@matheusbsbs / matheus-bagliano / commits / 67d232426b
Fork 0

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>

Jeff King committed Nov 30, 2007 at 17:22 UTC 67d232426b8858b31e54a9b6a5a90916690d1153
2 files changed +25 -4
git-cvsimport.perl
+4 -4
@@ -108,10 +108,6 @@ sub read_repo_config {
108 }
109 }
110 }
111 - if (@ARGV == 0) {
112 - chomp(my $module = `git-repo-config --get cvsimport.module`);
113 - push(@ARGV, $module);
114 - }
111 }
112
113 my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
@@ -119,6 +115,10 @@ read_repo_config($opts);
115 getopts($opts) or usage();
116 usage if $opt_h;
117
118 +if (@ARGV == 0) {
119 + chomp(my $module = `git-repo-config --get cvsimport.module`);
120 + push(@ARGV, $module) if $? == 0;
121 +}
122 @ARGV <= 1 or usage("You can't specify more than one CVS module");
123
124 if ($opt_d) {
t/t9600-cvsimport.sh
+21
@@ -98,4 +98,25 @@ test_expect_success 'update git module' '
98
99 '
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 +
122 test_done