summaryrefslogtreecommitdiffstats
path: root/pkg/env
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-08-07 22:08:12 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-08-07 22:40:53 +1000
commit595e28d335c9874eb56f7de61a85586567cd8f8c (patch)
tree7eae43fd38f1888bd01c126c33f78fbc4b445cec /pkg/env
parent0551f29de99d1d9fe2640aaa71ce2adf76896f25 (diff)
Support bare worktrees where worktree does not have its own .git file
This was on oversight on my part: I assumed that the --work-tree arg was always intended for use with linked worktrees which have a .git file pointing back to the repo. I'm honestly confused now: seems like there are three kinds of worktrees: * the main worktree of a non-bare repo * a linked worktree (with its own gitdir in the repo's worktrees/ dir) * a random folder which you specify as a worktree with the --work-tree arg I'm pretty sure the --work-tree arg is only intended to be used with this third kind or workree
Diffstat (limited to 'pkg/env')
-rw-r--r--pkg/env/env.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/env/env.go b/pkg/env/env.go
index c96bd18bd..1ade5b8c6 100644
--- a/pkg/env/env.go
+++ b/pkg/env/env.go
@@ -14,6 +14,15 @@ func SetGitDirEnv(value string) {
os.Setenv("GIT_DIR", value)
}
-func UnsetGitDirEnv() {
+func GetWorkTreeEnv() string {
+ return os.Getenv("GIT_WORK_TREE")
+}
+
+func SetWorkTreeEnv(value string) {
+ os.Setenv("GIT_WORK_TREE", value)
+}
+
+func UnsetGitLocationEnvVars() {
_ = os.Unsetenv("GIT_DIR")
+ _ = os.Unsetenv("GIT_WORK_TREE")
}