On Fri, 11 Jan 2013 12:05:56 -0800 (PST)
Blind <stoycho.slept...@gmail.com> wrote:
> I was wandering,
> is there an easy "git"-way to make a list of files (inside a git
> repository, of course), which outputs the same as "ls", plus last
> commit date and author who changed the file?
> I was doing some experiments with #git ls-files, but he provides me
> the hash of the blob, who have no info about dates and commits in it.
> It surely must be some clever git command to do this because I see
> similar output when listing github projects on the tab "Files". For
> example the git source itself on github looks like:
Well, my take is that this is not doable using porcelain commands.
`git ls-tree` also looks like it's not the right tool for this job.
You could roll your own history walking using calls to the
`git cat-file` plumbing command but then you'll face the need to
follow merges and track file renames. So it looks like the real way to
go is to reach for the Git internals and see how, say, `git log ...
<file>` is implemented and whether you can somehow use their algorythm.
You could first try a no-brainer approach though: start from the
specified revision (say, HEAD), capture what's available in the tree
associated with it and then go down the history looking for a moment
where the *name* of an object as recorded in the tree of the starting
revision changes its SHA-1 -- for files that would mean changing their
contents, and for directories (trees, in the plumbing-level Git's
lingo) that would mean changing their contents as well
(adding/removing/renaming files and/or subdirectories). The only
difficult problem to tackle in such scenario is following merges: even
for the case of a simple merge where a merge commit has just two
parents, you'll have to follow both lines of history to check which
line was the last to introduce a change to the given file/tree.