# [PATCH] More precise description of 'git describe --abbrev'

8 messages from 2009-10-29 to 2009-11-04. Participants: Gisle Aas, Junio C Hamano, Andreas Schwab.
Thread: https://gitlist.dev/t/21428

## Gisle Aas, 2009-10-29 21:38

Subject: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <b48ea8a00910291438r8b66a0fq9e821393ecfff0bf@mail.gmail.com>
URL: https://gitlist.dev/e/b48ea8a00910291438r8b66a0fq9e821393ecfff0bf%40mail.gmail.com

```
Also make the examples show what 'git describe' actually outputs
currently.  I guess the default --abbrev value has been changed from 4
to 7 at some point.

Signed-off-by: Gisle Aas <gisle@aas.no>
---
 Documentation/git-describe.txt |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index b231dbb..743eb95 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -44,7 +44,9 @@ OPTIONS

 --abbrev=<n>::
 	Instead of using the default 7 hexadecimal digits as the
-	abbreviated object name, use <n> digits.
+	abbreviated object name, use <n> digits or as many digits
+	are needed to form a unique object name.  An <n> of 0
+	will suppress long format, only showing the closest tag.

 --candidates=<n>::
 	Instead of considering only the 10 most recent tags as
@@ -68,8 +70,8 @@ OPTIONS
 	This is useful when you want to see parts of the commit object name
 	in "describe" output, even when the commit in question happens to be
 	a tagged version.  Instead of just emitting the tag name, it will
-	describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2
-	that points at object deadbeef....).
+	describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
+	that points at object deadbee....).

 --match <pattern>::
 	Only consider tags matching the given pattern (can be used to avoid
@@ -106,10 +108,10 @@ With --all, the command can use branch heads as
references, so
 the output shows the reference path as well:

 	[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
-	tags/v1.0.0-21-g975b
+	tags/v1.0.0-21-g975b3

 	[torvalds@g5 git]$ git describe --all HEAD^
-	heads/lt/describe-7-g975b
+	heads/lt/describe-7-g975b31d

 With --abbrev set to 0, the command can be used to find the
 closest tagname without any suffix:
-- 
1.6.2.95.g934f7

```

## Junio C Hamano, 2009-10-29 22:47

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <7vws2d4y3d.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vws2d4y3d.fsf%40alter.siamese.dyndns.org
In-Reply-To: <b48ea8a00910291438r8b66a0fq9e821393ecfff0bf@mail.gmail.com>

```
Gisle Aas <gisle@aas.no> writes:

> Also make the examples show what 'git describe' actually outputs
> currently.  I guess the default --abbrev value has been changed from 4
> to 7 at some point.

Some are good changes, but I do not think the example with --abbrev=4 is.

$ git describe 975bf9cf5ad5d440f98f464ae8124609a4835ce1
v1.3.2-216-g975bf9c
$ git describe 975b31dc6e12fba8f7b067ddbe32230995e05400
v1.0.0-21-g975b31d

Next time somebody adds a new object whose name happens to begin with
975b3 you would need to update the example output.

> Signed-off-by: Gisle Aas <gisle@aas.no>
> ---
>  Documentation/git-describe.txt |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
> index b231dbb..743eb95 100644
> --- a/Documentation/git-describe.txt
> +++ b/Documentation/git-describe.txt
> @@ -44,7 +44,9 @@ OPTIONS
>
>  --abbrev=<n>::
>  	Instead of using the default 7 hexadecimal digits as the
> -	abbreviated object name, use <n> digits.
> +	abbreviated object name, use <n> digits or as many digits
> +	are needed to form a unique object name.  An <n> of 0
> +	will suppress long format, only showing the closest tag.
>
>  --candidates=<n>::
>  	Instead of considering only the 10 most recent tags as
> @@ -68,8 +70,8 @@ OPTIONS
>  	This is useful when you want to see parts of the commit object name
>  	in "describe" output, even when the commit in question happens to be
>  	a tagged version.  Instead of just emitting the tag name, it will
> -	describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2
> -	that points at object deadbeef....).
> +	describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
> +	that points at object deadbee....).
>
>  --match <pattern>::
>  	Only consider tags matching the given pattern (can be used to avoid
> @@ -106,10 +108,10 @@ With --all, the command can use branch heads as
> references, so
>  the output shows the reference path as well:
>
>  	[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
> -	tags/v1.0.0-21-g975b
> +	tags/v1.0.0-21-g975b3
>
>  	[torvalds@g5 git]$ git describe --all HEAD^
> -	heads/lt/describe-7-g975b
> +	heads/lt/describe-7-g975b31d
>
>  With --abbrev set to 0, the command can be used to find the
>  closest tagname without any suffix:
> -- 
> 1.6.2.95.g934f7

```

