Skip to contentSkip to conversation

Remove "space damage" from patches

SCRIPT NAK Richard Knutsson 2 participants 8 messages Jan 28, 2007 – Jan 29, 2007

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 6 lines

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.

Quoted 8 lines

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".

____

#2 lore raw
Quoted 20 lines · Oleg Verych
Quoted 9 lines

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.

Quoted 7 lines

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 :)

Quoted 8 lines
Quoted 2 lines

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

#3 lore raw

29-01-2007, Richard Knutsson:

Quoted 11 lines
Quoted 5 lines · Oleg Verych

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.

Quoted 2 lines

Richard Knutsson

____

#4 lore raw
Quoted 10 lines · Oleg Verych

29-01-2007, Richard Knutsson:

Quoted 8 lines
Quoted 6 lines · Oleg Verych

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".

Quoted 8 lines
Quoted 2 lines

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

#5 lore raw

On Mon, Jan 29, 2007 at 02:26:04AM +0100, Richard Knutsson wrote:
[]

Quoted 3 lines

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.

Quoted 3 lines

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?

____

#6 lore raw
Quoted 8 lines · Oleg Verych

On Mon, Jan 29, 2007 at 02:26:04AM +0100, Richard Knutsson wrote:
[]

Quoted 2 lines

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).

Quoted 7 lines
Quoted 4 lines

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

#7 lore raw
Quoted 9 lines · Richard Knutsson
Quoted 8 lines · Oleg Verych

On Mon, Jan 29, 2007 at 02:26:04AM +0100, Richard Knutsson wrote:
[]

Quoted 4 lines

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.

Quoted 5 lines
Quoted 2 lines

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.

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

(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

Quoted 2 lines

Richard Knutsson

_____