@matheusbsbs / matheus-bagliano / commits / 9be30eed61
Fork 0

git svn: strip leading path when making empty dirs

Since unhandled.log stores paths relative to the repository root, we need to strip out leading path components if the directories we're tracking are not the repository root. Reported-by: Björn Steinbrink Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Nov 22, 2009 at 18:11 UTC 9be30eed61993a6f2d04a1609723e64e7632a64e
2 files changed +26
git-svn.perl
+3
@@ -2752,8 +2752,11 @@ sub mkemptydirs {
2752 }
2753 }
2754 close $fh;
2755 +
2756 + my $strip = qr/\A\Q$self->{path}\E(?:\/|$)/;
2757 foreach my $d (sort keys %empty_dirs) {
2758 $d = uri_decode($d);
2759 + $d =~ s/$strip//;
2760 next if -d $d;
2761 if (-e _) {
2762 warn "$d exists but is not a directory\n";
t/t9146-git-svn-empty-dirs.sh
+23
@@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '
82 )
83 '
84
85 +test_expect_success 'initialize trunk' '
86 + for i in trunk trunk/a trunk/"weird file name"
87 + do
88 + svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i"
89 + done
90 +'
91 +
92 +test_expect_success 'clone trunk' 'git svn clone -s "$svnrepo" trunk'
93 +
94 +test_expect_success 'empty directories in trunk exist' '
95 + (
96 + cd trunk &&
97 + for i in a "weird file name"
98 + do
99 + if ! test -d "$i"
100 + then
101 + echo >&2 "$i does not exist"
102 + exit 1
103 + fi
104 + done
105 + )
106 +'
107 +
108 test_done