## Gisle Aas, 2009-10-30 08:01

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <b48ea8a00910300101i38f2e4a8q2c2e014d2df1a150@mail.gmail.com>
URL: https://gitlist.dev/e/b48ea8a00910300101i38f2e4a8q2c2e014d2df1a150%40mail.gmail.com
In-Reply-To: <7vws2d4y3d.fsf@alter.siamese.dyndns.org>

```
On Thu, Oct 29, 2009 at 23:47, Junio C Hamano <gitster@pobox.com> wrote:
> Gisle Aas <gisle@aas.no> writes:
>
>> Also make the examples show what 'git describe' actually outputs
>> currently.  I guess the default --abbrev value has been changed from 4
>> to 7 at some point.
>
> Some are good changes, but I do not think the example with --abbrev=4 is.
>
> $ git describe 975bf9cf5ad5d440f98f464ae8124609a4835ce1
> v1.3.2-216-g975bf9c
> $ git describe 975b31dc6e12fba8f7b067ddbe32230995e05400
> v1.0.0-21-g975b31d
>
> Next time somebody adds a new object whose name happens to begin with
> 975b3 you would need to update the example output.

Yeah, I know, but I don't think that's a big deal.  So do you want an
updated patch for that?  We could either simply remove this example or
make it use --abbrev=10 or something like that.

--Gisle


>
>> Signed-off-by: Gisle Aas <gisle@aas.no>
>> ---
>>  Documentation/git-describe.txt |   12 +++++++-----
>>  1 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
>> index b231dbb..743eb95 100644
>> --- a/Documentation/git-describe.txt
>> +++ b/Documentation/git-describe.txt
>> @@ -44,7 +44,9 @@ OPTIONS
>>
>>  --abbrev=<n>::
>>       Instead of using the default 7 hexadecimal digits as the
>> -     abbreviated object name, use <n> digits.
>> +     abbreviated object name, use <n> digits or as many digits
>> +     are needed to form a unique object name.  An <n> of 0
>> +     will suppress long format, only showing the closest tag.
>>
>>  --candidates=<n>::
>>       Instead of considering only the 10 most recent tags as
>> @@ -68,8 +70,8 @@ OPTIONS
>>       This is useful when you want to see parts of the commit object name
>>       in "describe" output, even when the commit in question happens to be
>>       a tagged version.  Instead of just emitting the tag name, it will
>> -     describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2
>> -     that points at object deadbeef....).
>> +     describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
>> +     that points at object deadbee....).
>>
>>  --match <pattern>::
>>       Only consider tags matching the given pattern (can be used to avoid
>> @@ -106,10 +108,10 @@ With --all, the command can use branch heads as
>> references, so
>>  the output shows the reference path as well:
>>
>>       [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
>> -     tags/v1.0.0-21-g975b
>> +     tags/v1.0.0-21-g975b3
>>
>>       [torvalds@g5 git]$ git describe --all HEAD^
>> -     heads/lt/describe-7-g975b
>> +     heads/lt/describe-7-g975b31d
>>
>>  With --abbrev set to 0, the command can be used to find the
>>  closest tagname without any suffix:
>> --
>> 1.6.2.95.g934f7
>

```

## Junio C Hamano, 2009-10-30 19:00

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <7viqdwlnam.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7viqdwlnam.fsf%40alter.siamese.dyndns.org
In-Reply-To: <b48ea8a00910300101i38f2e4a8q2c2e014d2df1a150@mail.gmail.com>

