summaryrefslogtreecommitdiff
path: root/pack-write.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 /pack-write.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 'pack-write.c')
-rw-r--r--pack-write.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/pack-write.c b/pack-write.c
index 9cd3bfbb4b..46f3f846be 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -178,6 +178,18 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
return index_name;
}
+off_t write_pack_header(struct sha1file *f, uint32_t nr_entries)
+{
+ struct pack_header hdr;
+
+ hdr.hdr_signature = htonl(PACK_SIGNATURE);
+ hdr.hdr_version = htonl(PACK_VERSION);
+ hdr.hdr_entries = htonl(nr_entries);
+ if (sha1write(f, &hdr, sizeof(hdr)))
+ return 0;
+ return sizeof(hdr);
+}
+
/*
* Update pack header with object_count and compute new SHA1 for pack data
* associated to pack_fd, and write that SHA1 at the end. That new SHA1