summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-09-29 09:04:14 -0700
committerJunio C Hamano <gitster@pobox.com>2023-09-29 09:04:15 -0700
commit0b493d2986ab2664a35a87db04154c795f74d3fd (patch)
tree6cedffded7f4367108e37bdc2c78c57f2668e66a /diff.c
parent2affeb3cb57ec7124dc37743ace17a46921f8ce0 (diff)
parentbd48adc31d0522e7877aa494ce7df91581e09587 (diff)
Merge branch 'ds/stat-name-width-configuration'
"git diff" learned diff.statNameWidth configuration variable, to give the default width for the name part in the "--stat" output. * ds/stat-name-width-configuration: diff --stat: add config option to limit filename width
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index bccb018da4..353e3b2cc9 100644
--- a/diff.c
+++ b/diff.c
@@ -65,6 +65,7 @@ int diff_auto_refresh_index = 1;
static int diff_mnemonic_prefix;
static int diff_no_prefix;
static int diff_relative;
+static int diff_stat_name_width;
static int diff_stat_graph_width;
static int diff_dirstat_permille_default = 30;
static struct diff_options default_diff_options;
@@ -410,6 +411,10 @@ int git_diff_ui_config(const char *var, const char *value,
diff_relative = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "diff.statnamewidth")) {
+ diff_stat_name_width = git_config_int(var, value, ctx->kvi);
+ return 0;
+ }
if (!strcmp(var, "diff.statgraphwidth")) {
diff_stat_graph_width = git_config_int(var, value, ctx->kvi);
return 0;
@@ -2704,12 +2709,14 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
number_width = decimal_width(max_change) > number_width ?
decimal_width(max_change) : number_width;
+ if (options->stat_name_width == -1)
+ options->stat_name_width = diff_stat_name_width;
if (options->stat_graph_width == -1)
options->stat_graph_width = diff_stat_graph_width;
/*
- * Guarantee 3/8*16==6 for the graph part
- * and 5/8*16==10 for the filename part
+ * Guarantee 3/8*16 == 6 for the graph part
+ * and 5/8*16 == 10 for the filename part
*/
if (width < 16 + 6 + number_width)
width = 16 + 6 + number_width;