Thread (10 messages) flat view 10 messages, 5 authors, 2016-06-15

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

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:43:04


On Fri, 13 Apr 2007, Matthias Lederhofer wrote:
Linus Torvalds [off-list ref] wrote:
quoted
 - 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help