git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()
@ 2014-02-27 16:18 Sun He
  2014-02-27 17:31 ` Philip Oakley
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sun He @ 2014-02-27 16:18 UTC (permalink / raw)
  To: git; +Cc: mhagger, Sun He


Signed-off-by: Sun He <sunheehnus@gmail.com>
---
 bundle.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/bundle.c b/bundle.c
index 7809fbb..1a7b7eb 100644
--- a/bundle.c
+++ b/bundle.c
@@ -14,11 +14,7 @@ static const char bundle_signature[] = "# v2 git bundle\n";
 static void add_to_ref_list(const unsigned char *sha1, const char *name,
 		struct ref_list *list)
 {
-	if (list->nr + 1 >= list->alloc) {
-		list->alloc = alloc_nr(list->nr + 1);
-		list->list = xrealloc(list->list,
-				list->alloc * sizeof(list->list[0]));
-	}
+    ALLOC_GROW(list->list,list->nr,list->alloc);
 	hashcpy(list->list[list->nr].sha1, sha1);
 	list->list[list->nr].name = xstrdup(name);
 	list->nr++;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()
  2014-02-27 16:18 [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW() Sun He
@ 2014-02-27 17:31 ` Philip Oakley
  2014-02-27 19:44 ` Junio C Hamano
  2014-02-27 21:51 ` Michael Haggerty
  2 siblings, 0 replies; 4+ messages in thread
From: Philip Oakley @ 2014-02-27 17:31 UTC (permalink / raw)
  To: Sun He, git; +Cc: mhagger

From: "Sun He" <sunheehnus@gmail.com>
>
> Signed-off-by: Sun He <sunheehnus@gmail.com>
> ---
> bundle.c |    6 +-----
> 1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/bundle.c b/bundle.c
> index 7809fbb..1a7b7eb 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -14,11 +14,7 @@ static const char bundle_signature[] = "# v2 git 
> bundle\n";
> static void add_to_ref_list(const unsigned char *sha1, const char 
> *name,
>  struct ref_list *list)
> {
> - if (list->nr + 1 >= list->alloc) {
> - list->alloc = alloc_nr(list->nr + 1);
> - list->list = xrealloc(list->list,
> - list->alloc * sizeof(list->list[0]));
> - }
> +    ALLOC_GROW(list->list,list->nr,list->alloc);
>  hashcpy(list->list[list->nr].sha1, sha1);

Isn't this on top of your other micro-project patch?

If so, it is worth including a note after your signoff and --- to say 
that, so they get applied in the right order :: The principle of least 
surprise.

>  list->list[list->nr].name = xstrdup(name);
>  list->nr++;
> -- 
> 1.7.1
>
> --
Philip 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()
  2014-02-27 16:18 [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW() Sun He
  2014-02-27 17:31 ` Philip Oakley
@ 2014-02-27 19:44 ` Junio C Hamano
  2014-02-27 21:51 ` Michael Haggerty
  2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2014-02-27 19:44 UTC (permalink / raw)
  To: Sun He; +Cc: git, mhagger

Sun He <sunheehnus@gmail.com> writes:

> Signed-off-by: Sun He <sunheehnus@gmail.com>
> ---

The subject reads:

>> Subject: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()

I do not think we want to see the leading part of it in our "git
shortlog" output.

	Subject: [PATCH] bundle.c:add_to_ref_list(): use ALLOC_GROW()

or something, perhaps.

>  bundle.c |    6 +-----
>  1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/bundle.c b/bundle.c
> index 7809fbb..1a7b7eb 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -14,11 +14,7 @@ static const char bundle_signature[] = "# v2 git bundle\n";
>  static void add_to_ref_list(const unsigned char *sha1, const char *name,
>  		struct ref_list *list)
>  {
> -	if (list->nr + 1 >= list->alloc) {
> -		list->alloc = alloc_nr(list->nr + 1);
> -		list->list = xrealloc(list->list,
> -				list->alloc * sizeof(list->list[0]));
> -	}
> +    ALLOC_GROW(list->list,list->nr,list->alloc);
>  	hashcpy(list->list[list->nr].sha1, sha1);
>  	list->list[list->nr].name = xstrdup(name);
>  	list->nr++;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW()
  2014-02-27 16:18 [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW() Sun He
  2014-02-27 17:31 ` Philip Oakley
  2014-02-27 19:44 ` Junio C Hamano
@ 2014-02-27 21:51 ` Michael Haggerty
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Haggerty @ 2014-02-27 21:51 UTC (permalink / raw)
  To: Sun He; +Cc: git

On 02/27/2014 05:18 PM, Sun He wrote:
> Signed-off-by: Sun He <sunheehnus@gmail.com>
> ---
>  bundle.c |    6 +-----
>  1 files changed, 1 insertions(+), 5 deletions(-)
> 
> diff --git a/bundle.c b/bundle.c
> index 7809fbb..1a7b7eb 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -14,11 +14,7 @@ static const char bundle_signature[] = "# v2 git bundle\n";
>  static void add_to_ref_list(const unsigned char *sha1, const char *name,
>  		struct ref_list *list)
>  {
> -	if (list->nr + 1 >= list->alloc) {
> -		list->alloc = alloc_nr(list->nr + 1);
> -		list->list = xrealloc(list->list,
> -				list->alloc * sizeof(list->list[0]));
> -	}
> +    ALLOC_GROW(list->list,list->nr,list->alloc);
>  	hashcpy(list->list[list->nr].sha1, sha1);
>  	list->list[list->nr].name = xstrdup(name);
>  	list->nr++;
> 

Many of my comments about the formatting of your other patches apply
here.  Also, we put spaces after ",", as you can see in the very next line.

I'm also pretty sure there is a serious error in your code.  But I'd
rather you stick to one microproject and get it perfect rather than do
them all--especially all at once, with no time to incorporate feedback
from one microproject into the attempt at the next one.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-27 21:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-27 16:18 [PATCH] GSoC2014 microprojects #6 Change bundle.c:add_to_ref_list() to use ALLOC_GROW() Sun He
2014-02-27 17:31 ` Philip Oakley
2014-02-27 19:44 ` Junio C Hamano
2014-02-27 21:51 ` Michael Haggerty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).