sds/overcommit

Add support for working with git-worktree

egh opened this issue · 4 comments

egh commented

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-a

Expected 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

sds commented

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!

sds commented

For now, I've added a note to the README about the lack of support for git-worktree.

egh commented

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!

sds commented

Implemented in #559