[Libreoffice] automagic 'fix' in pre-commit hook considered harmful
nthiebaud at gmail.com
Wed Jun 22 00:16:27 PDT 2011
A 'git' bug has been reported some times ago by Tor Lillqvist. the
symptom was that on a partial commit the rest of the changes (the
uncommited part') would 'disappear'.
Unfortunately the condition to reproduce that problem eluded us...
While reviewing the EasyHack list, I noticed one about the pre-commit
hook... I took a look and realized that
the hook was actually trying to 'fix' things on the fly... That is a
very scary proposition... what if something goes wrong ?
(the code that try to do the fixing is far from trivial, involving git
stash and temp-files dance...)
which reminded me of Tor's bug.
Sure enough: do 2 changes in a file, in 2 separate hunk. in one of
these change add trailing spaces... then commit only that hunk -> the
second hunk 'disappear'
So, since I do think that even trying to silently overrule the dev by
changing his commit on the fly is a Bad Thing(tm), I did not even try
to make that magic work in the case of partial commit... instead I
replaced the code by a pure detection, that yell at you when you try
trailing spaces (but is nice enough to tell you where they are)
This is now pushed on bootstrap... (the other gits share the hook of bootstrap)
PS: I have not clean-up the entire hook... there is still some love
that can be dispensed there; like: do we really need to spend time to
grep for old 'Sun' license to warn about them ?
More information about the LibreOffice