```
Gisle Aas <gisle@aas.no> writes:

> On Thu, Oct 29, 2009 at 23:47, Junio C Hamano <gitster@pobox.com> wrote:
>> Gisle Aas <gisle@aas.no> writes:
>>
>>> Also make the examples show what 'git describe' actually outputs
>>> currently.  I guess the default --abbrev value has been changed from 4
>>> to 7 at some point.
>>
>> Some are good changes, but I do not think the example with --abbrev=4 is.
>>
>> $ git describe 975bf9cf5ad5d440f98f464ae8124609a4835ce1
>> v1.3.2-216-g975bf9c
>> $ git describe 975b31dc6e12fba8f7b067ddbe32230995e05400
>> v1.0.0-21-g975b31d
>>
>> Next time somebody adds a new object whose name happens to begin with
>> 975b3 you would need to update the example output.
>
> Yeah, I know, but I don't think that's a big deal.  So do you want an
> updated patch for that?  We could either simply remove this example or
> make it use --abbrev=10 or something like that.

Not touching the example would be the simplest.

Adding an explanation like this so that nobody will be tempted to "fix"
the example would be the best, I think.

     [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
     tags/v1.0.0-21-g975b

     Note that the suffix you get if you type this command today may be
     longer than what Linus saw above when he ran this command, as your
     git repository may have new commits whose object names begin with
     975b that did not exist back then, and "-g975b" suffix alone is not
     sufficient to disambiguate these commits.

```

## Gisle Aas, 2009-10-30 19:27

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <b48ea8a00910301227l4714eca9l767afd036938f494@mail.gmail.com>
URL: https://gitlist.dev/e/b48ea8a00910301227l4714eca9l767afd036938f494%40mail.gmail.com
In-Reply-To: <7viqdwlnam.fsf@alter.siamese.dyndns.org>

```
On Fri, Oct 30, 2009 at 20:00, Junio C Hamano <gitster@pobox.com> wrote:
> Adding an explanation like this so that nobody will be tempted to "fix"
> the example would be the best, I think.

Updated patch attached.

>
>     [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
>     tags/v1.0.0-21-g975b
>
>     Note that the suffix you get if you type this command today may be
>     longer than what Linus saw above when he ran this command, as your
>     git repository may have new commits whose object names begin with
>     975b that did not exist back then, and "-g975b" suffix alone is not
>     sufficient to disambiguate these commits.
>
>


From 5f6b405fa24861ae89207d334ea2e11f383a7e4e Mon Sep 17 00:00:00 2001
From: Gisle Aas <gisle@aas.no>
Date: Thu, 29 Oct 2009 22:29:35 +0100
Subject: [PATCH] More precise description of 'git describe --abbrev'

Also adds a note about why the output in the examples might give
different output today.

Signed-off-by: Gisle Aas <gisle@aas.no>
---
 Documentation/git-describe.txt |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index b231dbb..f8d91b1 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -44,7 +44,9 @@ OPTIONS
 
 --abbrev=<n>::
 	Instead of using the default 7 hexadecimal digits as the
-	abbreviated object name, use <n> digits.
+	abbreviated object name, use <n> digits or as many digits
+	are needed to form a unique object name.  An <n> of 0
+	will suppress long format, only showing the closest tag.
 
 --candidates=<n>::
 	Instead of considering only the 10 most recent tags as
@@ -68,8 +70,8 @@ OPTIONS
 	This is useful when you want to see parts of the commit object name
 	in "describe" output, even when the commit in question happens to be
 	a tagged version.  Instead of just emitting the tag name, it will
-	describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2
-	that points at object deadbeef....).
+	describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
+	that points at object deadbee....).
 
 --match <pattern>::
 	Only consider tags matching the given pattern (can be used to avoid
@@ -108,7 +110,7 @@ the output shows the reference path as well:
 	[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
 	tags/v1.0.0-21-g975b
 
-	[torvalds@g5 git]$ git describe --all HEAD^
+	[torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
 	heads/lt/describe-7-g975b
 
 With --abbrev set to 0, the command can be used to find the
@@ -117,6 +119,13 @@ closest tagname without any suffix:
 	[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
 	tags/v1.0.0
 
+Note that the suffix you get if you type these commands today may be
+longer than what Linus saw above when he ran this command, as your
+git repository may have new commits whose object names begin with
+975b that did not exist back then, and "-g975b" suffix alone is not
+sufficient to disambiguate these commits.
+
+
 SEARCH STRATEGY
 ---------------
 
-- 
1.6.2.95.g934f7


```

