mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
055e57b7b2
Fix a memory leak in code added in5d7eeee2ac
(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 this5d7eeee2ac
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 inf6bfea0ad0
(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>
65 lines
2 KiB
Bash
Executable file
65 lines
2 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2011 Frédéric Heitzmann
|
|
|
|
test_description='git svn dcommit --interactive series'
|
|
|
|
. ./lib-git-svn.sh
|
|
|
|
test_expect_success 'initialize repo' '
|
|
svn_cmd mkdir -m"mkdir test-interactive" "$svnrepo/test-interactive" &&
|
|
git svn clone "$svnrepo/test-interactive" test-interactive &&
|
|
cd test-interactive &&
|
|
touch foo && git add foo && git commit -m"foo: first commit" &&
|
|
git svn dcommit
|
|
'
|
|
|
|
test_expect_success 'answers: y [\n] yes' '
|
|
(
|
|
echo "change #1" >> foo && git commit -a -m"change #1" &&
|
|
echo "change #2" >> foo && git commit -a -m"change #2" &&
|
|
echo "change #3" >> foo && git commit -a -m"change #3" &&
|
|
( echo "y
|
|
|
|
y" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) &&
|
|
test $(git rev-parse HEAD) = $(git rev-parse remotes/git-svn)
|
|
)
|
|
'
|
|
|
|
test_expect_success 'answers: yes yes no' '
|
|
(
|
|
echo "change #1" >> foo && git commit -a -m"change #1" &&
|
|
echo "change #2" >> foo && git commit -a -m"change #2" &&
|
|
echo "change #3" >> foo && git commit -a -m"change #3" &&
|
|
( echo "yes
|
|
yes
|
|
no" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) &&
|
|
test $(git rev-parse HEAD^^^) = $(git rev-parse remotes/git-svn) &&
|
|
git reset --hard remotes/git-svn
|
|
)
|
|
'
|
|
|
|
test_expect_success 'answers: yes quit' '
|
|
(
|
|
echo "change #1" >> foo && git commit -a -m"change #1" &&
|
|
echo "change #2" >> foo && git commit -a -m"change #2" &&
|
|
echo "change #3" >> foo && git commit -a -m"change #3" &&
|
|
( echo "yes
|
|
quit" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) &&
|
|
test $(git rev-parse HEAD^^^) = $(git rev-parse remotes/git-svn) &&
|
|
git reset --hard remotes/git-svn
|
|
)
|
|
'
|
|
|
|
test_expect_success 'answers: all' '
|
|
(
|
|
echo "change #1" >> foo && git commit -a -m"change #1" &&
|
|
echo "change #2" >> foo && git commit -a -m"change #2" &&
|
|
echo "change #3" >> foo && git commit -a -m"change #3" &&
|
|
( echo "all" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) &&
|
|
test $(git rev-parse HEAD) = $(git rev-parse remotes/git-svn) &&
|
|
git reset --hard remotes/git-svn
|
|
)
|
|
'
|
|
|
|
test_done
|