Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio code shouldn't attempt to update git until it has focus #11918

Closed
jyavenard opened this issue Sep 13, 2016 · 28 comments
Closed

Visual Studio code shouldn't attempt to update git until it has focus #11918

jyavenard opened this issue Sep 13, 2016 · 28 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues verified Verification succeeded
Milestone

Comments

@jyavenard
Copy link

  • VSCode Version: 1.5.2
  • OS Version: OS 10.11.6

This is something that has bugged me with XCode for years, and unfortunately, I'm experiencing the same issue with VS.

Typical use case:

  • Have VS opened, could be on the git pane.
  • In a terminal, performed git operations such as a rebase.

You can see that VS attempts to update the git view, even though it hasn't got the focus.

This leads to git operation in the terminal failing due to:
fatal: Unable to create '/Users/jyavenard/Work/Mozilla/mozilla-central/.git/index.lock': File exists. As you can only have one git operation going at a time.

While the likelihood of the failure to occur appears to be much lesser than with xcode, I still get it occasionally.

Solution: VS shouldn't attempt to perform a git operation, unless it has the focus.

@joaomoreno
Copy link
Member

joaomoreno commented Sep 13, 2016

Since a few releases already, Code doesn't update the git view if it's not in focus.

Are you sure you still see this in 1.5.2? My Code stays put, until I focus it.

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Sep 13, 2016
@jyavenard
Copy link
Author

Yes I'm certain...
If VS Code is showing up by the side of the terminal window, in its git view (while the focus is on the terminal window) you can see the list of staged files being refreshed while the rebate is in progress.

Version and platform used are in the original message.

@joaomoreno
Copy link
Member

Is this the internal terminal? Or something like Terminal.app or iTerm.app?

@jyavenard
Copy link
Author

@jyavenard
Copy link
Author

Mind you, if I modify manually a file outside VS Code (and one in git), neither the editor nor git view show an updated content.

But when rebasing, I can see the file being staged changing in the VS Code code view, even though it doesn't have the focus.

@joaomoreno
Copy link
Member

I could reproduce! Definitely a bug, thanks for the persistence, @jyavenard!

@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Sep 14, 2016
@joaomoreno joaomoreno added this to the September 2016 milestone Sep 14, 2016
@joaomoreno joaomoreno added the git GIT issues label Sep 14, 2016
@djg
Copy link

djg commented Sep 16, 2016

I also experienced this issue with vscode on Linux and using git from a terminal.

@joaomoreno
Copy link
Member

I can no longer reproduce this... But I did a code change which might affect your scenario, @jyavenard. Let me know how it goes.

@jyavenard
Copy link
Author

If you're referring to the version 6.1

I had it happening just a few hours ago...

@chrmarti chrmarti added the verified Verification succeeded label Oct 27, 2016
@chrmarti
Copy link
Contributor

I see a 'git fetch' in the Output's git channel and monaco.d.ts come and go in the Git viewlet without Code having focus. I'm running npm run watch and git rebase ... in a terminal window. Reopening.

  • VSCode Version: Code - Insiders 1.7.0-insider (3c6f232, 2016-10-27T13:34:54.959Z)
  • OS Version: Darwin x64 15.6.0
  • Extensions:
Extension Author Version
dart-code DanTup 0.13.0
EditorConfig EditorConfig 0.3.3
vscode-docker PeterJausovec 0.0.6
speech bierner 0.0.1
regex chrmarti 0.0.6
vscode-eslint dbaeumer 1.0.7
python donjayamanne 0.5.0
ghlink dt 0.0.4
gitlens eamodio 0.5.5
tslint eg2 0.5.39
vsc-travis-ci-status felixrieseberg 1.0.3
PowerShell ms-vscode 0.7.2
cpptools ms-vscode 0.9.2
csharp ms-vscode 1.4.1
debugger-for-chrome msjsdiag 1.1.0
diff rafaelmaiolla 0.0.1
kustovscode seanmcbreen 0.0.1
vscode-open-in-github sysoev 1.2.0

