Skip to content

Commit c7446af

Browse files
committed
🤖 fix: git polling skips fetch when lock files present
When git operations (e.g., agent tool calls) are in progress, they create lock files in the .git directory (index.lock, shallow.lock, etc.). The background git fetch polling would previously run regardless, potentially causing unexpected errors or conflicts. Now the fetch script checks for any .lock files in the .git directory before attempting to fetch. If locks are present, it exits cleanly with exit code 0 and the message 'SKIP: git lock files present'. This is a non-blocking check - the polling will just try again on its next cycle (3s later for status, exponential backoff for fetch). _Generated with `mux`_
1 parent 59be8be commit c7446af

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/common/utils/git/gitStatus.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,19 @@ export function parseGitStatusScriptOutput(output: string): ParsedGitStatusOutpu
8686
*
8787
* Environment variables disable all interactive prompts (keychain, SSH, credentials).
8888
* Git flags optimize for speed - only fetch refs, not objects.
89+
*
90+
* Lock-aware: Skips fetch if any git lock files exist in the .git directory.
91+
* This avoids conflicts with concurrent git operations (e.g., agent tool calls).
92+
* Common lock files: index.lock, shallow.lock, refs/heads/*.lock, config.lock
8993
*/
9094
export const GIT_FETCH_SCRIPT = `
95+
# Skip if any git lock files exist (another operation in progress)
96+
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null) || exit 1
97+
if find "$GIT_DIR" -name "*.lock" -type f 2>/dev/null | grep -q .; then
98+
echo "SKIP: git lock files present"
99+
exit 0
100+
fi
101+
91102
# Disable ALL prompts
92103
export GIT_TERMINAL_PROMPT=0
93104
export GIT_ASKPASS=echo

0 commit comments

Comments
 (0)