@@ -42,6 +42,7 @@ static struct survey_refs_wanted default_ref_options = {
4242struct survey_opts {
4343 int verbose ;
4444 int show_progress ;
45+ int show_name_rev ;
4546
4647 int show_largest_commits_by_nr_parents ;
4748 int show_largest_commits_by_size_bytes ;
@@ -767,7 +768,7 @@ static void survey_report_commit_parents(struct survey_context *ctx)
767768 clear_table (& table );
768769}
769770
770- static void survey_report_largest_vec (struct large_item_vec * vec )
771+ static void survey_report_largest_vec (struct survey_context * ctx , struct large_item_vec * vec )
771772{
772773 struct survey_table table = SURVEY_TABLE_INIT ;
773774 struct strbuf size = STRBUF_INIT ;
@@ -776,7 +777,7 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
776777 return ;
777778
778779 table .table_name = vec -> dimension_label ;
779- strvec_pushl (& table .header , "Size" , "OID" , "Name" , "Commit" , "Name-Rev" , NULL );
780+ strvec_pushl (& table .header , "Size" , "OID" , "Name" , "Commit" , ctx -> opts . show_name_rev ? "Name-Rev" : NULL , NULL );
780781
781782 for (size_t k = 0 ; k < vec -> nr_items ; k ++ ) {
782783 struct large_item * pk = & vec -> items [k ];
@@ -787,7 +788,7 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
787788 insert_table_rowv (& table , size .buf , oid_to_hex (& pk -> oid ), pk -> name .buf ,
788789 is_null_oid (& pk -> containing_commit_oid ) ?
789790 "" : oid_to_hex (& pk -> containing_commit_oid ),
790- pk -> name_rev .len ? pk -> name_rev .buf : "" ,
791+ ! ctx -> opts . show_name_rev ? NULL : pk -> name_rev .len ? pk -> name_rev .buf : "" ,
791792 NULL );
792793 }
793794 }
@@ -977,11 +978,11 @@ static void survey_report_plaintext(struct survey_context *ctx)
977978 survey_report_plaintext_sorted_size (
978979 & ctx -> report .top_paths_by_inflate [REPORT_TYPE_BLOB ]);
979980
980- survey_report_largest_vec (ctx -> report .reachable_objects .commits .vec_largest_by_nr_parents );
981- survey_report_largest_vec (ctx -> report .reachable_objects .commits .vec_largest_by_size_bytes );
982- survey_report_largest_vec (ctx -> report .reachable_objects .trees .vec_largest_by_nr_entries );
983- survey_report_largest_vec (ctx -> report .reachable_objects .trees .vec_largest_by_size_bytes );
984- survey_report_largest_vec (ctx -> report .reachable_objects .blobs .vec_largest_by_size_bytes );
981+ survey_report_largest_vec (ctx , ctx -> report .reachable_objects .commits .vec_largest_by_nr_parents );
982+ survey_report_largest_vec (ctx , ctx -> report .reachable_objects .commits .vec_largest_by_size_bytes );
983+ survey_report_largest_vec (ctx , ctx -> report .reachable_objects .trees .vec_largest_by_nr_entries );
984+ survey_report_largest_vec (ctx , ctx -> report .reachable_objects .trees .vec_largest_by_size_bytes );
985+ survey_report_largest_vec (ctx , ctx -> report .reachable_objects .blobs .vec_largest_by_size_bytes );
985986}
986987
987988/*
@@ -1053,6 +1054,10 @@ static int survey_load_config_cb(const char *var, const char *value,
10531054 ctx -> opts .show_progress = git_config_bool (var , value );
10541055 return 0 ;
10551056 }
1057+ if (!strcmp (var , "survey.namerev" )) {
1058+ ctx -> opts .show_name_rev = git_config_bool (var , value );
1059+ return 0 ;
1060+ }
10561061 if (!strcmp (var , "survey.showcommitparents" )) {
10571062 ctx -> opts .show_largest_commits_by_nr_parents = git_config_ulong (var , value , cctx -> kvi );
10581063 return 0 ;
@@ -1188,6 +1193,13 @@ static void large_item_vec_lookup_name_rev(struct survey_context *ctx,
11881193
11891194static void do_lookup_name_rev (struct survey_context * ctx )
11901195{
1196+ /*
1197+ * `git name-rev` can be very expensive when there are lots of
1198+ * refs, so make it optional.
1199+ */
1200+ if (!ctx -> opts .show_name_rev )
1201+ return ;
1202+
11911203 if (ctx -> opts .show_progress ) {
11921204 ctx -> progress_total = 0 ;
11931205 ctx -> progress = start_progress (_ ("Resolving name-revs..." ), 0 );
@@ -1559,9 +1571,12 @@ static void survey_phase_objects(struct survey_context *ctx)
15591571 release_revisions (& revs );
15601572 trace2_region_leave ("survey" , "phase/objects" , ctx -> repo );
15611573
1562- trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1563- do_lookup_name_rev (ctx );
1564- trace2_region_enter ("survey" , "phase/namerev" , the_repository );}
1574+ if (ctx -> opts .show_name_rev ) {
1575+ trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1576+ do_lookup_name_rev (ctx );
1577+ trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1578+ }
1579+ }
15651580
15661581int cmd_survey (int argc , const char * * argv , const char * prefix , struct repository * repo )
15671582{
@@ -1585,6 +1600,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
15851600 static struct option survey_options [] = {
15861601 OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
15871602 OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
1603+ OPT_BOOL (0 , "name-rev" , & ctx .opts .show_name_rev , N_ ("run name-rev on each reported commit" )),
15881604 OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
15891605 N_ ("number of entries to include in detail tables" )),
15901606
0 commit comments