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

Re: RFH - git-log variant that _does_ search through diffs

From
Jeff King <peff@peff.net>
Date
Jul 1, 2009, 07:02 UTC
Message-ID
<20090701070252.GA7987@sigio.peff.net>
In-Reply-To
<279b37b20906301422w2b895afai5edf42fcbfcc7d5a@mail.gmail.com>
On Tue, Jun 30, 2009 at 02:22:43PM -0700, Eric Raible wrote:
Show 12 quoted lines
> Unfortunately --format seems to turn off -z (at least in msysgit):
> 
> $ git --version
> git version 1.6.3.2.1299.gee46c
> $ git log -p > L1
> $ git log -p -z > L2
> $ diff L1 L2 | wc
>    2415    4347   62889
> $ git log -p --format=%s > L1
> $ git log -p -z --format=%s > L2
> $ diff L1 L2 | wc
>       0       0       0
Ugh. I did some looking into this. It actually does work if you do:
  git log -p -z --pretty=format:%s
rather than
  git log -p -z --pretty=tformat:%s

And --format=%s behaves as if 'tformat' was given. And if you are not up to date on the difference, "format" implies "separator semantics", where the NUL is placed _between_ each record. "tformat" implies "terminator semantics", where the NUL is placed at the end.

Placing the separator correctly is fairly easy; when we start a new record, if we are not the first, we print the separator. Placing a terminator is a little trickier because of the way the code is structured. I'll post my attempt in a minute; see patch 2/2 for more discussion.

-Peff
Previous: Eric RaibleNext: Jeff King
Message 9 of 12 in “RFH - git-log variant that _does_ search through diffs”
  1. Eric RaibleJun 30, 2009
  2. Jeff KingJun 30, 2009
  3. Junio C HamanoJun 30, 2009
  4. Eric RaibleJun 30, 2009
  5. Eric RaibleJun 30, 2009
  6. Jeff KingJun 30, 2009
  7. Eric RaibleJun 30, 2009
  8. Eric RaibleJun 30, 2009
  9. Jeff KingJul 1, 2009
  10. 1/2 log-tree: fix confusing commentJeff King, Jul 1, 2009
  11. 2/2 fix missing NUL termination with pretty=tformatJeff King, Jul 1, 2009
  12. Junio C HamanoJul 1, 2009

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.