git svn: Don't create empty directories whose parents were deleted

Commit 6111b93 "git svn: attempt to create empty dirs on clone+rebase"
will create empty directories 'a/b' and 'a/c' if they were previously
created in SVN, even if their parent directory 'a' was deleted.

For example, unhandled.log may contain lines like this:

r32
  +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/acl
  +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/machine.d
  +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/moira-acl
[...]
r314
  -empty_dir: packages/sipb-xen-remctl-auto

[ew: rewrote to be line-wrapped at <= 80-columns]

Reported-by: Evan Broder <broder@mit.edu>
Signed-off-by: Greg Price <price@ksplice.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
Greg Price 2009-12-07 22:28:32 -05:00 committed by Eric Wong
parent e9e4c8b747
commit 33f2a3108e

View File

@ -2748,7 +2748,8 @@ sub mkemptydirs {
} elsif (/^ \+empty_dir: (.+)$/) {
$empty_dirs{$1} = 1;
} elsif (/^ \-empty_dir: (.+)$/) {
delete $empty_dirs{$1};
my @d = grep {m[^\Q$1\E(/|$)]} (keys %empty_dirs);
delete @empty_dirs{@d};
}
}
close $fh;