diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-04-04 10:56:21 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-04-04 10:56:21 -0700 |
commit | e8926670d4167c664f7dcbbec1c1887c51b5f08f (patch) | |
tree | 8c0394139b248a8b49b26430e1d9e75036637e74 /t | |
parent | Merge branch 'ds/partial-bundle-more' (diff) | |
parent | test-lib-functions: remove test_subcommand_inexact (diff) | |
download | tgif-e8926670d4167c664f7dcbbec1c1887c51b5f08f.tar.xz |
Merge branch 'ds/t7700-kept-pack-test'
Test clean-up.
* ds/t7700-kept-pack-test:
test-lib-functions: remove test_subcommand_inexact
t7700: check post-condition in kept-pack test
Diffstat (limited to 't')
-rwxr-xr-x | t/t7700-repack.sh | 57 | ||||
-rw-r--r-- | t/test-lib-functions.sh | 34 |
2 files changed, 54 insertions, 37 deletions
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 770d143204..ca45c4cd2c 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -369,10 +369,61 @@ test_expect_success '--write-midx with preferred bitmap tips' ' ) ' +# The first argument is expected to be a filename +# and that file should contain the name of a .idx +# file. Send the list of objects in that .idx file +# into stdout. +get_sorted_objects_from_pack () { + git show-index <$(cat "$1") >raw && + cut -d" " -f2 raw +} + test_expect_success '--write-midx -b packs non-kept objects' ' - GIT_TRACE2_EVENT="$(pwd)/trace.txt" \ - git repack --write-midx -a -b && - test_subcommand_inexact git pack-objects --honor-pack-keep <trace.txt + git init repo && + test_when_finished "rm -fr repo" && + ( + cd repo && + + # Create a kept pack-file + test_commit base && + git repack -ad && + find $objdir/pack -name "*.idx" >before && + test_line_count = 1 before && + before_name=$(cat before) && + >${before_name%.idx}.keep && + + # Create a non-kept pack-file + test_commit other && + git repack && + + # Create loose objects + test_commit loose && + + # Repack everything + git repack --write-midx -a -b -d && + + # There should be two pack-files now, the + # old, kept pack and the new, non-kept pack. + find $objdir/pack -name "*.idx" | sort >after && + test_line_count = 2 after && + find $objdir/pack -name "*.keep" >kept && + kept_name=$(cat kept) && + echo ${kept_name%.keep}.idx >kept-idx && + test_cmp before kept-idx && + + # Get object list from the kept pack. + get_sorted_objects_from_pack before >old.objects && + + # Get object list from the one non-kept pack-file + comm -13 before after >new-pack && + test_line_count = 1 new-pack && + get_sorted_objects_from_pack new-pack >new.objects && + + # None of the objects in the new pack should + # exist within the kept pack. + comm -12 old.objects new.objects >shared.objects && + test_must_be_empty shared.objects + ) ' test_expect_success TTY '--quiet disables progress' ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 1c3d65e6ea..93c03380d4 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1865,40 +1865,6 @@ test_subcommand () { } # Check that the given command was invoked as part of the -# trace2-format trace on stdin, but without an exact set of -# arguments. -# -# test_subcommand [!] <command> <args>... < <trace> -# -# For example, to look for an invocation of "git pack-objects" -# with the "--honor-pack-keep" argument, use -# -# GIT_TRACE2_EVENT=event.log git repack ... && -# test_subcommand git pack-objects --honor-pack-keep <event.log -# -# If the first parameter passed is !, this instead checks that -# the given command was not called. -# -test_subcommand_inexact () { - local negate= - if test "$1" = "!" - then - negate=t - shift - fi - - local expr=$(printf '"%s".*' "$@") - expr="${expr%,}" - - if test -n "$negate" - then - ! grep "\"event\":\"child_start\".*\[$expr\]" - else - grep "\"event\":\"child_start\".*\[$expr\]" - fi -} - -# Check that the given command was invoked as part of the # trace2-format trace on stdin. # # test_region [!] <category> <label> git <command> <args>... |