Merge branch 'jt/fetch-pack-negotiator'
[gitweb.git] / t / t5318-commit-graph.sh
index fed05e2f12a23511aabf85318036d70cdf903c33..5947de3d2438ea301e33f2fc3430ee703d1436b9 100755 (executable)
@@ -205,6 +205,16 @@ test_expect_success 'build graph from commits with append' '
 graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
 graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
 
+test_expect_success 'build graph using --reachable' '
+       cd "$TRASH_DIRECTORY/full" &&
+       git commit-graph write --reachable &&
+       test_path_is_file $objdir/info/commit-graph &&
+       graph_read_expect "11" "large_edges"
+'
+
+graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
+graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
+
 test_expect_success 'setup bare repo' '
        cd "$TRASH_DIRECTORY" &&
        git clone --bare --no-local full bare &&
@@ -235,6 +245,20 @@ test_expect_success 'perform fast-forward merge in full repo' '
        test_cmp expect output
 '
 
+test_expect_success 'check that gc computes commit-graph' '
+       cd "$TRASH_DIRECTORY/full" &&
+       git commit --allow-empty -m "blank" &&
+       git commit-graph write --reachable &&
+       cp $objdir/info/commit-graph commit-graph-before-gc &&
+       git reset --hard HEAD~1 &&
+       git config gc.writeCommitGraph true &&
+       git gc &&
+       cp $objdir/info/commit-graph commit-graph-after-gc &&
+       ! test_cmp commit-graph-before-gc commit-graph-after-gc &&
+       git commit-graph write --reachable &&
+       test_cmp commit-graph-after-gc $objdir/info/commit-graph
+'
+
 # the verify tests below expect the commit-graph to contain
 # exactly the commits reachable from the commits/8 branch.
 # If the file changes the set of commits in the list, then the
@@ -399,4 +423,12 @@ test_expect_success 'detect invalid checksum hash' '
                "incorrect checksum"
 '
 
+test_expect_success 'git fsck (checks commit-graph)' '
+       cd "$TRASH_DIRECTORY/full" &&
+       git fsck &&
+       corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
+               "incorrect checksum" &&
+       test_must_fail git fsck
+'
+
 test_done