Subject: Re: git-last-modified on bare repository

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 6 Jan 2026 10:58:33 +0100

On Tue, Jan 06, 2026 at 10:42:55AM +0100, Gusted wrote:
> On 1/5/26 4:17 PM, Patrick Steinhardt wrote:
> > On Mon, Jan 05, 2026 at 04:06:39PM +0100, Gusted wrote:
> > > On 1/5/26 4:03 PM, Patrick Steinhardt wrote:
> > > > On Mon, Jan 05, 2026 at 02:35:56PM +0100, Gusted wrote:
> > > > > Hi,
> > > > > 
> > > > > Now trying to actually make Forgejo use git last-modified after being
> > > > > pointed to the non-yet-documented options but I quickly noticed that it
> > > > > looks like it does not work as intended on bare repositories when looking
> > > > > specifying files.
> > > > > 
> > > > > $ git clone https://codeberg.org/Gusted/math-accuracy
> > > > > $ cd math-accuracy
> > > > > $ git last-modified -- LICENSES
> > > > > 768f05837e7db2832425bc3b65d0f524e81b2769        LICENSES
> > > > > 
> > > > > And on a bare repository:
> > > > > 
> > > > > $ git clone --bare https://codeberg.org/Gusted/math-accuracy
> > > > > $ cd math-accuracy.git
> > > > > $ git last-modified -- LICENSE
> > > > > fatal: ambiguous argument 'LICENSE': unknown revision or path not in the
> > > > > working tree.
> > > > > Use '--' to separate paths from revisions, like this:
> > > > > 'git <command> [<revision>...] -- [<file>...]'
> > > > > 
> > > > > Is a worktree required for this to work?
> > > > 
> > > > A worktree is not required for this to work. The problem is that you've
> > > > got a typo in there: you say "LICENSE", but the actual file is called
> > > > "LICENSES". If you spell it correctly it should work alright.
> > > > 
> > > 
> > > Ah, sorry the typo is on me from copying the wrong command from the shell
> > > history. It produces the same output with using LICENSES as path.
> > > 
> > > $ git last-modified -- LICENSES
> > > fatal: ambiguous argument 'LICENSES': unknown revision or path not in the
> > > working tree.
> > > Use '--' to separate paths from revisions, like this:
> > > 'git <command> [<revision>...] -- [<file>...]'
> > 
> > Hm, interesting, this works for me in a bare repository. Has this
> > already been fixed...? Indeed, bisecting this points to 05491b90ce
> > (last-modified: support sparse checkouts, 2025-11-29). So you should
> > probably try with Git's "master" branch.
> > 
> > Patrick
> 
> Yup, git from source works! Do you by any chance know if 05491b90ce is going
> to be in v2.52.1?

No idea, point releases are typically done rather ad-hoc. Let me Cc
Junio though so that he's aware that we might want to pick this if we
ever release v2.52.1.

Patrick