All of lore.kernel.org
 help / color / mirror / Atom feed
* GIT_CONFIG - what's the point?
@ 2016-04-01  0:54 Matthew Persico
  2016-04-01 11:19 ` Christian Couder
  2016-04-01 12:38 ` Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Matthew Persico @ 2016-04-01  0:54 UTC (permalink / raw)
  To: git

Greetings.

Given the GIT_CONFIG environment variable can change 'git config'
behaves, it stands to reason that if GIT_CONFIG is defined, then ALL
git commands obey the value of GIT_CONFIG and use that file for config
info.

As a test, exported GIT_CONFIG=/tmp/ohm, copied ~/.gitconfig to
/tmp/ohm, moved ~/.gitconfig to ~/.gitconfig.hold and then tried git
st, where 'st' is an alias for status in my config file.

No dice. git st was unrecognized.

So, what's the point of GIT_CONFIG if only git-config uses it? Or did
I miss a step?

Thanks

-- 
Matthew O. Persico

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

* Re: GIT_CONFIG - what's the point?
  2016-04-01  0:54 GIT_CONFIG - what's the point? Matthew Persico
@ 2016-04-01 11:19 ` Christian Couder
  2016-04-01 12:38 ` Jeff King
  1 sibling, 0 replies; 7+ messages in thread
From: Christian Couder @ 2016-04-01 11:19 UTC (permalink / raw)
  To: Matthew Persico; +Cc: git

On Fri, Apr 1, 2016 at 2:54 AM, Matthew Persico
<matthew.persico@gmail.com> wrote:
> Greetings.
>
> Given the GIT_CONFIG environment variable can change 'git config'
> behaves, it stands to reason that if GIT_CONFIG is defined, then ALL
> git commands obey the value of GIT_CONFIG and use that file for config
> info.
>
> As a test, exported GIT_CONFIG=/tmp/ohm, copied ~/.gitconfig to
> /tmp/ohm,

Is /tmp/ohm a directory? If that is the case, then you should probably
have exported "GIT_CONFIG=/tmp/ohm/.gitconfig", as the git config doc
says it specifies a filename.

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

* Re: GIT_CONFIG - what's the point?
  2016-04-01  0:54 GIT_CONFIG - what's the point? Matthew Persico
  2016-04-01 11:19 ` Christian Couder
@ 2016-04-01 12:38 ` Jeff King
  2016-04-01 14:31   ` Matthew Persico
  1 sibling, 1 reply; 7+ messages in thread
From: Jeff King @ 2016-04-01 12:38 UTC (permalink / raw)
  To: Matthew Persico; +Cc: git

On Thu, Mar 31, 2016 at 08:54:26PM -0400, Matthew Persico wrote:

> So, what's the point of GIT_CONFIG if only git-config uses it? Or did
> I miss a step?

There isn't a point to it. It's historical cruft that has been left in
to avoid breaking older scripts. The same thing is generally better
accomplished by using git-config's "--file" parameter. We should
probably do a better job of making that clear in the documentation.

Or possibly deprecate it and eventually remove it entirely, as discussed
in:

  http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/1195694/focus=257770

-Peff

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

* Re: GIT_CONFIG - what's the point?
  2016-04-01 12:38 ` Jeff King
@ 2016-04-01 14:31   ` Matthew Persico
  2016-04-01 14:53     ` Jeff King
  2016-04-01 17:28     ` SZEDER Gábor
  0 siblings, 2 replies; 7+ messages in thread
From: Matthew Persico @ 2016-04-01 14:31 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Let me explain my scenario. I have an nfs mounted home directory. It
is used across multiple machines. I use different colored xterms for
each machine. But that means that the one set of colors in my one
.gitconfig file don't work against all my screen backgrounds. I'm
trying to find a way to tune the git colors per login. The ability to
set colors in an environment variable (like most UNIX utils support)
would be the easiest way to do this. Failing that, I was hoping that
by setting GIT_CONFIG per login, I could tune the color schemes with
different config files.

Since that is not how GIT_CONFIG is used, I have simply decided to
squint where necessary, or open up a neutral colored xterm for the
diff, regardless of machine.

Yes, I could probably do diffs in many other ways, but git diff at the
command line is usually the most expedient.

Unless I wanted to define a GIT_CONFIG_OVER environment variable upon
login, place inside it the appropriate -c<name>=<value> overrides for
colors, and then define a bash function git as

git () {
   $(which git) $GIT_CONFIG_OVER "$@"
   return $?
}

which seems silly.

Thanks anyway.

On Fri, Apr 1, 2016 at 8:38 AM, Jeff King <peff@peff.net> wrote:
> On Thu, Mar 31, 2016 at 08:54:26PM -0400, Matthew Persico wrote:
>
>> So, what's the point of GIT_CONFIG if only git-config uses it? Or did
>> I miss a step?
>
> There isn't a point to it. It's historical cruft that has been left in
> to avoid breaking older scripts. The same thing is generally better
> accomplished by using git-config's "--file" parameter. We should
> probably do a better job of making that clear in the documentation.
>
> Or possibly deprecate it and eventually remove it entirely, as discussed
> in:
>
>   http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/1195694/focus=257770
>
> -Peff



-- 
Matthew O. Persico

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

* Re: GIT_CONFIG - what's the point?
  2016-04-01 14:31   ` Matthew Persico
