@@ -40,6 +40,7 @@ static struct survey_refs_wanted default_ref_options = {
4040struct survey_opts {
4141 int verbose ;
4242 int show_progress ;
43+ int top_nr ;
4344 struct survey_refs_wanted refs ;
4445};
4546
@@ -548,6 +549,10 @@ static int survey_load_config_cb(const char *var, const char *value,
548549 ctx -> opts .show_progress = git_config_bool (var , value );
549550 return 0 ;
550551 }
552+ if (!strcmp (var , "survey.top" )) {
553+ ctx -> opts .top_nr = git_config_bool (var , value );
554+ return 0 ;
555+ }
551556
552557 return git_default_config (var , value , cctx , pvoid );
553558}
@@ -794,8 +799,6 @@ static int survey_objects_path_walk_fn(const char *path,
794799
795800static void initialize_report (struct survey_context * ctx )
796801{
797- const int top_limit = 100 ;
798-
799802 CALLOC_ARRAY (ctx -> report .by_type , REPORT_TYPE_COUNT );
800803 ctx -> report .by_type [REPORT_TYPE_COMMIT ].label = xstrdup (_ ("Commits" ));
801804 ctx -> report .by_type [REPORT_TYPE_TREE ].label = xstrdup (_ ("Trees" ));
@@ -804,21 +807,21 @@ static void initialize_report(struct survey_context *ctx)
804807
805808 CALLOC_ARRAY (ctx -> report .top_paths_by_count , REPORT_TYPE_COUNT );
806809 init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_TREE ],
807- top_limit , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
810+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
808811 init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_BLOB ],
809- top_limit , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
812+ ctx -> opts . top_nr , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
810813
811814 CALLOC_ARRAY (ctx -> report .top_paths_by_disk , REPORT_TYPE_COUNT );
812815 init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_TREE ],
813- top_limit , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
816+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
814817 init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_BLOB ],
815- top_limit , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
818+ ctx -> opts . top_nr , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
816819
817820 CALLOC_ARRAY (ctx -> report .top_paths_by_inflate , REPORT_TYPE_COUNT );
818821 init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_TREE ],
819- top_limit , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
822+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
820823 init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_BLOB ],
821- top_limit , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
824+ ctx -> opts . top_nr , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
822825}
823826
824827static void survey_phase_objects (struct survey_context * ctx )
@@ -869,6 +872,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
869872 .opts = {
870873 .verbose = 0 ,
871874 .show_progress = -1 , /* defaults to isatty(2) */
875+ .top_nr = 10 ,
872876
873877 .refs .want_all_refs = -1 ,
874878
@@ -884,6 +888,8 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
884888 static struct option survey_options [] = {
885889 OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
886890 OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
891+ OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
892+ N_ ("number of entries to include in detail tables" )),
887893
888894 OPT_BOOL_F (0 , "all-refs" , & ctx .opts .refs .want_all_refs , N_ ("include all refs" ), PARSE_OPT_NONEG ),
889895
0 commit comments