diff: add --compact-summary

Certain information is currently shown with --summary, but when used
in combination with --stat it's a bit hard to read since info of the
same file is in two places (--stat and --summary).

On top of that, commits that add or remove files double the number of
display lines, which could be a lot if you add or remove a lot of
files.

--compact-summary embeds most of --summary back in --stat in the
little space between the file name part and the graph line, e.g. with
commit 0433d533f1:

   Documentation/merge-config.txt         |  4 +
   builtin/merge.c                        |  2 +
   ...-pull-verify-signatures.sh (new +x) | 81 ++++++++++++++
   t/t7612-merge-verify-signatures.sh     | 45 ++++++++
   4 files changed, 132 insertions(+)

It helps both condensing information and saving some text
space. What's new in diffstat is:

- A new 0644 file is shown as (new)
- A new 0755 file is shown as (new +x)
- A new symlink is shown as (new +l)
- A deleted file is shown as (gone)
- A mode change adding executable bit is shown as (mode +x)
- A mode change removing it is shown as (mode -x)

Note that --compact-summary does not contain all the information
--summary provides. Rewrite percentage is not shown but it could be
added later, like R50% or C20%.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2018-02-24 21:09:59 +07:00
committed by Junio C Hamano
parent c905cbc49c
commit ddf88fa616
8 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
$ git diff-tree --pretty --root --stat --compact-summary initial
commit 444ac553ac7612cc88969031b02b3767fb8a353a
Author: A U Thor <author@example.com>
Date: Mon Jun 26 00:00:00 2006 +0000
Initial
dir/sub (new) | 2 ++
file0 (new) | 3 +++
file2 (new) | 3 +++
3 files changed, 8 insertions(+)
$

View File

@@ -0,0 +1,12 @@
$ git diff-tree --pretty -R --root --stat --compact-summary initial
commit 444ac553ac7612cc88969031b02b3767fb8a353a
Author: A U Thor <author@example.com>
Date: Mon Jun 26 00:00:00 2006 +0000
Initial
dir/sub (gone) | 2 --
file0 (gone) | 3 ---
file2 (gone) | 3 ---
3 files changed, 8 deletions(-)
$

View File

@@ -0,0 +1,4 @@
$ git diff-tree --stat --compact-summary initial mode
file0 (mode +x) | 0
1 file changed, 0 insertions(+), 0 deletions(-)
$

View File

@@ -0,0 +1,4 @@
$ git diff-tree -R --stat --compact-summary initial mode
file0 (mode -x) | 0
1 file changed, 0 insertions(+), 0 deletions(-)
$