threads / patch / 33661

patch, 2 partsgit-svn: fix occasional "Failed to strip path" error on fetch next commit

Subject: [PATCH 1/2] git-svn: fix occasional "Failed to strip path" error on fetch next commit

## tl;dr

2 messages between Apr 28, 2013 and Apr 28, 2013. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Ilya Basin· Apr 28, 2013, 08:36 UTC · lore

When --stdlayout and --preserve-empty-dirs flags are used and a directory becomes empty, sometimes no empty dir placeholder file created. Then on fetch next commit git-svn dies with "Failed to strip path" error.

Test script:
    rm -rf testrepo.svn testrepo.gitsvn
    svnadmin create testrepo.svn
    url=file://`pwd`/testrepo.svn
    svn mkdir -m "" "$url/trunk" "$url/branches" "$url/tags"
    rm -rf testrepo
    svn co "$url" testrepo
    cd testrepo/trunk
    mkdir -p foo/bar/
    svn add foo/
    svn commit -mx
    svn rm foo/bar/
    svn commit -mx
    svn up
    mkdir -p baz/
    svn add baz/
    svn commit -mx
    echo x > fil.txt
    svn add fil.txt
    svn commit -mx
    cd ../..
    git svn clone --stdlayout --preserve-empty-dirs "$url" testrepo.gitsvn
---
 perl/Git/SVN/Fetcher.pm | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Show changes to perl/Git/SVN/Fetcher.pm +8 −4
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 046a7a2..4f96076 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -129,6 +129,7 @@ sub is_path_ignored {
 
 sub set_path_strip {
 	my ($self, $path) = @_;
+	$self->{pathprefix_strip} = length $path ? ($path . "/") : "";
 	$self->{path_strip} = qr/^\Q$path\E(\/|$)/ if length $path;
 }
 
@@ -458,9 +459,12 @@ sub find_empty_directories {
 		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;
+				if (length $self->git_path($path)) {
+					$path = dirname($path);
+					if ($dir eq $self->git_path($path) && exists $self->{$t}->{$path}) {
+						$skip_added = 1;
+						last;
+					}
 				}
 			}
 			last if $skip_added;
@@ -477,7 +481,7 @@ sub find_empty_directories {
 		delete $files{$_} foreach (@deleted_gpath);
 
 		# Report the directory if there are no filenames left.
-		push @empty_dirs, $dir unless (scalar %files);
+		push @empty_dirs, ($self->{pathprefix_strip} . $dir) unless (scalar %files);
 	}
 	@empty_dirs;
 }
-- 
1.8.1.5
Thomas Rast· Apr 28, 2013, 08:58 UTC · re: Ilya Basin · lore

Re: [PATCH 1/2] git-svn: fix occasional "Failed to strip path" error on fetch next commit

Ilya Basin <basinilya@gmail.com> writes:
>
You should Cc Eric on git-svn related patches.
Show 30 quoted lines
> Test script:
>
>     rm -rf testrepo.svn testrepo.gitsvn
>     svnadmin create testrepo.svn
>     url=file://`pwd`/testrepo.svn
>
>     svn mkdir -m "" "$url/trunk" "$url/branches" "$url/tags"
>     rm -rf testrepo
>     svn co "$url" testrepo
>     cd testrepo/trunk
>
>     mkdir -p foo/bar/
>     svn add foo/
>     svn commit -mx
>
>     svn rm foo/bar/
>     svn commit -mx
>
>     svn up
>     mkdir -p baz/
>     svn add baz/
>     svn commit -mx
>
>     echo x > fil.txt
>     svn add fil.txt
>     svn commit -mx
>
>     cd ../..
>
>     git svn clone --stdlayout --preserve-empty-dirs "$url" testrepo.gitsvn
Please add an actual regression test, probably to t9160.
-- 
Thomas Rast
trast@{inf,student}.ethz.ch

← back to recent threads