@@ -40,6 +40,7 @@ static struct survey_refs_wanted default_ref_options = {
40
40
struct survey_opts {
41
41
int verbose ;
42
42
int show_progress ;
43
+ int top_nr ;
43
44
struct survey_refs_wanted refs ;
44
45
};
45
46
@@ -539,6 +540,10 @@ static int survey_load_config_cb(const char *var, const char *value,
539
540
ctx -> opts .show_progress = git_config_bool (var , value );
540
541
return 0 ;
541
542
}
543
+ if (!strcmp (var , "survey.top" )) {
544
+ ctx -> opts .top_nr = git_config_bool (var , value );
545
+ return 0 ;
546
+ }
542
547
543
548
return git_default_config (var , value , cctx , pvoid );
544
549
}
@@ -783,8 +788,6 @@ static int survey_objects_path_walk_fn(const char *path,
783
788
784
789
static void initialize_report (struct survey_context * ctx )
785
790
{
786
- const int top_limit = 100 ;
787
-
788
791
CALLOC_ARRAY (ctx -> report .by_type , REPORT_TYPE_COUNT );
789
792
ctx -> report .by_type [REPORT_TYPE_COMMIT ].label = xstrdup (_ ("Commits" ));
790
793
ctx -> report .by_type [REPORT_TYPE_TREE ].label = xstrdup (_ ("Trees" ));
@@ -793,21 +796,21 @@ static void initialize_report(struct survey_context *ctx)
793
796
794
797
CALLOC_ARRAY (ctx -> report .top_paths_by_count , REPORT_TYPE_COUNT );
795
798
init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_TREE ],
796
- top_limit , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
799
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
797
800
init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_BLOB ],
798
- top_limit , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
801
+ ctx -> opts . top_nr , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
799
802
800
803
CALLOC_ARRAY (ctx -> report .top_paths_by_disk , REPORT_TYPE_COUNT );
801
804
init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_TREE ],
802
- top_limit , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
805
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
803
806
init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_BLOB ],
804
- top_limit , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
807
+ ctx -> opts . top_nr , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
805
808
806
809
CALLOC_ARRAY (ctx -> report .top_paths_by_inflate , REPORT_TYPE_COUNT );
807
810
init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_TREE ],
808
- top_limit , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
811
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
809
812
init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_BLOB ],
810
- top_limit , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
813
+ ctx -> opts . top_nr , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
811
814
}
812
815
813
816
static void survey_phase_objects (struct survey_context * ctx )
@@ -856,6 +859,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix)
856
859
.opts = {
857
860
.verbose = 0 ,
858
861
.show_progress = -1 , /* defaults to isatty(2) */
862
+ .top_nr = 100 ,
859
863
860
864
.refs .want_all_refs = -1 ,
861
865
@@ -871,6 +875,8 @@ int cmd_survey(int argc, const char **argv, const char *prefix)
871
875
static struct option survey_options [] = {
872
876
OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
873
877
OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
878
+ OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
879
+ N_ ("number of entries to include in detail tables" )),
874
880
875
881
OPT_BOOL_F (0 , "all-refs" , & ctx .opts .refs .want_all_refs , N_ ("include all refs" ), PARSE_OPT_NONEG ),
876
882
0 commit comments