2019-02-02 13:30:12 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Jiang Xin
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Test git pack-redundant
|
|
|
|
|
|
|
|
In order to test git-pack-redundant, we will create a number of objects and
|
2020-11-18 23:44:29 +00:00
|
|
|
packs in the repository `main.git`. The relationship between packs (P1-P8)
|
2019-02-02 13:30:12 +00:00
|
|
|
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.
|
|
|
|
|
|
|
|
| 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* | ! ! ! ! ! ! !
|
|
|
|
P3 | x x x x x x
|
|
|
|
P4* | ! ! ! ! !
|
|
|
|
P5 | x x x x
|
|
|
|
P6* | ! ! !
|
|
|
|
P7 | x x
|
|
|
|
P8* | !
|
|
|
|
----+--------------------------------------
|
|
|
|
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
|
2020-11-18 23:44:29 +00:00
|
|
|
(marked with letter s) are shared through alt-odb (of `main.git`). The
|
2019-02-02 13:30:12 +00:00
|
|
|
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
|
|
|
|
----+----------------------------------------------
|
|
|
|
Px1 | s s s x x x
|
|
|
|
Px2 | s s s x x x
|
|
|
|
'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2020-11-18 23:44:29 +00:00
|
|
|
main_repo=main.git
|
2019-02-02 13:30:12 +00:00
|
|
|
shared_repo=shared.git
|
|
|
|
|
2020-08-25 22:45:52 +00:00
|
|
|
git_pack_redundant='git pack-redundant --i-still-use-this'
|
|
|
|
|
2019-02-02 13:30:12 +00:00
|
|
|
# Create commits in <repo> and assign each commit's oid to shell variables
|
|
|
|
# given in the arguments (A, B, and C). E.g.:
|
|
|
|
#
|
|
|
|
# create_commits_in <repo> A B C
|
|
|
|
#
|
|
|
|
# NOTE: Avoid calling this function from a subshell since variable
|
|
|
|
# assignments will disappear when subshell exits.
|
|
|
|
create_commits_in () {
|
|
|
|
repo="$1" &&
|
|
|
|
if ! parent=$(git -C "$repo" rev-parse HEAD^{} 2>/dev/null)
|
|
|
|
then
|
|
|
|
parent=
|
|
|
|
fi &&
|
|
|
|
T=$(git -C "$repo" write-tree) &&
|
|
|
|
shift &&
|
|
|
|
while test $# -gt 0
|
|
|
|
do
|
|
|
|
name=$1 &&
|
|
|
|
test_tick &&
|
|
|
|
if test -z "$parent"
|
|
|
|
then
|
|
|
|
oid=$(echo $name | git -C "$repo" commit-tree $T)
|
|
|
|
else
|
|
|
|
oid=$(echo $name | git -C "$repo" commit-tree -p $parent $T)
|
|
|
|
fi &&
|
|
|
|
eval $name=$oid &&
|
|
|
|
parent=$oid &&
|
|
|
|
shift ||
|
|
|
|
return 1
|
|
|
|
done &&
|
2020-11-18 23:44:29 +00:00
|
|
|
git -C "$repo" update-ref refs/heads/main $oid
|
2019-02-02 13:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create pack in <repo> and assign pack id to variable given in the 2nd argument
|
|
|
|
# (<name>). Commits in the pack will be read from stdin. E.g.:
|
|
|
|
#
|
|
|
|
# create_pack_in <repo> <name> <<-EOF
|
|
|
|
# ...
|
|
|
|
# EOF
|
|
|
|
#
|
|
|
|
# NOTE: commits from stdin should be given using heredoc, not using pipe, and
|
|
|
|
# avoid calling this function from a subshell since variable assignments will
|
|
|
|
# disappear when subshell exits.
|
|
|
|
create_pack_in () {
|
|
|
|
repo="$1" &&
|
|
|
|
name="$2" &&
|
|
|
|
pack=$(git -C "$repo/objects/pack" pack-objects -q pack) &&
|
|
|
|
eval $name=$pack &&
|
|
|
|
eval P$pack=$name:$pack
|
|
|
|
}
|
|
|
|
|
|
|
|
format_packfiles () {
|
|
|
|
sed \
|
|
|
|
-e "s#.*/pack-\(.*\)\.idx#\1#" \
|
|
|
|
-e "s#.*/pack-\(.*\)\.pack#\1#" |
|
|
|
|
sort -u |
|
|
|
|
while read p
|
|
|
|
do
|
|
|
|
if test -z "$(eval echo \${P$p})"
|
|
|
|
then
|
|
|
|
echo $p
|
|
|
|
else
|
|
|
|
eval echo "\${P$p}"
|
|
|
|
fi
|
|
|
|
done |
|
|
|
|
sort
|
|
|
|
}
|
|
|
|
|
2020-11-18 23:44:29 +00:00
|
|
|
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
|
2019-02-02 13:30:12 +00:00
|
|
|
'
|
|
|
|
|
t5323: drop mentions of "master"
Commit 0696232390 (pack-redundant: fix crash when one packfile in repo,
2020-12-16) added one some new tests to t5323. At the time, the sub-repo
we used was called "master". But in a parallel branch, this was switched
to "main".
When the latter branch was merged in 27d7c8599b (Merge branch
'js/default-branch-name-tests-final-stretch', 2021-01-25), some of those
spots caused textual conflicts, but some (for tests that were far enough
away from other changed code) were just semantic. The merge resolution
fixed up most spots, but missed this one.
Even though this did impact actual code, it turned out not to fail the
tests. Running 'cd "$master_repo"' ended up staying in the same
directory, running the test in the main trash repo instead of the
sub-repo. But because the point of the test is checking behavior when
there are no packfiles, it worked in either repo (since both are empty
at this point in the script).
Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-25 01:35:52 +00:00
|
|
|
test_expect_success 'main: pack-redundant works with no packfile' '
|
2020-12-17 01:57:09 +00:00
|
|
|
(
|
t5323: drop mentions of "master"
Commit 0696232390 (pack-redundant: fix crash when one packfile in repo,
2020-12-16) added one some new tests to t5323. At the time, the sub-repo
we used was called "master". But in a parallel branch, this was switched
to "main".
When the latter branch was merged in 27d7c8599b (Merge branch
'js/default-branch-name-tests-final-stretch', 2021-01-25), some of those
spots caused textual conflicts, but some (for tests that were far enough
away from other changed code) were just semantic. The merge resolution
fixed up most spots, but missed this one.
Even though this did impact actual code, it turned out not to fail the
tests. Running 'cd "$master_repo"' ended up staying in the same
directory, running the test in the main trash repo instead of the
sub-repo. But because the point of the test is checking behavior when
there are no packfiles, it worked in either repo (since both are empty
at this point in the script).
Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-25 01:35:52 +00:00
|
|
|
cd "$main_repo" &&
|
2020-12-17 01:57:09 +00:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
fatal: Zero packs found!
|
|
|
|
EOF
|
2021-01-25 22:19:17 +00:00
|
|
|
test_must_fail $git_pack_redundant --all >actual 2>&1 &&
|
2020-12-17 01:57:09 +00:00
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2019-02-02 13:30:12 +00:00
|
|
|
#############################################################################
|
|
|
|
# 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
|
|
|
|
# ----+--------------------------------------
|
2020-12-17 01:57:09 +00:00
|
|
|
# ALL | x x x x x x x x
|
2019-02-02 13:30:12 +00:00
|
|
|
#
|
|
|
|
#############################################################################
|
2021-01-25 22:19:18 +00:00
|
|
|
test_expect_success 'main: pack-redundant works with one packfile' '
|
2020-11-18 23:44:29 +00:00
|
|
|
create_pack_in "$main_repo" P1 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$T
|
|
|
|
$A
|
|
|
|
$B
|
|
|
|
$C
|
|
|
|
$D
|
|
|
|
$E
|
|
|
|
$F
|
|
|
|
$R
|
|
|
|
EOF
|
2020-12-17 01:57:09 +00:00
|
|
|
(
|
2021-01-25 22:19:18 +00:00
|
|
|
cd "$main_repo" &&
|
2021-01-25 22:19:17 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2020-12-17 01:57:09 +00:00
|
|
|
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
|
|
|
|
#
|
|
|
|
#############################################################################
|
2021-01-25 22:19:18 +00:00
|
|
|
test_expect_success 'main: no redundant for pack 1, 2, 3' '
|
2020-11-18 23:44:29 +00:00
|
|
|
create_pack_in "$main_repo" P2 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$B
|
|
|
|
$C
|
|
|
|
$D
|
|
|
|
$E
|
|
|
|
$G
|
|
|
|
$H
|
|
|
|
$I
|
|
|
|
EOF
|
2020-11-18 23:44:29 +00:00
|
|
|
create_pack_in "$main_repo" P3 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$F
|
|
|
|
$I
|
|
|
|
$J
|
|
|
|
$K
|
|
|
|
$L
|
|
|
|
$M
|
|
|
|
EOF
|
|
|
|
(
|
2020-11-18 23:44:29 +00:00
|
|
|
cd "$main_repo" &&
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
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
|
2019-02-02 13:30:17 +00:00
|
|
|
# P2 | x x x x x x x
|
|
|
|
# P3* | ! ! ! ! ! !
|
2019-02-02 13:30:12 +00:00
|
|
|
# P4 | x x x x x
|
|
|
|
# P5 | x x x x
|
|
|
|
# ----+--------------------------------------
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x
|
|
|
|
#
|
|
|
|
#############################################################################
|
2020-11-18 23:44:29 +00:00
|
|
|
test_expect_success 'main: one of pack-2/pack-3 is redundant' '
|
|
|
|
create_pack_in "$main_repo" P4 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$J
|
|
|
|
$K
|
|
|
|
$L
|
|
|
|
$M
|
|
|
|
$P
|
|
|
|
EOF
|
2020-11-18 23:44:29 +00:00
|
|
|
create_pack_in "$main_repo" P5 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$G
|
|
|
|
$H
|
|
|
|
$N
|
|
|
|
$O
|
|
|
|
EOF
|
|
|
|
(
|
2020-11-18 23:44:29 +00:00
|
|
|
cd "$main_repo" &&
|
2019-02-02 13:30:12 +00:00
|
|
|
cat >expect <<-EOF &&
|
2019-02-02 13:30:17 +00:00
|
|
|
P3:$P3
|
2019-02-02 13:30:12 +00:00
|
|
|
EOF
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
format_packfiles <out >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 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* | ! ! ! ! ! ! !
|
|
|
|
# P3 | x x x x x x
|
|
|
|
# P4* | ! ! ! ! !
|
|
|
|
# P5 | x x x x
|
|
|
|
# P6* | ! ! !
|
|
|
|
# P7 | x x
|
|
|
|
# ----+--------------------------------------
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x x
|
|
|
|
#
|
|
|
|
#############################################################################
|
2020-11-18 23:44:29 +00:00
|
|
|
test_expect_success 'main: pack 2, 4, and 6 are redundant' '
|
|
|
|
create_pack_in "$main_repo" P6 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$N
|
|
|
|
$O
|
|
|
|
$Q
|
|
|
|
EOF
|
2020-11-18 23:44:29 +00:00
|
|
|
create_pack_in "$main_repo" P7 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$P
|
|
|
|
$Q
|
|
|
|
EOF
|
|
|
|
(
|
2020-11-18 23:44:29 +00:00
|
|
|
cd "$main_repo" &&
|
2019-02-02 13:30:12 +00:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
P2:$P2
|
|
|
|
P4:$P4
|
|
|
|
P6:$P6
|
|
|
|
EOF
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
format_packfiles <out >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 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* | ! ! ! ! ! ! !
|
|
|
|
# P3 | x x x x x x
|
|
|
|
# P4* | ! ! ! ! !
|
|
|
|
# P5 | x x x x
|
|
|
|
# P6* | ! ! !
|
|
|
|
# P7 | x x
|
|
|
|
# P8* | !
|
|
|
|
# ----+--------------------------------------
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x x
|
|
|
|
#
|
|
|
|
#############################################################################
|
2020-11-18 23:44:29 +00:00
|
|
|
test_expect_success 'main: pack-8 (subset of pack-1) is also redundant' '
|
|
|
|
create_pack_in "$main_repo" P8 <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$A
|
|
|
|
EOF
|
|
|
|
(
|
2020-11-18 23:44:29 +00:00
|
|
|
cd "$main_repo" &&
|
2019-02-02 13:30:12 +00:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
P2:$P2
|
|
|
|
P4:$P4
|
|
|
|
P6:$P6
|
|
|
|
P8:$P8
|
|
|
|
EOF
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
format_packfiles <out >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2020-11-18 23:44:29 +00:00
|
|
|
test_expect_success 'main: clean loose objects' '
|
2019-02-02 13:30:12 +00:00
|
|
|
(
|
2020-11-18 23:44:29 +00:00
|
|
|
cd "$main_repo" &&
|
2019-02-02 13:30:12 +00:00
|
|
|
git prune-packed &&
|
|
|
|
find objects -type f | sed -e "/objects\/pack\//d" >out &&
|
|
|
|
test_must_be_empty out
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2020-11-18 23:44:29 +00:00
|
|
|
test_expect_success 'main: remove redundant packs and pass fsck' '
|
2019-02-02 13:30:12 +00:00
|
|
|
(
|
2020-11-18 23:44:29 +00:00
|
|
|
cd "$main_repo" &&
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all | xargs rm &&
|
2019-02-02 13:30:12 +00:00
|
|
|
git fsck &&
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
test_must_be_empty out
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
# The following test cases will execute inside `shared.git`, instead of
|
2020-11-18 23:44:29 +00:00
|
|
|
# inside `main.git`.
|
2019-02-02 13:30:12 +00:00
|
|
|
test_expect_success 'setup shared.git' '
|
2020-11-18 23:44:29 +00:00
|
|
|
git clone --mirror "$main_repo" "$shared_repo" &&
|
2019-02-02 13:30:12 +00:00
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
2020-11-18 23:44:29 +00:00
|
|
|
printf "../../$main_repo/objects\n" >objects/info/alternates
|
2019-02-02 13:30:12 +00:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2019-02-02 13:30:17 +00:00
|
|
|
test_expect_success 'shared: all packs are redundant, but no output without --alt-odb' '
|
2019-02-02 13:30:12 +00:00
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
test_must_be_empty out
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# Chart of packs and objects for this test case
|
|
|
|
#
|
2020-11-18 23:44:29 +00:00
|
|
|
# ================= main.git ================
|
2019-02-02 13:30:12 +00:00
|
|
|
# | 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 |
|
|
|
|
# P3 | x x x x x x |
|
|
|
|
# P5 | x x x x |
|
|
|
|
# P7 | x x |
|
|
|
|
# ----+-------------------------------------- |
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x x |
|
|
|
|
# |
|
|
|
|
# |
|
|
|
|
# ================ shared.git =============== |
|
|
|
|
# | T A B C D E F G H I J K L M N O P Q R <objects/info/alternates>
|
|
|
|
# ----+--------------------------------------
|
|
|
|
# P1* | s s s s s s s s
|
|
|
|
# P3* | s s s s s s
|
|
|
|
# P5* | s s s s
|
|
|
|
# P7* | s s
|
|
|
|
# ----+--------------------------------------
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x x
|
|
|
|
#
|
|
|
|
#############################################################################
|
2019-02-02 13:30:17 +00:00
|
|
|
test_expect_success 'shared: show redundant packs in stderr for verbose mode' '
|
2019-02-02 13:30:12 +00:00
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
P1:$P1
|
|
|
|
P3:$P3
|
|
|
|
P5:$P5
|
|
|
|
P7:$P7
|
|
|
|
EOF
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all --verbose >out 2>out.err &&
|
2019-02-02 13:30:12 +00:00
|
|
|
test_must_be_empty out &&
|
|
|
|
grep "pack$" out.err | format_packfiles >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'shared: remove redundant packs, no packs left' '
|
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
fatal: Zero packs found!
|
|
|
|
EOF
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all --alt-odb | xargs rm &&
|
2019-02-02 13:30:12 +00:00
|
|
|
git fsck &&
|
2020-08-25 22:45:52 +00:00
|
|
|
test_must_fail $git_pack_redundant --all --alt-odb >actual 2>&1 &&
|
2019-02-02 13:30:12 +00:00
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'shared: create new objects and packs' '
|
|
|
|
create_commits_in "$shared_repo" X Y Z &&
|
|
|
|
create_pack_in "$shared_repo" Px1 <<-EOF &&
|
|
|
|
$X
|
|
|
|
$Y
|
|
|
|
$Z
|
|
|
|
$A
|
|
|
|
$B
|
|
|
|
$C
|
|
|
|
EOF
|
|
|
|
create_pack_in "$shared_repo" Px2 <<-EOF
|
|
|
|
$X
|
|
|
|
$Y
|
|
|
|
$Z
|
|
|
|
$D
|
|
|
|
$E
|
|
|
|
$F
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'shared: no redundant without --alt-odb' '
|
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
test_must_be_empty out
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# Chart of packs and objects for this test case
|
|
|
|
#
|
2020-11-18 23:44:29 +00:00
|
|
|
# ================= main.git ================
|
2019-02-02 13:30:12 +00:00
|
|
|
# | 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 |
|
|
|
|
# P3 | x x x x x x |
|
|
|
|
# P5 | x x x x |
|
|
|
|
# P7 | x x |
|
|
|
|
# ----+-------------------------------------- |
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x x |
|
|
|
|
# |
|
|
|
|
# |
|
|
|
|
# ================ shared.git ======================= |
|
|
|
|
# | T A B C D E F G H I J K L M N O P Q R X Y Z <objects/info/alternates>
|
|
|
|
# ----+----------------------------------------------
|
|
|
|
# Px1 | s s s x x x
|
|
|
|
# Px2*| s s s ! ! !
|
|
|
|
# ----+----------------------------------------------
|
|
|
|
# ALL | s s s s s s s s s s s s s s s s s s s x x x
|
|
|
|
#
|
|
|
|
#############################################################################
|
|
|
|
test_expect_success 'shared: one pack is redundant with --alt-odb' '
|
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all --alt-odb >out &&
|
2019-02-02 13:30:12 +00:00
|
|
|
format_packfiles <out >actual &&
|
|
|
|
test_line_count = 1 actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# Chart of packs and objects for this test case
|
|
|
|
#
|
2020-11-18 23:44:29 +00:00
|
|
|
# ================= main.git ================
|
2019-02-02 13:30:12 +00:00
|
|
|
# | 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 |
|
|
|
|
# P3 | x x x x x x |
|
|
|
|
# P5 | x x x x |
|
|
|
|
# P7 | x x |
|
|
|
|
# ----+-------------------------------------- |
|
|
|
|
# ALL | x x x x x x x x x x x x x x x x x x x |
|
|
|
|
# |
|
|
|
|
# |
|
|
|
|
# ================ shared.git ======================= |
|
|
|
|
# | T A B C D E F G H I J K L M N O P Q R X Y Z <objects/info/alternates>
|
|
|
|
# ----+----------------------------------------------
|
|
|
|
# Px1*| s s s i i i
|
|
|
|
# Px2*| s s s i i i
|
|
|
|
# ----+----------------------------------------------
|
|
|
|
# ALL | s s s s s s s s s s s s s s s s s s s i i i
|
|
|
|
# (ignored objects, marked with i)
|
|
|
|
#
|
|
|
|
#############################################################################
|
|
|
|
test_expect_success 'shared: ignore unique objects and all two packs are redundant' '
|
|
|
|
(
|
|
|
|
cd "$shared_repo" &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
Px1:$Px1
|
|
|
|
Px2:$Px2
|
|
|
|
EOF
|
2020-08-25 22:45:52 +00:00
|
|
|
$git_pack_redundant --all --alt-odb >out <<-EOF &&
|
2019-02-02 13:30:12 +00:00
|
|
|
$X
|
|
|
|
$Y
|
|
|
|
$Z
|
|
|
|
EOF
|
|
|
|
format_packfiles <out >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|