commit-graph: not compatible with grafts
Augment commit_graph_compatible(r) to return false when the given repository r has commit grafts or is a shallow clone. Test that in these situations we ignore existing commit-graph files and we do not write new commit-graph files. Helped-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
d6538246d3
commit
20fd6d5799
@ -281,6 +281,44 @@ test_expect_success 'replace-objects invalidates commit-graph' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'commit grafts invalidate commit-graph' '
|
||||
cd "$TRASH_DIRECTORY" &&
|
||||
test_when_finished rm -rf graft &&
|
||||
git clone full graft &&
|
||||
(
|
||||
cd graft &&
|
||||
git commit-graph write --reachable &&
|
||||
test_path_is_file .git/objects/info/commit-graph &&
|
||||
H1=$(git rev-parse --verify HEAD~1) &&
|
||||
H3=$(git rev-parse --verify HEAD~3) &&
|
||||
echo "$H1 $H3" >.git/info/grafts &&
|
||||
git -c core.commitGraph=false log >expect &&
|
||||
git -c core.commitGraph=true log >actual &&
|
||||
test_cmp expect actual &&
|
||||
git commit-graph write --reachable &&
|
||||
git -c core.commitGraph=false --no-replace-objects log >expect &&
|
||||
git -c core.commitGraph=true --no-replace-objects log >actual &&
|
||||
test_cmp expect actual &&
|
||||
rm -rf .git/objects/info/commit-graph &&
|
||||
git commit-graph write --reachable &&
|
||||
test_path_is_missing .git/objects/info/commit-graph
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'replace-objects invalidates commit-graph' '
|
||||
cd "$TRASH_DIRECTORY" &&
|
||||
test_when_finished rm -rf shallow &&
|
||||
git clone --depth 2 "file://$TRASH_DIRECTORY/full" shallow &&
|
||||
(
|
||||
cd shallow &&
|
||||
git commit-graph write --reachable &&
|
||||
test_path_is_missing .git/objects/info/commit-graph &&
|
||||
git fetch origin --unshallow &&
|
||||
git commit-graph write --reachable &&
|
||||
test_path_is_file .git/objects/info/commit-graph
|
||||
)
|
||||
'
|
||||
|
||||
# the verify tests below expect the commit-graph to contain
|
||||
# exactly the commits reachable from the commits/8 branch.
|
||||
# If the file changes the set of commits in the list, then the
|
||||
|
||||
Reference in New Issue
Block a user