git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] branch --contains: default to HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 9, 2008, 01:17 UTC
Message-ID
<7vr6a3onyr.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<7vvdzfoo1s.fsf@gitster.siamese.dyndns.org>

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>
---
 * This comes on top of the FAKELASTARG patch
 builtin-branch.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index d279702..375e5e0 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -438,13 +438,17 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		OPT_BOOLEAN( 0 , "color",  &branch_use_color, "use colored output"),
 		OPT_SET_INT('r', NULL,     &kinds, "act on remote-tracking branches",
 			REF_REMOTE_BRANCH),
-		OPT_CALLBACK(0, "contains", &with_commit, "commit",
-			     "print only branches that contain the commit",
-			     opt_parse_with_commit),
+		{
+			OPTION_CALLBACK, 0, "contains", &with_commit, "commit",
+			"print only branches that contain the commit",
+			PARSE_OPT_FAKELASTARG,
+			opt_parse_with_commit, (intptr_t)"HEAD",
+		},
 		{
 			OPTION_CALLBACK, 0, "with", &with_commit, "commit",
 			"print only branches that contain the commit",
-			PARSE_OPT_HIDDEN, opt_parse_with_commit,
+			PARSE_OPT_HIDDEN | PARSE_OPT_FAKELASTARG,
+			opt_parse_with_commit, (intptr_t) "HEAD",
 		},
 		OPT__ABBREV(&abbrev),
 
-- 
1.5.6.2.255.gbed62
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 9 in “What should "git branch --merged master" do?”
  1. Junio C HamanoJul 8, 2008
  2. Pierre HabouzitJul 8, 2008
  3. parse-options: add PARSE_OPT_FAKELASTARG flag.Pierre Habouzit, Jul 8, 2008
  4. Junio C HamanoJul 9, 2008
  5. 1/2 branch --contains: default to HEADJunio C Hamano, Jul 9, 2008
  6. 2/2 branch --merged/--not-merged: allow specifying arbitrary commitJunio C Hamano, Jul 9, 2008
  7. Pierre HabouzitJul 9, 2008
  8. Junio C HamanoJul 9, 2008
  9. Pierre HabouzitJul 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.