@@ -156,7 +156,21 @@ static void incr_obj_hist_bin(struct obj_hist_bin *pbin,
156
156
struct large_item {
157
157
uint64_t size ;
158
158
struct object_id oid ;
159
+
160
+ /*
161
+ * For blobs and trees the name field is the pathname of the
162
+ * file or directory. Root trees will have a zero-length
163
+ * name. The name field is not currenly used for commits.
164
+ */
159
165
struct strbuf name ;
166
+
167
+ /*
168
+ * For blobs and trees remember the transient commit from
169
+ * the treewalk so that we can say that this large item
170
+ * first appeared in this commit (relative to the treewalk
171
+ * order).
172
+ */
173
+ struct object_id containing_commit_oid ;
160
174
};
161
175
162
176
struct large_item_vec {
@@ -204,7 +218,8 @@ static void free_large_item_vec(struct large_item_vec *vec)
204
218
static void maybe_insert_large_item (struct large_item_vec * vec ,
205
219
uint64_t size ,
206
220
struct object_id * oid ,
207
- const char * name )
221
+ const char * name ,
222
+ const struct object_id * containing_commit_oid )
208
223
{
209
224
size_t rest_len ;
210
225
size_t k ;
@@ -240,6 +255,7 @@ static void maybe_insert_large_item(struct large_item_vec *vec,
240
255
memset (& vec -> items [k ], 0 , sizeof (struct large_item ));
241
256
vec -> items [k ].size = size ;
242
257
oidcpy (& vec -> items [k ].oid , oid );
258
+ oidcpy (& vec -> items [k ].containing_commit_oid , containing_commit_oid ? containing_commit_oid : null_oid (the_hash_algo ));
243
259
strbuf_init (& vec -> items [k ].name , 0 );
244
260
if (name && * name )
245
261
strbuf_addstr (& vec -> items [k ].name , name );
@@ -748,15 +764,18 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
748
764
return ;
749
765
750
766
table .table_name = vec -> dimension_label ;
751
- strvec_pushl (& table .header , "Size" , "OID" , "Name" , NULL );
767
+ strvec_pushl (& table .header , "Size" , "OID" , "Name" , "Commit" , NULL );
752
768
753
769
for (size_t k = 0 ; k < vec -> nr_items ; k ++ ) {
754
770
struct large_item * pk = & vec -> items [k ];
755
771
if (!is_null_oid (& pk -> oid )) {
756
772
strbuf_reset (& size );
757
773
strbuf_addf (& size , "%" PRIuMAX , (uintmax_t )pk -> size );
758
774
759
- insert_table_rowv (& table , size .buf , oid_to_hex (& pk -> oid ), pk -> name .buf , NULL );
775
+ insert_table_rowv (& table , size .buf , oid_to_hex (& pk -> oid ), pk -> name .buf ,
776
+ is_null_oid (& pk -> containing_commit_oid ) ?
777
+ "" : oid_to_hex (& pk -> containing_commit_oid ),
778
+ NULL );
760
779
}
761
780
}
762
781
strbuf_release (& size );
@@ -1255,8 +1274,8 @@ static void increment_totals(struct survey_context *ctx,
1255
1274
ctx -> report .reachable_objects .commits .parent_cnt_pbin [k ]++ ;
1256
1275
base = & ctx -> report .reachable_objects .commits .base ;
1257
1276
1258
- maybe_insert_large_item (ctx -> report .reachable_objects .commits .vec_largest_by_nr_parents , k , & commit -> object .oid , NULL );
1259
- maybe_insert_large_item (ctx -> report .reachable_objects .commits .vec_largest_by_size_bytes , object_length , & commit -> object .oid , NULL );
1277
+ maybe_insert_large_item (ctx -> report .reachable_objects .commits .vec_largest_by_nr_parents , k , & commit -> object .oid , NULL , & commit -> object . oid );
1278
+ maybe_insert_large_item (ctx -> report .reachable_objects .commits .vec_largest_by_size_bytes , object_length , & commit -> object .oid , NULL , & commit -> object . oid );
1260
1279
break ;
1261
1280
}
1262
1281
case OBJ_TREE : {
@@ -1276,8 +1295,8 @@ static void increment_totals(struct survey_context *ctx,
1276
1295
1277
1296
pst -> sum_entries += nr_entries ;
1278
1297
1279
- maybe_insert_large_item (pst -> vec_largest_by_nr_entries , nr_entries , & tree -> object .oid , path );
1280
- maybe_insert_large_item (pst -> vec_largest_by_size_bytes , object_length , & tree -> object .oid , path );
1298
+ maybe_insert_large_item (pst -> vec_largest_by_nr_entries , nr_entries , & tree -> object .oid , path , NULL );
1299
+ maybe_insert_large_item (pst -> vec_largest_by_size_bytes , object_length , & tree -> object .oid , path , NULL );
1281
1300
1282
1301
qb = qbin (nr_entries );
1283
1302
incr_obj_hist_bin (& pst -> entry_qbin [qb ], object_length , disk_sizep );
@@ -1288,7 +1307,7 @@ static void increment_totals(struct survey_context *ctx,
1288
1307
case OBJ_BLOB :
1289
1308
base = & ctx -> report .reachable_objects .blobs .base ;
1290
1309
1291
- maybe_insert_large_item (ctx -> report .reachable_objects .blobs .vec_largest_by_size_bytes , object_length , & oids -> oid [i ], path );
1310
+ maybe_insert_large_item (ctx -> report .reachable_objects .blobs .vec_largest_by_size_bytes , object_length , & oids -> oid [i ], path , NULL );
1292
1311
break ;
1293
1312
default :
1294
1313
continue ;
0 commit comments