GIT env variable needs to be unset #408

Closed
docwhat opened this Issue Sep 27, 2013 · 7 comments

Projects

None yet

2 participants

@docwhat

After using ENV['GIT'] it needs to unset the GIT environment variable.

This will:

  • Prevent infinite recursion if someone tries env GIT=hub hub (or if they have git aliased to hub: env GIT=hub git).
  • Allow chaining to another wrapper that uses GIT to determine the next git executable to run.

Ciao!

@mislav
GitHub member

Sorry, I don't understand why I need to unset GIT. I can see how infinite recursion can happen, but why would anyone do env GIT=hub hub?

@docwhat

My use case is I'm writing something similar to hub for work and want to use both.

E.g. env GIT=mywrap hub version

Returns mywrap version twice because it uses GIT as well.

The alias thing is just an example of how things might go wrong in a way that just hangs.

Ciao!

@mislav
GitHub member

Returns mywrap version twice because it uses GIT as well.

I don't understand why would it return mywrap version twice. The result of the above should be equivalent to running:

mywrap version
echo hub version X.Y.Z
@docwhat

I'm on my phone so excuse me.

hub runs $GIT which is mywrap. mywrap unsets and runs $GIT which is mywrap. mywrap then runs git.

@mislav
GitHub member

hub runs $GIT which is mywrap. mywrap unsets and runs $GIT which is mywrap

That makes sense. However, I don't agree that we should be unsetting the GIT variable. The whole point of $GIT is that you can pick an alternate executable to be used instead of git, and deleting that value for sub-processes defeats that purpose.

I don't think $GIT it's well-suited for keeping a chain of wrapper scripts to be executed. Maybe we should think about an alternate solution.

@docwhat

@mislav

Let's say we use $GIT as the chaining mechanism and we unset it. This means that we can only chain two commands. So that is problematic.

However, I think unsetting $GIT is not unreasonable... git doesn't use that variable and it may mess up other things.

Alternatively, we could do something like:

env GIT_WRAPPERS='hub:/path/to/mywrap' git version

And we would just remove each item in GIT_WRAPPER that matches basename $0and pass off to the next item in.

However, that seems overly complicated.

Another idea:

env HUB_GIT=/path/to/mywrap hub version
...
env MYWRAP_GIT=hub mywrap version

I like this because HUB_GIT won't conflict (easily) with anything else. And it would allow chaining to be set up regardless of which one you call (mywrap or hub) as the initial version.

Thoughts?

@mislav
GitHub member

Update: hub is not implemented in Ruby and doesn't set or read the "GIT" environment variable. This shouldn't be an issue anymore!

@mislav mislav closed this Jan 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment