Skip to content

Commit

Permalink
cvsimport: Improve usage error reporting
Browse files Browse the repository at this point in the history
Actually tell the user what he did wrong in case of usage errors
instead of only printing the general usage information.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Frank Lichtenheld authored and Junio C Hamano committed Apr 6, 2007
1 parent 407049c commit 7bf7764
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a);
my (%conv_author_name, %conv_author_email);

sub usage() {
sub usage(;$) {
my $msg = shift;
print(STDERR "Error: $msg\n") if $msg;
print STDERR <<END;
Usage: ${\basename $0} # fetch/update GIT from CVS
[-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
Expand Down Expand Up @@ -117,7 +119,7 @@ sub read_repo_config {
getopts($opts) or usage();
usage if $opt_h;

@ARGV <= 1 or usage();
@ARGV <= 1 or usage("You can't specify more than one CVS module");

if ($opt_d) {
$ENV{"CVSROOT"} = $opt_d;
Expand All @@ -130,7 +132,7 @@ sub read_repo_config {
} elsif ($ENV{"CVSROOT"}) {
$opt_d = $ENV{"CVSROOT"};
} else {
die "CVSROOT needs to be set";
usage("CVSROOT needs to be set");
}
$opt_o ||= "origin";
$opt_s ||= "-";
Expand All @@ -149,7 +151,7 @@ sub read_repo_config {
chomp $cvs_tree;
close $f;
} else {
usage();
usage("CVS module has to be specified");
}

our @mergerx = ();
Expand Down

0 comments on commit 7bf7764

Please sign in to comment.