Re: "git svn mkdirs" is very slow
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:55
Michael Haggerty [off-list ref] writes:
So I wanted to implement the following feature: 1. An svn.autoMkdirs / svn-remote.<name>.autoMkdirs configuration variable. The value should default to true for backwards compatibility. 2. Only call mkemptydirs() if this variable is set to true. 3. Make an exception for "git svn mkdirs", which should do its thing regardless of how this configuration option is set. I think it should only be about a 10-line change, plus documentation and tests. Unfortunately, my perl-foo is very limited, and it will take me a while to figure out how option parsing and handling works in git-svn. Would this feature be welcome? Is there anybody willing to make the Perl changes? I would be willing to work on the documentation and test suite changes.
Sounds like a sensible thing to do, but I wonder if we also want a command line option --automkdirs (or --auto-create-empty-directories) in %fc_opts to make it overridable from the command line. Perhaps it is not worth it. A completely untested patch is here. git-svn.perl | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index a5857c1..fe4c716 100755
--- a/git-svn.perl
+++ b/git-svn.perl@@ -781,6 +781,16 @@ sub cmd_find_rev { print "$result\n" if $result; } +sub auto_create_empty_directories { + my ($gs) = @_; + my $var = eval { command_oneline('config', '--get', '--bool', + "svn-remote.$gs->{repo_id}.automkdirs") }; + # By default, create empty directories by consulting the unhandled log, + # but allow setting it to 'false' to skip it. I wonder if the variable + # should be "skip create empty directories", though... + return !($var && $var eq 'false'); +} + sub cmd_rebase { command_noisy(qw/update-index --refresh/); my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
@@ -804,7 +814,9 @@ sub cmd_rebase { $_fetch_all ? $gs->fetch_all : $gs->fetch; } command_noisy(rebase_cmd(), $gs->refname); - $gs->mkemptydirs; + if (auto_create_empty_directories($gs)) { + $gs->mkemptydirs; + } } sub cmd_show_ignore {
@@ -1242,7 +1254,9 @@ sub post_fetch_checkout { command_noisy(qw/read-tree -m -u -v HEAD HEAD/); print STDERR "Checked out HEAD:\n ", $gs->full_url, " r", $gs->last_rev, "\n"; - $gs->mkemptydirs($gs->last_rev); + if (auto_create_empty_directories($gs)) { + $gs->mkemptydirs($gs->last_rev); + } } sub complete_svn_url {