Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Add "--summary" option to git diff.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:26
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Linus Torvalds [off-list ref] writes:
On Sun, 14 May 2006, Sean wrote:
quoted
What's a bit more worrying is that:

$ PAGER= ./git whatchanged -B -C --stat --no-merges --diff-filter=RC

Causes the same problem on the current (1.3.2) release branch without any
other patches applied at all.
And the culprit was _me_ X-<.  *BLUSH*


-- >8 --
diff --git a/diff.c b/diff.c
index 7a7b839..2d72673 100644
--- a/diff.c
+++ b/diff.c
@@ -232,11 +232,16 @@ static char *pprint_rename(const char *a
 	 * name-a => name-b
 	 */
 	if (pfx_length + sfx_length) {
+		int a_len = len_a - pfx_length - sfx_length;
+		int b_len = len_b - pfx_length - sfx_length;
+		if (a_len < 0) a_len = 0;
+		if (b_len < 0) b_len = 0;
+
 		name = xmalloc(len_a + len_b - pfx_length - sfx_length + 7);
 		sprintf(name, "%.*s{%.*s => %.*s}%s",
 			pfx_length, a,
-			len_a - pfx_length - sfx_length, a + pfx_length,
-			len_b - pfx_length - sfx_length, b + pfx_length,
+			a_len, a + pfx_length,
+			b_len, b + pfx_length,
 			a + len_a - sfx_length);
 	}
 	else {
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help