Skip to content

Commit 82db195

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9aa1cba commit 82db195

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

pack-write.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,26 +310,21 @@ static void write_mtimes_trailer(struct hashfile *f, const unsigned char *hash)
310310
hashwrite(f, hash, the_hash_algo->rawsz);
311311
}
312312

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,
315314
struct pack_idx_entry **objects,
316315
uint32_t nr_objects,
317316
const unsigned char *hash)
318317
{
318+
struct strbuf tmp_file = STRBUF_INIT;
319+
const char *mtimes_name;
319320
struct hashfile *f;
320321
int fd;
321322

322323
if (!to_pack)
323324
BUG("cannot call write_mtimes_file with NULL packing_data");
324325

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);
333328
f = hashfd(fd, mtimes_name);
334329

335330
write_mtimes_header(f);
@@ -561,7 +556,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
561556
pack_idx_opts->flags);
562557

563558
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,
565560
nr_written,
566561
hash);
567562
}

0 commit comments

Comments
 (0)