git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv2 2/5] submodule: modernize ok_to_remove_submodule to use argv_array

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2016, 18:39 UTC
Message-ID
<xmqqfulqxsml.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161213205622.841-3-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 9 quoted lines
> Instead of constructing the NULL terminated array ourselves, we
> should make use of the argv_array infrastructure.
>
> While at it, adapt the error messages to reflect the actual invocation.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
Looks good.
Show 46 quoted lines
>
> diff --git a/submodule.c b/submodule.c
> index 45ccfb7ab4..9f0b544ebe 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1023,13 +1023,6 @@ int ok_to_remove_submodule(const char *path)
>  {
>  	ssize_t len;
>  	struct child_process cp = CHILD_PROCESS_INIT;
> -	const char *argv[] = {
> -		"status",
> -		"--porcelain",
> -		"-u",
> -		"--ignore-submodules=none",
> -		NULL,
> -	};
>  	struct strbuf buf = STRBUF_INIT;
>  	int ok_to_remove = 1;
>  
> @@ -1039,14 +1032,15 @@ int ok_to_remove_submodule(const char *path)
>  	if (!submodule_uses_gitfile(path))
>  		return 0;
>  
> -	cp.argv = argv;
> +	argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
> +				   "--ignore-submodules=none", NULL);
>  	prepare_submodule_repo_env(&cp.env_array);
>  	cp.git_cmd = 1;
>  	cp.no_stdin = 1;
>  	cp.out = -1;
>  	cp.dir = path;
>  	if (start_command(&cp))
> -		die("Could not run 'git status --porcelain -uall --ignore-submodules=none' in submodule %s", path);
> +		die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
>  
>  	len = strbuf_read(&buf, cp.out, 1024);
>  	if (len > 2)
> @@ -1054,7 +1048,7 @@ int ok_to_remove_submodule(const char *path)
>  	close(cp.out);
>  
>  	if (finish_command(&cp))
> -		die("'git status --porcelain -uall --ignore-submodules=none' failed in submodule %s", path);
> +		die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
>  
>  	strbuf_release(&buf);
>  	return ok_to_remove;
Previous: Stefan BellerNext: Stefan Beller
Message 4 of 10 in “[PATCHv2 0/5] git-rm absorbs submodule git directory before deletion”
  1. Stefan BellerDec 13, 2016
  2. 1/5 submodule.h: add extern keyword to functionsStefan Beller, Dec 13, 2016
  3. 2/5 submodule: modernize ok_to_remove_submodule to use argv_arrayStefan Beller, Dec 13, 2016
  4. Junio C HamanoDec 14, 2016
  5. 4/5 ok_to_remove_submodule: absorb the submodule git dirStefan Beller, Dec 13, 2016
  6. Junio C HamanoDec 14, 2016
  7. Stefan BellerDec 14, 2016
  8. 5/5 rm: add absorb a submodules git dir before deletionStefan Beller, Dec 13, 2016
  9. Junio C HamanoDec 14, 2016
  10. 3/5 submodule: add flags to ok_to_remove_submoduleStefan Beller, Dec 13, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.