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

[RFC/PATCH 2/2] branch: introduce --list argument

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Apr 27, 2011, 12:15 UTC
Message-ID
<90570cc5b04bf1f73833f365dc58a3d5ae200a21.1303906496.git.git@drmicha.warpmail.net>
In-Reply-To
<cover.1303906496.git.git@drmicha.warpmail.net>

Currently, there is no way to invoke the list mode with a pattern because this is interpreted as branch creation.

Introduce a --list argument which invokes the list mode.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin/branch.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 10292ab..4ccd89c 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -619,7 +619,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
 
 int cmd_branch(int argc, const char **argv, const char *prefix)
 {
-	int delete = 0, rename = 0, force_create = 0;
+	int delete = 0, rename = 0, force_create = 0, list = 0;
 	int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
 	int reflog = 0;
 	enum branch_track track;
@@ -658,6 +658,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		OPT_BIT('D', NULL, &delete, "delete branch (even if not merged)", 2),
 		OPT_BIT('m', NULL, &rename, "move/rename a branch and its reflog", 1),
 		OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
+		OPT_BOOLEAN(0, "list", &list, "list branch names"),
 		OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"),
 		OPT__FORCE(&force_create, "force creation (when already exists)"),
 		{
@@ -700,12 +701,15 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
 	argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
 			     0);
-	if (!!delete + !!rename + !!force_create > 1)
+	if (!!delete + !!rename + !!force_create + !!list > 1)
 		usage_with_options(builtin_branch_usage, options);
 
+	if (argc == 0 || (verbose && argc == 1))
+		list = 1;
+
 	if (delete)
 		return delete_branches(argc, argv, delete > 1, kinds);
-	else if (argc == 0 || (verbose && argc == 1))
+	else if (list)
 		return print_ref_list(kinds, detached, verbose, abbrev, with_commit, argc ? argv[0] : NULL);
 	else if (rename && (argc == 1))
 		rename_branch(head, argv[0], rename > 1);
-- 
1.7.5.270.gafca7
Previous: Michael J GruberNext: Junio C Hamano
Message 3 of 4 in “RFC/POC: patterns for branch list”
  1. 0/2 RFC/POC: patterns for branch listMichael J Gruber, Apr 27, 2011
  2. 1/2 branch: allow pattern argumentsMichael J Gruber, Apr 27, 2011
  3. 2/2 branch: introduce --list argumentMichael J Gruber, Apr 27, 2011
  4. Junio C HamanoApr 27, 2011

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.