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

[PATCH v2] branch: honor core.abbrev

From
Namhyung Kim <namhyung@gmail.com>
Date
Jul 1, 2011, 06:06 UTC
Message-ID
<1309500368-3729-1-git-send-email-namhyung@gmail.com>
In-Reply-To
<20110630181020.GA1128@elie>

Honor 'core.abbrev' configuration unless user specifies the length on command line. In order to do that, we need to set 'abbrev' to DEFAULT_ABBREV after config and command line parsing done.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
Sorry for my bad English and thanks for pointing this out. :)
 Documentation/git-branch.txt |    3 ++-
 builtin/branch.c             |    5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index c50f189..507b8d0 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -113,7 +113,8 @@ OPTIONS
 
 --abbrev=<length>::
 	Alter the sha1's minimum display length in the output listing.
-	The default value is 7.
+	The default value is 7 and can be overridden by the `core.abbrev`
+	config option.
 
 --no-abbrev::
 	Display the full sha1s in the output listing rather than abbreviating them.
diff --git a/builtin/branch.c b/builtin/branch.c
index d6ab93b..5a15022 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -613,7 +613,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 verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
+	int verbose = 0, abbrev = -1, detached = 0;
 	int reflog = 0;
 	enum branch_track track;
 	int kinds = REF_LOCAL_BRANCH;
@@ -696,6 +696,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 	if (!!delete + !!rename + !!force_create > 1)
 		usage_with_options(builtin_branch_usage, options);
 
+	if (abbrev == -1)
+		abbrev = DEFAULT_ABBREV;
+
 	if (delete)
 		return delete_branches(argc, argv, delete > 1, kinds);
 	else if (argc == 0)
-- 
1.7.6
Previous: Jonathan NiederNext: Junio C Hamano
Message 3 of 8 in “branch: honor core.abbrev”
  1. branch: honor core.abbrevNamhyung Kim, Jun 30, 2011
  2. Jonathan NiederJun 30, 2011
  3. branch: honor core.abbrevNamhyung Kim, Jul 1, 2011
  4. Junio C HamanoJul 1, 2011
  5. Jonathan NiederJul 1, 2011
  6. Jonathan NiederJul 2, 2011
  7. Andreas SchwabJun 30, 2011
  8. Namhyung KimJul 1, 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.