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

query-watchman error when working in a worktree #338

Closed
marcodejongh opened this issue Feb 22, 2020 · 5 comments · Fixed by #340
Closed

query-watchman error when working in a worktree #338

marcodejongh opened this issue Feb 22, 2020 · 5 comments · Fixed by #340

Comments

@marcodejongh
Copy link

marcodejongh commented Feb 22, 2020

When I use worktree I get a query watchmen error for every git command:

mdejongh@C02XP02SJGH7|~/Projects/Atlassian/a-f2 on RenovateSharedConfig
± git status
fatal: cannot exec '.git/hooks/query-watchman': Not a directory
On branch RenovateSharedConfig
nothing to commit, working tree clean
mdejongh@C02XP02SJGH7|~/Projects/Atlassian/a-f2 on RenovateSharedConfig
±

I set my repo up using scalar register instead of clone, so figured maybe the old worktree's I had when I ran register were broken. But creating a new worktree from the main checkout, also returns a error:

mdejongh@C02XP02SJGH7|~/Projects/Atlassian/atlassian-frontend on master
± git worktree add ../a-f9 bla
Preparing worktree (checking out 'bla')
fatal: cannot exec '.git/hooks/query-watchman': Not a directory
Can't find Husky, skipping post-checkout hook
You can reinstall it using 'npm install husky --save-dev' or delete this hook
mdejongh@C02XP02SJGH7|~/Projects/Atlassian/atlassian-frontend on master
±
@jrbriggs
Copy link
Member

Thanks for the report, @marcodejongh ! We'll take a look.

@derrickstolee
Copy link
Contributor

Scalar can be improved to handle worktrees. In particular, we should probably set our fsmonitor hook setting in the worktree config (using git config --worktree ...) and then enable the ability in this worktree. I believe that Scalar will ignore the worktree if you try to run scalar register or scalar run config in the worktree.

@marcodejongh: you may be able to get out of this state by doing one of the following:

  1. Disable the hook in your worktree: git config --worktree core.fsmonitor ""
  2. Move the hook to your base dir hooks directory: git config core.fsmonitor "/full/path/to/repo/.git/hooks/query-fsmonitor"

Perhaps it is enough for Scalar to discover the fully-rooted path and use that in the config.

derrickstolee added a commit that referenced this issue Feb 24, 2020
Resolves #338.

This appears to be the issue:

Someone runs scalar register in a repository that has worktrees.
The worktrees start to use the core.fsmonitor config setting.
The worktree tries to execute from .git/hooks/query-watchman, but that is not a path relative to the worktree.
This fixes the configs setting.

I've tested this on my Windows machine with a worktree of git/git.

Cc: @kewillford the expert on fsmonitor. As a longer plan, we should consider adding tests that cover the case for worktrees.
@derrickstolee
Copy link
Contributor

@marcodejongh: This will be fixed in the next release. In my testing, my existing, incorrect config values were upgraded to the new values shortly after installing my new version (since we run scalar run config on every registered repo). For now, you can replace the core.fsmonitor config value with a fully-scoped path <repo>/.git/hooks/query-watchman.

@marcodejongh
Copy link
Author

Thanks will do!

@devinrhode2
Copy link

For anybody just googling - I am not using scaler, just git worktrees. At some point I enabled the query-watchman hook per the instructions here: https://github.com/git/git/blob/v2.28.0/templates/hooks--fsmonitor-watchman.sample
Then, adding a worktree, I could see this:

master ➤ git worktree add ../aCoWorker
Preparing worktree (new branch 'aCoWorker')
fatal: cannot exec '.git/hooks/query-watchman': Not a directory
fatal: cannot exec '.git/hooks/query-watchman': Not a directory
HEAD is now at ...

Fix from @derrickstolee worked great!
Just cd to main/original/host repo/worktree. Edit .git/config, and change core.fsmonitor config value to a fully-scoped path to the query-watchman file (<repo>/.git/hooks/query-watchman)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants