aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorDragan Simic <dsimic@manjaro.org>2023-09-11 17:39:44 +0200
committerJunio C Hamano <gitster@pobox.com>2023-09-18 09:39:07 -0700
commitbd48adc31d0522e7877aa494ce7df91581e09587 (patch)
tree453a553971c3d0127271fa77ddfbe34d700b6612 /builtin
parentbda494f4043963b9ec9a1ecd4b19b7d1cd9a0518 (diff)
downloadgit-bd48adc31d0522e7877aa494ce7df91581e09587.tar.xz
diff --stat: add config option to limit filename width
Add new configuration option diff.statNameWidth=<width> that is equivalent to the command-line option --stat-name-width=<width>, but it is ignored by format-patch. This follows the logic established by the already existing configuration option diff.statGraphWidth=<width>. Limiting the widths of names and graphs in the --stat output makes sense for interactive work on wide terminals with many columns, hence the support for these configuration options. They don't affect format-patch because it already adheres to the traditional 80-column standard. Update the documentation and add more tests to cover new configuration option diff.statNameWidth=<width>. While there, perform a few minor code and whitespace cleanups here and there, as spotted. Signed-off-by: Dragan Simic <dsimic@manjaro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/diff.c1
-rw-r--r--builtin/log.c1
-rw-r--r--builtin/merge.c1
-rw-r--r--builtin/rebase.c1
4 files changed, 4 insertions, 0 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index 0b313549c7..c0f564273a 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -475,6 +475,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
/* Set up defaults that will apply to both no-index and regular diffs. */
rev.diffopt.stat_width = -1;
+ rev.diffopt.stat_name_width = -1;
rev.diffopt.stat_graph_width = -1;
rev.diffopt.flags.allow_external = 1;
rev.diffopt.flags.allow_textconv = 1;
diff --git a/builtin/log.c b/builtin/log.c
index b085417942..80e1be1645 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -178,6 +178,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
rev->verbose_header = 1;
rev->diffopt.flags.recursive = 1;
rev->diffopt.stat_width = -1; /* use full terminal width */
+ rev->diffopt.stat_name_width = -1; /* respect statNameWidth config */
rev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
rev->abbrev_commit = default_abbrev_commit;
rev->show_root_diff = default_show_root;
diff --git a/builtin/merge.c b/builtin/merge.c
index 545da0c8a1..fd21c0d4f4 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -467,6 +467,7 @@ static void finish(struct commit *head_commit,
struct diff_options opts;
repo_diff_setup(the_repository, &opts);
opts.stat_width = -1; /* use full terminal width */
+ opts.stat_name_width = -1; /* respect statNameWidth config */
opts.stat_graph_width = -1; /* respect statGraphWidth config */
opts.output_format |=
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 50cb85751f..ed15accec9 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1804,6 +1804,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
/* We want color (if set), but no pager */
repo_diff_setup(the_repository, &opts);
opts.stat_width = -1; /* use full terminal width */
+ opts.stat_name_width = -1; /* respect statNameWidth config */
opts.stat_graph_width = -1; /* respect statGraphWidth config */
opts.output_format |=
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;