@matheusbsbs / matheus-bagliano / commits / 53909056da
Fork 0

contrib/git-svn: accept configuration via repo-config

repo-config keys are any of the long option names minus the '-' characters Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Apr 1, 2006 at 18:25 UTC 53909056da869eb79c2a20699794b63c8c87e7fd
1 file changed +17
contrib/git-svn/git-svn.perl
+17
@@ -67,6 +67,23 @@ for (my $i = 0; $i < @ARGV; $i++) {
67
68 my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
69
70 +# convert GetOpt::Long specs for use by git-repo-config
71 +foreach my $o (keys %opts) {
72 + my $v = $opts{$o};
73 + my ($key) = ($o =~ /^([a-z\-]+)/);
74 + $key =~ s/-//g;
75 + my $arg = 'git-repo-config';
76 + $arg .= ' --int' if ($o =~ /=i$/);
77 + $arg .= ' --bool' if ($o !~ /=[sfi]$/);
78 + $arg .= " svn.$key"; # $key only matches [a-z\-], always shell-safe
79 + if (ref $v eq 'ARRAY') {
80 + chomp(@$v = `$arg`);
81 + } else {
82 + chomp($$v = `$arg`);
83 + $$v = 0 if $$v eq 'false';
84 + }
85 +}
86 +
87 GetOptions(%opts, 'help|H|h' => \$_help,
88 'version|V' => \$_version,
89 'id|i=s' => \$GIT_SVN) or exit 1;