{"thread":{"id":"7687","subject":"[PATCH 5/9] pack-objects: get rid of reuse_cached_pack","startedAt":"2007-04-16T16:14:52Z","lastAt":"2007-04-16T16:14:52Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"39542","messageId":"S1030829AbXDPQO7/20070416161459Z+65@vger.kernel.org","threadId":"7687","inReplyTo":null,"subject":"[PATCH 5/9] pack-objects: get rid of reuse_cached_pack","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-04-16T16:14:52Z","receivedAt":"2007-04-16T16:14:52Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"This capability is practically never useful, and therefore never tested,\nbecause it is fairly unlikely that the requested pack will be already\navailable.  Furthermore it is of little gain over the ability to reuse\nexisting pack data.\n\nIn fact the ability to change delta type on the fly when reusing delta\ndata is a nice thing that has almost no cost and allows greater backward\ncompatibility with a client's capabilities than if the client is blindly\nsent a whole pack without any discrimination.\n\nAnd this \"feature\" is simply in the way of other cleanups.\nLet's get rid of it.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n builtin-pack-objects.c |   86 ++++++++----------------------------------------\n 1 files changed, 14 insertions(+), 72 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 15119d6..c2f7c30 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -1445,60 +1445,6 @@ static void prepare_pack(int window, int depth)\n \tfree(delta_list);\n }\n \n-static int reuse_cached_pack(unsigned char *sha1)\n-{\n-\tstatic const char cache[] = \"pack-cache/pack-%s.%s\";\n-\tchar *cached_pack, *cached_idx;\n-\tint ifd, ofd, ifd_ix = -1;\n-\n-\tcached_pack = git_path(cache, sha1_to_hex(sha1), \"pack\");\n-\tifd = open(cached_pack, O_RDONLY);\n-\tif (ifd < 0)\n-\t\treturn 0;\n-\n-\tif (!pack_to_stdout) {\n-\t\tcached_idx = git_path(cache, sha1_to_hex(sha1), \"idx\");\n-\t\tifd_ix = open(cached_idx, O_RDONLY);\n-\t\tif (ifd_ix < 0) {\n-\t\t\tclose(ifd);\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\n-\tif (progress)\n-\t\tfprintf(stderr, \"Reusing %u objects pack %s\\n\", nr_objects,\n-\t\t\tsha1_to_hex(sha1));\n-\n-\tif (pack_to_stdout) {\n-\t\tif (copy_fd(ifd, 1))\n-\t\t\texit(1);\n-\t\tclose(ifd);\n-\t}\n-\telse {\n-\t\tchar name[PATH_MAX];\n-\t\tsnprintf(name, sizeof(name),\n-\t\t\t \"%s-%s.%s\", base_name, sha1_to_hex(sha1), \"pack\");\n-\t\tofd = open(name, O_CREAT | O_EXCL | O_WRONLY, 0666);\n-\t\tif (ofd < 0)\n-\t\t\tdie(\"unable to open %s (%s)\", name, strerror(errno));\n-\t\tif (copy_fd(ifd, ofd))\n-\t\t\texit(1);\n-\t\tclose(ifd);\n-\n-\t\tsnprintf(name, sizeof(name),\n-\t\t\t \"%s-%s.%s\", base_name, sha1_to_hex(sha1), \"idx\");\n-\t\tofd = open(name, O_CREAT | O_EXCL | O_WRONLY, 0666);\n-\t\tif (ofd < 0)\n-\t\t\tdie(\"unable to open %s (%s)\", name, strerror(errno));\n-\t\tif (copy_fd(ifd_ix, ofd))\n-\t\t\texit(1);\n-\t\tclose(ifd_ix);\n-\t\tputs(sha1_to_hex(sha1));\n-\t}\n-\n-\treturn 1;\n-}\n-\n static void progress_interval(int signum)\n {\n \tprogress_update = 1;\n@@ -1618,6 +1564,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \tSHA_CTX ctx;\n \tint depth = 10;\n \tstruct object_entry **list;\n+\toff_t last_obj_offset;\n \tint use_internal_rev_list = 0;\n \tint thin = 0;\n \tuint32_t i;\n@@ -1779,24 +1726,19 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \tif (progress && (nr_objects != nr_result))\n \t\tfprintf(stderr, \"Result has %u objects.\\n\", nr_result);\n \n-\tif (reuse_cached_pack(object_list_sha1))\n-\t\t;\n-\telse {\n-\t\toff_t last_obj_offset;\n-\t\tif (nr_result)\n-\t\t\tprepare_pack(window, depth);\n-\t\tif (progress == 1 && pack_to_stdout) {\n-\t\t\t/* the other end usually displays progress itself */\n-\t\t\tstruct itimerval v = {{0,},};\n-\t\t\tsetitimer(ITIMER_REAL, &v, NULL);\n-\t\t\tsignal(SIGALRM, SIG_IGN );\n-\t\t\tprogress_update = 0;\n-\t\t}\n-\t\tlast_obj_offset = write_pack_file();\n-\t\tif (!pack_to_stdout) {\n-\t\t\twrite_index_file(last_obj_offset);\n-\t\t\tputs(sha1_to_hex(object_list_sha1));\n-\t\t}\n+\tif (nr_result)\n+\t\tprepare_pack(window, depth);\n+\tif (progress == 1 && pack_to_stdout) {\n+\t\t/* the other end usually displays progress itself */\n+\t\tstruct itimerval v = {{0,},};\n+\t\tsetitimer(ITIMER_REAL, &v, NULL);\n+\t\tsignal(SIGALRM, SIG_IGN );\n+\t\tprogress_update = 0;\n+\t}\n+\tlast_obj_offset = write_pack_file();\n+\tif (!pack_to_stdout) {\n+\t\twrite_index_file(last_obj_offset);\n+\t\tputs(sha1_to_hex(object_list_sha1));\n \t}\n \tif (progress)\n \t\tfprintf(stderr, \"Total %u (delta %u), reused %u (delta %u)\\n\",\n-- \n1.5.1.1.781.g65e8\n"}]}