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

[PATCH v2 3/3] diff: turn skip_stat_unmatch on selectively

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 27, 2014, 22:59 UTC
Message-ID
<1390863568-22656-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<1390632411-3596-3-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 some diff case, stat is not involved 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().

Only enable it when worktree is involved: "diff" and "diff <rev>". This should help track down how skip_stat_unmatch is actually used when bugs occur.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 This replaces 'diff: turn off skip_stat_unmatch on "diff --cached"'
 The previous patch obviously leaves skip_stat_unmatch on in "diff
 <rev> <rev>" and maybe other cases.
 builtin/diff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/diff.c b/builtin/diff.c
index 0f247d2..88542d9 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -150,6 +150,7 @@ static int builtin_diff_index(struct rev_info *revs,
 			perror("read_cache_preload");
 			return -1;
 		}
+		revs->diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 	} else if (read_cache() < 0) {
 		perror("read_cache");
 		return -1;
@@ -252,6 +253,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
 		perror("read_cache_preload");
 		return -1;
 	}
+	revs->diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 	return run_diff_files(revs, options);
 }
 
@@ -343,7 +345,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 		diff_no_index(&rev, argc, argv, prefix);
 
 	/* Otherwise, we are doing the usual "git" diff */
-	rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 
 	/* Scale to real terminal size and respect statGraphWidth config */
 	rev.diffopt.stat_width = -1;
-- 
1.8.5.2.240.g8478abd
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 6 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.