Skip to content

Commit 49ea8ae

Browse files
authored
acceptance: guard git-repo-init against running inside an existing repo (#5281)
## Why "git config" writes to whatever repo CWD is in, so calling git-repo-init from inside an existing repo poisons that repo's config without any error signal. I had my cli repo config messed up by an agent. Co-authored-by: Isaac
1 parent a649259 commit 49ea8ae

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

acceptance/script.prepare

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ trace() {
5555
}
5656

5757
git-repo-init() {
58+
if git rev-parse --git-dir > /dev/null 2>&1; then
59+
echo "git-repo-init: already inside a git repository" >&2
60+
return 1
61+
fi
5862
git init -qb main
5963
git config core.autocrlf false
6064
git config user.name "Tester"

0 commit comments

Comments
 (0)