Skip to content

Commit 4c58a71

Browse files
author
Eric Wong
committed
git-svn: allow disabling expensive broken symlink checks
Since dbc6c74, git-svn has had an expensive check for broken symlinks that exist in some repositories. This leads to a heavy performance hit on repositories with many empty blobs that are not supposed to be symlinks. The workaround is enabled by default; and may be disabled via: git config svn.brokenSymlinkWorkaround false Reported by Markus Heidelberg. Signed-off-by: Eric Wong <[email protected]>
1 parent 1b53a07 commit 4c58a71

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Documentation/git-svn.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,14 @@ svn-remote.<name>.rewriteRoot::
499499
the repository with a public http:// or svn:// URL in the
500500
metadata so users of it will see the public URL.
501501

502+
svn.brokenSymlinkWorkaround::
503+
This disables potentially expensive checks to workaround broken symlinks
504+
checked into SVN by broken clients. Set this option to "false" if you
505+
track a SVN repository with many empty blobs that are not symlinks.
506+
This option may be changed while "git-svn" is running and take effect on
507+
the next revision fetched. If unset, git-svn assumes this option to be
508+
"true".
509+
502510
--
503511

504512
Since the noMetadata, rewriteRoot, useSvnsyncProps and useSvmProps

git-svn.perl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,10 +3271,18 @@ sub new {
32713271
# do_{switch,update}
32723272
sub _mark_empty_symlinks {
32733273
my ($git_svn) = @_;
3274+
my $bool = Git::config_bool('svn.brokenSymlinkWorkaround');
3275+
return {} if (defined($bool) && ! $bool);
3276+
32743277
my %ret;
32753278
my ($rev, $cmt) = $git_svn->last_rev_commit;
32763279
return {} unless ($rev && $cmt);
32773280

3281+
# allow the warning to be printed for each revision we fetch to
3282+
# ensure the user sees it. The user can also disable the workaround
3283+
# on the repository even while git svn is running and the next
3284+
# revision fetched will skip this expensive function.
3285+
my $printed_warning;
32783286
chomp(my $empty_blob = `git hash-object -t blob --stdin < /dev/null`);
32793287
my ($ls, $ctx) = command_output_pipe(qw/ls-tree -r -z/, $cmt);
32803288
local $/ = "\0";
@@ -3283,6 +3291,18 @@ sub _mark_empty_symlinks {
32833291
while (<$ls>) {
32843292
chomp;
32853293
s/\A100644 blob $empty_blob\t//o or next;
3294+
unless ($printed_warning) {
3295+
print STDERR "Scanning for empty symlinks, ",
3296+
"this may take a while if you have ",
3297+
"many empty files\n",
3298+
"You may disable this with `",
3299+
"git config svn.brokenSymlinkWorkaround ",
3300+
"false'.\n",
3301+
"This may be done in a different ",
3302+
"terminal without restarting ",
3303+
"git svn\n";
3304+
$printed_warning = 1;
3305+
}
32863306
my $path = $_;
32873307
my (undef, $props) =
32883308
$git_svn->ra->get_file($pfx.$path, $rev, undef);

t/t9131-git-svn-empty-symlink.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,14 @@ test_expect_success '"bar" is an empty file' 'test -f x/bar && ! test -s x/bar'
8787
test_expect_success 'get "bar" => symlink fix from svn' \
8888
'(cd x && git svn rebase)'
8989
test_expect_success '"bar" becomes a symlink' 'test -L x/bar'
90+
91+
92+
test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" y'
93+
test_expect_success 'disable broken symlink workaround' \
94+
'(cd y && git config svn.brokenSymlinkWorkaround false)'
95+
test_expect_success '"bar" is an empty file' 'test -f y/bar && ! test -s y/bar'
96+
test_expect_success 'get "bar" => symlink fix from svn' \
97+
'(cd y && git svn rebase)'
98+
test_expect_success '"bar" does not become a symlink' '! test -L y/bar'
99+
90100
test_done

0 commit comments

Comments
 (0)