Jiang Xin <[email protected]> writes:
> From: Jiang Xin <[email protected]>
>
> Add test cases for git pack-redundant to validate new algorithm for git
> pack-redundant.
>
> Signed-off-by: Jiang Xin <[email protected]>
> Reviewed-by: SZEDER Gábor <[email protected]>
> ---
> t/t5323-pack-redundant.sh | 157 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 157 insertions(+)
> create mode 100755 t/t5323-pack-redundant.sh
>
> diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh
> new file mode 100755
> index 0000000000..7410426dee
> --- /dev/null
> +++ b/t/t5323-pack-redundant.sh
> @@ -0,0 +1,157 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2018 Jiang Xin
> +#
> +
> +test_description='git pack-redundant test'
> +
> +. ./test-lib.sh
> +
> +create_commits()
> +{
Style (see Documentation/CodingGuidelines).
> + parent=
> + for name in A B C D E F G H I J K L M N O P Q R
> + do
> + test_tick &&
> + T=$(git write-tree) &&
> + if test -z "$parent"
> + then
> + oid=$(echo $name | git commit-tree $T)
> + else
> + oid=$(echo $name | git commit-tree -p $parent $T)
> + fi &&
> + eval $name=$oid &&
> + parent=$oid ||
> + return 1
> + done
> + git update-ref refs/heads/master $M
> +}
> +
> +create_pack_1()
> +{
> + P1=$(cd .git/objects/pack; printf "$T\n$A\n$B\n$C\n$D\n$E\n$F\n$R\n" |
> git pack-objects pack 2>/dev/null) &&
Yikes. Can't "git pack-objects" get the input directly without
overlong printf, something along the lines of...
P1=$(git -C .git/objects/pack pack-objects pack <<-EOF
$A
$B
$C
...
$R
EOF
)
> + eval P$P1=P1:$P1
> +}
> ...
> +test_expect_success 'setup' '
> + create_commits
> +'
> +
> +test_expect_success 'no redundant packs' '
> + create_pack_1 && create_pack_2 && create_pack_3 &&
> + git pack-redundant --all >out &&
> + test_must_be_empty out
> +'
> +
> +test_expect_success 'create pack 4, 5' '
> + create_pack_4 && create_pack_5
> +'
> +
> +cat >expected <<EOF
> +P2:$P2
> +EOF
Move this to the next "expect success" block?
> +test_expect_success 'one of pack-2/pack-3 is redundant' '
> + git pack-redundant --all >out &&
> + sed -E -e "s#.*/pack-(.*)\.(idx|pack)#\1#" out | \
How portable is "sed -E" (it is not even in POSIX.1)? Wouldn't it
be easier to work with to have two "-e" fed to a single sed
invocation instead?