X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fgit-svn%2Fgit-svn.perl;h=7c44450d72021a91069697826227922a841cd472;hb=fc9957b0052df6a8248420395bc9febd66194252;hp=3e5733eed91c35dd0c52ebcc57b9d560373f89f5;hpb=f4e96f97e85c145616bc2e23e9441bc0daa2906e;p=git.git diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl index 3e5733ee..7c44450d 100755 --- a/contrib/git-svn/git-svn.perl +++ b/contrib/git-svn/git-svn.perl @@ -9,7 +9,11 @@ use vars qw/ $AUTHOR $VERSION $GIT_DIR $REV_DIR/; $AUTHOR = 'Eric Wong '; $VERSION = '0.11.0'; -$GIT_DIR = $ENV{GIT_DIR} || "$ENV{PWD}/.git"; + +use Cwd qw/abs_path/; +$GIT_DIR = abs_path($ENV{GIT_DIR} || '.git'); +$ENV{GIT_DIR} = $GIT_DIR; + # make sure the svn binary gives consistent output between locales and TZs: $ENV{TZ} = 'UTC'; $ENV{LC_ALL} = 'C'; @@ -63,13 +67,31 @@ for (my $i = 0; $i < @ARGV; $i++) { my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd); +# convert GetOpt::Long specs for use by git-repo-config +foreach my $o (keys %opts) { + my $v = $opts{$o}; + my ($key) = ($o =~ /^([a-z\-]+)/); + $key =~ s/-//g; + my $arg = 'git-repo-config'; + $arg .= ' --int' if ($o =~ /=i$/); + $arg .= ' --bool' if ($o !~ /=[sfi]$/); + if (ref $v eq 'ARRAY') { + chomp(my @tmp = `$arg --get-all svn.$key`); + @$v = @tmp if @tmp; + } else { + chomp(my $tmp = `$arg --get svn.$key`); + if ($tmp && !($arg =~ / --bool / && $tmp eq 'false')) { + $$v = $tmp; + } + } +} + GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version, 'id|i=s' => \$GIT_SVN) or exit 1; $GIT_SVN ||= $ENV{GIT_SVN_ID} || 'git-svn'; $GIT_SVN_INDEX = "$GIT_DIR/$GIT_SVN/index"; -$ENV{GIT_DIR} ||= $GIT_DIR; $SVN_URL = undef; $REV_DIR = "$GIT_DIR/$GIT_SVN/revs"; $SVN_WC = "$GIT_DIR/$GIT_SVN/tree";