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>
This commit is contained in:
5
diff.c
5
diff.c
@ -1016,6 +1016,9 @@ static long gather_dirstat(struct diffstat_dir *dir, unsigned long changed, cons
|
|||||||
this = gather_dirstat(dir, changed, f->name, newbaselen);
|
this = gather_dirstat(dir, changed, f->name, newbaselen);
|
||||||
sources++;
|
sources++;
|
||||||
} else {
|
} else {
|
||||||
|
if (f->is_unmerged || f->is_binary)
|
||||||
|
this = 0;
|
||||||
|
else
|
||||||
this = f->added + f->deleted;
|
this = f->added + f->deleted;
|
||||||
dir->files++;
|
dir->files++;
|
||||||
dir->nr--;
|
dir->nr--;
|
||||||
@ -1053,6 +1056,8 @@ static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
|
|||||||
/* Calculate total changes */
|
/* Calculate total changes */
|
||||||
changed = 0;
|
changed = 0;
|
||||||
for (i = 0; i < data->nr; i++) {
|
for (i = 0; i < data->nr; i++) {
|
||||||
|
if (data->files[i]->is_binary || data->files[i]->is_unmerged)
|
||||||
|
continue;
|
||||||
changed += data->files[i]->added;
|
changed += data->files[i]->added;
|
||||||
changed += data->files[i]->deleted;
|
changed += data->files[i]->deleted;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user