cvsimport: Added option '-p': pass options to cvsps
[gitweb.git] / git-cvsimport-script
index 3f157725c8d3bcb8142b2e840d665c49ab8a24d1..7ee8845a3dd922644d9cf9b9e64da29c4c59497f 100755 (executable)
@@ -26,18 +26,19 @@ use POSIX qw(strftime dup2);
 $SIG{'PIPE'}="IGNORE";
 $ENV{'TZ'}="UTC";
 
-our($opt_h,$opt_o,$opt_v,$opt_d);
+our($opt_h,$opt_o,$opt_v,$opt_d,$opt_p);
 
 sub usage() {
        print STDERR <<END;
 Usage: ${\basename $0}     # fetch/update GIT from CVS
           [ -o branch-for-HEAD ] [ -h ] [ -v ] [ -d CVSROOT ]
+       [ -p opts-for-cvsps ]
        CVS_module [ GIT_repository ]
 END
        exit(1);
 }
 
-getopts("hqvo:d:") or usage();
+getopts("hqvo:d:p:") or usage();
 usage if $opt_h;
 
 @ARGV == 1 or @ARGV == 2 or usage();
@@ -338,6 +339,11 @@ unless(-d $git_dir) {
        $last_branch = $opt_o;
        $orig_branch = "";
 } else {
+       -f "$git_dir/refs/head/$opt_o"
+               or die "Branch '$opt_o' does not exist.\n".
+                      "Either use the correct '-o branch' option,\n".
+                      "or import to a new repository.\n";
+
        $last_branch = basename(readlink("$git_dir/HEAD"));
        unless($last_branch) {
                warn "Cannot read the last branch name: $! -- assuming 'master'\n";
@@ -370,7 +376,9 @@ unless(-d $git_dir) {
 my $pid = open(CVS,"-|");
 die "Cannot fork: $!\n" unless defined $pid;
 unless($pid) {
-       exec("cvsps","-A","--cvs-direct",$cvs_tree);
+       my @opt;
+       @opt = split(/,/,$opt_p) if defined $opt_p;
+       exec("cvsps",@opt,"-x","-A","--cvs-direct",$cvs_tree);
        die "Could not start cvsps: $!\n";
 }