Skip to content

Commit

Permalink
cvsimport: fix usage of cvsimport.module
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Nov 30, 2007
1 parent a6214fe commit 67d2324
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 4 additions & 4 deletions git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ sub read_repo_config {
}
}
}
if (@ARGV == 0) {
chomp(my $module = `git-repo-config --get cvsimport.module`);
push(@ARGV, $module);
}
}

my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
read_repo_config($opts);
getopts($opts) or usage();
usage if $opt_h;

if (@ARGV == 0) {
chomp(my $module = `git-repo-config --get cvsimport.module`);
push(@ARGV, $module) if $? == 0;
}
@ARGV <= 1 or usage("You can't specify more than one CVS module");

if ($opt_d) {
Expand Down
21 changes: 21 additions & 0 deletions t/t9600-cvsimport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,25 @@ test_expect_success 'update git module' '
'

test_expect_success 'update cvs module' '
cd module-cvs &&
echo 1 >tick &&
cvs add tick &&
cvs commit -m 1
cd ..
'

test_expect_success 'cvsimport.module config works' '
cd module-git &&
git config cvsimport.module module &&
git cvsimport -a -z0 &&
git merge origin &&
cd .. &&
git diff module-cvs/tick module-git/tick
'

test_done

0 comments on commit 67d2324

Please sign in to comment.