Skip to content

Commit 5b15eb3

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16110c9 commit 5b15eb3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

t/t5324-split-commit-graph.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ corrupt_file() {
237237
file=$1
238238
pos=$2
239239
data="${3:-\0}"
240+
chmod a+w "$file" &&
240241
printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
241242
}
242243

@@ -295,6 +296,24 @@ test_expect_success 'verify after commit-graph-chain corruption' '
295296
)
296297
'
297298

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+
298317
test_expect_success 'add octopus merge' '
299318
git reset --hard commits/10 &&
300319
git merge commits/3 commits/4 &&

0 commit comments

Comments
 (0)