summaryrefslogtreecommitdiff
path: root/pack-objects.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 01:29:23 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 01:29:23 (GMT)
commit78817c15de0dfb408d1e35a2f692f54dc51e80a3 (patch)
tree35370170f660f0fd308f7d45a510e5176b839903 /pack-objects.c
parenteb41ab11e8eaa1bd71a4413d71583d72dd181b33 (diff)
downloadgit-78817c15de0dfb408d1e35a2f692f54dc51e80a3.zip
git-78817c15de0dfb408d1e35a2f692f54dc51e80a3.tar.gz
git-78817c15de0dfb408d1e35a2f692f54dc51e80a3.tar.bz2
Fix delta "sliding window" code
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.
Diffstat (limited to 'pack-objects.c')
-rw-r--r--pack-objects.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 68c7e59..dfa9d44 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -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;