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

Re: [PATCHv5 3/4] submodule: rename and add flags to ok_to_remove_submodule

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 27, 2016, 00:53 UTC
Message-ID
<xmqqr34uchuq.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161220232012.15997-4-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> As only 0 is understood as false, rename the function to invert the
> meaning, i.e. the return code of 0 signals the removal of the submodule
> is fine, and other values can be used to return a more precise answer
> what went wrong.

Makes sense to rename it as that will catch all the callers that depend on the old semantics and name.

Show 9 quoted lines
> -	if (start_command(&cp))
> -		die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
> +	if (start_command(&cp)) {
> +		if (flags & SUBMODULE_REMOVAL_DIE_ON_ERROR)
> +			die(_("could not start 'git status in submodule '%s'"),
> +				path);
> +		ret = -1;
> +		goto out;
> +	}

This new codepath that does not die will not leak anything, as a failed start_command() should release its argv[] and env[].

>  	len = strbuf_read(&buf, cp.out, 1024);
>  	if (len > 2)
> -		ok_to_remove = 0;
> +		ret = 1;

Not a new problem but is it obvious why the comparison of "len" is against "2"? This may deserve a one-liner comment.

Otherwise looks good to me.
Previous: Stefan BellerNext: Stefan Beller
Message 7 of 13 in “[PATCHv5 0/4] git-rm absorbs submodule git directory before deletion”
  1. Stefan BellerDec 20, 2016
  2. 1/4 submodule.h: add extern keyword to functionsStefan Beller, Dec 20, 2016
  3. Junio C HamanoDec 27, 2016
  4. Stefan BellerDec 27, 2016
  5. 2/4 submodule: modernize ok_to_remove_submodule to use argv_arrayStefan Beller, Dec 20, 2016
  6. 3/4 submodule: rename and add flags to ok_to_remove_submoduleStefan Beller, Dec 20, 2016
  7. Junio C HamanoDec 27, 2016
  8. Stefan BellerDec 27, 2016
  9. 4/4 rm: absorb a submodules git dir before deletionStefan Beller, Dec 20, 2016
  10. Junio C HamanoDec 27, 2016
  11. Stefan BellerDec 27, 2016
  12. Stefan BellerDec 27, 2016
  13. Junio C HamanoDec 27, 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.