diff options
| author | Derrick Stolee <stolee@gmail.com> | 2025-01-27 19:02:30 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-27 13:21:43 -0800 |
| commit | 928ef41dd879a1e12373842e865477e9e1167621 (patch) | |
| tree | 59d8ea4367a4381391f6a5c007f0775efc58cdcb /t | |
| parent | fc62e033cd93ff6b93e312d89bfb5683a4c6f90c (diff) | |
| download | git-928ef41dd879a1e12373842e865477e9e1167621.tar.xz | |
repack: add --name-hash-version option
The new '--name-hash-version' 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
--name-hash-version option is passing through.
Since we are modifying the 'git repack' command, let's bring its usage
in line with the Documentation's synopsis. This removes it from the
allow list in t0450 so it will remain in sync in the future.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
| -rw-r--r-- | t/t0450/txt-help-mismatches | 1 | ||||
| -rwxr-xr-x | t/t7700-repack.sh | 6 | ||||
| -rw-r--r-- | t/test-lib-functions.sh | 26 |
3 files changed, 32 insertions, 1 deletions
diff --git a/t/t0450/txt-help-mismatches b/t/t0450/txt-help-mismatches index 28003f18c9..c4a15fd0cb 100644 --- a/t/t0450/txt-help-mismatches +++ b/t/t0450/txt-help-mismatches @@ -45,7 +45,6 @@ rebase remote remote-ext remote-fd -repack reset restore rev-parse diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index c4c3d1a15d..b9a5759e01 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -777,6 +777,12 @@ test_expect_success 'repack -ad cleans up old .tmp-* packs' ' test_must_be_empty tmpfiles ' +test_expect_success '--name-hash-version option passes through to pack-objects' ' + GIT_TRACE2_EVENT="$(pwd)/hash-trace.txt" \ + git repack -a --name-hash-version=2 && + test_subcommand_flex git pack-objects --name-hash-version=2 <hash-trace.txt +' + test_expect_success 'setup for update-server-info' ' git init update-server-info && test_commit -C update-server-info message diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 78e054ab50..af47247f25 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1886,6 +1886,32 @@ 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. # |
