Skip to content

Commit

Permalink
Merge branch 'bc/fix-cherry-pick-root'
Browse files Browse the repository at this point in the history
* bc/fix-cherry-pick-root:
  builtin/revert.c: don't dereference a NULL pointer
  • Loading branch information
Junio C Hamano committed Oct 6, 2010
2 parents 90d6bd5 + 6355e50 commit 4ac9aeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/revert.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static int do_pick_commit(void)
else
parent = commit->parents->item;

if (allow_ff && !hashcmp(parent->object.sha1, head))
if (allow_ff && parent && !hashcmp(parent->object.sha1, head))
return fast_forward_to(commit->object.sha1, head);

if (parent && parse_commit(parent) < 0)
Expand Down
10 changes: 10 additions & 0 deletions t/t3506-cherry-pick-ff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4ac9aeb

Please sign in to comment.