Skip to content

Commit

Permalink
restore: reject invalid combinations with --staged
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pclouds authored and gitster committed May 7, 2019
1 parent 183fb44 commit e3ddd3b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,16 @@ static int checkout_paths(const struct checkout_opts *opts,
die(_("'%s' must be used when '%s' is not specified"),
"--worktree", "--source");

if (opts->checkout_index && !opts->checkout_worktree &&
opts->writeout_stage)
die(_("'%s' or '%s' cannot be used with %s"),
"--ours", "--theirs", "--staged");

if (opts->checkout_index && !opts->checkout_worktree &&
opts->merge)
die(_("'%s' or '%s' cannot be used with %s"),
"--merge", "--conflict", "--staged");

if (opts->patch_mode) {
const char *patch_mode;

Expand Down

0 comments on commit e3ddd3b

Please sign in to comment.