Skip to content

Commit 9be30ee

Browse files
author
Eric Wong
committed
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>
1 parent 4d0157d commit 9be30ee

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

git-svn.perl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,8 +2752,11 @@ sub mkemptydirs {
27522752
}
27532753
}
27542754
close $fh;
2755+
2756+
my $strip = qr/\A\Q$self->{path}\E(?:\/|$)/;
27552757
foreach my $d (sort keys %empty_dirs) {
27562758
$d = uri_decode($d);
2759+
$d =~ s/$strip//;
27572760
next if -d $d;
27582761
if (-e _) {
27592762
warn "$d exists but is not a directory\n";

t/t9146-git-svn-empty-dirs.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '
8282
)
8383
'
8484

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+
85108
test_done

0 commit comments

Comments
 (0)