@@ -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 ;
@@ -1189,6 +1194,13 @@ static void large_item_vec_lookup_name_rev(struct survey_context *ctx,
11891194
11901195static void do_lookup_name_rev (struct survey_context * ctx )
11911196{
1197+ /*
1198+ * `git name-rev` can be very expensive when there are lots of
1199+ * refs, so make it optional.
1200+ */
1201+ if (!ctx -> opts .show_name_rev )
1202+ return ;
1203+
11921204 if (ctx -> opts .show_progress ) {
11931205 ctx -> progress_total = 0 ;
11941206 ctx -> progress = start_progress (ctx -> repo , _ ("Resolving name-revs..." ), 0 );
@@ -1563,9 +1575,12 @@ static void survey_phase_objects(struct survey_context *ctx)
15631575 release_revisions (& revs );
15641576 trace2_region_leave ("survey" , "phase/objects" , ctx -> repo );
15651577
1566- trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1567- do_lookup_name_rev (ctx );
1568- trace2_region_enter ("survey" , "phase/namerev" , the_repository );}
1578+ if (ctx -> opts .show_name_rev ) {
1579+ trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1580+ do_lookup_name_rev (ctx );
1581+ trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1582+ }
1583+ }
15691584
15701585int cmd_survey (int argc , const char * * argv , const char * prefix , struct repository * repo )
15711586{
@@ -1589,6 +1604,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
15891604 static struct option survey_options [] = {
15901605 OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
15911606 OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
1607+ OPT_BOOL (0 , "name-rev" , & ctx .opts .show_name_rev , N_ ("run name-rev on each reported commit" )),
15921608 OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
15931609 N_ ("number of entries to include in detail tables" )),
15941610
0 commit comments