git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	git@vger.kernel.org
Subject: Re: [PATCH 3/7] refactor argv_array into generic code
Date: Wed, 14 Sep 2011 07:54:48 +0200	[thread overview]
Message-ID: <CAP8UFD1vxP9ABgJpM99hxDWWLeGO_QW7QLVFq1f-teu1fiCftA@mail.gmail.com> (raw)
In-Reply-To: <20110913215757.GC24490@sigill.intra.peff.net>

Hi Peff,

On Tue, Sep 13, 2011 at 11:57 PM, Jeff King <peff@peff.net> wrote:
> diff --git a/argv-array.c b/argv-array.c
> new file mode 100644
> index 0000000..a50507a
> --- /dev/null
> +++ b/argv-array.c
> @@ -0,0 +1,52 @@
> +#include "cache.h"
> +#include "argv-array.h"
> +#include "strbuf.h"
> +
> +static const char *empty_argv_storage = NULL;
> +const char **empty_argv = &empty_argv_storage;
> +
> +void argv_array_init(struct argv_array *array)
> +{
> +       array->argv = empty_argv;
> +       array->argc = 0;
> +       array->alloc = 0;
> +}
> +
> +static void argv_array_push_nodup(struct argv_array *array, const char *value)
> +{
> +       if (array->argv == empty_argv)
> +               array->argv = NULL;
> +
> +       ALLOC_GROW(array->argv, array->argc + 2, array->alloc);
> +       array->argv[array->argc++] = value;
> +       array->argv[array->argc] = NULL;
> +}
> +
> +void argv_array_push(struct argv_array *array, const char *value)
> +{
> +       argv_array_push_nodup(array, xstrdup(value));
> +}
> +
> +void argv_array_pushf(struct argv_array *array, const char *fmt, ...)
> +{
> +       va_list ap;
> +       struct strbuf v = STRBUF_INIT;
> +
> +       va_start(ap, fmt);
> +       strbuf_vaddf(&v, fmt, ap);
> +       va_end(ap);
> +
> +       argv_array_push_nodup(array, strbuf_detach(&v, NULL));
> +}

In sha1-array you called the "push" function "sha1_array_append"
instead of "sha1_array_push", so I wonder why here you call them
"*_push*" instead of "*_append*"?

Thanks for doing this anyway,
Christian.

  reply	other threads:[~2011-09-14  5:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13 21:50 [PATCH 0/7] create argv_array API Jeff King
2011-09-13 21:57 ` [PATCH 1/7] add sha1_array API docs Jeff King
2011-09-13 21:57 ` [PATCH 2/7] quote.h: fix bogus comment Jeff King
2011-09-13 21:57 ` [PATCH 3/7] refactor argv_array into generic code Jeff King
2011-09-14  5:54   ` Christian Couder [this message]
2011-09-14 23:18     ` Jeff King
2011-09-14 18:42   ` Junio C Hamano
2011-09-14 18:51     ` Junio C Hamano
2011-09-13 21:58 ` [PATCH 4/7] quote: provide sq_dequote_to_argv_array Jeff King
2011-09-13 21:58 ` [PATCH 5/7] bisect: use argv_array API Jeff King
2011-09-13 21:58 ` [PATCH 6/7] checkout: " Jeff King
2011-09-13 21:58 ` [PATCH 7/7] run_hook: " Jeff King
2011-09-13 22:04   ` [nit] diff func headers ignore context Jeff King
2011-09-14 10:13     ` Andreas Ericsson
2011-09-14 19:01     ` Junio C Hamano
2011-09-14 18:54   ` [PATCH 7/7] run_hook: use argv_array API Junio C Hamano
2011-09-14 18:56     ` Jeff King
2011-09-14 20:01       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP8UFD1vxP9ABgJpM99hxDWWLeGO_QW7QLVFq1f-teu1fiCftA@mail.gmail.com \
    --to=christian.couder@gmail.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).