git-svn: silence bogus v1-layout migration message
cover git-svn: silence bogus v1-layout migration message
While running dzil build' (a Perl tool for minting and shipping modules) without a git remote configured, git started printing "Migrating from a git-svn v1 layout..." messages. In addition it also created an empty .git/svn' directory. After removing that directory, it again repeated the behaviour on every `dzil build' invocation.
One of the plugins runs git svn info' to probe whether the repo is an SVN checkout. On a plain git-only repository this produced a wall of migration text on the terminal and left behind an empty .git/svn' directory. I initially thought it was just a plugin being weird, but running `git svn info' myself turned out to be the real "troublemaker".
You can do reproduce the behaviour by doing:
git init .
git svn info
This patch addresses that and uses the same pattern as `migrate_from_v0'. I've included tests to t9107.
In addition, which was my intitial reaction: I've added a knob to exclude git svn from being installed. When you add `NO_GIT_SVN=YesPlease' to your make invocation, git is installed without git-svn and no SVN tests run.
Wesley Schwengle (2):
git-svn: don't print v1-layout migration noise when there's nothing to
migrate
Makefile: add NO_GIT_SVN knob to skip building/installing git-svn
Makefile | 8 ++++++++ perl/Git/SVN/Migration.pm | 16 ++++++++++------ t/t9107-git-svn-migrate.sh | 7 +++++++ 3 files changed, 25 insertions(+), 6 deletions(-)
Signature · 1 line
2.55.0.827.g48ce2c92dc
PATCH 1/2 git-svn: don't print v1-layout migration noise when there's nothing to migrate
migrate_from_v1()' unconditionally announced and created .git/svn' when no legacy refs/remotes/*' metadata existed to migrate. This happens for example right after a git init'.
Defer the logic until an actual candidate is found, matching the existing pattern of `migrate_from_v0'
--- perl/Git/SVN/Migration.pm | 16 ++++++++++------ t/t9107-git-svn-migrate.sh | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-)
perl/Git/SVN/Migration.pm +10 -6
@@ -84,35 +84,39 @@ sub migrate_from_v0 { sub migrate_from_v1 { my $git_dir = $ENV{GIT_DIR}; my $migrated = 0; return $migrated unless -d $git_dir; my $svn_dir = Git::SVN::svn_dir(); # just in case somebody used 'svn' as their $id at some point... return $migrated if -d $svn_dir && ! -f "$svn_dir/info/url"; - print STDERR "Migrating from a git-svn v1 layout...\n"; - mkpath([$svn_dir]); - print STDERR "Data from a previous version of git-svn exists, but\n\t", - "$svn_dir\n\t(required for this version ", - "($::VERSION) of git-svn) does not exist.\n"; my ($fh, $ctx) = command_output_pipe(qw/rev-parse --symbolic --all/); while (<$fh>) { my $x = $_; next unless $x =~ s#^refs/remotes/##; chomp $x; my $info_url = command_oneline(qw(rev-parse --git-path), "$x/info/url"); next unless -f $info_url; my $u = eval { ::file_to_s($info_url) }; next unless $u; + unless ($migrated) { + print STDERR "Migrating from a git-svn v1 layout...\n"; + mkpath([$svn_dir]); + print STDERR "Data from a previous version of ", + "git-svnexists, but\n\t", + "$svn_dir\n\t(required for this version ", + "($::VERSION) of git-svn) does not ", + "exist.\n"; + } my $dn = dirname("$svn_dir/$x"); mkpath([$dn]) unless -d $dn; if ($x eq 'svn') { # they used 'svn' as GIT_SVN_ID: mkpath(["$svn_dir/svn"]); print STDERR " - $git_dir/$x/info => ", "$svn_dir/$x/info\n"; rename "$git_dir/$x/info", "$svn_dir/$x/info" or croak "$!: $x"; # don't worry too much about these, they probably # don't exist with repos this old (save for index,
@@ -120,21 +124,21 @@ sub migrate_from_v1 { foreach my $f (qw/unhandled.log index .rev_db/) { rename "$git_dir/$x/$f", "$svn_dir/$x/$f"; } } else { print STDERR " - $git_dir/$x => $svn_dir/$x\n"; rename "$git_dir/$x", "$svn_dir/$x" or croak "$!: $x"; } $migrated++; } command_close_pipe($fh, $ctx); - print STDERR "Done migrating from a git-svn v1 layout\n"; + print STDERR "Done migrating from a git-svn v1 layout\n" if $migrated; $migrated; } sub read_old_urls { my ($l_map, $pfx, $path) = @_; my @dir; foreach (<$path/*>) { if (-r "$_/info/url") { $pfx .= '/' if $pfx && $pfx !~ m!/$!; my $ref_id = $pfx . basename $_;
t/t9107-git-svn-migrate.sh +7 -0
@@ -1,15 +1,22 @@ #!/bin/sh # Copyright (c) 2006 Eric Wong test_description='git svn metadata migrations from previous versions' . ./lib-git-svn.sh +test_expect_success 'migrate is silent when there is nothing to migrate' ' + git svn migrate 2>err.log && + test_grep ! "Migrating from a git-svn v1 layout" err.log && + test_grep ! "Data from a previous version of git-svn exists" err.log && + ! test -d "$GIT_DIR"/svn + ' + test_expect_success 'setup old-looking metadata' ' cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && mkdir import && ( cd import && for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3 do mkdir -p $i && echo hello >>$i/README || exit 1
Signature · 1 line
2.55.0.827.g48ce2c92dc
Re: [PATCH 1/2] git-svn: don't print v1-layout migration noise when there's nothing to migrate
Quoted 14 lines · Wesley Schwengle
perl/Git/SVN/Migration.pm +0
-5- print STDERR "Migrating from a git-svn v1 layout...\n"; - mkpath([$svn_dir]); - print STDERR "Data from a previous version of git-svn exists, but\n\t", - "$svn_dir\n\t(required for this version ", - "($::VERSION) of git-svn) does not exist.\n"; my ($fh, $ctx) = command_output_pipe(qw/rev-parse --symbolic --all/); while (<$fh>) { my $x = $_; next unless $x =~ s#^refs/remotes/##; chomp $x; my $info_url = command_oneline(qw(rev-parse --git-path), "$x/info/url"); next unless -f $info_url; my $u = eval { ::file_to_s($info_url) };
perl/Git/SVN/Migration.pm sub migrate_from_v0 { · line 112
Quoted 10 lines
perl/Git/SVN/Migration.pm +9
-0next unless $u; + unless ($migrated) { + print STDERR "Migrating from a git-svn v1 layout...\n"; + mkpath([$svn_dir]); + print STDERR "Data from a previous version of ", + "git-svnexists, but\n\t", + "$svn_dir\n\t(required for this version ", + "($::VERSION) of git-svn) does not ", + "exist.\n"; + }
Delaying the initialization and messaging is a reasonable idea, but you lost a SP in the message (there might be other changes I failed to spot---I wasn't especially being careful).
Quoted 60 lines
perl/Git/SVN/Migration.pm +1
-1my $dn = dirname("$svn_dir/$x"); mkpath([$dn]) unless -d $dn; if ($x eq 'svn') { # they used 'svn' as GIT_SVN_ID: mkpath(["$svn_dir/svn"]); print STDERR " - $git_dir/$x/info => ", "$svn_dir/$x/info\n"; rename "$git_dir/$x/info", "$svn_dir/$x/info" or croak "$!: $x"; # don't worry too much about these, they probably # don't exist with repos this old (save for index,@@ -120,21 +124,21 @@ sub migrate_from_v1 { foreach my $f (qw/unhandled.log index .rev_db/) { rename "$git_dir/$x/$f", "$svn_dir/$x/$f"; } } else { print STDERR " - $git_dir/$x => $svn_dir/$x\n"; rename "$git_dir/$x", "$svn_dir/$x" or croak "$!: $x"; } $migrated++; } command_close_pipe($fh, $ctx); - print STDERR "Done migrating from a git-svn v1 layout\n"; + print STDERR "Done migrating from a git-svn v1 layout\n" if $migrated; $migrated; } sub read_old_urls { my ($l_map, $pfx, $path) = @_; my @dir; foreach (<$path/*>) { if (-r "$_/info/url") { $pfx .= '/' if $pfx && $pfx !~ m!/$!; my $ref_id = $pfx . basename $_;t/t9107-git-svn-migrate.sh +7
-0@@ -1,15 +1,22 @@ #!/bin/sh # Copyright (c) 2006 Eric Wong test_description='git svn metadata migrations from previous versions' . ./lib-git-svn.sh +test_expect_success 'migrate is silent when there is nothing to migrate' ' + git svn migrate 2>err.log && + test_grep ! "Migrating from a git-svn v1 layout" err.log && + test_grep ! "Data from a previous version of git-svn exists" err.log && + ! test -d "$GIT_DIR"/svn + ' + test_expect_success 'setup old-looking metadata' ' cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && mkdir import && ( cd import && for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3 do mkdir -p $i && echo hello >>$i/README || exit 1
v2 cover git-svn: don't print v1-layout migration noise when there's nothing to migrate
Sorry, I missed the space when I reworked the patch a bit before sending it. Here is the new patch set for the change.
Wesley Schwengle (2):
git-svn: don't print v1-layout migration noise when there's nothing to
migrate
Makefile: add NO_GIT_SVN knob to skip building/installing git-svn
Makefile | 8 ++++++++ perl/Git/SVN/Migration.pm | 16 ++++++++++------ t/t9107-git-svn-migrate.sh | 7 +++++++ 3 files changed, 25 insertions(+), 6 deletions(-)
Signature · 1 line
2.55.0.975.g5fa7c85aff
PATCH v2 1/2 git-svn: don't print v1-layout migration noise when there's nothing to migrate
migrate_from_v1()' unconditionally announced and created .git/svn' when no legacy refs/remotes/*' metadata existed to migrate. This happens for example right after a git init'.
Defer the logic until an actual candidate is found, matching the existing pattern of `migrate_from_v0'
--- perl/Git/SVN/Migration.pm | 16 ++++++++++------ t/t9107-git-svn-migrate.sh | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-)
perl/Git/SVN/Migration.pm +10 -6
@@ -84,35 +84,39 @@ sub migrate_from_v0 { sub migrate_from_v1 { my $git_dir = $ENV{GIT_DIR}; my $migrated = 0; return $migrated unless -d $git_dir; my $svn_dir = Git::SVN::svn_dir(); # just in case somebody used 'svn' as their $id at some point... return $migrated if -d $svn_dir && ! -f "$svn_dir/info/url"; - print STDERR "Migrating from a git-svn v1 layout...\n"; - mkpath([$svn_dir]); - print STDERR "Data from a previous version of git-svn exists, but\n\t", - "$svn_dir\n\t(required for this version ", - "($::VERSION) of git-svn) does not exist.\n"; my ($fh, $ctx) = command_output_pipe(qw/rev-parse --symbolic --all/); while (<$fh>) { my $x = $_; next unless $x =~ s#^refs/remotes/##; chomp $x; my $info_url = command_oneline(qw(rev-parse --git-path), "$x/info/url"); next unless -f $info_url; my $u = eval { ::file_to_s($info_url) }; next unless $u; + unless ($migrated) { + print STDERR "Migrating from a git-svn v1 layout...\n"; + mkpath([$svn_dir]); + print STDERR "Data from a previous version of ", + "git-svn exists, but\n\t", + "$svn_dir\n\t(required for this version ", + "($::VERSION) of git-svn) does not ", + "exist.\n"; + } my $dn = dirname("$svn_dir/$x"); mkpath([$dn]) unless -d $dn; if ($x eq 'svn') { # they used 'svn' as GIT_SVN_ID: mkpath(["$svn_dir/svn"]); print STDERR " - $git_dir/$x/info => ", "$svn_dir/$x/info\n"; rename "$git_dir/$x/info", "$svn_dir/$x/info" or croak "$!: $x"; # don't worry too much about these, they probably # don't exist with repos this old (save for index,
@@ -120,21 +124,21 @@ sub migrate_from_v1 { foreach my $f (qw/unhandled.log index .rev_db/) { rename "$git_dir/$x/$f", "$svn_dir/$x/$f"; } } else { print STDERR " - $git_dir/$x => $svn_dir/$x\n"; rename "$git_dir/$x", "$svn_dir/$x" or croak "$!: $x"; } $migrated++; } command_close_pipe($fh, $ctx); - print STDERR "Done migrating from a git-svn v1 layout\n"; + print STDERR "Done migrating from a git-svn v1 layout\n" if $migrated; $migrated; } sub read_old_urls { my ($l_map, $pfx, $path) = @_; my @dir; foreach (<$path/*>) { if (-r "$_/info/url") { $pfx .= '/' if $pfx && $pfx !~ m!/$!; my $ref_id = $pfx . basename $_;
t/t9107-git-svn-migrate.sh +7 -0
@@ -1,15 +1,22 @@ #!/bin/sh # Copyright (c) 2006 Eric Wong test_description='git svn metadata migrations from previous versions' . ./lib-git-svn.sh +test_expect_success 'migrate is silent when there is nothing to migrate' ' + git svn migrate 2>err.log && + test_grep ! "Migrating from a git-svn v1 layout" err.log && + test_grep ! "Data from a previous version of git-svn exists" err.log && + ! test -d "$GIT_DIR"/svn + ' + test_expect_success 'setup old-looking metadata' ' cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && mkdir import && ( cd import && for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3 do mkdir -p $i && echo hello >>$i/README || exit 1
Signature · 1 line
2.55.0.975.g5fa7c85aff
PATCH v2 2/2 Makefile: add NO_GIT_SVN knob to skip building/installing git-svn
In reply to Wesley SchwengleThis option also implies that NO_SVN_TESTS is enabled.
--- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
Makefile +8 -0
@@ -81,20 +81,23 @@ include shared.mak # # Define NO_SYS_SELECT_H if you don't have sys/select.h. # # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # Enable it on Windows. By default, symrefs are still used. # # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability # tests. These tests take up a significant amount of the total test time # but are not needed unless you plan to talk to SVN repos. # +# Define NO_GIT_SVN if you don't want git-svn built or installed at all. +# Implies NO_SVN_TESTS. +# # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink # installed in /sw, but don't want GIT to link against any libraries # installed there. If defined you may specify your own (or Fink's) # include directories and library directories by defining CFLAGS # and LDFLAGS appropriately. # # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X, # have DarwinPorts (which is an old name for MacPorts) installed # in /opt/local, but don't want GIT to # link against any libraries installed there. If defined you may
@@ -741,21 +744,23 @@ SCRIPT_SH += git-web--browse.sh SCRIPT_LIB += git-mergetool--lib SCRIPT_LIB += git-sh-i18n SCRIPT_LIB += git-sh-setup SCRIPT_PERL += git-archimport.perl SCRIPT_PERL += git-cvsexportcommit.perl SCRIPT_PERL += git-cvsimport.perl SCRIPT_PERL += git-cvsserver.perl SCRIPT_PERL += git-send-email.perl +ifndef NO_GIT_SVN SCRIPT_PERL += git-svn.perl +endif SCRIPT_PYTHON += git-p4.py # Generated files for scripts SCRIPT_SH_GEN = $(patsubst %.sh,%,$(SCRIPT_SH)) SCRIPT_PERL_GEN = $(patsubst %.perl,%,$(SCRIPT_PERL)) SCRIPT_PYTHON_GEN = $(patsubst %.py,%,$(SCRIPT_PYTHON)) # Individual rules to allow e.g. # "make -C ../.. SCRIPT_PERL=contrib/foo/bar.perl build-perl-script"
@@ -3408,20 +3413,23 @@ $(test_bindir_programs): bin-wrappers/%: bin-wrappers/wrap-for-bin.sh -e 's|@GITPERLLIB@|$(shell pwd)/perl/build/lib|' \ -e 's|@MERGE_TOOLS_DIR@|$(shell pwd)/mergetools|' \ -e 's|@TEMPLATE_DIR@|$(shell pwd)/templates/blt|' \ -e 's|@PROG@|$(shell pwd)/$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \ chmod +x $@ # GNU make supports exporting all variables by "export" without parameters. # However, the environment gets quite big, and some programs have problems # with that. +ifdef NO_GIT_SVN +NO_SVN_TESTS = YesPlease +endif export NO_SVN_TESTS export TEST_NO_MALLOC_CHECK ### Testing rules test: all $(MAKE) -C t/ all ifdef TEST_CONTRIB_TOO $(MAKE) -C contrib/ test endif
Signature · 1 line
2.55.0.975.g5fa7c85aff
Re: [PATCH v2 0/2] git-svn: don't print v1-layout migration noise when there's nothing to migrate
In reply to Wesley SchwengleQuoted 8 lines · Wesley Schwengle
Sorry, I missed the space when I reworked the patch a bit before sending it. Here is the new patch set for the change.
Wesley Schwengle (2):
git-svn: don't print v1-layout migration noise when there's nothing to
migrate
Makefile: addNO_GIT_SVNknob to skip building/installing git-svn
Quoted 4 lines
Makefile | 8 ++++++++ perl/Git/SVN/Migration.pm | 16 ++++++++++------ t/t9107-git-svn-migrate.sh | 7 +++++++ 3 files changed, 25 insertions(+), 6 deletions(-)
This has been hanging without receiving reviews from anybody since late August. As the number of topics that are in 'seen' without getting any attention is getting unmanageably large, I will have to drop this topic unless somebody volunteers and gives a thorough review on it in the coming few weeks.
PATCH 2/2 Makefile: add NO_GIT_SVN knob to skip building/installing git-svn
In reply to Wesley SchwengleThis option also implies that NO_SVN_TESTS is enabled.
--- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
Makefile +8 -0
@@ -81,20 +81,23 @@ include shared.mak # # Define NO_SYS_SELECT_H if you don't have sys/select.h. # # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # Enable it on Windows. By default, symrefs are still used. # # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability # tests. These tests take up a significant amount of the total test time # but are not needed unless you plan to talk to SVN repos. # +# Define NO_GIT_SVN if you don't want git-svn built or installed at all. +# Implies NO_SVN_TESTS. +# # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink # installed in /sw, but don't want GIT to link against any libraries # installed there. If defined you may specify your own (or Fink's) # include directories and library directories by defining CFLAGS # and LDFLAGS appropriately. # # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X, # have DarwinPorts (which is an old name for MacPorts) installed # in /opt/local, but don't want GIT to # link against any libraries installed there. If defined you may
@@ -741,21 +744,23 @@ SCRIPT_SH += git-web--browse.sh SCRIPT_LIB += git-mergetool--lib SCRIPT_LIB += git-sh-i18n SCRIPT_LIB += git-sh-setup SCRIPT_PERL += git-archimport.perl SCRIPT_PERL += git-cvsexportcommit.perl SCRIPT_PERL += git-cvsimport.perl SCRIPT_PERL += git-cvsserver.perl SCRIPT_PERL += git-send-email.perl +ifndef NO_GIT_SVN SCRIPT_PERL += git-svn.perl +endif SCRIPT_PYTHON += git-p4.py # Generated files for scripts SCRIPT_SH_GEN = $(patsubst %.sh,%,$(SCRIPT_SH)) SCRIPT_PERL_GEN = $(patsubst %.perl,%,$(SCRIPT_PERL)) SCRIPT_PYTHON_GEN = $(patsubst %.py,%,$(SCRIPT_PYTHON)) # Individual rules to allow e.g. # "make -C ../.. SCRIPT_PERL=contrib/foo/bar.perl build-perl-script"
@@ -3408,20 +3413,23 @@ $(test_bindir_programs): bin-wrappers/%: bin-wrappers/wrap-for-bin.sh -e 's|@GITPERLLIB@|$(shell pwd)/perl/build/lib|' \ -e 's|@MERGE_TOOLS_DIR@|$(shell pwd)/mergetools|' \ -e 's|@TEMPLATE_DIR@|$(shell pwd)/templates/blt|' \ -e 's|@PROG@|$(shell pwd)/$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \ chmod +x $@ # GNU make supports exporting all variables by "export" without parameters. # However, the environment gets quite big, and some programs have problems # with that. +ifdef NO_GIT_SVN +NO_SVN_TESTS = YesPlease +endif export NO_SVN_TESTS export TEST_NO_MALLOC_CHECK ### Testing rules test: all $(MAKE) -C t/ all ifdef TEST_CONTRIB_TOO $(MAKE) -C contrib/ test endif
Signature · 1 line
2.55.0.827.g48ce2c92dc