From: Junio C Hamano Date: Wed, 8 Apr 2026 17:19:18 +0000 (-0700) Subject: Merge branch 'tc/replay-ref' X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37a4780f2c30de9fe0bef533a266c6bca767a50f;p=thirdparty%2Fgit.git Merge branch 'tc/replay-ref' The experimental `git replay` command learned the `--ref=` option to allow specifying which ref to update, overriding the default behavior. * tc/replay-ref: replay: allow to specify a ref with option --ref replay: use stuck form in documentation and help message builtin/replay: mark options as not negatable --- 37a4780f2c30de9fe0bef533a266c6bca767a50f diff --cc replay.c index cf1f0bcba0,b958ddabfa..f96f1f6551 --- a/replay.c +++ b/replay.c @@@ -375,6 -366,29 +377,27 @@@ int replay_revisions(struct rev_info *r set_up_replay_mode(revs->repo, &revs->cmdline, opts->onto, &detached_head, &advance, &revert, &onto, &update_refs); + 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); + } + - /* FIXME: Should allow replaying commits with the first as a root commit */ - if (prepare_revision_walk(revs) < 0) { ret = error(_("error preparing revisions")); goto out;