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