setup: merge configuration of repository formats
[git/gitster.git] / t / lib-commit-graph.sh
blob89b26676fbb94b0b4f570ec9a51ca74cce7620c5
1 #!/bin/sh
3 # Helper functions for testing commit-graphs.
5 # Initialize OID cache with oid_version
6 test_oid_cache <<-EOF
7 oid_version sha1:1
8 oid_version sha256:2
9 EOF
11 graph_git_two_modes() {
12 git -c core.commitGraph=true $1 >output &&
13 git -c core.commitGraph=false $1 >expect &&
14 test_cmp expect output
17 # graph_git_behavior <name> <directory> <branch> <compare>
19 # Ensures that a handful of traversal operations produce the same
20 # results with and without the commit-graph in use.
22 # NOTE: it is a bug to call this function with <directory> containing
23 # any characters in $IFS.
24 graph_git_behavior() {
25 MSG=$1
26 DIR=$2
27 BRANCH=$3
28 COMPARE=$4
29 test_expect_success "check normal git operations: $MSG" '
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"
38 graph_read_expect() {
39 OPTIONAL=""
40 NUM_CHUNKS=3
41 DIR="."
42 if test "$1" = -C
43 then
44 shift
45 DIR="$1"
46 shift
48 if test -n "$2"
49 then
50 OPTIONAL=" $2"
51 NUM_CHUNKS=$((3 + $(echo "$2" | wc -w)))
53 GENERATION_VERSION=2
54 if test -n "$3"
55 then
56 GENERATION_VERSION=$3
58 OPTIONS=
59 if test $GENERATION_VERSION -gt 1
60 then
61 OPTIONS=" read_generation_data"
63 cat >"$DIR/expect" <<-EOF
64 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
65 num_commits: $1
66 chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
67 options:$OPTIONS
68 EOF
70 cd "$DIR" &&
71 test-tool read-graph >output &&
72 test_cmp expect output