git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] describe: add tests for unusual graphs
@ 2016-12-09 13:11 Quinn Grier
  2016-12-09 23:12 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Quinn Grier @ 2016-12-09 13:11 UTC (permalink / raw)
  To: git; +Cc: Quinn Grier

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] describe: add tests for unusual graphs
  2016-12-09 13:11 [PATCH] describe: add tests for unusual graphs Quinn Grier
@ 2016-12-09 23:12 ` Junio C Hamano
  2016-12-10  6:47   ` Quinn Grier
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2016-12-09 23:12 UTC (permalink / raw)
  To: Quinn Grier; +Cc: git

Quinn Grier <quinn@quinngrier.com> writes:

> 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.

I am not sure if this is a good patch to take.  test_expect_failure
is to demonstrate an incorrect behaviour that we wish to correct
later, but I do not think these demonstrate incorrect behaviours to
begin with.

For example, the latter one seems to expect that by asking to
describe D in this picture

> +#
> +# A---B*--D master
> +#        /
> +#       C* other
> +#

you seem to expect the description is based on B.  

It is not at all clear why it is incorrect if the description were
made based on C.  If D were described relative to A, ignoring B,
then I understand why that result is incorrect and I would agree
that describing D in terms of B is more correct.  But I do not think
that is what the test is trying to demonstrate.

But it is hard to guess only from looking at the test and the
proposed log message, because it does not say what makes you think
the behaviour you saw was incorrect.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] describe: add tests for unusual graphs
  2016-12-09 23:12 ` Junio C Hamano
@ 2016-12-10  6:47   ` Quinn Grier
  0 siblings, 0 replies; 3+ messages in thread
From: Quinn Grier @ 2016-12-10  6:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 2016-12-09 17:12, Junio C Hamano wrote:
> Quinn Grier <quinn@quinngrier.com> writes:
> 
>> 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.
> 
> I am not sure if this is a good patch to take.  test_expect_failure
> is to demonstrate an incorrect behaviour that we wish to correct
> later, but I do not think these demonstrate incorrect behaviours to
> begin with.
> 
> For example, the latter one seems to expect that by asking to
> describe D in this picture
> 
>> +#
>> +# A---B*--D master
>> +#        /
>> +#       C* other
>> +#
> 
> you seem to expect the description is based on B.  
> 
> It is not at all clear why it is incorrect if the description were
> made based on C.  If D were described relative to A, ignoring B,
> then I understand why that result is incorrect and I would agree
> that describing D in terms of B is more correct.  But I do not think
> that is what the test is trying to demonstrate.
> 
> But it is hard to guess only from looking at the test and the
> proposed log message, because it does not say what makes you think
> the behaviour you saw was incorrect.
> 

I thought the behavior was incorrect because of the following paragraph
from the documentation for git describe:

      If multiple tags were found during the walk then the tag
      which has the fewest commits different from the input
      commit-ish will be selected and output. Here fewest commits
      different is defined as the number of commits which would be
      shown by git log tag..input will be the smallest number of
      commits possible.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-10  6:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-09 13:11 [PATCH] describe: add tests for unusual graphs Quinn Grier
2016-12-09 23:12 ` Junio C Hamano
2016-12-10  6:47   ` Quinn Grier

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).