[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] [PATCH] remove-trailing-ws
From: |
Jean Delvare |
Subject: |
Re: [Quilt-dev] [PATCH] remove-trailing-ws |
Date: |
Mon, 17 Dec 2012 18:00:53 +0100 |
Le vendredi 14 décembre 2012 à 15:36 +0100, Andreas Krebbel a écrit :
> On 14/12/12 15:13, Jean Delvare wrote:
> > Actually I found that your fix is needed but not sufficient. It works
> > fine if the hunk which is only removing lines is at the end of the file.
> > However, if it is not and the hunk immediately after is adding lines
> > with trailing whitespace to another file, the script will get the file
> > name wrong. It was already the case before, and doesn't fail with "I'm
> > confused", just the output is wrong. So I have changed your fix to:
> >
> > --- a/quilt/scripts/remove-trailing-ws.in
> > +++ b/quilt/scripts/remove-trailing-ws.in
> > @@ -88,8 +88,8 @@ while (<>) {
> > my $last_line = defined $2 ? $2 : $1;
> > while ($line_number <= $last_line) {
> > $_ = <>;
> > - defined $_
> > - or die sprintf(_("%s: I'm confused.\n"), $0);
> > + defined $_ or last;
> > + last if /^diff / || /^\*\*\* /;
> > if (s/(^[+!] .*?)[ \t]+$/$1/) {
> > push @{$files{$file}}, $line_number;
> > }
> >
> > Is it OK with you?
>
> Right that's missing. But why do you check for ^diff ? For a context diff I
> would expect the line
> after the empty chunk to start with "Index: ".
>
> Feel free to adjust the patch as you want. Thanks!
I came up with the following, which passes the test suite (my previous
attempt did not.)
From: Andreas Krebbel <address@hidden>
Subject: remove-trailing-ws: Fix parsing of some context diffs
the script for trailing whitespace removal fails for me if a
context diff has an "delete-only" chunk at the end. The following
patch fixes this for me.
[JD: Add one more check for when the "delete-only" chunk is
not at the end.]
---
quilt/scripts/remove-trailing-ws.in | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/quilt/scripts/remove-trailing-ws.in
+++ b/quilt/scripts/remove-trailing-ws.in
@@ -88,14 +88,13 @@ while (<>) {
my $last_line = defined $2 ? $2 : $1;
while ($line_number <= $last_line) {
$_ = <>;
- defined $_
- or die sprintf(_("%s: I'm confused.\n"), $0);
+ defined $_ or last;
if (s/(^[+!] .*?)[ \t]+$/$1/) {
push @{$files{$file}}, $line_number;
}
$line_number++;
print unless $opt_n;
- last if (/^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/);
+ last if (/^\*\*\*[* ]/);
}
} elsif (/^--- (.+?)(?:[ \t][^\t]*)?$/) {
$file = $1;
--
Jean Delvare
Suse L3