Commit Diff


commit - 7cda4b11fea3fbaea57848853f7e6fe7204812ee9f4477f2303e7e83d50d11ae
commit + e29770f443934beabfe006e390a78f476c4ea84595f040b70e2d6b7954381e03
blob - f3d4a58b959613b05d584b861277117559333ecc4ec25b8a47392da7f9bf7528
blob + 7f0dad96216b083f7b96ee9146b736efb1ab9bb5a1f98dcb998b3cef0e5f5873
--- lib/pack_create.c	
+++ lib/pack_create.c	
@@ -598,6 +598,25 @@ pick_deltas(struct got_pack_meta **meta, int nmeta, in
 			n->dtab = NULL;
 		}
 
+		/*
+		 * Do not deltify objects which are already packed and not
+		 * deltified. The object is likely a delta-base for deltas
+		 * we are reusing, and deltifying bases is a waste of time.
+		 * We can just copy them to our new pack file directly.
+		 * In the worst case we could end up using a bit more disk
+		 * space. But our newly created pack will be done sooner.
+		 *
+		 * We cannot skip deltified objects here because we cannot
+		 * tell whether their base object will be included in the
+		 * pack file we are generating.
+		 */
+		if ((raw->flags & GOT_RAW_OBJ_FLAG_PACKED) &&
+		    (raw->flags & GOT_RAW_OBJ_FLAG_DELTIFIED) == 0) {
+			got_object_raw_close(raw);
+			raw = NULL;
+			continue;
+		}
+
 		best_size = raw->size;
 		best_ndeltas = 0;
 		for (j = MAX(0, i - max_base_candidates); j < i; j++) {