Skip to contentSkip to conversation

diff: give --compact-summary a short synonym --sstat

PATCH In review Junio C Hamano 2 participants 3 messages Jul 5 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 diff: give --compact-summary a short synonym --sstat

These days I find myself using '--compact-summary' very often, which I consider is a strict superset of '--stat' (or '--stat --summary'). Promote its use by giving it a short synonym '--sstat' (stands for summary+stat).

---
* The format-patch output still uses --stat --summary, which looks like so:

 Documentation/diff-options.adoc                      |  1 +
 diff.c                                               |  3 +++
 t/t4000-diff-format.sh                               |  2 +-
 t/t4013-diff-various.sh                              |  2 ++
 .../diff.diff-tree_--pretty_--root_--sstat_initial   | 12 ++++++++++++
 t/t4013/diff.diff-tree_-R_--sstat_initial_mode       |  4 ++++
 6 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--sstat_initial
 create mode 100644 t/t4013/diff.diff-tree_-R_--sstat_initial_mode

but if we change it to use --compact-summary (aka --sstat), it would instead look like this:

 Documentation/diff-options.adoc                              |  1 +
 diff.c                                                       |  3 +++
 t/t4000-diff-format.sh                                       |  2 +-
 t/t4013-diff-various.sh                                      |  2 ++
 t/t4013/diff.diff-tree_--pretty_--root_--sstat_initial (new) | 12 ++++++++++++
 t/t4013/diff.diff-tree_-R_--sstat_initial_mode (new)         |  4 ++++
 6 files changed, 23 insertions(+), 1 deletion(-)
Documentation/diff-options.adoc +1 -0
index c8242e2462..b2b755fd3d 100644
@@ -221,6 +221,7 @@ These parameters can also be set individually with `--stat-width=<width>`,
 `--stat-name-width=<name-width>` and `--stat-count=<count>`.
 
 `--compact-summary`::
