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

[PATCH] Fix reading of cloud tags

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 15, 2008, 04:27 UTC
Message-ID
<7v1vyi5vq7.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<20081014000812.GZ4856@spearce.org>

The projectroot path could have SP in it, in which case iterating over <$git_dir/ctags/*> does not correctly enumerate the cloud tags files at all.

This can be observed by creating an empty t/trash directory and running t9500 test. The $projectroot ends with "trash directory.t9500-gitweb-/" and <$glob> would give "trash", which can be opened and reading from it immediately yields undef, which in turn gives an undef value warning to the standard error stream upon attempt to chomp it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 gitweb/gitweb.perl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git c/gitweb/gitweb.perl w/gitweb/gitweb.perl
index 1116800..577c041 100755
--- c/gitweb/gitweb.perl
+++ w/gitweb/gitweb.perl
@@ -1805,7 +1805,8 @@ sub git_get_project_ctags {
 	my $ctags = {};
 
 	$git_dir = "$projectroot/$path";
-	foreach (<$git_dir/ctags/*>) {
+	opendir D, "$git_dir/ctags";
+	foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir(D)) {
 		open CT, $_ or next;
 		my $val = <CT>;
 		chomp $val;
@@ -1813,6 +1814,7 @@ sub git_get_project_ctags {
 		my $ctag = $_; $ctag =~ s#.*/##;
 		$ctags->{$ctag} = $val;
 	}
+	closedir D;
 	$ctags;
 }
 
Previous: Shawn O. PearceNext: Junio C Hamano
Message 4 of 6 in “Puzzled by a t9500 test failure”
  1. Junio C HamanoOct 13, 2008
  2. Shawn O. PearceOct 13, 2008
  3. Shawn O. PearceOct 14, 2008
  4. Fix reading of cloud tagsJunio C Hamano, Oct 15, 2008
  5. Junio C HamanoOct 14, 2008
  6. Shawn O. PearceOct 14, 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.