GIT_WORK_TREE
DancingQuanta opened this issue · 7 comments
I want to ask whether it is possible to export GIT_WORK_TREE
?
Some git helper vim plugins rely on this variable and I think asking them to look at core.worktree
via git
incur a speed penalty on these plugins.
Export, how? If you vcsh enter foo
, you will spawn a new shell and have that set. I can't change the parent shell, though.
I can offer to have something like vcsh print_variables foo
print those variables, though.
Sorry, I don't understand. I did not see GIT_WORK_TREE
set when entering a vcsh shell.
Here is my example in Bash for Windows
+16:17:23 [Andrew@WALKER:~] $
-> vcsh enter vim-config
+16:19:35 [Andrew@WALKER:~] master |±|
-> echo $GIT_DIR
/home/Andrew/.config/vcsh/repo.d/vim-config.git
+16:19:43 [Andrew@WALKER:~] master |±|
-> echo $GIT_WORK_TREE
+16:19:52 [Andrew@WALKER:~] master |±|
-> exit
exit
+16:19:55 [Andrew@WALKER:~] $
-> echo $GIT_DIR
+16:20:00 [Andrew@WALKER:~] $
-> echo $GIT_WORK_TREE
+16:20:06 [Andrew@WALKER:~] $
Is this expected behaviour?
For comparison vcsh enter <repo>
leaves me with $GIT_DIR set to the proper value but $GIT_WORK_TREE is empty for me too.
This issue seems to be two things rolled into one: How GIT_WORK_TREE
is handled and whether it is set at all (even in a vcsh
shell), and exporting variables for use in a shell context other than one spawned by vcsh enter
. The later issue I've split off to a separate feature iss #276. Lets keep this issue for just where GIT_WORK_TREE
fits in and why/when it should be set.
@DanacingQuanta are you still using VCSH? Can you give me an example of something that needs (or would be faster with) this var? It would be helpful to have an actual use case. What vim helper plugin were you thinking of?
FWIW, I found this issue when looking about ways to set the work tree (which is very important for a use case I have), and managed to do it with a config file in ~/.config/vcsh/config.d/repo
containing export GIT_WORK_TREE=$PWD
. I don't know if VCSH_BASE
would be more appropriate, though.
By the way, this config.d
for vcsh
doesn't seem mentioned in the documentation, at all. There are a few mentions of a config.d
but are for mr
only. I'll file an issue.
Additionally: the docs say that GIT_WORK_TREE is set. I don't see that being the case for me, and looking at the source in my version and in the one on the repo on the default branch doesn't seem possible either. There are many uses of GIT_DIR, and many lines export it, but not so with GIT_WORK_TREE.
~$ dpkg -l vcsh
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=====================================================================
ii vcsh 1.20151229-1 all Version Control System for $HOME - multiple Git repositories in $HOME
~$ vcsh init foo1
Initialized empty shared Git repository in /home/alex/.config/vcsh/repo.d/foo1.git/
~$ vcsh enter foo1
~ master #%$ echo $GIT_WORK_TREE
I had to look it up myself; it's been a decade or so... vcsh
works through setting core.worktree
:
% vcsh enter zshrc
% git config core.worktree
/home/richih
% echo $GIT_DIR
/home/richih/.config/vcsh/repo.d/zshrc.git
% grep worktree $GIT_DIR/config
worktree = /home/richih
%
All git
commands will pick this up automagically and it's been the recommended way to change the work tree for ages now.
Do you need to set the work tree to $PWD
once or to the everchanging current one? If the former, vcsh hooks should work. If the latter, Zsh can do that, I suspect Bash can, too.
If the help/manpage is wrong, I would appreciate a PR :)