27
* nonzero if already written.
28
*/
29
unsigned int depth; /* delta depth */
30
- unsigned int delta_limit; /* base adjustment for in-pack delta */
30
unsigned int hash; /* name hint hash */
31
enum object_type type;
32
enum object_type in_pack_type; /* could be delta */
1171
sha1_to_hex(entry->sha1));
1172
}
1173
1175
-static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
1176
-{
1177
- struct object_entry *child = me->delta_child;
1178
- unsigned int m = n;
1179
- while (child) {
1180
- unsigned int c = check_delta_limit(child, n + 1);
1181
- if (m < c)
1182
- m = c;
1183
- child = child->delta_sibling;
1184
- }
1185
- return m;
1186
-}
1187
-
1174
static void get_object_details(void)
1175
{
1176
uint32_t i;
1179
prepare_pack_ix();
1180
for (i = 0, entry = objects; i < nr_objects; i++, entry++)
1181
check_object(entry);
1196
-
1197
- if (nr_objects == nr_result) {
1198
- /*
1199
- * Depth of objects that depend on the entry -- this
1200
- * is subtracted from depth-max to break too deep
1201
- * delta chain because of delta data reusing.
1202
- * However, we loosen this restriction when we know we
1203
- * are creating a thin pack -- it will have to be
1204
- * expanded on the other end anyway, so do not
1205
- * artificially cut the delta chain and let it go as
1206
- * deep as it wants.
1207
- */
1208
- for (i = 0, entry = objects; i < nr_objects; i++, entry++)
1209
- if (!entry->delta && entry->delta_child)
1210
- entry->delta_limit =
1211
- check_delta_limit(entry, 1);
1212
- }
1182
}
1183
1184
typedef int (*entry_sort_t)(const struct object_entry *, const struct object_entry *);
1291
trg_entry->in_pack_type != OBJ_OFS_DELTA)
1292
return 0;
1293
1325
- /*
1326
- * If the current object is at pack edge, take the depth the
1327
- * objects that depend on the current object into account --
1328
- * otherwise they would become too deep.
1329
- */
1330
- if (trg_entry->delta_child) {
1331
- if (max_depth <= trg_entry->delta_limit)
1332
- return 0;
1333
- max_depth -= trg_entry->delta_limit;
1334
- }
1294
+ /* Let's not bust the allowed depth. */
1295
if (src_entry->depth >= max_depth)
1296
return 0;
1297
1338
return 1;
1339
}
1340
1381
-static void progress_interval(int signum)
1341
+static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
1342
{
1383
- progress_update = 1;
1343
+ struct object_entry *child = me->delta_child;
1344
+ unsigned int m = n;
1345
+ while (child) {
1346
+ unsigned int c = check_delta_limit(child, n + 1);
1347
+ if (m < c)
1348
+ m = c;
1349
+ child = child->delta_sibling;
1350
+ }
1351
+ return m;
1352
}
1353
1354
static void find_deltas(struct object_entry **list, int window, int depth)
1357
unsigned int array_size = window * sizeof(struct unpacked);
1358
struct unpacked *array;
1359
unsigned last_percent = 999;
1360
+ int max_depth;
1361
1362
if (!nr_objects)
1363
return;
1398
n->data = NULL;
1399
n->entry = entry;
1400
1401
+ /*
1402
+ * If the current object is at pack edge, take the depth the
1403
+ * objects that depend on the current object into account
1404
+ * otherwise they would become too deep.
1405
+ */
1406
+ max_depth = depth;
1407
+ if (entry->delta_child) {
1408
+ max_depth -= check_delta_limit(entry, 0);
1409
+ if (max_depth <= 0)
1410
+ goto next;
1411
+ }
1412
+
1413
j = window;
1414
while (--j > 0) {
1415
uint32_t other_idx = idx + j;
1419
m = array + other_idx;
1420
if (!m->entry)
1421
break;
1441
- if (try_delta(n, m, depth) < 0)
1422
+ if (try_delta(n, m, max_depth) < 0)
1423
break;
1424
}
1425
+
1426
/* if we made n a delta, and if n is already at max
1427
* depth, leaving it in the window is pointless. we
1428
* should evict it first.
1430
if (entry->delta && depth <= entry->depth)
1431
continue;
1432
1433
+ next:
1434
idx++;
1435
if (idx >= window)
1436
idx = 0;
1508
return 1;
1509
}
1510
1511
+static void progress_interval(int signum)
1512
+{
1513
+ progress_update = 1;
1514
+}
1515
+
1516
static void setup_progress_signal(void)
1517
{
1518
struct sigaction sa;