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)
442
442
else
443
443
parent = commit -> parents -> item ;
444
444
445
- if (allow_ff && !hashcmp (parent -> object .sha1 , head ))
445
+ if (allow_ff && parent && !hashcmp (parent -> object .sha1 , head ))
446
446
return fast_forward_to (commit -> object .sha1 , head );
447
447
448
448
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
95
95
test_must_fail git cherry-pick --ff -m 3 C
96
96
'
97
97
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
+
98
108
test_done
You can’t perform that action at this time.
0 commit comments