git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] diff- family --stat width
@ 2022-04-21 20:15 Thomas Koutcher via GitGitGadget
  2022-04-21 20:15 ` [PATCH 1/2] diff- family --stat: use the full terminal width Thomas Koutcher via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thomas Koutcher via GitGitGadget @ 2022-04-21 20:15 UTC (permalink / raw)
  To: git; +Cc: Thomas Koutcher

diff- family commands do not use the full terminal width. This is visible in
Tig which uses git diff-files to show diffs for unstaged changes. When
trying to display diffs with long filenames, the diffstat does not improve
when the Tig window size is increased.

This patch makes diff-files, diff-index and diff-tree --stat behave like
diff --stat and use the full terminal width. The handling of the config
option diff.statGraphWidth is also added.

Thomas Koutcher (2):
  diff- family --stat: use the full terminal width
  diff- family --stat: honour config option to limit graph width

 builtin/diff-files.c | 2 ++
 builtin/diff-index.c | 2 ++
 builtin/diff-tree.c  | 2 ++
 diff.c               | 9 +++++----
 4 files changed, 11 insertions(+), 4 deletions(-)


base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1256%2Fkoutcher%2Fdiff-family-stat-width-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1256/koutcher/diff-family-stat-width-v1
Pull-Request: https://github.com/git/git/pull/1256
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] diff- family --stat: use the full terminal width
  2022-04-21 20:15 [PATCH 0/2] diff- family --stat width Thomas Koutcher via GitGitGadget
@ 2022-04-21 20:15 ` Thomas Koutcher via GitGitGadget
  2022-04-21 20:15 ` [PATCH 2/2] diff- family --stat: honour config option to limit graph width Thomas Koutcher via GitGitGadget
  2022-04-21 21:33 ` [PATCH 0/2] diff- family --stat width Junio C Hamano
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Koutcher via GitGitGadget @ 2022-04-21 20:15 UTC (permalink / raw)
  To: git; +Cc: Thomas Koutcher, Thomas Koutcher

From: Thomas Koutcher <thomas.koutcher@online.fr>

Make diff-files, diff-index and diff-tree --stat behave like diff --stat
and use the full terminal width.

Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
---
 builtin/diff-files.c | 1 +
 builtin/diff-index.c | 1 +
 builtin/diff-tree.c  | 1 +
 3 files changed, 3 insertions(+)

diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 70103c40952..2265cd256be 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -29,6 +29,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	repo_init_revisions(the_repository, &rev, prefix);
 	rev.abbrev = 0;
