summaryrefslogtreecommitdiff
path: root/diffcore.h
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-01-25 13:46:50 +0700
committerJunio C Hamano <gitster@pobox.com>2014-02-24 14:50:14 -0800
commitf34b205f6cc2c78cbed03a1582422cb59e36f729 (patch)
treefc164a597ad862e9541ed117e73ad1b6f04a73f0 /diffcore.h
parentfceb907225745b91aa8b9e0ef2ea068b0351ea01 (diff)
downloadgit-f34b205f6cc2c78cbed03a1582422cb59e36f729.tar.gz
diff: do not quit early on stat-dirty filesnd/diff-quiet-stat-dirty
When QUICK is set (i.e. with --quiet) we try to do as little work as possible, stopping after seeing the first change. stat-dirty is considered a "change" but it may turn out not, if no actual content is changed. The actual content test is performed too late in the process and the shortcut may be taken prematurely, leading to incorrect return code. Assume we do "git diff --quiet". If we have a stat-dirty file "a" and a really dirty file "b". We break the loop in run_diff_files() and stop after "a" because we have got a "change". Later in diffcore_skip_stat_unmatch() we find out "a" is actually not changed. But there's nothing else in the diff queue, we incorrectly declare "no change", ignoring the fact that "b" is changed. This also happens to "git diff --quiet HEAD" when it hits diff_can_quit_early() in oneway_diff(). This patch does the content test earlier in order to keep going if "a" is unchanged. The test result is cached so that when diffcore_skip_stat_unmatch() is done in the end, we spend no cycles on re-testing "a". Reported-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diffcore.h')
-rw-r--r--diffcore.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/diffcore.h b/diffcore.h
index 1c16c8595b..6b538bc2fb 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -70,6 +70,8 @@ struct diff_filepair {
unsigned broken_pair : 1;
unsigned renamed_pair : 1;
unsigned is_unmerged : 1;
+ unsigned done_skip_stat_unmatch : 1;
+ unsigned skip_stat_unmatch_result : 1;
};
#define DIFF_PAIR_UNMERGED(p) ((p)->is_unmerged)