Fixing whitespace when applying patches with git

The way the Koha project works is that we require any patch to be signed off at least by 2 people, usually 3, ideally even more. So we do a lot of applying of patches. Using git-bz this is very easy, but occasionally  when applying a patch you spot whitespace errors and if you are like me, you want to fix them, and if you are also like me, you are lazy.

What I have done is set these 2 options

git config --global core.whitespace trailing-space,space-before-tab
git config --global apply.whitespace fix

So this is what used to happen:

% git checkout -b 5729 kc/master
Previous HEAD position was 288c1a7... Bug 7139 : 
Log addition and deletion of circulation messages
Branch 5729 set up to track remote branch master from kc.
Switched to a new branch '5729'
% git bz apply 5729
bugs.koha-community.org
Bug 5729 - Add coins information to the intranet

Bug 5729 - Add CoinS to intranet
Apply? [yn] y

Applying: Bug 5729 - Add CoinS to intranet
/home/chrisc/git/catalyst-koha/.git/rebase-apply/patch:61: trailing whitespace.
[% END %]
/home/chrisc/git/catalyst-koha/.git/rebase-apply/patch:76: trailing whitespace.
[% END %]
/home/chrisc/git/catalyst-koha/.git/rebase-apply/patch:91: trailing whitespace.
[% END %]
warning: 3 lines add whitespace errors.

And now with the config set

% git bz apply 5729
bugs.koha-community.org
Bug 5729 - Add coins information to the intranet

Bug 5729 - Add CoinS to intranet
Apply? [yn] y

Applying: Bug 5729 - Add CoinS to intranet
/home/chrisc/git/catalyst-koha/.git/rebase-apply/patch:61: trailing whitespace.
    [% END %]
/home/chrisc/git/catalyst-koha/.git/rebase-apply/patch:76: trailing whitespace.
[% END %]
/home/chrisc/git/catalyst-koha/.git/rebase-apply/patch:91: trailing whitespace.
    [% END %]
warning: 3 lines applied after fixing whitespace errors.

Patch applied with the whitespace fix I can now  test then signoff

git commit --amend -s

And attach to the bug

git bz attach -e 5729 HEAD
Posted on December 15, 2011 at 1:42 pm by Chris · Permalink
In: Geek, Koha · Tagged with: ,

One Response

Subscribe to comments via RSS

  1. Written by Paul Poulain
    on April 5, 2012 at 3:55 am
    Permalink

    To add a comment: this can also fix tab indentation errors.

    The following parameter will transform all tabs into 4 spaces:
    git config –global core.whitespace trailing-space,space-before-tab,tab-in-indent,tabwidth=4

    (I just tested that with bug 7876 http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7876)

Subscribe to comments via RSS