@chrmarti chrmarti reopened this Oct 27, 2016
@chrmarti chrmarti added verification-found Issue verification failed and removed verified Verification succeeded labels Oct 27, 2016
@joaomoreno
Copy link
Member

git fetch is OK. Files coming and going are not. I'm still unable to repro, but I'll take a closer look.

@jyavenard
Copy link
Author

Are you sure they are?

Because whenever I'm getting those .git.lock error, at no time vscode is writing on the repo.
Not like two writing operations are occurring in parallel...

@dlong500
Copy link

I don't know if there has been any changes recently along the lines of this issue, but I'm running 1.8.0-insider (2016-11-23) on Win7 and the vscode git refresh is taking forever now even if the window has focus. I can commit some files in a separate terminal, go back to vscode and easily wait 30-60 seconds before the git information is correct.

@joaomoreno
Copy link
Member

@dlong500 How slow is git status in the command line? Code will react to outside changes and call git status to update its state. It won't call it more often than every 10 seconds though... so there might be a 10 second delay, once focused. 30-60 is way too much. You can check the Git Output within Code to track what it's doing.

@joaomoreno joaomoreno removed the verification-found Issue verification failed label Apr 21, 2017
@tinacious
Copy link

I'm on VSCode v1.12.1 for Mac and I'm experiencing the same issue when I try to use Git from the terminal, usually when doing a merge:

fatal: Unable to create '.../path/to/project/.git/index.lock': File exists.

I can fix this by focusing VSCode and quitting it.

VSCode shouldn't hijack Git, especially if it's not in use, and even more so if the Git pane is not even in focus in VSCode.

@Fischer-L
Copy link

Yeah, the same issue

fatal: Unable to create '.../path/to/project/.git/index.lock': File exists.

It seems VSCode doesn't release the lock file properly......

@stefanweck
Copy link

I'm experiencing the same issues while working with VSC. I can't use any other program like SourceTree or GitKraken because VSC keeps hijacking the index.lock file.

@XavCamp
Copy link

XavCamp commented Jul 4, 2017

Please fix this, I've lost commit contents several times because VSCode took the lock during rebases and I probably didn't abort or continue correctly.
I have to quit VSCode every time I want to rebase, because of that I'll probably have to switch to another editor. (I'm on Mac, VSCode v1.13.1

@SailorMax
Copy link

@XavCamp
As temporary solution, you can setup in settings:

	"git.autorefresh": false,
	"git.autofetch": false,

@XavCamp
Copy link

XavCamp commented Jul 4, 2017

Thanks @SailorMax, I had autofetch to false but I missed autorefresh, I'll give it a try

@ricardobeat
Copy link

1 year and 8 months since this was reported in #901, it is still a major blocker for using VSCode at work. Hopeful for next milestone! 🤞

@joaomoreno
Copy link
Member

@ricardobeat It was actually fixed during most of that time and broke recently when we moved git to an extension. But we're always happy to have pressuring passion. 👍

@bjornhanson
Copy link

I just started using VSC this week and have been seeing the fatal: Unable to create [...]/.git/index.lock': File exists error fairly often while trying to do git rebase or git status in an external terminal. I'm using Ubuntu 14.04 with Git 2.13.0 and Visual Studio Code 1.14.2. I'm going to disable git.autorefresh (and probably git.autofetch) for now.

@joelhock
Copy link

joelhock commented Oct 2, 2017

One final comment on this closed issue. The atom developers have gotten a commit accepted to the git codebase that prevents git status from grabbing git/index.lock when --no-optional-locks or GIT_OPTIONAL_LOCKS=0 is specified. This seems like the best long-term solution for vscode and its extensions.
https://public-inbox.org/git/20170921043214.pyhdsrpy4omy54rm@sigill.intra.peff.net/

@joaomoreno
Copy link
Member

joaomoreno commented Oct 3, 2017

@joelhock This is awesome, thanks for the update! Created #35513 to track this.

@jyavenard
Copy link
Author

still happening in Version 1.17.1 (1.17.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests