git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Movchan Pavel <movchan.pv@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH][GSOC2014] add: Rewrite run_add_interactive to use struct argv_array
Date: Tue, 18 Mar 2014 12:47:59 -0700	[thread overview]
Message-ID: <xmqq1txz8f0w.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1395145875-5072-1-git-send-email-movchan.pv@gmail.com> (Movchan Pavel's message of "Tue, 18 Mar 2014 20:31:14 +0800")

Movchan Pavel <movchan.pv@gmail.com> writes:

> Origin code are code with own realisation argv array editing.
> It was changed, and code modified for using unified argv-array
> realisation from argv-array.h.
> Commit for Google Summer of Code 2014
>
> Signed-off-by: Movchan Pavel <movchan.pv@gmail.com>
> ---

Thanks.  "Commit for ..." is not something we would want to see in
"git log" output, though.

>  builtin/add.c |   21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/builtin/add.c b/builtin/add.c
> index 4b045ba..258b491 100644
> --- a/builtin/add.c
> +++ b/builtin/add.c
> @@ -15,6 +15,7 @@
>  #include "diffcore.h"
>  #include "revision.h"
>  #include "bulk-checkin.h"
> +#include "argv-array.h"
>  
>  static const char * const builtin_add_usage[] = {
>  	N_("git add [options] [--] <pathspec>..."),
> @@ -141,23 +142,21 @@ static void refresh(int verbose, const struct pathspec *pathspec)
>  int run_add_interactive(const char *revision, const char *patch_mode,
>  			const struct pathspec *pathspec)
>  {
> -	int status, ac, i;
> -	const char **args;
> +	int status, i;
> +	struct argv_array *argv = ARGV_ARRAY_INIT;

Where does that pointer point at and who allocated the piece of
memory used by it?

See http://thread.gmane.org/gmane.comp.version-control.git/244151
for an example solution.

>  
> -	args = xcalloc(sizeof(const char *), (pathspec->nr + 6));
> -	ac = 0;
> -	args[ac++] = "add--interactive";
> +	argv_array_push(argv, "add--interactive");
>  	if (patch_mode)
> -		args[ac++] = patch_mode;
> +		argv_array_push(argv, patch_mode);
>  	if (revision)
> -		args[ac++] = revision;
> -	args[ac++] = "--";
> +		argv_array_push(argv, revision);
> +	argv_array_push(argv, "--");
>  	for (i = 0; i < pathspec->nr; i++)
>  		/* pass original pathspec, to be re-parsed */
> -		args[ac++] = pathspec->items[i].original;
> +		argv_array_push(argv, pathspec->items[i].original);
>  
> -	status = run_command_v_opt(args, RUN_GIT_CMD);
> -	free(args);
> +	status = run_command_v_opt(argv->argv, RUN_GIT_CMD);
> +	argv_array_clear(argv);
>  	return status;
>  }

      reply	other threads:[~2014-03-18 19:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18 12:31 [PATCH][GSOC2014] add: Rewrite run_add_interactive to use struct argv_array Movchan Pavel
2014-03-18 19:47 ` Junio C Hamano [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqq1txz8f0w.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=movchan.pv@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).