From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Robin Rosenberg <robin.rosenberg@dewire.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] cvsexportcommit: chomp only removes trailing whitespace
Date: Wed, 14 May 2008 10:58:33 -0700 [thread overview]
Message-ID: <7vskwkojhy.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.DEB.1.00.0805141526160.30431@racer> (Johannes Schindelin's message of "Wed, 14 May 2008 15:27:05 +0100 (BST)")
Johannes Schindelin <Johannes.Schindelin@gmx.de> 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@gmx.de>
> ---
>
> 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
next prev parent reply other threads:[~2008-05-14 17:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-14 14:27 [PATCH 1/2] cvsexportcommit: chomp only removes trailing whitespace Johannes Schindelin
2008-05-14 14:29 ` [PATCH 2/2] cvsexportcommit: introduce -W for shared working trees (between Git and CVS) Johannes Schindelin
2008-05-14 17:58 ` Junio C Hamano [this message]
2008-05-14 18:38 ` [PATCH 1/2] cvsexportcommit: chomp only removes trailing whitespace Johannes Schindelin
2008-05-14 20:06 ` Robin Rosenberg
2008-05-14 22:15 ` Johannes Schindelin
2008-05-14 22:30 ` [PATCH 1/2 v2] " Johannes Schindelin
2008-05-15 2:27 ` Junio C Hamano
2008-05-15 3:21 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vskwkojhy.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox