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]
- [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz] [-i] [-k] [-u]
- [-s subst] [-a] [-m] [-M regex] [-S regex] [CVS_module]
+ [-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]
+ [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]
+ [CVS_module]
END
exit(1);
}
close ($f);
}
-getopts("haivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage();
+# convert getopts specs for use by git-repo-config
+sub read_repo_config {
+ # Split the string between characters, unless there is a ':'
+ # So "abc:de" becomes ["a", "b", "c:", "d", "e"]
+ my @opts = split(/ *(?!:)/, shift);
+ foreach my $o (@opts) {
+ my $key = $o;
+ $key =~ s/://g;
+ my $arg = 'git-repo-config';
+ $arg .= ' --bool' if ($o !~ /:$/);
+
+ chomp(my $tmp = `$arg --get cvsimport.$key`);
+ if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {
+ no strict 'refs';
+ my $opt_name = "opt_" . $key;
+ if (!$$opt_name) {
+ $$opt_name = $tmp;
+ }
+ }
+ }
+ if (@ARGV == 0) {
+ chomp(my $module = `git-repo-config --get cvsimport.module`);
+ push(@ARGV, $module);
+ }
+}
+
+my $opts = "haivmkuo:d:p:C:z:s:M:P:A:S:L:";
+read_repo_config($opts);
+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;
} 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 ||= "-";
chomp $cvs_tree;
close $f;
} else {
- usage();
+ usage("CVS module has to be specified");
}
our @mergerx = ();