@@ -31,7 +31,7 @@ static const char *external_diff_cmd_cfg;
31
31
int diff_auto_refresh_index = 1 ;
32
32
static int diff_mnemonic_prefix ;
33
33
static int diff_no_prefix ;
34
- static int diff_dirstat_percent_default = 3 ;
34
+ static int diff_dirstat_permille_default = 30 ;
35
35
static struct diff_options default_diff_options ;
36
36
37
37
static char diff_colors [][COLOR_MAXLEN ] = {
@@ -85,8 +85,15 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
85
85
DIFF_OPT_SET (options , DIRSTAT_CUMULATIVE );
86
86
} else if (isdigit (* p )) {
87
87
char * end ;
88
- options -> dirstat_percent = strtoul (p , & end , 10 );
88
+ options -> dirstat_permille = strtoul (p , & end , 10 ) * 10 ;
89
89
p = end ;
90
+ if (* p == '.' && isdigit (* ++ p )) {
91
+ /* only use first digit */
92
+ options -> dirstat_permille += * p - '0' ;
93
+ /* .. and ignore any further digits */
94
+ while (isdigit (* ++ p ))
95
+ ; /* nothing */
96
+ }
90
97
} else
91
98
return error ("Unknown --dirstat parameter '%s'" , p );
92
99
@@ -182,9 +189,9 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
182
189
}
183
190
184
191
if (!strcmp (var , "diff.dirstat" )) {
185
- default_diff_options .dirstat_percent = diff_dirstat_percent_default ;
192
+ default_diff_options .dirstat_permille = diff_dirstat_permille_default ;
186
193
(void ) parse_dirstat_params (& default_diff_options , value );
187
- diff_dirstat_percent_default = default_diff_options .dirstat_percent ;
194
+ diff_dirstat_permille_default = default_diff_options .dirstat_permille ;
188
195
return 0 ;
189
196
}
190
197
@@ -1498,7 +1505,7 @@ struct dirstat_file {
1498
1505
1499
1506
struct dirstat_dir {
1500
1507
struct dirstat_file * files ;
1501
- int alloc , nr , percent , cumulative ;
1508
+ int alloc , nr , permille , cumulative ;
1502
1509
};
1503
1510
1504
1511
static long gather_dirstat (struct diff_options * opt , struct dirstat_dir * dir ,
@@ -1547,10 +1554,9 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
1547
1554
if (baselen && sources != 1 ) {
1548
1555
if (this_dir ) {
1549
1556
int permille = this_dir * 1000 / changed ;
1550
- int percent = permille / 10 ;
1551
- if (percent >= dir -> percent ) {
1557
+ if (permille >= dir -> permille ) {
1552
1558
fprintf (opt -> file , "%s%4d.%01d%% %.*s\n" , line_prefix ,
1553
- percent , permille % 10 , baselen , base );
1559
+ permille / 10 , permille % 10 , baselen , base );
1554
1560
if (!dir -> cumulative )
1555
1561
return 0 ;
1556
1562
}
@@ -1576,7 +1582,7 @@ static void show_dirstat(struct diff_options *options)
1576
1582
dir .files = NULL ;
1577
1583
dir .alloc = 0 ;
1578
1584
dir .nr = 0 ;
1579
- dir .percent = options -> dirstat_percent ;
1585
+ dir .permille = options -> dirstat_permille ;
1580
1586
dir .cumulative = DIFF_OPT_TST (options , DIRSTAT_CUMULATIVE );
1581
1587
1582
1588
changed = 0 ;
@@ -2934,7 +2940,7 @@ void diff_setup(struct diff_options *options)
2934
2940
options -> line_termination = '\n' ;
2935
2941
options -> break_opt = -1 ;
2936
2942
options -> rename_limit = -1 ;
2937
- options -> dirstat_percent = diff_dirstat_percent_default ;
2943
+ options -> dirstat_permille = diff_dirstat_permille_default ;
2938
2944
options -> context = 3 ;
2939
2945
2940
2946
options -> change = diff_change ;
0 commit comments