Git extension keeps refs/remotes/<upstream>/<branch> permanently open, preventing atomic Git ref replacement on non-Unix filesystems
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: No
- VS Code Version: 1.130.0
- OS Version: macOS Tahoe 26.5.2
Steps to Reproduce:
1. Open any project with `.git` (and a connected remote with e.g. `refs/remotes/origin/master`) on a non-Unix file system where open files can't be unlinked (e.g. a SSHFS-mounted directory with a a non-Unix OS on the other side).
2. Try to push/pull/fetch, run `git pack-refs` or any other command that changes/updates remote refs.
Git will complain that it can't rename (or unlink) `refs/remotes/origin/master` because the file is held permanently open by VS Code's file watcher.
The responsible part of the code is these lines:
https://github.com/microsoft/vscode/blob/05c208e9e28d8c1c723fa08f85e2b7a96092e8e5/extensions/git/src/repository.ts#L490-L492
I did some testing by patching `repository.ts` locally to simply return from `updateTransientWatchers` early before installing a watcher and it expectedly fixes the problem (and the rest of Git extension's functionality, except immediate notifications about upstream changes, seems to remain intact).
A better solution would be to watch the `refs/remotes/` directory instead of watching (effectively keeping open) individual ref files. These files are atomic mutable objects in git and keeping them open indefinitely does not look correct.
Contributor guide
Assessment
This issue has not been assessed yet.