Sublime Forum

Does sublime's 'git status' call hold optional locks?

#1

I work in a somewhat large and old codebase, where ‘git status’ takes a significant amount of time (several seconds) to run. I and other have noticed that, when we try to commit something, we often receive this error:

"fatal: Unable to create ‘/projects/ixengine/.git/index.lock’: File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by ‘git commit’. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
could not detach HEAD"

We’re not 100% confident, but local testing seems to indicate that Sublime Text is holding the lock, and that the issue is fixed by adding this to our settings:

“show_git_status”: false,

I’m curious how sublime calculates the git status; in particular, whether it actually needs to hold a lock on the index. (Assuming that it in fact is holding such a lock- again, I’m not 100% sure.) The git documentation recommends that “Scripts running status in the background should consider using git --no-optional-locks status”: https://git-scm.com/docs/git-status#_background_refresh

0 Likes

#2

We do not invoke the git command line client, nor use libgit2 within Sublime Text itself. Instead, we have our own library that reads the git data. It does not write lock files.

If you are seeing such lock files, my hunch would be a third-party package such as GitGutter, or another program.

2 Likes

#3

GitGutter uses GIT_OPTIONAL_LOCKS environment variable to ask git to prevent writing log files whenever possible.

2 Likes