From 2d17495196d0dceb0ff492aa97bfff33ef1baa18 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Fri, 29 Apr 2011 11:36:19 +0200 Subject: Add config variable for specifying default --dirstat behavior The new diff.dirstat config variable takes the same arguments as '--dirstat=', 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 Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- diff.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'diff.c') 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; -- cgit v1.2.1