pack-objects: get rid of reuse_cached_pack
This capability is practically never useful, and therefore never tested, because it is fairly unlikely that the requested pack will be already available. Furthermore it is of little gain over the ability to reuse existing pack data. In fact the ability to change delta type on the fly when reusing delta data is a nice thing that has almost no cost and allows greater backward compatibility with a client's capabilities than if the client is blindly sent a whole pack without any discrimination. And this "feature" is simply in the way of other cleanups. Let's get rid of it. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nicolas Pitre committed
Apr 16, 2007 at 12:30 UTC
f7ae6a930a3c5d501439cdba98417af747350738
1 file changed
+14
-72
builtin-pack-objects.c
+14
-72
@@ -1445,60 +1445,6 @@ static void prepare_pack(int window, int depth)
1445
free(delta_list);
1446
}
1447
1448
-static int reuse_cached_pack(unsigned char *sha1)
1449
-{
1450
- static const char cache[] = "pack-cache/pack-%s.%s";
1451
- char *cached_pack, *cached_idx;
1452
- int ifd, ofd, ifd_ix = -1;
1453
-
1454
- cached_pack = git_path(cache, sha1_to_hex(sha1), "pack");
1455
- ifd = open(cached_pack, O_RDONLY);
1456
- if (ifd < 0)
1457
- return 0;
1458
-
1459
- if (!pack_to_stdout) {
1460
- cached_idx = git_path(cache, sha1_to_hex(sha1), "idx");
1461
- ifd_ix = open(cached_idx, O_RDONLY);
1462
- if (ifd_ix < 0) {
1463
- close(ifd);
1464
- return 0;
1465
- }
1466
- }
1467
-
1468
- if (progress)
1469
- fprintf(stderr, "Reusing %u objects pack %s\n", nr_objects,
1470
- sha1_to_hex(sha1));
1471
-
1472
- if (pack_to_stdout) {
1473
- if (copy_fd(ifd, 1))
1474
- exit(1);
1475
- close(ifd);
1476
- }
1477
- else {
1478
- char name[PATH_MAX];
1479
- snprintf(name, sizeof(name),
1480
- "%s-%s.%s", base_name, sha1_to_hex(sha1), "pack");
1481
- ofd = open(name, O_CREAT | O_EXCL | O_WRONLY, 0666);
1482
- if (ofd < 0)
1483
- die("unable to open %s (%s)", name, strerror(errno));
1484
- if (copy_fd(ifd, ofd))
1485
- exit(1);
1486
- close(ifd);
1487
-
1488
- snprintf(name, sizeof(name),
1489
- "%s-%s.%s", base_name, sha1_to_hex(sha1), "idx");
1490
- ofd = open(name, O_CREAT | O_EXCL | O_WRONLY, 0666);
1491
- if (ofd < 0)
1492
- die("unable to open %s (%s)", name, strerror(errno));
1493
- if (copy_fd(ifd_ix, ofd))
1494
- exit(1);
1495
- close(ifd_ix);
1496
- puts(sha1_to_hex(sha1));
1497
- }
1498
-
1499
- return 1;
1500
-}
1501
-
1448
static void progress_interval(int signum)
1449
{
1450
progress_update = 1;
@@ -1618,6 +1564,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1564
SHA_CTX ctx;
1565
int depth = 10;
1566
struct object_entry **list;
1567
+ off_t last_obj_offset;
1568
int use_internal_rev_list = 0;
1569
int thin = 0;
1570
uint32_t i;
@@ -1779,24 +1726,19 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1726
if (progress && (nr_objects != nr_result))
1727
fprintf(stderr, "Result has %u objects.\n", nr_result);
1728
1782
- if (reuse_cached_pack(object_list_sha1))
1783
- ;
1784
- else {
1785
- off_t last_obj_offset;
1786
- if (nr_result)
1787
- prepare_pack(window, depth);
1788
- if (progress == 1 && pack_to_stdout) {
1789
- /* the other end usually displays progress itself */
1790
- struct itimerval v = {{0,},};
1791
- setitimer(ITIMER_REAL, &v, NULL);
1792
- signal(SIGALRM, SIG_IGN );
1793
- progress_update = 0;
1794
- }
1795
- last_obj_offset = write_pack_file();
1796
- if (!pack_to_stdout) {
1797
- write_index_file(last_obj_offset);
1798
- puts(sha1_to_hex(object_list_sha1));
1799
- }
1729
+ if (nr_result)
1730
+ prepare_pack(window, depth);
1731
+ if (progress == 1 && pack_to_stdout) {
1732
+ /* the other end usually displays progress itself */
1733
+ struct itimerval v = {{0,},};
1734
+ setitimer(ITIMER_REAL, &v, NULL);
1735
+ signal(SIGALRM, SIG_IGN );
1736
+ progress_update = 0;
1737
+ }
1738
+ last_obj_offset = write_pack_file();
1739
+ if (!pack_to_stdout) {
1740
+ write_index_file(last_obj_offset);
1741
+ puts(sha1_to_hex(object_list_sha1));
1742
}
1743
if (progress)
1744
fprintf(stderr, "Total %u (delta %u), reused %u (delta %u)\n",