summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-05-01 19:10:15 +0200
committerJunio C Hamano <gitster@pobox.com>2012-05-01 21:29:03 -0700
commit352ca4e105e6fb37cad97b80f2640d28b133ca9d (patch)
tree738e0a4337cf77ae6cb0f3851ffe2b25e02133d9 /diff.c
parente18872b2f0fba4cb860c9350bb8b8d8680dfc83b (diff)
downloadgit-352ca4e105e6fb37cad97b80f2640d28b133ca9d.tar.gz
diff --stat: do not run diff on indentical files
If two objects are known to be equal, there is no point running the diff. Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index e61ccd1123..8e61f4bf85 100644
--- a/diff.c
+++ b/diff.c
@@ -2370,6 +2370,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
{
mmfile_t mf1, mf2;
struct diffstat_file *data;
+ int same_contents;
data = diffstat_add(diffstat, name_a, name_b);
@@ -2378,9 +2379,11 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
return;
}
+ same_contents = !hashcmp(one->sha1, two->sha1);
+
if (diff_filespec_is_binary(one) || diff_filespec_is_binary(two)) {
data->is_binary = 1;
- if (!hashcmp(one->sha1, two->sha1)) {
+ if (same_contents) {
data->added = 0;
data->deleted = 0;
} else {
@@ -2396,7 +2399,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
data->added = count_lines(two->data, two->size);
}
- else {
+ else if (!same_contents) {
/* Crazy xdl interfaces.. */
xpparam_t xpp;
xdemitconf_t xecfg;