Skip to content

Commit a4a77e4

Browse files
rscharfegitster
authored andcommitted
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. 15cd4ef (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 <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8cb4a11 commit a4a77e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/replay.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ int cmd_replay(int argc,
454454
determine_replay_mode(repo, &revs.cmdline, onto_name, &advance_name,
455455
&onto, &update_refs);
456456

457+
if (!onto) /* FIXME: Should handle replaying down to root commit */
458+
die("Replaying down to root commit is not supported yet!");
459+
457460
/* Build reflog message */
458461
if (advance_name_opt)
459462
strbuf_addf(&reflog_msg, "replay --advance %s", advance_name_opt);
@@ -472,9 +475,6 @@ int cmd_replay(int argc,
472475
}
473476
}
474477

475-
if (!onto) /* FIXME: Should handle replaying down to root commit */
476-
die("Replaying down to root commit is not supported yet!");
477-
478478
if (prepare_revision_walk(&revs) < 0) {
479479
ret = error(_("error preparing revisions"));
480480
goto cleanup;

0 commit comments

Comments
 (0)