git/t/t4217-log-limit.sh
Jeff King 8ef8da4842 revision: clear decoration structs during release_revisions()
The point of release_revisions() is to free memory associated with the
rev_info struct, but we have several "struct decoration" members that
are left untouched. Since the previous commit introduced a function to
do that, we can just call it.

We do have to provide some specialized callbacks to map the void
pointers onto real ones (the alternative would be casting the existing
function pointers; this generally works because "void *" is usually
interchangeable with a struct pointer, but it is technically forbidden
by the standard).

Since the line-log code does not expose the type it stores in the
decoration (nor of course the function to free it), I put this behind a
generic line_log_free() entry point. It's possible we may need to add
more line-log specific bits anyway (running t4211 shows a number of
other leaks in the line-log code).

While this doubtless cleans up many leaks triggered by the test suite,
the only script which becomes leak-free is t4217, as it does very little
beyond a simple traversal (its existing leak was from the use of
--children, which is now fixed).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-10-05 14:54:57 -07:00

42 lines
968 B
Bash
Executable file

#!/bin/sh
test_description='git log with filter options limiting the output'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup test' '
git init &&
echo a >file &&
git add file &&
GIT_COMMITTER_DATE="2021-02-01 00:00" git commit -m init &&
echo a >>file &&
git add file &&
GIT_COMMITTER_DATE="2022-02-01 00:00" git commit -m first &&
echo a >>file &&
git add file &&
GIT_COMMITTER_DATE="2021-03-01 00:00" git commit -m second &&
echo a >>file &&
git add file &&
GIT_COMMITTER_DATE="2022-03-01 00:00" git commit -m third
'
test_expect_success 'git log --since-as-filter=...' '
git log --since-as-filter="2022-01-01" --format=%s >actual &&
cat >expect <<-\EOF &&
third
first
EOF
test_cmp expect actual
'
test_expect_success 'git log --children --since-as-filter=...' '
git log --children --since-as-filter="2022-01-01" --format=%s >actual &&
cat >expect <<-\EOF &&
third
first
EOF
test_cmp expect actual
'
test_done