Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-09 00:27:51 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-09 00:27:51 +0300
commitc47b89cde6e81e03a642186df90ff8b372a5bcdd (patch)
treeb3b2c2de95d4befb7c3438dc15bd9c46cc34cffb
parentb8117d2c082019928f1bccd2341dc08093496442 (diff)
parent41c64ae0e762d2c4ef1ddd578b8992967547dc5f (diff)
Merge branch 'jc/show-branch-g-current' into maint
The "--current" option of "git show-branch" should have been made incompatible with the "--reflog" mode, but this was not enforced, which has been corrected. source: <xmqqh76mf7s4.fsf_-_@gitster.g> * jc/show-branch-g-current: show-branch: -g and --current are incompatible
-rw-r--r--builtin/show-branch.c4
-rwxr-xr-xt/t3202-show-branch.sh14
2 files changed, 18 insertions, 0 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 330b0553b9..64c649c6a2 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -712,6 +712,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
"--all/--remotes/--independent/--merge-base");
}
+ if (with_current_branch && reflog)
+ die(_("options '%s' and '%s' cannot be used together"),
+ "--reflog", "--current");
+
/* If nothing is specified, show all branches by default */
if (ac <= topics && all_heads + all_remotes == 0)
all_heads = 1;
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 7a1be73ce8..f2b9199007 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -161,4 +161,18 @@ test_expect_success 'show branch --reflog=2' '
test_cmp actual expect
'
+# incompatible options
+while read combo
+do
+ test_expect_success "show-branch $combo (should fail)" '
+ test_must_fail git show-branch $combo 2>error &&
+ grep -e "cannot be used together" -e "usage:" error
+ '
+done <<\EOF
+--all --reflog
+--merge-base --reflog
+--list --merge-base
+--reflog --current
+EOF
+
test_done