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