t5324: harmonize sha1/sha256 graph chain corruption

In t5324.20, we corrupt a hex character 60 bytes into the graph chain file. Since the file consists of two hash identifiers, one per line, the corruption differs between sha1 and sha256. In a sha1 repository, the corruption is on the second line, and in a sha256 repository, it is on the first. We should of course detect the problem with either line. But as the next few patches will show (and fix), that is not the case (in fact, we currently do not exit non-zero for either line!). And while at the end of our series we'll catch all errors, our intermediate states will have differing behavior between the two hashes. Let's make sure we test corruption of both the first and second lines, and do so consistently with either hash by choosing offsets which are always in the first hash (30 bytes) or in the second (70). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 28, 2023 at 00:38 UTC 2d45710c5d1dc20db0d6c856e9e711dd6a19e18f
1 file changed +20 -5
t/t5324-split-commit-graph.sh
+20 -5
@@ -312,15 +312,30 @@ test_expect_success 'warn on base graph chunk incorrect' '
312 )
313 '
314
315 -test_expect_success 'verify after commit-graph-chain corruption' '
316 - git clone --no-hardlinks . verify-chain &&
315 +test_expect_success 'verify after commit-graph-chain corruption (base)' '
316 + git clone --no-hardlinks . verify-chain-base &&
317 (
318 - cd verify-chain &&
319 - corrupt_file "$graphdir/commit-graph-chain" 60 "G" &&
318 + cd verify-chain-base &&
319 + corrupt_file "$graphdir/commit-graph-chain" 30 "G" &&
320 git commit-graph verify 2>test_err &&
321 grep -v "^+" test_err >err &&
322 test_i18ngrep "invalid commit-graph chain" err &&
323 - corrupt_file "$graphdir/commit-graph-chain" 60 "A" &&
323 + corrupt_file "$graphdir/commit-graph-chain" 30 "A" &&
324 + git commit-graph verify 2>test_err &&
325 + grep -v "^+" test_err >err &&
326 + test_i18ngrep "unable to find all commit-graph files" err
327 + )
328 +'
329 +
330 +test_expect_success 'verify after commit-graph-chain corruption (tip)' '
331 + git clone --no-hardlinks . verify-chain-tip &&
332 + (
333 + cd verify-chain-tip &&
334 + corrupt_file "$graphdir/commit-graph-chain" 70 "G" &&
335 + git commit-graph verify 2>test_err &&
336 + grep -v "^+" test_err >err &&
337 + test_i18ngrep "invalid commit-graph chain" err &&
338 + corrupt_file "$graphdir/commit-graph-chain" 70 "A" &&
339 git commit-graph verify 2>test_err &&
340 grep -v "^+" test_err >err &&
341 test_i18ngrep "unable to find all commit-graph files" err