Skip to content

Commit e892667

Browse files
committed
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
2 parents 3928e90 + 16dcec2 commit e892667

File tree

2 files changed

+54
-37
lines changed

2 files changed

+54
-37
lines changed

t/t7700-repack.sh

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,61 @@ test_expect_success '--write-midx with preferred bitmap tips' '
369369
)
370370
'
371371

372+
# The first argument is expected to be a filename
373+
# and that file should contain the name of a .idx
374+
# file. Send the list of objects in that .idx file
375+
# into stdout.
376+
get_sorted_objects_from_pack () {
377+
git show-index <$(cat "$1") >raw &&
378+
cut -d" " -f2 raw
379+
}
380+
372381
test_expect_success '--write-midx -b packs non-kept objects' '
373-
GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
374-
git repack --write-midx -a -b &&
375-
test_subcommand_inexact git pack-objects --honor-pack-keep <trace.txt
382+
git init repo &&
383+
test_when_finished "rm -fr repo" &&
384+
(
385+
cd repo &&
386+
387+
# Create a kept pack-file
388+
test_commit base &&
389+
git repack -ad &&
390+
find $objdir/pack -name "*.idx" >before &&
391+
test_line_count = 1 before &&
392+
before_name=$(cat before) &&
393+
>${before_name%.idx}.keep &&
394+
395+
# Create a non-kept pack-file
396+
test_commit other &&
397+
git repack &&
398+
399+
# Create loose objects
400+
test_commit loose &&
401+
402+
# Repack everything
403+
git repack --write-midx -a -b -d &&
404+
405+
# There should be two pack-files now, the
406+
# old, kept pack and the new, non-kept pack.
407+
find $objdir/pack -name "*.idx" | sort >after &&
408+
test_line_count = 2 after &&
409+
find $objdir/pack -name "*.keep" >kept &&
410+
kept_name=$(cat kept) &&
411+
echo ${kept_name%.keep}.idx >kept-idx &&
412+
test_cmp before kept-idx &&
413+
414+
# Get object list from the kept pack.
415+
get_sorted_objects_from_pack before >old.objects &&
416+
417+
# Get object list from the one non-kept pack-file
418+
comm -13 before after >new-pack &&
419+
test_line_count = 1 new-pack &&
420+
get_sorted_objects_from_pack new-pack >new.objects &&
421+
422+
# None of the objects in the new pack should
423+
# exist within the kept pack.
424+
comm -12 old.objects new.objects >shared.objects &&
425+
test_must_be_empty shared.objects
426+
)
376427
'
377428

378429
test_expect_success TTY '--quiet disables progress' '

t/test-lib-functions.sh

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,40 +1864,6 @@ test_subcommand () {
18641864
fi
18651865
}
18661866

1867-
# Check that the given command was invoked as part of the
1868-
# trace2-format trace on stdin, but without an exact set of
1869-
# arguments.
1870-
#
1871-
# test_subcommand [!] <command> <args>... < <trace>
1872-
#
1873-
# For example, to look for an invocation of "git pack-objects"
1874-
# with the "--honor-pack-keep" argument, use
1875-
#
1876-
# GIT_TRACE2_EVENT=event.log git repack ... &&
1877-
# test_subcommand git pack-objects --honor-pack-keep <event.log
1878-
#
1879-
# If the first parameter passed is !, this instead checks that
1880-
# the given command was not called.
1881-
#
1882-
test_subcommand_inexact () {
1883-
local negate=
1884-
if test "$1" = "!"
1885-
then
1886-
negate=t
1887-
shift
1888-
fi
1889-
1890-
local expr=$(printf '"%s".*' "$@")
1891-
expr="${expr%,}"
1892-
1893-
if test -n "$negate"
1894-
then
1895-
! grep "\"event\":\"child_start\".*\[$expr\]"
1896-
else
1897-
grep "\"event\":\"child_start\".*\[$expr\]"
1898-
fi
1899-
}
1900-
19011867
# Check that the given command was invoked as part of the
19021868
# trace2-format trace on stdin.
19031869
#

0 commit comments

Comments
 (0)