Code

hooks-pre-commit: use \t, rather than a literal TAB in regexp
[git.git] / git-cvsimport.perl
index f16ac3d8a06692e5b93222dee55ff41b4bee2d64..2954fb846e3372a648124d92b7c1a1ccbd44306f 100755 (executable)
@@ -40,7 +40,7 @@ Usage: ${\basename $0}     # fetch/update GIT from CVS
        [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
        [-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]
+       [-r remote] [CVS_module]
 END
        exit(1);
 }
@@ -153,7 +153,7 @@ my $cvs_tree;
 if ($#ARGV == 0) {
        $cvs_tree = $ARGV[0];
 } elsif (-f 'CVS/Repository') {
-       open my $f, '<', 'CVS/Repository' or 
+       open my $f, '<', 'CVS/Repository' or
            die 'Failed to open CVS/Repository';
        $cvs_tree = <$f>;
        chomp $cvs_tree;
@@ -442,7 +442,7 @@ sub file {
        my ($self,$fn,$rev) = @_;
        my $res;
 
-       my ($fh, $name) = tempfile('gitcvs.XXXXXX', 
+       my ($fh, $name) = tempfile('gitcvs.XXXXXX',
                    DIR => File::Spec->tmpdir(), UNLINK => 1);
 
        $self->_file($fn,$rev) and $res = $self->_line($fh);
@@ -528,8 +528,8 @@ sub is_sha1 {
 
 sub get_headref ($$) {
     my $name    = shift;
-    my $git_dir = shift; 
-    
+    my $git_dir = shift;
+
     my $f = "$git_dir/$remote/$name";
     if (open(my $fh, $f)) {
            chomp(my $r = <$fh>);
@@ -700,8 +700,8 @@ sub commit {
        if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) {
            # looks like an initial commit
            # use the index primed by git-init
-           $ENV{GIT_INDEX_FILE} = '.git/index';
-           $index{$branch} = '.git/index';
+           $ENV{GIT_INDEX_FILE} = "$git_dir/index";
+           $index{$branch} = "$git_dir/index";
        } else {
            # use an index per branch to speed up
            # imports of projects with many branches
@@ -774,36 +774,13 @@ sub commit {
                or die "Cannot write branch $branch for update: $!\n";
 
        if ($tag) {
-               my ($in, $out) = ('','');
                my ($xtag) = $tag;
                $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
                $xtag =~ tr/_/\./ if ( $opt_u );
                $xtag =~ s/[\/]/$opt_s/g;
-               
-               my $pid = open2($in, $out, 'git-mktag');
-               print $out "object $cid\n".
-                   "type commit\n".
-                   "tag $xtag\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";
-
-               my $tagobj = <$in>;
-               chomp $tagobj;
-
-               if ( !close($in) or waitpid($pid, 0) != $pid or
-                    $? != 0 or $tagobj !~ /^[0123456789abcdef]{40}$/ ) {
-                   die "Cannot create tag object $xtag: $!\n";
-               }
-               
-
-               open(C,">$git_dir/refs/tags/$xtag")
+
+               system('git-tag', '-f', $xtag, $cid) == 0
                        or die "Cannot create tag $xtag: $!\n";
-               print C "$tagobj\n"
-                       or die "Cannot write tag $xtag: $!\n";
-               close(C)
-                       or die "Cannot write tag $xtag: $!\n";
 
                print "Created tag '$xtag' on '$branch'\n" if $opt_v;
        }
@@ -992,7 +969,7 @@ if ($line =~ /^(\d+) objects, (\d+) kilobytes$/) {
 }
 
 foreach my $git_index (values %index) {
-    if ($git_index ne '.git/index') {
+    if ($git_index ne "$git_dir/index") {
        unlink($git_index);
     }
 }
@@ -1026,9 +1003,11 @@ if ($orig_branch) {
        print "DONE; creating $orig_branch branch\n" if $opt_v;
        system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
                unless -f "$git_dir/refs/heads/master";
+       system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
+               if ($opt_r && $opt_o ne 'HEAD');
        system('git-update-ref', 'HEAD', "$orig_branch");
        unless ($opt_i) {
-               system('git checkout');
+               system('git checkout -f');
                die "checkout failed: $?\n" if $?;
        }
 }