Skip to content

Commit 82dfc2c

Browse files
committed
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 <[email protected]>
1 parent a20d3c0 commit 82dfc2c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

diff.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,12 +1669,14 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
16691669
struct diffstat_file *file = data->files[i];
16701670
uintmax_t added = file->added;
16711671
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))) {
16731675
total_files--;
16741676
continue;
16751677
}
16761678

1677-
if (!file->is_binary && !file->is_unmerged) {
1679+
if (!file->is_binary) {
16781680
adds += added;
16791681
dels += deleted;
16801682
}

t/t4049-diff-stat-count.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test_expect_success 'binary changes do not count in lines' '
4444
test_i18ncmp expect actual
4545
'
4646

47-
test_expect_failure 'exclude unmerged entries from total file count' '
47+
test_expect_success 'exclude unmerged entries from total file count' '
4848
git reset --hard &&
4949
echo a >a &&
5050
echo b >b &&

0 commit comments

Comments
 (0)