{"thread":{"id":"33661","subject":"[PATCH 1/2] git-svn: fix occasional \"Failed to strip path\" error on fetch next commit","startedAt":"2013-04-28T08:36:27Z","lastAt":"2013-04-28T08:58:36Z","messageCount":2,"participants":["Ilya Basin","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"215788","messageId":"1107347907.20130428123527@gmail.com","threadId":"33661","inReplyTo":null,"subject":"[PATCH 1/2] git-svn: fix occasional \"Failed to strip path\" error on fetch next commit","fromName":"Ilya Basin","fromEmail":"basinilya@gmail.com","sentAt":"2013-04-28T08:36:27Z","receivedAt":"2013-04-28T08:36:27Z","isPatch":true,"sender":{"key":"basinilya@gmail.com","avatar":null},"body":"When --stdlayout and --preserve-empty-dirs flags are used and a\ndirectory becomes empty, sometimes no empty dir placeholder file\ncreated. Then on fetch next commit git-svn dies with \"Failed to strip\npath\" error.\n\nTest script:\n\n    rm -rf testrepo.svn testrepo.gitsvn\n    svnadmin create testrepo.svn\n    url=file://`pwd`/testrepo.svn\n\n    svn mkdir -m \"\" \"$url/trunk\" \"$url/branches\" \"$url/tags\"\n    rm -rf testrepo\n    svn co \"$url\" testrepo\n    cd testrepo/trunk\n\n    mkdir -p foo/bar/\n    svn add foo/\n    svn commit -mx\n\n    svn rm foo/bar/\n    svn commit -mx\n\n    svn up\n    mkdir -p baz/\n    svn add baz/\n    svn commit -mx\n\n    echo x > fil.txt\n    svn add fil.txt\n    svn commit -mx\n\n    cd ../..\n\n    git svn clone --stdlayout --preserve-empty-dirs \"$url\" testrepo.gitsvn\n---\n perl/Git/SVN/Fetcher.pm | 12 ++++++++----\n 1 file changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 046a7a2..4f96076 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -129,6 +129,7 @@ sub is_path_ignored {\n \n sub set_path_strip {\n \tmy ($self, $path) = @_;\n+\t$self->{pathprefix_strip} = length $path ? ($path . \"/\") : \"\";\n \t$self->{path_strip} = qr/^\\Q$path\\E(\\/|$)/ if length $path;\n }\n \n@@ -458,9 +459,12 @@ sub find_empty_directories {\n \t\tmy $skip_added = 0;\n \t\tforeach my $t (qw/dir_prop file_prop/) {\n \t\t\tforeach my $path (keys %{ $self->{$t} }) {\n-\t\t\t\tif (exists $self->{$t}->{dirname($path)}) {\n-\t\t\t\t\t$skip_added = 1;\n-\t\t\t\t\tlast;\n+\t\t\t\tif (length $self->git_path($path)) {\n+\t\t\t\t\t$path = dirname($path);\n+\t\t\t\t\tif ($dir eq $self->git_path($path) && exists $self->{$t}->{$path}) {\n+\t\t\t\t\t\t$skip_added = 1;\n+\t\t\t\t\t\tlast;\n+\t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t\tlast if $skip_added;\n@@ -477,7 +481,7 @@ sub find_empty_directories {\n \t\tdelete $files{$_} foreach (@deleted_gpath);\n \n \t\t# Report the directory if there are no filenames left.\n-\t\tpush @empty_dirs, $dir unless (scalar %files);\n+\t\tpush @empty_dirs, ($self->{pathprefix_strip} . $dir) unless (scalar %files);\n \t}\n \t@empty_dirs;\n }\n-- \n1.8.1.5\n"},{"id":"215789","messageId":"87obcz3ubn.fsf@linux-k42r.v.cablecom.net","threadId":"33661","inReplyTo":"1107347907.20130428123527@gmail.com","subject":"Re: [PATCH 1/2] git-svn: fix occasional \"Failed to strip path\" error on fetch next commit","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2013-04-28T08:58:36Z","receivedAt":"2013-04-28T08:58:36Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Ilya Basin <basinilya@gmail.com> writes:\n>\n\nYou should Cc Eric on git-svn related patches.\n\n> Test script:\n>\n>     rm -rf testrepo.svn testrepo.gitsvn\n>     svnadmin create testrepo.svn\n>     url=file://`pwd`/testrepo.svn\n>\n>     svn mkdir -m \"\" \"$url/trunk\" \"$url/branches\" \"$url/tags\"\n>     rm -rf testrepo\n>     svn co \"$url\" testrepo\n>     cd testrepo/trunk\n>\n>     mkdir -p foo/bar/\n>     svn add foo/\n>     svn commit -mx\n>\n>     svn rm foo/bar/\n>     svn commit -mx\n>\n>     svn up\n>     mkdir -p baz/\n>     svn add baz/\n>     svn commit -mx\n>\n>     echo x > fil.txt\n>     svn add fil.txt\n>     svn commit -mx\n>\n>     cd ../..\n>\n>     git svn clone --stdlayout --preserve-empty-dirs \"$url\" testrepo.gitsvn\n\nPlease add an actual regression test, probably to t9160.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}