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>
86 lines
1.9 KiB
Bash
Executable File
86 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git svn authorship'
|
|
|
|
. ./lib-git-svn.sh
|
|
|
|
test_expect_success 'setup svn repository' '
|
|
svn_cmd checkout "$svnrepo" work.svn &&
|
|
(
|
|
cd work.svn &&
|
|
echo >file &&
|
|
svn_cmd add file &&
|
|
svn_cmd commit -m "first commit" file
|
|
)
|
|
'
|
|
|
|
test_expect_success 'interact with it via git svn' '
|
|
mkdir work.git &&
|
|
(
|
|
cd work.git &&
|
|
git svn init "$svnrepo" &&
|
|
git svn fetch &&
|
|
|
|
echo modification >file &&
|
|
test_tick &&
|
|
git commit -a -m second &&
|
|
|
|
test_tick &&
|
|
git svn dcommit &&
|
|
|
|
echo "further modification" >file &&
|
|
test_tick &&
|
|
git commit -a -m third &&
|
|
|
|
test_tick &&
|
|
git svn --add-author-from dcommit &&
|
|
|
|
echo "yet further modification" >file &&
|
|
test_tick &&
|
|
git commit -a -m fourth &&
|
|
|
|
test_tick &&
|
|
git svn --add-author-from --use-log-author dcommit &&
|
|
|
|
git log &&
|
|
|
|
git show -s HEAD^^ >../actual.2 &&
|
|
git show -s HEAD^ >../actual.3 &&
|
|
git show -s HEAD >../actual.4
|
|
|
|
) &&
|
|
|
|
# Make sure that --add-author-from without --use-log-author
|
|
# did not affect the authorship information
|
|
myself=$(grep "^Author: " actual.2) &&
|
|
unaffected=$(grep "^Author: " actual.3) &&
|
|
test "z$myself" = "z$unaffected" &&
|
|
|
|
# Make sure lack of --add-author-from did not add cruft
|
|
! grep "^ From: A U Thor " actual.2 &&
|
|
|
|
# Make sure --add-author-from added cruft
|
|
grep "^ From: A U Thor " actual.3 &&
|
|
grep "^ From: A U Thor " actual.4 &&
|
|
|
|
# Make sure --add-author-from with --use-log-author affected
|
|
# the authorship information
|
|
grep "^Author: A U Thor " actual.4 &&
|
|
|
|
# Make sure there are no commit messages with excess blank lines
|
|
test $(grep "^ " actual.2 | wc -l) = 3 &&
|
|
test $(grep "^ " actual.3 | wc -l) = 5 &&
|
|
test $(grep "^ " actual.4 | wc -l) = 5 &&
|
|
|
|
# Make sure there are no svn commit messages with excess blank lines
|
|
(
|
|
cd work.svn &&
|
|
svn_cmd up &&
|
|
|
|
test $(svn_cmd log -r2:2 | wc -l) = 5 &&
|
|
test $(svn_cmd log -r4:4 | wc -l) = 7
|
|
)
|
|
'
|
|
|
|
test_done
|