| 331 | } |
| 332 | |
| 333 | static char *write_mtimes_file(struct repository *repo, |
| 334 | struct packing_data *to_pack, |
| 335 | struct pack_idx_entry **objects, |
| 336 | uint32_t nr_objects, |
| 337 | const unsigned char *hash) |
| 338 | { |
| 339 | struct strbuf tmp_file = STRBUF_INIT; |
| 340 | char *mtimes_name; |
| 341 | struct hashfile *f; |
| 342 | int fd; |
| 343 | |
| 344 | if (!to_pack) |
| 345 | BUG("cannot call write_mtimes_file with NULL packing_data"); |
| 346 | |
| 347 | fd = odb_mkstemp(repo->objects, &tmp_file, "pack/tmp_mtimes_XXXXXX"); |
| 348 | mtimes_name = strbuf_detach(&tmp_file, NULL); |
| 349 | f = hashfd(repo->hash_algo, fd, mtimes_name); |
| 350 | |
| 351 | write_mtimes_header(repo->hash_algo, f); |
| 352 | write_mtimes_objects(f, to_pack, objects, nr_objects); |
| 353 | write_mtimes_trailer(repo->hash_algo, f, hash); |
| 354 | |
| 355 | if (adjust_shared_perm(repo, mtimes_name) < 0) |
| 356 | die(_("failed to make %s readable"), mtimes_name); |
| 357 | |
| 358 | finalize_hashfile(f, NULL, FSYNC_COMPONENT_PACK_METADATA, |
| 359 | CSUM_HASH_IN_STREAM | CSUM_CLOSE | CSUM_FSYNC); |
| 360 | |
| 361 | return mtimes_name; |
| 362 | } |
| 363 | |
| 364 | off_t write_pack_header(struct hashfile *f, uint32_t nr_entries) |
| 365 | { |
no test coverage detected