{"thread":{"id":"19466","subject":"[PATCH 02/18] http-push, http-walker: style fixes","startedAt":"2009-05-24T14:19:41Z","lastAt":"2009-05-25T12:03:55Z","messageCount":3,"participants":["Tay Ray Chuan","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":18},"messages":[{"id":"114557","messageId":"20090524221941.8670c41d.rctay89@gmail.com","threadId":"19466","inReplyTo":null,"subject":"[PATCH 02/18] http-push, http-walker: style fixes","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-05-24T14:19:41Z","receivedAt":"2009-05-24T14:19:41Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":" *spaces used as indentation have been replaced by tabs instead.\n\n *'if' and 'while' conditionals with a single line have had their curly\n  braces removed.\n\n */*\n   * We prefer this over...\n   */\n\n  /* comments like\n   * this (notice the first line)\n   */\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c   |   48 ++++++++++++++++++++-------------\n http-walker.c |   83 ++++++++++++++++++++++++++++++++++----------------------\n 2 files changed, 79 insertions(+), 52 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 83d7235..024f05b 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -276,7 +276,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \tstruct transfer_request *request = (struct transfer_request *)data;\n \tdo {\n \t\tssize_t retval = xwrite(request->local_fileno,\n-\t\t\t\t       (char *) ptr + posn, size - posn);\n+\t\t\t\t\t(char *) ptr + posn, size - posn);\n \t\tif (retval < 0)\n \t\t\treturn posn;\n \t\tposn += retval;\n@@ -289,7 +289,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t\trequest->stream.avail_out = sizeof(expn);\n \t\trequest->zret = git_inflate(&request->stream, Z_SYNC_FLUSH);\n \t\tgit_SHA1_Update(&request->c, expn,\n-\t\t\t    sizeof(expn) - request->stream.avail_out);\n+\t\t\t\tsizeof(expn) - request->stream.avail_out);\n \t} while (request->stream.avail_in && request->zret == Z_OK);\n \tdata_received++;\n \treturn size;\n@@ -323,7 +323,8 @@ static void start_fetch_loose(struct transfer_request *request)\n \t\terror(\"fd leakage in start: %d\", request->local_fileno);\n \trequest->local_fileno = open(request->tmpfile,\n \t\t\t\t     O_WRONLY | O_CREAT | O_EXCL, 0666);\n-\t/* This could have failed due to the \"lazy directory creation\";\n+\t/*\n+\t * This could have failed due to the \"lazy directory creation\";\n \t * try to mkdir the last path component.\n \t */\n \tif (request->local_fileno < 0 && errno == ENOENT) {\n@@ -353,8 +354,10 @@ static void start_fetch_loose(struct transfer_request *request)\n \turl = get_remote_object_url(repo->url, hex, 0);\n \trequest->url = xstrdup(url);\n\n-\t/* If a previous temp file is present, process what was already\n-\t   fetched. */\n+\t/*\n+\t * If a previous temp file is present, process what was already\n+\t * fetched.\n+\t */\n \tprevlocal = open(prevfile, O_RDONLY);\n \tif (prevlocal != -1) {\n \t\tdo {\n@@ -363,19 +366,20 @@ static void start_fetch_loose(struct transfer_request *request)\n \t\t\t\tif (fwrite_sha1_file(prev_buf,\n \t\t\t\t\t\t     1,\n \t\t\t\t\t\t     prev_read,\n-\t\t\t\t\t\t     request) == prev_read) {\n+\t\t\t\t\t\t     request) == prev_read)\n \t\t\t\t\tprev_posn += prev_read;\n-\t\t\t\t} else {\n+\t\t\t\telse\n \t\t\t\t\tprev_read = -1;\n-\t\t\t\t}\n \t\t\t}\n \t\t} while (prev_read > 0);\n \t\tclose(prevlocal);\n \t}\n \tunlink_or_warn(prevfile);\n\n-\t/* Reset inflate/SHA1 if there was an error reading the previous temp\n-\t   file; also rewind to the beginning of the local file. */\n+\t/*\n+\t * Reset inflate/SHA1 if there was an error reading the previous temp\n+\t * file; also rewind to the beginning of the local file.\n+\t */\n \tif (prev_read == -1) {\n \t\tmemset(&request->stream, 0, sizeof(request->stream));\n \t\tgit_inflate_init(&request->stream);\n@@ -398,8 +402,10 @@ static void start_fetch_loose(struct transfer_request *request)\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);\n\n-\t/* If we have successfully processed data from a previous fetch\n-\t   attempt, only fetch the data we don't already have. */\n+\t/*\n+\t * If we have successfully processed data from a previous fetch\n+\t * attempt, only fetch the data we don't already have.\n+\t */\n \tif (prev_posn>0) {\n \t\tif (push_verbosely)\n \t\t\tfprintf(stderr,\n@@ -514,8 +520,10 @@ static void start_fetch_packed(struct transfer_request *request)\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);\n \tslot->local = packfile;\n\n-\t/* If there is data present from a previous transfer attempt,\n-\t   resume where it left off */\n+\t/*\n+\t * If there is data present from a previous transfer attempt,\n+\t * resume where it left off\n+\t */\n \tprev_posn = ftell(packfile);\n \tif (prev_posn>0) {\n \t\tif (push_verbosely)\n@@ -778,7 +786,8 @@ static void finish_request(struct transfer_request *request)\n \t\t\taborted = 1;\n \t\t}\n \t} else if (request->state == RUN_FETCH_LOOSE) {\n-\t\tclose(request->local_fileno); request->local_fileno = -1;\n+\t\tclose(request->local_fileno);\n+\t\trequest->local_fileno = -1;\n\n \t\tif (request->curl_result != CURLE_OK &&\n \t\t    request->http_code != 416) {\n@@ -801,9 +810,8 @@ static void finish_request(struct transfer_request *request)\n \t\t\t\t\tmove_temp_to_file(\n \t\t\t\t\t\trequest->tmpfile,\n \t\t\t\t\t\trequest->filename);\n-\t\t\t\tif (request->rename == 0) {\n+\t\t\t\tif (request->rename == 0)\n \t\t\t\t\trequest->obj->flags |= (LOCAL | REMOTE);\n-\t\t\t\t}\n \t\t\t}\n \t\t}\n\n@@ -1007,8 +1015,10 @@ static int fetch_index(unsigned char *sha1)\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);\n \tslot->local = indexfile;\n\n-\t/* If there is data present from a previous transfer attempt,\n-\t   resume where it left off */\n+\t/*\n+\t * If there is data present from a previous transfer attempt,\n+\t * resume where it left off\n+\t */\n \tprev_posn = ftell(indexfile);\n \tif (prev_posn>0) {\n \t\tif (push_verbosely)\ndiff --git a/http-walker.c b/http-walker.c\nindex 7321ccc..dffb844 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -71,7 +71,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \tstruct object_request *obj_req = (struct object_request *)data;\n \tdo {\n \t\tssize_t retval = xwrite(obj_req->local,\n-\t\t\t\t       (char *) ptr + posn, size - posn);\n+\t\t\t\t\t(char *) ptr + posn, size - posn);\n \t\tif (retval < 0)\n \t\t\treturn posn;\n \t\tposn += retval;\n@@ -84,7 +84,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t\tobj_req->stream.avail_out = sizeof(expn);\n \t\tobj_req->zret = git_inflate(&obj_req->stream, Z_SYNC_FLUSH);\n \t\tgit_SHA1_Update(&obj_req->c, expn,\n-\t\t\t    sizeof(expn) - obj_req->stream.avail_out);\n+\t\t\t\tsizeof(expn) - obj_req->stream.avail_out);\n \t} while (obj_req->stream.avail_in && obj_req->zret == Z_OK);\n \tdata_received++;\n \treturn size;\n@@ -119,7 +119,8 @@ static void start_object_request(struct walker *walker,\n \t\terror(\"fd leakage in start: %d\", obj_req->local);\n \tobj_req->local = open(obj_req->tmpfile,\n \t\t\t      O_WRONLY | O_CREAT | O_EXCL, 0666);\n-\t/* This could have failed due to the \"lazy directory creation\";\n+\t/*\n+\t * This could have failed due to the \"lazy directory creation\";\n \t * try to mkdir the last path component.\n \t */\n \tif (obj_req->local < 0 && errno == ENOENT) {\n@@ -158,8 +159,10 @@ static void start_object_request(struct walker *walker,\n \tstrcpy(posn, hex + 2);\n \tstrcpy(obj_req->url, url);\n\n-\t/* If a previous temp file is present, process what was already\n-\t   fetched. */\n+\t/*\n+\t * If a previous temp file is present, process what was already\n+\t * fetched.\n+\t */\n \tprevlocal = open(prevfile, O_RDONLY);\n \tif (prevlocal != -1) {\n \t\tdo {\n@@ -168,19 +171,20 @@ static void start_object_request(struct walker *walker,\n \t\t\t\tif (fwrite_sha1_file(prev_buf,\n \t\t\t\t\t\t     1,\n \t\t\t\t\t\t     prev_read,\n-\t\t\t\t\t\t     obj_req) == prev_read) {\n+\t\t\t\t\t\t     obj_req) == prev_read)\n \t\t\t\t\tprev_posn += prev_read;\n-\t\t\t\t} else {\n+\t\t\t\telse\n \t\t\t\t\tprev_read = -1;\n-\t\t\t\t}\n \t\t\t}\n \t\t} while (prev_read > 0);\n \t\tclose(prevlocal);\n \t}\n \tunlink_or_warn(prevfile);\n\n-\t/* Reset inflate/SHA1 if there was an error reading the previous temp\n-\t   file; also rewind to the beginning of the local file. */\n+\t/*\n+\t * Reset inflate/SHA1 if there was an error reading the previous temp\n+\t * file; also rewind to the beginning of the local file.\n+\t */\n \tif (prev_read == -1) {\n \t\tmemset(&obj_req->stream, 0, sizeof(obj_req->stream));\n \t\tgit_inflate_init(&obj_req->stream);\n@@ -203,8 +207,10 @@ static void start_object_request(struct walker *walker,\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, data->no_pragma_header);\n\n-\t/* If we have successfully processed data from a previous fetch\n-\t   attempt, only fetch the data we don't already have. */\n+\t/*\n+\t * If we have successfully processed data from a previous fetch\n+\t * attempt, only fetch the data we don't already have.\n+\t */\n \tif (prev_posn>0) {\n \t\tif (walker->get_verbosely)\n \t\t\tfprintf(stderr,\n@@ -221,7 +227,8 @@ static void start_object_request(struct walker *walker,\n \tif (!start_active_slot(slot)) {\n \t\tobj_req->state = ABORTED;\n \t\tobj_req->slot = NULL;\n-\t\tclose(obj_req->local); obj_req->local = -1;\n+\t\tclose(obj_req->local);\n+\t\tobj_req->local = -1;\n \t\tfree(obj_req->url);\n \t\treturn;\n \t}\n@@ -231,7 +238,8 @@ static void finish_object_request(struct object_request *obj_req)\n {\n \tstruct stat st;\n\n-\tclose(obj_req->local); obj_req->local = -1;\n+\tclose(obj_req->local);\n+\tobj_req->local = -1;\n\n \tif (obj_req->http_code == 416) {\n \t\tfprintf(stderr, \"Warning: requested range invalid; we may already have all the data.\\n\");\n@@ -350,9 +358,8 @@ static void prefetch(struct walker *walker, unsigned char *sha1)\n \t\tobject_queue_head = newreq;\n \t} else {\n \t\ttail = object_queue_head;\n-\t\twhile (tail->next != NULL) {\n+\t\twhile (tail->next != NULL)\n \t\t\ttail = tail->next;\n-\t\t}\n \t\ttail->next = newreq;\n \t}\n\n@@ -401,8 +408,10 @@ static int fetch_index(struct walker *walker, struct alt_base *repo, unsigned ch\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, data->no_pragma_header);\n \tslot->local = indexfile;\n\n-\t/* If there is data present from a previous transfer attempt,\n-\t   resume where it left off */\n+\t/*\n+\t * If there is data present from a previous transfer attempt,\n+\t * resume where it left off\n+\t */\n \tprev_posn = ftell(indexfile);\n \tif (prev_posn>0) {\n \t\tif (walker->get_verbosely)\n@@ -504,7 +513,8 @@ static void process_alternates_response(void *callback_data)\n \t\t\tstruct alt_base *newalt;\n \t\t\tchar *target = NULL;\n \t\t\tif (data[i] == '/') {\n-\t\t\t\t/* This counts\n+\t\t\t\t/*\n+\t\t\t\t * This counts\n \t\t\t\t * http://git.host/pub/scm/linux.git/\n \t\t\t\t * -----------here^\n \t\t\t\t * so memcpy(dst, base, serverlen) will\n@@ -517,7 +527,8 @@ static void process_alternates_response(void *callback_data)\n \t\t\t\t\tokay = 1;\n \t\t\t\t}\n \t\t\t} else if (!memcmp(data + i, \"../\", 3)) {\n-\t\t\t\t/* Relative URL; chop the corresponding\n+\t\t\t\t/*\n+\t\t\t\t * Relative URL; chop the corresponding\n \t\t\t\t * number of subpath from base (and ../\n \t\t\t\t * from data), and concatenate the result.\n \t\t\t\t *\n@@ -546,7 +557,7 @@ static void process_alternates_response(void *callback_data)\n \t\t\t\t}\n \t\t\t\t/* If the server got removed, give up. */\n \t\t\t\tokay = strchr(base, ':') - base + 3 <\n-\t\t\t\t\tserverlen;\n+\t\t\t\t       serverlen;\n \t\t\t} else if (alt_req->http_specific) {\n \t\t\t\tchar *colon = strchr(data + i, ':');\n \t\t\t\tchar *slash = strchr(data + i, '/');\n@@ -590,9 +601,11 @@ static void fetch_alternates(struct walker *walker, const char *base)\n \tstruct alternates_request alt_req;\n \tstruct walker_data *cdata = walker->data;\n\n-\t/* If another request has already started fetching alternates,\n-\t   wait for them to arrive and return to processing this request's\n-\t   curl message */\n+\t/*\n+\t * If another request has already started fetching alternates,\n+\t * wait for them to arrive and return to processing this request's\n+\t * curl message\n+\t */\n #ifdef USE_CURL_MULTI\n \twhile (cdata->got_alternates == 0) {\n \t\tstep_active_slots();\n@@ -612,8 +625,10 @@ static void fetch_alternates(struct walker *walker, const char *base)\n \turl = xmalloc(strlen(base) + 31);\n \tsprintf(url, \"%s/objects/info/http-alternates\", base);\n\n-\t/* Use a callback to process the result, since another request\n-\t   may fail and need to have alternates loaded before continuing */\n+\t/*\n+\t * Use a callback to process the result, since another request\n+\t * may fail and need to have alternates loaded before continuing\n+\t */\n \tslot = get_active_slot();\n \tslot->callback_func = process_alternates_response;\n \talt_req.walker = walker;\n@@ -759,8 +774,10 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, data->no_pragma_header);\n \tslot->local = packfile;\n\n-\t/* If there is data present from a previous transfer attempt,\n-\t   resume where it left off */\n+\t/*\n+\t * If there is data present from a previous transfer attempt,\n+\t * resume where it left off\n+\t */\n \tprev_posn = ftell(packfile);\n \tif (prev_posn>0) {\n \t\tif (walker->get_verbosely)\n@@ -834,18 +851,18 @@ static int fetch_object(struct walker *walker, struct alt_base *repo, unsigned c\n \t}\n\n #ifdef USE_CURL_MULTI\n-\twhile (obj_req->state == WAITING) {\n+\twhile (obj_req->state == WAITING)\n \t\tstep_active_slots();\n-\t}\n #else\n \tstart_object_request(walker, obj_req);\n #endif\n\n-\twhile (obj_req->state == ACTIVE) {\n+\twhile (obj_req->state == ACTIVE)\n \t\trun_active_slot(obj_req->slot);\n-\t}\n+\n \tif (obj_req->local != -1) {\n-\t\tclose(obj_req->local); obj_req->local = -1;\n+\t\tclose(obj_req->local);\n+\t\tobj_req->local = -1;\n \t}\n\n \tif (obj_req->state == ABORTED) {\n--\n1.6.3.1\n"},{"id":"114589","messageId":"7v7i06ut92.fsf@alter.siamese.dyndns.org","threadId":"19466","inReplyTo":"20090524221941.8670c41d.rctay89@gmail.com","subject":"Re: [PATCH 02/18] http-push, http-walker: style fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-24T20:43:21Z","receivedAt":"2009-05-24T20:43:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n>  *spaces used as indentation have been replaced by tabs instead.\n>\n>  *'if' and 'while' conditionals with a single line have had their curly\n>   braces removed.\n>\n\nWe need to apply a style fix to your commit messages first.\n\nUsing '*' without any space as the enumeration bullet makes the message\nharder to read.  Please don't.  Also we prefer to give orders to the\nperson who applies the patch (i.e. \"do _this_, so that the result becomes\nbetter in _this_ and _that_ way\"), instead of saying \"I've done this and\nthat\".\n\n\t- Use tabs to indent, instead of spaces.\n\n\t- Do not use curly-braces around a single statement body in\n          if/while statement; \n\n\t- Do not start multi-line comment with description on the first\n          line after \"/*\", i.e.\n        \n            /*\n             * We prefer this over...\n             */\n\n            /* comments like\n             * this (notice the first line)\n             */\n\nI personally do not necessarily agree with the first \"clean-up\", but as\nlong as the style is internally consistent within the file that's Ok.\n"},{"id":"114665","messageId":"be6fef0d0905250503s8a6facax94dc19ff4a462b70@mail.gmail.com","threadId":"19466","inReplyTo":"7v7i06ut92.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 02/18] http-push, http-walker: style fixes","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-05-25T12:03:55Z","receivedAt":"2009-05-25T12:03:55Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Mon, May 25, 2009 at 4:43 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> We need to apply a style fix to your commit messages first.\n\nthanks for taking the time to go through this gargantuan series; your\nsuggestions and comments are really appreciated. I'll fix it soon.\n\n-- \nCheers,\nRay Chuan\n"}]}