From 549ad6d2f3a7090d6f73f8ebacd5d1db7a0cf90f Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sun, 28 Nov 2010 20:39:45 +0100 Subject: cvsimport: partial whitespace cleanup in preparation of the config parse patch Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 7ab7bbc9ea..bf953543ac 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -90,8 +90,8 @@ sub write_author_info($) { # convert getopts specs for use by git config sub read_repo_config { - # Split the string between characters, unless there is a ':' - # So "abc:de" becomes ["a", "b", "c:", "d", "e"] + # Split the string between characters, unless there is a ':' + # So "abc:de" becomes ["a", "b", "c:", "d", "e"] my @opts = split(/ *(?!:)/, shift); foreach my $o (@opts) { my $key = $o; @@ -99,13 +99,13 @@ sub read_repo_config { my $arg = 'git config'; $arg .= ' --bool' if ($o !~ /:$/); - chomp(my $tmp = `$arg --get cvsimport.$key`); + chomp(my $tmp = `$arg --get cvsimport.$key`); if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) { - no strict 'refs'; - my $opt_name = "opt_" . $key; - if (!$$opt_name) { - $$opt_name = $tmp; - } + no strict 'refs'; + my $opt_name = "opt_" . $key; + if (!$$opt_name) { + $$opt_name = $tmp; + } } } } -- cgit v1.2.3 From 60d5985dab5d3c5a283f060414b903778adfd09a Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 29 Dec 2010 22:55:34 +0100 Subject: cvsimport: handle the parsing of uppercase config options The current code leads to fatal: bad config value for 'cvsimport.r' in .git/config for a standard use case with cvsimport.r set. cvsimport sets internal variables by checking the config for each possible command line option. The problem is that config items are case insensitive, so config.r and config.R are the same. The ugly error is due to that fact that cvsimport expects a bool for -R (and thus config.R) but a remote name for -r (and thus config.r). Fix this by making cvsimport expect long names for uppercase options. config options for cvsimport have been undocumented so far, though present in the code and advertised in several tutorials. So one may read "enhance" for "fix". Similarly, the names for the options are "documented" in the code, waitiing for their lowercase equivalents to be transformed into long config options, as well. Helped-by: Junio C Hamano Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index bf953543ac..58f5b11dc2 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -89,6 +89,14 @@ sub write_author_info($) { } # convert getopts specs for use by git config +my %longmap = ( + 'A:' => 'authors-file', + 'M:' => 'merge-regex', + 'P:' => undef, + 'R' => 'track-revisions', + 'S:' => 'ignore-paths', +); + sub read_repo_config { # Split the string between characters, unless there is a ':' # So "abc:de" becomes ["a", "b", "c:", "d", "e"] @@ -98,8 +106,17 @@ sub read_repo_config { $key =~ s/://g; my $arg = 'git config'; $arg .= ' --bool' if ($o !~ /:$/); - - chomp(my $tmp = `$arg --get cvsimport.$key`); + my $ckey = $key; + + if (exists $longmap{$o}) { + # An uppercase option like -R cannot be + # expressed in the configuration, as the + # variable names are downcased. + $ckey = $longmap{$o}; + next if (! defined $ckey); + $ckey =~ s/-//g; + } + chomp(my $tmp = `$arg --get cvsimport.$ckey`); if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) { no strict 'refs'; my $opt_name = "opt_" . $key; -- cgit v1.2.3