Feature Request: show ages in tree view

John Keeping john at keeping.me.uk
Thu Nov 24 19:56:47 CET 2016


On Sun, Oct 30, 2016 at 01:22:24PM +0100, Silly Slux wrote:
> i want to see when a file or tree was last changed when i'm watching
> the tree of a repository.  I've tried to implement it myself, but it
> seems i can't, though i have something to illustrate what i mean.

This is going to be quite a costly operation because it entails walking
back along the commit graph to see when the relevant path last changed.

The algorithm for doing this has to get the SHA-1 associated with the
tree/blob representing the path of interest and then finding the most
recent commit with a different SHA-1 at that location.  Obviously at
merges all parents have to be added to the list of interesting commits.

If you want to try to implement this, Git's commit_list_insert_by_date
function is probably useful for sorting the parent commits.  You can see
how this is used in git/builtin/describe.c::describe() which looks to
have the right structure for walking backwards in the history, then you
just need to get the SHA-1 of the relevant path and break as soon as it
changes.

I expect there's a relatively obvious optimization when we're printing
the contents of a tree object to avoid walking the history for every
path that is printed, but I haven't thought about this in detail.


More information about the CGit mailing list