@@ -14,24 +14,37 @@ graph_git_two_modes() {
14
14
test_cmp expect output
15
15
}
16
16
17
+ # graph_git_behavior <name> <directory> <branch> <compare>
18
+ #
19
+ # Ensures that a handful of traversal operations produce the same
20
+ # results with and without the commit-graph in use.
21
+ #
22
+ # NOTE: it is a bug to call this function with <directory> containing
23
+ # any characters in $IFS.
17
24
graph_git_behavior () {
18
25
MSG=$1
19
26
DIR=$2
20
27
BRANCH=$3
21
28
COMPARE=$4
22
29
test_expect_success " check normal git operations: $MSG " '
23
- cd "$TRASH_DIRECTORY/$DIR" &&
24
- graph_git_two_modes "log --oneline $BRANCH" &&
25
- graph_git_two_modes "log --topo-order $BRANCH" &&
26
- graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
27
- graph_git_two_modes "branch -vv" &&
28
- graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
30
+ graph_git_two_modes "${DIR:+-C $DIR} log --oneline $BRANCH" &&
31
+ graph_git_two_modes "${DIR:+-C $DIR} log --topo-order $BRANCH" &&
32
+ graph_git_two_modes "${DIR:+-C $DIR} log --graph $COMPARE..$BRANCH" &&
33
+ graph_git_two_modes "${DIR:+-C $DIR} branch -vv" &&
34
+ graph_git_two_modes "${DIR:+-C $DIR} merge-base -a $BRANCH $COMPARE"
29
35
'
30
36
}
31
37
32
38
graph_read_expect () {
33
39
OPTIONAL=" "
34
40
NUM_CHUNKS=3
41
+ DIR=" ."
42
+ if test " $1 " = -C
43
+ then
44
+ shift
45
+ DIR=" $1 "
46
+ shift
47
+ fi
35
48
if test -n " $2 "
36
49
then
37
50
OPTIONAL=" $2 "
@@ -47,12 +60,15 @@ graph_read_expect() {
47
60
then
48
61
OPTIONS=" read_generation_data"
49
62
fi
50
- cat > expect << - EOF
63
+ cat > " $DIR / expect" << -EOF
51
64
header: 43475048 1 $( test_oid oid_version) $NUM_CHUNKS 0
52
65
num_commits: $1
53
66
chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
54
67
options:$OPTIONS
55
68
EOF
56
- test-tool read-graph > output &&
57
- test_cmp expect output
69
+ (
70
+ cd " $DIR " &&
71
+ test-tool read-graph > output &&
72
+ test_cmp expect output
73
+ )
58
74
}
0 commit comments