summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 333f3fb)
raw | patch | inline | side by side (parent: 333f3fb)
author | Johan Herland <johan@herland.net> | |
Fri, 29 Apr 2011 09:36:19 +0000 (11:36 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 29 Apr 2011 18:20:03 +0000 (11:20 -0700) |
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>
'--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>
Documentation/diff-config.txt | patch | blob | history | |
Documentation/diff-options.txt | patch | blob | history | |
diff.c | patch | blob | history | |
t/t4047-diff-dirstat.sh | patch | blob | history |
index 2b1605f5c8f07b96f8e8c27a65717fca6046d613..228329d4ad0565f1dd22a648107baf79de01ebd9 100644 (file)
affects only 'git diff' Porcelain, and not lower level
'diff' commands such as 'git diff-files'.
+diff.dirstat::
+ A comma separated list of `--dirstat` parameters specifying the
+ default behavior of the `--dirstat` option to linkgit:git-diff[1]`
+ and friends. The defaults can be overridden on the command line
+ (using `--dirstat=<param1,param2,...>`). The fallback defaults
+ (when not changed by `diff.dirstat`) are `changes,noncumulative,3`.
+ The following parameters are available:
++
+--
+`changes`;;
+ Compute the dirstat numbers by counting the lines that have been
+ removed from the source, or added to the destination. This ignores
+ the amount of pure code movements within a file. In other words,
+ rearranging lines in a file is not counted as much as other changes.
+ This is the default behavior when no parameter is given.
+`files`;;
+ Compute the dirstat numbers by counting the number of files changed.
+ Each changed file counts equally in the dirstat analysis. This is
+ the computationally cheapest `--dirstat` behavior, since it does
+ not have to look at the file contents at all.
+`cumulative`;;
+ Count changes in a child directory for the parent directory as well.
+ Note that when using `cumulative`, the sum of the percentages
+ reported may exceed 100%. The default (non-cumulative) behavior can
+ be specified with the `noncumulative` parameter.
+<limit>;;
+ An integer parameter specifies a cut-off percent (3% by default).
+ Directories contributing less than this percentage of the changes
+ are not shown in the output.
+--
++
+Example: The following will count changed files, while ignoring
+directories with less than 10% of the total amount of changed files,
+and accumulating child directory counts in the parent directories:
+`files,10,cumulative`.
+
diff.external::
If this config variable is set, diff generation is not
performed using the internal diff machinery, but using the
index 0962035faac1d8189bea4abf50ec6bd4bba2b058..dc023523ee9c1710dcd6f465d7df2d1342321cf7 100644 (file)
Output the distribution of relative amount of changes for each
sub-directory. The behavior of `--dirstat` can be customized by
passing it a comma separated list of parameters.
+ The defaults are controlled by the `diff.dirstat` configuration
+ variable (see linkgit:git-config[1]).
The following parameters are available:
+
--
index 3b0cda43f16ccf844b711e10f487b1763f0f88ab..c78f7d5218def3d0546b636069107bc349d2c884 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_dirstat_percent_default = 3;
static struct diff_options default_diff_options;
static char diff_colors[][COLOR_MAXLEN] = {
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);
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;
index d0ed62c0dd14a78c7c9ef97354583dc380502775..c1b3697bf70b39401a6650ed96d18849e99b6af3 100755 (executable)
--- a/t/t4047-diff-dirstat.sh
+++ b/t/t4047-diff-dirstat.sh
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'non-defaults in config overridden by explicit defaults on command line' '
+ git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=files,cumulative,50 diff --dirstat=changes,noncumulative,3 -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
cat <<EOF >expect_diff_dirstat
2.1% changed/
10.8% dst/copy/changed/
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'diff.dirstat=0' '
+ git -c diff.dirstat=0 diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=0 diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=0 diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
cat <<EOF >expect_diff_dirstat
2.1% changed/
10.8% dst/copy/changed/
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'diff.dirstat=0,cumulative' '
+ git -c diff.dirstat=0,cumulative diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=0,cumulative diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=0,cumulative diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
+test_expect_success 'diff.dirstat=0 & --dirstat=cumulative' '
+ git -c diff.dirstat=0 diff --dirstat=cumulative HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=0 diff --dirstat=cumulative -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=0 diff --dirstat=cumulative -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
cat <<EOF >expect_diff_dirstat
9.0% changed/
9.0% dst/copy/changed/
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'diff.dirstat=files' '
+ git -c diff.dirstat=files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
cat <<EOF >expect_diff_dirstat
27.2% dst/copy/
27.2% dst/move/
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'diff.dirstat=10,files' '
+ git -c diff.dirstat=10,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=10,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=10,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
cat <<EOF >expect_diff_dirstat
9.0% changed/
9.0% dst/copy/changed/
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'diff.dirstat=cumulative,files' '
+ git -c diff.dirstat=cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
cat <<EOF >expect_diff_dirstat
27.2% dst/copy/
27.2% dst/move/
test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
'
+test_expect_success 'diff.dirstat=10,cumulative,files' '
+ git -c diff.dirstat=10,cumulative,files diff --dirstat HEAD^..HEAD >actual_diff_dirstat &&
+ test_cmp expect_diff_dirstat actual_diff_dirstat &&
+ git -c diff.dirstat=10,cumulative,files diff --dirstat -M HEAD^..HEAD >actual_diff_dirstat_M &&
+ test_cmp expect_diff_dirstat_M actual_diff_dirstat_M &&
+ git -c diff.dirstat=10,cumulative,files diff --dirstat -C -C HEAD^..HEAD >actual_diff_dirstat_CC &&
+ test_cmp expect_diff_dirstat_CC actual_diff_dirstat_CC
+'
+
test_done