@matheusbsbs / matheus-bagliano / commits / 8841b37f2f
Fork 0

git-svn: fix broken symlink workaround when switching branches

Thanks to Anton Gyllenberg <anton@iki.fi> for the bug report (and testcase in the following commit): > Commit dbc6c74d0858d77e61e092a48d467e725211f8e9 "git-svn: > handle empty files marked as symlinks in SVN" caused a > regression in an unusual case where a branch has been created > in SVN, later deleted and then created again from another > branch point and the original branch point had empty files not > in the new branch. In some cases git svn fetch will then fail > while trying to fetch the empty file from the wrong SVN > revision. Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Feb 11, 2009 at 01:56 UTC 8841b37f2f5ce74359e150254dd138602eb418a7
1 file changed +6 -5
git-svn.perl
+6 -5
@@ -2417,7 +2417,7 @@ sub find_parent_branch {
2417 # is not included with SVN 1.4.3 (the latest version
2418 # at the moment), so we can't rely on it
2419 $self->{last_commit} = $parent;
2420 - $ed = SVN::Git::Fetcher->new($self);
2420 + $ed = SVN::Git::Fetcher->new($self, $gs->{path});
2421 $gs->ra->gs_do_switch($r0, $rev, $gs,
2422 $self->full_url, $ed)
2423 or die "SVN connection failed somewhere...\n";
@@ -3258,12 +3258,13 @@ use vars qw/$_ignore_regex/;
3258
3259 # file baton members: path, mode_a, mode_b, pool, fh, blob, base
3260 sub new {
3261 - my ($class, $git_svn) = @_;
3261 + my ($class, $git_svn, $switch_path) = @_;
3262 my $self = SVN::Delta::Editor->new;
3263 bless $self, $class;
3264 if (exists $git_svn->{last_commit}) {
3265 $self->{c} = $git_svn->{last_commit};
3266 - $self->{empty_symlinks} = _mark_empty_symlinks($git_svn);
3266 + $self->{empty_symlinks} =
3267 + _mark_empty_symlinks($git_svn, $switch_path);
3268 }
3269 $self->{empty} = {};
3270 $self->{dir_prop} = {};
@@ -3278,7 +3279,7 @@ sub new {
3279 # not inside them (when the Git::SVN::Fetcher object is passed) to
3280 # do_{switch,update}
3281 sub _mark_empty_symlinks {
3281 - my ($git_svn) = @_;
3282 + my ($git_svn, $switch_path) = @_;
3283 my $bool = Git::config_bool('svn.brokenSymlinkWorkaround');
3284 return {} if (defined($bool) && ! $bool);
3285
@@ -3294,7 +3295,7 @@ sub _mark_empty_symlinks {
3295 chomp(my $empty_blob = `git hash-object -t blob --stdin < /dev/null`);
3296 my ($ls, $ctx) = command_output_pipe(qw/ls-tree -r -z/, $cmt);
3297 local $/ = "\0";
3297 - my $pfx = $git_svn->{path};
3298 + my $pfx = defined($switch_path) ? $switch_path : $git_svn->{path};
3299 $pfx .= '/' if length($pfx);
3300 while (<$ls>) {
3301 chomp;