diff --dirstat: saner handling of binary and unmerged files
We do not account binary nor unmerged files when --shortstat is asked for (or the summary stat at the end of --stat). The new option --dirstat should work the same way as it is about summarizing the changes of multiple files by adding them up. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Feb 24, 2008 at 17:37 UTC
2b0b551d7662a4246ed55b6a7029ba3caa65cf98
1 file changed
+6
-1
diff.c
+6
-1
@@ -1016,7 +1016,10 @@ static long gather_dirstat(struct diffstat_dir *dir, unsigned long changed, cons
1016
this = gather_dirstat(dir, changed, f->name, newbaselen);
1017
sources++;
1018
} else {
1019
- this = f->added + f->deleted;
1019
+ if (f->is_unmerged || f->is_binary)
1020
+ this = 0;
1021
+ else
1022
+ this = f->added + f->deleted;
1023
dir->files++;
1024
dir->nr--;
1025
sources += 2;
@@ -1053,6 +1056,8 @@ static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
1056
/* Calculate total changes */
1057
changed = 0;
1058
for (i = 0; i < data->nr; i++) {
1059
+ if (data->files[i]->is_binary || data->files[i]->is_unmerged)
1060
+ continue;
1061
changed += data->files[i]->added;
1062
changed += data->files[i]->deleted;
1063
}