@@ -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 ;
@@ -1188,6 +1193,13 @@ static void large_item_vec_lookup_name_rev(struct survey_context *ctx,
1188
1193
1189
1194
static void do_lookup_name_rev (struct survey_context * ctx )
1190
1195
{
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
+
1191
1203
if (ctx -> opts .show_progress ) {
1192
1204
ctx -> progress_total = 0 ;
1193
1205
ctx -> progress = start_progress (_ ("Resolving name-revs..." ), 0 );
@@ -1559,9 +1571,12 @@ static void survey_phase_objects(struct survey_context *ctx)
1559
1571
release_revisions (& revs );
1560
1572
trace2_region_leave ("survey" , "phase/objects" , ctx -> repo );
1561
1573
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
+ }
1565
1580
1566
1581
int cmd_survey (int argc , const char * * argv , const char * prefix , struct repository * repo )
1567
1582
{
@@ -1585,6 +1600,7 @@ int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
1585
1600
static struct option survey_options [] = {
1586
1601
OPT__VERBOSE (& ctx .opts .verbose , N_ ("verbose output" )),
1587
1602
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" )),
1588
1604
OPT_INTEGER ('n' , "top" , & ctx .opts .top_nr ,
1589
1605
N_ ("number of entries to include in detail tables" )),
1590
1606
0 commit comments