Skip to content

Commit a046aa3

Browse files
avargitster
authored andcommitted
commit-graph tests: fix another graph_git_two_modes() helper
In 135a712 (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 c523035 (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". It's not easy to simply move the "graph_git_behavior" to the test above it, since it itself spawns a "test_expect_success". Let's instead add support to "graph_git_behavior()" and "graph_git_two_modes()" to pass a "-C" argument to git. We also need to add a "test -d fork" here, because otherwise we'll fail on e.g.: GIT_SKIP_TESTS=t5324.13 ./t5324-split-commit-graph.sh Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3247919 commit a046aa3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

t/t5324-split-commit-graph.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,22 @@ test_expect_success 'create commits and write commit-graph' '
5555
'
5656

5757
graph_git_two_modes() {
58-
git -c core.commitGraph=true $1 >output
59-
git -c core.commitGraph=false $1 >expect
58+
git ${2:+ -C "$2"} -c core.commitGraph=true $1 >output &&
59+
git ${2:+ -C "$2"} -c core.commitGraph=false $1 >expect &&
6060
test_cmp expect output
6161
}
6262

6363
graph_git_behavior() {
6464
MSG=$1
6565
BRANCH=$2
6666
COMPARE=$3
67+
DIR=$4
6768
test_expect_success "check normal git operations: $MSG" '
68-
graph_git_two_modes "log --oneline $BRANCH" &&
69-
graph_git_two_modes "log --topo-order $BRANCH" &&
70-
graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
71-
graph_git_two_modes "branch -vv" &&
72-
graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
69+
graph_git_two_modes "log --oneline $BRANCH" "$DIR" &&
70+
graph_git_two_modes "log --topo-order $BRANCH" "$DIR" &&
71+
graph_git_two_modes "log --graph $COMPARE..$BRANCH" "$DIR" &&
72+
graph_git_two_modes "branch -vv" "$DIR" &&
73+
graph_git_two_modes "merge-base -a $BRANCH $COMPARE" "$DIR"
7374
'
7475
}
7576

@@ -187,7 +188,10 @@ test_expect_success 'create fork and chain across alternate' '
187188
)
188189
'
189190

190-
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
191+
if test -d fork
192+
then
193+
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 origin/commits/6 "fork"
194+
fi
191195

192196
test_expect_success 'test merge stragety constants' '
193197
git clone . merge-2 &&

0 commit comments

Comments
 (0)