@@ -45,6 +45,7 @@ static struct survey_refs_wanted default_ref_options = {
45
45
struct survey_opts {
46
46
int verbose ;
47
47
int show_progress ;
48
+ int top_nr ;
48
49
struct survey_refs_wanted refs ;
49
50
};
50
51
@@ -553,6 +554,10 @@ static int survey_load_config_cb(const char *var, const char *value,
553
554
ctx -> opts .show_progress = git_config_bool (var , value );
554
555
return 0 ;
555
556
}
557
+ if (!strcmp (var , "survey.top" )) {
558
+ ctx -> opts .top_nr = git_config_bool (var , value );
559
+ return 0 ;
560
+ }
556
561
557
562
return git_default_config (var , value , cctx , pvoid );
558
563
}
@@ -797,8 +802,6 @@ static int survey_objects_path_walk_fn(const char *path,
797
802
798
803
static void initialize_report (struct survey_context * ctx )
799
804
{
800
- const int top_limit = 100 ;
801
-
802
805
CALLOC_ARRAY (ctx -> report .by_type , REPORT_TYPE_COUNT );
803
806
ctx -> report .by_type [REPORT_TYPE_COMMIT ].label = xstrdup (_ ("Commits" ));
804
807
ctx -> report .by_type [REPORT_TYPE_TREE ].label = xstrdup (_ ("Trees" ));
@@ -807,21 +810,21 @@ static void initialize_report(struct survey_context *ctx)
807
810
808
811
CALLOC_ARRAY (ctx -> report .top_paths_by_count , REPORT_TYPE_COUNT );
809
812
init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_TREE ],
810
- top_limit , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
813
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
811
814
init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_BLOB ],
812
- top_limit , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
815
+ ctx -> opts . top_nr , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
813
816
814
817
CALLOC_ARRAY (ctx -> report .top_paths_by_disk , REPORT_TYPE_COUNT );
815
818
init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_TREE ],
816
- top_limit , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
819
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
817
820
init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_BLOB ],
818
- top_limit , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
821
+ ctx -> opts . top_nr , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
819
822
820
823
CALLOC_ARRAY (ctx -> report .top_paths_by_inflate , REPORT_TYPE_COUNT );
821
824
init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_TREE ],
822
- top_limit , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
825
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
823
826
init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_BLOB ],
824
- top_limit , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
827
+ ctx -> opts . top_nr , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
825
828
}
826
829
827
830
static void survey_phase_objects (struct survey_context * ctx )
@@ -873,6 +876,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix,
873
876
.opts = {
874
877
.verbose = 0 ,
875
878
.show_progress = -1 , /* defaults to isatty(2) */
879
+ .top_nr = 100 ,
876
880
877
881
.refs .want_all_refs = -1 ,
878
882
@@ -888,6 +892,8 @@ int cmd_survey(int argc, const char **argv, const char *prefix,
888
892
static struct option survey_options [] = {
889
893
OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
890
894
OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
895
+ OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
896
+ N_ ("number of entries to include in detail tables" )),
891
897
892
898
OPT_BOOL_F (0 , "all-refs" , & ctx .opts .refs .want_all_refs , N_ ("include all refs" ), PARSE_OPT_NONEG ),
893
899
0 commit comments