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

One thought on “Fixing whitespace when applying patches with git”

Comments are closed.