summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2011-04-29 11:36:19 +0200
committerJunio C Hamano <gitster@pobox.com>2011-04-29 11:20:03 -0700
commit2d17495196d0dceb0ff492aa97bfff33ef1baa18 (patch)
tree010da01ffd0d5101ba2d3689553f07165302e3a7 /diff.c
parent333f3fb0c5307fed170cae336ab3c056f4d6ca1c (diff)
downloadgit-2d17495196d0dceb0ff492aa97bfff33ef1baa18.tar.gz
Add config variable for specifying default --dirstat behavior
The new diff.dirstat config variable takes the same arguments as '--dirstat=<args>', and specifies the default arguments for --dirstat. The config is obviously overridden by --dirstat arguments passed on the command line. When not specified, the --dirstat defaults are 'changes,noncumulative,3'. The patch also adds several tests verifying the interaction between the diff.dirstat config variable, and the --dirstat command line option. Improved-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 3b0cda43f1..c78f7d5218 100644
--- a/diff.c
+++ b/diff.c
@@ -31,6 +31,7 @@ static const char *external_diff_cmd_cfg;
int diff_auto_refresh_index = 1;
static int diff_mnemonic_prefix;
static int diff_no_prefix;
+static int diff_dirstat_percent_default = 3;
static struct diff_options default_diff_options;
static char diff_colors[][COLOR_MAXLEN] = {
@@ -180,6 +181,13 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
return 0;
}
+ if (!strcmp(var, "diff.dirstat")) {
+ default_diff_options.dirstat_percent = diff_dirstat_percent_default;
+ (void) parse_dirstat_params(&default_diff_options, value);
+ diff_dirstat_percent_default = default_diff_options.dirstat_percent;
+ return 0;
+ }
+
if (!prefixcmp(var, "submodule."))
return parse_submodule_config_option(var, value);
@@ -2926,7 +2934,7 @@ void diff_setup(struct diff_options *options)
options->line_termination = '\n';
options->break_opt = -1;
options->rename_limit = -1;
- options->dirstat_percent = 3;
+ options->dirstat_percent = diff_dirstat_percent_default;
options->context = 3;
options->change = diff_change;