X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=pack-write.c;fp=pack-write.c;h=9cd3bfbb4b3859cbbdc1b9375ea95f511fffc94e;hb=3c9fc074c220d5d1d2173c84cc6ae57d750e2a2c;hp=92e7eefb405c1df9a91dbe003a0b2fe1c29cfc69;hpb=fb956c1f44b5c99273eb9e3850717c8b489ff78f;p=git.git diff --git a/pack-write.c b/pack-write.c index 92e7eefb4..9cd3bfbb4 100644 --- a/pack-write.c +++ b/pack-write.c @@ -16,9 +16,25 @@ static int sha1_compare(const void *_a, const void *_b) return hashcmp(a->sha1, b->sha1); } +static int cmp_uint32(const void *a_, const void *b_) +{ + uint32_t a = *((uint32_t *)a_); + uint32_t b = *((uint32_t *)b_); + + return (a < b) ? -1 : (a != b); +} + static int need_large_offset(off_t offset, const struct pack_idx_option *opts) { - return (offset >> 31) || (opts->off32_limit < offset); + uint32_t ofsval; + + if ((offset >> 31) || (opts->off32_limit < offset)) + return 1; + if (!opts->anomaly_nr) + return 0; + ofsval = offset; + return !!bsearch(&ofsval, opts->anomaly, opts->anomaly_nr, + sizeof(ofsval), cmp_uint32); } /*