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

Re: [PATCH v4 10/15] clone: die on config error in cmd_clone

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 2, 2016, 20:55 UTC
Message-ID
<xmqqwpqmrfvo.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1454413916-31984-11-git-send-email-ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 7 quoted lines
> The clone command does not check for error codes returned by
> `git_config_set` functions. This may cause the user to end up
> with an inconsistent repository without any indication with what
> went wrong.
>
> Fix this problem by dying with an error message when we are
> unable to write the configuration files to disk.

When this happens, the junk_mode is still JUNK_LEAVE_NONE, so upon hitting such an error, we'd remove everything and die. And we haven't wasted the effort for large object transfer yet.

Which all sounds sensible.
Show 41 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  builtin/clone.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 81e238f..f2a2f9a 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -786,12 +786,12 @@ static void write_refspec_config(const char *src_ref_prefix,
>  		/* Configure the remote */
>  		if (value.len) {
>  			strbuf_addf(&key, "remote.%s.fetch", option_origin);
> -			git_config_set_multivar(key.buf, value.buf, "^$", 0);
> +			git_config_set_multivar_or_die(key.buf, value.buf, "^$", 0);
>  			strbuf_reset(&key);
>  
>  			if (option_mirror) {
>  				strbuf_addf(&key, "remote.%s.mirror", option_origin);
> -				git_config_set(key.buf, "true");
> +				git_config_set_or_die(key.buf, "true");
>  				strbuf_reset(&key);
>  			}
>  		}
> @@ -949,14 +949,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>  			src_ref_prefix = "refs/";
>  		strbuf_addstr(&branch_top, src_ref_prefix);
>  
> -		git_config_set("core.bare", "true");
> +		git_config_set_or_die("core.bare", "true");
>  	} else {
>  		strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
>  	}
>  
>  	strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
>  	strbuf_addf(&key, "remote.%s.url", option_origin);
> -	git_config_set(key.buf, repo);
> +	git_config_set_or_die(key.buf, repo);
>  	strbuf_reset(&key);
>  
>  	if (option_reference.nr)
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 18 of 26 in “config: make git_config_set die on failure”
  1. 00/15 config: make git_config_set die on failurePatrick Steinhardt, Feb 2, 2016
  2. 01/15 config: introduce set_or_die wrappersPatrick Steinhardt, Feb 2, 2016
  3. 02/15 branch: die on error in setting up tracking branchPatrick Steinhardt, Feb 2, 2016
  4. Junio C HamanoFeb 2, 2016
  5. Patrick SteinhardtFeb 8, 2016
  6. Patrick SteinhardtFeb 8, 2016
  7. 03/15 branch: die on config error when unsetting upstreamPatrick Steinhardt, Feb 2, 2016
  8. 04/15 branch: die on config error when editing branch descriptionPatrick Steinhardt, Feb 2, 2016
  9. 05/15 submodule: die on config error when linking modulesPatrick Steinhardt, Feb 2, 2016
  10. 06/15 submodule--helper: die on config error when cloning modulePatrick Steinhardt, Feb 2, 2016
  11. Eric SunshineFeb 2, 2016
  12. Patrick SteinhardtFeb 8, 2016
  13. 07/15 remote: die on config error when setting URLPatrick Steinhardt, Feb 2, 2016
  14. Patrick SteinhardtFeb 2, 2016
  15. 08/15 remote: die on config error when setting/adding branchesPatrick Steinhardt, Feb 2, 2016
  16. 09/15 remote: die on config error when manipulating remotesPatrick Steinhardt, Feb 2, 2016
  17. 10/15 clone: die on config error in cmd_clonePatrick Steinhardt, Feb 2, 2016
  18. Junio C HamanoFeb 2, 2016
  19. 11/15 init-db: die on config errors when initializing empty repoPatrick Steinhardt, Feb 2, 2016
  20. 12/15 sequencer: die on config error when saving replay optsPatrick Steinhardt, Feb 2, 2016
  21. 13/15 compat: die when unable to set core.precomposeunicodePatrick Steinhardt, Feb 2, 2016
  22. 14/15 config: rename git_config_set to git_config_set_gentlyPatrick Steinhardt, Feb 2, 2016
  23. 15/15 config: rename git_config_set_or_die to git_config_setPatrick Steinhardt, Feb 2, 2016
  24. Stefan BellerFeb 2, 2016
  25. Junio C HamanoFeb 2, 2016
  26. Patrick SteinhardtFeb 4, 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.