diff --stat: do not count "unmerged" entries

Even though we show a separate *UNMERGED* entry in the patch and diffstat output (or in the --raw format, for that matter) in addition to and separately from the diff against the specified stage (defaulting to #2) for unmerged paths, they should not be counted in the total number of files affected---that would lead to counting the same path twice. The separation done by the previous step makes this fix simple and straightforward. Among the filepairs in diff_queue, paths that weren't modified, and the extra "unmerged" entries do not count as total number of files. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 27, 2012 at 12:05 UTC 82dfc2c44ecda8a7afe417086c704b141a11cd58
2 files changed +5 -3
diff.c
+4 -2
@@ -1669,12 +1669,14 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
1669 struct diffstat_file *file = data->files[i];
1670 uintmax_t added = file->added;
1671 uintmax_t deleted = file->deleted;
1672 - if (!file->is_interesting && (added + deleted == 0)) {
1672 +
1673 + if (file->is_unmerged ||
1674 + (!file->is_interesting && (added + deleted == 0))) {
1675 total_files--;
1676 continue;
1677 }
1678
1677 - if (!file->is_binary && !file->is_unmerged) {
1679 + if (!file->is_binary) {
1680 adds += added;
1681 dels += deleted;
1682 }
t/t4049-diff-stat-count.sh
+1 -1
@@ -44,7 +44,7 @@ test_expect_success 'binary changes do not count in lines' '
44 test_i18ncmp expect actual
45 '
46
47 -test_expect_failure 'exclude unmerged entries from total file count' '
47 +test_expect_success 'exclude unmerged entries from total file count' '
48 git reset --hard &&
49 echo a >a &&
50 echo b >b &&