浏览代码

Support Git worktrees in generation of hash header

Pedro J. Estébanez 2 年之前
父节点
当前提交
078ab7fe05
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      methods.py

+ 4 - 0
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):