git/list[1] front-page[2] threads[3] people[4] search[5] about
 

GIT blame (was Re: Quick command reference)

From
Junio C Hamano <junkio@cox.net>
Date
May 6, 2005, 09:32 UTC
Message-ID
<7v3bt0em35.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7vhdhgeuj1.fsf@assigned-by-dhcp.cox.net>
>>>>> I == Junio C Hamano <junkio@cox.net> 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.

Previous: Junio C HamanoNext: bert hubert
Message 10 of 16 in “Quick command reference”
  1. Paul MackerrasMay 1, 2005
  2. David GreavesMay 1, 2005
  3. Brian O'MahoneyMay 1, 2005
  4. David GreavesMay 1, 2005
  5. Linus TorvaldsMay 1, 2005
  6. David GreavesMay 1, 2005
  7. Junio C HamanoMay 1, 2005
  8. Junio C HamanoMay 1, 2005
  9. Junio C HamanoMay 6, 2005
  10. GIT blame (was Re: Quick command reference)Junio C Hamano, May 6, 2005
  11. bert hubertMay 1, 2005
  12. David GreavesMay 1, 2005
  13. Linus TorvaldsMay 1, 2005
  14. Randy.DunlapMay 2, 2005
  15. H. Peter AnvinMay 1, 2005
  16. David GreavesMay 1, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.