commit-graph: test verify across alternates
The 'git commit-graph verify' subcommand loads a commit-graph from a given object directory instead of using the standard method prepare_commit_graph(). During development of load_commit_graph_chain(), a version did not include prepare_alt_odb() as it was previously run by prepare_commit_graph() in most cases. Add a test that prevents that mistake from happening again. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jun 18, 2019 at 11:14 UTC
5b15eb397d176c557a82e872d6b4043aa7589874
1 file changed
+19
t/t5324-split-commit-graph.sh
+19
@@ -237,6 +237,7 @@ corrupt_file() {
237
file=$1
238
pos=$2
239
data="${3:-\0}"
240
+ chmod a+w "$file" &&
241
printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
242
}
243
@@ -295,6 +296,24 @@ test_expect_success 'verify after commit-graph-chain corruption' '
296
)
297
'
298
299
+test_expect_success 'verify across alternates' '
300
+ git clone --no-hardlinks . verify-alt &&
301
+ (
302
+ cd verify-alt &&
303
+ rm -rf $graphdir &&
304
+ altdir="$(pwd)/../.git/objects" &&
305
+ echo "$altdir" >.git/objects/info/alternates &&
306
+ git commit-graph verify --object-dir="$altdir/" &&
307
+ test_commit extra &&
308
+ git commit-graph write --reachable --split &&
309
+ tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph &&
310
+ corrupt_file "$tip_file" 100 "\01" &&
311
+ test_must_fail git commit-graph verify --shallow 2>test_err &&
312
+ grep -v "^+" test_err >err &&
313
+ test_i18ngrep "commit-graph has incorrect fanout value" err
314
+ )
315
+'
316
+
317
test_expect_success 'add octopus merge' '
318
git reset --hard commits/10 &&
319
git merge commits/3 commits/4 &&