Skip to content

Commit 8841b37

Browse files
author
Eric Wong
committed
git-svn: fix broken symlink workaround when switching branches
Thanks to Anton Gyllenberg <[email protected]> for the bug report (and testcase in the following commit): > Commit dbc6c74 "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 <[email protected]>
1 parent 9936656 commit 8841b37

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

git-svn.perl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,7 +2417,7 @@ sub find_parent_branch {
24172417
# is not included with SVN 1.4.3 (the latest version
24182418
# at the moment), so we can't rely on it
24192419
$self->{last_commit} = $parent;
2420-
$ed = SVN::Git::Fetcher->new($self);
2420+
$ed = SVN::Git::Fetcher->new($self, $gs->{path});
24212421
$gs->ra->gs_do_switch($r0, $rev, $gs,
24222422
$self->full_url, $ed)
24232423
or die "SVN connection failed somewhere...\n";
@@ -3258,12 +3258,13 @@ package SVN::Git::Fetcher;
32583258

32593259
# file baton members: path, mode_a, mode_b, pool, fh, blob, base
32603260
sub new {
3261-
my ($class, $git_svn) = @_;
3261+
my ($class, $git_svn, $switch_path) = @_;
32623262
my $self = SVN::Delta::Editor->new;
32633263
bless $self, $class;
32643264
if (exists $git_svn->{last_commit}) {
32653265
$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);
32673268
}
32683269
$self->{empty} = {};
32693270
$self->{dir_prop} = {};
@@ -3278,7 +3279,7 @@ sub new {
32783279
# not inside them (when the Git::SVN::Fetcher object is passed) to
32793280
# do_{switch,update}
32803281
sub _mark_empty_symlinks {
3281-
my ($git_svn) = @_;
3282+
my ($git_svn, $switch_path) = @_;
32823283
my $bool = Git::config_bool('svn.brokenSymlinkWorkaround');
32833284
return {} if (defined($bool) && ! $bool);
32843285

@@ -3294,7 +3295,7 @@ sub _mark_empty_symlinks {
32943295
chomp(my $empty_blob = `git hash-object -t blob --stdin < /dev/null`);
32953296
my ($ls, $ctx) = command_output_pipe(qw/ls-tree -r -z/, $cmt);
32963297
local $/ = "\0";
3297-
my $pfx = $git_svn->{path};
3298+
my $pfx = defined($switch_path) ? $switch_path : $git_svn->{path};
32983299
$pfx .= '/' if length($pfx);
32993300
while (<$ls>) {
33003301
chomp;

0 commit comments

Comments
 (0)