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

Re: [PATCH] branch: honor core.abbrev

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 30, 2011, 18:10 UTC
Message-ID
<20110630181020.GA1128@elie>
In-Reply-To
<1309449762-10476-1-git-send-email-namhyung@gmail.com>
Namhyung Kim wrote:
Show 7 quoted lines
> --- a/Documentation/git-branch.txt
> +++ b/Documentation/git-branch.txt
> @@ -114,6 +114,7 @@ OPTIONS
>  --abbrev=<length>::
>  	Alter the sha1's minimum display length in the output listing.
>  	The default value is 7.
> +	(and can be overrided by the `core.abbrev` config option).
Nitpicks: this would be clearer without the period after "7" and without
the parentheses around the following phrase.  s/overrided/overridden/.
Show 8 quoted lines
> --- 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;
Yes.  (One meaningful "c89 -pedantic" warning down, several to go.)

Some squashable tests follow. Maybe they can be useful. Thanks for fixing this.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 t/t3203-branch-output.sh |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
diff --git i/t/t3203-branch-output.sh w/t/t3203-branch-output.sh
index 6b7c118e..87333b49 100755
--- i/t/t3203-branch-output.sh
+++ w/t/t3203-branch-output.sh
@@ -3,6 +3,17 @@
 test_description='git branch display tests'
 . ./test-lib.sh
 
+minimum_line_length () {
+	awk '
+		BEGIN { minlen = 99 }
+		{
+			if (length($1) < minlen)
+				minlen = length($1)
+		}
+		END { print minlen }
+	'
+}
+
 test_expect_success 'make commits' '
 	echo content >file &&
 	git add file &&
@@ -66,6 +77,24 @@ test_expect_success 'git branch -v shows branch summaries' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git branch -v --abbrev' '
+	echo 10 >expect &&
+	git branch -v --abbrev=10 >tmp &&
+	awk "{print \$(NF - 1)}" <tmp >commitids &&
+	minimum_line_length <commitids >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git branch -v respects [core] abbrev configuration' '
+	git config core.abbrev 9 &&
+	test_when_finished "git config --unset core.abbrev" &&
+	echo 9 >expect &&
+	git branch -v >tmp &&
+	awk "{print \$(NF - 1)}" <tmp >commitids &&
+	minimum_line_length <commitids >actual &&
+	test_cmp expect actual
+'
+
 cat >expect <<'EOF'
 * (no branch)
   branch-one
Previous: Namhyung KimNext: Namhyung Kim
Message 2 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.