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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Fri, 13 Apr 2007, Matthias Lederhofer wrote:

> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]