Skip to content

Commit 209d9cb

Browse files
jpgraysongitster
authored andcommitted
diff: fix regression with --stat and unmerged file
A regression was introduced in 12fc4ad (diff.c: use utf8_strwidth() to count display width, 2022-09-14) that causes missing newlines after "Unmerged" entries in `git diff --cached --stat` output. This problem affects v2.39.0-rc0 through v2.39.0. Add the missing newline along with a new test to cover this behavior. Signed-off-by: Peter Grayson <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 12fc4ad commit 209d9cb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
27842784
else if (file->is_unmerged) {
27852785
strbuf_addf(&out, " %s%s%*s | %*s",
27862786
prefix, name, padding, "",
2787-
number_width, "Unmerged");
2787+
number_width, "Unmerged\n");
27882788
emit_diff_symbol(options, DIFF_SYMBOL_STATS_LINE,
27892789
out.buf, out.len, 0);
27902790
strbuf_reset(&out);

t/t4046-diff-unmerged.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@ test_expect_success 'diff-files -3' '
8686
test_cmp diff-files-3.expect diff-files-3.actual
8787
'
8888

89+
test_expect_success 'diff --stat' '
90+
for path in $paths
91+
do
92+
echo " $path | Unmerged" || return 1
93+
done >diff-stat.expect &&
94+
echo " 0 files changed" >>diff-stat.expect &&
95+
git diff --cached --stat >diff-stat.actual &&
96+
test_cmp diff-stat.expect diff-stat.actual
97+
'
98+
8999
test_done

0 commit comments

Comments
 (0)