Re: [PATCH] replay: move onto NULL check before first use
- From
- Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
- Date
- Dec 15, 2025, 12:04 UTC
- Message-ID
- <a395825a-a9e9-4cde-bf2d-f9b72de9212d@app.fastmail.com>
- In-Reply-To
- <a017e50f-7c8f-461f-8627-2fd1445d29f6@gmail.com>
On Mon, Dec 15, 2025, at 11:10, Phillip Wood wrote:
Show 10 quoted lines
> On 11/12/2025 17:56, René Scharfe wrote: >> 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. > > This fixes the regression nicely. There is a preexisting bug that we > treat an invalid --onto argument the same as a missing argument but that > can be fixed separately.
I have a commit cooking (locally) which makes the command die when it cannot find commit-ish for `--onto` or `--advance` (whitespace mangled diff):
```
diff --git a/builtin/replay.c b/builtin/replay.c index 507b909df7d..72d62aa34a6 100644 --- a/builtin/replay.c +++ b/builtin/replay.c @@ -39,7 +39,7 @@ static struct commit *peel_committish(struct repository *repo, const char *name) struct object_id oid; if (repo_get_oid(repo, name, &oid)) - return NULL; + die(_("'%s' is not a valid commit-ish"), name); obj = parse_object(repo, &oid); return (struct commit *)repo_peel_to_type(repo, name, 0, obj, OBJ_COMMIT); ``` Instead of dieing like this: Replaying down to root commit is not supported yet! I hope that doesn’t cause any leak issues when I test it later.