Git fork

cvsimport: fix usage of cvsimport.module

There were two problems:

1. We only look at the config variable if there is no module
given on the command line. We checked this by comparing
@ARGV == 0. However, at the time of the comparison, we
have not yet parsed the dashed options, meaning that
"git cvsimport" would read the variable but "git
cvsimport -a" would not. This is fixed by simply moving
the check after the call to getopt.

2. If the config variable did not exist, we were adding an
empty string to @ARGV. The rest of the script, rather
than barfing for insufficient input, would then try to
import the module '', leading to rather confusing error
messages. Based on patch from Emanuele Giaquinta.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Jeff King and committed by
Junio C Hamano
67d23242 a6214fe0

+25 -4
+4 -4
git-cvsimport.perl
··· 108 108 } 109 109 } 110 110 } 111 - if (@ARGV == 0) { 112 - chomp(my $module = `git-repo-config --get cvsimport.module`); 113 - push(@ARGV, $module); 114 - } 115 111 } 116 112 117 113 my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:"; ··· 119 115 getopts($opts) or usage(); 120 116 usage if $opt_h; 121 117 118 + if (@ARGV == 0) { 119 + chomp(my $module = `git-repo-config --get cvsimport.module`); 120 + push(@ARGV, $module) if $? == 0; 121 + } 122 122 @ARGV <= 1 or usage("You can't specify more than one CVS module"); 123 123 124 124 if ($opt_d) {
+21
t/t9600-cvsimport.sh
··· 98 98 99 99 ' 100 100 101 + test_expect_success 'update cvs module' ' 102 + 103 + cd module-cvs && 104 + echo 1 >tick && 105 + cvs add tick && 106 + cvs commit -m 1 107 + cd .. 108 + 109 + ' 110 + 111 + test_expect_success 'cvsimport.module config works' ' 112 + 113 + cd module-git && 114 + git config cvsimport.module module && 115 + git cvsimport -a -z0 && 116 + git merge origin && 117 + cd .. && 118 + git diff module-cvs/tick module-git/tick 119 + 120 + ' 121 + 101 122 test_done