Skip to content

Commit 5e35bba

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 41a74fa commit 5e35bba

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
@@ -1896,6 +1896,33 @@ test_subcommand () {
18961896
fi
18971897
}
18981898

1899+
1900+
# Check that the given subcommand was run with the given set of
1901+
# arguments in order (but with possible extra arguments).
1902+
#
1903+
# test_subcommand_flex [!] <command> <args>... < <trace>
1904+
#
1905+
# If the first parameter passed is !, this instead checks that
1906+
# the given command was not called.
1907+
#
1908+
test_subcommand_flex () {
1909+
local negate=
1910+
if test "$1" = "!"
1911+
then
1912+
negate=t
1913+
shift
1914+
fi
1915+
1916+
local expr="$(printf '"%s".*' "$@")"
1917+
1918+
if test -n "$negate"
1919+
then
1920+
! grep "\[$expr\]"
1921+
else
1922+
grep "\[$expr\]"
1923+
fi
1924+
}
1925+
18991926
# Check that the given command was invoked as part of the
19001927
# trace2-format trace on stdin.
19011928
#

0 commit comments

Comments
 (0)