Skip to content

Commit 243caa8

Browse files
avargitster
authored andcommitted
t5314: check exit code of "git"
Amend the test added in [1] to check the exit code of the "git" invocations. An in-flight change[2] introduced a memory leak in these invocations, which went undetected unless we were running under "GIT_TEST_SANITIZE_LEAK_LOG=true". Note that the in-flight change made 8 test files fail, but as far as I can tell only this one would have had its exit code hidden unless under "GIT_TEST_SANITIZE_LEAK_LOG=true". The rest would be caught without it. We could pick other variable names here than "ln%d", e.g. "commit", "dummy_blob" and "file_blob", but having the "rev-parse" invocations aligned makes the difference between them more readable, so let's pick "ln%d". 1. 4cf2143 (pack-objects: break delta cycles before delta-search phase, 2016-08-11) 2. https://lore.kernel.org/git/[email protected]/ 3. faececa (test-lib: have the "check" mode for SANITIZE=leak consider leak logs, 2022-07-28) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e7e5c6f commit 243caa8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

t/t5314-pack-cycle-detection.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ TEST_PASSES_SANITIZE_LEAK=true
6363
# Note that the two variants of "file" must be similar enough to convince git
6464
# to create the delta.
6565
make_pack () {
66-
{
67-
printf '%s\n' "-$(git rev-parse $2)"
68-
printf '%s dummy\n' "$(git rev-parse $1:dummy)"
69-
printf '%s file\n' "$(git rev-parse $1:file)"
70-
} |
71-
git pack-objects --stdout |
72-
git index-pack --stdin --fix-thin
66+
ln1=$(git rev-parse "$2") &&
67+
ln2=$(git rev-parse "$1:dummy") &&
68+
ln3=$(git rev-parse "$1:file") &&
69+
cat >list <<-EOF
70+
-$ln1
71+
$ln2 dummy
72+
$ln3 file
73+
EOF
74+
git pack-objects --stdout <list >pack &&
75+
git index-pack --stdin --fix-thin <pack
7376
}
7477

7578
test_expect_success 'setup' '

0 commit comments

Comments
 (0)