Skip to content

Commit 60d5985

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 549ad6d commit 60d5985

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

git-cvsimport.perl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ ($)
8989
}
9090

9191
# convert getopts specs for use by git config
92+
my %longmap = (
93+
'A:' => 'authors-file',
94+
'M:' => 'merge-regex',
95+
'P:' => undef,
96+
'R' => 'track-revisions',
97+
'S:' => 'ignore-paths',
98+
);
99+
92100
sub read_repo_config {
93101
# Split the string between characters, unless there is a ':'
94102
# So "abc:de" becomes ["a", "b", "c:", "d", "e"]
@@ -98,8 +106,17 @@ sub read_repo_config {
98106
$key =~ s/://g;
99107
my $arg = 'git config';
100108
$arg .= ' --bool' if ($o !~ /:$/);
101-
102-
chomp(my $tmp = `$arg --get cvsimport.$key`);
109+
my $ckey = $key;
110+
111+
if (exists $longmap{$o}) {
112+
# An uppercase option like -R cannot be
113+
# expressed in the configuration, as the
114+
# variable names are downcased.
115+
$ckey = $longmap{$o};
116+
next if (! defined $ckey);
117+
$ckey =~ s/-//g;
118+
}
119+
chomp(my $tmp = `$arg --get cvsimport.$ckey`);
103120
if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {
104121
no strict 'refs';
105122
my $opt_name = "opt_" . $key;

t/t9600-cvsimport.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ EOF
8989
test_expect_success PERL 'update git module' '
9090
9191
(cd module-git &&
92-
git cvsimport -a -R -z 0 module &&
92+
git config cvsimport.trackRevisions true &&
93+
git cvsimport -a -z 0 module &&
9394
git merge origin
9495
) &&
9596
test_cmp module-cvs/o_fortuna module-git/o_fortuna
@@ -117,7 +118,8 @@ test_expect_success PERL 'cvsimport.module config works' '
117118
118119
(cd module-git &&
119120
git config cvsimport.module module &&
120-
git cvsimport -a -R -z0 &&
121+
git config cvsimport.trackRevisions true &&
122+
git cvsimport -a -z0 &&
121123
git merge origin
122124
) &&
123125
test_cmp module-cvs/tick module-git/tick
@@ -137,6 +139,7 @@ test_expect_success PERL 'import from a CVS working tree' '
137139
138140
$CVS co -d import-from-wt module &&
139141
(cd import-from-wt &&
142+
git config cvsimport.trackRevisions false &&
140143
git cvsimport -a -z0 &&
141144
echo 1 >expect &&
142145
git log -1 --pretty=format:%s%n >actual &&

0 commit comments

Comments
 (0)