From 353c5f45c11601bcb47f2c736e3ba13eee050f4e Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Tue, 11 Sep 2012 15:32:32 +0200 Subject: [PATCH] describe: document and test --first-parent --- Documentation/git-describe.txt | 16 +++++++++++++++- t/t6120-describe.sh | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index 3c81e85ec5..429788b740 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -85,6 +85,10 @@ OPTIONS excluding the "refs/tags/" prefix. This can be used to avoid leaking private tags from the repository. +--first-parent:: + Only consider tags which can be reached from '' by a first + parent walk, i.e. only those which are not on side branches. + --always:: Show uniquely abbreviated commit object as fallback. @@ -130,6 +134,14 @@ closest tagname without any suffix: [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 tags/v1.0.0 +With --first-parent, tags on side branches are not considered: + + git describe v1.1.0^ + v1.0.7-44-ge77f489 + + git describe --first-parent v1.1.0^ + v1.0.0-41-ge77f489 + Note that the suffix you get if you type these commands today may be longer than what Linus saw above when he ran these commands, as your Git repository may have new commits whose object names begin with @@ -149,7 +161,9 @@ is found, its name will be output and searching will stop. If an exact match was not found, 'git describe' will walk back through the commit history to locate an ancestor commit which has been tagged. The ancestor's tag will be output along with an -abbreviation of the input committish's SHA1. +abbreviation of the input committish's SHA1. With '--first-parent', +'git describe' will walk the history only along the first parent +of each commit. If multiple tags were found during the walk then the tag which has the fewest commits different from the input committish will be diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index f67aa6ff6a..2524236776 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -103,6 +103,13 @@ check_describe c-* --tags HEAD^^2 check_describe B --tags HEAD^^2^ check_describe e --tags HEAD^^^ +check_describe R-* --first-parent HEAD +check_describe R-* --first-parent HEAD^ +check_describe R-* --first-parent HEAD^^ +check_describe B-* --first-parent HEAD^^2 +check_describe B --first-parent HEAD^^2^ +check_describe R-* --first-parent HEAD^^^ + check_describe heads/master --all HEAD check_describe tags/c-* --all HEAD^ check_describe tags/e --all HEAD^^^ -- 2.11.4.GIT