summaryrefslogtreecommitdiff
path: root/t/t9162-git-svn-dcommit-interactive.sh
AgeCommit message (Collapse)Author
2022-08-03log: fix a memory leak in "git show <revision>..."Ævar Arnfjörð Bjarmason
Fix a memory leak in code added in 5d7eeee2ac6 (git-show: grok blobs, trees and tags, too, 2006-12-14). As we iterate over a "<revision>..." command-line and encounter ad OBJ_COMMIT we want to use our "struct rev_info", but with a "pending" array of one element: the one commit we're showing in the loop. To do this 5d7eeee2ac6 saved away a pointer to rev.pending.objects and rev.pending.nr for its iteration. We'd then clobber those (and alloc) when we needed to show an OBJ_COMMIT. We'd therefore leak the "rev.pending" we started out with, and only free the new "rev.pending" in the "OBJ_COMMIT" case arm as prepare_revision_walk() would draw it down. Let's fix this memory leak. Now when we encounter an OBJ_COMMIT we save away the "rev.pending" before clearing it. We then add a single commit to it, which our indirect invocation of prepare_revision_walk() will remove. After that we restore the "rev.pending". Our "rev.pending" will then get free'd by the release_revisions() added in f6bfea0ad01 (revisions API users: use release_revisions() in builtin/log.c, 2022-04-13) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-04-14revisions API: have release_revisions() release "cmdline"Ævar Arnfjörð Bjarmason
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. See 14d30cdfc04 (ref-filter: fix memory leak in `free_array_item()`, 2019-07-10), c514c62a4fd (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 my 6798b08e848 (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's de004e848a9 (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>
2011-10-20tests: add missing executable bitsJeff King
Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-16git svn dcommit: new option --interactive.Frédéric Heitzmann
Allow the user to check the patch set before it is commited to SVN. It is then possible to accept/discard one patch, accept all, or quit. This interactive mode is similar with 'git send email' behaviour. However, 'git svn dcommit' returns as soon as one patch is discarded. Part of the code was taken from git-send-email.perl (see 'ask' function) Tests several combinations of potential answers to 'git svn dcommit --interactive'. For each of them, test whether patches were commited to SVN or not. Thanks-to Eric Wong <normalperson@yhbt.net> for the initial idea. Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com>