{"thread":{"id":"2044","subject":"[PATCH] Don't fetch objects that exist in the local repository","startedAt":"2005-10-07T22:01:51Z","lastAt":"2005-10-07T23:25:54Z","messageCount":4,"participants":["Nick Hengeveld","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9814","messageId":"20051007220151.GB4989@reactrix.com","threadId":"2044","inReplyTo":null,"subject":"[PATCH] Don't fetch objects that exist in the local repository","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-10-07T22:01:51Z","receivedAt":"2005-10-07T22:01:51Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Be sure not to fetch objects that already exist in the local repository.\nThe main process loop no longer performs this check, http-fetch now checks\nprior to starting a new request queue entry and when fetch_object() is called,\nand local-fetch now checks when fetch_object() is called.\n\nAs discussed in this thread: http://marc.theaimsgroup.com/?t=112854890500001\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\n fetch.c       |    2 +-\n http-fetch.c  |   10 +++++++++-\n local-fetch.c |    5 ++++-\n 3 files changed, 14 insertions(+), 3 deletions(-)\n\n41b78748fe458224fc1d621f5f0a4df2a3ac3253\ndiff --git a/fetch.c b/fetch.c\n--- a/fetch.c\n+++ b/fetch.c\n@@ -165,7 +165,7 @@ static int loop(void)\n \t\t * the queue because we needed to fetch it first.\n \t\t */\n \t\tif (! (obj->flags & TO_SCAN)) {\n-\t\t\tif (!has_sha1_file(obj->sha1) && fetch(obj->sha1)) {\n+\t\t\tif (fetch(obj->sha1)) {\n \t\t\t\treport_missing(obj->type\n \t\t\t\t\t       ? obj->type\n \t\t\t\t\t       : \"object\", obj->sha1);\ndiff --git a/http-fetch.c b/http-fetch.c\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -489,7 +489,10 @@ void process_request_queue()\n \n \twhile (active_requests < max_requests && request != NULL) {\n \t\tif (request->state == WAITING) {\n-\t\t\tstart_request(request);\n+\t\t\tif (has_sha1_file(request->sha1))\n+\t\t\t\trelease_request(request);\n+\t\t\telse\n+\t\t\t\tstart_request(request);\n \t\t\tcurl_multi_perform(curlm, &num_transfers);\n \t\t}\n \t\trequest = request->next;\n@@ -890,6 +893,11 @@ static int fetch_object(struct alt_base \n \tif (request == NULL)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n+\tif (has_sha1_file(request->sha1)) {\n+\t\trelease_request(request);\n+\t\treturn 0;\n+\t}\n+\n #ifdef USE_CURL_MULTI\n \tint num_transfers;\n \twhile (request->state == WAITING) {\ndiff --git a/local-fetch.c b/local-fetch.c\n--- a/local-fetch.c\n+++ b/local-fetch.c\n@@ -166,7 +166,10 @@ static int fetch_file(const unsigned cha\n \n int fetch(unsigned char *sha1)\n {\n-\treturn fetch_file(sha1) && fetch_pack(sha1);\n+\tif (has_sha1_file(sha1))\n+\t\treturn 0;\n+\telse\n+\t\treturn fetch_file(sha1) && fetch_pack(sha1);\n }\n \n int fetch_ref(char *ref, unsigned char *sha1)\n"},{"id":"9816","messageId":"Pine.LNX.4.63.0510080047500.20922@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2044","inReplyTo":"20051007220151.GB4989@reactrix.com","subject":"Re: [PATCH] Don't fetch objects that exist in the local repository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-07T22:50:53Z","receivedAt":"2005-10-07T22:50:53Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 7 Oct 2005, Nick Hengeveld wrote:\n\n> Be sure not to fetch objects that already exist in the local repository.\n\nReally? I seem to recall a dispute I had with Linus that this is \nunacceptable. He seems worried about incomplete fetches.\n\nOnly objects which are descendants of refs are safe, since the refs are \nwritten only after the objects were fetched successfully.\n\nCiao,\nDscho\n"},{"id":"9818","messageId":"20051007230856.GC4989@reactrix.com","threadId":"2044","inReplyTo":"Pine.LNX.4.63.0510080047500.20922@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Don't fetch objects that exist in the local repository","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-10-07T23:08:56Z","receivedAt":"2005-10-07T23:08:56Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"On Sat, Oct 08, 2005 at 12:50:53AM +0200, Johannes Schindelin wrote:\n\n> > Be sure not to fetch objects that already exist in the local repository.\n> \n> Really? I seem to recall a dispute I had with Linus that this is \n> unacceptable. He seems worried about incomplete fetches.\n\nThis patch just moved an existing check from the process queue loop to the\nappropriate places in transport-specific code to prevent the transport\nfrom transferring an object that appeared in the local repository after\nit was prefetched (eg. via a pack), and to make sure that all objects that\nwere prefetched are subsequently fetched so the transport can perform the\nappropriate cleanup.\n\n-- \nFor a successful technology, reality must take precedence over public\nrelations, for nature cannot be fooled.\n"},{"id":"9819","messageId":"Pine.LNX.4.63.0510080125210.21577@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2044","inReplyTo":"20051007230856.GC4989@reactrix.com","subject":"Re: [PATCH] Don't fetch objects that exist in the local repository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-07T23:25:54Z","receivedAt":"2005-10-07T23:25:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 7 Oct 2005, Nick Hengeveld wrote:\n\n> On Sat, Oct 08, 2005 at 12:50:53AM +0200, Johannes Schindelin wrote:\n> \n> > > Be sure not to fetch objects that already exist in the local repository.\n> > \n> > Really? I seem to recall a dispute I had with Linus that this is \n> > unacceptable. He seems worried about incomplete fetches.\n> \n> This patch just moved an existing check from the process queue loop to the\n> appropriate places in transport-specific code to prevent the transport\n> from transferring an object that appeared in the local repository after\n> it was prefetched (eg. via a pack), and to make sure that all objects that\n> were prefetched are subsequently fetched so the transport can perform the\n> appropriate cleanup.\n\nAh! Okay, now I understand.\n\nThanks,\nDscho\n"}]}