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

Re: gitk "find commit adding/removing string"/possible pickaxe bug?

From
Jeff King <peff@peff.net>
Date
Jan 18, 2011, 18:50 UTC
Message-ID
<20110118185027.GA10562@sigill.intra.peff.net>
In-Reply-To
<201101181744.18139.trast@student.ethz.ch>
On Tue, Jan 18, 2011 at 05:44:17PM +0100, Thomas Rast wrote:
Show 8 quoted lines
> In particular, in a history where
> 
>   $ git show HEAD:foo
>   quux
>   $ git show HEAD^:foo
>   bar
>   $ git show HEAD^2:foo
>   baz
I created a similar repo with:
commit() {
  echo $1 >file && git add file && git commit -m $1
}
mkdir repo && cd repo && git init
commit base
commit master
git checkout -b other HEAD^
commit other
git merge master
commit resolved

which should be identical. But I get different results (see near the end):

> the behaviour is:
> 
>   git log -Squux                  # empty
>   git log -Squux -p               # empty

All of which make sense to me. Pickaxe operates on diff filepairs, and git by default doesn't seem to do merge diffing at all (but see below). So those filepairs don't exist to consider.

>   git log -Squux --pickaxe-all    # empty

This doesn't help. It just loosens the actual diff shown from "just the things that matched -S" to "everything in that commit". It doesn't add to the filepairs that make it to pickaxe.

>   git log -Squux -c      	  # shows merge, but no diff

This "-c" does what you want, because we start looking at merge filepairs. Although one thing leaves me confused. If I do:

  git log -p
I get no diff for the merge commit. But in git-diff(1), it says:
  COMBINED DIFF FORMAT
    "git-diff-tree", "git-diff-files" and "git-diff" can take -c or --cc
    option to produce combined diff. For showing a merge commit with
    "git log -p", this is the default format; you can force showing full
    diff with the -m option.

which implies to me that "-c" should be on by default if we selected "-p" (or presumably -S).

I didn't bisect, but I wonder if the doc is wrong, or if we accidentally lost this default at some point.

>   git log -Squux --cc    	  # shows merge, but no diff
Makes sense again, since you didn't ask for a patch, no patch.
>   git log -Squux -c -p   	  # shows merge, but no diff
Weird.  Here I get a nice combined diff, which is what I expect.
>   git log -Squux -c --pickaxe-all # shows merge, but no diff
Yep, no "-p" again.
>   git log -Squux --pickaxe-all -c -p  # shows merge & combined diff

The pickaxe-all shouldn't impact anything, at least not in my test repo, as there is only one file. But of course I do get the diff, as I did above. Can you show the steps to create your repo? I'm wondering what is different.

-Peff
Previous: Junio C HamanoNext: Thomas Rast
Message 4 of 10 in “gitk "find commit adding/removing string"/possible pickaxe bug?”
  1. Sebastian HahnJan 18, 2011
  2. Thomas RastJan 18, 2011
  3. Junio C HamanoJan 18, 2011
  4. Jeff KingJan 18, 2011
  5. Thomas RastJan 18, 2011
  6. Jeff KingJan 18, 2011
  7. Junio C HamanoJan 18, 2011
  8. Jeff KingJan 18, 2011
  9. Jeff KingJan 31, 2011
  10. Thomas RastJan 18, 2011

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.