Skip to content

Commit c3b1c1e

Browse files
committed
Merge branch 'nd/slim-index-pack-memory-usage'
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
2 parents 486b51b + f0e7f11 commit c3b1c1e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

builtin/index-pack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,9 @@ static int compare_ofs_delta_bases(off_t offset1, off_t offset2,
616616
int cmp = type1 - type2;
617617
if (cmp)
618618
return cmp;
619-
return offset1 - offset2;
619+
return offset1 < offset2 ? -1 :
620+
offset1 > offset2 ? 1 :
621+
0;
620622
}
621623

622624
static int find_ofs_delta(const off_t offset, enum object_type type)
@@ -1051,7 +1053,9 @@ static int compare_ofs_delta_entry(const void *a, const void *b)
10511053
const struct ofs_delta_entry *delta_a = a;
10521054
const struct ofs_delta_entry *delta_b = b;
10531055

1054-
return delta_a->offset - delta_b->offset;
1056+
return delta_a->offset < delta_b->offset ? -1 :
1057+
delta_a->offset > delta_b->offset ? 1 :
1058+
0;
10551059
}
10561060

10571061
static int compare_ref_delta_entry(const void *a, const void *b)

0 commit comments

Comments
 (0)