|
1 | 1 | #!/usr/bin/perl -w |
2 | 2 |
|
3 | | -# Known limitations: |
4 | | -# - does not propagate permissions |
5 | | -# - error handling has not been extensively tested |
6 | | -# |
7 | | - |
8 | 3 | use strict; |
9 | 4 | use Getopt::Std; |
10 | 5 | use File::Temp qw(tempdir); |
11 | 6 | use Data::Dumper; |
12 | 7 | use File::Basename qw(basename dirname); |
13 | 8 |
|
14 | | -unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){ |
15 | | - die "GIT_DIR is not defined or is unreadable"; |
16 | | -} |
17 | | - |
18 | | -our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u); |
| 9 | +our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w); |
19 | 10 |
|
20 | | -getopts('uhPpvcfam:d:'); |
| 11 | +getopts('uhPpvcfam:d:w:'); |
21 | 12 |
|
22 | 13 | $opt_h && usage(); |
23 | 14 |
|
24 | 15 | die "Need at least one commit identifier!" unless @ARGV; |
25 | 16 |
|
| 17 | +if ($opt_w) { |
| 18 | + unless ($ENV{GIT_DIR}) { |
| 19 | + # Remember where our GIT_DIR is before changing to CVS checkout |
| 20 | + my $gd =`git-rev-parse --git-dir`; |
| 21 | + chomp($gd); |
| 22 | + if ($gd eq '.git') { |
| 23 | + my $wd = `pwd`; |
| 24 | + chomp($wd); |
| 25 | + $gd = $wd."/.git" ; |
| 26 | + } |
| 27 | + $ENV{GIT_DIR} = $gd; |
| 28 | + } |
| 29 | + |
| 30 | + if (! -d $opt_w."/CVS" ) { |
| 31 | + die "$opt_w is not a CVS checkout"; |
| 32 | + } |
| 33 | + chdir $opt_w or die "Cannot change to CVS checkout at $opt_w"; |
| 34 | +} |
| 35 | +unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){ |
| 36 | + die "GIT_DIR is not defined or is unreadable"; |
| 37 | +} |
| 38 | + |
| 39 | + |
26 | 40 | my @cvs; |
27 | 41 | if ($opt_d) { |
28 | 42 | @cvs = ('cvs', '-d', $opt_d); |
|
274 | 288 | print "You'll need to apply the patch in .cvsexportcommit.diff manually\n"; |
275 | 289 | print "using a patch program. After applying the patch and resolving the\n"; |
276 | 290 | print "problems you may commit using:"; |
| 291 | + print "\n cd \"$opt_w\"" if $opt_w; |
277 | 292 | print "\n $cmd\n\n"; |
278 | 293 | exit(1); |
279 | 294 | } |
|
301 | 316 |
|
302 | 317 | sub usage { |
303 | 318 | print STDERR <<END; |
304 | | -Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [-f] [-m msgprefix] [ parent ] commit |
| 319 | +Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [-f] [-u] [-w cvsworkdir] [-m msgprefix] [ parent ] commit |
305 | 320 | END |
306 | 321 | exit(1); |
307 | 322 | } |
|
0 commit comments