]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5324: make hash size independent
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 21 Dec 2019 19:49:27 +0000 (19:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jan 2020 22:06:19 +0000 (14:06 -0800)
There are some offsets in the commit graph files used to corrupt data.
Compute these offsets for both SHA-1 and SHA-256 so that the test works
with either.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5324-split-commit-graph.sh

index c24823431f2314169874adc705188f40da4c1618..53b2e6b4555de7d7cc27c727e2e7a3d7a4ff3f5b 100755 (executable)
@@ -11,7 +11,14 @@ test_expect_success 'setup repo' '
        git config gc.writeCommitGraph false &&
        infodir=".git/objects/info" &&
        graphdir="$infodir/commit-graphs" &&
-       test_oid_init
+       test_oid_init &&
+       test_oid_cache <<-EOM
+       shallow sha1:1760
+       shallow sha256:2064
+
+       base sha1:1376
+       base sha256:1496
+       EOM
 '
 
 graph_read_expect() {
@@ -248,7 +255,7 @@ test_expect_success 'verify hashes along chain, even in shallow' '
                cd verify &&
                git commit-graph verify &&
                base_file=$graphdir/graph-$(head -n 1 $graphdir/commit-graph-chain).graph &&
-               corrupt_file "$base_file" 1760 "\01" &&
+               corrupt_file "$base_file" $(test_oid shallow) "\01" &&
                test_must_fail git commit-graph verify --shallow 2>test_err &&
                grep -v "^+" test_err >err &&
                test_i18ngrep "incorrect checksum" err
@@ -275,7 +282,7 @@ test_expect_success 'warn on base graph chunk incorrect' '
                cd base-chunk &&
                git commit-graph verify &&
                base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
-               corrupt_file "$base_file" 1376 "\01" &&
+               corrupt_file "$base_file" $(test_oid base) "\01" &&
                git commit-graph verify --shallow 2>test_err &&
                grep -v "^+" test_err >err &&
                test_i18ngrep "commit-graph chain does not match" err