restore: reject invalid combinations with --staged
git-checkout rejects plenty of invalid option combinations. Since git-checkout is equivalent of either git restore --source --staged --worktree or git restore --worktree that still leaves the new mode 'git restore --index' unprotected. Reject some more invalid option combinations. The other new mode 'restore --source --worktree' does not need anything else. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Apr 25, 2019 at 16:45 UTC
e3ddd3b5e583e62d874f56f8c88603ad0ebafd5e
1 file changed
+10
builtin/checkout.c
+10
@@ -433,6 +433,16 @@ static int checkout_paths(const struct checkout_opts *opts,
433
die(_("'%s' must be used when '%s' is not specified"),
434
"--worktree", "--source");
435
436
+ if (opts->checkout_index && !opts->checkout_worktree &&
437
+ opts->writeout_stage)
438
+ die(_("'%s' or '%s' cannot be used with %s"),
439
+ "--ours", "--theirs", "--staged");
440
+
441
+ if (opts->checkout_index && !opts->checkout_worktree &&
442
+ opts->merge)
443
+ die(_("'%s' or '%s' cannot be used with %s"),
444
+ "--merge", "--conflict", "--staged");
445
+
446
if (opts->patch_mode) {
447
const char *patch_mode;
448