]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'tc/replay-ref'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2026 17:19:18 +0000 (10:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2026 17:19:18 +0000 (10:19 -0700)
The experimental `git replay` command learned the `--ref=<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

1  2 
replay.c
t/t3650-replay-basics.sh

diff --cc replay.c
index cf1f0bcba0b3330ef54c219c7c204f62114e235a,b958ddabfa1363ec5258cace994dc8cc019f1098..f96f1f6551ae631d850dc1e928826e708342a193
+++ 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);
  
 -      /* 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;
Simple merge