Code

Merge branch 'lt/maint-wrap-zlib'
authorJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:55:17 +0000 (16:55 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:55:17 +0000 (16:55 -0800)
* lt/maint-wrap-zlib:
  Wrap inflate and other zlib routines for better error reporting

Conflicts:
http-push.c
http-walker.c
sha1_file.c

1  2 
builtin-apply.c
builtin-pack-objects.c
builtin-unpack-objects.c
cache.h
http-push.c
http-walker.c
index-pack.c
sha1_file.c

diff --cc builtin-apply.c
Simple merge
Simple merge
Simple merge
diff --cc cache.h
Simple merge
diff --cc http-push.c
index 6ad853e2d01b4ee3b3ee282b30b8b7f374ae3d47,6d977ea6e17ce3a03e47fbfdbc83f8d33f6dd94b..cb5bf95a736c571259aef51884cc20e4169bf707
@@@ -209,8 -208,8 +209,8 @@@ static size_t fwrite_sha1_file(void *pt
        do {
                request->stream.next_out = expn;
                request->stream.avail_out = sizeof(expn);
-               request->zret = inflate(&request->stream, Z_SYNC_FLUSH);
+               request->zret = git_inflate(&request->stream, Z_SYNC_FLUSH);
 -              SHA1_Update(&request->c, expn,
 +              git_SHA1_Update(&request->c, expn,
                            sizeof(expn) - request->stream.avail_out);
        } while (request->stream.avail_in && request->zret == Z_OK);
        data_received++;
@@@ -269,9 -268,9 +269,9 @@@ static void start_fetch_loose(struct tr
  
        memset(&request->stream, 0, sizeof(request->stream));
  
-       inflateInit(&request->stream);
+       git_inflate_init(&request->stream);
  
 -      SHA1_Init(&request->c);
 +      git_SHA1_Init(&request->c);
  
        url = xmalloc(strlen(remote->url) + 50);
        request->url = xmalloc(strlen(remote->url) + 50);
           file; also rewind to the beginning of the local file. */
        if (prev_read == -1) {
                memset(&request->stream, 0, sizeof(request->stream));
-               inflateInit(&request->stream);
+               git_inflate_init(&request->stream);
 -              SHA1_Init(&request->c);
 +              git_SHA1_Init(&request->c);
                if (prev_posn>0) {
                        prev_posn = 0;
                        lseek(request->local_fileno, 0, SEEK_SET);
@@@ -742,8 -741,8 +742,8 @@@ static void finish_request(struct trans
                        if (request->http_code == 416)
                                fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
  
-                       inflateEnd(&request->stream);
+                       git_inflate_end(&request->stream);
 -                      SHA1_Final(request->real_sha1, &request->c);
 +                      git_SHA1_Final(request->real_sha1, &request->c);
                        if (request->zret != Z_STREAM_END) {
                                unlink(request->tmpfile);
                        } else if (hashcmp(request->obj->sha1, request->real_sha1)) {
diff --cc http-walker.c
index 7271c7d19d3b08ef76c9c868ae57f6872f6186d0,747d3adef884ec4d5c0370fc5c086e1904a7d442..0dbad3c888c6c9441af4d9550fd147ecb5b1aaf3
@@@ -82,8 -82,8 +82,8 @@@ static size_t fwrite_sha1_file(void *pt
        do {
                obj_req->stream.next_out = expn;
                obj_req->stream.avail_out = sizeof(expn);
-               obj_req->zret = inflate(&obj_req->stream, Z_SYNC_FLUSH);
+               obj_req->zret = git_inflate(&obj_req->stream, Z_SYNC_FLUSH);
 -              SHA1_Update(&obj_req->c, expn,
 +              git_SHA1_Update(&obj_req->c, expn,
                            sizeof(expn) - obj_req->stream.avail_out);
        } while (obj_req->stream.avail_in && obj_req->zret == Z_OK);
        data_received++;
@@@ -142,9 -142,9 +142,9 @@@ static void start_object_request(struc
  
        memset(&obj_req->stream, 0, sizeof(obj_req->stream));
  
-       inflateInit(&obj_req->stream);
+       git_inflate_init(&obj_req->stream);
  
 -      SHA1_Init(&obj_req->c);
 +      git_SHA1_Init(&obj_req->c);
  
        url = xmalloc(strlen(obj_req->repo->base) + 51);
        obj_req->url = xmalloc(strlen(obj_req->repo->base) + 51);
           file; also rewind to the beginning of the local file. */
        if (prev_read == -1) {
                memset(&obj_req->stream, 0, sizeof(obj_req->stream));
-               inflateInit(&obj_req->stream);
+               git_inflate_init(&obj_req->stream);
 -              SHA1_Init(&obj_req->c);
 +              git_SHA1_Init(&obj_req->c);
                if (prev_posn>0) {
                        prev_posn = 0;
                        lseek(obj_req->local, 0, SEEK_SET);
@@@ -243,8 -243,8 +243,8 @@@ static void finish_object_request(struc
                return;
        }
  
-       inflateEnd(&obj_req->stream);
+       git_inflate_end(&obj_req->stream);
 -      SHA1_Final(obj_req->real_sha1, &obj_req->c);
 +      git_SHA1_Final(obj_req->real_sha1, &obj_req->c);
        if (obj_req->zret != Z_STREAM_END) {
                unlink(obj_req->tmpfile);
                return;
diff --cc index-pack.c
Simple merge
diff --cc sha1_file.c
index f08493f039fa28c90e3edc708bbcf0a527e4f659,71c2282c9c56a00be75e3bc395e6e695dae229f2..360f7e5a028b4842b152f1fcbd9f39f3a8623b5c
@@@ -1356,11 -1342,9 +1356,11 @@@ unsigned long get_size_from_delta(struc
                curpos += stream.next_in - in;
        } while ((st == Z_OK || st == Z_BUF_ERROR) &&
                 stream.total_out < sizeof(delta_head));
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
 -      if ((st != Z_STREAM_END) && stream.total_out != sizeof(delta_head))
 -              die("delta data unpack-initial failed");
 +      if ((st != Z_STREAM_END) && stream.total_out != sizeof(delta_head)) {
 +              error("delta data unpack-initial failed");
 +              return 0;
 +      }
  
        /* Examine the initial part of the delta to figure out
         * the result size.