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

[PATCH 3/3] diff: turn off skip_stat_unmatch on "diff --cached"

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 25, 2014, 06:46 UTC
Message-ID
<1390632411-3596-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1390632411-3596-1-git-send-email-pclouds@gmail.com>

skip_stat_unmatch flag is added in fb13227 (git-diff: squelch "empty" diffs - 2007-08-03) to ignore empty diffs caused by stat-only dirtiness. In "diff --cached" case, stat is not invovled at all. While the code is written in a way that no expensive I/O is done, we still need to move all file pairs from the old queue to the new queue in diffcore_skip_stat_unmatch(). Avoid it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/diff.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin/diff.c b/builtin/diff.c
index 0f247d2..85f97d7 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -150,9 +150,10 @@ static int builtin_diff_index(struct rev_info *revs,
 			perror("read_cache_preload");
 			return -1;
 		}
-	} else if (read_cache() < 0) {
-		perror("read_cache");
-		return -1;
+	} else {
+		if (read_cache() < 0)
+			return error("read_cache: %s", strerror(errno));
+		revs->diffopt.skip_stat_unmatch = 0;
 	}
 	return run_diff_index(revs, cached);
 }
-- 
1.8.5.2.240.g8478abd
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 5 of 12 in “bug with git-diff --quiet”
  1. IWAMOTO ToshihiroJan 23, 2014
  2. Duy NguyenJan 25, 2014
  3. 1/3 Move diffcore_skip_stat_unmatch core logic out for reuse laterNguyễn Thái Ngọc Duy, Jan 25, 2014
  4. 2/3 diff: do not quit early on stat-dirty filesNguyễn Thái Ngọc Duy, Jan 25, 2014
  5. 3/3 diff: turn off skip_stat_unmatch on "diff --cached"Nguyễn Thái Ngọc Duy, Jan 25, 2014
  6. 3/3 diff: turn skip_stat_unmatch on selectivelyNguyễn Thái Ngọc Duy, Jan 27, 2014
  7. Junio C HamanoJan 27, 2014
  8. Junio C HamanoJan 28, 2014
  9. Duy NguyenJan 28, 2014
  10. Junio C HamanoJan 29, 2014
  11. Duy NguyenJan 30, 2014
  12. Junio C HamanoJan 31, 2014

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.