Skip to content

Commit

Permalink
Fix delta "sliding window" code
Browse files Browse the repository at this point in the history
When Junio fixed the lack of a successful error code from try_delta(),
that uncovered an off-by-one error in the caller.

Also, some testing made it clear that we now find a lot more deltas,
because we used to (incorrectly) break early on bogus "failure"
cases.
  • Loading branch information
Linus Torvalds committed Jun 26, 2005
1 parent eb41ab1 commit 78817c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,12 @@ static void find_deltas(struct object_entry **list, int window)
n->data = read_sha1_file(entry->sha1, type, &size);
if (size != entry->size)
die("object %s inconsistent object length (%lu vs %lu)", sha1_to_hex(entry->sha1), size, entry->size);
for (j = 0; j < window; j++) {
unsigned int other_idx = idx - 1 - j;
j = window;
while (--j > 0) {
unsigned int other_idx = idx + j;
struct unpacked *m;
if (other_idx < 0)
other_idx += window;
if (other_idx >= window)
other_idx -= window;
m = array + other_idx;
if (!m->entry)
break;
Expand Down

0 comments on commit 78817c1

Please sign in to comment.