diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-09-09 20:57:55 +0700 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2013-09-13 21:00:29 -0400 |
commit | d552beddb253da2e6fe49680835cf51f31ec40c1 (patch) | |
tree | f1d129936647745034324ed353a5227beea4fc7a | |
parent | 5fe95cdd012fcbfc48fb5f0d96b468d919edb809 (diff) | |
download | git-d552beddb253da2e6fe49680835cf51f31ec40c1.tar.gz |
pack v4: add version argument to write_pack_header
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
-rw-r--r-- | builtin/pack-objects.c | 2 | ||||
-rw-r--r-- | bulk-checkin.c | 2 | ||||
-rw-r--r-- | pack-write.c | 7 | ||||
-rw-r--r-- | pack.h | 3 |
4 files changed, 8 insertions, 6 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index f069462cb0..33faea89fc 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -735,7 +735,7 @@ static void write_pack_file(void) else f = create_tmp_packfile(&pack_tmp_name); - offset = write_pack_header(f, nr_remaining); + offset = write_pack_header(f, 2, nr_remaining); if (!offset) die_errno("unable to write pack header"); nr_written = 0; diff --git a/bulk-checkin.c b/bulk-checkin.c index 6b0b6d4904..9d8f0d0447 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -176,7 +176,7 @@ static void prepare_to_stream(struct bulk_checkin_state *state, reset_pack_idx_option(&state->pack_idx_opts); /* Pretend we are going to write only one object */ - state->offset = write_pack_header(state->f, 1); + state->offset = write_pack_header(state->f, 2, 1); if (!state->offset) die_errno("unable to write pack header"); } diff --git a/pack-write.c b/pack-write.c index 631007e168..88e4788f4b 100644 --- a/pack-write.c +++ b/pack-write.c @@ -186,12 +186,15 @@ 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) +off_t write_pack_header(struct sha1file *f, + int version, uint32_t nr_entries) { struct pack_header hdr; hdr.hdr_signature = htonl(PACK_SIGNATURE); - hdr.hdr_version = htonl(PACK_VERSION); + hdr.hdr_version = htonl(version); + if (!pack_version_ok(hdr.hdr_version)) + die(_("pack version %d is not supported"), version); hdr.hdr_entries = htonl(nr_entries); if (sha1write(f, &hdr, sizeof(hdr))) return 0; @@ -8,7 +8,6 @@ * Packed object header */ #define PACK_SIGNATURE 0x5041434b /* "PACK" */ -#define PACK_VERSION 2 #define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3)) struct pack_header { uint32_t hdr_signature; @@ -80,7 +79,7 @@ extern const char *write_idx_file(const char *index_name, struct pack_idx_entry extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr); extern int verify_pack_index(struct packed_git *); extern int verify_pack(struct packed_git *, verify_fn fn, struct progress *, uint32_t); -extern off_t write_pack_header(struct sha1file *f, uint32_t); +extern off_t write_pack_header(struct sha1file *f, int, uint32_t); extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t); extern char *index_pack_lockfile(int fd); extern int encode_in_pack_object_header(enum object_type, uintmax_t, unsigned char *); |