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

[PATCH 4/4] diff --stat: do not run diff on indentical files

From
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Date
May 1, 2012, 17:10 UTC
Message-ID
<1335892215-21331-5-git-send-email-zbyszek@in.waw.pl>
In-Reply-To
<1335892215-21331-1-git-send-email-zbyszek@in.waw.pl>
If sha1's are equal, then there's no point in performing the diff.
In a very unscientific test:
git init &&
  dd if=/dev/urandom bs=1M count=30 | hexdump >file1 &&
  git add file1 && git commit -m 'add file' &&
  git mv file1 file1-moved && chmod +x file1-moved &&
  command time git diff --stat

(before) git diff --stat 2.00s user 0.31s system 99% cpu 2.323 total (after) git diff --stat 0.80s user 0.10s system 98% cpu 0.913 total

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
---
 diff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/diff.c b/diff.c
index 6eb2946..7cb9893 100644
--- a/diff.c
+++ b/diff.c
@@ -2398,7 +2398,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
 		data->added = count_lines(two->data, two->size);
 	}
 
-	else {
+	else if (!data->is_unchanged) {
 		/* Crazy xdl interfaces.. */
 		xpparam_t xpp;
 		xdemitconf_t xecfg;
-- 
1.7.10.539.g288dd
Previous: Zbigniew Jędrzejewski-SzmekNext: Martin Mares
Message 10 of 11 in “report chmod'ed binary files the same as text files”
  1. 0/4 report chmod'ed binary files the same as text filesZbigniew Jędrzejewski-Szmek, May 1, 2012
  2. 1/4 test: modernize style of t4006Zbigniew Jędrzejewski-Szmek, May 1, 2012
  3. Junio C HamanoMay 1, 2012
  4. Zbigniew Jędrzejewski-SzmekMay 1, 2012
  5. 2/4 tests: check --[short]stat output after chmodZbigniew Jędrzejewski-Szmek, May 1, 2012
  6. Johannes SixtMay 2, 2012
  7. 3/4 diff --stat: report chmoded binary files like text filesZbigniew Jędrzejewski-Szmek, May 1, 2012
  8. Junio C HamanoMay 1, 2012
  9. Zbigniew Jędrzejewski-SzmekMay 1, 2012
  10. 4/4 diff --stat: do not run diff on indentical filesZbigniew Jędrzejewski-Szmek, May 1, 2012
  11. Martin MaresMay 3, 2012

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.