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

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 <>
 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,
                        return -1;
+               revs->diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
        } else if (read_cache() < 0) {
                return -1;
@@ -252,6 +253,7 @@ static int builtin_diff_files(struct rev_info *revs, int 
argc, const char **argv
                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 
                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;

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to