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

Re: [PATCH 1/2] clone: respect the settings in $HOME/.gitconfig and /etc/gitconfig

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Jun 27, 2008, 16:05 UTC
Message-ID
<alpine.LNX.1.00.0806271149580.19665@iabervon.org>
In-Reply-To
<alpine.DEB.1.00.0806271353350.9925@racer>
On Fri, 27 Jun 2008, Johannes Schindelin wrote:
> After initializing the config in the newly-created repository, we
> need to unset GIT_CONFIG so that the global configs are read again.

This seems fine to me. OTOH, I'm not sure the environment variable should be needed in the first place; I think the config stuff should look in git_path("config") without it, and we set the git dir to the one we're initializing. So I think the use of the environment variable is just an artifact of how the shell script did it and how I was originally calling the init_db stuff.

Just removing the "setenv()" line survives all of the tests for me, and I remember some of them failing before I'd gotten some sort of solution for the config stuff.

> Noticed by Pieter de Bie.

You'd think I would have noticed this, since I mainly decided to convert clone to C so that url.insteadOf in global config would let you do "git clone work:modulename", but I clearly never tested it.

Show 53 quoted lines
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> 
> 	On Fri, 27 Jun 2008, Pieter de Bie wrote:
> 
> 	> I sometimes use url.insteadOf to create a shortcut to a central 
> 	> repository. For example, having something like[*1*]
> 	> 
> 	> [url "git://repo.or.cz/git/"]
> 	> 	insteadOf = "repo:"
> 	> 
> 	> in my global gitconfig allows me to do a 'git fetch 
> 	> repo:dscho.git'. I'd also like to use that with git clone :).
> 	> Currently if I try that, I get
> 	> 
> 	> Vienna:~ pieter$ git clone repo:dscho.git
> 	> Initialize dscho/.git
> 	> Initialized empty Git repository in /Users/pieter/dscho/.git/
> 	> ssh: Error resolving hostname repo: nodename nor servname provided,
> 	>	or not known
> 	> fatal: The remote end hung up unexpectedly
> 	> 
> 	> [...]
> 	>
> 	> Is there an easy fix for this?
> 
> 	Yes ;-)
> 
>  builtin-clone.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/builtin-clone.c b/builtin-clone.c
> index 17baa20..965b5fc 100644
> --- a/builtin-clone.c
> +++ b/builtin-clone.c
> @@ -424,6 +424,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>  	fprintf(stderr, "Initialize %s\n", git_dir);
>  	init_db(option_template, option_quiet ? INIT_DB_QUIET : 0);
>  
> +	/*
> +	 * At this point, the config exists, so we do not need the
> +	 * environment variable.  We actually need to unset it, too, to
> +	 * re-enable parsing of the global configs.
> +	 */
> +	unsetenv(CONFIG_ENVIRONMENT);
> +
>  	if (option_reference)
>  		setup_reference(git_dir);
>  
> -- 
> 1.5.6.173.gde14c
> 
> 
Previous: Johannes SchindelinNext: Junio C Hamano
Message 7 of 26 in “Using url.insteadOf in git-clone”
  1. Pieter de BieJun 27, 2008
  2. 1/2 clone: respect the settings in $HOME/.gitconfig and /etc/gitconfigJohannes Schindelin, Jun 27, 2008
  3. 2/2 clone: respect url.insteadOf setting in global configsJohannes Schindelin, Jun 27, 2008
  4. Daniel BarkalowJun 27, 2008
  5. Pieter de BieJun 29, 2008
  6. Johannes SchindelinJun 29, 2008
  7. Daniel BarkalowJun 27, 2008
  8. Junio C HamanoJun 27, 2008
  9. Daniel BarkalowJun 29, 2008
  10. Junio C HamanoJun 29, 2008
  11. Johannes SchindelinJun 29, 2008
  12. Daniel BarkalowJun 29, 2008
  13. Johannes SchindelinJun 30, 2008
  14. Daniel BarkalowJun 30, 2008
  15. Junio C HamanoJun 30, 2008
  16. Daniel BarkalowJun 30, 2008
  17. Daniel BarkalowJun 30, 2008
  18. Johannes SchindelinJun 30, 2008
  19. Daniel BarkalowJun 30, 2008
  20. Junio C HamanoJun 30, 2008
  21. Junio C HamanoJun 30, 2008
  22. Jeff KingJun 30, 2008
  23. Junio C HamanoJun 30, 2008
  24. Johannes SchindelinJun 30, 2008
  25. Junio C HamanoJun 27, 2008
  26. Pieter de BieJun 29, 2008

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.