Add support for working with git-worktree
egh opened this issue · 4 comments
Steps to reproduce:
git init foo && cd foo
echo "gem 'overcommit'" > Gemfile
bundle install
overcommit
overcommit --sign
git add Gemfile* .overcommit.yml
git commit -a -m 'init'
git worktree add ../foo-aExpected behavior: no error.
Actual behavior (after running git worktree add ../foo-a):
Enter ../foo-a (identifier foo-a)
Switched to a new branch 'foo-a'
No such file or directory @ rb_file_s_size - /home/egh/foo/.git/worktrees/foo-a/hooks/overcommit-hook
/home/egh/.rbenv/versions/2.2.3/lib/ruby/2.2.0/fileutils.rb:815:in `size'
/home/egh/.rbenv/versions/2.2.3/lib/ruby/2.2.0/fileutils.rb:815:in `compare_file'
/home/egh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/overcommit-0.31.0/lib/overcommit/installer.rb:54:in `update'
/home/egh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/overcommit-0.31.0/lib/overcommit/installer.rb:20:in `run'
/home/egh/foo/.git/hooks/post-checkout:67:in `<main>'
Report this bug at https://github.com/brigade/overcommit/issues
Environment:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
overcommit: 0.31.0
git version 2.5.0
os: GNU/Linux, Ubuntu 15.10
Hey @egh, thanks for the report.
git-worktree didn't exist (i.e. Git 2.5 hadn't been released) when Overcommit was first created. I haven't had much opportunity to personally play around with the feature as my primary professional development environment is still on Git 1.8.3.1 (CentOS 7). Thus I'm not sure how much work it would take to add support for it to Overcommit (it may not be much).
Having said that, I would love to merge a pull request adding support!
For now, I've added a note to the README about the lack of support for git-worktree.
Unfortunately, I don't even use git-worktree - I was just trying it out. I assume the fix would be easy, but I don't know overcommit of git-worktree, so I'm not sure I'll have the time to fix it. Thanks for the README note!