@@ -42,6 +42,7 @@ static struct survey_refs_wanted default_ref_options = {
42
42
struct survey_opts {
43
43
int verbose ;
44
44
int show_progress ;
45
+ int show_name_rev ;
45
46
46
47
int show_largest_commits_by_nr_parents ;
47
48
int show_largest_commits_by_size_bytes ;
@@ -767,7 +768,7 @@ static void survey_report_commit_parents(struct survey_context *ctx)
767
768
clear_table (& table );
768
769
}
769
770
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 )
771
772
{
772
773
struct survey_table table = SURVEY_TABLE_INIT ;
773
774
struct strbuf size = STRBUF_INIT ;
@@ -776,7 +777,7 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
776
777
return ;
777
778
778
779
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 );
780
781
781
782
for (size_t k = 0 ; k < vec -> nr_items ; k ++ ) {
782
783
struct large_item * pk = & vec -> items [k ];
@@ -787,7 +788,7 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
787
788
insert_table_rowv (& table , size .buf , oid_to_hex (& pk -> oid ), pk -> name .buf ,
788
789
is_null_oid (& pk -> containing_commit_oid ) ?
789
790
"" : 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 : "" ,
791
792
NULL );
792
793
}
793
794
}
@@ -977,11 +978,11 @@ static void survey_report_plaintext(struct survey_context *ctx)
977
978
survey_report_plaintext_sorted_size (
978
979
& ctx -> report .top_paths_by_inflate [REPORT_TYPE_BLOB ]);
979
980
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 );
985
986
}
986
987
987
988
/*
@@ -1053,6 +1054,10 @@ static int survey_load_config_cb(const char *var, const char *value,
1053
1054
ctx -> opts .show_progress = git_config_bool (var , value );
1054
1055
return 0 ;
1055
1056
}
1057
+ if (!strcmp (var , "survey.namerev" )) {
1058
+ ctx -> opts .show_name_rev = git_config_bool (var , value );
1059
+ return 0 ;
1060
+ }
1056
1061
if (!strcmp (var , "survey.showcommitparents" )) {
1057
1062
ctx -> opts .show_largest_commits_by_nr_parents = git_config_ulong (var , value , cctx -> kvi );
1058
1063
return 0 ;
@@ -1189,6 +1194,13 @@ static void large_item_vec_lookup_name_rev(struct survey_context *ctx,
1189
1194
1190
1195
static void do_lookup_name_rev (struct survey_context * ctx )
1191
1196
{
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
+
1192
1204
if (ctx -> opts .show_progress ) {
1193
1205
ctx -> progress_total = 0 ;
1194
1206
ctx -> progress = start_progress (ctx -> repo , _ ("Resolving name-revs..." ), 0 );
@@ -1562,9 +1574,12 @@ static void survey_phase_objects(struct survey_context *ctx)
1562
1574
release_revisions (& revs );
1563
1575
trace2_region_leave ("survey" , "phase/objects" , ctx -> repo );
1564
1576
1565
- trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1566
- do_lookup_name_rev (ctx );
1567
- trace2_region_enter ("survey" , "phase/namerev" , the_repository );}
1577
+ if (ctx -> opts .show_name_rev ) {
1578
+ trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1579
+ do_lookup_name_rev (ctx );
1580
+ trace2_region_enter ("survey" , "phase/namerev" , the_repository );
1581
+ }
1582
+ }
1568
1583
1569
1584
int cmd_survey (int argc , const char * * argv , const char * prefix , struct repository * repo )
1570
1585
{
@@ -1588,6 +1603,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
1588
1603
static struct option survey_options [] = {
1589
1604
OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
1590
1605
OPT_BOOL (0 , "progress" , & ctx .opts .show_progress , N_ ("show progress" )),
1606
+ OPT_BOOL (0 , "name-rev" , & ctx .opts .show_name_rev , N_ ("run name-rev on each reported commit" )),
1591
1607
OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
1592
1608
N_ ("number of entries to include in detail tables" )),
1593
1609
0 commit comments