From: Junio C Hamano Date: Fri, 16 Jan 2026 18:24:44 GMT Subject: Re: [PATCH v3 4/4] last-modified: verify revision argument is a commit-ish Message-ID: In-Reply-To: <20260116-toon-last-modified-tree-v3-4-e6ade4dc35ab@iotcl.com> Toon Claes writes: > Passing a tree OID to git-last-modified(1) would trigger BUG behavior. > > git last-modified HEAD^{tree} > BUG: builtin/last-modified.c:456: paths remaining beyond boundary in last-modified > > Fix this error by verifying the parsed revision is a commit-ish. > > Reported-by: Gusted > Signed-off-by: Toon Claes > --- > builtin/last-modified.c | 5 +++++ > t/t8020-last-modified.sh | 13 +++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/builtin/last-modified.c b/builtin/last-modified.c > index 0df85be318..5366cedd0f 100644 > --- a/builtin/last-modified.c > +++ b/builtin/last-modified.c > @@ -150,6 +150,11 @@ static int populate_paths_from_revs(struct last_modified *lm) > goto out; > } > > + if (!repo_peel_to_type(lm->rev.repo, obj->path, 0, obj->item, OBJ_COMMIT)) { > + ret = error(_("revision argument is not a commit-ish")); > + goto out; > + } This will do, at least for now, but I tend to prefer to say what the user gave us when we expected a commit, e.g., "commit expected, got a tree".