Sfoglia il codice sorgente

Support Git worktrees in generation of hash header

(cherry picked from commit 078ab7fe05dcf139b7f943937c602b2c9dbdc8e2)
Pedro J. Estébanez 2 anni fa
parent
commit
a6eece7a97
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      methods.py

+ 4 - 0
methods.py

@@ -104,6 +104,10 @@ def update_version(module_version_string=""):
         head = open_utf8(os.path.join(gitfolder, "HEAD"), "r").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):