summaryrefslogtreecommitdiff
path: root/t/t5323-pack-redundant.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5323-pack-redundant.sh')
-rwxr-xr-xt/t5323-pack-redundant.sh129
1 files changed, 80 insertions, 49 deletions
diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh
index 6b4d1ca..8b01793 100755
--- a/t/t5323-pack-redundant.sh
+++ b/t/t5323-pack-redundant.sh
@@ -6,7 +6,7 @@
test_description='Test git pack-redundant
In order to test git-pack-redundant, we will create a number of objects and
-packs in the repository `master.git`. The relationship between packs (P1-P8)
+packs in the repository `main.git`. The relationship between packs (P1-P8)
and objects (T, A-R) is showed in the following chart. Objects of a pack will
be marked with letter x, while objects of redundant packs will be marked with
exclamation point, and redundant pack itself will be marked with asterisk.
@@ -25,7 +25,7 @@ exclamation point, and redundant pack itself will be marked with asterisk.
ALL | x x x x x x x x x x x x x x x x x x x
Another repository `shared.git` has unique objects (X-Z), while other objects
-(marked with letter s) are shared through alt-odb (of `master.git`). The
+(marked with letter s) are shared through alt-odb (of `main.git`). The
relationship between packs and objects is as follows:
| T A B C D E F G H I J K L M N O P Q R X Y Z
@@ -36,9 +36,11 @@ relationship between packs and objects is as follows:
. ./test-lib.sh
-master_repo=master.git
+main_repo=main.git
shared_repo=shared.git
+git_pack_redundant='git pack-redundant --i-still-use-this'
+
# Create commits in <repo> and assign each commit's oid to shell variables
# given in the arguments (A, B, and C). E.g.:
#
@@ -69,7 +71,7 @@ create_commits_in () {
shift ||
return 1
done &&
- git -C "$repo" update-ref refs/heads/master $oid
+ git -C "$repo" update-ref refs/heads/main $oid
}
# Create pack in <repo> and assign pack id to variable given in the 2nd argument
@@ -107,9 +109,20 @@ format_packfiles () {
sort
}
-test_expect_success 'setup master repo' '
- git init --bare "$master_repo" &&
- create_commits_in "$master_repo" A B C D E F G H I J K L M N O P Q R
+test_expect_success 'setup main repo' '
+ git init --bare "$main_repo" &&
+ create_commits_in "$main_repo" A B C D E F G H I J K L M N O P Q R
+'
+
+test_expect_success 'master: pack-redundant works with no packfile' '
+ (
+ cd "$master_repo" &&
+ cat >expect <<-EOF &&
+ fatal: Zero packs found!
+ EOF
+ test_must_fail $git_pack_redundant --all >actual 2>&1 &&
+ test_cmp expect actual
+ )
'
#############################################################################
@@ -118,14 +131,12 @@ test_expect_success 'setup master repo' '
# | T A B C D E F G H I J K L M N O P Q R
# ----+--------------------------------------
# P1 | x x x x x x x x
-# P2 | x x x x x x x
-# P3 | x x x x x x
# ----+--------------------------------------
-# ALL | x x x x x x x x x x x x x x x
+# ALL | x x x x x x x x
#
#############################################################################
-test_expect_success 'master: no redundant for pack 1, 2, 3' '
- create_pack_in "$master_repo" P1 <<-EOF &&
+test_expect_success 'main: pack-redundant works with one packfile' '
+ create_pack_in "$main_repo" P1 <<-EOF &&
$T
$A
$B
@@ -135,7 +146,27 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
$F
$R
EOF
- create_pack_in "$master_repo" P2 <<-EOF &&
+ (
+ cd "$main_repo" &&
+ $git_pack_redundant --all >out &&
+ test_must_be_empty out
+ )
+'
+
+#############################################################################
+# Chart of packs and objects for this test case
+#
+# | T A B C D E F G H I J K L M N O P Q R
+# ----+--------------------------------------
+# P1 | x x x x x x x x
+# P2 | x x x x x x x
+# P3 | x x x x x x
+# ----+--------------------------------------
+# ALL | x x x x x x x x x x x x x x x
+#
+#############################################################################
+test_expect_success 'main: no redundant for pack 1, 2, 3' '
+ create_pack_in "$main_repo" P2 <<-EOF &&
$B
$C
$D
@@ -144,7 +175,7 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
$H
$I
EOF
- create_pack_in "$master_repo" P3 <<-EOF &&
+ create_pack_in "$main_repo" P3 <<-EOF &&
$F
$I
$J
@@ -153,8 +184,8 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
$M
EOF
(
- cd "$master_repo" &&
- git pack-redundant --all >out &&
+ cd "$main_repo" &&
+ $git_pack_redundant --all >out &&
test_must_be_empty out
)
'
@@ -173,26 +204,26 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
# ALL | x x x x x x x x x x x x x x x x x x
#
#############################################################################
-test_expect_success 'master: one of pack-2/pack-3 is redundant' '
- create_pack_in "$master_repo" P4 <<-EOF &&
+test_expect_success 'main: one of pack-2/pack-3 is redundant' '
+ create_pack_in "$main_repo" P4 <<-EOF &&
$J
$K
$L
$M
$P
EOF
- create_pack_in "$master_repo" P5 <<-EOF &&
+ create_pack_in "$main_repo" P5 <<-EOF &&
$G
$H
$N
$O
EOF
(
- cd "$master_repo" &&
+ cd "$main_repo" &&
cat >expect <<-EOF &&
P3:$P3
EOF
- git pack-redundant --all >out &&
+ $git_pack_redundant --all >out &&
format_packfiles <out >actual &&
test_cmp expect actual
)
@@ -214,24 +245,24 @@ test_expect_success 'master: one of pack-2/pack-3 is redundant' '
# ALL | x x x x x x x x x x x x x x x x x x x
#
#############################################################################
-test_expect_success 'master: pack 2, 4, and 6 are redundant' '
- create_pack_in "$master_repo" P6 <<-EOF &&
+test_expect_success 'main: pack 2, 4, and 6 are redundant' '
+ create_pack_in "$main_repo" P6 <<-EOF &&
$N
$O
$Q
EOF
- create_pack_in "$master_repo" P7 <<-EOF &&
+ create_pack_in "$main_repo" P7 <<-EOF &&
$P
$Q
EOF
(
- cd "$master_repo" &&
+ cd "$main_repo" &&
cat >expect <<-EOF &&
P2:$P2
P4:$P4
P6:$P6
EOF
- git pack-redundant --all >out &&
+ $git_pack_redundant --all >out &&
format_packfiles <out >actual &&
test_cmp expect actual
)
@@ -254,57 +285,57 @@ test_expect_success 'master: pack 2, 4, and 6 are redundant' '
# ALL | x x x x x x x x x x x x x x x x x x x
#
#############################################################################
-test_expect_success 'master: pack-8 (subset of pack-1) is also redundant' '
- create_pack_in "$master_repo" P8 <<-EOF &&
+test_expect_success 'main: pack-8 (subset of pack-1) is also redundant' '
+ create_pack_in "$main_repo" P8 <<-EOF &&
$A
EOF
(
- cd "$master_repo" &&
+ cd "$main_repo" &&
cat >expect <<-EOF &&
P2:$P2
P4:$P4
P6:$P6
P8:$P8
EOF
- git pack-redundant --all >out &&
+ $git_pack_redundant --all >out &&
format_packfiles <out >actual &&
test_cmp expect actual
)
'
-test_expect_success 'master: clean loose objects' '
+test_expect_success 'main: clean loose objects' '
(
- cd "$master_repo" &&
+ cd "$main_repo" &&
git prune-packed &&
find objects -type f | sed -e "/objects\/pack\//d" >out &&
test_must_be_empty out
)
'
-test_expect_success 'master: remove redundant packs and pass fsck' '
+test_expect_success 'main: remove redundant packs and pass fsck' '
(
- cd "$master_repo" &&
- git pack-redundant --all | xargs rm &&
+ cd "$main_repo" &&
+ $git_pack_redundant --all | xargs rm &&
git fsck &&
- git pack-redundant --all >out &&
+ $git_pack_redundant --all >out &&
test_must_be_empty out
)
'
# The following test cases will execute inside `shared.git`, instead of
-# inside `master.git`.
+# inside `main.git`.
test_expect_success 'setup shared.git' '
- git clone --mirror "$master_repo" "$shared_repo" &&
+ git clone --mirror "$main_repo" "$shared_repo" &&
(
cd "$shared_repo" &&
- printf "../../$master_repo/objects\n" >objects/info/alternates
+ printf "../../$main_repo/objects\n" >objects/info/alternates
)
'
test_expect_success 'shared: all packs are redundant, but no output without --alt-odb' '
(
cd "$shared_repo" &&
- git pack-redundant --all >out &&
+ $git_pack_redundant --all >out &&
test_must_be_empty out
)
'
@@ -312,7 +343,7 @@ test_expect_success 'shared: all packs are redundant, but no output without --al
#############################################################################
# Chart of packs and objects for this test case
#
-# ================ master.git ===============
+# ================= main.git ================
# | T A B C D E F G H I J K L M N O P Q R <----------+
# ----+-------------------------------------- |
# P1 | x x x x x x x x |
@@ -343,7 +374,7 @@ test_expect_success 'shared: show redundant packs in stderr for verbose mode' '
P5:$P5
P7:$P7
EOF
- git pack-redundant --all --verbose >out 2>out.err &&
+ $git_pack_redundant --all --verbose >out 2>out.err &&
test_must_be_empty out &&
grep "pack$" out.err | format_packfiles >actual &&
test_cmp expect actual
@@ -356,9 +387,9 @@ test_expect_success 'shared: remove redundant packs, no packs left' '
cat >expect <<-EOF &&
fatal: Zero packs found!
EOF
- git pack-redundant --all --alt-odb | xargs rm &&
+ $git_pack_redundant --all --alt-odb | xargs rm &&
git fsck &&
- test_must_fail git pack-redundant --all --alt-odb >actual 2>&1 &&
+ test_must_fail $git_pack_redundant --all --alt-odb >actual 2>&1 &&
test_cmp expect actual
)
'
@@ -386,7 +417,7 @@ test_expect_success 'shared: create new objects and packs' '
test_expect_success 'shared: no redundant without --alt-odb' '
(
cd "$shared_repo" &&
- git pack-redundant --all >out &&
+ $git_pack_redundant --all >out &&
test_must_be_empty out
)
'
@@ -394,7 +425,7 @@ test_expect_success 'shared: no redundant without --alt-odb' '
#############################################################################
# Chart of packs and objects for this test case
#
-# ================ master.git ===============
+# ================= main.git ================
# | T A B C D E F G H I J K L M N O P Q R <----------------+
# ----+-------------------------------------- |
# P1 | x x x x x x x x |
@@ -417,7 +448,7 @@ test_expect_success 'shared: no redundant without --alt-odb' '
test_expect_success 'shared: one pack is redundant with --alt-odb' '
(
cd "$shared_repo" &&
- git pack-redundant --all --alt-odb >out &&
+ $git_pack_redundant --all --alt-odb >out &&
format_packfiles <out >actual &&
test_line_count = 1 actual
)
@@ -426,7 +457,7 @@ test_expect_success 'shared: one pack is redundant with --alt-odb' '
#############################################################################
# Chart of packs and objects for this test case
#
-# ================ master.git ===============
+# ================= main.git ================
# | T A B C D E F G H I J K L M N O P Q R <----------------+
# ----+-------------------------------------- |
# P1 | x x x x x x x x |
@@ -454,7 +485,7 @@ test_expect_success 'shared: ignore unique objects and all two packs are redunda
Px1:$Px1
Px2:$Px2
EOF
- git pack-redundant --all --alt-odb >out <<-EOF &&
+ $git_pack_redundant --all --alt-odb >out <<-EOF &&
$X
$Y
$Z