Add config variable core.symrefsonly
[gitweb.git] / git-cvsimport.perl
index 565f4f1b32c8b9d96df3602ab2d729cf3529836a..7bd9136205f46d4334b7272e6617c0f7f553f5e8 100755 (executable)
@@ -29,7 +29,7 @@
 $SIG{'PIPE'}="IGNORE";
 $ENV{'TZ'}="UTC";
 
-our($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_s,$opt_m,$opt_M);
+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);
 
 sub usage() {
        print STDERR <<END;
@@ -41,7 +41,7 @@ END
        exit(1);
 }
 
-getopts("hivmkuo:d:p:C:z:s:M:") or usage();
+getopts("hivmkuo:d:p:C:z:s:M:P:") or usage();
 usage if $opt_h;
 
 @ARGV <= 1 or usage();
@@ -337,6 +337,10 @@ sub file {
        }
        close ($fh);
 
+       if ($res eq '') {
+           die "Looks like the server has gone away while fetching $fn $rev -- exiting!";
+       }
+
        return ($name, $res);
 }
 
@@ -487,8 +491,16 @@ ($$)
        my @opt;
        @opt = split(/,/,$opt_p) if defined $opt_p;
        unshift @opt, '-z', $opt_z if defined $opt_z;
-       exec("cvsps",@opt,"-u","-A","--cvs-direct",'--root',$opt_d,$cvs_tree);
-       die "Could not start cvsps: $!\n";
+       unshift @opt, '-q'         unless defined $opt_v;
+       unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
+               push @opt, '--cvs-direct';
+       }
+       if ($opt_P) {
+           exec("cat", $opt_P);
+       } else {
+           exec("cvsps",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
+           die "Could not start cvsps: $!\n";
+       }
 }
 
 
@@ -510,7 +522,7 @@ ($$)
 
 my $state = 0;
 
-my($patchset,$date,$author,$branch,$ancestor,$tag,$logmsg);
+my($patchset,$date,$author_name,$author_email,$branch,$ancestor,$tag,$logmsg);
 my(@old,@new);
 my $commit = sub {
        my $pid;
@@ -567,6 +579,7 @@ ($$)
        unless($pid) {
                $pr->writer();
                $pw->reader();
+               open(OUT,">&STDOUT");
                dup2($pw->fileno(),0);
                dup2($pr->fileno(),1);
                $pr->close();
@@ -584,18 +597,17 @@ ($$)
                                if ( -e "$git_dir/refs/heads/$mparent") {
                                        $mparent = get_headref($mparent, $git_dir);
                                        push @par, '-p', $mparent;
-                                       # printing here breaks import # 
-                                       # # print "Merge parent branch: $mparent\n" if $opt_v;
+                                       print OUT "Merge parent branch: $mparent\n" if $opt_v;
                                }
-                       } 
+                       }
                }
 
                exec("env",
-                       "GIT_AUTHOR_NAME=$author",
-                       "GIT_AUTHOR_EMAIL=$author",
+                       "GIT_AUTHOR_NAME=$author_name",
+                       "GIT_AUTHOR_EMAIL=$author_email",
                        "GIT_AUTHOR_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
-                       "GIT_COMMITTER_NAME=$author",
-                       "GIT_COMMITTER_EMAIL=$author",
+                       "GIT_COMMITTER_NAME=$author_name",
+                       "GIT_COMMITTER_EMAIL=$author_email",
                        "GIT_COMMITTER_DATE=".strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)),
                        "git-commit-tree", $tree,@par);
                die "Cannot exec git-commit-tree: $!\n";
@@ -638,7 +650,7 @@ ($$)
                print $out "object $cid\n".
                    "type commit\n".
                    "tag $xtag\n".
-                   "tagger $author <$author>\n"
+                   "tagger $author_name <$author_email>\n"
                    or die "Cannot create tag object $xtag: $!\n";
                close($out)
                    or die "Cannot create tag object $xtag: $!\n";
@@ -683,7 +695,11 @@ ($$)
                $state=3;
        } elsif($state == 3 and s/^Author:\s+//) {
                s/\s+$//;
-               $author = $_;
+               if (/^(.*?)\s+<(.*)>/) {
+                   ($author_name, $author_email) = ($1, $2);
+               } else {
+                   $author_name = $author_email = $_;
+               }
                $state = 4;
        } elsif($state == 4 and s/^Branch:\s+//) {
                s/\s+$//;