+`--sstat`::
 	Output a condensed summary of extended header information such
 	as file creations or deletions ("new" or "gone", optionally `+l`
 	if it's a symlink) and mode changes (`+x` or `-x` for adding
diff.c +3 -0
index 2a9d0d8687..284d391c47 100644
@@ -6112,6 +6112,9 @@ struct option *add_diff_options(const struct option *opts,
 		OPT_CALLBACK_F(0, "compact-summary", options, NULL,
 			       N_("generate compact summary in diffstat"),
 			       PARSE_OPT_NOARG, diff_opt_compact_summary),
+		OPT_CALLBACK_F(0, "sstat", options, NULL,
+			       N_("generate compact summary in diffstat"),
+			       PARSE_OPT_NOARG|PARSE_OPT_HIDDEN, diff_opt_compact_summary),
 		OPT_CALLBACK_F(0, "binary", options, NULL,
 			       N_("output a binary diff that can be applied"),
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_binary),
t/t4000-diff-format.sh +1 -1
index 32b14e3a71..cc5c62fdbc 100755
@@ -101,7 +101,7 @@ date >path2/path3
 
 for format in stat raw numstat shortstat summary \
 	dirstat cumulative dirstat-by-file \
-	patch-with-raw patch-with-stat compact-summary
+	patch-with-raw patch-with-stat compact-summary sstat
 do
 	test_expect_success "--no-patch in 'git diff-files --no-patch --$format' is a no-op" '
 		git diff-files --no-patch "--$format" >actual &&
t/t4013-diff-various.sh +2 -0
index d35695f5b0..a42dca8a0b 100755
@@ -474,6 +474,8 @@ diff-tree --pretty --notes note
 diff-tree --format=%N note
 diff-tree --stat --compact-summary initial mode
 diff-tree -R --stat --compact-summary initial mode
+diff-tree --pretty --root --sstat initial
+diff-tree -R --sstat initial mode
 EOF
 
 test_expect_success !WITH_BREAKING_CHANGES 'whatchanged needs --i-still-use-this' '
t/t4013/diff.diff-tree_--pretty_--root_--sstat_initial new file +12 -0
new file mode 100644
index 0000000000..b5c9d7693a
@@ -0,0 +1,12 @@
+$ git diff-tree --pretty --root --sstat initial
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <[email protected]>
+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(+)
+$
t/t4013/diff.diff-tree_-R_--sstat_initial_mode new file +4 -0
new file mode 100644
index 0000000000..51b1aa7d71
@@ -0,0 +1,4 @@
+$ git diff-tree -R --sstat initial mode
+ file0 (mode -x) | 0
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+$
Signature · 1 line
2.55.0-236-g7bd4d671b1
#1 lore raw

Hi Junio

Quoted 4 lines · Junio C Hamano

These days I find myself using '--compact-summary' very often, which I consider is a strict superset of '--stat' (or '--stat --summary'). Promote its use by giving it a short synonym '--sstat' (stands for summary+stat).

Thanks for the example below, it was useful to see the difference between "--compact-summary" and "--stat --summary". I'm afraid I don't think adding a slightly cryptic shortened alias is a good idea. It is already possible to tab-complete after typing "--comp" so I don't think this is saving the user much typing and it clutters the UI with an obscure option name that could plausibly be an alias for "--shortstat".

Thanks

Phillip

Quoted 106 lines

---
* The format-patch output still uses --stat --summary, which looks like so:

  Documentation/diff-options.adoc                      |  1 +
  diff.c                                               |  3 +++
  t/t4000-diff-format.sh                               |  2 +-
  t/t4013-diff-various.sh                              |  2 ++
  .../diff.diff-tree_--pretty_--root_--sstat_initial   | 12 ++++++++++++
  t/t4013/diff.diff-tree_-R_--sstat_initial_mode       |  4 ++++
  6 files changed, 23 insertions(+), 1 deletion(-)

create mode 100644 t/t4013/diff.diff-tree_--pretty_--root_--sstat_initial create mode 100644 t/t4013/diff.diff-tree_-R_--sstat_initial_mode

but if we change it to use --compact-summary (aka --sstat), it would instead look like this:

  Documentation/diff-options.adoc                              |  1 +
  diff.c                                                       |  3 +++
  t/t4000-diff-format.sh                                       |  2 +-
  t/t4013-diff-various.sh                                      |  2 ++
  t/t4013/diff.diff-tree_--pretty_--root_--sstat_initial (new) | 12 ++++++++++++
  t/t4013/diff.diff-tree_-R_--sstat_initial_mode (new)         |  4 ++++
  6 files changed, 23 insertions(+), 1 deletion(-)
Documentation/diff-options.adoc +1 -0
index c8242e2462..b2b755fd3d 100644
@@ -221,6 +221,7 @@ These parameters can also be set individually with `--stat-width=<width>`,
  `--stat-name-width=<name-width>` and `--stat-count=<count>`.
 
  `--compact-summary`::
+`--sstat`::
  	Output a condensed summary of extended header information such
  	as file creations or deletions ("new" or "gone", optionally `+l`
  	if it's a symlink) and mode changes (`+x` or `-x` for adding
diff.c +3 -0
index 2a9d0d8687..284d391c47 100644
@@ -6112,6 +6112,9 @@ struct option *add_diff_options(const struct option *opts,
  		OPT_CALLBACK_F(0, "compact-summary", options, NULL,
  			       N_("generate compact summary in diffstat"),
  			       PARSE_OPT_NOARG, diff_opt_compact_summary),
+		OPT_CALLBACK_F(0, "sstat", options, NULL,
+			       N_("generate compact summary in diffstat"),
+			       PARSE_OPT_NOARG|PARSE_OPT_HIDDEN, diff_opt_compact_summary),
  		OPT_CALLBACK_F(0, "binary", options, NULL,
  			       N_("output a binary diff that can be applied"),
  			       PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_binary),
t/t4000-diff-format.sh +1 -1
index 32b14e3a71..cc5c62fdbc 100755
@@ -101,7 +101,7 @@ date >path2/path3
 
  for format in stat raw numstat shortstat summary \
  	dirstat cumulative dirstat-by-file \
-	patch-with-raw patch-with-stat compact-summary
+	patch-with-raw patch-with-stat compact-summary sstat
  do
  	test_expect_success "--no-patch in 'git diff-files --no-patch --$format' is a no-op" '
  		git diff-files --no-patch "--$format" >actual &&
t/t4013-diff-various.sh +2 -0
index d35695f5b0..a42dca8a0b 100755
@@ -474,6 +474,8 @@ diff-tree --pretty --notes note
  diff-tree --format=%N note
  diff-tree --stat --compact-summary initial mode
  diff-tree -R --stat --compact-summary initial mode
+diff-tree --pretty --root --sstat initial
+diff-tree -R --sstat initial mode
  EOF
 
  test_expect_success !WITH_BREAKING_CHANGES 'whatchanged needs --i-still-use-this' '
t/t4013/diff.diff-tree_--pretty_--root_--sstat_initial new file +12 -0
new file mode 100644
index 0000000000..b5c9d7693a
@@ -0,0 +1,12 @@
+$ git diff-tree --pretty --root --sstat initial
+commit 444ac553ac7612cc88969031b02b3767fb8a353a
+Author: A U Thor <[email protected]>
+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(+)
+$
t/t4013/diff.diff-tree_-R_--sstat_initial_mode new file +4 -0
new file mode 100644
index 0000000000..51b1aa7d71
@@ -0,0 +1,4 @@
+$ git diff-tree -R --sstat initial mode
+ file0 (mode -x) | 0
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+$
#2 lore raw
Quoted 2 lines · Phillip Wood

... this is saving the user much typing and it clutters the UI with an obscure option name that could plausibly be an alias for "--shortstat".

Fair enough. Thanks for a doze of sanity.