commit - e6c1173dcf57c322cbb74af339c615c983c190f3
commit + 160bbe2e336908947c078a78e3ae58100a38e9fc
blob - 058e5043c887bbd0abf19e56bf3c6d7dfe952f16
blob + b4e4dc21f9308f616d81790239027df7bcacdb7b
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
SHA1_CTX ctx;
uint8_t packidx_hash[SHA1_DIGEST_LENGTH];
ssize_t r, w;
- int pass, have_ref_deltas = 0;
+ int pass, have_ref_deltas = 0, first_delta_idx = -1;
size_t mapoff = 0;
/* Check pack file header. */
obj->type == GOT_OBJ_TYPE_TAG) {
obj->valid = 1;
nloose++;
- } else if (obj->type == GOT_OBJ_TYPE_REF_DELTA)
- have_ref_deltas = 1;
+ } else {
+ if (first_delta_idx == -1)
+ first_delta_idx = i;
+ if (obj->type == GOT_OBJ_TYPE_REF_DELTA)
+ have_ref_deltas = 1;
+ }
}
nvalid = nloose;
+ if (first_delta_idx == -1)
+ first_delta_idx = 0;
+
/* In order to resolve ref deltas we need an in-progress pack index. */
if (have_ref_deltas)
make_packidx(&packidx, nobj, objects);
* Offset deltas can always be resolved in one pass
* unless the packfile is corrupt.
*/
- for (i = 0; i < nobj; i++) {
+ for (i = first_delta_idx; i < nobj; i++) {
obj = &objects[i];
if (obj->type != GOT_OBJ_TYPE_REF_DELTA &&
obj->type != GOT_OBJ_TYPE_OFFSET_DELTA)