summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2010-09-27 17:29:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-09-27 17:39:54 (GMT)
commit6355e505bacf0a12a5de77bcd0c1198e74ad340b (patch)
treec1e13fda5177484fa34872ff4dc9cba2245f5df3 /t
parent9027fa9eb7df606b6658dd48a40bb993ce222ddd (diff)
downloadgit-6355e505bacf0a12a5de77bcd0c1198e74ad340b.zip
git-6355e505bacf0a12a5de77bcd0c1198e74ad340b.tar.gz
git-6355e505bacf0a12a5de77bcd0c1198e74ad340b.tar.bz2
builtin/revert.c: don't dereference a NULL pointer
cherry-pick will segfault when transplanting a root commit if the --ff option is used. This happens because the "parent" pointer is set to NULL when the commit being cherry-picked has no parents. Later, when "parent" is dereferenced, the cherry-pick segfaults. Fix this by checking whether "parent" is NULL before dereferencing it and add a test for this case of cherry-picking a root commit with --ff. Reported-by: Zbyszek Szmek <zbyszek@in.waw.pl> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3506-cherry-pick-ff.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t3506-cherry-pick-ff.sh b/t/t3506-cherry-pick-ff.sh
index e17ae71..51ca391 100755
--- a/t/t3506-cherry-pick-ff.sh
+++ b/t/t3506-cherry-pick-ff.sh
@@ -95,4 +95,14 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent with --f
test_must_fail git cherry-pick --ff -m 3 C
'
+test_expect_success 'cherry pick a root commit with --ff' '
+ git reset --hard first -- &&
+ git rm file1 &&
+ echo first >file2 &&
+ git add file2 &&
+ git commit --amend -m "file2" &&
+ git cherry-pick --ff first &&
+ test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"
+'
+
test_done