1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 12:26:12 +02:00

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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2019-04-25 16:45:51 +07:00 committed by Junio C Hamano
parent 183fb44fd2
commit e3ddd3b5e5

View File

@ -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;