Survive a git branch name that is not UTF-8

This commit is contained in:
2026-10-02 14:23:33 +02:00
parent 0370adf1fc
commit 7ba3d0325b
2 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ def current_branch(where: str) -> str:
if not where:
return ""
try:
found = subprocess.run(["git", "-C", where, "branch", "--show-current"], capture_output=True, text=True)
found = subprocess.run(["git", "-C", where, "branch", "--show-current"], errors="replace", stderr=subprocess.DEVNULL, stdout=subprocess.PIPE, text=True)
except OSError:
return ""
return found.stdout.strip() if found.returncode == 0 else ""