combine-diff: treat --summary like --stat

Currently "--cc --summary" on a merge shows nothing. Since we show "--cc --stat" as a stat against the first parent, and because --summary is typically used in combination with --stat, it makes sense to treat them both the same way. Note that we have to tweak t4013's setup a bit to test this case, as the existing merges do not have any --summary results against their first parent. But since the merge at the tip of 'master' does add and remove files with respect to the second parent, we can just make a reversed doppelganger merge where the parents are swapped. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 24, 2019 at 07:35 UTC 04b19fcafd734245e61fd1c090cd7de8c2993eaa
3 files changed +14
combine-diff.c
+1
@@ -1326,6 +1326,7 @@ static const char *path_path(void *obj)
1326 */
1327 #define STAT_FORMAT_MASK (DIFF_FORMAT_NUMSTAT \
1328 | DIFF_FORMAT_SHORTSTAT \
1329 + | DIFF_FORMAT_SUMMARY \
1330 | DIFF_FORMAT_DIFFSTAT)
1331
1332 /* find set of paths that every parent touches */
t/t4013-diff-various.sh
+7
@@ -98,6 +98,12 @@ test_expect_success setup '
98 git commit -m "update mode" &&
99 git checkout -f master &&
100
101 + # Same merge as master, but with parents reversed. Hide it in a
102 + # pseudo-ref to avoid impacting tests with --all.
103 + commit=$(echo reverse |
104 + git commit-tree -p master^2 -p master^1 master^{tree}) &&
105 + git update-ref REVERSE $commit &&
106 +
107 git config diff.renames false &&
108
109 git show-branch
@@ -240,6 +246,7 @@ diff-tree --cc --stat --summary master
246 diff-tree -c --stat --summary side
247 diff-tree --cc --stat --summary side
248 diff-tree --cc --shortstat master
249 +diff-tree --cc --summary REVERSE
250 # improved by Timo's patch
251 diff-tree --cc --patch-with-stat master
252 # improved by Timo's patch
t/t4013/diff.diff-tree_--cc_--summary_REVERSE new
+6
@@ -0,0 +1,6 @@
1 +$ git diff-tree --cc --summary REVERSE
2 +2562325a7ee916efb2481da93073b82cec801cbc
3 + create mode 100644 file1
4 + delete mode 100644 file2
5 + delete mode 100644 file3
6 +$