Subject: Re: Tracking file metadata in git -- fix metastore or enhance git?

From: Jonathan Nieder <[email-masked]>
Date: Sat, 9 Apr 2011 19:15:18 -0500

Hi again.

Chris Webb wrote:

> (Disclaimer: I've never tried using smudge filters; maybe they can't be used
> in the way I describe!)

In the current form, they couldn't.  smudge/clean filters take their
input through stdin and write their output to stdout --- there is not
a chance to look at the on-disk directory entry to get metadata.

It might be possible to introduce a new %p substitution pointing to
the actual file the filter is working on, since with a few exceptions,
the file passed to a clean filter is already on-disk.  Exceptions:

 * "git blame --contents=- -- <path>" reads from stdin instead of <path>.

 * the low-level --renormalize facility (see git-merge(1)) and its
   callers feed a clean filter with output from a smudge filter before
   content hits the disk.

 * "git hash-object --path=<path> --stdin" reads from stdin instead of
   <path>.

I'd be worried about using a clean filter to store timestamps.
Treating a file as changed whenever mtime changes could be confusing.
Treating atime changes as content changes would be even stranger.

Richard Hartmann wrote:

> One large question in my mind is if anyone who's familiar enough with
> the codebase and has the time would be interested in actually
> implementing this.

I don't think this has to touch git core, except perhaps as mentioned
above.  Please feel free to cc me if working on hooks (pre-commit hook
or clean filter) to automatically track metadata and some mechanism to
restore it.  I'd be glad to give feedback and help in any other way I
can.

To be clear, I will not be driving this forward --- it's just not
something I've ever needed, so I'd trust others to do a better job of
taking good care of the actual use cases.

Ciao,
Jonathan