Skip to content

Commit 5cc3464

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 6ed5f62 commit 5cc3464

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

t/t7700-repack.sh

+7
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,13 @@ test_expect_success 'repack -ad cleans up old .tmp-* packs' '
777777
test_must_be_empty tmpfiles
778778
'
779779

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

t/test-lib-functions.sh

+27
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,33 @@ test_subcommand () {
18851885
fi
18861886
}
18871887

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

0 commit comments

Comments
 (0)