set_up_replay_mode(revs->repo, &revs->cmdline, opts->onto,
&detached_head, &advance, &revert, &onto, &update_refs);
- /* FIXME: Should allow replaying commits with the first as a root commit */
-
+ if (opts->ref) {
+ struct object_id oid;
+
+ if (update_refs && strset_get_size(update_refs) > 1) {
+ ret = error(_("'--ref' cannot be used with multiple revision ranges"));
+ goto out;
+ }
+ if (check_refname_format(opts->ref, 0) || !starts_with(opts->ref, "refs/")) {
+ ret = error(_("'%s' is not a valid refname"), opts->ref);
+ goto out;
+ }
+ ref = opts->ref;
+ if (!refs_read_ref(get_main_ref_store(revs->repo), opts->ref, &oid))
+ oidcpy(&old_oid, &oid);
+ else
+ oidclr(&old_oid, revs->repo->hash_algo);
+ } else {
+ ref = advance ? advance : revert;
+ oidcpy(&old_oid, &onto->object.oid);
+ }
+
if (prepare_revision_walk(revs) < 0) {
ret = error(_("error preparing revisions"));
goto out;