]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-cvsimport.perl
Merge git://git.bogomips.org/git-svn
[thirdparty/git.git] / git-cvsimport.perl
index 249aeaf17557c4b8f05fdd5f1df5c16d65f0f84c..bbf327f3e891cacdd14c0b18b51702ce14b2b6df 100755 (executable)
@@ -90,23 +90,40 @@ sub write_author_info($) {
 }
 
 # convert getopts specs for use by git config
+my %longmap = (
+       'A:' => 'authors-file',
+       'M:' => 'merge-regex',
+       'P:' => undef,
+       'R' => 'track-revisions',
+       'S:' => 'ignore-paths',
+);
+
 sub read_repo_config {
-    # Split the string between characters, unless there is a ':'
-    # So "abc:de" becomes ["a", "b", "c:", "d", "e"]
+       # 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 config';
                $arg .= ' --bool' if ($o !~ /:$/);
-
-        chomp(my $tmp = `$arg --get cvsimport.$key`);
+               my $ckey = $key;
+
+               if (exists $longmap{$o}) {
+                       # An uppercase option like -R cannot be
+                       # expressed in the configuration, as the
+                       # variable names are downcased.
+                       $ckey = $longmap{$o};
+                       next if (! defined $ckey);
+                       $ckey =~ s/-//g;
+               }
+               chomp(my $tmp = `$arg --get cvsimport.$ckey`);
                if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {
-            no strict 'refs';
-            my $opt_name = "opt_" . $key;
-            if (!$$opt_name) {
-                $$opt_name = $tmp;
-            }
+                       no strict 'refs';
+                       my $opt_name = "opt_" . $key;
+                       if (!$$opt_name) {
+                               $$opt_name = $tmp;
+                       }
                }
        }
 }
@@ -349,7 +366,9 @@ sub conn {
        $self->{'socketo'}->write("valid-requests\n");
        $self->{'socketo'}->flush();
 
-       chomp(my $rep=$self->readline());
+       my $rep=$self->readline();
+       die "Failed to read from server" unless defined $rep;
+       chomp($rep);
        if ($rep !~ s/^Valid-requests\s*//) {
                $rep="<unknown>" unless $rep;
                die "Expected Valid-requests from server, but got: $rep\n";
@@ -612,7 +631,7 @@ my %index; # holds filenames of one index per branch
 unless (-d $git_dir) {
        system(qw(git init));
        die "Cannot init the GIT db at $git_tree: $?\n" if $?;
-       system(qw(git read-tree));
+       system(qw(git read-tree --empty));
        die "Cannot init an empty tree: $?\n" if $?;
 
        $last_branch = $opt_o;