mirror of
https://github.com/git/git
synced 2024-11-04 16:17:49 +00:00
revisions API: have release_revisions() release "cmdline"
Extend the the release_revisions() function so that it frees the "cmdline" in the "struct rev_info". This in combination with a preceding change to free "commits" and "mailmap" means that we can whitelist another test under "TEST_PASSES_SANITIZE_LEAK=true". There was a proposal in [1] to do away with xstrdup()-ing this add_rev_cmdline(), perhaps that would be worthwhile, but for now let's just free() it. We could also make that a "char *" in "struct rev_cmdline_entry" itself, but since we own it let's expose it as a constant to outside callers. I proposed that in [2] but have since changed my mind. See14d30cdfc0
(ref-filter: fix memory leak in `free_array_item()`, 2019-07-10),c514c62a4f
(checkout: fix leak of non-existent branch names, 2020-08-14) and other log history hits for "free((char *)" for prior art. This includes the tests we had false-positive passes on before my6798b08e84
(perl Git.pm: don't ignore signalled failure in _cmd_close(), 2022-02-01), now they pass for real. Since there are 66 tests matching t/t[0-9]*git-svn*.sh it's easier to list those that don't pass than to touch most of those 66. So let's introduce a "TEST_FAILS_SANITIZE_LEAK=true", which if set in the tests won't cause lib-git-svn.sh to set "TEST_PASSES_SANITIZE_LEAK=true. This change also marks all the tests that we removed "TEST_FAILS_SANITIZE_LEAK=true" from in an earlier commit due to removing the UNLEAK() from cmd_format_patch(), we can now assert that its API use doesn't leak any "struct rev_info" memory. This change also made commit "t5503-tagfollow.sh" pass on current master, but that would regress when combined with ps/fetch-atomic-fixup'sde004e848a
(t5503: simplify setup of test which exercises failure of backfill, 2022-03-03) (through no fault of that topic, that change started using "git clone" in the test, which has an outstanding leak). Let's leave that test out for now to avoid in-flight semantic conflicts. 1. https://lore.kernel.org/git/YUj%2FgFRh6pwrZalY@carlos-mbp.lan/ 2. https://lore.kernel.org/git/87o88obkb1.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
a52f07afcb
commit
7a98d9ab00
36 changed files with 58 additions and 0 deletions
10
revision.c
10
revision.c
|
@ -2926,6 +2926,15 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||
return left;
|
||||
}
|
||||
|
||||
static void release_revisions_cmdline(struct rev_cmdline_info *cmdline)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < cmdline->nr; i++)
|
||||
free((char *)cmdline->rev[i].name);
|
||||
free(cmdline->rev);
|
||||
}
|
||||
|
||||
static void release_revisions_mailmap(struct string_list *mailmap)
|
||||
{
|
||||
if (!mailmap)
|
||||
|
@ -2938,6 +2947,7 @@ void release_revisions(struct rev_info *revs)
|
|||
{
|
||||
free_commit_list(revs->commits);
|
||||
object_array_clear(&revs->pending);
|
||||
release_revisions_cmdline(&revs->cmdline);
|
||||
release_revisions_mailmap(revs->mailmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
if test -z "$TEST_FAILS_SANITIZE_LEAK"
|
||||
then
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
fi
|
||||
. ./test-lib.sh
|
||||
|
||||
if test -n "$NO_SVN_TESTS"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
test_description='Test revision walking api'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
cat >run_twice_expected <<-EOF
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='various @{whatever} syntax tests'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='see how we handle various forms of corruption'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
# convert "1234abcd" to ".git/objects/12/34abcd"
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='Test commit notes organized in subtrees'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
number_of_commits=100
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='Test that adding/removing many notes triggers automatic fanout restructuring'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
path_has_fanout() {
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='rebasing a commit with multi-line first paragraph.'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success setup '
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='difference in submodules'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='apply same filename'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='git log with invalid commit headers'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
@ -14,6 +14,7 @@ export GIT_TEST_PROTOCOL_VERSION
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
build_script () {
|
||||
|
|
|
@ -8,6 +8,7 @@ test_description='fetch exit status test'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success setup '
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#
|
||||
test_description='Tests git rev-list --bisect functionality'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
test_description='Tests git rev-list --topo-order functionality'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='git rev-list --max-count and --skip test'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
|
|
@ -5,6 +5,7 @@ test_description='rev-list/rev-parse --glob'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
commit () {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='rev-list testing in-commit-order'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup a commit history with trees, blobs' '
|
||||
|
|
|
@ -8,6 +8,7 @@ test_description='git svn basic tests'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
prepare_utf8_locale
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
|
||||
test_description='git svn property tests'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
mkdir import
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
|
||||
test_description='git svn fetching'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'initialize repo' '
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#
|
||||
# Copyright (c) 2006 Eric Wong
|
||||
test_description='git svn commit-diff clobber'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'initialize repo' '
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
test_description='git svn dcommit can commit renames of files with ugly names'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'load repository with strange names' '
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
|
||||
test_description='git svn log tests'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'setup repository and import' '
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='git svn authorship'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'setup svn repository' '
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
|
||||
test_description='git svn partial-rebuild tests'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'initialize svnrepo' '
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
test_description='git svn honors i18n.commitEncoding in config'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
compare_git_head_with () {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='test that git handles an svn repository with empty symlinks'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
test_expect_success 'load svn dumpfile' '
|
||||
svnadmin load "$rawsvnrepo" <<EOF
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
test_description='git svn refuses to dcommit non-UTF8 messages'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
# ISO-2022-JP can pass for valid UTF-8, so skipping that in this test
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
# Copyright (c) 2009 Eric Wong
|
||||
|
||||
test_description='git svn creates empty directories'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'initialize repo' '
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
test_description='git svn propset tests'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'setup propset via import' '
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
test_description='git-svn svn mergeinfo properties'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'load svn dump' "
|
||||
|
|
|
@ -9,6 +9,7 @@ This test uses git to clone a Subversion repository that contains empty
|
|||
directories, and checks that corresponding directories are created in the
|
||||
local Git repository with placeholder files.'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
GIT_REPO=git-svn-repo
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
# Copyright (c) 2011 Frédéric Heitzmann
|
||||
|
||||
test_description='git svn dcommit --interactive series'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
test_expect_success 'initialize repo' '
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
|
||||
test_description='concurrent git svn dcommit'
|
||||
|
||||
TEST_FAILS_SANITIZE_LEAK=true
|
||||
. ./lib-git-svn.sh
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ code and message.'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./lib-gitweb.sh
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue