Thread (1 message) 1 message, 1 author, 2016-06-15

GIT blame (was Re: Quick command reference)

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:56

quoted
quoted
quoted
quoted
I == Junio C Hamano [off-list ref] said:
JCH> Linus, please pull from git-jc.git archive at:
JCH>     http://members.cox.net/junkio/git-jc.git/

Since that message I have added a couple more commits there.
One of the things is a backport of -t (tag) flag to git-ls-files
from Cogito fork.

The reason I am writing this message is not because I am excited
about the backport [*1*], but because I find it quite cool the
way I found out which commit in Pasky's development line
introduced the change.  It demonstrates your previous "renames
does not matter when doing CVS blame" argument actually works.

Here is what I did:

  1. Go into git.pasky and look at ls-files.c, grab a couple of
     lines that look particular to Cogito version and store
     those lines in a file.  I used the following:

     $ cat >pattern <<\EOF
     static const char *tag_cached = "";
     static const char *tag_unmerged = "";
     static const char *tag_removed = "";
     static const char *tag_other = "";
     EOF

  2. Run the following command:

     $ jit-search-change HEAD pattern

What jit-search-change does is essentially what you described in
your "renames do not matter" argument.  It does git-rev-list to
list the commits from newer to older, runs git-diff-tree between
parent-commit pairs, with GIT_EXTERNAL_DIFF set to a script that
shows the diff between corresponding file in these two trees
only if the file from one tree has that pattern string and the
other tree's does not.  When it shows this diff, it also reports
the commit pair, and that's how you can find out which commit
introduced that change.

It currently shows useless hits when it sees merges from you to
Cogito, since those merges re-introduces the same change by
forward porting it over and over, which I am thinking about ways
to cull.  Maybe limiting the search only to parent-commit pair
that has only one parent would be good enough.  There are other
things to improve, but I am reasonably happy how it worked out.

[Footnote]

*1* The reason for the backport is because it is so small and
trivial change that does not affect the operation of the command
when the flag is not used.  I do not see a reason to force Pasky
to keep shipping the version modified for Cogito use.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help