29
29
$SIG {' PIPE' }=" IGNORE" ;
30
30
$ENV {' TZ' }=" UTC" ;
31
31
32
- 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 ,$opt_A ,$opt_S ,$opt_L , $opt_a );
32
+ 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 ,$opt_A ,$opt_S ,$opt_L , $opt_a , $opt_r );
33
33
my (%conv_author_name , %conv_author_email );
34
34
35
35
sub usage (;$) {
40
40
[-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
41
41
[-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]
42
42
[-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]
43
- [CVS_module]
43
+ [-r remote] [ CVS_module]
44
44
END
45
45
exit (1);
46
46
}
@@ -114,7 +114,7 @@ sub read_repo_config {
114
114
}
115
115
}
116
116
117
- my $opts = " haivmkuo:d:p:C:z:s:M:P:A:S:L:" ;
117
+ my $opts = " haivmkuo:d:p:r: C:z:s:M:P:A:S:L:" ;
118
118
read_repo_config($opts );
119
119
getopts($opts ) or usage();
120
120
usage if $opt_h ;
@@ -134,13 +134,21 @@ sub read_repo_config {
134
134
} else {
135
135
usage(" CVSROOT needs to be set" );
136
136
}
137
- $opt_o ||= " origin" ;
138
137
$opt_s ||= " -" ;
139
138
$opt_a ||= 0;
140
139
141
140
my $git_tree = $opt_C ;
142
141
$git_tree ||= " ." ;
143
142
143
+ my $remote ;
144
+ if (defined $opt_r ) {
145
+ $remote = ' refs/remotes/' . $opt_r ;
146
+ $opt_o ||= " master" ;
147
+ } else {
148
+ $opt_o ||= " origin" ;
149
+ $remote = ' refs/heads' ;
150
+ }
151
+
144
152
my $cvs_tree ;
145
153
if ($#ARGV == 0) {
146
154
$cvs_tree = $ARGV [0];
522
530
my $name = shift ;
523
531
my $git_dir = shift ;
524
532
525
- my $f = " $git_dir /refs/heads /$name " ;
533
+ my $f = " $git_dir /$remote /$name " ;
526
534
if (open (my $fh , $f )) {
527
535
chomp (my $r = <$fh >);
528
536
is_sha1($r ) or die " Cannot get head id for $name ($r ): $! " ;
@@ -573,12 +581,12 @@ ($$)
573
581
574
582
# Get the last import timestamps
575
583
my $fmt = ' ($ref, $author) = (%(refname), %(author));' ;
576
- open (H, " git-for-each-ref --perl --format='$fmt ' refs/heads |" ) or
584
+ open (H, " git-for-each-ref --perl --format='$fmt ' $remote |" ) or
577
585
die " Cannot run git-for-each-ref: $! \n " ;
578
586
while (defined (my $entry = <H>)) {
579
587
my ($ref , $author );
580
588
eval ($entry ) || die " cannot eval refs list: $@ " ;
581
- my ($head ) = ($ref =~ m | ^refs/heads /(.*)| );
589
+ my ($head ) = ($ref =~ m | ^$remote /(.*)| );
582
590
$author =~ / ^.*\s (\d +)\s [-+]\d {4}$ / ;
583
591
$branch_date {$head } = $1 ;
584
592
}
@@ -701,9 +709,9 @@ sub commit {
701
709
$index {$branch } = tmpnam();
702
710
$ENV {GIT_INDEX_FILE } = $index {$branch };
703
711
if ($ancestor ) {
704
- system (" git-read-tree" , $ ancestor );
712
+ system (" git-read-tree" , " $remote / $ ancestor" );
705
713
} else {
706
- system (" git-read-tree" , $ branch );
714
+ system (" git-read-tree" , " $remote / $ branch" );
707
715
}
708
716
die " read-tree failed: $? \n " if $? ;
709
717
}
@@ -762,7 +770,7 @@ sub commit {
762
770
waitpid ($pid ,0);
763
771
die " Error running git-commit-tree: $? \n " if $? ;
764
772
765
- system (" git-update-ref refs/heads /$branch $cid " ) == 0
773
+ system (" git-update-ref $remote /$branch $cid " ) == 0
766
774
or die " Cannot write branch $branch for update: $! \n " ;
767
775
768
776
if ($tag ) {
@@ -861,20 +869,20 @@ sub commit {
861
869
print STDERR " Branch $branch erroneously stems from itself -- changed ancestor to $opt_o \n " ;
862
870
$ancestor = $opt_o ;
863
871
}
864
- if (-f " $git_dir /refs/heads /$branch " ) {
872
+ if (-f " $git_dir /$remote /$branch " ) {
865
873
print STDERR " Branch $branch already exists!\n " ;
866
874
$state =11;
867
875
next ;
868
876
}
869
- unless (open (H," $git_dir /refs/heads /$ancestor " )) {
877
+ unless (open (H," $git_dir /$remote /$ancestor " )) {
870
878
print STDERR " Branch $ancestor does not exist!\n " ;
871
879
$ignorebranch {$branch } = 1;
872
880
$state =11;
873
881
next ;
874
882
}
875
883
chomp (my $id = <H>);
876
884
close (H);
877
- unless (open (H," > $git_dir /refs/heads /$branch " )) {
885
+ unless (open (H," > $git_dir /$remote /$branch " )) {
878
886
print STDERR " Could not create branch $branch : $! \n " ;
879
887
$ignorebranch {$branch } = 1;
880
888
$state =11;
@@ -988,14 +996,16 @@ sub commit {
988
996
die "Fast-forward update failed: $? \n" if $? ;
989
997
}
990
998
else {
991
- system(qw(git-merge cvsimport HEAD), " refs/heads /$opt_o " );
999
+ system(qw(git-merge cvsimport HEAD), " $remote /$opt_o " );
992
1000
die " Could not merge $opt_o into the current branch.\n" if $? ;
993
1001
}
994
1002
} else {
995
1003
$orig_branch = " master" ;
996
1004
print " DONE; creating $orig_branch branch\n" if $opt_v ;
997
- system(" git-update-ref " , " refs/heads/master" , " refs/heads /$opt_o " )
1005
+ system(" git-update-ref " , " refs/heads/master" , " $remote /$opt_o " )
998
1006
unless -f " $git_dir /refs/heads/master" ;
1007
+ system(" git-symbolic-ref " , " $remote /HEAD" , " $remote /$opt_o " )
1008
+ if ($opt_r && $opt_o ne 'HEAD');
999
1009
system('git-update-ref', 'HEAD', " $orig_branch " );
1000
1010
unless ($opt_i ) {
1001
1011
system('git checkout');
0 commit comments