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>
This commit is contained in:
Johan Herland
2011-04-29 11:36:19 +02:00
committed by Junio C Hamano
parent 333f3fb0c5
commit 2d17495196
4 changed files with 119 additions and 1 deletions

10
diff.c
View File

@ -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;