+	rev.diffopt.stat_width = -1; /* use full terminal width */
 
 	/*
 	 * Consider "intent-to-add" files as new by default, unless
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 5fd23ab5b6c..9cb9555fdeb 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -26,6 +26,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 	repo_init_revisions(the_repository, &rev, prefix);
 	rev.abbrev = 0;
+	rev.diffopt.stat_width = -1; /* use full terminal width */
 	prefix = precompose_argv_prefix(argc, argv, prefix);
 
 	/*
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 0e0ac1f1670..4a2a2744fae 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -122,6 +122,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 		die(_("index file corrupt"));
 	opt->abbrev = 0;
 	opt->diff = 1;
+	opt->diffopt.stat_width = -1; /* use full terminal width */
 	opt->disable_stdin = 1;
 	memset(&s_r_opt, 0, sizeof(s_r_opt));
 	s_r_opt.tweak = diff_tree_tweak_rev;
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] diff- family --stat: honour config option to limit graph width
  2022-04-21 20:15 [PATCH 0/2] diff- family --stat width Thomas Koutcher via GitGitGadget
  2022-04-21 20:15 ` [PATCH 1/2] diff- family --stat: use the full terminal width Thomas Koutcher via GitGitGadget
@ 2022-04-21 20:15 ` Thomas Koutcher via GitGitGadget
  2022-04-21 21:33 ` [PATCH 0/2] diff- family --stat width Junio C Hamano
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Koutcher via GitGitGadget @ 2022-04-21 20:15 UTC (permalink / raw)
  To: git; +Cc: Thomas Koutcher, Thomas Koutcher

From: Thomas Koutcher <thomas.koutcher@online.fr>

Make diff-files, diff-index and diff-tree --stat honour config option
diff.statGraphWidth as, according to git-config(1), it applies to all
commands generating --stat output except format-patch.

Move the parsing of diff.statgraphwidth from git_diff_ui_config() to
git_diff_basic_config() to make it accessible to all commands.

Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
---
 builtin/diff-files.c | 1 +
 builtin/diff-index.c | 1 +
 builtin/diff-tree.c  | 1 +
 diff.c               | 9 +++++----
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 2265cd256be..e9b96278434 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -30,6 +30,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	repo_init_revisions(the_repository, &rev, prefix);
 	rev.abbrev = 0;
 	rev.diffopt.stat_width = -1; /* use full terminal width */
+	rev.diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
 
 	/*
 	 * Consider "intent-to-add" files as new by default, unless
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 9cb9555fdeb..10f78180264 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -27,6 +27,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 	repo_init_revisions(the_repository, &rev, prefix);
 	rev.abbrev = 0;
 	rev.diffopt.stat_width = -1; /* use full terminal width */
+	rev.diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
 	prefix = precompose_argv_prefix(argc, argv, prefix);
 
 	/*
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 4a2a2744fae..0b783dcbc44 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -123,6 +123,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	opt->abbrev = 0;
 	opt->diff = 1;
 	opt->diffopt.stat_width = -1; /* use full terminal width */
+	opt->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
 	opt->disable_stdin = 1;
 	memset(&s_r_opt, 0, sizeof(s_r_opt));
 	s_r_opt.tweak = diff_tree_tweak_rev;
diff --git a/diff.c b/diff.c
index ef7159968b6..0923a25d5bb 100644
--- a/diff.c
+++ b/diff.c
@@ -394,10 +394,6 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
 		diff_relative = git_config_bool(var, value);
 		return 0;
 	}
-	if (!strcmp(var, "diff.statgraphwidth")) {
-		diff_stat_graph_width = git_config_int(var, value);
-		return 0;
-	}
 	if (!strcmp(var, "diff.external"))
 		return git_config_string(&external_diff_cmd_cfg, var, value);
 	if (!strcmp(var, "diff.wordregex"))
@@ -477,6 +473,11 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
 		return 0;
 	}
 
+	if (!strcmp(var, "diff.statgraphwidth")) {
+		diff_stat_graph_width = git_config_int(var, value);
+		return 0;
+	}
+
 	if (git_diff_heuristic_config(var, value, cb) < 0)
 		return -1;
 
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] diff- family --stat width
  2022-04-21 20:15 [PATCH 0/2] diff- family --stat width Thomas Koutcher via GitGitGadget
  2022-04-21 20:15 ` [PATCH 1/2] diff- family --stat: use the full terminal width Thomas Koutcher via GitGitGadget
  2022-04-21 20:15 ` [PATCH 2/2] diff- family --stat: honour config option to limit graph width Thomas Koutcher via GitGitGadget
@ 2022-04-21 21:33 ` Junio C Hamano
  2022-04-29 17:22   ` Thomas Koutcher
  2 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2022-04-21 21:33 UTC (permalink / raw)
  To: Thomas Koutcher via GitGitGadget; +Cc: git, Thomas Koutcher

"Thomas Koutcher via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff- family commands do not use the full terminal width. This is visible in
> Tig which uses git diff-files to show diffs for unstaged changes. When
> trying to display diffs with long filenames, the diffstat does not improve
> when the Tig window size is increased.
>
> This patch makes diff-files, diff-index and diff-tree --stat behave like
> diff --stat and use the full terminal width. The handling of the config
> option diff.statGraphWidth is also added.

I do not think it is a good move to change the output from these
plumbing commands, whose purpose of existence is to give more
predictable outcome, to be affected by dynamic elements like the
width of the terminal the user happens to be using.

A program or script that spawns the plumbing commands should be able
to pass --stat=<width>, --stat-graph-width=<width> etc. to control
its behaviour without affecting (and possibly breaking) what other
programs have been depending on for the last 15+ years.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] diff- family --stat width
  2022-04-21 21:33 ` [PATCH 0/2] diff- family --stat width Junio C Hamano
@ 2022-04-29 17:22   ` Thomas Koutcher
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Koutcher @ 2022-04-29 17:22 UTC (permalink / raw)
  To: git

Junio C Hamano writes:
>
> I do not think it is a good move to change the output from these
> plumbing commands, whose purpose of existence is to give more
> predictable outcome, to be affected by dynamic elements like the
> width of the terminal the user happens to be using.
>
Thanks for your feedback Junio, I agree this is certainly the safest 
choice to leave them as they are. Man pages git-diff-files(1), 
git-diff-index(1), git-diff-tree(1) and git-config(1) 
[diff.statGraphWidth section] will need an update to reflect the current 
behaviour.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-29 17:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 20:15 [PATCH 0/2] diff- family --stat width Thomas Koutcher via GitGitGadget
2022-04-21 20:15 ` [PATCH 1/2] diff- family --stat: use the full terminal width Thomas Koutcher via GitGitGadget
2022-04-21 20:15 ` [PATCH 2/2] diff- family --stat: honour config option to limit graph width Thomas Koutcher via GitGitGadget
2022-04-21 21:33 ` [PATCH 0/2] diff- family --stat width Junio C Hamano
2022-04-29 17:22   ` Thomas Koutcher

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).