replay: move onto NULL check before first use
cmd_replay() aborts if the pointer "onto" is NULL after argument parsing, e.g. when specifying a non-existing commit with --onto. 15cd4ef1f4 (replay: make atomic ref updates the default behavior, 2025-11-06) added code that dereferences this pointer before the check. Switch their places to avoid a segmentation fault. Reported-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 11, 2025 at 18:56 UTC
a4a77e41fa0ee3d526993be47086bbfe3a115cdc
1 file changed
+3
-3
builtin/replay.c
+3
-3
@@ -454,6 +454,9 @@ int cmd_replay(int argc,
454
determine_replay_mode(repo, &revs.cmdline, onto_name, &advance_name,
455
&onto, &update_refs);
456
457
+ if (!onto) /* FIXME: Should handle replaying down to root commit */
458
+ die("Replaying down to root commit is not supported yet!");
459
+
460
/* Build reflog message */
461
if (advance_name_opt)
462
strbuf_addf(&reflog_msg, "replay --advance %s", advance_name_opt);
@@ -472,9 +475,6 @@ int cmd_replay(int argc,
475
}
476
}
477
475
- if (!onto) /* FIXME: Should handle replaying down to root commit */
476
- die("Replaying down to root commit is not supported yet!");
477
-
478
if (prepare_revision_walk(&revs) < 0) {
479
ret = error(_("error preparing revisions"));
480
goto cleanup;