Skip to content

Commit b7a28f7

Browse files
Nicolas Pitregitster
authored andcommitted
pack-objects: fix delta cache size accounting
The wrong value was substracted from delta_cache_size when replacing a cached delta, as trg_entry->delta_size was used after the old size had been replaced by the new size. Noticed by Linus. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2099bca commit b7a28f7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

builtin-pack-objects.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,6 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
14221422
}
14231423
}
14241424

1425-
trg_entry->delta = src_entry;
1426-
trg_entry->delta_size = delta_size;
1427-
trg->depth = src->depth + 1;
1428-
14291425
/*
14301426
* Handle memory allocation outside of the cache
14311427
* accounting lock. Compiler will optimize the strangeness
@@ -1439,14 +1435,18 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
14391435
trg_entry->delta_data = NULL;
14401436
}
14411437
if (delta_cacheable(src_size, trg_size, delta_size)) {
1442-
delta_cache_size += trg_entry->delta_size;
1438+
delta_cache_size += delta_size;
14431439
cache_unlock();
14441440
trg_entry->delta_data = xrealloc(delta_buf, delta_size);
14451441
} else {
14461442
cache_unlock();
14471443
free(delta_buf);
14481444
}
14491445

1446+
trg_entry->delta = src_entry;
1447+
trg_entry->delta_size = delta_size;
1448+
trg->depth = src->depth + 1;
1449+
14501450
return 1;
14511451
}
14521452

0 commit comments

Comments
 (0)