git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git config not following include paths by default
@ 2020-06-18 20:25 Paul S. Strauss
  2020-06-18 20:40 ` Paul S. Strauss
  0 siblings, 1 reply; 4+ messages in thread
From: Paul S. Strauss @ 2020-06-18 20:25 UTC (permalink / raw)
  To: git

Using git version 2.25.1 in a bash shell on Ubuntu 20.04 (focal).

My global git config file has an [include] with path set to additional 
configuration.

"git config --list --show-origin --includes" shows all of my configuration, 
including items from the included file.

"git config --list --show-origin" shows only the items in my main config file. 
Not sure why "--no-includes" is the default, but not a huge deal either way.

What is a big deal is that none of the configuration in my included config file 
is available to me. I have lots of aliases and other settings in the included 
file, but none of them work.

This can't be the expected behavior, can it? If so, then including config files 
is pretty useless.

-- 
Paul S. Strausspss@acm.org


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

* Re: git config not following include paths by default
  2020-06-18 20:25 git config not following include paths by default Paul S. Strauss
@ 2020-06-18 20:40 ` Paul S. Strauss
  2020-06-19 11:58   ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Paul S. Strauss @ 2020-06-18 20:40 UTC (permalink / raw)
  To: git

Update:

The problem is related to my having GIT_CONFIG set to a file other than 
~/.gitconfig - when I unset GIT_CONFIG and copied my config file to 
~/.gitconfig, the include worked as expected.

So, to reproduce:

    Do NOT have a ~/.gitconfig file
    Set GIT_CONFIG to a configuration file with [include] statements
    Then the behavior I mentioned will occur



On 6/18/20 1:25 PM, Paul S. Strauss wrote:
> Using git version 2.25.1 in a bash shell on Ubuntu 20.04 (focal).
>
> My global git config file has an [include] with path set to additional 
> configuration.
>
> "git config --list --show-origin --includes" shows all of my configuration, 
> including items from the included file.
>
> "git config --list --show-origin" shows only the items in my main config file. 
> Not sure why "--no-includes" is the default, but not a huge deal either way.
>
> What is a big deal is that none of the configuration in my included config 
> file is available to me. I have lots of aliases and other settings in the 
> included file, but none of them work.
>
> This can't be the expected behavior, can it? If so, then including config 
> files is pretty useless.
>

-- 
Paul S. Strauss                                  pss@acm.org


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

* Re: git config not following include paths by default
  2020-06-18 20:40 ` Paul S. Strauss
@ 2020-06-19 11:58   ` Jeff King
  2020-06-19 18:50     ` Paul S. Strauss
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2020-06-19 11:58 UTC (permalink / raw)
  To: Paul S. Strauss; +Cc: git

On Thu, Jun 18, 2020 at 01:40:11PM -0700, Paul S. Strauss wrote:

> The problem is related to my having GIT_CONFIG set to a file other than
> ~/.gitconfig - when I unset GIT_CONFIG and copied my config file to
> ~/.gitconfig, the include worked as expected.

That's working as designed. From git-config(1):

   --[no-]includes
       Respect include.* directives in config files when looking up
       values. Defaults to off when a specific file is given (e.g.,
       using --file, --global, etc) and on when searching all config
       files.

The reasons for that are historical. Includes were added much later, and
you would probably not want "git config --file=.gitmodules" against an
untrusted input to be able to include from anywhere on your filesystem.

$GIT_CONFIG works the same way (as it's equivalent to using --file).  We
generally discourage the use of the environment variable (and its
existence is yet another historical compatibility thing). If you tell us
more about what you're trying to accomplish with it, we might be able to
suggest a better solution.

-Peff

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

* Re: git config not following include paths by default
  2020-06-19 11:58   ` Jeff King
@ 2020-06-19 18:50     ` Paul S. Strauss
  0 siblings, 0 replies; 4+ messages in thread
From: Paul S. Strauss @ 2020-06-19 18:50 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Thank you very much for your help.

I was trying to set up a dual-platform git configuration with a common (synced) 
home directory structure.

I created gitconfig-linux and gitconfig-windows files that both include 
gitconfig-common. (I would have done it the other way around if there was a 
platform-based includeIf). Then I just set GIT_CONFIG to gitconfig-<platform> on 
each system, which led to the problem.

I worked around it by linking ~/.gitconfig to the the platform-specific file on 
each platform, but that is not ideal, IMO.

I didn't realize that using GIT_CONFIG was deprecated (or that it was equivalent 
to specifying a file); there didn't seem to be a better way to do what I wanted.

    - Paul


On 6/19/20 4:58 AM, Jeff King wrote:
> On Thu, Jun 18, 2020 at 01:40:11PM -0700, Paul S. Strauss wrote:
>
>> The problem is related to my having GIT_CONFIG set to a file other than
>> ~/.gitconfig - when I unset GIT_CONFIG and copied my config file to
>> ~/.gitconfig, the include worked as expected.
> That's working as designed. From git-config(1):
>
>     --[no-]includes
>         Respect include.* directives in config files when looking up
>         values. Defaults to off when a specific file is given (e.g.,
>         using --file, --global, etc) and on when searching all config
>         files.
>
> The reasons for that are historical. Includes were added much later, and
> you would probably not want "git config --file=.gitmodules" against an
> untrusted input to be able to include from anywhere on your filesystem.
>
> $GIT_CONFIG works the same way (as it's equivalent to using --file).  We
> generally discourage the use of the environment variable (and its
> existence is yet another historical compatibility thing). If you tell us
> more about what you're trying to accomplish with it, we might be able to
> suggest a better solution.
>
> -Peff

-- 
Paul S. Strauss                                  pss@acm.org


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

end of thread, other threads:[~2020-06-19 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 20:25 git config not following include paths by default Paul S. Strauss
2020-06-18 20:40 ` Paul S. Strauss
2020-06-19 11:58   ` Jeff King
2020-06-19 18:50     ` Paul S. Strauss

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).