Skip to content

Commit

Permalink
repack: test --full-name-hash option
Browse files Browse the repository at this point in the history
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 <stolee@gmail.com>
  • Loading branch information
derrickstolee authored and dscho committed Sep 24, 2024
1 parent 3f2c20a commit 10680be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions t/t7700-repack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,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 <full-trace.txt
'


test_expect_success 'setup for update-server-info' '
git init update-server-info &&
test_commit -C update-server-info message
Expand Down
27 changes: 27 additions & 0 deletions t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,33 @@ 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.
#
Expand Down

0 comments on commit 10680be

Please sign in to comment.