Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
restore: reject invalid combinations with --staged
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Thu, 25 Apr 2019 09:45:51 +0000
(16:45 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 7 May 2019 04:04:47 +0000
(13:04 +0900)
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>
builtin/checkout.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
183fb44
)
diff --git
a/builtin/checkout.c
b/builtin/checkout.c
index e855c64cfef6e470386fc828ab62e338a56743da..71e25893408fce5d6992f8535ee7895cf3dfcaa0 100644
(file)
--- a/
builtin/checkout.c
+++ b/
builtin/checkout.c
@@
-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");
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;
if (opts->patch_mode) {
const char *patch_mode;