summaryrefslogtreecommitdiff
path: root/t/t4202-log.sh
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2013-05-27 22:49:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-28 18:26:24 (GMT)
commit46ec510ac088ac2669e617a4c8c35e6218dabecc (patch)
tree31bd560c6e1c11bd5d56c29067fa9640f4bb1c0d /t/t4202-log.sh
parent04a74b6cfa5ef4870263f84ac94a488d9f2ef14a (diff)
downloadgit-46ec510ac088ac2669e617a4c8c35e6218dabecc.zip
git-46ec510ac088ac2669e617a4c8c35e6218dabecc.tar.gz
git-46ec510ac088ac2669e617a4c8c35e6218dabecc.tar.bz2
fix segfault with git log -c --follow
In diff_tree_combined we make a copy of diffopts. In try_to_follow_renames, called via diff_tree_sha1, we free and re-initialize diffopts->pathspec->items. Since we did not make a deep copy of diffopts in diff_tree_combined, the original diffopts does not get the update. By the time we return from diff_tree_combined, rev->diffopt->pathspec->items points to an invalid memory address. We get a segfault next time we try to access that pathspec. Instead, along with the copy of diffopts, make a copy pathspec->items as well. We would also have to make a copy of pathspec->raw to keep it consistent with pathspec->items, but nobody seems to rely on that. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4202-log.sh')
-rwxr-xr-xt/t4202-log.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index fa686b8..d9e587a 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -542,6 +542,20 @@ test_expect_success 'show added path under "--follow -M"' '
)
'
+test_expect_success 'git log -c --follow' '
+ test_create_repo follow-c &&
+ (
+ cd follow-c &&
+ test_commit initial file original &&
+ git rm file &&
+ test_commit rename file2 original &&
+ git reset --hard initial &&
+ test_commit modify file foo &&
+ git merge -m merge rename &&
+ git log -c --follow file2
+ )
+'
+
cat >expect <<\EOF
* commit COMMIT_OBJECT_NAME
|\ Merge: MERGE_PARENTS