pack-write: drop always-NULL parameter

write_mtimes_file() takes an mtimes parameter as its first option, but the only caller passes a NULL constant. Drop this parameter to simplify logic. This can be reverted if that parameter is needed in the future. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jun 16, 2022 at 13:13 UTC 82db195e1be63cfa274c26351ef782b2df0a21fd
1 file changed +6 -11
pack-write.c
+6 -11
@@ -310,26 +310,21 @@ static void write_mtimes_trailer(struct hashfile *f, const unsigned char *hash)
310 hashwrite(f, hash, the_hash_algo->rawsz);
311 }
312
313 -static const char *write_mtimes_file(const char *mtimes_name,
314 - struct packing_data *to_pack,
313 +static const char *write_mtimes_file(struct packing_data *to_pack,
314 struct pack_idx_entry **objects,
315 uint32_t nr_objects,
316 const unsigned char *hash)
317 {
318 + struct strbuf tmp_file = STRBUF_INIT;
319 + const char *mtimes_name;
320 struct hashfile *f;
321 int fd;
322
323 if (!to_pack)
324 BUG("cannot call write_mtimes_file with NULL packing_data");
325
325 - if (!mtimes_name) {
326 - struct strbuf tmp_file = STRBUF_INIT;
327 - fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
328 - mtimes_name = strbuf_detach(&tmp_file, NULL);
329 - } else {
330 - unlink(mtimes_name);
331 - fd = xopen(mtimes_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
332 - }
326 + fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
327 + mtimes_name = strbuf_detach(&tmp_file, NULL);
328 f = hashfd(fd, mtimes_name);
329
330 write_mtimes_header(f);
@@ -561,7 +556,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
556 pack_idx_opts->flags);
557
558 if (pack_idx_opts->flags & WRITE_MTIMES) {
564 - mtimes_tmp_name = write_mtimes_file(NULL, to_pack, written_list,
559 + mtimes_tmp_name = write_mtimes_file(to_pack, written_list,
560 nr_written,
561 hash);
562 }