type-git 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ import {
19
19
  validatePathInput,
20
20
  validateRevParseQuery,
21
21
  validateRevParseRefOpts
22
- } from "./chunk-UAKOSACD.js";
22
+ } from "./chunk-SXHFNCJZ.js";
23
23
 
24
24
  // src/core/clone-config.ts
25
25
  var HTTP_VARIABLES = [
@@ -159,6 +159,22 @@ function checkedRefSortKey(command, value) {
159
159
  }
160
160
  return value;
161
161
  }
162
+ function checkedRevision(command, name, value) {
163
+ if (value === "") {
164
+ throw new GitArgumentError(
165
+ `${command}: ${name} must not be empty; Git rejects an empty revision.`
166
+ );
167
+ }
168
+ return checkedOperand(command, name, value);
169
+ }
170
+ function checkedOptionValue(command, name, value) {
171
+ if (value === "") {
172
+ throw new GitArgumentError(
173
+ `${command}: ${name} must not be empty; Git rejects an empty value here.`
174
+ );
175
+ }
176
+ return value;
177
+ }
162
178
 
163
179
  // src/core/untrusted-repo.ts
164
180
  var UNTRUSTED_REPO_MIN_GIT_VERSION = "2.38.0";
@@ -973,8 +989,8 @@ var BareRepoImpl = class {
973
989
  if (opts?.refsOnly) {
974
990
  args.push("--refs");
975
991
  }
976
- if (opts?.sort) {
977
- args.push("--sort", opts.sort);
992
+ if (opts?.sort !== void 0) {
993
+ args.push("--sort", checkedOptionValue("lsRemote", "sort", opts.sort));
978
994
  }
979
995
  args.push(checkedOperand("lsRemote", "remote", remote));
980
996
  if (opts?.refs && opts.refs.length > 0) {
@@ -1091,7 +1107,7 @@ var BareRepoImpl = class {
1091
1107
  async remoteAdd(name, url, opts) {
1092
1108
  validateOptions("remoteAdd", opts);
1093
1109
  const args = ["remote", "add"];
1094
- if (opts?.track) {
1110
+ if (opts?.track !== void 0) {
1095
1111
  args.push("-t", opts.track);
1096
1112
  }
1097
1113
  if (opts?.fetch) {
@@ -1166,8 +1182,14 @@ var BareRepoImpl = class {
1166
1182
  args.push("--delete");
1167
1183
  }
1168
1184
  args.push(checkedOperand("remote.setHead", "remote", remote));
1169
- if (branch && !opts?.auto && !opts?.delete) {
1170
- args.push(checkedOperand("remote.setHead", "branch", branch));
1185
+ if (branch !== void 0 && !opts?.auto && !opts?.delete) {
1186
+ args.push(
1187
+ checkedOperand(
1188
+ "remote.setHead",
1189
+ "branch",
1190
+ checkedOptionValue("remote.setHead", "branch", branch)
1191
+ )
1192
+ );
1171
1193
  }
1172
1194
  await this.runner.runOrThrow(this.context, args, {
1173
1195
  signal: opts?.signal
@@ -1616,8 +1638,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
1616
1638
  if (opts?.refsOnly) {
1617
1639
  args.push("--refs");
1618
1640
  }
1619
- if (opts?.sort) {
1620
- args.push("--sort", opts.sort);
1641
+ if (opts?.sort !== void 0) {
1642
+ args.push("--sort", checkedOptionValue("lsRemote", "sort", opts.sort));
1621
1643
  }
1622
1644
  args.push(checkedOperand("lsRemote", "remote", remote));
1623
1645
  if (opts?.refs && opts.refs.length > 0) {
@@ -1792,19 +1814,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
1792
1814
  if (opts?.skip !== void 0) {
1793
1815
  args.push(`--skip=${opts.skip}`);
1794
1816
  }
1795
- if (opts?.since) {
1817
+ if (opts?.since !== void 0) {
1796
1818
  const since = opts.since instanceof Date ? opts.since.toISOString() : opts.since;
1797
1819
  args.push(`--since=${since}`);
1798
1820
  }
1799
- if (opts?.after) {
1821
+ if (opts?.after !== void 0) {
1800
1822
  const after = opts.after instanceof Date ? opts.after.toISOString() : opts.after;
1801
1823
  args.push(`--after=${after}`);
1802
1824
  }
1803
- if (opts?.until) {
1825
+ if (opts?.until !== void 0) {
1804
1826
  const until = opts.until instanceof Date ? opts.until.toISOString() : opts.until;
1805
1827
  args.push(`--until=${until}`);
1806
1828
  }
1807
- if (opts?.before) {
1829
+ if (opts?.before !== void 0) {
1808
1830
  const before = opts.before instanceof Date ? opts.before.toISOString() : opts.before;
1809
1831
  args.push(`--before=${before}`);
1810
1832
  }
@@ -1835,8 +1857,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
1835
1857
  if (opts?.reverse) {
1836
1858
  args.push("--reverse");
1837
1859
  }
1838
- if (opts?.ref) {
1839
- args.push(checkedOperand("log", "ref", opts.ref));
1860
+ if (opts?.ref !== void 0) {
1861
+ args.push(checkedRevision("log", "ref", opts.ref));
1840
1862
  }
1841
1863
  const result = await this.runner.runOrThrow(this.context, args, {
1842
1864
  signal: opts?.signal
@@ -2288,8 +2310,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2288
2310
  const patterns = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude];
2289
2311
  args.push("--exclude", patterns.join(","));
2290
2312
  }
2291
- if (opts?.ref) {
2292
- args.push(checkedOperand("lfs.lsFiles", "ref", opts.ref));
2313
+ if (opts?.ref !== void 0) {
2314
+ args.push(checkedRevision("lfs.lsFiles", "ref", opts.ref));
2293
2315
  }
2294
2316
  const result = await this.runner.runOrThrow(this.context, args, {
2295
2317
  signal: opts?.signal
@@ -2675,8 +2697,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2675
2697
  args.push("-b", opts.branch);
2676
2698
  }
2677
2699
  args.push(checkedOperand("worktree.add", "path", path));
2678
- if (opts?.commitish) {
2679
- args.push(checkedOperand("worktree.add", "commitish", opts.commitish));
2700
+ if (opts?.commitish !== void 0) {
2701
+ args.push(checkedRevision("worktree.add", "commitish", opts.commitish));
2680
2702
  }
2681
2703
  await this.runner.runOrThrow(this.context, args, {
2682
2704
  signal: opts?.signal,
@@ -2702,8 +2724,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2702
2724
  if (opts?.verbose) {
2703
2725
  args.push("--verbose");
2704
2726
  }
2705
- if (opts?.expire) {
2706
- args.push(`--expire=${opts.expire}`);
2727
+ if (opts?.expire !== void 0) {
2728
+ args.push(`--expire=${checkedOptionValue("worktree.prune", "expire", opts.expire)}`);
2707
2729
  }
2708
2730
  const result = await this.runner.runOrThrow(this.context, args, {
2709
2731
  signal: opts?.signal
@@ -2795,7 +2817,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2795
2817
  if (opts?.chmod) {
2796
2818
  args.push(`--chmod=${opts.chmod}`);
2797
2819
  }
2798
- if (opts?.pathspecFromFile) {
2820
+ if (opts?.pathspecFromFile !== void 0) {
2799
2821
  args.push(`--pathspec-from-file=${opts.pathspecFromFile}`);
2800
2822
  }
2801
2823
  const pathList = Array.isArray(paths) ? paths : [paths];
@@ -2822,26 +2844,28 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2822
2844
  if (opts?.quiet) {
2823
2845
  args.push("--quiet");
2824
2846
  }
2825
- if (opts?.contains) {
2826
- args.push(`--contains=${opts.contains}`);
2847
+ if (opts?.contains !== void 0) {
2848
+ args.push(`--contains=${checkedOptionValue("branch.list", "contains", opts.contains)}`);
2827
2849
  }
2828
- if (opts?.noContains) {
2829
- args.push(`--no-contains=${opts.noContains}`);
2850
+ if (opts?.noContains !== void 0) {
2851
+ args.push(
2852
+ `--no-contains=${checkedOptionValue("branch.list", "noContains", opts.noContains)}`
2853
+ );
2830
2854
  }
2831
2855
  if (opts?.abbrev !== void 0) {
2832
2856
  args.push(`--abbrev=${opts.abbrev}`);
2833
2857
  }
2834
- if (opts?.merged) {
2835
- args.push(`--merged=${opts.merged}`);
2858
+ if (opts?.merged !== void 0) {
2859
+ args.push(`--merged=${checkedOptionValue("branch.list", "merged", opts.merged)}`);
2836
2860
  }
2837
- if (opts?.noMerged) {
2838
- args.push(`--no-merged=${opts.noMerged}`);
2861
+ if (opts?.noMerged !== void 0) {
2862
+ args.push(`--no-merged=${checkedOptionValue("branch.list", "noMerged", opts.noMerged)}`);
2839
2863
  }
2840
2864
  if (opts?.sort !== void 0) {
2841
2865
  args.push(`--sort=${checkedRefSortKey("branch.list", opts.sort)}`);
2842
2866
  }
2843
- if (opts?.pointsAt) {
2844
- args.push(`--points-at=${opts.pointsAt}`);
2867
+ if (opts?.pointsAt !== void 0) {
2868
+ args.push(`--points-at=${checkedOptionValue("branch.list", "pointsAt", opts.pointsAt)}`);
2845
2869
  }
2846
2870
  if (opts?.ignoreCase) {
2847
2871
  args.push("--ignore-case");
@@ -2899,8 +2923,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2899
2923
  }
2900
2924
  args.push(checkedOperand("branch.create", "name", name));
2901
2925
  checkedNewBranchName("branch.create", "name", name);
2902
- if (opts?.startPoint) {
2903
- args.push(checkedOperand("branch.create", "startPoint", opts.startPoint));
2926
+ if (opts?.startPoint !== void 0) {
2927
+ args.push(checkedRevision("branch.create", "startPoint", opts.startPoint));
2904
2928
  }
2905
2929
  await this.runner.runOrThrow(this.context, args, {
2906
2930
  signal: opts?.signal
@@ -2973,11 +2997,11 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2973
2997
  if (pathOpts?.theirs) {
2974
2998
  args.push("--theirs");
2975
2999
  }
2976
- if (pathOpts?.pathspecFromFile) {
3000
+ if (pathOpts?.pathspecFromFile !== void 0) {
2977
3001
  args.push(`--pathspec-from-file=${pathOpts.pathspecFromFile}`);
2978
3002
  }
2979
- if (pathOpts?.source) {
2980
- args.push(checkedOperand("checkout", "source", pathOpts.source));
3003
+ if (pathOpts?.source !== void 0) {
3004
+ args.push(checkedRevision("checkout", "source", pathOpts.source));
2981
3005
  }
2982
3006
  args.push("--");
2983
3007
  args.push(...targetOrPaths);
@@ -3025,8 +3049,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3025
3049
  args.push("--ignore-other-worktrees");
3026
3050
  }
3027
3051
  args.push(checkedOperand("checkout", "target", targetOrPaths));
3028
- if (branchOpts?.startPoint) {
3029
- args.push(checkedOperand("checkout", "startPoint", branchOpts.startPoint));
3052
+ if (branchOpts?.startPoint !== void 0) {
3053
+ args.push(checkedRevision("checkout", "startPoint", branchOpts.startPoint));
3030
3054
  }
3031
3055
  }
3032
3056
  await this.runner.runOrThrow(this.context, args, {
@@ -3041,7 +3065,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3041
3065
  validateOptions("commit", opts);
3042
3066
  validateInput("commitPaths", { ...opts }, "commit");
3043
3067
  const args = ["commit"];
3044
- if (opts?.message) {
3068
+ if (opts?.message !== void 0) {
3045
3069
  args.push("-m", opts.message);
3046
3070
  }
3047
3071
  if (opts?.allowEmpty) {
@@ -3053,12 +3077,12 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3053
3077
  if (opts?.all) {
3054
3078
  args.push("-a");
3055
3079
  }
3056
- if (opts?.author) {
3080
+ if (opts?.author !== void 0) {
3057
3081
  args.push("--author", opts.author);
3058
3082
  }
3059
- if (opts?.date) {
3083
+ if (opts?.date !== void 0) {
3060
3084
  const date = opts.date instanceof Date ? opts.date.toISOString() : opts.date;
3061
- args.push("--date", date);
3085
+ args.push("--date", checkedOptionValue("commit", "date", date));
3062
3086
  }
3063
3087
  if (opts?.noVerify) {
3064
3088
  args.push("--no-verify");
@@ -3075,17 +3099,17 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3075
3099
  if (opts?.verbose) {
3076
3100
  args.push("--verbose");
3077
3101
  }
3078
- if (opts?.file) {
3079
- args.push("--file", opts.file);
3102
+ if (opts?.file !== void 0) {
3103
+ args.push("--file", checkedOptionValue("commit", "file", opts.file));
3080
3104
  }
3081
- if (opts?.reuseMessage) {
3082
- args.push("--reuse-message", opts.reuseMessage);
3105
+ if (opts?.reuseMessage !== void 0) {
3106
+ args.push("--reuse-message", checkedOptionValue("commit", "reuseMessage", opts.reuseMessage));
3083
3107
  }
3084
- if (opts?.fixup) {
3085
- args.push("--fixup", opts.fixup);
3108
+ if (opts?.fixup !== void 0) {
3109
+ args.push("--fixup", checkedOptionValue("commit", "fixup", opts.fixup));
3086
3110
  }
3087
- if (opts?.squash) {
3088
- args.push("--squash", opts.squash);
3111
+ if (opts?.squash !== void 0) {
3112
+ args.push("--squash", checkedOptionValue("commit", "squash", opts.squash));
3089
3113
  }
3090
3114
  if (opts?.resetAuthor) {
3091
3115
  args.push("--reset-author");
@@ -3114,7 +3138,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3114
3138
  if (opts?.untrackedFiles) {
3115
3139
  args.push(`--untracked-files=${opts.untrackedFiles}`);
3116
3140
  }
3117
- if (opts?.pathspecFromFile) {
3141
+ if (opts?.pathspecFromFile !== void 0) {
3118
3142
  args.push(`--pathspec-from-file=${opts.pathspecFromFile}`);
3119
3143
  }
3120
3144
  if (opts?.allowEmptyMessage) {
@@ -3245,8 +3269,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3245
3269
  if (opts?.renameLimit !== void 0) {
3246
3270
  args.push(`-l${opts.renameLimit}`);
3247
3271
  }
3248
- if (opts?.pickaxe) {
3249
- args.push(`-S${opts.pickaxe}`);
3272
+ if (opts?.pickaxe !== void 0) {
3273
+ args.push(...opts.pickaxe === "" ? ["-S", ""] : [`-S${opts.pickaxe}`]);
3250
3274
  }
3251
3275
  if (opts?.pickaxeAll) {
3252
3276
  args.push("--pickaxe-all");
@@ -3260,8 +3284,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3260
3284
  if (opts?.wordDiff) {
3261
3285
  args.push(`--word-diff=${opts.wordDiff}`);
3262
3286
  }
3263
- if (target) {
3264
- args.push(checkedOperand("diff", "target", target));
3287
+ if (target !== void 0) {
3288
+ args.push(checkedRevision("diff", "target", target));
3265
3289
  }
3266
3290
  if (opts?.paths && opts.paths.length > 0) {
3267
3291
  args.push("--", ...opts.paths);
@@ -3319,7 +3343,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3319
3343
  return { success: true };
3320
3344
  }
3321
3345
  const args = ["merge"];
3322
- if (opts?.message) {
3346
+ if (opts?.message !== void 0) {
3323
3347
  args.push("-m", opts.message);
3324
3348
  }
3325
3349
  if (opts?.ff === "only") {
@@ -3333,8 +3357,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3333
3357
  if (opts?.noCommit) {
3334
3358
  args.push("--no-commit");
3335
3359
  }
3336
- if (opts?.strategy) {
3337
- args.push("-s", opts.strategy);
3360
+ if (opts?.strategy !== void 0) {
3361
+ args.push("-s", checkedOptionValue("merge", "strategy", opts.strategy));
3338
3362
  }
3339
3363
  if (opts?.strategyOption) {
3340
3364
  const strategyOpts = Array.isArray(opts.strategyOption) ? opts.strategyOption : [opts.strategyOption];
@@ -3394,7 +3418,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3394
3418
  if (opts?.signoff) {
3395
3419
  args.push("--signoff");
3396
3420
  }
3397
- if (opts?.intoName) {
3421
+ if (opts?.intoName !== void 0) {
3398
3422
  args.push(`--into-name=${opts.intoName}`);
3399
3423
  }
3400
3424
  args.push(checkedOperand("merge", "branch", branch));
@@ -3505,8 +3529,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3505
3529
  if (opts?.autostash) {
3506
3530
  args.push("--autostash");
3507
3531
  }
3508
- if (opts?.strategy) {
3509
- args.push(`--strategy=${opts.strategy}`);
3532
+ if (opts?.strategy !== void 0) {
3533
+ args.push(`--strategy=${checkedOptionValue("pull", "strategy", opts.strategy)}`);
3510
3534
  }
3511
3535
  if (opts?.strategyOption) {
3512
3536
  const strategyOpts = Array.isArray(opts.strategyOption) ? opts.strategyOption : [opts.strategyOption];
@@ -3573,10 +3597,12 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3573
3597
  if (opts?.setUpstream) {
3574
3598
  args.push("--set-upstream");
3575
3599
  }
3576
- if (opts?.remote) {
3577
- args.push(checkedOperand("pull", "remote", opts.remote));
3600
+ if (opts?.remote !== void 0) {
3601
+ args.push(
3602
+ checkedOperand("pull", "remote", checkedOptionValue("pull", "remote", opts.remote))
3603
+ );
3578
3604
  }
3579
- if (opts?.branch) {
3605
+ if (opts?.branch !== void 0) {
3580
3606
  args.push(checkedOperand("pull", "branch", opts.branch));
3581
3607
  }
3582
3608
  await this.runner.runOrThrow(this.context, args, {
@@ -3612,11 +3638,11 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3612
3638
  if (opts?.intentToAdd) {
3613
3639
  args.push("--intent-to-add");
3614
3640
  }
3615
- if (opts?.pathspecFromFile) {
3641
+ if (opts?.pathspecFromFile !== void 0) {
3616
3642
  args.push(`--pathspec-from-file=${opts.pathspecFromFile}`);
3617
3643
  }
3618
- if (target) {
3619
- args.push(checkedOperand("reset", "target", target), "--");
3644
+ if (target !== void 0) {
3645
+ args.push(checkedRevision("reset", "target", target), "--");
3620
3646
  }
3621
3647
  await this.runner.runOrThrow(this.context, args, {
3622
3648
  signal: opts?.signal,
@@ -3647,7 +3673,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3647
3673
  if (opts?.sparse) {
3648
3674
  args.push("--sparse");
3649
3675
  }
3650
- if (opts?.pathspecFromFile) {
3676
+ if (opts?.pathspecFromFile !== void 0) {
3651
3677
  args.push(`--pathspec-from-file=${opts.pathspecFromFile}`);
3652
3678
  }
3653
3679
  const pathList = Array.isArray(paths) ? paths : [paths];
@@ -3707,7 +3733,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3707
3733
  if (opts?.all) {
3708
3734
  args.push("--all");
3709
3735
  }
3710
- if (opts?.pathspecFromFile) {
3736
+ if (opts?.pathspecFromFile !== void 0) {
3711
3737
  args.push(`--pathspec-from-file=${opts.pathspecFromFile}`);
3712
3738
  }
3713
3739
  if (opts?.paths && opts.paths.length > 0) {
@@ -3819,8 +3845,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3819
3845
  } else {
3820
3846
  args.push(target);
3821
3847
  }
3822
- if (opts?.startPoint) {
3823
- args.push(checkedOperand("switch", "startPoint", opts.startPoint));
3848
+ if (opts?.startPoint !== void 0) {
3849
+ args.push(checkedRevision("switch", "startPoint", opts.startPoint));
3824
3850
  }
3825
3851
  await this.runner.runOrThrow(this.context, args, {
3826
3852
  signal: opts?.signal,
@@ -3832,31 +3858,31 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3832
3858
  // ==========================================================================
3833
3859
  async tagList(opts) {
3834
3860
  const args = ["tag", "--list"];
3835
- if (opts?.sort) {
3836
- args.push(`--sort=${opts.sort}`);
3861
+ if (opts?.sort !== void 0) {
3862
+ args.push(`--sort=${checkedOptionValue("tag.list", "sort", opts.sort)}`);
3837
3863
  }
3838
3864
  if (opts?.lines !== void 0) {
3839
3865
  args.push(`-n${opts.lines}`);
3840
3866
  }
3841
- if (opts?.contains) {
3842
- args.push(`--contains=${opts.contains}`);
3867
+ if (opts?.contains !== void 0) {
3868
+ args.push(`--contains=${checkedOptionValue("tag.list", "contains", opts.contains)}`);
3843
3869
  }
3844
- if (opts?.noContains) {
3845
- args.push(`--no-contains=${opts.noContains}`);
3870
+ if (opts?.noContains !== void 0) {
3871
+ args.push(`--no-contains=${checkedOptionValue("tag.list", "noContains", opts.noContains)}`);
3846
3872
  }
3847
- if (opts?.merged) {
3848
- args.push(`--merged=${opts.merged}`);
3873
+ if (opts?.merged !== void 0) {
3874
+ args.push(`--merged=${checkedOptionValue("tag.list", "merged", opts.merged)}`);
3849
3875
  }
3850
- if (opts?.noMerged) {
3851
- args.push(`--no-merged=${opts.noMerged}`);
3876
+ if (opts?.noMerged !== void 0) {
3877
+ args.push(`--no-merged=${checkedOptionValue("tag.list", "noMerged", opts.noMerged)}`);
3852
3878
  }
3853
- if (opts?.pointsAt) {
3854
- args.push(`--points-at=${opts.pointsAt}`);
3879
+ if (opts?.pointsAt !== void 0) {
3880
+ args.push(`--points-at=${checkedOptionValue("tag.list", "pointsAt", opts.pointsAt)}`);
3855
3881
  }
3856
3882
  if (opts?.ignoreCase) {
3857
3883
  args.push("--ignore-case");
3858
3884
  }
3859
- if (opts?.pattern) {
3885
+ if (opts?.pattern !== void 0) {
3860
3886
  args.push(checkedOperand("tag.list", "pattern", opts.pattern));
3861
3887
  }
3862
3888
  const result = await this.runner.runOrThrow(this.context, args, {
@@ -3894,15 +3920,15 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3894
3920
  if (opts?.cleanup) {
3895
3921
  args.push(`--cleanup=${opts.cleanup}`);
3896
3922
  }
3897
- if (opts?.localUser) {
3923
+ if (opts?.localUser !== void 0) {
3898
3924
  args.push(`--local-user=${opts.localUser}`);
3899
3925
  }
3900
3926
  if (opts?.createReflog) {
3901
3927
  args.push("--create-reflog");
3902
3928
  }
3903
3929
  args.push(checkedOperand("tag.create", "name", name));
3904
- if (opts?.commit) {
3905
- args.push(checkedOperand("tag.create", "commit", opts.commit));
3930
+ if (opts?.commit !== void 0) {
3931
+ args.push(checkedRevision("tag.create", "commit", opts.commit));
3906
3932
  }
3907
3933
  await this.runner.runOrThrow(this.context, args, {
3908
3934
  signal: opts?.signal
@@ -3986,6 +4012,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3986
4012
  async cherryPick(commits, opts) {
3987
4013
  const control = opts?.abort || opts?.continue || opts?.skip;
3988
4014
  const commitList = control ? [] : checkedOperands("cherryPick", "commits", Array.isArray(commits) ? commits : [commits]);
4015
+ if (opts?.strategy !== void 0) {
4016
+ checkedOptionValue("cherryPick", "strategy", opts.strategy);
4017
+ }
3989
4018
  await this.runner.validateMainlineOptions(this.context, "cherryPick", opts, {
3990
4019
  signal: opts?.signal
3991
4020
  });
@@ -4011,7 +4040,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4011
4040
  if (opts?.mainline !== void 0) {
4012
4041
  args.push("-m", opts.mainline.toString());
4013
4042
  }
4014
- if (opts?.strategy) {
4043
+ if (opts?.strategy !== void 0) {
4015
4044
  args.push("--strategy", opts.strategy);
4016
4045
  }
4017
4046
  if (opts?.cleanup) {
@@ -4144,8 +4173,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4144
4173
  if (opts?.skip) {
4145
4174
  args.push("--skip");
4146
4175
  }
4147
- if (opts?.onto) {
4148
- args.push("--onto", opts.onto);
4176
+ if (opts?.onto !== void 0) {
4177
+ args.push("--onto", checkedOptionValue("rebase", "onto", opts.onto));
4149
4178
  }
4150
4179
  if (opts?.rebaseMerges) {
4151
4180
  args.push("--rebase-merges");
@@ -4230,8 +4259,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4230
4259
  } else if (opts?.forkPoint === false) {
4231
4260
  args.push("--no-fork-point");
4232
4261
  }
4233
- if (opts?.strategy) {
4234
- args.push("--strategy", opts.strategy);
4262
+ if (opts?.strategy !== void 0) {
4263
+ args.push("--strategy", checkedOptionValue("rebase", "strategy", opts.strategy));
4235
4264
  }
4236
4265
  if (opts?.strategyOption) {
4237
4266
  const strategyOptions = Array.isArray(opts.strategyOption) ? opts.strategyOption : [opts.strategyOption];
@@ -4252,8 +4281,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4252
4281
  } else if (opts?.reapplyCherryPicks === false) {
4253
4282
  args.push("--no-reapply-cherry-picks");
4254
4283
  }
4255
- if (opts?.upstream) {
4256
- args.push(checkedOperand("rebase", "upstream", opts.upstream));
4284
+ if (opts?.upstream !== void 0) {
4285
+ args.push(checkedRevision("rebase", "upstream", opts.upstream));
4257
4286
  }
4258
4287
  await this.runner.runOrThrow(this.context, args, {
4259
4288
  signal: opts?.signal,
@@ -4279,8 +4308,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4279
4308
  if (opts?.worktree) {
4280
4309
  args.push("--worktree");
4281
4310
  }
4282
- if (opts?.source) {
4283
- args.push("--source", opts.source);
4311
+ if (opts?.source !== void 0) {
4312
+ args.push("--source", checkedOptionValue("restore", "source", opts.source));
4284
4313
  }
4285
4314
  if (opts?.ours) {
4286
4315
  args.push("--ours");
@@ -4318,7 +4347,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4318
4347
  if (opts?.ignoreSkipWorktreeBits) {
4319
4348
  args.push("--ignore-skip-worktree-bits");
4320
4349
  }
4321
- if (opts?.pathspecFromFile) {
4350
+ if (opts?.pathspecFromFile !== void 0) {
4322
4351
  args.push("--pathspec-from-file", opts.pathspecFromFile);
4323
4352
  }
4324
4353
  const pathList = Array.isArray(paths) ? paths : [paths];
@@ -4334,6 +4363,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4334
4363
  async revert(commits, opts) {
4335
4364
  const control = opts?.abort || opts?.continue || opts?.skip;
4336
4365
  const commitList = control ? [] : checkedOperands("revert", "commits", Array.isArray(commits) ? commits : [commits]);
4366
+ if (opts?.strategy !== void 0) {
4367
+ checkedOptionValue("revert", "strategy", opts.strategy);
4368
+ }
4337
4369
  await this.runner.validateMainlineOptions(this.context, "revert", opts, {
4338
4370
  signal: opts?.signal
4339
4371
  });
@@ -4367,7 +4399,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4367
4399
  } else if (opts?.rerereAutoupdate === false) {
4368
4400
  args.push("--no-rerere-autoupdate");
4369
4401
  }
4370
- if (opts?.strategy) {
4402
+ if (opts?.strategy !== void 0) {
4371
4403
  args.push("--strategy", opts.strategy);
4372
4404
  }
4373
4405
  if (opts?.strategyOption) {
@@ -4406,7 +4438,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4406
4438
  if (opts?.nameStatus) {
4407
4439
  args.push("--name-status");
4408
4440
  }
4409
- if (opts?.format) {
4441
+ if (opts?.format !== void 0) {
4410
4442
  args.push(`--format=${opts.format}`);
4411
4443
  }
4412
4444
  if (opts?.quiet) {
@@ -4418,10 +4450,10 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4418
4450
  if (opts?.useMailmap) {
4419
4451
  args.push("--use-mailmap");
4420
4452
  }
4421
- if (opts?.decorateRefs) {
4453
+ if (opts?.decorateRefs !== void 0) {
4422
4454
  args.push("--decorate-refs", opts.decorateRefs);
4423
4455
  }
4424
- if (opts?.decorateRefsExclude) {
4456
+ if (opts?.decorateRefsExclude !== void 0) {
4425
4457
  args.push("--decorate-refs-exclude", opts.decorateRefsExclude);
4426
4458
  }
4427
4459
  if (opts?.decorate) {
@@ -4588,8 +4620,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4588
4620
  */
4589
4621
  async revListCount(ref, opts) {
4590
4622
  const args = ["rev-list", "--count"];
4591
- if (ref) {
4592
- args.push(checkedOperand("revListCount", "ref", ref));
4623
+ if (ref !== void 0) {
4624
+ args.push(checkedRevision("revListCount", "ref", ref));
4593
4625
  } else {
4594
4626
  args.push("HEAD");
4595
4627
  }
@@ -4708,14 +4740,14 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4708
4740
  if (opts?.recommendShallow) {
4709
4741
  args.push("--recommend-shallow");
4710
4742
  }
4711
- if (opts?.reference) {
4743
+ if (opts?.reference !== void 0) {
4712
4744
  args.push(`--reference=${opts.reference}`);
4713
4745
  }
4714
4746
  if (opts?.singleBranch) {
4715
4747
  args.push("--single-branch");
4716
4748
  }
4717
- if (opts?.filter) {
4718
- args.push(`--filter=${opts.filter}`);
4749
+ if (opts?.filter !== void 0) {
4750
+ args.push(`--filter=${checkedOptionValue("submodule.update", "filter", opts.filter)}`);
4719
4751
  }
4720
4752
  await this.runner.runOrThrow(this.context, args, {
4721
4753
  signal: opts?.signal
@@ -4723,17 +4755,17 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4723
4755
  }
4724
4756
  async submoduleAdd(url, path, opts) {
4725
4757
  const args = ["submodule", "add"];
4726
- if (opts?.branch) {
4727
- args.push("-b", opts.branch);
4758
+ if (opts?.branch !== void 0) {
4759
+ args.push("-b", checkedOptionValue("submodule.add", "branch", opts.branch));
4728
4760
  }
4729
4761
  if (opts?.force) {
4730
4762
  args.push("--force");
4731
4763
  }
4732
- if (opts?.name) {
4733
- args.push("--name", opts.name);
4764
+ if (opts?.name !== void 0) {
4765
+ args.push("--name", checkedOptionValue("submodule.add", "name", opts.name));
4734
4766
  }
4735
- if (opts?.reference) {
4736
- args.push("--reference", opts.reference);
4767
+ if (opts?.reference !== void 0) {
4768
+ args.push("--reference", checkedOptionValue("submodule.add", "reference", opts.reference));
4737
4769
  }
4738
4770
  if (opts?.depth !== void 0) {
4739
4771
  args.push("--depth", String(opts.depth));
@@ -4876,7 +4908,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4876
4908
  async remoteAdd(name, url, opts) {
4877
4909
  validateOptions("remoteAdd", opts);
4878
4910
  const args = ["remote", "add"];
4879
- if (opts?.track) {
4911
+ if (opts?.track !== void 0) {
4880
4912
  args.push("-t", opts.track);
4881
4913
  }
4882
4914
  if (opts?.fetch) {
@@ -4953,8 +4985,14 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4953
4985
  args.push("--delete");
4954
4986
  }
4955
4987
  args.push(checkedOperand("remote.setHead", "remote", remote));
4956
- if (branch && !opts?.auto && !opts?.delete) {
4957
- args.push(checkedOperand("remote.setHead", "branch", branch));
4988
+ if (branch !== void 0 && !opts?.auto && !opts?.delete) {
4989
+ args.push(
4990
+ checkedOperand(
4991
+ "remote.setHead",
4992
+ "branch",
4993
+ checkedOptionValue("remote.setHead", "branch", branch)
4994
+ )
4995
+ );
4958
4996
  }
4959
4997
  await this.runner.runOrThrow(this.context, args, {
4960
4998
  signal: opts?.signal
@@ -5538,7 +5576,7 @@ var GitImpl = class {
5538
5576
  if (opts?.bare) {
5539
5577
  args.push("--bare");
5540
5578
  }
5541
- if (opts?.template) {
5579
+ if (opts?.template !== void 0) {
5542
5580
  args.push("--template", opts.template);
5543
5581
  }
5544
5582
  if (opts?.shared !== void 0) {
@@ -5552,14 +5590,22 @@ var GitImpl = class {
5552
5590
  args.push(`--shared=${opts.shared}`);
5553
5591
  }
5554
5592
  }
5555
- if (opts?.initialBranch && await this.supportsInitialBranch()) {
5556
- args.push("--initial-branch", opts.initialBranch);
5593
+ const initialBranch = opts?.initialBranch;
5594
+ const separateGitDir = opts?.separateGitDir;
5595
+ if (initialBranch !== void 0) {
5596
+ checkedOptionValue("init", "initialBranch", initialBranch);
5597
+ }
5598
+ if (separateGitDir !== void 0) {
5599
+ checkedOptionValue("init", "separateGitDir", separateGitDir);
5600
+ }
5601
+ if (initialBranch && await this.supportsInitialBranch()) {
5602
+ args.push("--initial-branch", initialBranch);
5557
5603
  }
5558
5604
  if (opts?.objectFormat) {
5559
5605
  args.push("--object-format", opts.objectFormat);
5560
5606
  }
5561
- if (opts?.separateGitDir) {
5562
- args.push("--separate-git-dir", opts.separateGitDir);
5607
+ if (separateGitDir !== void 0) {
5608
+ args.push("--separate-git-dir", separateGitDir);
5563
5609
  }
5564
5610
  args.push(checkedOperand("init", "path", path));
5565
5611
  const destinationExisted = await this.adapters.fs.exists(path);
@@ -5569,11 +5615,11 @@ var GitImpl = class {
5569
5615
  signal: opts?.signal,
5570
5616
  onProgress: opts?.onProgress
5571
5617
  });
5572
- if (opts?.initialBranch && !await this.supportsInitialBranch()) {
5618
+ if (initialBranch && !await this.supportsInitialBranch()) {
5573
5619
  const context = opts?.bare ? { type: "bare", gitDir: path } : { type: "worktree", workdir: path };
5574
5620
  await this.runner.runOrThrow(
5575
5621
  context,
5576
- ["symbolic-ref", "HEAD", `refs/heads/${opts.initialBranch}`],
5622
+ ["symbolic-ref", "HEAD", `refs/heads/${initialBranch}`],
5577
5623
  {
5578
5624
  signal: opts?.signal
5579
5625
  }
@@ -5605,8 +5651,8 @@ var GitImpl = class {
5605
5651
  if (opts?.refs) {
5606
5652
  args.push("--refs");
5607
5653
  }
5608
- if (opts?.sort) {
5609
- args.push("--sort", opts.sort);
5654
+ if (opts?.sort !== void 0) {
5655
+ args.push("--sort", checkedOptionValue("lsRemote", "sort", opts.sort));
5610
5656
  }
5611
5657
  args.push(checkedOperand("lsRemote", "url", url));
5612
5658
  const result = await this.runner.runOrThrow({ type: "global" }, args, {