git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 14, 2008, 22:30 UTC
Message-ID
<alpine.DEB.1.00.0805142327520.30431@racer>
In-Reply-To
<alpine.DEB.1.00.0805141936410.30431@racer>

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 newlines. With help of the mailing list, the author realized his mistake and provided this patch.

The idea is that we do not want to rely on a certain layout of the output of "cvs status". Therefore we only call it with files that are unambiguous after stripping leading and trailing whitespace.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Wed, 14 May 2008, Johannes Schindelin wrote:
	> To prevent bad things from happening, the status is checked on a 
	> set of files which have unique names with regard to the chomp()ed
	> name (well, whatever we do to the name, really).
	> 
	> So yes, this patch needs an update.
	> 
	> Will do so in a couple of hours,
	And so I did.
 git-cvsexportcommit.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index b6036bd..52ba7de 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -210,7 +210,7 @@ if (@canstatusfiles) {
 	my $basename = basename($name);
 
 	$basename = "no file " . $basename if (exists($added{$basename}));
-	chomp($basename);
+	$basename =~ s/^\s+(.*?)\s*$/$1/;
 
 	if (!exists($fullname{$basename})) {
 	  $fullname{$basename} = $name;
-- 
1.5.5.1.375.g1becb
Previous: Johannes SchindelinNext: Junio C Hamano
Message 7 of 9 in “cvsexportcommit: chomp only removes trailing whitespace”
  1. 1/2 cvsexportcommit: chomp only removes trailing whitespaceJohannes Schindelin, May 14, 2008
  2. 2/2 cvsexportcommit: introduce -W for shared working trees (between Git and CVS)Johannes Schindelin, May 14, 2008
  3. Junio C HamanoMay 14, 2008
  4. Johannes SchindelinMay 14, 2008
  5. Robin RosenbergMay 14, 2008
  6. Johannes SchindelinMay 14, 2008
  7. 1/2 cvsexportcommit: chomp only removes trailing whitespaceJohannes Schindelin, May 14, 2008
  8. Junio C HamanoMay 15, 2008
  9. Johannes SchindelinMay 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.