From 4ca7a3fd26d0c6214f46f2413c5ba8ed346fea1a Mon Sep 17 00:00:00 2001 From: Dragan Simic Date: Sat, 23 Sep 2023 06:01:14 +0200 Subject: diff --stat: set the width defaults in a helper function Extract the commonly used initialization of the --stat-width=, --stat-name-width= and --stat-graph-with= parameters to their internal default values into a helper function, to avoid repeating the same initialization code in a few places. Add a couple of tests to additionally cover existing configuration options diff.statNameWidth= and diff.statGraphWidth= when used by git-merge to generate --stat outputs. This closes the gap that existed previously in the --stat tests, and reduces the chances for having any regressions introduced by this commit. While there, perform a small bunch of minor wording tweaks in the improved unit test, to improve its test-level consistency a bit. Signed-off-by: Dragan Simic Signed-off-by: Junio C Hamano --- builtin/diff.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'builtin/diff.c') diff --git a/builtin/diff.c b/builtin/diff.c index c0f564273a..55e7d21755 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -474,9 +474,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) repo_init_revisions(the_repository, &rev, 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; + init_diffstat_widths(&rev.diffopt); rev.diffopt.flags.allow_external = 1; rev.diffopt.flags.allow_textconv = 1; -- cgit v1.2.3