combine-diff: treat --dirstat like --stat
authorJeff King <peff@peff.net>
Thu, 24 Jan 2019 12:36:47 +0000 (07:36 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 Jan 2019 20:18:53 +0000 (12:18 -0800)
Currently "--cc --dirstat" will show nothing for a merge. Like
--shortstat and --summary in the previous two patches, it probably makes
sense to treat it like we do --stat, and show a stat against the
first-parent.

This case is less obviously correct than for --shortstat and --summary,
as those are basically variants of --stat themselves. It's possible we
could develop a multi-parent combined dirstat format, in which case we
might regret defining this first-parent behavior. But the same could be
said for --stat, and in the 12+ years of it showing first-parent stats,
nobody has complained.

So showing the first-parent dirstat is at least _useful_, and if we
later develop a clever multi-parent stat format, we'd probably have to
deal with --stat anyway.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
combine-diff.c
t/t4013-diff-various.sh
t/t4013/diff.diff_--dirstat_--cc_master~1_master [new file with mode: 0644]
index ea79830f619c57f3e780589b0f58ee428a4a00ee..dc9d9866186d94db808e168b0f648b8e6acf76cf 100644 (file)
@@ -1327,6 +1327,7 @@ static const char *path_path(void *obj)
 #define STAT_FORMAT_MASK (DIFF_FORMAT_NUMSTAT \
                          | DIFF_FORMAT_SHORTSTAT \
                          | DIFF_FORMAT_SUMMARY \
+                         | DIFF_FORMAT_DIRSTAT \
                          | DIFF_FORMAT_DIFFSTAT)
 
 /* find set of paths that every parent touches */
index e28953975b46484327c8c9e0e32993b83a164a6a..9f8f0e84ad4f35b72da73ef8ddfee0a3cddfbe1a 100755 (executable)
@@ -358,6 +358,7 @@ diff --line-prefix=abc master master^ side
 diff --dirstat master~1 master~2
 diff --dirstat initial rearrange
 diff --dirstat-by-file initial rearrange
+diff --dirstat --cc master~1 master
 # No-index --abbrev and --no-abbrev
 diff --raw initial
 :noellipses diff --raw initial
diff --git a/t/t4013/diff.diff_--dirstat_--cc_master~1_master b/t/t4013/diff.diff_--dirstat_--cc_master~1_master
new file mode 100644 (file)
index 0000000..fba4e34
--- /dev/null
@@ -0,0 +1,3 @@
+$ git diff --dirstat --cc master~1 master
+  40.0% dir/
+$