* Possible meaningless block in perl/Git/SVN/Fetcher.pm: sub find_empty_directories
@ 2013-04-27 19:10 Ilya Basin
0 siblings, 0 replies; only message in thread
From: Ilya Basin @ 2013-04-27 19:10 UTC (permalink / raw)
To: git; +Cc: Ray Chen
Hi list, Hi Ray.
Ray Chen who coded this part didn't show up in this list since 2011,
so I'm asking everyone else.
Also, I don't know perl. Excuse me, if the question is stupid.
Here's the function. It's supposed to return a list of directories
that became empty during this commit. The returned paths should be SVN
paths (like "trunk/*"), but that's another question.
My comments inside.
sub find_empty_directories {
my ($self) = @_;
my @empty_dirs;
my %dirs = map { dirname($_) => 1 } @deleted_gpath;
foreach my $dir (sort keys %dirs) {
next if $dir eq ".";
IB> ################################################
IB> The variable $dir isn't used here.
IB> I think the value of $skip_added will be the same (0 or 1) in all
IB> iterations, regardless of $dir
# If there have been any additions to this directory, there is
# no reason to check if it is empty.
my $skip_added = 0;
foreach my $t (qw/dir_prop file_prop/) {
foreach my $path (keys %{ $self->{$t} }) {
if (exists $self->{$t}->{dirname($path)}) {
$skip_added = 1;
last;
}
}
last if $skip_added;
}
next if $skip_added;
IB> ################################################
# Use `git ls-tree` to get the filenames of this directory
# that existed prior to this particular commit.
my $ls = command('ls-tree', '-z', '--name-only',
$self->{c}, "$dir/");
my %files = map { $_ => 1 } split(/\0/, $ls);
# Remove the filenames that were deleted during this commit.
delete $files{$_} foreach (@deleted_gpath);
# Report the directory if there are no filenames left.
push @empty_dirs, $dir unless (scalar %files);
}
@empty_dirs;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-04-27 19:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-27 19:10 Possible meaningless block in perl/Git/SVN/Fetcher.pm: sub find_empty_directories Ilya Basin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).