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

Re: [RFD] Strange patch formats (aka tricks with unified diffs)..

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Apr 13, 2007, 15:00 UTC
Message-ID
<Pine.LNX.4.64.0704130751560.28042@woody.linux-foundation.org>
In-Reply-To
<20070413081049.GA26649@moooo.ath.cx>
On Fri, 13 Apr 2007, Matthias Lederhofer wrote:
Show 8 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
> >  - add some actual switch to git diff generation to hide the negative side 
> >    of a unified diff, and add some way to just make gitk pass that switch 
> >    in.
> 
> This one would still allow to show the added lines still colored in
> green.  Or do I miss a way to do this?  git show --color is not very
> grep friendly because lines begin with an escape sequence.

Heh. I'm not much for color, so I've never done it. But if you want it, you should be able to just do

	git show --color <commit> |
		grep -v '^[^ ]*-' |
		less -RS

because every line of a diff (and even the explanations, thanks to the indent-by-four rule of git log printing) should either start with a "+/-" *or* they will have a space before they will show up, so using the "no spaces before the -" rule instead of "beginning of line" should work..

So the above will *literally* just remove the "---" line and the actual removal lines of the diff, even in the presense of color coding.

The exception, of course, is:
 - maybe I didn't think it through and I missed some case, and it removes 
   lines it shouldn't.
 - if you make the color coding itself have spaces or something in it 
   you break my assumption (but the vt100 codes should be fine)
Hmm?
		Linus
Previous: Matthias Lederhofer
Message 16 of 16 in “[RFD] Strange patch formats (aka tricks with unified diffs)..”
  1. Linus TorvaldsApr 12, 2007
  2. Junio C HamanoApr 12, 2007
  3. Marco CostalbaApr 13, 2007
  4. Marco CostalbaApr 17, 2007
  5. Paul MackerrasApr 13, 2007
  6. Martin LanghoffApr 13, 2007
  7. Junio C HamanoApr 13, 2007
  8. Martin LanghoffApr 13, 2007
  9. Johannes SchindelinApr 14, 2007
  10. Junio C HamanoApr 14, 2007
  11. Jeff KingApr 14, 2007
  12. Linus TorvaldsApr 13, 2007
  13. Paul MackerrasApr 18, 2007
  14. Linus TorvaldsApr 18, 2007
  15. Matthias LederhoferApr 13, 2007
  16. Linus TorvaldsApr 13, 2007

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.