@@ -225,12 +225,18 @@ static struct commit *pick_regular_commit(struct repository *repo,
225225 struct commit * base , * replayed_base ;
226226 struct tree * pickme_tree , * base_tree , * replayed_base_tree ;
227227
228- base = pickme -> parents -> item ;
229- replayed_base = mapped_commit (replayed_commits , base , onto );
228+ if (pickme -> parents ) {
229+ base = pickme -> parents -> item ;
230+ replayed_base = mapped_commit (replayed_commits , base , onto );
231+ base_tree = repo_get_commit_tree (repo , base );
232+ } else {
233+ base = NULL ;
234+ replayed_base = onto ;
235+ base_tree = lookup_tree (repo , repo -> hash_algo -> empty_tree );
236+ }
230237
231238 replayed_base_tree = repo_get_commit_tree (repo , replayed_base );
232239 pickme_tree = repo_get_commit_tree (repo , pickme );
233- base_tree = repo_get_commit_tree (repo , base );
234240
235241 merge_opt -> branch1 = short_commit_name (repo , replayed_base );
236242 merge_opt -> branch2 = short_commit_name (repo , pickme );
@@ -293,8 +299,6 @@ int replay_revisions(struct rev_info *revs,
293299 set_up_replay_mode (revs -> repo , & revs -> cmdline , opts -> onto ,
294300 & detached_head , & advance , & onto , & update_refs );
295301
296- /* FIXME: Should allow replaying commits with the first as a root commit */
297-
298302 if (prepare_revision_walk (revs ) < 0 ) {
299303 ret = error (_ ("error preparing revisions" ));
300304 goto out ;
@@ -309,9 +313,7 @@ int replay_revisions(struct rev_info *revs,
309313 khint_t pos ;
310314 int hr ;
311315
312- if (!commit -> parents )
313- die (_ ("replaying down from root commit is not supported yet!" ));
314- if (commit -> parents -> next )
316+ if (commit -> parents && commit -> parents -> next )
315317 die (_ ("replaying merge commits is not supported yet!" ));
316318
317319 last_commit = pick_regular_commit (revs -> repo , commit , replayed_commits ,
0 commit comments