mlawren / githook-perltidy

Run perltidy as a Git pre-commit hook
41 stars 10 forks source link

could not open .git/MERGE_HEAD #8

Closed mrenvoize closed 8 years ago

mrenvoize commented 8 years ago

Every time I have a merge with conflicts githook-perltidy "breaks" the merge commit message. this is what appear after fixing the conflicts and trying to commit the merge:

  1 # It looks like you may be committing a merge.
  2 # If this is not correct, please remove the file
  3 # .git/MERGE_HEAD
  4 # and try again.
  5 
  6 
  7 # Please enter the commit message for your changes. Lines starting
  8 # with '#' will be ignored, and an empty message aborts the commit.

and on closing the editor:

fatal: could not open '.git/MERGE_HEAD' for reading: No such file or directory
mrenvoize commented 8 years ago

This looks extremely similar to: https://github.com/brigade/overcommit/issues/52 I wonder if the fix there can be used as a basis for a fix here?

mlawren commented 8 years ago

On Wed May 11, 2016 at 03:23:14AM -0700, Martin Renvoize wrote:

Every time I have a merge with conflicts githook-perltidy "breaks" the merge commit message.

Thanks for reporting this. I must admit I had seen that error occasionally but hadn't gotten around to tracking down under which conditions it occurred.

This looks extremely similar to: https://github.com/brigade/overcommit/issues/52 I wonder if the fix there can be used as a basis for a fix here?

I have actually been thinking that using git-stash is the wrong way for githook-perltidy to do what it does. Apart from the merge issue it is also problematic if the tidied code and the stashed code conflict: applying the stash in the post-commit hook fails leaving the repo and working tree in a bad state.

I did a quick bit of research and I think a better option will be to rework githook-perltidy in terms of git-checkout-index and git-update-index/git-read-tree. Will take me a couple of weeks to get round to doing that though.

Mark Lawrence

mrenvoize commented 8 years ago

Sounds interesting.. I've been wondering similar things though hadn't managed to get round to looking into the specifics.

Wish I wasn't so lacking in time at the minute else I'd have a stab myself.

Many thanks,

mlawren commented 8 years ago

I have just uploaded MLAWREN/App-githook-perltidy-0.11.3_1.tar.gz which you can test if you like. It is basically a rewrite that does everything in a temporary work tree instead of the main one. Since it doesn't use git-stash at all it should not conflict with merges.

Once the cpantesters have given it a decent run I'll do a stable release.

mrenvoize commented 8 years ago

Awesome! I'll have a play over the next couple of days.. many thanks for working on it :)

mlawren commented 8 years ago

Closing this as version 0.11.4 is now on CPAN.