Derrick Stolee | 17925e0 | 2022-03-01 19:48:29 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Helper functions for testing commit-graphs. |
| 4 | |
| 5 | # Initialize OID cache with oid_version |
| 6 | test_oid_cache <<-EOF |
| 7 | oid_version sha1:1 |
| 8 | oid_version sha256:2 |
| 9 | EOF |
| 10 | |
| 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 |
| 15 | } |
| 16 | |
| 17 | graph_git_behavior() { |
| 18 | MSG=$1 |
| 19 | DIR=$2 |
| 20 | BRANCH=$3 |
| 21 | COMPARE=$4 |
| 22 | 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" |
| 29 | ' |
| 30 | } |
| 31 | |
| 32 | graph_read_expect() { |
| 33 | OPTIONAL="" |
| 34 | NUM_CHUNKS=3 |
| 35 | if test -n "$2" |
| 36 | then |
| 37 | OPTIONAL=" $2" |
| 38 | NUM_CHUNKS=$((3 + $(echo "$2" | wc -w))) |
| 39 | fi |
Derrick Stolee | 3b0199d | 2022-03-01 19:48:31 +0000 | [diff] [blame] | 40 | GENERATION_VERSION=2 |
| 41 | if test -n "$3" |
| 42 | then |
| 43 | GENERATION_VERSION=$3 |
| 44 | fi |
| 45 | OPTIONS= |
| 46 | if test $GENERATION_VERSION -gt 1 |
| 47 | then |
| 48 | OPTIONS=" read_generation_data" |
| 49 | fi |
Derrick Stolee | 17925e0 | 2022-03-01 19:48:29 +0000 | [diff] [blame] | 50 | cat >expect <<- EOF |
| 51 | header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0 |
| 52 | num_commits: $1 |
| 53 | chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL |
Derrick Stolee | 3b0199d | 2022-03-01 19:48:31 +0000 | [diff] [blame] | 54 | options:$OPTIONS |
Derrick Stolee | 17925e0 | 2022-03-01 19:48:29 +0000 | [diff] [blame] | 55 | EOF |
| 56 | test-tool read-graph >output && |
| 57 | test_cmp expect output |
| 58 | } |