1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-12 17:36:08 +02:00

Allow passing of an alternative CVSROOT via -d.

This is necessary if using CVS in an asymmetric fashion, i.e. when the
CVSROOT you are checking out from differs from the CVSROOT you have to
commit to.

Signed-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Simon 'corecode' Schubert 2007-02-18 18:17:08 +01:00 committed by Junio C Hamano
parent d2cd696322
commit 4a6b9bb60a
2 changed files with 23 additions and 11 deletions

View File

@ -8,7 +8,7 @@ git-cvsexportcommit - Export a single commit to a CVS checkout
SYNOPSIS SYNOPSIS
-------- --------
'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID 'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-d cvsroot] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
DESCRIPTION DESCRIPTION
@ -43,6 +43,11 @@ OPTIONS
Add authorship information. Adds Author line, and Committer (if Add authorship information. Adds Author line, and Committer (if
different from Author) to the message. different from Author) to the message.
-d::
Set an alternative CVSROOT to use. This corresponds to the CVS
-d parameter. Usually users will not want to set this, except
if using CVS in an asymmetric fashion.
-f:: -f::
Force the merge even if the files are not up to date. Force the merge even if the files are not up to date.

View File

@ -15,14 +15,21 @@
die "GIT_DIR is not defined or is unreadable"; die "GIT_DIR is not defined or is unreadable";
} }
our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m ); our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d);
getopts('hPpvcfam:'); getopts('hPpvcfam:d:');
$opt_h && usage(); $opt_h && usage();
die "Need at least one commit identifier!" unless @ARGV; die "Need at least one commit identifier!" unless @ARGV;
my @cvs;
if ($opt_d) {
@cvs = ('cvs', '-d', $opt_d);
} else {
@cvs = ('cvs');
}
# setup a tempdir # setup a tempdir
our ($tmpdir, $tmpdirname) = tempdir('git-cvsapplycommit-XXXXXX', our ($tmpdir, $tmpdirname) = tempdir('git-cvsapplycommit-XXXXXX',
TMPDIR => 1, TMPDIR => 1,
@ -160,7 +167,7 @@
my $p = $1; my $p = $1;
next if (grep { $_ eq $p } @dirs); next if (grep { $_ eq $p } @dirs);
} }
my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f)); my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f));
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'}; if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
if (-d dirname $f and $status[0] !~ m/Status: Unknown$/ if (-d dirname $f and $status[0] !~ m/Status: Unknown$/
and $status[0] !~ m/^File: no file /) { and $status[0] !~ m/^File: no file /) {
@ -173,7 +180,7 @@
foreach my $f (@files) { foreach my $f (@files) {
next if grep { $_ eq $f } @afiles; next if grep { $_ eq $f } @afiles;
# TODO:we need to handle removed in cvs # TODO:we need to handle removed in cvs
my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f)); my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f));
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'}; if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
unless ($status[0] =~ m/Status: Up-to-date$/) { unless ($status[0] =~ m/Status: Up-to-date$/) {
$dirty = 1; $dirty = 1;
@ -194,7 +201,7 @@
print "Patch applied successfully. Adding new files and directories to CVS\n"; print "Patch applied successfully. Adding new files and directories to CVS\n";
my $dirtypatch = 0; my $dirtypatch = 0;
foreach my $d (@dirs) { foreach my $d (@dirs) {
if (system('cvs','add',$d)) { if (system(@cvs,'add',$d)) {
$dirtypatch = 1; $dirtypatch = 1;
warn "Failed to cvs add directory $d -- you may need to do it manually"; warn "Failed to cvs add directory $d -- you may need to do it manually";
} }
@ -202,9 +209,9 @@
foreach my $f (@afiles) { foreach my $f (@afiles) {
if (grep { $_ eq $f } @bfiles) { if (grep { $_ eq $f } @bfiles) {
system('cvs', 'add','-kb',$f); system(@cvs, 'add','-kb',$f);
} else { } else {
system('cvs', 'add', $f); system(@cvs, 'add', $f);
} }
if ($?) { if ($?) {
$dirtypatch = 1; $dirtypatch = 1;
@ -213,7 +220,7 @@
} }
foreach my $f (@dfiles) { foreach my $f (@dfiles) {
system('cvs', 'rm', '-f', $f); system(@cvs, 'rm', '-f', $f);
if ($?) { if ($?) {
$dirtypatch = 1; $dirtypatch = 1;
warn "Failed to cvs rm -f $f -- you may need to do it manually"; warn "Failed to cvs rm -f $f -- you may need to do it manually";
@ -223,7 +230,7 @@
print "Commit to CVS\n"; print "Commit to CVS\n";
print "Patch title (first comment line): $title\n"; print "Patch title (first comment line): $title\n";
my @commitfiles = map { unless (m/\s/) { '\''.$_.'\''; } else { $_; }; } (@files); my @commitfiles = map { unless (m/\s/) { '\''.$_.'\''; } else { $_; }; } (@files);
my $cmd = "cvs commit -F .msg @commitfiles"; my $cmd = join(' ', @cvs)." commit -F .msg @commitfiles";
if ($dirtypatch) { if ($dirtypatch) {
print "NOTE: One or more hunks failed to apply cleanly.\n"; print "NOTE: One or more hunks failed to apply cleanly.\n";
@ -236,7 +243,7 @@
if ($opt_c) { if ($opt_c) {
print "Autocommit\n $cmd\n"; print "Autocommit\n $cmd\n";
print safe_pipe_capture('cvs', 'commit', '-F', '.msg', @files); print safe_pipe_capture(@cvs, 'commit', '-F', '.msg', @files);
if ($?) { if ($?) {
die "Exiting: The commit did not succeed"; die "Exiting: The commit did not succeed";
} }