summaryrefslogtreecommitdiff
path: root/t/t5324-split-commit-graph.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5324-split-commit-graph.sh')
-rwxr-xr-xt/t5324-split-commit-graph.sh299
1 files changed, 291 insertions, 8 deletions
diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh
index 53b2e6b..8e90f34 100755
--- a/t/t5324-split-commit-graph.sh
+++ b/t/t5324-split-commit-graph.sh
@@ -4,6 +4,7 @@ test_description='split commit graph'
. ./test-lib.sh
GIT_TEST_COMMIT_GRAPH=0
+GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
test_expect_success 'setup repo' '
git init &&
@@ -11,13 +12,15 @@ test_expect_success 'setup repo' '
git config gc.writeCommitGraph false &&
infodir=".git/objects/info" &&
graphdir="$infodir/commit-graphs" &&
- test_oid_init &&
test_oid_cache <<-EOM
- shallow sha1:1760
- shallow sha256:2064
+ shallow sha1:2132
+ shallow sha256:2436
- base sha1:1376
- base sha256:1496
+ base sha1:1408
+ base sha256:1528
+
+ oid_version sha1:1
+ oid_version sha256:2
EOM
'
@@ -28,14 +31,18 @@ graph_read_expect() {
NUM_BASE=$2
fi
cat >expect <<- EOF
- header: 43475048 1 1 3 $NUM_BASE
+ header: 43475048 1 $(test_oid oid_version) 4 $NUM_BASE
num_commits: $1
- chunks: oid_fanout oid_lookup commit_metadata
+ chunks: oid_fanout oid_lookup commit_metadata generation_data
EOF
test-tool read-graph >output &&
test_cmp expect output
}
+test_expect_success POSIXPERM 'tweak umask for modebit tests' '
+ umask 022
+'
+
test_expect_success 'create commits and write commit-graph' '
for i in $(test_seq 3)
do
@@ -210,8 +217,14 @@ test_expect_success 'test merge stragety constants' '
git config core.commitGraph true &&
test_line_count = 2 $graphdir/commit-graph-chain &&
test_commit 15 &&
- git commit-graph write --reachable --split --size-multiple=10 --expire-time=1980-01-01 &&
+ touch $graphdir/to-delete.graph $graphdir/to-keep.graph &&
+ test-tool chmtime =1546362000 $graphdir/to-delete.graph &&
+ test-tool chmtime =1546362001 $graphdir/to-keep.graph &&
+ git commit-graph write --reachable --split --size-multiple=10 \
+ --expire-time="2019-01-01 12:00 -05:00" &&
test_line_count = 1 $graphdir/commit-graph-chain &&
+ test_path_is_missing $graphdir/to-delete.graph &&
+ test_path_is_file $graphdir/to-keep.graph &&
ls $graphdir/graph-*.graph >graph-files &&
test_line_count = 3 graph-files
) &&
@@ -351,4 +364,274 @@ test_expect_success 'split across alternate where alternate is not split' '
test_cmp commit-graph .git/objects/info/commit-graph
'
+test_expect_success '--split=no-merge always writes an incremental' '
+ test_when_finished rm -rf a b &&
+ rm -rf $graphdir $infodir/commit-graph &&
+ git reset --hard commits/2 &&
+ git rev-list HEAD~1 >a &&
+ git rev-list HEAD >b &&
+ git commit-graph write --split --stdin-commits <a &&
+ git commit-graph write --split=no-merge --stdin-commits <b &&
+ test_line_count = 2 $graphdir/commit-graph-chain
+'
+
+test_expect_success '--split=replace replaces the chain' '
+ rm -rf $graphdir $infodir/commit-graph &&
+ git reset --hard commits/3 &&
+ git rev-list -1 HEAD~2 >a &&
+ git rev-list -1 HEAD~1 >b &&
+ git rev-list -1 HEAD >c &&
+ git commit-graph write --split=no-merge --stdin-commits <a &&
+ git commit-graph write --split=no-merge --stdin-commits <b &&
+ git commit-graph write --split=no-merge --stdin-commits <c &&
+ test_line_count = 3 $graphdir/commit-graph-chain &&
+ git commit-graph write --stdin-commits --split=replace <b &&
+ test_path_is_missing $infodir/commit-graph &&
+ test_path_is_file $graphdir/commit-graph-chain &&
+ ls $graphdir/graph-*.graph >graph-files &&
+ test_line_count = 1 graph-files &&
+ verify_chain_files_exist $graphdir &&
+ graph_read_expect 2
+'
+
+test_expect_success ULIMIT_FILE_DESCRIPTORS 'handles file descriptor exhaustion' '
+ git init ulimit &&
+ (
+ cd ulimit &&
+ for i in $(test_seq 64)
+ do
+ test_commit $i &&
+ run_with_limited_open_files test_might_fail git commit-graph write \
+ --split=no-merge --reachable || return 1
+ done
+ )
+'
+
+while read mode modebits
+do
+ test_expect_success POSIXPERM "split commit-graph respects core.sharedrepository $mode" '
+ rm -rf $graphdir $infodir/commit-graph &&
+ git reset --hard commits/1 &&
+ test_config core.sharedrepository "$mode" &&
+ git commit-graph write --split --reachable &&
+ ls $graphdir/graph-*.graph >graph-files &&
+ test_line_count = 1 graph-files &&
+ echo "$modebits" >expect &&
+ test_modebits $graphdir/graph-*.graph >actual &&
+ test_cmp expect actual &&
+ test_modebits $graphdir/commit-graph-chain >actual &&
+ test_cmp expect actual
+ '
+done <<\EOF
+0666 -r--r--r--
+0600 -r--------
+EOF
+
+test_expect_success '--split=replace with partial Bloom data' '
+ rm -rf $graphdir $infodir/commit-graph &&
+ git reset --hard commits/3 &&
+ git rev-list -1 HEAD~2 >a &&
+ git rev-list -1 HEAD~1 >b &&
+ git commit-graph write --split=no-merge --stdin-commits --changed-paths <a &&
+ git commit-graph write --split=no-merge --stdin-commits <b &&
+ git commit-graph write --split=replace --stdin-commits --changed-paths <c &&
+ ls $graphdir/graph-*.graph >graph-files &&
+ test_line_count = 1 graph-files &&
+ verify_chain_files_exist $graphdir
+'
+
+test_expect_success 'prevent regression for duplicate commits across layers' '
+ git init dup &&
+ git -C dup commit --allow-empty -m one &&
+ git -C dup -c core.commitGraph=false commit-graph write --split=no-merge --reachable 2>err &&
+ test_i18ngrep "attempting to write a commit-graph" err &&
+ git -C dup commit-graph write --split=no-merge --reachable &&
+ git -C dup commit --allow-empty -m two &&
+ git -C dup commit-graph write --split=no-merge --reachable &&
+ git -C dup commit --allow-empty -m three &&
+ git -C dup commit-graph write --split --reachable &&
+ git -C dup commit-graph verify
+'
+
+NUM_FIRST_LAYER_COMMITS=64
+NUM_SECOND_LAYER_COMMITS=16
+NUM_THIRD_LAYER_COMMITS=7
+NUM_FOURTH_LAYER_COMMITS=8
+NUM_FIFTH_LAYER_COMMITS=16
+SECOND_LAYER_SEQUENCE_START=$(($NUM_FIRST_LAYER_COMMITS + 1))
+SECOND_LAYER_SEQUENCE_END=$(($SECOND_LAYER_SEQUENCE_START + $NUM_SECOND_LAYER_COMMITS - 1))
+THIRD_LAYER_SEQUENCE_START=$(($SECOND_LAYER_SEQUENCE_END + 1))
+THIRD_LAYER_SEQUENCE_END=$(($THIRD_LAYER_SEQUENCE_START + $NUM_THIRD_LAYER_COMMITS - 1))
+FOURTH_LAYER_SEQUENCE_START=$(($THIRD_LAYER_SEQUENCE_END + 1))
+FOURTH_LAYER_SEQUENCE_END=$(($FOURTH_LAYER_SEQUENCE_START + $NUM_FOURTH_LAYER_COMMITS - 1))
+FIFTH_LAYER_SEQUENCE_START=$(($FOURTH_LAYER_SEQUENCE_END + 1))
+FIFTH_LAYER_SEQUENCE_END=$(($FIFTH_LAYER_SEQUENCE_START + $NUM_FIFTH_LAYER_COMMITS - 1))
+
+# Current split graph chain:
+#
+# 16 commits (No GDAT)
+# ------------------------
+# 64 commits (GDAT)
+#
+test_expect_success 'setup repo for mixed generation commit-graph-chain' '
+ graphdir=".git/objects/info/commit-graphs" &&
+ test_oid_cache <<-EOF &&
+ oid_version sha1:1
+ oid_version sha256:2
+ EOF
+ git init mixed &&
+ (
+ cd mixed &&
+ git config core.commitGraph true &&
+ git config gc.writeCommitGraph false &&
+ for i in $(test_seq $NUM_FIRST_LAYER_COMMITS)
+ do
+ test_commit $i &&
+ git branch commits/$i || return 1
+ done &&
+ git commit-graph write --reachable --split &&
+ graph_read_expect $NUM_FIRST_LAYER_COMMITS &&
+ test_line_count = 1 $graphdir/commit-graph-chain &&
+ for i in $(test_seq $SECOND_LAYER_SEQUENCE_START $SECOND_LAYER_SEQUENCE_END)
+ do
+ test_commit $i &&
+ git branch commits/$i || return 1
+ done &&
+ GIT_TEST_COMMIT_GRAPH_NO_GDAT=1 git commit-graph write --reachable --split=no-merge &&
+ test_line_count = 2 $graphdir/commit-graph-chain &&
+ test-tool read-graph >output &&
+ cat >expect <<-EOF &&
+ header: 43475048 1 $(test_oid oid_version) 4 1
+ num_commits: $NUM_SECOND_LAYER_COMMITS
+ chunks: oid_fanout oid_lookup commit_metadata
+ EOF
+ test_cmp expect output &&
+ git commit-graph verify &&
+ cat $graphdir/commit-graph-chain
+ )
+'
+
+# The new layer will be added without generation data chunk as it was not
+# present on the layer underneath it.
+#
+# 7 commits (No GDAT)
+# ------------------------
+# 16 commits (No GDAT)
+# ------------------------
+# 64 commits (GDAT)
+#
+test_expect_success 'do not write generation data chunk if not present on existing tip' '
+ git clone mixed mixed-no-gdat &&
+ (
+ cd mixed-no-gdat &&
+ for i in $(test_seq $THIRD_LAYER_SEQUENCE_START $THIRD_LAYER_SEQUENCE_END)
+ do
+ test_commit $i &&
+ git branch commits/$i || return 1
+ done &&
+ git commit-graph write --reachable --split=no-merge &&
+ test_line_count = 3 $graphdir/commit-graph-chain &&
+ test-tool read-graph >output &&
+ cat >expect <<-EOF &&
+ header: 43475048 1 $(test_oid oid_version) 4 2
+ num_commits: $NUM_THIRD_LAYER_COMMITS
+ chunks: oid_fanout oid_lookup commit_metadata
+ EOF
+ test_cmp expect output &&
+ git commit-graph verify
+ )
+'
+
+# Number of commits in each layer of the split-commit graph before merge:
+#
+# 8 commits (No GDAT)
+# ------------------------
+# 7 commits (No GDAT)
+# ------------------------
+# 16 commits (No GDAT)
+# ------------------------
+# 64 commits (GDAT)
+#
+# The top two layers are merged and do not have generation data chunk as layer below them does
+# not have generation data chunk.
+#
+# 15 commits (No GDAT)
+# ------------------------
+# 16 commits (No GDAT)
+# ------------------------
+# 64 commits (GDAT)
+#
+test_expect_success 'do not write generation data chunk if the topmost remaining layer does not have generation data chunk' '
+ git clone mixed-no-gdat mixed-merge-no-gdat &&
+ (
+ cd mixed-merge-no-gdat &&
+ for i in $(test_seq $FOURTH_LAYER_SEQUENCE_START $FOURTH_LAYER_SEQUENCE_END)
+ do
+ test_commit $i &&
+ git branch commits/$i || return 1
+ done &&
+ git commit-graph write --reachable --split --size-multiple 1 &&
+ test_line_count = 3 $graphdir/commit-graph-chain &&
+ test-tool read-graph >output &&
+ cat >expect <<-EOF &&
+ header: 43475048 1 $(test_oid oid_version) 4 2
+ num_commits: $(($NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS))
+ chunks: oid_fanout oid_lookup commit_metadata
+ EOF
+ test_cmp expect output &&
+ git commit-graph verify
+ )
+'
+
+# Number of commits in each layer of the split-commit graph before merge:
+#
+# 16 commits (No GDAT)
+# ------------------------
+# 15 commits (No GDAT)
+# ------------------------
+# 16 commits (No GDAT)
+# ------------------------
+# 64 commits (GDAT)
+#
+# The top three layers are merged and has generation data chunk as the topmost remaining layer
+# has generation data chunk.
+#
+# 47 commits (GDAT)
+# ------------------------
+# 64 commits (GDAT)
+#
+test_expect_success 'write generation data chunk if topmost remaining layer has generation data chunk' '
+ git clone mixed-merge-no-gdat mixed-merge-gdat &&
+ (
+ cd mixed-merge-gdat &&
+ for i in $(test_seq $FIFTH_LAYER_SEQUENCE_START $FIFTH_LAYER_SEQUENCE_END)
+ do
+ test_commit $i &&
+ git branch commits/$i || return 1
+ done &&
+ git commit-graph write --reachable --split --size-multiple 1 &&
+ test_line_count = 2 $graphdir/commit-graph-chain &&
+ test-tool read-graph >output &&
+ cat >expect <<-EOF &&
+ header: 43475048 1 $(test_oid oid_version) 5 1
+ num_commits: $(($NUM_SECOND_LAYER_COMMITS + $NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS + $NUM_FIFTH_LAYER_COMMITS))
+ chunks: oid_fanout oid_lookup commit_metadata generation_data
+ EOF
+ test_cmp expect output
+ )
+'
+
+test_expect_success 'write generation data chunk when commit-graph chain is replaced' '
+ git clone mixed mixed-replace &&
+ (
+ cd mixed-replace &&
+ git commit-graph write --reachable --split=replace &&
+ test_path_is_file $graphdir/commit-graph-chain &&
+ test_line_count = 1 $graphdir/commit-graph-chain &&
+ verify_chain_files_exist $graphdir &&
+ graph_read_expect $(($NUM_FIRST_LAYER_COMMITS + $NUM_SECOND_LAYER_COMMITS)) &&
+ git commit-graph verify
+ )
+'
+
test_done