summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 969fe57)
raw | patch | inline | side by side (parent: 969fe57)
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | |
Thu, 1 Mar 2012 12:26:46 +0000 (13:26 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 1 Mar 2012 17:15:58 +0000 (09:15 -0800) |
Config option diff.statGraphWidth=<width> is equivalent to
--stat-graph-width=<width>, except that the config option is ignored
by format-patch.
For the graph-width limiting to be usable, it should happen
'automatically' once configured, hence the config option.
Nevertheless, graph width limiting only makes sense when used on a
wide terminal, so it should not influence the output of format-patch,
which adheres to the 80-column standard.
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
--stat-graph-width=<width>, except that the config option is ignored
by format-patch.
For the graph-width limiting to be usable, it should happen
'automatically' once configured, hence the config option.
Nevertheless, graph width limiting only makes sense when used on a
wide terminal, so it should not influence the output of format-patch,
which adheres to the 80-column standard.
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
index 1aed79e7dc451f02e1b15dd0644c89fee6071703..6aa1be04787b998d12b873afc98d9b498c942363 100644 (file)
and accumulating child directory counts in the parent directories:
`files,10,cumulative`.
+diff.statGraphWidth::
+ Limit the width of the graph part in --stat output. If set, applies
+ to all commands generating --stat outuput except format-patch.
+
diff.external::
If this config variable is set, diff generation is not
performed using the internal diff machinery, but using the
index d34efd521835a2004ab193063a37ed2a92b4827a..87f0a5fb8f1b74332d0a9ce6579bc5d8d0f00ef3 100644 (file)
--stat[=<width>[,<name-width>[,<count>]]]::
Generate a diffstat. By default, as much space as necessary
- will be used for the filename part, and the rest for
- the graph part. Maximum width defaults to terminal width,
- or 80 columns if not connected to a terminal, and can be
- overriden by `<width>`. The width of the filename part can be
- limited by giving another width `<name-width>` after a comma.
- The width of the graph part can be limited by using
- `--stat-graph-width=<width>`.
+ will be used for the filename part, and the rest for the graph
+ part. Maximum width defaults to terminal width, or 80 columns
+ if not connected to a terminal, and can be overriden by
+ `<width>`. The width of the filename part can be limited by
+ giving another width `<name-width>` after a comma. The width
+ of the graph part can be limited by using
+ `--stat-graph-width=<width>` (affects all commands generating
+ a stat graph) or by setting `diff.statGraphWidth=<width>`
+ (does not affect `git format-patch`).
By giving a third parameter `<count>`, you can limit the
output to the first `<count>` lines, followed by `...` if
there are more.
diff --git a/builtin/diff.c b/builtin/diff.c
index 81b6baec7472ff34c8ee5c9630f697f9897bd747..424c815f9bc2ca8f87eb4694d1375b949b635170 100644 (file)
--- a/builtin/diff.c
+++ b/builtin/diff.c
/* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
- /* Scale to real terminal size */
+ /* Scale to real terminal size and respect statGraphWidth config */
rev.diffopt.stat_width = -1;
+ rev.diffopt.stat_graph_width = -1;
/* Default to let external and textconv be used */
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
diff --git a/builtin/log.c b/builtin/log.c
index 075a427b71326a26ab7d2fcd2d18bd11bbfa72ec..8a47012b0bd2fefe616c44b918d16a18463b5d2a 100644 (file)
--- a/builtin/log.c
+++ b/builtin/log.c
rev->verbose_header = 1;
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
rev->diffopt.stat_width = -1; /* use full terminal width */
+ rev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */
rev->abbrev_commit = default_abbrev_commit;
rev->show_root_diff = default_show_root;
rev->subject_prefix = fmt_patch_subject_prefix;
diff --git a/builtin/merge.c b/builtin/merge.c
index b1cd90ccc39d224d57129172da9a9c650e627df7..34a5034a7667455728c7833513a43ef989d01538 100644 (file)
--- a/builtin/merge.c
+++ b/builtin/merge.c
struct diff_options opts;
diff_setup(&opts);
opts.stat_width = -1; /* use full terminal width */
+ opts.stat_graph_width = -1; /* respect statGraphWidth config */
opts.output_format |=
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
index 78be1958383da7cc2fd1ec22e3cd02e972874eb1..bacf40365b2eb0cfc4ba693b7dc4eb37382a1a80 100755 (executable)
core.whitespace
core.worktree
diff.autorefreshindex
+ diff.statGraphWidth
diff.external
diff.ignoreSubmodules
diff.mnemonicprefix
index 8f2abc8fe4b73590cbdecbaaa5cfe75eb1a4829c..4525cdadd805e018cfe158ea3e867ac882795a4f 100644 (file)
--- a/diff.c
+++ b/diff.c
int diff_auto_refresh_index = 1;
static int diff_mnemonic_prefix;
static int diff_no_prefix;
+static int diff_stat_graph_width;
static int diff_dirstat_permille_default = 30;
static struct diff_options default_diff_options;
diff_no_prefix = 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"))
else
width = options->stat_width ? options->stat_width : 80;
+ 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
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 3d823af38f11bff3e9e617a9b5eb32e6667bc343..328aa8f39865fb90d4b54991f158affa9cf2e1dc 100755 (executable)
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
grep " | " output >actual &&
test_cmp "$expect" actual
'
+
+ test_expect_success "$cmd $verb statGraphWidth config" '
+ git -c diff.statGraphWidth=26 $cmd $args >output
+ grep " | " output >actual &&
+ test_cmp "$expect" actual
+ '
done <<\EOF
ignores expect80 format-patch -1 --stdout
respects expect40 diff HEAD^ HEAD --stat