Re: [PATCH 1/1] commit-graph: fix bug around octopus merges
Derrick Stolee via GitGitGadget
Junio C Hamano
Derrick Stolee
See Also
Prev Ref 1
2019-08-06 09:21:59 UTC
On Mon, Aug 05, 2019 at 09:43:41AM -0700, Derrick Stolee via GitGitGadget wrote:

> In such a case, the reading
> process outputs the following message to stderr:
> 	warning: commit-graph chain does not match
> These warnings are output in the test suite, but ignored. By
> checking the stderr of `git commit-graph verify` to include
> the expected progress output, it will now catch this error.

There should be a better way to check this than relying on the number
of progress lines, e.g. 'git commit-graph verify' could print
something specific, like "Verified 3 commit-graph files, all OK", to
its standard output, and the test should check only that.  Or check
only that there is no warning on standard error.

On one hand, see the recent commits 077b979891 (t3404: make the
'rebase.missingCommitsCheck=ignore' test more focused, 2019-06-24) and
bb431c3dad (t3420: remove progress lines before comparing output,
2019-07-04), where we started to exclude the progress output from
verification in tests like this that are not specifically about
progress output.

On the other hand, one of my fun side-projects is to run some
semi-automated and souped-up CI builds of currently cooking topics,
which include a custom GETTEXT_POISON mode [1], where the poisoned
translated progress output in this new test looks like this [2]:

  V.e.r.i.f.y.i.n.g. .c.o.m.m.i.t.s. .i.n. .c.o.m.m.i.t. .g.r.a.p.h.: 100% (1/1),  d.o.n.e..
  V.e.r.i.f.y.i.n.g. .c.o.m.m.i.t.s. .i.n. .c.o.m.m.i.t. .g.r.a.p.h.: 100% (5/5),  d.o.n.e..
  V.e.r.i.f.y.i.n.g. .c.o.m.m.i.t.s. .i.n. .c.o.m.m.i.t. .g.r.a.p.h.:
    100% (12/12),  d.o.n.e..

So this makes the progress lines almost twice as long, and as the last
commit-graph file contains double-digit commits, the length of the
progress line just happens to exceed the width of a 80 character
terminal, and gets line wrapped.  This throws off the line count
check, as there are now 4 lines on standard error instead of the
expected 3.

    Note that the highlighted line is in the 'after failure' fold, and
    your browser might unhelpfully fold it up before you could take a
    good look.

> diff --git a/t/ b/t/
> index 03f45a1ed9..99f4ef4c19 100755
> --- a/t/
> +++ b/t/
> @@ -319,7 +319,9 @@ test_expect_success 'add octopus merge' '
>  	git merge commits/3 commits/4 &&
>  	git branch merge/octopus &&
>  	git commit-graph write --reachable --split &&
> -	git commit-graph verify &&
> +	git commit-graph verify 2>err &&
> +	test_line_count = 3 err &&
> +	test_i18ngrep ! warning err &&
>  	test_line_count = 3 $graphdir/commit-graph-chain
>  '
> -- 
> gitgitgadget