Skip to content

Commit c07ed6f

Browse files
derrickstoleedscho
authored andcommitted
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 <[email protected]>
1 parent 791493f commit c07ed6f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

t/t7700-repack.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,13 @@ test_expect_success 'repack -ad cleans up old .tmp-* packs' '
776776
test_must_be_empty tmpfiles
777777
'
778778

779+
test_expect_success '--full-name-hash option passes through to pack-objects' '
780+
GIT_TRACE2_EVENT="$(pwd)/full-trace.txt" \
781+
git repack -a --full-name-hash &&
782+
test_subcommand_flex git pack-objects --full-name-hash <full-trace.txt
783+
'
784+
785+
779786
test_expect_success 'setup for update-server-info' '
780787
git init update-server-info &&
781788
test_commit -C update-server-info message

t/test-lib-functions.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,33 @@ test_subcommand () {
18861886
fi
18871887
}
18881888

1889+
1890+
# Check that the given subcommand was run with the given set of
1891+
# arguments in order (but with possible extra arguments).
1892+
#
1893+
# test_subcommand_flex [!] <command> <args>... < <trace>
1894+
#
1895+
# If the first parameter passed is !, this instead checks that
1896+
# the given command was not called.
1897+
#
1898+
test_subcommand_flex () {
1899+
local negate=
1900+
if test "$1" = "!"
1901+
then
1902+
negate=t
1903+
shift
1904+
fi
1905+
1906+
local expr="$(printf '"%s".*' "$@")"
1907+
1908+
if test -n "$negate"
1909+
then
1910+
! grep "\[$expr\]"
1911+
else
1912+
grep "\[$expr\]"
1913+
fi
1914+
}
1915+
18891916
# Check that the given command was invoked as part of the
18901917
# trace2-format trace on stdin.
18911918
#

0 commit comments

Comments
 (0)