List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: Feature Request: show ages in tree view
Date: Thu, 24 Nov 2016 18:56:47 +0000	[thread overview]
Message-ID: <20161124185647.GB24063@john.keeping.me.uk> (raw)
In-Reply-To: <20161030132224.9B9784EB@net.hr>

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.


      reply	other threads:[~2016-11-24 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-30 12:22 
2016-11-24 18:56 ` john [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161124185647.GB24063@john.keeping.me.uk \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).