diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-09 17:51:27 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-09 17:51:27 +0100 |
commit | be753a40a7fa4c0f8989d23a1b01b2870ba88185 (patch) | |
tree | faca3b7246d015c33bdc26af3fab5a8a75619506 | |
parent | 64f2b970d8b4d2dec9a7f8047e0b5071cf41acbf (diff) | |
parent | 078ab7fe05dcf139b7f943937c602b2c9dbdc8e2 (diff) |
Merge pull request #71118 from RandomShaper/git_worktrees
Support Git worktrees in generation of hash header
-rw-r--r-- | methods.py | 4 |
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): |