1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-22 05:06:09 +02:00

Merge branch 'pg/diff-stat-unmerged-regression-fix'

The output from "git diff --stat" on an unmerged path lost the
terminating LF in Git 2.39, which has been corrected.

* pg/diff-stat-unmerged-regression-fix:
  diff: fix regression with --stat and unmerged file
This commit is contained in:
Junio C Hamano 2022-12-26 11:42:07 +09:00
commit e57caee004
2 changed files with 11 additions and 1 deletions

2
diff.c
View File

@ -2800,7 +2800,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
else if (file->is_unmerged) {
strbuf_addf(&out, " %s%s%*s | %*s",
prefix, name, padding, "",
number_width, "Unmerged");
number_width, "Unmerged\n");
emit_diff_symbol(options, DIFF_SYMBOL_STATS_LINE,
out.buf, out.len, 0);
strbuf_reset(&out);

View File

@ -86,4 +86,14 @@ test_expect_success 'diff-files -3' '
test_cmp diff-files-3.expect diff-files-3.actual
'
test_expect_success 'diff --stat' '
for path in $paths
do
echo " $path | Unmerged" || return 1
done >diff-stat.expect &&
echo " 0 files changed" >>diff-stat.expect &&
git diff --cached --stat >diff-stat.actual &&
test_cmp diff-stat.expect diff-stat.actual
'
test_done