summaryrefslogtreecommitdiff
path: root/methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'methods.py')
-rw-r--r--methods.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/methods.py b/methods.py
index 99a59b49e3..ee88401671 100644
--- a/methods.py
+++ b/methods.py
@@ -111,6 +111,10 @@ def get_version_info(module_version_string="", silent=False):
head = open(os.path.join(gitfolder, "HEAD"), "r", encoding="utf8").readline().strip()
if head.startswith("ref: "):
ref = head[5:]
+ # If this directory is a Git worktree instead of a root clone.
+ parts = gitfolder.split("/")
+ if len(parts) > 2 and parts[-2] == "worktrees":
+ gitfolder = "/".join(parts[0:-2])
head = os.path.join(gitfolder, ref)
packedrefs = os.path.join(gitfolder, "packed-refs")
if os.path.isfile(head):