Git development
 help / color / mirror / Atom feed
* [RFD] Strange patch formats (aka tricks with unified diffs)..
@ 2007-04-12 21:58 Linus Torvalds
  2007-04-12 23:02 ` Junio C Hamano
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Linus Torvalds @ 2007-04-12 21:58 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Paul Mackerras


I'm not sure how many people on this list have worked with unified diffs 
for as long as I have, and are so used to them that they can edit them up 
(and fix up line numbers etc) in their sleep.

So I don't know if people are used to some of the really nice tricks you 
can do with them.

For example, a lot of traditional context diff patch proponents (you're 
wrong, btw) think that unified diffs are hard to read, because you don't 
see the "end result". There's a really trivial trick for this, which is to 
just do

	grep -v '^-'

on the patch, and suddenly you see the patch in a totally different light: 
you see what the end result is (in a much more readable format than a 
traditional context diff).

The reverse operation ("grep -v '^+'") also obviously works, but since it 
just shows the code the way it already is, the only reason to use it tends 
to be an incorrectly reversed patch, or when you just want to see the old 
code side-by-side with the new code (which is why some people prefer 
traditional context diffs, but the reason I hate them is that they break 
up the old/new vertically in random places, so you can't just have two 
windows open and compare them side by side).

I'm normally actually very good at doing that "grep" mentally, and don't 
actually often need to do it explicitly at all, unless the patch is just 
pretty messy. But sometimes the patch is just confusing enough that it 
helps to explicitly filter it.

Now, the reason I mention this is that I was just in "gitk", and while I 
love the gitk graphical revision view, I just noticed (once again) why I 
tend to hate most GUI programs. I can't do the clever tricks! The gitk 
diffs are nice and colorized, but the "show just end result" trick just 
doesn't work.

So I can see two ways to fix this:
 - bug Paul about alternate diff viewing capabilities in gitk. He's cc'd 
   here. A way to make the "diff" pane show just the new one, the old one, 
   or even both side-by-side with some mousy interface?
 - 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.

I dunno. I realize that it's not just gitk - gitweb, qgit etc don't allow 
the tricks *either*, but gitk was the one I just hit this with. I ended up 
just cutting-and-pasting the SHA1 and doing the thing in a terminal with 
the shell pipeline instead. Am wondering if maybe other people have ideas 
on this.

Maybe I don't need this often enough for it to matter (as mentioned, I'm 
so good at doing this in squishy-ware that I read patches _without_ the 
explicit help most of the time) but I realized that if I do it 
occasionally, perhaps people who haven't worked with unified diffs quite 
as much as I have never even realized..

		Linus

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-04-18  4:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-12 21:58 [RFD] Strange patch formats (aka tricks with unified diffs) Linus Torvalds
2007-04-12 23:02 ` Junio C Hamano
2007-04-13  5:38 ` Marco Costalba
2007-04-17 18:02   ` Marco Costalba
2007-04-13  5:43 ` Paul Mackerras
2007-04-13  6:07   ` Martin Langhoff
2007-04-13  6:35     ` Junio C Hamano
2007-04-13  7:01       ` Martin Langhoff
2007-04-14  8:59       ` Johannes Schindelin
2007-04-14  9:55         ` Junio C Hamano
2007-04-14 10:09           ` Jeff King
2007-04-13 15:16   ` Linus Torvalds
2007-04-18  1:44     ` Paul Mackerras
2007-04-18  4:02       ` Linus Torvalds
2007-04-13  8:10 ` Matthias Lederhofer
2007-04-13 15:00   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox