path: root/t
diff options
authorJunio C Hamano <>2020-03-27 00:11:21 (GMT)
committerJunio C Hamano <>2020-03-27 00:11:21 (GMT)
commit0f0625a630081d532d528d87ba236a6385bbbac1 (patch)
treee6c3e6c57219732b8165105970590a7d09cec91d /t
parentfb4175b0e4bec59b97dae84a0073d8a5334508d6 (diff)
parentff165f00c1065d94c0bcab8708364e6dc5655f5d (diff)
Merge branch 'jc/describe-misnamed-annotated-tag'
When "git describe C" finds an annotated tag with tagname A to be the best name to explain commit C, and the tag is stored in a "wrong" place in the refs/tags hierarchy, e.g. refs/tags/B, the command gave a warning message but used A (not B) to describe C. If C is exactly at the tag, the describe output would be "A", but "git rev-parse A^0" would not be equal as "git rev-parse C^0". The behavior of the command has been changed to use the "long" form i.e. A-0-gOBJECTNAME, which is correctly interpreted by rev-parse. * jc/describe-misnamed-annotated-tag: describe: force long format for a name based on a mislocated tag
Diffstat (limited to 't')
1 files changed, 19 insertions, 1 deletions
diff --git a/t/ b/t/
index 34502e3..f822d5d 100755
--- a/t/
+++ b/t/
@@ -129,12 +129,30 @@ test_expect_success 'rename tag A to Q locally' '
mv .git/refs/tags/A .git/refs/tags/Q
cat - >err.expect <<EOF
-warning: tag 'A' is really 'Q' here
+warning: tag 'Q' is externally known as 'A'
check_describe A-* HEAD
test_expect_success 'warning was displayed for Q' '
test_i18ncmp err.expect err.actual
+test_expect_success 'misnamed annotated tag forces long output' '
+ description=$(git describe --no-long Q^0) &&
+ expr "$description" : "A-0-g[0-9a-f]*$" &&
+ git rev-parse --verify "$description" >actual &&
+ git rev-parse --verify Q^0 >expect &&
+ test_cmp expect actual
+test_expect_success 'abbrev=0 will not break misplaced tag (1)' '
+ description=$(git describe --abbrev=0 Q^0) &&
+ expr "$description" : "A-0-g[0-9a-f]*$"
+test_expect_success 'abbrev=0 will not break misplaced tag (2)' '
+ description=$(git describe --abbrev=0 c^0) &&
+ expr "$description" : "A-1-g[0-9a-f]*$"
test_expect_success 'rename tag Q back to A' '
mv .git/refs/tags/Q .git/refs/tags/A