Merge branch 'ws/squelch-svn-migrate' into seen

* ws/squelch-svn-migrate:
  Makefile: add NO_GIT_SVN knob to skip building/installing git-svn
  git-svn: don't print v1-layout migration noise when there's nothing to migrate
seen
Junio C Hamano 2026-08-31 13:53:30 -07:00
commit 780c994586
3 changed files with 25 additions and 6 deletions

View File

@ -90,6 +90,9 @@ include shared.mak
# tests. These tests take up a significant amount of the total test time # 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. # 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 # 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 in /sw, but don't want GIT to link against any libraries
# installed there. If defined you may specify your own (or Fink's) # installed there. If defined you may specify your own (or Fink's)
@ -746,7 +749,9 @@ SCRIPT_PERL += git-cvsexportcommit.perl
SCRIPT_PERL += git-cvsimport.perl SCRIPT_PERL += git-cvsimport.perl
SCRIPT_PERL += git-cvsserver.perl SCRIPT_PERL += git-cvsserver.perl
SCRIPT_PERL += git-send-email.perl SCRIPT_PERL += git-send-email.perl
ifndef NO_GIT_SVN
SCRIPT_PERL += git-svn.perl SCRIPT_PERL += git-svn.perl
endif


SCRIPT_PYTHON += git-p4.py SCRIPT_PYTHON += git-p4.py


@ -3423,6 +3428,9 @@ $(test_bindir_programs): bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
# However, the environment gets quite big, and some programs have problems # However, the environment gets quite big, and some programs have problems
# with that. # with that.


ifdef NO_GIT_SVN
NO_SVN_TESTS = YesPlease
endif
export NO_SVN_TESTS export NO_SVN_TESTS
export TEST_NO_MALLOC_CHECK export TEST_NO_MALLOC_CHECK



View File

@ -91,11 +91,6 @@ sub migrate_from_v1 {
# just in case somebody used 'svn' as their $id at some point... # just in case somebody used 'svn' as their $id at some point...
return $migrated if -d $svn_dir && ! -f "$svn_dir/info/url"; 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/); my ($fh, $ctx) = command_output_pipe(qw/rev-parse --symbolic --all/);
while (<$fh>) { while (<$fh>) {
my $x = $_; my $x = $_;
@ -106,6 +101,15 @@ sub migrate_from_v1 {
next unless -f $info_url; next unless -f $info_url;
my $u = eval { ::file_to_s($info_url) }; my $u = eval { ::file_to_s($info_url) };
next unless $u; 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"); my $dn = dirname("$svn_dir/$x");
mkpath([$dn]) unless -d $dn; mkpath([$dn]) unless -d $dn;
if ($x eq 'svn') { # they used 'svn' as GIT_SVN_ID: if ($x eq 'svn') { # they used 'svn' as GIT_SVN_ID:
@ -127,7 +131,7 @@ sub migrate_from_v1 {
$migrated++; $migrated++;
} }
command_close_pipe($fh, $ctx); 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; $migrated;
} }



View File

@ -3,6 +3,13 @@
test_description='git svn metadata migrations from previous versions' test_description='git svn metadata migrations from previous versions'
. ./lib-git-svn.sh . ./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' ' test_expect_success 'setup old-looking metadata' '
cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn &&
mkdir import && mkdir import &&