From b0f1e442fb29782fd17a06744ae8da79e05a15b2 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 17 Sep 2024 14:53:52 -0400 Subject: [PATCH] repack: test --full-name-hash option The new '--full-name-hash' option for 'git repack' is a simple pass-through to the underlying 'git pack-objects' subcommand. However, this subcommand may have other options and a temporary filename as part of the subcommand execution that may not be predictable or could change over time. The existing test_subcommand method requires an exact list of arguments for the subcommand. This is too rigid for our needs here, so create a new method, test_subcommand_flex. Use it to check that the --full-name-hash option is passing through. Signed-off-by: Derrick Stolee --- t/t7700-repack.sh | 7 +++++++ t/test-lib-functions.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index be1188e7365b19..1feb6643e69979 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -776,6 +776,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 ... < +# +# 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. #