Git: a repository named by the caller's environment (GIT_DIR and friends) no longer decides which project a folder is
A git hook sets GIT_DIR, so sisi's git calls resolved every checkout to that outer repository; the tripwire test failed with inherited GIT_DIR. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f849609afb
commit
8f679dbba0
1 file changed
+3
-1
+3
-1
@@ -87,8 +87,10 @@ def append(path, line, once=False):
|
||||
|
||||
|
||||
def git(args, cwd, timeout=15):
|
||||
# A repository named by the caller's environment (a git hook sets GIT_DIR) must not decide which project this folder is.
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR")}
|
||||
try:
|
||||
r = subprocess.run(["git"] + args, cwd=cwd, capture_output=True, text=True, timeout=timeout)
|
||||
r = subprocess.run(["git"] + args, cwd=cwd, capture_output=True, text=True, timeout=timeout, env=env)
|
||||
return r.returncode, r.stdout
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return 1, ""
|
||||
|
||||
Reference in new issue
Block a user