Re: [PATCH] Built-in diff driver shows Index: line.

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Built-in diff driver shows Index: line.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:55

quoted
quoted
quoted
quoted
"LT" == Linus Torvalds [off-list ref] writes:
LT> Actually, I do dislike the Index: line, and think this is a pretty
LT> intrusive work-around for a problem with diffstat.

Alright.  Please consider the patch retracted.

LT> Oh, actually maybe the better pattern to use is the one that GNU diff 
LT> itself ends up matching:
LT> 	"*** %[^\t ]%[\t ]%d%c%d%c%d %d:%d:%d"
LT> where the "%c" has to be either '-' or '/' (ie it ends up matching as 
LT> "numeric date" + "numeric time").

LT> You can put the "mode" thing at the end, and diffstat won't care about it.

Hmph.  Timestamps do not mean anything in most of the intended
use of diff-* family, since they are meant to operate on trees,
except:

 - comparing against the working tree --- show-diff's <new> and
   diff-cache's <new>; we can take the timestamp from the
   filesystem.

 - comparing against a tree that comes from a known commit ---
   we can take the timestamp of the commit that contains the
   file.

If we want to show the timestamp of the latter, diff-tree and
diff-cache need to be taught to take notice if their
tree-or-commit parameter is actually a commit and if so needs to
pass the timestamp in the committer field down the path for the
diff driver.  There is no way for diff-tree-helper to do this
because the origin information is already stripped out when it
sees a valid SHA1.

So I'd say we'd punt this one for now, unless somebody else has
a better idea.

Re: [PATCH] Built-in diff driver shows Index: line.

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:41:55


On Thu, 28 Apr 2005, Junio C Hamano wrote:
So I'd say we'd punt this one for now, unless somebody else has
a better idea.
It's trivially easy to do it with a external diff helper.

So you can do it with a few lines of GIT_EXTERNAL_DIFF, and the hardest 
part is showing it in a nice format (ie do the normalization of the 
results that diffstat does).

The external diff program can _literally_ just do something like

	#!/bin/sh
	name="$1"
	src="$2"
	dst="$5"
	diff "$src" "$dst" | cut -c1 | grep '[<>]' | sort | uniq -c

and the output should be something like

    458 <
    104 >

which means "458 lines removed, 104 lines added". Pretty-print it some, 
and you're done.

Hacky hacky,

		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