git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Overriding ~/.gitconfig using GIT_CONFIG
@ 2011-08-12 15:38 Richard Purdie
  2011-08-12 19:16 ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Purdie @ 2011-08-12 15:38 UTC (permalink / raw)
  To: GIT Mailing-list

I work on build systems which need to check code out of source control
systems like git. I need to do this in a way in which there are not
outside influences and a user's $HOME/.gitconfig file can contain things
we don't want. I therefore need a way to disable it.

Looking through the manuals/code, it suggests I should be able to do:

GIT_CONFIG=/dev/null git XXX

and all should work happily. It doesn't though. As an example, with a
~/.gitconfig, "GIT_CONFIG=/dev/null git fetch --all" is clearly
accessing the file in ~ and then acting upon it.

I've searched through the code and whilst config_exclusive_filename
appears to be the magic variable that should get set when I set
GIT_CONFIG in the environment, nothing ever sets it apart from within a
git-config command.

The following patch sets the variable from the environment initially and
should do what the code intends if I read understand it correctly. Its
not ideal for my use case as I actually want the repo_config and only
the repo config to be used but I can live with setting GIT_CONFIG to
point at it.

Alternative ideas welcome, I've considered changing $HOME but that seems
a little too ugly and likely to cause other problems.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/config.c b/config.c
index d06fb19..19e7565 100644
--- a/config.c
+++ b/config.c
@@ -860,6 +860,8 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
 	int ret = 0, found = 0;
 	const char *home = NULL;
 
+	config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
+
 	/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
 	if (config_exclusive_filename)
 		return git_config_from_file(fn, config_exclusive_filename, data);


-- 
Linux Foundation
http://www.yoctoproject.org/

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-09-05 19:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-12 15:38 Overriding ~/.gitconfig using GIT_CONFIG Richard Purdie
2011-08-12 19:16 ` Junio C Hamano
2011-08-12 19:39   ` Junio C Hamano
2011-08-12 20:44     ` Richard Purdie
2011-08-28 13:05       ` David Aguilar
2011-08-29 12:16         ` Richard Purdie
2011-08-30  3:10           ` David Aguilar
2011-08-30 12:13             ` Richard Purdie
2011-08-30 15:56               ` Jeff King
2011-08-30 18:39                 ` Richard Purdie
2011-08-30 18:49                   ` Jeff King
2011-09-05 19:29                     ` Richard Purdie

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 NNTP newsgroup(s).