Merge branch 'js/t0001-case-insensitive'
[gitweb.git] / t / t5318-commit-graph.sh
index 4601732b99677c05a04bbc5a40d59529bbae86c5..5267c4be20e709bb1632c5b9786ffdb418bcb5c9 100755 (executable)
@@ -23,6 +23,14 @@ test_expect_success 'write graph with no packs' '
        test_path_is_file info/commit-graph
 '
 
+test_expect_success 'close with correct error on bad input' '
+       cd "$TRASH_DIRECTORY/full" &&
+       echo doesnotexist >in &&
+       { git commit-graph write --stdin-packs <in 2>stderr; ret=$?; } &&
+       test "$ret" = 1 &&
+       test_i18ngrep "error adding pack" stderr
+'
+
 test_expect_success 'create commits and repack' '
        cd "$TRASH_DIRECTORY/full" &&
        for i in $(test_seq 3)
@@ -75,7 +83,7 @@ graph_read_expect() {
 
 test_expect_success 'write graph' '
        cd "$TRASH_DIRECTORY/full" &&
-       graph1=$(git commit-graph write) &&
+       git commit-graph write &&
        test_path_is_file $objdir/info/commit-graph &&
        graph_read_expect "3"
 '
@@ -377,7 +385,13 @@ corrupt_graph_verify() {
        test_must_fail git commit-graph verify 2>test_err &&
        grep -v "^+" test_err >err &&
        test_i18ngrep "$grepstr" err &&
-       git status --short
+       if test "$2" != "no-copy"
+       then
+               cp $objdir/info/commit-graph commit-graph-pre-write-test
+       fi &&
+       git status --short &&
+       GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD=true git commit-graph write &&
+       git commit-graph verify
 }
 
 # usage: corrupt_graph_and_verify <position> <data> <string> [<zero_pos>]
@@ -394,7 +408,7 @@ corrupt_graph_and_verify() {
        orig_size=$(wc -c < $objdir/info/commit-graph) &&
        zero_pos=${4:-${orig_size}} &&
        printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
-       dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
+       dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null &&
        generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
        corrupt_graph_verify "$grepstr"
 
@@ -403,7 +417,7 @@ corrupt_graph_and_verify() {
 test_expect_success POSIXPERM,SANITY 'detect permission problem' '
        corrupt_graph_setup &&
        chmod 000 $objdir/info/commit-graph &&
-       corrupt_graph_verify "Could not open"
+       corrupt_graph_verify "Could not open" "no-copy"
 '
 
 test_expect_success 'detect too small' '
@@ -522,6 +536,7 @@ test_expect_success 'git fsck (checks commit-graph)' '
        git fsck &&
        corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
                "incorrect checksum" &&
+       cp commit-graph-pre-write-test $objdir/info/commit-graph &&
        test_must_fail git fsck
 '