Skip to content

Commit e3ddd3b

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 183fb44 commit e3ddd3b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

builtin/checkout.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,16 @@ static int checkout_paths(const struct checkout_opts *opts,
433433
die(_("'%s' must be used when '%s' is not specified"),
434434
"--worktree", "--source");
435435

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+
436446
if (opts->patch_mode) {
437447
const char *patch_mode;
438448

0 commit comments

Comments
 (0)