All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Namhyung Kim <namhyung@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] branch: honor core.abbrev
Date: Thu, 30 Jun 2011 13:10:20 -0500	[thread overview]
Message-ID: <20110630181020.GA1128@elie> (raw)
In-Reply-To: <1309449762-10476-1-git-send-email-namhyung@gmail.com>

Namhyung Kim wrote:

> --- 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/.

> --- 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

  reply	other threads:[~2011-06-30 18:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 16:02 [PATCH] branch: honor core.abbrev Namhyung Kim
2011-06-30 18:10 ` Jonathan Nieder [this message]
2011-07-01  6:06   ` [PATCH v2] " Namhyung Kim
2011-07-01 18:21     ` Junio C Hamano
2011-07-01 19:05       ` Jonathan Nieder
2011-07-02  1:32   ` [PATCH] " Jonathan Nieder
2011-06-30 18:27 ` Andreas Schwab
2011-07-01  6:10   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110630181020.GA1128@elie \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=namhyung@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.