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>
Junio C Hamano committed
Jul 8, 2008 at 17:31 UTC
e84fb2ff75f861a708ea5a914883e178a845f4ef
1 file changed
+8
-4
builtin-branch.c
+8
-4
@@ -438,13 +438,17 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
438
OPT_BOOLEAN( 0 , "color", &branch_use_color, "use colored output"),
439
OPT_SET_INT('r', NULL, &kinds, "act on remote-tracking branches",
440
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
+ },
447
{
448
OPTION_CALLBACK, 0, "with", &with_commit, "commit",
449
"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",
452
},
453
OPT__ABBREV(&abbrev),
454