replay: die when --onto does not peel to a commit

The `peel_committish()` function calls `repo_peel_to_type()` to convert the given object to a commit, but does not check the return value. When the object exists but cannot be peeled to a commit (e.g., a tree or blob OID is passed as --onto), the return value is NULL. Add an explicit NULL check and die with a descriptive message in that case. Pointed out by Coverity. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 10, 2026 at 11:39 UTC e87d701dc69a6b194f223f2405102cae4c4af03b
1 file changed +6 -2
replay.c
+6 -2
@@ -36,12 +36,16 @@ static struct commit *peel_committish(struct repository *repo,
36 {
37 struct object *obj;
38 struct object_id oid;
39 + struct commit *commit;
40
41 if (repo_get_oid(repo, name, &oid))
42 die(_("'%s' is not a valid commit-ish for %s"), name, mode);
43 obj = parse_object_or_die(repo, &oid, name);
43 - return (struct commit *)repo_peel_to_type(repo, name, 0, obj,
44 - OBJ_COMMIT);
44 + commit = (struct commit *)repo_peel_to_type(repo, name, 0, obj,
45 + OBJ_COMMIT);
46 + if (!commit)
47 + die(_("'%s' does not point to a commit for %s"), name, mode);
48 + return commit;
49 }
50
51 static char *get_author(const char *message)