Subject: Re: [PATCH RFC v2 0/5] Introduce git-last-modified(1) command

From: Junio C Hamano <[email-masked]>
Date: Tue, 01 Jul 2025 14:06:49 -0700

"Kristoffer Haugsbakk" <[email-masked]> writes:

> It feels like the command strays a bit from the usual patterns to me.  For paths/files 
> that is.  I like this:
>
> ```
> $ git last-modified -r refs.c refs.h
> 062b914c841329a003f74e1340ea5178391274a6	refs.c
> 47478802daddf3f9916111307f153c6298ffc0bc	refs.h
> ```

I am not getting this example.  Unless "-r" stands for "reverse",
the above looks totally expected.

> I ask for two files and I get those in the output.
>
> But for individual files in subdirectories:
>
> ```
> $ git last-modified refs.c refs.h Documentation/git-last-modified.adoc Documentation/git-config.adoc
> 3691fe72d927658ae77ade7fe967544fc6739e67	Documentation
> 062b914c841329a003f74e1340ea5178391274a6	refs.c
> 47478802daddf3f9916111307f153c6298ffc0bc	refs.h
> ```

I am indifferent with this outcome.  I do not mind the tool giving
Documentation/ even when paths inside it are asked about, when it is
not asked to go recursive.

> Same as if I ask for `Documentation`:
>
> ```
> $ git last-modified refs.c refs.h Documentation/
> 3691fe72d927658ae77ade7fe967544fc6739e67	Documentation
> 062b914c841329a003f74e1340ea5178391274a6	refs.c
> 47478802daddf3f9916111307f153c6298ffc0bc	refs.h
> ```
>
> But I didn’t ask for the directory first.  I asked for two files.

I do not see anything unexpected.  Have you seen "git ls-tree"
output without -r(ecursive) before?

    $ git ls-tree HEAD refs.c refs.h Documentation
    040000 tree a0f7113f63a19b70dff14bfd9f8f82809f5068e1	Documentation
    100644 blob dce5c49ca2ba65fd6a2974e38f67134215bee369	refs.c
    100644 blob 46a6008e07f2624239139cd8b2ff712545f07d3f	refs.h

As I understand that this tool was written primarily to implement
scripts like repository browsers showing https://github.com/git/git
I do not mind non-recursive behaviour being the default.  After all
I view it as a plumbing.

> I have to use `-r` (recurse):
>
> ```
> $ git last-modified -r refs.c refs.h Documentation/git-last-modified.adoc Documentation/git-config.adoc
> 3691fe72d927658ae77ade7fe967544fc6739e67	Documentation/git-last-modified.adoc
> 062b914c841329a003f74e1340ea5178391274a6	refs.c
> 47478802daddf3f9916111307f153c6298ffc0bc	refs.h
> 0fbe93b36c05bbf4156c157f27998938ce312265	Documentation/git-config.adoc
> ```
>
> And `-r` with a directory like `Documentation` will recurse through that
> directory.

Totally expected.