{"thread":{"id":"57777","subject":"[PATCH 0/2] diff- family --stat width","startedAt":"2022-04-21T20:17:40Z","lastAt":"2022-04-29T17:22:52Z","messageCount":5,"participants":["Thomas Koutcher via GitGitGadget","Junio C Hamano","Thomas Koutcher"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"454173","messageId":"pull.1256.git.git.1650572159.gitgitgadget@gmail.com","threadId":"57777","inReplyTo":null,"subject":"[PATCH 0/2] diff- family --stat width","fromName":"Thomas Koutcher via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-04-21T20:15:57Z","receivedAt":"2022-04-21T20:17:40Z","isPatch":true,"sender":{"key":"thomas.koutcher@online.fr","avatar":"https://avatars.githubusercontent.com/u/11375970?v=4"},"body":"diff- family commands do not use the full terminal width. This is visible in\nTig which uses git diff-files to show diffs for unstaged changes. When\ntrying to display diffs with long filenames, the diffstat does not improve\nwhen the Tig window size is increased.\n\nThis patch makes diff-files, diff-index and diff-tree --stat behave like\ndiff --stat and use the full terminal width. The handling of the config\noption diff.statGraphWidth is also added.\n\nThomas Koutcher (2):\n  diff- family --stat: use the full terminal width\n  diff- family --stat: honour config option to limit graph width\n\n builtin/diff-files.c | 2 ++\n builtin/diff-index.c | 2 ++\n builtin/diff-tree.c  | 2 ++\n diff.c               | 9 +++++----\n 4 files changed, 11 insertions(+), 4 deletions(-)\n\n\nbase-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1256%2Fkoutcher%2Fdiff-family-stat-width-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1256/koutcher/diff-family-stat-width-v1\nPull-Request: https://github.com/git/git/pull/1256\n-- \ngitgitgadget\n"},{"id":"454174","messageId":"c591e50ebb4593f9716c8e7682ecdecdb6fb5ae1.1650572159.git.gitgitgadget@gmail.com","threadId":"57777","inReplyTo":"pull.1256.git.git.1650572159.gitgitgadget@gmail.com","subject":"[PATCH 1/2] diff- family --stat: use the full terminal width","fromName":"Thomas Koutcher via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-04-21T20:15:58Z","receivedAt":"2022-04-21T20:18:16Z","isPatch":true,"sender":{"key":"thomas.koutcher@online.fr","avatar":"https://avatars.githubusercontent.com/u/11375970?v=4"},"body":"From: Thomas Koutcher <thomas.koutcher@online.fr>\n\nMake diff-files, diff-index and diff-tree --stat behave like diff --stat\nand use the full terminal width.\n\nSigned-off-by: Thomas Koutcher <thomas.koutcher@online.fr>\n---\n builtin/diff-files.c | 1 +\n builtin/diff-index.c | 1 +\n builtin/diff-tree.c  | 1 +\n 3 files changed, 3 insertions(+)\n\ndiff --git a/builtin/diff-files.c b/builtin/diff-files.c\nindex 70103c40952..2265cd256be 100644\n--- a/builtin/diff-files.c\n+++ b/builtin/diff-files.c\n@@ -29,6 +29,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \tgit_config(git_diff_basic_config, NULL); /* no \"diff\" UI options */\n \trepo_init_revisions(the_repository, &rev, prefix);\n \trev.abbrev = 0;\n+\trev.diffopt.stat_width = -1; /* use full terminal width */\n \n \t/*\n \t * Consider \"intent-to-add\" files as new by default, unless\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 5fd23ab5b6c..9cb9555fdeb 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -26,6 +26,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \tgit_config(git_diff_basic_config, NULL); /* no \"diff\" UI options */\n \trepo_init_revisions(the_repository, &rev, prefix);\n \trev.abbrev = 0;\n+\trev.diffopt.stat_width = -1; /* use full terminal width */\n \tprefix = precompose_argv_prefix(argc, argv, prefix);\n \n \t/*\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 0e0ac1f1670..4a2a2744fae 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -122,6 +122,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"index file corrupt\"));\n \topt->abbrev = 0;\n \topt->diff = 1;\n+\topt->diffopt.stat_width = -1; /* use full terminal width */\n \topt->disable_stdin = 1;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.tweak = diff_tree_tweak_rev;\n-- \ngitgitgadget\n\n"},{"id":"454175","messageId":"94acd9e0a47fcbee91f7759d1556d39fec26dd2d.1650572159.git.gitgitgadget@gmail.com","threadId":"57777","inReplyTo":"pull.1256.git.git.1650572159.gitgitgadget@gmail.com","subject":"[PATCH 2/2] diff- family --stat: honour config option to limit graph width","fromName":"Thomas Koutcher via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-04-21T20:15:59Z","receivedAt":"2022-04-21T20:18:48Z","isPatch":true,"sender":{"key":"thomas.koutcher@online.fr","avatar":"https://avatars.githubusercontent.com/u/11375970?v=4"},"body":"From: Thomas Koutcher <thomas.koutcher@online.fr>\n\nMake diff-files, diff-index and diff-tree --stat honour config option\ndiff.statGraphWidth as, according to git-config(1), it applies to all\ncommands generating --stat output except format-patch.\n\nMove the parsing of diff.statgraphwidth from git_diff_ui_config() to\ngit_diff_basic_config() to make it accessible to all commands.\n\nSigned-off-by: Thomas Koutcher <thomas.koutcher@online.fr>\n---\n builtin/diff-files.c | 1 +\n builtin/diff-index.c | 1 +\n builtin/diff-tree.c  | 1 +\n diff.c               | 9 +++++----\n 4 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/diff-files.c b/builtin/diff-files.c\nindex 2265cd256be..e9b96278434 100644\n--- a/builtin/diff-files.c\n+++ b/builtin/diff-files.c\n@@ -30,6 +30,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \trepo_init_revisions(the_repository, &rev, prefix);\n \trev.abbrev = 0;\n \trev.diffopt.stat_width = -1; /* use full terminal width */\n+\trev.diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \n \t/*\n \t * Consider \"intent-to-add\" files as new by default, unless\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 9cb9555fdeb..10f78180264 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -27,6 +27,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \trepo_init_revisions(the_repository, &rev, prefix);\n \trev.abbrev = 0;\n \trev.diffopt.stat_width = -1; /* use full terminal width */\n+\trev.diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \tprefix = precompose_argv_prefix(argc, argv, prefix);\n \n \t/*\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 4a2a2744fae..0b783dcbc44 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -123,6 +123,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \topt->abbrev = 0;\n \topt->diff = 1;\n \topt->diffopt.stat_width = -1; /* use full terminal width */\n+\topt->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \topt->disable_stdin = 1;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.tweak = diff_tree_tweak_rev;\ndiff --git a/diff.c b/diff.c\nindex ef7159968b6..0923a25d5bb 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -394,10 +394,6 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)\n \t\tdiff_relative = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.statgraphwidth\")) {\n-\t\tdiff_stat_graph_width = git_config_int(var, value);\n-\t\treturn 0;\n-\t}\n \tif (!strcmp(var, \"diff.external\"))\n \t\treturn git_config_string(&external_diff_cmd_cfg, var, value);\n \tif (!strcmp(var, \"diff.wordregex\"))\n@@ -477,6 +473,11 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"diff.statgraphwidth\")) {\n+\t\tdiff_stat_graph_width = git_config_int(var, value);\n+\t\treturn 0;\n+\t}\n+\n \tif (git_diff_heuristic_config(var, value, cb) < 0)\n \t\treturn -1;\n \n-- \ngitgitgadget\n"},{"id":"454185","messageId":"xmqqczhaf7f7.fsf@gitster.g","threadId":"57777","inReplyTo":"pull.1256.git.git.1650572159.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/2] diff- family --stat width","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-04-21T21:33:32Z","receivedAt":"2022-04-21T21:33:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Thomas Koutcher via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> diff- family commands do not use the full terminal width. This is visible in\n> Tig which uses git diff-files to show diffs for unstaged changes. When\n> trying to display diffs with long filenames, the diffstat does not improve\n> when the Tig window size is increased.\n>\n> This patch makes diff-files, diff-index and diff-tree --stat behave like\n> diff --stat and use the full terminal width. The handling of the config\n> option diff.statGraphWidth is also added.\n\nI do not think it is a good move to change the output from these\nplumbing commands, whose purpose of existence is to give more\npredictable outcome, to be affected by dynamic elements like the\nwidth of the terminal the user happens to be using.\n\nA program or script that spawns the plumbing commands should be able\nto pass --stat=<width>, --stat-graph-width=<width> etc. to control\nits behaviour without affecting (and possibly breaking) what other\nprograms have been depending on for the last 15+ years.\n\nThanks.\n"},{"id":"454626","messageId":"4fa61676-976c-9337-4dcc-742e6fdeac99@online.fr","threadId":"57777","inReplyTo":"xmqqczhaf7f7.fsf@gitster.g","subject":"Re: [PATCH 0/2] diff- family --stat width","fromName":"Thomas Koutcher","fromEmail":"thomas.koutcher@online.fr","sentAt":"2022-04-29T17:22:40Z","receivedAt":"2022-04-29T17:22:52Z","isPatch":true,"sender":{"key":"thomas.koutcher@online.fr","avatar":"https://avatars.githubusercontent.com/u/11375970?v=4"},"body":"Junio C Hamano writes:\n>\n> I do not think it is a good move to change the output from these\n> plumbing commands, whose purpose of existence is to give more\n> predictable outcome, to be affected by dynamic elements like the\n> width of the terminal the user happens to be using.\n>\nThanks for your feedback Junio, I agree this is certainly the safest \nchoice to leave them as they are. Man pages git-diff-files(1), \ngit-diff-index(1), git-diff-tree(1) and git-config(1) \n[diff.statGraphWidth section] will need an update to reflect the current \nbehaviour.\n\n\n\n"}]}