git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] replay: move onto NULL check before first use

From
René Scharfe <l.s.r@web.de>
Date
Dec 11, 2025, 17:56 UTC
Message-ID
<9db2b913-b5d6-4617-b079-b4612eaa2b97@web.de>
In-Reply-To
<3d83161b-ec34-404a-bb0e-bf4da7ac1db5@app.fastmail.com>

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>
---
 builtin/replay.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/replay.c b/builtin/replay.c
index 507b909df7..64ad2f0f04 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -454,6 +454,9 @@ int cmd_replay(int argc,
 	determine_replay_mode(repo, &revs.cmdline, onto_name, &advance_name,
 			      &onto, &update_refs);
 
+	if (!onto) /* FIXME: Should handle replaying down to root commit */
+		die("Replaying down to root commit is not supported yet!");
+
 	/* Build reflog message */
 	if (advance_name_opt)
 		strbuf_addf(&reflog_msg, "replay --advance %s", advance_name_opt);
@@ -472,9 +475,6 @@ int cmd_replay(int argc,
 		}
 	}
 
-	if (!onto) /* FIXME: Should handle replaying down to root commit */
-		die("Replaying down to root commit is not supported yet!");
-
 	if (prepare_revision_walk(&revs) < 0) {
 		ret = error(_("error preparing revisions"));
 		goto cleanup;
-- 
2.52.0
Previous: Kristoffer HaugsbakkNext: Phillip Wood
Message 2 of 4 in “[BUG] replay: segmentation fault when mistyping target to --onto”
  1. Kristoffer HaugsbakkDec 11, 2025
  2. replay: move onto NULL check before first useRené Scharfe, Dec 11, 2025
  3. Phillip WoodDec 15, 2025
  4. Kristoffer HaugsbakkDec 15, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.