test format-patch -s: make sure MIME content type is shown as needed
[gitweb.git] / builtin-pack-objects.c
index 9b3ef94c4cea6eba9d79feb5c6647deb2e149daa..12509faa777bb2903e98c79a98be151380911b87 100644 (file)
@@ -1389,21 +1389,25 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
        if (!delta_buf)
                return 0;
 
-       if (trg_entry->delta_data) {
+       if (trg_entry->delta) {
                /* Prefer only shallower same-sized deltas. */
                if (delta_size == trg_entry->delta_size &&
                    src->depth + 1 >= trg->depth) {
                        free(delta_buf);
                        return 0;
                }
-               delta_cache_size -= trg_entry->delta_size;
-               free(trg_entry->delta_data);
-               trg_entry->delta_data = NULL;
        }
+
        trg_entry->delta = src_entry;
        trg_entry->delta_size = delta_size;
        trg->depth = src->depth + 1;
 
+       if (trg_entry->delta_data) {
+               delta_cache_size -= trg_entry->delta_size;
+               free(trg_entry->delta_data);
+               trg_entry->delta_data = NULL;
+       }
+
        if (delta_cacheable(src_size, trg_size, delta_size)) {
                trg_entry->delta_data = xrealloc(delta_buf, delta_size);
                delta_cache_size += trg_entry->delta_size;