Code

git svn: Don't create empty directories whose parents were deleted
authorGreg Price <price@ksplice.com>
Tue, 8 Dec 2009 03:28:32 +0000 (22:28 -0500)
committerEric Wong <normalperson@yhbt.net>
Tue, 8 Dec 2009 04:47:08 +0000 (20:47 -0800)
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>
git-svn.perl

index 51f03adb9ba41cb4b37158b4ea366f0444f9a3f9..bdd1f966c37cc3454bfcbd0968146dbd73578717 100755 (executable)
@@ -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;