Skip to content

Commit c47b89c

Browse files
committed
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: <[email protected]> * jc/show-branch-g-current: show-branch: -g and --current are incompatible
2 parents b8117d2 + 41c64ae commit c47b89c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

builtin/show-branch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
712712
"--all/--remotes/--independent/--merge-base");
713713
}
714714

715+
if (with_current_branch && reflog)
716+
die(_("options '%s' and '%s' cannot be used together"),
717+
"--reflog", "--current");
718+
715719
/* If nothing is specified, show all branches by default */
716720
if (ac <= topics && all_heads + all_remotes == 0)
717721
all_heads = 1;

t/t3202-show-branch.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,18 @@ test_expect_success 'show branch --reflog=2' '
161161
test_cmp actual expect
162162
'
163163

164+
# incompatible options
165+
while read combo
166+
do
167+
test_expect_success "show-branch $combo (should fail)" '
168+
test_must_fail git show-branch $combo 2>error &&
169+
grep -e "cannot be used together" -e "usage:" error
170+
'
171+
done <<\EOF
172+
--all --reflog
173+
--merge-base --reflog
174+
--list --merge-base
175+
--reflog --current
176+
EOF
177+
164178
test_done

0 commit comments

Comments
 (0)