Subject: git-last-modified weirdness

From: Gusted <[email-masked]>
Date: Sun, 4 Jan 2026 06:13:27 +0100

Hi,

Resending this mail as it looks like it might not have arrived (couldn't 
find
it in the mailing list archive).

For Forgejo, I wanted to look into using git-last-modified to gain extra
performance for larger repositories where this can often result in being 
(one
of) the slowest git operation. However I noticed some problems that 
looks to
be bugs.

I've ran all the following commands on the following Git repository, on Git
v2.52.0 (Arch Linux) and my git config does not enable or disable any 
feature
that should've impacted the any of the following observations.

$ tmp=$(mktemp -d)
$ git clone https://codeberg.org/forgejo/forgejo $tmp
$ cd tmp

During some experiments I noticed it being slower for some files. An 
example:

$ hyperfine --warmup 5 'git log --max-count=1 DCO' 'git last-modified DCO'
Benchmark 1: git log --max-count=1 DCO
   Time (mean ± σ):      86.9 ms ±   0.8 ms    [User: 70.1 ms, System: 
15.6 ms]
   Range (min … max):    85.5 ms …  88.3 ms    34 runs

Benchmark 2: git last-modified DCO
   Time (mean ± σ):     151.3 ms ±   4.3 ms    [User: 133.4 ms, System: 
15.9 ms]
   Range (min … max):   145.4 ms … 167.1 ms    19 runs

This might be me misunderstanding the feature, but it looks to me this 
cannot
be used for paths that is inside a directory. The following two commands 
yield
the same output:

$ git last-modified -- web_src
24019ef5e83fd7bed7f31ad09dd8d5f26b4bdc69        web_src
$ git last-modified -- web_src/svg
24019ef5e83fd7bed7f31ad09dd8d5f26b4bdc69        web_src

Where I expected the latter command to return the last commit of 
web_src/svg.

I'm not sure why I tried this, but I can trigger a BUG when giving it some
nonsense input:

$ git last-modified fb06ce04173d47aaaa498385621cba8b8dfd7584
BUG: builtin/last-modified.c:456: paths remaining beyond boundary in
last-modified
[1]    690163 IOT instruction (core dumped)  git last-modified

`fb06ce04173d47aaaa498385621cba8b8dfd7584` is the tree commit id of 
web_src. I
suppose this should've returned a nice error message or blank output. It 
does
give a blank output when you specify a valid path:

$ git last-modified fb06ce04173d47aaaa498385621cba8b8dfd7584 web_src

Kind regards,
Gusted