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

Git: File events don't work if .git is outside the opened folder #41085

Closed
warpdesign opened this issue Jan 3, 2018 · 8 comments
Closed

Git: File events don't work if .git is outside the opened folder #41085

warpdesign opened this issue Jan 3, 2018 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues verified Verification succeeded
Milestone

Comments

@warpdesign
Copy link
Contributor

warpdesign commented Jan 3, 2018

  • VSCode Version: latest insider
  • OS Version: Windows 10 x64

The following bug only seems to happen when two folders belonging to the same parent git repository are added to the workspace. For example, here myApp is the repository:

myApp/
myApp/.git
myApp/foo
myApp/foo/test.js
myApp/bar
myApp/bar/test.js

Steps to Reproduce:

  1. open an empty VSCode window
  2. add the foo folder to the workspace
  3. add the bar folder to the workspace
  4. open one of the test.js file
  5. open the integrated terminal and type git checkout -b new_branch

What happens?
The branch sticks to master in the bottom left corner of vscode.

Note: Exiting VSCode and opening the previous workspace will correctly show the new_branch as current branch.

Reproduces without extensions: Yes

edit:
Problem also happens with macOS High Sierra. See my last comment.

@vscodebot vscodebot bot added the insiders label Jan 3, 2018
@vscodebot vscodebot bot added the git GIT issues label Jan 3, 2018
@warpdesign
Copy link
Contributor Author

warpdesign commented Jan 3, 2018

I looked at the git extension source code and noticed in extensions/git/repository.ts that the onFSChange() callback isn't executed in my case after running git checkout new_branch.

This explains why the status is never updated.

@warpdesign
Copy link
Contributor Author

warpdesign commented Jan 4, 2018

Question: couldn't the problem simply be that the fileSystemWatcher only listens for file changes inside the workspace (ie: in this example, only in myApp/bar and myApp/foo)?

If I create and switch to a new branch with checkout -b new_branch, no files would change inside the workspace (only inside the .git which isn't inside the workspace so is not tracked), the fsWatcher wouldn't trigger any change, and so the git's branch isn't updated in the statusBar.

Now, most of the time, switching branches will change at least one file inside the workspace, but not when creating new branch, so this would explain why it works in most cases.

@warpdesign
Copy link
Contributor Author

warpdesign commented Jan 5, 2018

I now know how to easily reproduce it, with the following folder structure:

myApp
myApp/foo
myApp/.git

Opening the myApp/foo folder is enough to trigger the problem.

In this case VSCode will detect the git repository found in foo's parent directory but will only listen for file changes inside the myApp/foo folder.

Creating a new branch, or changing a branch with no changes (eg. git checkout -b new_branch) won't make any file modifications inside myApp/foo folder, so won't trigger status update of the git branch.

@warpdesign warpdesign changed the title Git branch out of sync Git branch out of sync if .git is outside the workspace/folder Jan 5, 2018
@joaomoreno joaomoreno modified the milestones: Backlog, December 2017/January 2018 Jan 8, 2018
@joaomoreno joaomoreno added the bug Issue identified by VS Code Team member as probable bug label Jan 8, 2018
@joaomoreno
Copy link
Member

Yup.

@jrieken @bpasero This happens because the .git folder is up the directory chain and outside the workspace. The git extensions gets no file events within it. This was working fine when I was using fs.watch, and stopped working as soon as I moved to workspace.createFileSystemWatcher. Have you guys considered providing a file system watcher creator function which lets me pick any root?

@joaomoreno joaomoreno modified the milestones: December 2017/January 2018, Backlog Jan 9, 2018
@jrieken
Copy link
Member

jrieken commented Jan 9, 2018

Exposing this in the API is easy ;-)

@bpasero
Copy link
Member

bpasero commented Jan 9, 2018

@joaomoreno not easy without a reliable watcher, but we have #3025 for it already.

@joaomoreno
Copy link
Member

Well this is really just a duplicate of #3025, which I failed to find in my search efforts.

@joaomoreno joaomoreno added *duplicate Issue identified as a duplicate of another issue(s) and removed bug Issue identified by VS Code Team member as probable bug git GIT issues labels Jan 10, 2018
@vscodebot
Copy link

vscodebot bot commented Jan 10, 2018

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

Happy Coding!

@joaomoreno joaomoreno removed this from the Backlog milestone Jan 10, 2018
@vscodebot vscodebot bot closed this as completed Jan 10, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 24, 2018
@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug git GIT issues and removed *duplicate Issue identified as a duplicate of another issue(s) labels Apr 23, 2018
@joaomoreno joaomoreno added this to the May 2018 milestone Apr 23, 2018
@joaomoreno joaomoreno modified the milestones: May 2018, Backlog Apr 23, 2018
@joaomoreno joaomoreno reopened this Apr 23, 2018
@microsoft microsoft unlocked this conversation Apr 23, 2018
@joaomoreno joaomoreno changed the title Git branch out of sync if .git is outside the workspace/folder Git: File events don't work if .git is outside the workspace/folder Sep 18, 2018
@joaomoreno joaomoreno changed the title Git: File events don't work if .git is outside the workspace/folder Git: File events don't work if .git is outside the opened folder Sep 18, 2018
@joaomoreno joaomoreno modified the milestones: Backlog, June 2019 Jun 3, 2019
joaomoreno added a commit that referenced this issue Jun 6, 2019
@RMacfarlane RMacfarlane added the verified Verification succeeded label Jun 26, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 27, 2019
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

5 participants