-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made git commands work despite values of GIT_DIR
and GIT_WORK_TREE
#523
base: master
Are you sure you want to change the base?
Conversation
The previous method for interacting with a bundle via git involved cd'ing into the bundle directory then running the relevant git commands. The problem with this approach is that if the environmental variables `GIT_DIR` and `GIT_WORK_TREE` are set at this point then git will preference their values over those implied by the current directory. (This can cause trouble for vcsh users, for example.) This patch uses the git arguments `-C`, `--git-dir`, and `--work-tree` to specify the location of the bundle explicitly. This overcomes the original problem since git gives these values precedence over `GIT_DIR` and `GIT_WORK_TREE`.
The code looks good to me. I just ran a :PluginUpdate using this patch and it works well (does not seem to introduce errors). (I also set GIT_DIR and GIT_WORK_TREE to some nonexistent dirs for a test) |
This is exciting. By removing the I am concerned about the -C option, I seem to recall reading about it in a git's changelog, which would mean it's relatively new. Must check this. |
If you decide that we really can not use the -C option it can also be done with the --git-dir and --work-tree options alone. |
The |
It's not that long ago. |
@lucc Unfortunately I don't think this can be done with
but receive an error However, my original motivation for this patch was not to remove the
|
Right on. The ability to remove '&&' was an observed nice side effect, doesn't matter if we don't get it. |
What if we, at the beginning of the installation, checked whether these vars are set, if so cache their values and unset them, and then at the end do the reverse? Seems to me like a simpler change. |
The previous method for interacting with a bundle via git involved
cd'ing into the bundle directory then running the relevant git commands.
The problem with this approach is that if the environmental variables
GIT_DIR
andGIT_WORK_TREE
are set at this point then git willpreference their values over those implied by the current directory.
(This can cause trouble for vcsh users, for example.)
This patch uses the git arguments
-C
,--git-dir
, and--work-tree
to specify the location of the bundle explicitly. This overcomes the
original problem since git gives these values precedence over
GIT_DIR
and
GIT_WORK_TREE
.