threads / discuss / 64724

git-last-modified on bare repository

Subject: git-last-modified on bare repository

## tl;dr

11 messages between Jan 5, 2026 and Jan 12, 2026.

replies: 10people: 6as markdown or json

Gusted· Jan 5, 2026, 13:35 UTC · lore
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?

Because it was talking about revision, I quickly checked a refspec as input and it looks like I found another way to trigger a BUG.

$ git last-modified -- HEAD:LICENSES
BUG: builtin/last-modified.c:456: paths remaining beyond boundary in 
last-modified
[1]    202076 IOT instruction (core dumped)  git last-modified -- 
HEAD:LICENSES
On the bare and non-bare repository.

Kind Regards Gusted

Patrick Steinhardt· Jan 5, 2026, 15:03 UTC · re: Gusted · lore

Re: git-last-modified on bare repository

On Mon, Jan 05, 2026 at 02:35:56PM +0100, Gusted wrote:
Show 23 quoted lines
> 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.

Show 10 quoted lines
> Because it was talking about revision, I quickly checked a refspec as input
> and it looks like I found another way to trigger a BUG.
> 
> $ git last-modified -- HEAD:LICENSES
> BUG: builtin/last-modified.c:456: paths remaining beyond boundary in
> last-modified
> [1]    202076 IOT instruction (core dumped)  git last-modified --
> HEAD:LICENSES
> 
> On the bare and non-bare repository.
This looks like a bug to me indeed. Cc'ing Toon.
Thanks!
Patrick
Gusted· Jan 5, 2026, 15:06 UTC · re: Patrick Steinhardt · lore

Re: git-last-modified on bare repository

On 1/5/26 4:03 PM, Patrick Steinhardt wrote:
Show 29 quoted lines
> 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>...]'

Show 16 quoted lines
>> Because it was talking about revision, I quickly checked a refspec as input
>> and it looks like I found another way to trigger a BUG.
>>
>> $ git last-modified -- HEAD:LICENSES
>> BUG: builtin/last-modified.c:456: paths remaining beyond boundary in
>> last-modified
>> [1]    202076 IOT instruction (core dumped)  git last-modified --
>> HEAD:LICENSES
>>
>> On the bare and non-bare repository.
> 
> This looks like a bug to me indeed. Cc'ing Toon.
> 
> Thanks!
> 
> Patrick

Kind Regards Gusted

Patrick Steinhardt· Jan 5, 2026, 15:17 UTC · re: Gusted · lore

Re: git-last-modified on bare repository

On Mon, Jan 05, 2026 at 04:06:39PM +0100, Gusted wrote:
Show 39 quoted lines
> 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
Gusted· Jan 6, 2026, 09:42 UTC · re: Patrick Steinhardt · lore

Re: git-last-modified on bare repository

On 1/5/26 4:17 PM, Patrick Steinhardt wrote:
Show 47 quoted lines
> 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?

Kind Regards Gusted

Patrick Steinhardt· Jan 6, 2026, 09:58 UTC · re: Gusted · lore

Re: git-last-modified on bare repository

On Tue, Jan 06, 2026 at 10:42:55AM +0100, Gusted wrote:
Show 51 quoted lines
> 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
Kristoffer Haugsbakk· Jan 6, 2026, 10:54 UTC · re: Patrick Steinhardt · lore

Re: git-last-modified on bare repository

On Tue, Jan 6, 2026, at 10:58, Patrick Steinhardt wrote:
Show 10 quoted lines
> On Tue, Jan 06, 2026 at 10:42:55AM +0100, Gusted wrote:
>> On 1/5/26 4:17 PM, Patrick Steinhardt wrote:
>>>[snip]
>>
>> 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.

`RelNotes` says that this will be merged to `maint` later which points at tag v2.52.0 currently.

     * "git last-modified" used to mishandle "--" to mark the beginning of
       pathspec, which has been corrected.
       (merge 05491b90ce js/last-modified-with-sparse-checkouts later to maint).
Junio C Hamano· Jan 7, 2026, 00:01 UTC · re: Kristoffer Haugsbakk · lore

Re: git-last-modified on bare repository

"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
Show 18 quoted lines
> On Tue, Jan 6, 2026, at 10:58, Patrick Steinhardt wrote:
>> On Tue, Jan 06, 2026 at 10:42:55AM +0100, Gusted wrote:
>>> On 1/5/26 4:17 PM, Patrick Steinhardt wrote:
>>>>[snip]
>>>
>>> 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.
>
> `RelNotes` says that this will be merged to `maint` later which points
> at tag v2.52.0 currently.
>
>      * "git last-modified" used to mishandle "--" to mark the beginning of
>        pathspec, which has been corrected.
>        (merge 05491b90ce js/last-modified-with-sparse-checkouts later to maint).

These are really "if we will produce a release out of 'maint', the topics marked with these can cleanly be merged to be part of it", and does not answer "if we ever have 2.52.1?" at all, though ;-)

I am on a bereavement leave now, so expect that my response will be leaky and slow.

D. Ben Knoble· Jan 7, 2026, 17:12 UTC · re: Junio C Hamano · lore

Re: git-last-modified on bare repository

On Tue, Jan 6, 2026 at 7:01 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 25 quoted lines
>
> "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
>
> > On Tue, Jan 6, 2026, at 10:58, Patrick Steinhardt wrote:
> >> On Tue, Jan 06, 2026 at 10:42:55AM +0100, Gusted wrote:
> >>> On 1/5/26 4:17 PM, Patrick Steinhardt wrote:
> >>>>[snip]
> >>>
> >>> 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.
> >
> > `RelNotes` says that this will be merged to `maint` later which points
> > at tag v2.52.0 currently.
> >
> >      * "git last-modified" used to mishandle "--" to mark the beginning of
> >        pathspec, which has been corrected.
> >        (merge 05491b90ce js/last-modified-with-sparse-checkouts later to maint).
>
> These are really "if we will produce a release out of 'maint', the
> topics marked with these can cleanly be merged to be part of it",
> and does not answer "if we ever have 2.52.1?" at all, though ;-)
Good to know; I'd had questions about that as well.
> I am on a bereavement leave now, so expect that my response will be
> leaky and slow.
Sorry to hear that. The only thing I know for sure is it gets easier with time.
-- 
D. Ben Knoble
Kristoffer Haugsbakk· Jan 5, 2026, 15:17 UTC · re: Patrick Steinhardt · lore

Re: git-last-modified on bare repository

On Mon, Jan 5, 2026, at 16:03, Patrick Steinhardt wrote:
Show 28 quoted lines
> 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.

The error message is more generic than it needs to be though. It has seen a `--` but it falls back to “revision or path”. A more pointed error error message “unknown path” would make it harder to make the mistake of dismissing the error as a bogus one.

Of course, separate issue and all.
Toon Claes· Jan 12, 2026, 15:15 UTC · re: Patrick Steinhardt · lore

Re: git-last-modified on bare repository

Patrick Steinhardt <ps@pks.im> writes:
Show 13 quoted lines
> On Mon, Jan 05, 2026 at 02:35:56PM +0100, Gusted wrote:
>> Because it was talking about revision, I quickly checked a refspec as input
>> and it looks like I found another way to trigger a BUG.
>> 
>> $ git last-modified -- HEAD:LICENSES
>> BUG: builtin/last-modified.c:456: paths remaining beyond boundary in
>> last-modified
>> [1]    202076 IOT instruction (core dumped)  git last-modified --
>> HEAD:LICENSES
>> 
>> On the bare and non-bare repository.
>
> This looks like a bug to me indeed. Cc'ing Toon.
Okay, there are various things going on.
First. If you do:
    $ git last-modified -- HEAD:LICENSES

On Git 2.52.0, then you're getting the BUG. On 'master' you'll get simply no output.

But if you do:
    $ git last-modified HEAD:LICENSES

Then you actually trigger the same bug as you've reported before. "HEAD:LICENSES" resolves to a tree oid. So that command is basically the same as:

    $ git last-modified b79c618f6a11fc6f550dc98ef3227ef77b3132aa
In both situation you get a BUG. And I'm still working on a fix.
-- 
Cheers,
Toon

← back to recent threads