pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'

This structure will be used to communicate the per-object mtimes when writing a cruft pack. Here, we need the full packing_data structure because the mtime information is stored in an array there, not on the individual object_entry's themselves (to avoid paying the overhead in structure width for operations which do not generate a cruft pack). We haven't passed this information down before because one of the two callers (in bulk-checkin.c) does not have a packing_data structure at all. In that case (where no cruft pack will be generated), NULL is passed instead. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed May 20, 2022 at 19:17 UTC 1c573cdd7219db5600fb2b5249f7c8835c8d416d
4 files changed +7 -2
builtin/pack-objects.c
+2 -1
@@ -1262,7 +1262,8 @@ static void write_pack_file(void)
1262
1263 stage_tmp_packfiles(&tmpname, pack_tmp_name,
1264 written_list, nr_written,
1265 - &pack_idx_opts, hash, &idx_tmp_name);
1265 + &to_pack, &pack_idx_opts, hash,
1266 + &idx_tmp_name);
1267
1268 if (write_bitmap_index) {
1269 size_t tmpname_len = tmpname.len;
bulk-checkin.c
+1 -1
@@ -33,7 +33,7 @@ static void finish_tmp_packfile(struct strbuf *basename,
33 char *idx_tmp_name = NULL;
34
35 stage_tmp_packfiles(basename, pack_tmp_name, written_list, nr_written,
36 - pack_idx_opts, hash, &idx_tmp_name);
36 + NULL, pack_idx_opts, hash, &idx_tmp_name);
37 rename_tmp_packfile_idx(basename, &idx_tmp_name);
38
39 free(idx_tmp_name);
pack-write.c
+1
@@ -484,6 +484,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
484 const char *pack_tmp_name,
485 struct pack_idx_entry **written_list,
486 uint32_t nr_written,
487 + struct packing_data *to_pack,
488 struct pack_idx_option *pack_idx_opts,
489 unsigned char hash[],
490 char **idx_tmp_name)
pack.h
+3
@@ -109,11 +109,14 @@ int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
109 #define PH_ERROR_PROTOCOL (-3)
110 int read_pack_header(int fd, struct pack_header *);
111
112 +struct packing_data;
113 +
114 struct hashfile *create_tmp_packfile(char **pack_tmp_name);
115 void stage_tmp_packfiles(struct strbuf *name_buffer,
116 const char *pack_tmp_name,
117 struct pack_idx_entry **written_list,
118 uint32_t nr_written,
119 + struct packing_data *to_pack,
120 struct pack_idx_option *pack_idx_opts,
121 unsigned char hash[],
122 char **idx_tmp_name);