@matheusbsbs / matheus-bagliano / commits / 55f9d7a75c
Fork 0

git-svn: add an option to skip the creation of empty directories

"git svn mkdirs" (which creates empty directories in the current working copy) can be very slow and is often unnecessary. Provide a config file option "svn-remote.<name>.automkdirs" that prevents empty directories from being created automatically. (They are still created if "git svn mkdirs" is invoked explicitly.) Based-on-patch-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Apr 1, 2011 at 12:26 UTC 55f9d7a75c90ca98f7d7be32e9bdca5a789d1257
3 files changed +42 -2
Documentation/git-svn.txt
+10
@@ -343,6 +343,8 @@ Any other arguments are passed directly to 'git log'
343 Empty directories are automatically recreated when using
344 "git svn clone" and "git svn rebase", so "mkdirs" is intended
345 for use after commands like "git checkout" or "git reset".
346 + (See the svn-remote.<name>.automkdirs config file option for
347 + more information.)
348
349 'commit-diff'::
350 Commits the diff of two tree-ish arguments from the
@@ -663,6 +665,14 @@ svn.pathnameencoding::
665 locales to avoid corrupted file names with non-ASCII characters.
666 Valid encodings are the ones supported by Perl's Encode module.
667
668 +svn-remote.<name>.automkdirs::
669 + Normally, the "git svn clone" and "git svn rebase" commands
670 + attempt to recreate empty directories that are in the
671 + Subversion repository. If this option is set to "false", then
672 + empty directories will only be created if the "git svn mkdirs"
673 + command is run explicitly. If unset, 'git svn' assumes this
674 + option to be "true".
675 +
676 Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and useSvmProps
677 options all affect the metadata generated and used by 'git svn'; they
678 *must* be set in the configuration file before any history is imported
git-svn.perl
+15 -2
@@ -781,6 +781,15 @@ sub cmd_find_rev {
781 print "$result\n" if $result;
782 }
783
784 +sub auto_create_empty_directories {
785 + my ($gs) = @_;
786 + my $var = eval { command_oneline('config', '--get', '--bool',
787 + "svn-remote.$gs->{repo_id}.automkdirs") };
788 + # By default, create empty directories by consulting the unhandled log,
789 + # but allow setting it to 'false' to skip it.
790 + return !($var && $var eq 'false');
791 +}
792 +
793 sub cmd_rebase {
794 command_noisy(qw/update-index --refresh/);
795 my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
@@ -804,7 +813,9 @@ sub cmd_rebase {
813 $_fetch_all ? $gs->fetch_all : $gs->fetch;
814 }
815 command_noisy(rebase_cmd(), $gs->refname);
807 - $gs->mkemptydirs;
816 + if (auto_create_empty_directories($gs)) {
817 + $gs->mkemptydirs;
818 + }
819 }
820
821 sub cmd_show_ignore {
@@ -1242,7 +1253,9 @@ sub post_fetch_checkout {
1253 command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
1254 print STDERR "Checked out HEAD:\n ",
1255 $gs->full_url, " r", $gs->last_rev, "\n";
1245 - $gs->mkemptydirs($gs->last_rev);
1256 + if (auto_create_empty_directories($gs)) {
1257 + $gs->mkemptydirs($gs->last_rev);
1258 + }
1259 }
1260
1261 sub complete_svn_url {
t/t9146-git-svn-empty-dirs.sh
+17
@@ -28,6 +28,23 @@ test_expect_success 'empty directories exist' '
28 )
29 '
30
31 +test_expect_success 'option automkdirs set to false' '
32 + (
33 + git svn init "$svnrepo" cloned-no-mkdirs &&
34 + cd cloned-no-mkdirs &&
35 + git config svn-remote.svn.automkdirs false &&
36 + git svn fetch &&
37 + for i in a b c d d/e d/e/f "weird file name"
38 + do
39 + if test -d "$i"
40 + then
41 + echo >&2 "$i exists"
42 + exit 1
43 + fi
44 + done
45 + )
46 +'
47 +
48 test_expect_success 'more emptiness' '
49 svn_cmd mkdir -m "bang bang" "$svnrepo"/"! !"
50 '