Re: [PATCH 1/2] cvsexportcommit: chomp only removes trailing whitespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:

> In commit fef3a7cc(cvsexportcommit: be graceful when "cvs status"
> reorders the arguments), caution was taken to get the status even
> for files with leading or trailing whitespace.
>
> However, the author of that commit missed that chomp() removes only
> trailing whitespace.  But the author realized his mistake.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
> ---
>
> 	Really my fault.

I am not quite sure if I understand what is going on correctly.

Is this about a filename that has leading or trailing whitespace, or
lazily not parsing a protocol message but attempting to match with
possible whitespaces around the place where a filename should be?

If you are saying that the output from cvs status is so unreliable that we
can only strip all whitespaces from both ends and hope for the best
(e.g. files " a" (two leading spaces in the name), "a " (two trailing
spaces in the name), and "a" (no such funny spaces) cannot be
distinguished from cvs status output), then perhaps you would also need to
remove as many trailing whitespaces as you can?

"chomp()" chomps only a single line terminator, and only if one exists.

        sub foo {
                my ($a) = @_;
                chomp($a);
                print join(" ", map { sprintf "%02x", ord($_) } split(//, $a)), "\n";
        }
        foo("abc");    # 61 62 63
        foo("def\n");  # 64 65 66
        foo("gh \n");  # 67 68 20
        foo("ij\n\n"); # 69 6a 0a

>  git-cvsexportcommit.perl |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
> index b6036bd..3b20bd1 100755
> --- a/git-cvsexportcommit.perl
> +++ b/git-cvsexportcommit.perl
> @@ -211,6 +211,7 @@ if (@canstatusfiles) {
>  
>  	$basename = "no file " . $basename if (exists($added{$basename}));
>  	chomp($basename);
> +	$basename =~ s/^\s+//;
>  
>  	if (!exists($fullname{$basename})) {
>  	  $fullname{$basename} = $name;
> -- 
> 1.5.5.1.375.g1becb
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux