Merge branch 'nd/slim-index-pack-memory-usage'
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Jun 2015 21:27:08 +0000 (14:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Jun 2015 21:27:08 +0000 (14:27 -0700)
An earlier optimization broke index-pack for a large object
transfer; this fixes it before the breakage hits any released
version.

* nd/slim-index-pack-memory-usage:
index-pack: fix truncation of off_t in comparison

1  2 
builtin/index-pack.c
diff --combined builtin/index-pack.c
index 7ea2020d821004569a6913d9cf550149032a1b96,06dd973a78a86de002ebc7559a34b6b743deced3..2ecfbae239c0d603aaf3359679bf3162dbd48767
@@@ -616,7 -616,9 +616,9 @@@ static int compare_ofs_delta_bases(off_
        int cmp = type1 - type2;
        if (cmp)
                return cmp;
-       return offset1 - offset2;
+       return offset1 < offset2 ? -1 :
+              offset1 > offset2 ?  1 :
+              0;
  }
  
  static int find_ofs_delta(const off_t offset, enum object_type type)
@@@ -1051,7 -1053,9 +1053,9 @@@ static int compare_ofs_delta_entry(cons
        const struct ofs_delta_entry *delta_a = a;
        const struct ofs_delta_entry *delta_b = b;
  
-       return delta_a->offset - delta_b->offset;
+       return delta_a->offset < delta_b->offset ? -1 :
+              delta_a->offset > delta_b->offset ?  1 :
+              0;
  }
  
  static int compare_ref_delta_entry(const void *a, const void *b)
@@@ -1272,6 -1276,7 +1276,6 @@@ static int write_compressed(struct sha1
        int status;
        unsigned char outbuf[4096];
  
 -      memset(&stream, 0, sizeof(stream));
        git_deflate_init(&stream, zlib_compression_level);
        stream.next_in = in;
        stream.avail_in = size;