[PATCH] describe: add tests for unusual graphs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]