{"thread":{"id":"35979","subject":"[PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()","startedAt":"2014-02-27T16:18:14Z","lastAt":"2014-02-27T21:51:41Z","messageCount":4,"participants":["Sun He","Philip Oakley","Junio C Hamano","Michael Haggerty"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"235482","messageId":"1393517894-670-1-git-send-email-sunheehnus@gmail.com","threadId":"35979","inReplyTo":null,"subject":"[PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()","fromName":"Sun He","fromEmail":"sunheehnus@gmail.com","sentAt":"2014-02-27T16:18:14Z","receivedAt":"2014-02-27T16:18:14Z","isPatch":true,"sender":{"key":"sunheehnus@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2889804?v=4"},"body":"\nSigned-off-by: Sun He <sunheehnus@gmail.com>\n---\n bundle.c |    6 +-----\n 1 files changed, 1 insertions(+), 5 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex 7809fbb..1a7b7eb 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n static void add_to_ref_list(const unsigned char *sha1, const char *name,\n \t\tstruct ref_list *list)\n {\n-\tif (list->nr + 1 >= list->alloc) {\n-\t\tlist->alloc = alloc_nr(list->nr + 1);\n-\t\tlist->list = xrealloc(list->list,\n-\t\t\t\tlist->alloc * sizeof(list->list[0]));\n-\t}\n+    ALLOC_GROW(list->list,list->nr,list->alloc);\n \thashcpy(list->list[list->nr].sha1, sha1);\n \tlist->list[list->nr].name = xstrdup(name);\n \tlist->nr++;\n-- \n1.7.1\n"},{"id":"235484","messageId":"D5ECFBC97E4246CBB939B7670259D3DC@PhilipOakley","threadId":"35979","inReplyTo":"1393517894-670-1-git-send-email-sunheehnus@gmail.com","subject":"Re: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2014-02-27T16:18:14Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Sun He\" <sunheehnus@gmail.com>\n>\n> Signed-off-by: Sun He <sunheehnus@gmail.com>\n> ---\n> bundle.c |    6 +-----\n> 1 files changed, 1 insertions(+), 5 deletions(-)\n>\n> diff --git a/bundle.c b/bundle.c\n> index 7809fbb..1a7b7eb 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git \n> bundle\\n\";\n> static void add_to_ref_list(const unsigned char *sha1, const char \n> *name,\n>  struct ref_list *list)\n> {\n> - if (list->nr + 1 >= list->alloc) {\n> - list->alloc = alloc_nr(list->nr + 1);\n> - list->list = xrealloc(list->list,\n> - list->alloc * sizeof(list->list[0]));\n> - }\n> +    ALLOC_GROW(list->list,list->nr,list->alloc);\n>  hashcpy(list->list[list->nr].sha1, sha1);\n\nIsn't this on top of your other micro-project patch?\n\nIf so, it is worth including a note after your signoff and --- to say \nthat, so they get applied in the right order :: The principle of least \nsurprise.\n\n>  list->list[list->nr].name = xstrdup(name);\n>  list->nr++;\n> -- \n> 1.7.1\n>\n> --\nPhilip \n"},{"id":"235497","messageId":"xmqqzjlcxrva.fsf@gitster.dls.corp.google.com","threadId":"35979","inReplyTo":"1393517894-670-1-git-send-email-sunheehnus@gmail.com","subject":"Re: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-27T19:44:41Z","receivedAt":"2014-02-27T19:44:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sun He <sunheehnus@gmail.com> writes:\n\n> Signed-off-by: Sun He <sunheehnus@gmail.com>\n> ---\n\nThe subject reads:\n\n>> Subject: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()\n\nI do not think we want to see the leading part of it in our \"git\nshortlog\" output.\n\n\tSubject: [PATCH] bundle.c:add_to_ref_list(): use ALLOC_GROW()\n\nor something, perhaps.\n\n>  bundle.c |    6 +-----\n>  1 files changed, 1 insertions(+), 5 deletions(-)\n>\n> diff --git a/bundle.c b/bundle.c\n> index 7809fbb..1a7b7eb 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n>  static void add_to_ref_list(const unsigned char *sha1, const char *name,\n>  \t\tstruct ref_list *list)\n>  {\n> -\tif (list->nr + 1 >= list->alloc) {\n> -\t\tlist->alloc = alloc_nr(list->nr + 1);\n> -\t\tlist->list = xrealloc(list->list,\n> -\t\t\t\tlist->alloc * sizeof(list->list[0]));\n> -\t}\n> +    ALLOC_GROW(list->list,list->nr,list->alloc);\n>  \thashcpy(list->list[list->nr].sha1, sha1);\n>  \tlist->list[list->nr].name = xstrdup(name);\n>  \tlist->nr++;\n"},{"id":"235515","messageId":"530FB36D.6060103@alum.mit.edu","threadId":"35979","inReplyTo":"1393517894-670-1-git-send-email-sunheehnus@gmail.com","subject":"Re: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-27T21:51:41Z","receivedAt":"2014-02-27T21:51:41Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/27/2014 05:18 PM, Sun He wrote:\n> Signed-off-by: Sun He <sunheehnus@gmail.com>\n> ---\n>  bundle.c |    6 +-----\n>  1 files changed, 1 insertions(+), 5 deletions(-)\n> \n> diff --git a/bundle.c b/bundle.c\n> index 7809fbb..1a7b7eb 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n>  static void add_to_ref_list(const unsigned char *sha1, const char *name,\n>  \t\tstruct ref_list *list)\n>  {\n> -\tif (list->nr + 1 >= list->alloc) {\n> -\t\tlist->alloc = alloc_nr(list->nr + 1);\n> -\t\tlist->list = xrealloc(list->list,\n> -\t\t\t\tlist->alloc * sizeof(list->list[0]));\n> -\t}\n> +    ALLOC_GROW(list->list,list->nr,list->alloc);\n>  \thashcpy(list->list[list->nr].sha1, sha1);\n>  \tlist->list[list->nr].name = xstrdup(name);\n>  \tlist->nr++;\n> \n\nMany of my comments about the formatting of your other patches apply\nhere.  Also, we put spaces after \",\", as you can see in the very next line.\n\nI'm also pretty sure there is a serious error in your code.  But I'd\nrather you stick to one microproject and get it perfect rather than do\nthem all--especially all at once, with no time to incorporate feedback\nfrom one microproject into the attempt at the next one.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"}]}