From: Quinn Grier <quinn@quinngrier.com>
To: git@vger.kernel.org
Cc: Quinn Grier <quinn@quinngrier.com>
Subject: [PATCH] describe: add tests for unusual graphs
Date: Fri, 9 Dec 2016 07:11:41 -0600 [thread overview]
Message-ID: <20161209131141.3096-1-quinn@quinngrier.com> (raw)
git describe may give incorrect results if there are backdated commits
or multiple roots. This commit adds two test_expect_failure tests that
demonstrate these problems.
Signed-off-by: Quinn Grier <quinn@quinngrier.com>
---
t/t6120-describe.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 85f2694..ca82837 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -206,4 +206,52 @@ test_expect_success 'describe --contains with the exact tags' '
test_cmp expect actual
'
+#
+# A---B*--D master
+# \ /
+# .---C topic
+#
+
+test_expect_failure 'backdated commit' '(
+ test_tick &&
+ b=$GIT_COMMITTER_DATE && test_tick &&
+ test_create_repo backdated-commit &&
+ cd backdated-commit &&
+ git commit --allow-empty -m A && test_tick &&
+ GIT_COMMITTER_DATE=$b git commit --allow-empty -m B && test_tick &&
+ git checkout -b topic :/A &&
+ git commit --allow-empty -m C && test_tick &&
+ git checkout master &&
+ git merge -m D topic && test_tick &&
+ git tag -m B B :/B && test_tick &&
+ git describe :/D >tmp &&
+ sed s/-g.\*// tmp >actual &&
+ echo B-2 >expected &&
+ test_cmp expected actual
+)'
+
+#
+# A---B*--D master
+# /
+# C* other
+#
+
+test_expect_failure 'multiple roots' '(
+ test_tick &&
+ test_create_repo multiple-roots &&
+ cd multiple-roots &&
+ git commit --allow-empty -m A && test_tick &&
+ git commit --allow-empty -m B && test_tick &&
+ git checkout --orphan other &&
+ git commit --allow-empty -m C && test_tick &&
+ git checkout master &&
+ git merge --allow-unrelated-histories -m D other && test_tick &&
+ git tag -m B B :/B && test_tick &&
+ git tag -m C C :/C && test_tick &&
+ git describe :/D >tmp &&
+ sed s/-g.\*// tmp >actual &&
+ echo B-2 >expected &&
+ test_cmp expected actual
+)'
+
test_done
--
2.8.3
next reply other threads:[~2016-12-09 13:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-09 13:11 Quinn Grier [this message]
2016-12-09 23:12 ` [PATCH] describe: add tests for unusual graphs Junio C Hamano
2016-12-10 6:47 ` Quinn Grier
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=20161209131141.3096-1-quinn@quinngrier.com \
--to=quinn@quinngrier.com \
--cc=git@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).