File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,7 @@ static int do_pick_commit(void)
442442 else
443443 parent = commit -> parents -> item ;
444444
445- if (allow_ff && !hashcmp (parent -> object .sha1 , head ))
445+ if (allow_ff && parent && !hashcmp (parent -> object .sha1 , head ))
446446 return fast_forward_to (commit -> object .sha1 , head );
447447
448448 if (parent && parse_commit (parent ) < 0 )
Original file line number Diff line number Diff line change @@ -95,4 +95,14 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent with --f
9595 test_must_fail git cherry-pick --ff -m 3 C
9696'
9797
98+ test_expect_success ' cherry pick a root commit with --ff' '
99+ git reset --hard first -- &&
100+ git rm file1 &&
101+ echo first >file2 &&
102+ git add file2 &&
103+ git commit --amend -m "file2" &&
104+ git cherry-pick --ff first &&
105+ test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"
106+ '
107+
98108test_done
You can’t perform that action at this time.
0 commit comments