@@ -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
@@ -548,6 +549,10 @@ static int survey_load_config_cb(const char *var, const char *value,
548
549
ctx -> opts .show_progress = git_config_bool (var , value );
549
550
return 0 ;
550
551
}
552
+ if (!strcmp (var , "survey.top" )) {
553
+ ctx -> opts .top_nr = git_config_bool (var , value );
554
+ return 0 ;
555
+ }
551
556
552
557
return git_default_config (var , value , cctx , pvoid );
553
558
}
@@ -792,8 +797,6 @@ static int survey_objects_path_walk_fn(const char *path,
792
797
793
798
static void initialize_report (struct survey_context * ctx )
794
799
{
795
- const int top_limit = 100 ;
796
-
797
800
CALLOC_ARRAY (ctx -> report .by_type , REPORT_TYPE_COUNT );
798
801
ctx -> report .by_type [REPORT_TYPE_COMMIT ].label = xstrdup (_ ("Commits" ));
799
802
ctx -> report .by_type [REPORT_TYPE_TREE ].label = xstrdup (_ ("Trees" ));
@@ -802,21 +805,21 @@ static void initialize_report(struct survey_context *ctx)
802
805
803
806
CALLOC_ARRAY (ctx -> report .top_paths_by_count , REPORT_TYPE_COUNT );
804
807
init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_TREE ],
805
- top_limit , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
808
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY COUNT" ), cmp_by_nr );
806
809
init_top_sizes (& ctx -> report .top_paths_by_count [REPORT_TYPE_BLOB ],
807
- top_limit , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
810
+ ctx -> opts . top_nr , _ ("TOP FILES BY COUNT" ), cmp_by_nr );
808
811
809
812
CALLOC_ARRAY (ctx -> report .top_paths_by_disk , REPORT_TYPE_COUNT );
810
813
init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_TREE ],
811
- top_limit , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
814
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY DISK SIZE" ), cmp_by_disk_size );
812
815
init_top_sizes (& ctx -> report .top_paths_by_disk [REPORT_TYPE_BLOB ],
813
- top_limit , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
816
+ ctx -> opts . top_nr , _ ("TOP FILES BY DISK SIZE" ), cmp_by_disk_size );
814
817
815
818
CALLOC_ARRAY (ctx -> report .top_paths_by_inflate , REPORT_TYPE_COUNT );
816
819
init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_TREE ],
817
- top_limit , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
820
+ ctx -> opts . top_nr , _ ("TOP DIRECTORIES BY INFLATED SIZE" ), cmp_by_inflated_size );
818
821
init_top_sizes (& ctx -> report .top_paths_by_inflate [REPORT_TYPE_BLOB ],
819
- top_limit , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
822
+ ctx -> opts . top_nr , _ ("TOP FILES BY INFLATED SIZE" ), cmp_by_inflated_size );
820
823
}
821
824
822
825
static void survey_phase_objects (struct survey_context * ctx )
@@ -865,6 +868,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
865
868
.opts = {
866
869
.verbose = 0 ,
867
870
.show_progress = -1 , /* defaults to isatty(2) */
871
+ .top_nr = 10 ,
868
872
869
873
.refs .want_all_refs = -1 ,
870
874
@@ -880,6 +884,8 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
880
884
static struct option survey_options [] = {
881
885
OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
882
886
OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
887
+ OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
888
+ N_ ("number of entries to include in detail tables" )),
883
889
884
890
OPT_BOOL_F (0 , "all-refs" , & ctx .opts .refs .want_all_refs , N_ ("include all refs" ), PARSE_OPT_NONEG ),
885
891
0 commit comments