Skip to content

Commit 9b80744

Browse files
committed
Merge branch 'rs/misc-cleanups'
Misc cleanups. * rs/misc-cleanups: pack-bitmap-write: use hashwrite_be32() in write_hash_cache() midx: use hashwrite_u8() in write_midx_header() fast-import: use write_pack_header()
2 parents 54e85e7 + 7744a5d commit 9b80744

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

builtin/fast-import.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ static void start_packfile(void)
739739
{
740740
struct strbuf tmp_file = STRBUF_INIT;
741741
struct packed_git *p;
742-
struct pack_header hdr;
743742
int pack_fd;
744743

745744
pack_fd = odb_mkstemp(&tmp_file, "pack/tmp_pack_XXXXXX");
@@ -750,13 +749,8 @@ static void start_packfile(void)
750749
p->do_not_close = 1;
751750
pack_file = hashfd(pack_fd, p->pack_name);
752751

753-
hdr.hdr_signature = htonl(PACK_SIGNATURE);
754-
hdr.hdr_version = htonl(2);
755-
hdr.hdr_entries = 0;
756-
hashwrite(pack_file, &hdr, sizeof(hdr));
757-
758752
pack_data = p;
759-
pack_size = sizeof(hdr);
753+
pack_size = write_pack_header(pack_file, 0);
760754
object_count = 0;
761755

762756
REALLOC_ARRAY(all_packs, pack_id + 1);

midx.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,11 @@ static size_t write_midx_header(struct hashfile *f,
432432
unsigned char num_chunks,
433433
uint32_t num_packs)
434434
{
435-
unsigned char byte_values[4];
436-
437435
hashwrite_be32(f, MIDX_SIGNATURE);
438-
byte_values[0] = MIDX_VERSION;
439-
byte_values[1] = oid_version();
440-
byte_values[2] = num_chunks;
441-
byte_values[3] = 0; /* unused */
442-
hashwrite(f, byte_values, sizeof(byte_values));
436+
hashwrite_u8(f, MIDX_VERSION);
437+
hashwrite_u8(f, oid_version());
438+
hashwrite_u8(f, num_chunks);
439+
hashwrite_u8(f, 0); /* unused */
443440
hashwrite_be32(f, num_packs);
444441

445442
return MIDX_HEADER_SIZE;

pack-bitmap-write.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ static void write_hash_cache(struct hashfile *f,
503503

504504
for (i = 0; i < index_nr; ++i) {
505505
struct object_entry *entry = (struct object_entry *)index[i];
506-
uint32_t hash_value = htonl(entry->hash);
507-
hashwrite(f, &hash_value, sizeof(hash_value));
506+
hashwrite_be32(f, entry->hash);
508507
}
509508
}
510509

0 commit comments

Comments
 (0)