@@ -152,10 +152,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
onto = peel_committish(onto_name);
strbuf_addf(&branch_name, "refs/heads/%s", argv[2]);
- repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
- if (repo_read_index(the_repository) < 0)
- BUG("Could not read index");
-
repo_init_revisions(the_repository, &revs, prefix);
strvec_pushl(&rev_walk_args, "", argv[2], "--not", argv[1], NULL);
@@ -194,12 +190,39 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
die(_("replaying merge commits is not supported yet!"));
pick = pick_regular_commit(commit, last_commit, &merge_opt, &result);
- if (!pick)
- break;
+ if (!pick) {
+ /* TODO: handle conflicts in sparse worktree instead */
+ struct object_id head;
+ struct tree *head_tree;
+ struct lock_file lock = LOCK_INIT;
+
+ repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
+ if (repo_read_index(the_repository) < 0)
+ BUG("Could not read index");
+
+ get_oid("HEAD", &head);
+ head_tree = parse_tree_indirect(&head);
+ printf("Switching from %s to %s.\n",
+ oid_to_hex(&head_tree->object.oid),
+ oid_to_hex(&result.tree->object.oid));
+ merge_switch_to_result(&merge_opt, head_tree, &result,
+ 1, 1);
+ if (write_locked_index(&the_index, &lock,
+ COMMIT_LOCK | SKIP_IF_UNCHANGED))
+ die(_("unable to write %s"), get_index_file());
+
+ die(_("failure to pick %s; cannot handle conflicts yet"),
+ oid_to_hex(&commit->object.oid));
+ }
+
last_commit = pick;
last_picked_commit = commit;
}
+ repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
+ if (repo_read_index(the_repository) < 0)
+ BUG("Could not read index");
+
merge_switch_to_result(&merge_opt, head_tree, &result, 1, !result.clean);
if (result.clean < 0)