@ 2016-04-01 14:53     ` Jeff King
  2016-04-01 17:28     ` SZEDER Gábor
  1 sibling, 0 replies; 7+ messages in thread
From: Jeff King @ 2016-04-01 14:53 UTC (permalink / raw)
  To: Matthew Persico; +Cc: git

On Fri, Apr 01, 2016 at 10:31:12AM -0400, Matthew Persico wrote:

> Let me explain my scenario. I have an nfs mounted home directory. It
> is used across multiple machines. I use different colored xterms for
> each machine. But that means that the one set of colors in my one
> .gitconfig file don't work against all my screen backgrounds. I'm
> trying to find a way to tune the git colors per login. The ability to
> set colors in an environment variable (like most UNIX utils support)
> would be the easiest way to do this. Failing that, I was hoping that
> by setting GIT_CONFIG per login, I could tune the color schemes with
> different config files.
> 
> Since that is not how GIT_CONFIG is used, I have simply decided to
> squint where necessary, or open up a neutral colored xterm for the
> diff, regardless of machine.
> 
> Yes, I could probably do diffs in many other ways, but git diff at the
> command line is usually the most expedient.

I think per-environment config is a reasonable thing to want. I can
think of three approaches with varying drawbacks:

  1. The cleanest thing would be for git's config-include directive to
     respect environment variables somehow. We do expand $HOME in

       [include]
       path = ~/.whatever

     but only $HOME (and if you're willing to set $HOME, you can just
     point to a different ~/.gitconfig in the first place).

     So the drawback is that it doesn't currently work, and would need a
     patch to git. ;)

  2. If you don't want to change $HOME, you might be OK with changing
     $XDG_CONFIG_HOME, which could then point to your machine-specific
     user-level config (and could use an include to pull in the common
     bits). See "git help config" for more details (particularly, I
     think the XDG source only kicks in if you have no ~/.gitconfig, but
     I might be misremembering the details).

     The drawback is that other things besides git use $XDG_CONFIG_HOME,
     so you might be affecting them.

     You could probably come up with some elaborate scheme where each
     host has its own $XDG_CONFIG_HOME, and you symlink in the common
     bits. Or something. But that gets complicated pretty fast.

  3. The "git -c" mechanism communicates config to sub-processes via the
     $GIT_CONFIG_PARAMETERS variable. Its format and even existence are
     undocumented, but something like this would probably do what you
     want:

       export GIT_CONFIG_PARAMETERS="'config1=value1' 'config2=value2'"

     The drawback is that it is definitely not officially supported.
     However, I don't think there any plans to get rid of it (and if
     anything, I'd suspect in the future the parser may get less picky,
     and it might become an officially supported interface; but don't
     quote me on that).

-Peff

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

* Re: GIT_CONFIG - what's the point?
  2016-04-01 14:31   ` Matthew Persico
  2016-04-01 14:53     ` Jeff King
@ 2016-04-01 17:28     ` SZEDER Gábor
  2016-04-03 20:11       ` Matthew Persico
  1 sibling, 1 reply; 7+ messages in thread
From: SZEDER Gábor @ 2016-04-01 17:28 UTC (permalink / raw)
  To: Matthew Persico; +Cc: SZEDER Gábor, Jeff King, git

> Let me explain my scenario. I have an nfs mounted home directory. It
> is used across multiple machines. I use different colored xterms for
> each machine. But that means that the one set of colors in my one
> .gitconfig file don't work against all my screen backgrounds. I'm
> trying to find a way to tune the git colors per login. The ability to
> set colors in an environment variable (like most UNIX utils support)
> would be the easiest way to do this. Failing that, I was hoping that
> by setting GIT_CONFIG per login, I could tune the color schemes with
> different config files.
> 
> Since that is not how GIT_CONFIG is used, I have simply decided to
> squint where necessary, or open up a neutral colored xterm for the
> diff, regardless of machine.
> 
> Yes, I could probably do diffs in many other ways, but git diff at the
> command line is usually the most expedient.
> 
> Unless I wanted to define a GIT_CONFIG_OVER environment variable upon
> login, place inside it the appropriate -c<name>=<value> overrides for
> colors, and then define a bash function git as
> 
> git () {
>    $(which git) $GIT_CONFIG_OVER "$@"
>    return $?
> }
> 
> which seems silly.

Yeah, that 'return $?' at the end of the function does indeed seem
silly :)  (sorry, couldn't resist...)

You could use machine-specific config includes instead of that
GIT_CONFIG_OVER environment variable.  I.e. store machine-specific
color configuration in ~/.gitcolors.<machine> or something and define
the shell function as:

git () {
        command git -c include.path=~/.gitcolors.$HOSTNAME "$@"
}

The impact on your .bashrc would be much smaller than with the
GIT_CONFIG_OVER approach.
You could even turn this into an alias, if you want.

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

* Re: GIT_CONFIG - what's the point?
  2016-04-01 17:28     ` SZEDER Gábor
@ 2016-04-03 20:11       ` Matthew Persico
  0 siblings, 0 replies; 7+ messages in thread
From: Matthew Persico @ 2016-04-03 20:11 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Jeff King, git

On Fri, Apr 1, 2016 at 1:28 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:
>> Let me explain my scenario. I have an nfs mounted home directory. It
>> is used across multiple machines. I use different colored xterms for
>> each machine. But that means that the one set of colors in my one
>> .gitconfig file don't work against all my screen backgrounds. I'm
>> trying to find a way to tune the git colors per login. The ability to
>> set colors in an environment variable (like most UNIX utils support)
>> would be the easiest way to do this. Failing that, I was hoping that
>> by setting GIT_CONFIG per login, I could tune the color schemes with
>> different config files.
>>
>> Since that is not how GIT_CONFIG is used, I have simply decided to
>> squint where necessary, or open up a neutral colored xterm for the
>> diff, regardless of machine.
>>
>> Yes, I could probably do diffs in many other ways, but git diff at the
>> command line is usually the most expedient.
>>
>> Unless I wanted to define a GIT_CONFIG_OVER environment variable upon
>> login, place inside it the appropriate -c<name>=<value> overrides for
>> colors, and then define a bash function git as
>>
>> git () {
>>    $(which git) $GIT_CONFIG_OVER "$@"
>>    return $?
>> }
>>
>> which seems silly.
>
> Yeah, that 'return $?' at the end of the function does indeed seem
> silly :)  (sorry, couldn't resist...)
Part OCD, part OAC. :-)

>
> You could use machine-specific config includes instead of that
> GIT_CONFIG_OVER environment variable.  I.e. store machine-specific
> color configuration in ~/.gitcolors.<machine> or something and define
> the shell function as:
>
> git () {
>         command git -c include.path=~/.gitcolors.$HOSTNAME "$@"
> }
BINGO! THAT was the redirection I needed! One thing I was trying to
figure out early one was how to put HOSTNAME-based include.path-s in
the .gitconfig. So I put them OUTSIDE the .gitconfig like this.

Much obliged. Next time you are in NYC - I owe you a beer!

>
> The impact on your .bashrc would be much smaller than with the
> GIT_CONFIG_OVER approach.
> You could even turn this into an alias, if you want.
>
>



-- 
Matthew O. Persico

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

end of thread, other threads:[~2016-04-03 20:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01  0:54 GIT_CONFIG - what's the point? Matthew Persico
2016-04-01 11:19 ` Christian Couder
2016-04-01 12:38 ` Jeff King
2016-04-01 14:31   ` Matthew Persico
2016-04-01 14:53     ` Jeff King
2016-04-01 17:28     ` SZEDER Gábor
2016-04-03 20:11       ` Matthew Persico

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.