Skip to content
Merged
7 changes: 7 additions & 0 deletions t/t7700-repack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,13 @@ test_expect_success 'repack -ad cleans up old .tmp-* packs' '
test_must_be_empty tmpfiles
'

test_expect_success '--full-name-hash option passes through to pack-objects' '
GIT_TRACE2_EVENT="$(pwd)/full-trace.txt" \
git repack -a --full-name-hash &&
test_subcommand_flex git pack-objects --full-name-hash <full-trace.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, we could (ab-)use the fact that test_command, as all shell functions, really, is quite lax. One side effect of this is that it does not special-case characters that have special meaning in regular expressions. Therefore, we could easily write:

test_subcommand git pack-objects ".*--full-name-hash.*" <full-trace.txt

here.

But this is a minor point, and irrelevant for correctness (and I really want to focus on correctness because I want to slip this into v2.46.2 that, just like v2.46.1, showed up at my doorstep under-announced).

'


test_expect_success 'setup for update-server-info' '
git init update-server-info &&
test_commit -C update-server-info message
Expand Down
27 changes: 27 additions & 0 deletions t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,33 @@ test_subcommand () {
fi
}


# Check that the given subcommand was run with the given set of
# arguments in order (but with possible extra arguments).
#
# test_subcommand_flex [!] <command> <args>... < <trace>
#
# If the first parameter passed is !, this instead checks that
# the given command was not called.
#
test_subcommand_flex () {
local negate=
if test "$1" = "!"
then
negate=t
shift
fi

local expr="$(printf '"%s",.*' "$@")"

if test -n "$negate"
then
! grep "\[$expr\]"
else
grep "\[$expr\]"
fi
}

# Check that the given command was invoked as part of the
# trace2-format trace on stdin.
#
Expand Down