Skip to content

Commit a4b4f9b

Browse files
committed
Merge branch 'mk/diff-shortstat-dirstat-fix' into maint
"git diff --shortstat --dirstat=changes" showed a dirstat based on lines that was never asked by the end user in addition to the dirstat that the user asked for. * mk/diff-shortstat-dirstat-fix: diff --shortstat --dirstat: remove duplicate output
2 parents 30a52c1 + ab27389 commit a4b4f9b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4541,7 +4541,7 @@ void diff_flush(struct diff_options *options)
45414541
show_stats(&diffstat, options);
45424542
if (output_format & DIFF_FORMAT_SHORTSTAT)
45434543
show_shortstats(&diffstat, options);
4544-
if (output_format & DIFF_FORMAT_DIRSTAT)
4544+
if (output_format & DIFF_FORMAT_DIRSTAT && dirstat_by_line)
45454545
show_dirstat_by_line(&diffstat, options);
45464546
free_diffstat_info(&diffstat);
45474547
separator++;

t/t4047-diff-dirstat.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,4 +973,18 @@ test_expect_success 'diff.dirstat=future_param,0,lines should warn, but still wo
973973
test_i18ngrep -q "diff\\.dirstat" actual_error
974974
'
975975

976+
test_expect_success '--shortstat --dirstat should output only one dirstat' '
977+
git diff --shortstat --dirstat=changes HEAD^..HEAD >out &&
978+
grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_changes &&
979+
test_line_count = 1 actual_diff_shortstat_dirstat_changes &&
980+
981+
git diff --shortstat --dirstat=lines HEAD^..HEAD >out &&
982+
grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_lines &&
983+
test_line_count = 1 actual_diff_shortstat_dirstat_lines &&
984+
985+
git diff --shortstat --dirstat=files HEAD^..HEAD >out &&
986+
grep " dst/copy/changed/$" out >actual_diff_shortstat_dirstat_files &&
987+
test_line_count = 1 actual_diff_shortstat_dirstat_files
988+
'
989+
976990
test_done

0 commit comments

Comments
 (0)