summaryrefslogtreecommitdiff
path: root/builtin/pack-objects.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-28 11:40:48 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-28 11:40:48 -0700
commitc0ad465725302b9411e53d248871c36880b6f8fd (patch)
tree33e1a393619b1c55af02fbcb715804500798987d /builtin/pack-objects.c
parente8e1c29021da446d0c50573ef9619bf74f515c20 (diff)
downloadgit-c0ad465725302b9411e53d248871c36880b6f8fd.tar.gz
write_pack_header(): a helper function
Factor out a small logic out of the private write_pack_file() function in builtin/pack-objects.c Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r--builtin/pack-objects.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index ba3705d1de..6643c1657a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -571,7 +571,6 @@ static void write_pack_file(void)
uint32_t i = 0, j;
struct sha1file *f;
off_t offset;
- struct pack_header hdr;
uint32_t nr_remaining = nr_result;
time_t last_mtime = 0;
struct object_entry **write_order;
@@ -596,11 +595,9 @@ static void write_pack_file(void)
f = sha1fd(fd, pack_tmp_name);
}
- hdr.hdr_signature = htonl(PACK_SIGNATURE);
- hdr.hdr_version = htonl(PACK_VERSION);
- hdr.hdr_entries = htonl(nr_remaining);
- sha1write(f, &hdr, sizeof(hdr));
- offset = sizeof(hdr);
+ offset = write_pack_header(f, nr_remaining);
+ if (!offset)
+ die_errno("unable to write pack header");
nr_written = 0;
for (; i < nr_objects; i++) {
struct object_entry *e = write_order[i];