@@ -271,12 +271,18 @@ static struct commit *pick_regular_commit(struct repository *repo,
271271 struct commit * base , * replayed_base ;
272272 struct tree * pickme_tree , * base_tree , * replayed_base_tree ;
273273
274- base = pickme -> parents -> item ;
275- replayed_base = mapped_commit (replayed_commits , base , onto );
274+ if (pickme -> parents ) {
275+ base = pickme -> parents -> item ;
276+ replayed_base = mapped_commit (replayed_commits , base , onto );
277+ base_tree = repo_get_commit_tree (repo , base );
278+ } else {
279+ base = NULL ;
280+ replayed_base = onto ;
281+ base_tree = lookup_tree (repo , repo -> hash_algo -> empty_tree );
282+ }
276283
277284 replayed_base_tree = repo_get_commit_tree (repo , replayed_base );
278285 pickme_tree = repo_get_commit_tree (repo , pickme );
279- base_tree = repo_get_commit_tree (repo , base );
280286
281287 if (mode == REPLAY_MODE_PICK ) {
282288 /* Cherry-pick: normal order */
@@ -364,8 +370,6 @@ int replay_revisions(struct rev_info *revs,
364370 set_up_replay_mode (revs -> repo , & revs -> cmdline , opts -> onto ,
365371 & detached_head , & advance , & revert , & onto , & update_refs );
366372
367- /* FIXME: Should allow replaying commits with the first as a root commit */
368-
369373 if (prepare_revision_walk (revs ) < 0 ) {
370374 ret = error (_ ("error preparing revisions" ));
371375 goto out ;
@@ -380,9 +384,7 @@ int replay_revisions(struct rev_info *revs,
380384 khint_t pos ;
381385 int hr ;
382386
383- if (!commit -> parents )
384- die (_ ("replaying down from root commit is not supported yet!" ));
385- if (commit -> parents -> next )
387+ if (commit -> parents && commit -> parents -> next )
386388 die (_ ("replaying merge commits is not supported yet!" ));
387389
388390 last_commit = pick_regular_commit (revs -> repo , commit , replayed_commits ,
0 commit comments