2007-01-28 21:37:11

by Richard Knutsson

[permalink] [raw]
Subject: [SCRIPT] Remove "space damage" from patches

Hello Andrew and all

I recently tried "git-apply" on the 2.6.20-rc6-mm1 patch and found it to complain about white-spaces.
So as a mean to (hopefully) cut down on these nasty white-spaces (and sometimes tabs) I wrote this
little script. All it does is checking (lines that are going to be added) for spaces before tabs
and trailing spaces/tabs. I tried it on 2.6.20-rc6-mm1 and it seem to work well

If there is someone interested, _please_ take it. Any suggestion are welcomed :)

Richard Knutsson

---

#!/bin/sh

#./<script-name> <patch to check>

msg="Checking..."
echo $msg

while [ "$msg" ]; do \

msg=""

if grep -q -E "^\+ * + " $1; then \
msg="Found whitespace before tab"
echo $msg
sed --in-place -r "s/^\+( *) {8}( *) /\+\1 \2 /" $1
sed --in-place -r "s/^\+( *) {1,7} /\+\1 /" $1
fi

if grep -q -E "^\+.*[ ]$" $1; then \
msg="Found trailing whitespace/tab"
echo $msg
sed --in-place -r "s/^\+(.*)([^ ])[ ]+$/\+\1\2/" $1
sed --in-place -r "s/^\+[ ]+$/\+/" $1
fi

if [ "$msg" != "" ]; then \
echo "Cleaning done, will make another run"
fi
done



2007-01-28 22:52:34

by Oleg Verych

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

> From: Richard Knutsson
> Newsgroups: gmane.linux.kernel
> Subject: [SCRIPT] Remove "space damage" from patches
> Date: Sun, 28 Jan 2007 22:37:01 +0100

> Hello Andrew and all

Hallo.

> I recently tried "git-apply" on the 2.6.20-rc6-mm1 patch and found it to complain about white-spaces.
> So as a mean to (hopefully) cut down on these nasty white-spaces (and sometimes tabs) I wrote this
> little script. All it does is checking (lines that are going to be added) for spaces before tabs
> and trailing spaces/tabs. I tried it on 2.6.20-rc6-mm1 and it seem to work well
>
> If there is someone interested, _please_ take it. Any suggestion are welcomed :)
>
> Richard Knutsson

Nack, big and fat. It's userspace problem.

If our "developers" can't use or update their every-day-tools, it's a
shame. And this is not trolling: i'm using Jed and GNU Emacs, both are
ok with whitespace "production".

____

2007-01-29 00:08:37

by Richard Knutsson

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

Oleg Verych wrote:
>> From: Richard Knutsson
>> Newsgroups: gmane.linux.kernel
>> Subject: [SCRIPT] Remove "space damage" from patches
>> Date: Sun, 28 Jan 2007 22:37:01 +0100
>>
>
>
>> Hello Andrew and all
>>
>
> Hallo.
>
>
>> I recently tried "git-apply" on the 2.6.20-rc6-mm1 patch and found it to complain about white-spaces.
>> So as a mean to (hopefully) cut down on these nasty white-spaces (and sometimes tabs) I wrote this
>> little script. All it does is checking (lines that are going to be added) for spaces before tabs
>> and trailing spaces/tabs. I tried it on 2.6.20-rc6-mm1 and it seem to work well
>>
>> If there is someone interested, _please_ take it. Any suggestion are welcomed :)
>>
>> Richard Knutsson
>>
>
> Nack, big and fat. It's userspace problem.
>
> If our "developers" can't use or update their every-day-tools, it's a
> shame. And this is not trolling: i'm using Jed and GNU Emacs, both are
> ok with whitespace "production".
Oh, I hope I didn't give the impression I wanted it in the kernel (that
is why i labeled it as SCRIPT and not PATCH), as you said it is a
userspace problem. I just thought a simple script to remove those
whitespace could help in an imperfect world. I prefer kate since then
you can see where the tabs begins (and other features).

Richard Knutsson

2007-01-29 00:31:34

by Oleg Verych

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

29-01-2007, Richard Knutsson:
> Oleg Verych wrote:
>> Nack, big and fat. It's userspace problem.
>>
>> If our "developers" can't use or update their every-day-tools, it's a
>> shame. And this is not trolling: i'm using Jed and GNU Emacs, both are
>> ok with whitespace "production".
> Oh, I hope I didn't give the impression I wanted it in the kernel (that
> is why i labeled it as SCRIPT and not PATCH), as you said it is a
> userspace problem. I just thought a simple script to remove those
> whitespace could help in an imperfect world. I prefer kate since then
> you can see where the tabs begins (and other features).

Just to give you idea, how imperfect it is:
<http://marc.theaimsgroup.com/?l=linux-mm-commits&m=116198944205036&w=2>

