[PATCH] describe: add tests for unusual graphs
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 --- 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
Re: [PATCH] describe: add tests for unusual graphs
Quinn Grier 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.
Re: [PATCH] describe: add tests for unusual graphs
On 2016-12-09 17:12, Junio C Hamano wrote: > Quinn Grier 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.