Skip to content

Commit e84fb2f

Browse files
committed
branch --contains: default to HEAD
We used to require the name of the commit to limit the branches shown to the --contains option, but more recent --merged/--no-meregd defaults to HEAD (and they do not allow arbitrary commit, which is a separate issue). This teaches --contains to default to HEAD when no parameter is given. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1cc6985 commit e84fb2f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

builtin-branch.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,17 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
438438
OPT_BOOLEAN( 0 , "color", &branch_use_color, "use colored output"),
439439
OPT_SET_INT('r', NULL, &kinds, "act on remote-tracking branches",
440440
REF_REMOTE_BRANCH),
441-
OPT_CALLBACK(0, "contains", &with_commit, "commit",
442-
"print only branches that contain the commit",
443-
opt_parse_with_commit),
441+
{
442+
OPTION_CALLBACK, 0, "contains", &with_commit, "commit",
443+
"print only branches that contain the commit",
444+
PARSE_OPT_LASTARG_DEFAULT,
445+
opt_parse_with_commit, (intptr_t)"HEAD",
446+
},
444447
{
445448
OPTION_CALLBACK, 0, "with", &with_commit, "commit",
446449
"print only branches that contain the commit",
447-
PARSE_OPT_HIDDEN, opt_parse_with_commit,
450+
PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,
451+
opt_parse_with_commit, (intptr_t) "HEAD",
448452
},
449453
OPT__ABBREV(&abbrev),
450454

0 commit comments

Comments
 (0)