Anyway, i still think programmers *must* take care of it, if they think
they _are_ Programmers. IMHO LKML already gives obligation to be one.

> Richard Knutsson
>
____

2007-01-29 01:26:18

by Richard Knutsson

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

Oleg Verych wrote:
> 29-01-2007, Richard Knutsson:
>
>> Oleg Verych wrote:
>>
>>> Nack, big and fat. It's userspace problem.
>>>
>>> If our "developers" can't use or update their every-day-tools, it's a
>>> shame. And this is not trolling: i'm using Jed and GNU Emacs, both are
>>> ok with whitespace "production".
>>>
>> Oh, I hope I didn't give the impression I wanted it in the kernel (that
>> is why i labeled it as SCRIPT and not PATCH), as you said it is a
>> userspace problem. I just thought a simple script to remove those
>> whitespace could help in an imperfect world. I prefer kate since then
>> you can see where the tabs begins (and other features).
>>
>
> Just to give you idea, how imperfect it is:
> <http://marc.theaimsgroup.com/?l=linux-mm-commits&m=116198944205036&w=2>
>
> Anyway, i still think programmers *must* take care of it, if they think
> they _are_ Programmers. IMHO LKML already gives obligation to be one
Then I hope you don't mind me asking, why is there (L)indent? Everyone
can make a mistake and if your editor does not auto-format then there
may be a whitespace straying.
I also guess you saw that the script is _not_ for cleaning up
source-files (can be intrusive and is better to be fixed when fixing
something else), but patches. So if a maintainer does not have anything
to easily fix those, they might want a simple script to do the work
(otherwise I believe they just deleted my mail ;) ).

As I said in the posting, it is just if someone is interested in it,
otherwise you have a Del-button.

Richard Knutsson

2007-01-29 01:34:59

by Oleg Verych

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

On Mon, Jan 29, 2007 at 02:26:04AM +0100, Richard Knutsson wrote:
[]
> I also guess you saw that the script is _not_ for cleaning up
> source-files (can be intrusive and is better to be fixed when fixing
> something else), but patches.

IMHO it's dealing with consequences, not cause, and it's even worse.

> So if a maintainer does not have anything to easily fix those, they
> might want a simple script to do the work (otherwise I believe they
> just deleted my mail ;) ).

I would like to discuss, would you?

____

2007-01-29 02:00:48

by Richard Knutsson

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

Oleg Verych wrote:
> On Mon, Jan 29, 2007 at 02:26:04AM +0100, Richard Knutsson wrote:
> []
>
>> I also guess you saw that the script is _not_ for cleaning up
>> source-files (can be intrusive and is better to be fixed when fixing
>> something else), but patches.
>>
>
> IMHO it's dealing with consequences, not cause, and it's even worse.
>
How many patches is not to fix bugs, it is worse then some strayed
whitespace but it is due to reality.
The best is, of course, if neither happened but the next best thing is
to fix it. And if it can be automated, even better (imho).
>> So if a maintainer does not have anything to easily fix those, they
>> might want a simple script to do the work (otherwise I believe they
>> just deleted my mail ;) ).
>>
>
> I would like to discuss, would you?
>
I like to discuss but I am not sure what the result would be. Force
people to use the editors of our choice?
As long people uses valid e-mail-clients when sending patches (or they
use the script "sendpatchset"), I'm think we have to be satisfied.
But if you have any ideas, I'm listening.

Richard Knutsson

2007-01-29 02:19:11

by Oleg Verych

[permalink] [raw]
Subject: Re: [SCRIPT] Remove "space damage" from patches

On Mon, Jan 29, 2007 at 03:00:35AM +0100, Richard Knutsson wrote:
> Oleg Verych wrote:
> >On Mon, Jan 29, 2007 at 02:26:04AM +0100, Richard Knutsson wrote:
> >[]
> >
> >>I also guess you saw that the script is _not_ for cleaning up
> >>source-files (can be intrusive and is better to be fixed when fixing
> >>something else), but patches.
> >>
> >
> >IMHO it's dealing with consequences, not cause, and it's even worse.
> >
> How many patches is not to fix bugs, it is worse then some strayed
> whitespace but it is due to reality.
> The best is, of course, if neither happened but the next best thing is

1. Patches are signed-off (not by you).
2. Maybe Andrew Morton under his sign-off add such feature.

> >> (otherwise I believe they just deleted my mail ;) ).
> >>
> >
> >I would like to discuss, would you?
> >
> I like to discuss but I am not sure what the result would be. Force
> people to use the editors of our choice?
> As long people uses valid e-mail-clients when sending patches (or they
> use the script "sendpatchset"), I'm think we have to be satisfied.
> But if you have any ideas, I'm listening.

Open-source worker, hammering his fingers? Please, let me out it ;D

> Richard Knutsson
>

_____