From e3ddd3b5e583e62d874f56f8c88603ad0ebafd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 25 Apr 2019 16:45:51 +0700 Subject: restore: reject invalid combinations with --staged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano diff --git a/builtin/checkout.c b/builtin/checkout.c index e855c64..71e2589 100644 --- 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"); + 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; -- cgit v0.10.2-6-g49f6