Repository navigation
Description
Bug Description
Following #5475 (create_new_feature_branch.py), the remaining Python scripts in the bundled git extension (extensions/git/scripts/python/auto_commit.py, initialize_repo.py, and git_common.py) still invoke git via subprocess.run(..., capture_output=True, text=True) without encoding="utf-8" and write non-ASCII text directly to sys.stderr without a narrow-pipe fallback:
auto_commit.pycrashes withAttributeErroron untracked UTF-8 paths (core.quotepath=false):untracked = subprocess.run(["git", "ls-files", "--others", "--exclude-standard"], cwd=repo_root, capture_output=True, text=True).stdout.strip()decodes Git's stdout using the host locale (cp1252on Windows). Whencore.quotepath=falseis configured and an untracked file path contains any UTF-8 byte undefined incp1252(such as0x90inspecs/001-后台信息架构/spec.md),subprocess._readerthreadfails withUnicodeDecodeError, leaving.stdout = None, and.stdout.strip()crashes withAttributeError: 'NoneType' object has no attribute 'strip'.auto_commit.pyandinitialize_repo.pycrash withTypeErroron UTF-8 Git error output: Both scripts runresult = subprocess.run(cmd, cwd=repo_root, capture_output=True, text=True)followed byoutput = (result.stdout + result.stderr).strip(). Whengit init,git add, orgit commit(or a Git hook /gpg.programerror) fails with UTF-8 output containingcp1252-undefined bytes (0x90,0x9D),result.stdoutorresult.stderrisNone, raisingTypeError: can only concatenate str (not "NoneType") to strinstead of reporting[specify] Error: <step> failed: ...and returning1.- Narrow
sys.stderrpipes raiseUnicodeEncodeError:auto_commit.py,initialize_repo.py, andgit_common.check_feature_branch()print non-ASCII Git messages or branch names directly tosys.stderr, raisingUnicodeEncodeErrorwhensys.stderrusescp1252orascii.
Steps to Reproduce
- In a Spec Kit project with the
gitextension andcore.quotepath=false, enableauto_commit.after_specify.enabled: trueand create an untracked filespecs/001-后台信息架构/spec.md. - Run
python .specify/extensions/git/scripts/python/auto_commit.py after_specifyover acp1252pipe (PYTHONIOENCODING=cp1252). - Observe
UnicodeDecodeErrorinsubprocess._readerthreadfollowed byAttributeError: 'NoneType' object has no attribute 'strip'. - Trigger a
git commitfailure emitting UTF-8 bytes0x90/0x9Dinauto_commit.pyorinitialize_repo.py, or callgit_common.check_feature_branch("main-后台", True)withcp1252stderr, and observeTypeError/UnicodeEncodeError.
Expected Behavior
auto_commit.py, initialize_repo.py, and git_common.py decode Git subprocess output as UTF-8 (errors="replace"), guard nullable subprocess streams, and fall back to backslashreplace when writing non-ASCII diagnostics to narrow stderr streams (matching create_new_feature_branch.py from #5475).
Actual Behavior
subprocess.run(..., text=True) uses the host locale encoding in background reader threads and print(..., file=sys.stderr) uses unguarded stream encoding, raising AttributeError, TypeError, and UnicodeEncodeError on redirected Windows pipes.
Specify CLI Version
main @ a4d5712 (1.4.4.dev0, git extension 1.0.8)
AI Agent
opencode
Operating System
Windows 11 (10.0.26100)
Python Version
Python 3.14.7
Error Logs
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 886: character maps to <undefined>
AttributeError: 'NoneType' object has no attribute 'strip'
TypeError: can only concatenate str (not "NoneType") to str
UnicodeEncodeError: 'charmap' codec can't encode characters in position 53-54: character maps to <undefined>
Additional Context
Completes the Windows legacy-pipe / UTF-8 subprocess handling across the remaining Python scripts in extensions/git/scripts/python/ alongside #5475.
AI Disclosure
Found, reproduced, and drafted autonomously with OpenCode using Gemini 4 Carbon (max reasoning effort, autonomous mode; bug discovery, reproduction, and issue text).
Activity
fix(git): handle UTF-8 git output and narrow stderr pipes in remainin…