Imported Upstream version 2.14.2
[platform/upstream/git.git] / git-cvsimport.perl
index 0a31ebd..3692992 100755 (executable)
@@ -26,6 +26,7 @@ use IO::Socket;
 use IO::Pipe;
 use POSIX qw(strftime tzset dup2 ENOENT);
 use IPC::Open2;
+use Git qw(get_tz_offset);
 
 $SIG{'PIPE'}="IGNORE";
 set_timezone('UTC');
@@ -37,7 +38,7 @@ sub usage(;$) {
        my $msg = shift;
        print(STDERR "Error: $msg\n") if $msg;
        print STDERR <<END;
-Usage: git cvsimport     # fetch/update GIT from CVS
+usage: git cvsimport     # 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]
@@ -641,6 +642,7 @@ sub is_sha1 {
 
 sub get_headref ($) {
        my $name = shift;
+       $name =~ s/'/'\\''/;
        my $r = `git rev-parse --verify '$name' 2>/dev/null`;
        return undef unless $? == 0;
        chomp $r;
@@ -864,7 +866,9 @@ sub commit {
        }
 
        set_timezone($author_tz);
-       my $commit_date = strftime("%s %z", localtime($date));
+       # $date is in the seconds since epoch format
+       my $tz_offset = get_tz_offset($date);
+       my $commit_date = "$date $tz_offset";
        set_timezone('UTC');
        $ENV{GIT_AUTHOR_NAME} = $author_name;
        $ENV{GIT_AUTHOR_EMAIL} = $author_email;
@@ -918,7 +922,7 @@ sub commit {
                # (See check_refname_component in refs.c.)
                1 while $xtag =~ s/
                        (?: \.\.        # Tag cannot contain '..'.
-                       |   \@        # Tag cannot contain '@{'.
+                       |   \@\{        # Tag cannot contain '@{'.
                        | ^ -           # Tag cannot begin with '-'.
                        |   \.lock $    # Tag cannot end with '.lock'.
                        | ^ \.          # Tag cannot begin...
@@ -1159,7 +1163,7 @@ if ($orig_branch) {
                die "Fast-forward update failed: $?\n" if $?;
        }
        else {
-               system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
+               system(qw(git merge -m cvsimport), "$remote/$opt_o");
                die "Could not merge $opt_o into the current branch.\n" if $?;
        }
 } else {