git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] commit-graph tests: fix another graph_git_two_modes() helper

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 15, 2021, 16:15 UTC
Message-ID
<xmqqwnme8dsp.fsf@gitster.g>
In-Reply-To
<patch-2.3-d6934031882-20211014T233343Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 11 quoted lines
> In 135a7123755 (commit-graph: add --split option to builtin,
> 2019-06-18) this function was copy/pasted to the split commit-graph
> tests, as in the preceding commit we need to fix this to use
> &&-chaining, so it won't be hiding errors.
>
> Unlike its sister function in "t5318-commit-graph.sh", which we got
> lucky with, this one was hiding a real test failure. A tests added in
> c523035cbd8 (commit-graph: allow cross-alternate chains, 2019-06-18)
> has never worked as intended. Unlike most other graph_git_behavior
> uses in this file it clones the repository into a sub-directory, so
> we'll need to refer to "commits/6" as "origin/commits/6".

Interesting. The original created "fork" prepared the alternates structure in the preceding test, but tested the "behavour" of the commands outside the "fork" it just prepared?

Show 5 quoted lines
>  graph_git_two_modes() {
> -	git -c core.commitGraph=true $1 >output
> -	git -c core.commitGraph=false $1 >expect
> +	git ${2:+ -C "$2"} -c core.commitGraph=true $1 >output &&
> +	git ${2:+ -C "$2"} -c core.commitGraph=false $1 >expect &&

OK, it was a bit curious to see :+ (instead of just +), but the caller unconditionally passes "$DIR" (with double quotes), so it is understandable. Much more concise than having the caller to repeat ${4+"$4"} where it says "$DIR".

Show 34 quoted lines
>  	test_cmp expect output
>  }
>  
> @@ -64,12 +64,13 @@ graph_git_behavior() {
>  	MSG=$1
>  	BRANCH=$2
>  	COMPARE=$3
> +	DIR=$4
>  	test_expect_success "check normal git operations: $MSG" '
> -		graph_git_two_modes "log --oneline $BRANCH" &&
> -		graph_git_two_modes "log --topo-order $BRANCH" &&
> -		graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
> -		graph_git_two_modes "branch -vv" &&
> -		graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
> +		graph_git_two_modes "log --oneline $BRANCH" "$DIR" &&
> +		graph_git_two_modes "log --topo-order $BRANCH" "$DIR" &&
> +		graph_git_two_modes "log --graph $COMPARE..$BRANCH" "$DIR" &&
> +		graph_git_two_modes "branch -vv" "$DIR" &&
> +		graph_git_two_modes "merge-base -a $BRANCH $COMPARE" "$DIR"
>  	'
>  }
>  
> @@ -187,7 +188,10 @@ test_expect_success 'create fork and chain across alternate' '
>  	)
>  '
>  
> -graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
> +if test -d fork
> +then
> +	graph_git_behavior 'alternate: commit 13 vs 6' commits/13 origin/commits/6 "fork"
> +fi
>  
>  test_expect_success 'test merge stragety constants' '
>  	git clone . merge-2 &&
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 5 of 7 in “commit-graph: make "verify" work with replace refs”
  1. 0/3 commit-graph: make "verify" work with replace refsÆvar Arnfjörð Bjarmason, Oct 14, 2021
  2. 1/3 commit-graph tests: fix error-hiding graph_git_two_modes() helperÆvar Arnfjörð Bjarmason, Oct 14, 2021
  3. Junio C HamanoOct 15, 2021
  4. 2/3 commit-graph tests: fix another graph_git_two_modes() helperÆvar Arnfjörð Bjarmason, Oct 14, 2021
  5. Junio C HamanoOct 15, 2021
  6. 3/3 commit-graph: don't consider "replace" objects with "verify"Ævar Arnfjörð Bjarmason, Oct 14, 2021
  7. Junio C HamanoOct 15, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.