Skip to content

Commit 492cf3f

Browse files
gislegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c3baa9 commit 492cf3f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Documentation/git-describe.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ OPTIONS
4444

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

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

7476
--match <pattern>::
7577
Only consider tags matching the given pattern (can be used to avoid
@@ -108,7 +110,7 @@ the output shows the reference path as well:
108110
[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
109111
tags/v1.0.0-21-g975b
110112

111-
[torvalds@g5 git]$ git describe --all HEAD^
113+
[torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
112114
heads/lt/describe-7-g975b
113115

114116
With --abbrev set to 0, the command can be used to find the
@@ -117,6 +119,13 @@ closest tagname without any suffix:
117119
[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
118120
tags/v1.0.0
119121

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

0 commit comments

Comments
 (0)