{"thread":{"id":"15963","subject":"[PATCH/RFR&A] Fix reading of cloud tags","startedAt":"2008-10-19T07:06:57Z","lastAt":"2008-10-19T07:06:57Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"93416","messageId":"7vbpxh83n2.fsf@gitster.siamese.dyndns.org","threadId":"15963","inReplyTo":null,"subject":"[PATCH/RFR&A] Fix reading of cloud tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-19T07:06:57Z","receivedAt":"2008-10-19T07:06:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is in 'next' but it would be nice to get acked before advancing it to\nmaster.\n\n-- >8 --\n\nThe projectroot path could have SP in it, in which case iterating over\n<$git_dir/ctags/*> does not correctly enumerate the cloud tags files at\nall.\n\nThis can be observed by creating an empty t/trash directory and running\nt9500 test.  The $projectroot ends with \"trash directory.t9500-gitweb-/\"\nand <$glob> would give \"trash\", which can be opened and reading from it\nimmediately yields undef, which in turn gives an undef value warning to\nthe standard error stream upon attempt to chomp it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n gitweb/gitweb.perl |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1116800..41b6866 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1805,7 +1805,10 @@ sub git_get_project_ctags {\n \tmy $ctags = {};\n \n \t$git_dir = \"$projectroot/$path\";\n-\tforeach (<$git_dir/ctags/*>) {\n+\tunless (opendir D, \"$git_dir/ctags\") {\n+\t\treturn $ctags;\n+\t}\n+\tforeach (grep { -f $_ } map { \"$git_dir/ctags/$_\" } readdir(D)) {\n \t\topen CT, $_ or next;\n \t\tmy $val = <CT>;\n \t\tchomp $val;\n@@ -1813,6 +1816,7 @@ sub git_get_project_ctags {\n \t\tmy $ctag = $_; $ctag =~ s#.*/##;\n \t\t$ctags->{$ctag} = $val;\n \t}\n+\tclosedir D;\n \t$ctags;\n }\n \n-- \n1.6.0.2.767.g8f0e\n"}]}