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

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

From
Junio C Hamano <junkio@cox.net>
Date
Apr 12, 2007, 23:02 UTC
Message-ID
<7vodlti4bj.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0704121436050.4061@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 10 quoted lines
> 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.
Show 7 quoted lines
> 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.
The switch itself would literally be a one-liner (see below).

However, I suspect what you want is _not_ "turn the negative side completely off", but "make the negative side visually more easily ignorable".

How about displaying the deleted lines with light gray on white background, or something like that?

Show 5 quoted lines
> 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.
diff --git a/diff.c b/diff.c
index fbb79d7..e61abed 100644
--- a/diff.c
+++ b/diff.c
@@ -565,6 +565,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
 	}
 
 	if (color != DIFF_FILE_NEW) {
+		if (diff_no_deleted_lines && color == DIFF_FILE_OLD)
+			return;
 		emit_line(diff_get_color(ecbdata->color_diff, color),
 			  reset, line, len);
 		return;
Previous: Linus TorvaldsNext: Marco Costalba
Message 2 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.