summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/pack-write.c b/pack-write.c
index f0017be..23e19cc 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -38,9 +38,8 @@ static int need_large_offset(off_t offset, const struct pack_idx_option *opts)
}
/*
- * On entry *sha1 contains the pack content SHA1 hash, on exit it is
- * the SHA1 hash of sorted object names. The objects array passed in
- * will be sorted by SHA1 on exit.
+ * The *sha1 contains the pack content SHA1 hash.
+ * The objects array passed in will be sorted by SHA1 on exit.
*/
const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects,
int nr_objects, const struct pack_idx_option *opts,
@@ -49,7 +48,6 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
struct hashfile *f;
struct pack_idx_entry **sorted_by_sha, **list, **last;
off_t last_obj_offset = 0;
- uint32_t array[256];
int i, fd;
uint32_t index_version;
@@ -107,10 +105,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
break;
next++;
}
- array[i] = htonl(next - sorted_by_sha);
+ hashwrite_be32(f, next - sorted_by_sha);
list = next;
}
- hashwrite(f, array, 256 * 4);
/*
* Write the actual SHA1 entries..
@@ -118,10 +115,8 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
list = sorted_by_sha;
for (i = 0; i < nr_objects; i++) {
struct pack_idx_entry *obj = *list++;
- if (index_version < 2) {
- uint32_t offset = htonl(obj->offset);
- hashwrite(f, &offset, 4);
- }
+ if (index_version < 2)
+ hashwrite_be32(f, obj->offset);
hashwrite(f, obj->oid.hash, the_hash_algo->rawsz);
if ((opts->flags & WRITE_IDX_STRICT) &&
(i && oideq(&list[-2]->oid, &obj->oid)))
@@ -136,8 +131,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
list = sorted_by_sha;
for (i = 0; i < nr_objects; i++) {
struct pack_idx_entry *obj = *list++;
- uint32_t crc32_val = htonl(obj->crc32);
- hashwrite(f, &crc32_val, 4);
+ hashwrite_be32(f, obj->crc32);
}
/* write the 32-bit offset table */
@@ -149,8 +143,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
offset = (need_large_offset(obj->offset, opts)
? (0x80000000 | nr_large_offset++)
: obj->offset);
- offset = htonl(offset);
- hashwrite(f, &offset, 4);
+ hashwrite_be32(f, offset);
}
/* write the large offset table */