diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-09-11 13:06:13 +0700 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2013-09-13 21:00:30 -0400 |
commit | 3f68fd1e4b3963d97205e2339799ff4a52cf36ca (patch) | |
tree | ea2c2a1e0d83bbec58e3e34b4b7bc56f22090383 | |
parent | 8ae1090121480dc89a601d9cf672926ec70ca265 (diff) | |
download | git-3f68fd1e4b3963d97205e2339799ff4a52cf36ca.tar.gz |
unpack-objects: recognize end-of-pack in v4 thin pack
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/unpack-objects.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 6d0a65c898..c9eb31d218 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -20,6 +20,7 @@ static unsigned char buffer[4096]; static unsigned int offset, len; static off_t consumed_bytes; static git_SHA_CTX ctx; +static int packv4; /* * When running under --strict mode, objects whose reachability are @@ -421,7 +422,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, free(base); } -static void unpack_one(unsigned nr) +static int unpack_one(unsigned nr) { unsigned shift; unsigned char *pack; @@ -431,6 +432,10 @@ static void unpack_one(unsigned nr) obj_list[nr].offset = consumed_bytes; pack = fill(1); + if (packv4 && *(char*)fill(1) == 0) { + use(1); + return -1; + } c = *pack; use(1); type = (c >> 4) & 7; @@ -450,18 +455,19 @@ static void unpack_one(unsigned nr) case OBJ_BLOB: case OBJ_TAG: unpack_non_delta_entry(type, size, nr); - return; + break; case OBJ_REF_DELTA: case OBJ_OFS_DELTA: unpack_delta_entry(type, size, nr); - return; + break; default: error("bad object type %d", type); has_errors = 1; if (recover) - return; + break; exit(1); } + return 0; } static void unpack_all(void) @@ -477,13 +483,15 @@ static void unpack_all(void) if (!pack_version_ok(hdr->hdr_version)) die("unknown pack file version %"PRIu32, ntohl(hdr->hdr_version)); + packv4 = ntohl(hdr->hdr_version) == 4; use(sizeof(struct pack_header)); if (!quiet) progress = start_progress("Unpacking objects", nr_objects); obj_list = xcalloc(nr_objects, sizeof(*obj_list)); for (i = 0; i < nr_objects; i++) { - unpack_one(i); + if (unpack_one(i)) + break; display_progress(progress, i + 1); } stop_progress(&progress); |