Skip to content

Commit

Permalink
Merge branch 'nd/slim-index-pack-memory-usage'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Jun 16, 2015
2 parents 486b51b + f0e7f11 commit c3b1c1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,9 @@ static int compare_ofs_delta_bases(off_t offset1, off_t offset2,
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)
Expand Down Expand Up @@ -1051,7 +1053,9 @@ static int compare_ofs_delta_entry(const void *a, const void *b)
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)
Expand Down

0 comments on commit c3b1c1e

Please sign in to comment.