summaryrefslogtreecommitdiff
path: root/t/t5318-commit-graph.sh
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-04-10 12:56:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-11 01:43:01 (GMT)
commit2a2e32bdc5a80221981939e77643cec3462b4793 (patch)
treeae0344a998a46747dec3fbaf443e852ae4f71db4 /t/t5318-commit-graph.sh
parentf237c8b6feaa3bad352bd27c14f0d83d0a1c061a (diff)
downloadgit-2a2e32bdc5a80221981939e77643cec3462b4793.zip
git-2a2e32bdc5a80221981939e77643cec3462b4793.tar.gz
git-2a2e32bdc5a80221981939e77643cec3462b4793.tar.bz2
commit-graph: implement git commit-graph read
Teach git-commit-graph to read commit graph files and summarize their contents. Use the read subcommand to verify the contents of a commit graph file in the tests. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5318-commit-graph.sh')
-rwxr-xr-xt/t5318-commit-graph.sh32
1 files changed, 27 insertions, 5 deletions
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index d7b635b..2f44f91 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -26,10 +26,28 @@ test_expect_success 'create commits and repack' '
git repack
'
+graph_read_expect() {
+ OPTIONAL=""
+ NUM_CHUNKS=3
+ if test ! -z $2
+ then
+ OPTIONAL=" $2"
+ NUM_CHUNKS=$((3 + $(echo "$2" | wc -w)))
+ fi
+ cat >expect <<- EOF
+ header: 43475048 1 1 $NUM_CHUNKS 0
+ num_commits: $1
+ chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
+ EOF
+ git commit-graph read >output &&
+ test_cmp expect output
+}
+
test_expect_success 'write graph' '
cd "$TRASH_DIRECTORY/full" &&
graph1=$(git commit-graph write) &&
- test_path_is_file $objdir/info/commit-graph
+ test_path_is_file $objdir/info/commit-graph &&
+ graph_read_expect "3"
'
test_expect_success 'Add more commits' '
@@ -72,7 +90,8 @@ test_expect_success 'Add more commits' '
test_expect_success 'write graph with merges' '
cd "$TRASH_DIRECTORY/full" &&
git commit-graph write &&
- test_path_is_file $objdir/info/commit-graph
+ test_path_is_file $objdir/info/commit-graph &&
+ graph_read_expect "10" "large_edges"
'
test_expect_success 'Add one more commit' '
@@ -99,13 +118,15 @@ test_expect_success 'Add one more commit' '
test_expect_success 'write graph with new commit' '
cd "$TRASH_DIRECTORY/full" &&
git commit-graph write &&
- test_path_is_file $objdir/info/commit-graph
+ test_path_is_file $objdir/info/commit-graph &&
+ graph_read_expect "11" "large_edges"
'
test_expect_success 'write graph with nothing new' '
cd "$TRASH_DIRECTORY/full" &&
git commit-graph write &&
- test_path_is_file $objdir/info/commit-graph
+ test_path_is_file $objdir/info/commit-graph &&
+ graph_read_expect "11" "large_edges"
'
test_expect_success 'setup bare repo' '
@@ -118,7 +139,8 @@ test_expect_success 'setup bare repo' '
test_expect_success 'write graph in bare repo' '
cd "$TRASH_DIRECTORY/bare" &&
git commit-graph write &&
- test_path_is_file $baredir/info/commit-graph
+ test_path_is_file $baredir/info/commit-graph &&
+ graph_read_expect "11" "large_edges"
'
test_done