aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t5319-multi-pack-index.sh64
-rwxr-xr-xt/t7703-repack-geometric.sh35
2 files changed, 99 insertions, 0 deletions
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index 93f319a4b2..794f8b5ab4 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -350,9 +350,73 @@ test_expect_success 'preferred pack from existing MIDX without bitmaps' '
# the new MIDX
git multi-pack-index write --preferred-pack=pack-$pack.pack
)
+'
+
+test_expect_success 'preferred pack cannot be determined without bitmap' '
+ test_when_finished "rm -fr preferred-can-be-queried" &&
+ git init preferred-can-be-queried &&
+ (
+ cd preferred-can-be-queried &&
+ test_commit initial &&
+ git repack -Adl --write-midx --no-write-bitmap-index &&
+ test_must_fail test-tool read-midx --preferred-pack .git/objects 2>err &&
+ test_grep "could not determine MIDX preferred pack" err &&
+ git repack -Adl --write-midx --write-bitmap-index &&
+ test-tool read-midx --preferred-pack .git/objects
+ )
+'
+
+test_midx_is_retained () {
+ test-tool chmtime =0 .git/objects/pack/multi-pack-index &&
+ ls -l .git/objects/pack/multi-pack-index >expect &&
+ git multi-pack-index write "$@" &&
+ ls -l .git/objects/pack/multi-pack-index >actual &&
+ test_cmp expect actual
+}
+
+test_midx_is_rewritten () {
+ test-tool chmtime =0 .git/objects/pack/multi-pack-index &&
+ ls -l .git/objects/pack/multi-pack-index >expect &&
+ git multi-pack-index write "$@" &&
+ ls -l .git/objects/pack/multi-pack-index >actual &&
+ ! test_cmp expect actual
+}
+
+test_expect_success 'up-to-date multi-pack-index is retained' '
+ test_when_finished "rm -fr midx-up-to-date" &&
+ git init midx-up-to-date &&
+ (
+ cd midx-up-to-date &&
+
+ # Write the initial pack that contains the most objects.
+ test_commit first &&
+ test_commit second &&
+ git repack -Ad --write-midx &&
+ test_midx_is_retained &&
+
+ # Writing a new bitmap index should cause us to regenerate the MIDX.
+ test_midx_is_rewritten --bitmap &&
+ test_midx_is_retained --bitmap &&
+ # Ensure that writing a new packfile causes us to rewrite the index.
+ test_commit incremental &&
+ git repack -d &&
+ test_midx_is_rewritten &&
+ test_midx_is_retained &&
+
+ for pack in .git/objects/pack/*.idx
+ do
+ basename "$pack" || exit 1
+ done >stdin &&
+ test_line_count = 2 stdin &&
+ test_midx_is_retained --stdin-packs <stdin &&
+ head -n1 stdin >stdin.trimmed &&
+ test_midx_is_rewritten --stdin-packs <stdin.trimmed
+ )
'
+test_done
+
test_expect_success 'verify multi-pack-index success' '
git multi-pack-index verify --object-dir=$objdir
'
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh
index 9fc1626fbf..98806cdb6f 100755
--- a/t/t7703-repack-geometric.sh
+++ b/t/t7703-repack-geometric.sh
@@ -287,6 +287,41 @@ test_expect_success '--geometric with pack.packSizeLimit' '
)
'
+test_expect_success '--geometric --write-midx retains up-to-date MIDX without bitmap index' '
+ test_when_finished "rm -fr repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit initial &&
+
+ test_path_is_missing .git/objects/pack/multi-pack-index &&
+ git repack --geometric=2 --write-midx --no-write-bitmap-index &&
+ test_path_is_file .git/objects/pack/multi-pack-index &&
+ test-tool chmtime =0 .git/objects/pack/multi-pack-index &&
+
+ ls -l .git/objects/pack/ >expect &&
+ git repack --geometric=2 --write-midx --no-write-bitmap-index &&
+ ls -l .git/objects/pack/ >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success '--geometric --write-midx retains up-to-date MIDX with bitmap index' '
+ test_when_finished "rm -fr repo" &&
+ git init repo &&
+ test_commit -C repo initial &&
+
+ test_path_is_missing repo/.git/objects/pack/multi-pack-index &&
+ git -C repo repack --geometric=2 --write-midx --write-bitmap-index &&
+ test_path_is_file repo/.git/objects/pack/multi-pack-index &&
+ test-tool chmtime =0 repo/.git/objects/pack/multi-pack-index &&
+
+ ls -l repo/.git/objects/pack/ >expect &&
+ git -C repo repack --geometric=2 --write-midx --write-bitmap-index &&
+ ls -l repo/.git/objects/pack/ >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '--geometric --write-midx with packfiles in main and alternate ODB' '
test_when_finished "rm -fr shared member" &&