mirror of
https://github.com/git/git.git
synced 2026-04-11 17:30:08 +02:00
commit-graph: allow cross-alternate chains
In an environment like a fork network, it is helpful to have a
commit-graph chain that spans both the base repo and the fork repo. The
fork is usually a small set of data on top of the large repo, but
sometimes the fork is much larger. For example, git-for-windows/git has
almost double the number of commits as git/git because it rebases its
commits on every major version update.
To allow cross-alternate commit-graph chains, we need a few pieces:
1. When looking for a graph-{hash}.graph file, check all alternates.
2. When merging commit-graph chains, do not merge across alternates.
3. When writing a new commit-graph chain based on a commit-graph file
in another object directory, do not allow success if the base file
has of the name "commit-graph" instead of
"commit-graphs/graph-{hash}.graph".
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
1771be90c8
commit
c523035cbd
@@ -90,6 +90,21 @@ test_expect_success 'add more commits, and write a new base graph' '
|
||||
graph_read_expect 12
|
||||
'
|
||||
|
||||
test_expect_success 'fork and fail to base a chain on a commit-graph file' '
|
||||
test_when_finished rm -rf fork &&
|
||||
git clone . fork &&
|
||||
(
|
||||
cd fork &&
|
||||
rm .git/objects/info/commit-graph &&
|
||||
echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
|
||||
test_commit new-commit &&
|
||||
git commit-graph write --reachable --split &&
|
||||
test_path_is_file $graphdir/commit-graph-chain &&
|
||||
test_line_count = 1 $graphdir/commit-graph-chain &&
|
||||
verify_chain_files_exist $graphdir
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'add three more commits, write a tip graph' '
|
||||
git reset --hard commits/3 &&
|
||||
git merge merge/1 &&
|
||||
@@ -132,4 +147,26 @@ test_expect_success 'add one commit, write a merged graph' '
|
||||
|
||||
graph_git_behavior 'merged commit-graph: commit 12 vs 6' commits/12 commits/6
|
||||
|
||||
test_expect_success 'create fork and chain across alternate' '
|
||||
git clone . fork &&
|
||||
(
|
||||
cd fork &&
|
||||
git config core.commitGraph true &&
|
||||
rm -rf $graphdir &&
|
||||
echo "$(pwd)/../.git/objects" >.git/objects/info/alternates &&
|
||||
test_commit 13 &&
|
||||
git branch commits/13 &&
|
||||
git commit-graph write --reachable --split &&
|
||||
test_path_is_file $graphdir/commit-graph-chain &&
|
||||
test_line_count = 3 $graphdir/commit-graph-chain &&
|
||||
ls $graphdir/graph-*.graph >graph-files &&
|
||||
test_line_count = 1 graph-files &&
|
||||
git -c core.commitGraph=true rev-list HEAD >expect &&
|
||||
git -c core.commitGraph=false rev-list HEAD >actual &&
|
||||
test_cmp expect actual
|
||||
)
|
||||
'
|
||||
|
||||
graph_git_behavior 'alternate: commit 13 vs 6' commits/13 commits/6
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user