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

Re: [PATCH] config: introduce GIT_GLOBAL_CONFIG to override ~/.gitconfig

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2012, 17:27 UTC
Message-ID
<7vvcezqsug.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1348757171-3223-1-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 18 quoted lines
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  Documentation/git-config.txt |    3 +++
>  path.c                       |    5 +++++
>  t/t1306-xdg-files.sh         |    8 ++++++++
>  3 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
> index eaea079..c8db03f 100644
> --- a/Documentation/git-config.txt
> +++ b/Documentation/git-config.txt
> @@ -205,6 +205,9 @@ $GIT_DIR/config::
>  	User-specific configuration file. Also called "global"
>  	configuration file.
>  
> +$GIT_GLOBAL_CONFIG::
> +	Overrides the path of the global configuration file.
> +
Why is this even a good idea?
  - Does it make sense not to read $HOME/.gitconfig or XDG stuff
    when this is set?  Why skip them?  If it makes sense to skip
    them, why doesn't it also skip $GIT_DIR/config and/or
    /etc/gitconfig?
  - Why is it not "the third user-specific configuration file" instead?
  - Why is it not "a list of paths to read configurations from"?
  - Where does it end?
Not overly impressed, I'd have to say.
Show 34 quoted lines
> diff --git a/path.c b/path.c
> index cbbdf7d..9b09cee 100644
> --- a/path.c
> +++ b/path.c
> @@ -131,10 +131,15 @@ char *git_path(const char *fmt, ...)
>  
>  void home_config_paths(char **global, char **xdg, char *file)
>  {
> +	char *global_config = getenv("GIT_GLOBAL_CONFIG");
>  	char *xdg_home = getenv("XDG_CONFIG_HOME");
>  	char *home = getenv("HOME");
>  	char *to_free = NULL;
>  
> +	if (global_config) {
> +		*global = mkpathdup("%s", global_config);
> +		return;
> +	}
>  	if (!home) {
>  		if (global)
>  			*global = NULL;
> diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh
> index 8b14ab1..5b0e08e 100755
> --- a/t/t1306-xdg-files.sh
> +++ b/t/t1306-xdg-files.sh
> @@ -28,6 +28,14 @@ test_expect_success 'read config: xdg file exists and ~/.gitconfig exists' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'read config: $GIT_GLOBAL_CONFIG is set and ~/.gitconfig exists' '
> +	>.gitconfig &&
> +	echo "[alias]" >.gittestconfig &&
> +	echo "	myalias = !echo in_gitconfig" >>.gittestconfig &&
> +	echo in_gitconfig >expected &&
> +	GIT_GLOBAL_CONFIG=~/.gittestconfig git myalias >actual &&
How is this tilde expanded and by whom?
Previous: Junio C HamanoNext: Jeff King
Message 7 of 14 in “Configuring the location of ~/.gitconfig”
  1. Ramkumar RamachandraSep 26, 2012
  2. David AguilarSep 26, 2012
  3. Ramkumar RamachandraSep 27, 2012
  4. config: introduce GIT_GLOBAL_CONFIG to override ~/.gitconfigRamkumar Ramachandra, Sep 27, 2012
  5. Matthieu MoySep 27, 2012
  6. Junio C HamanoSep 27, 2012
  7. Junio C HamanoSep 27, 2012
  8. Jeff KingSep 27, 2012
  9. Junio C HamanoSep 27, 2012
  10. Matthieu MoySep 27, 2012
  11. Ramkumar RamachandraSep 28, 2012
  12. Junio C HamanoSep 27, 2012
  13. Anurag PriyamSep 27, 2012
  14. Junio C HamanoSep 27, 2012

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.