## Andreas Schwab, 2009-10-30 20:18

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <m2my38fxeo.fsf@igel.home>
URL: https://gitlist.dev/e/m2my38fxeo.fsf%40igel.home
In-Reply-To: <b48ea8a00910291438r8b66a0fq9e821393ecfff0bf@mail.gmail.com>

```
Gisle Aas <gisle@aas.no> writes:

> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
> index b231dbb..743eb95 100644
> --- a/Documentation/git-describe.txt
> +++ b/Documentation/git-describe.txt
> @@ -44,7 +44,9 @@ OPTIONS
>
>  --abbrev=<n>::
>  	Instead of using the default 7 hexadecimal digits as the
> -	abbreviated object name, use <n> digits.
> +	abbreviated object name, use <n> digits or as many digits
> +	are needed to form a unique object name.  An <n> of 0

"as many digits as needed"?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Junio C Hamano, 2009-10-30 21:53

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <7vmy38im51.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vmy38im51.fsf%40alter.siamese.dyndns.org
In-Reply-To: <m2my38fxeo.fsf@igel.home>

```
Andreas Schwab <schwab@linux-m68k.org> writes:

> Gisle Aas <gisle@aas.no> writes:
>
>> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
>> index b231dbb..743eb95 100644
>> --- a/Documentation/git-describe.txt
>> +++ b/Documentation/git-describe.txt
>> @@ -44,7 +44,9 @@ OPTIONS
>>
>>  --abbrev=<n>::
>>  	Instead of using the default 7 hexadecimal digits as the
>> -	abbreviated object name, use <n> digits.
>> +	abbreviated object name, use <n> digits or as many digits
>> +	are needed to form a unique object name.  An <n> of 0
>
> "as many digits as needed"?

Thanks; queued with this fix-up.

```

## Gisle Aas, 2009-11-04 22:04

Subject: Re: [PATCH] More precise description of 'git describe --abbrev'
Message-ID: <b48ea8a00911041404p2f176763kcc022249deab23a9@mail.gmail.com>
URL: https://gitlist.dev/e/b48ea8a00911041404p2f176763kcc022249deab23a9%40mail.gmail.com
In-Reply-To: <7vmy38im51.fsf@alter.siamese.dyndns.org>

```
Unfortunately there was still a grammar typo in that patch:

--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -120,7 +120,7 @@ closest tagname without any suffix:
        tags/v1.0.0

 Note that the suffix you get if you type these commands today may be
-longer than what Linus saw above when he ran this command, as your
+longer than what Linus saw above when he ran these commands, as your
 git repository may have new commits whose object names begin with
 975b that did not exist back then, and "-g975b" suffix alone may not
 be sufficient to disambiguate these commits.


From 8910eed48f0c4c53af1b74d0016ef772bdce5689 Mon Sep 17 00:00:00 2001
From: Gisle Aas <gisle@aas.no>
Date: Wed, 4 Nov 2009 22:57:46 +0100
Subject: [PATCH] Fix documentation grammar typo

Introduced in commit 492cf3f72f9d8...

Signed-off-by: Gisle Aas <gisle@aas.no>
---
 Documentation/git-describe.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index e9dbca7..2f97916 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -120,7 +120,7 @@ closest tagname without any suffix:
 	tags/v1.0.0
 
 Note that the suffix you get if you type these commands today may be
-longer than what Linus saw above when he ran this command, as your
+longer than what Linus saw above when he ran these commands, as your
 git repository may have new commits whose object names begin with
 975b that did not exist back then, and "-g975b" suffix alone may not
 be sufficient to disambiguate these commits.
-- 
1.6.2.95.g934f7


```
