Skip to contentSkip to conversation

Allow '.git' to be a file for worktrees

PATCH Applied Rob Herring 2 participants 2 messages Jun 21, 2021 – Jun 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow '.git' to be a file for worktrees

With multiple git worktrees, '.git' can be a file pointing to the real '.git' directory, so the current check for a directory is too strict.

---
Turns out I had 2 issues and didn't notice you fixed the first one when I rebased. With the first one fixed, it's the same issue with worktrees I recently fixed in the kernel.

 b4/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
b4/__init__.py +1 -1
index 53eaf2757e2a..2bb789e2eaf9 100644
@@ -1834,7 +1834,7 @@ def git_run_command(gitdir: Optional[str], args: List[str], stdin: Optional[byte
                     logstderr: bool = False) -> Tuple[int, str]:
     cmdargs = ['git', '--no-pager']
     if gitdir:
-        if os.path.isdir(os.path.join(gitdir, '.git')):
+        if os.path.exists(os.path.join(gitdir, '.git')):
             gitdir = os.path.join(gitdir, '.git')
         cmdargs += ['--git-dir', gitdir]
     cmdargs += args
Signature · 1 line
2.27.0
#1 lore raw
Quoted 2 lines · Rob Herring

With multiple git worktrees, '.git' can be a file pointing to the real '.git' directory, so the current check for a directory is too strict.

Applied, thanks!

[1/1] Allow '.git' to be a file for worktrees

      commit: c0dd194bdd9318107d187878a7a3b21c6eaf9b3b

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>