Re: [PATCH (amend)] gitweb: Use File::Find::find in git_get_projects_list

From: Randal L. Schwartz <merlyn@stonehenge.com>
Date: 2006-09-15 07:50:24
>>>>> "Jakub" == Jakub Narebski <jnareb@gmail.com> writes:

Jakub> +		sub wanted {
Jakub> +			# only directories can be git repositories
Jakub> +			return unless (-d $_);
Jakub> +
Jakub> +			my $subdir = substr($File::Find::name, $pfxlen + 1);
Jakub> +			# we check related file in $projectroot
Jakub> +			if (-e "$projectroot/$subdir/HEAD") {
Jakub> +				push @list, { path => $subdir };
Jakub> +				$File::Find::prune = 1;
Jakub>  			}
Jakub>  		}
Jakub> -		closedir($dh);
Jakub> +
Jakub> +		File::Find::find({
Jakub> +			follow_fast => 1, # follow symbolic links
Jakub> +			dangling_symlinks => 0, # ignore dangling symlinks, silently
Jakub> +			wanted => \&wanted,
Jakub> +		}, "$dir");

Don't define a sub inside a sub.  That's the "won't stay shared"
problem.

Move that like this:

find( {
        follow_fast => 1,
        dangling_symlinks => 0,
        wanted => sub {

                ... everything in &wanted above ...

        }, $dir);

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Sep 15 07:50:36 2006

This archive was generated by hypermail 2.1.8 : 2006-09-15 07:51:57 EST