@@ -3007,6 +3007,24 @@ static int dirstat_compare(const void *_a, const void *_b)
30073007 return strcmp (a -> name , b -> name );
30083008}
30093009
3010+ static void conclude_dirstat (struct diff_options * options ,
3011+ struct dirstat_dir * dir ,
3012+ unsigned long changed )
3013+ {
3014+ struct dirstat_file * to_free = dir -> files ;
3015+
3016+ if (!changed ) {
3017+ /* This can happen even with many files, if everything was renames */
3018+ ;
3019+ } else {
3020+ /* Show all directories with more than x% of the changes */
3021+ QSORT (dir -> files , dir -> nr , dirstat_compare );
3022+ gather_dirstat (options , dir , changed , "" , 0 );
3023+ }
3024+
3025+ free (to_free );
3026+ }
3027+
30103028static void show_dirstat (struct diff_options * options )
30113029{
30123030 int i ;
@@ -3096,13 +3114,7 @@ static void show_dirstat(struct diff_options *options)
30963114 dir .nr ++ ;
30973115 }
30983116
3099- /* This can happen even with many files, if everything was renames */
3100- if (!changed )
3101- return ;
3102-
3103- /* Show all directories with more than x% of the changes */
3104- QSORT (dir .files , dir .nr , dirstat_compare );
3105- gather_dirstat (options , & dir , changed , "" , 0 );
3117+ conclude_dirstat (options , & dir , changed );
31063118}
31073119
31083120static void show_dirstat_by_line (struct diffstat_t * data , struct diff_options * options )
@@ -3140,13 +3152,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o
31403152 dir .nr ++ ;
31413153 }
31423154
3143- /* This can happen even with many files, if everything was renames */
3144- if (!changed )
3145- return ;
3146-
3147- /* Show all directories with more than x% of the changes */
3148- QSORT (dir .files , dir .nr , dirstat_compare );
3149- gather_dirstat (options , & dir , changed , "" , 0 );
3155+ conclude_dirstat (options , & dir , changed );
31503156}
31513157
31523158static void free_diffstat_file (struct diffstat_file * f )
0 commit comments