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

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

From
Junio C Hamano <junkio@cox.net>
Date
May 15, 2006, 02:34 UTC
Message-ID
<7v7j4oxbgm.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0605141848080.3866@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 8 quoted lines
> On Sun, 14 May 2006, Sean wrote:
>> 
>> 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 {
Previous: Linus Torvalds
Message 5 of 5 in “Add "--summary" option to git diff.”
  1. Add "--summary" option to git diff.Sean, May 14, 2006
  2. Junio C HamanoMay 15, 2006
  3. SeanMay 15, 2006
  4. Linus TorvaldsMay 15, 2006
  5. Junio C HamanoMay 15, 2006

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.