Skip to content

Commit 907ffe1

Browse files
Alex Bennéegitster
authored andcommitted
Add -k option to cvsexportcommit to revert expanded CVS keywords in CVS working tree before applying commit patch
Depending on how your CVS->GIT conversion went you will have some unexpanded CVS keywords in your GIT repo. If any of your git commits touch these lines then the patch application will fail. This patch addresses that by adding an option that will revert and expanded CVS keywords to files in the working CVS directory that are affected by the commit being applied. Signed-off-by: Alex Bennée <alex@bennee.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4f4fa9c commit 907ffe1

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Documentation/git-cvsexportcommit.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ OPTIONS
6363
-u::
6464
Update affected files from CVS repository before attempting export.
6565

66+
-k::
67+
Reverse CVS keyword expansion (e.g. $Revision: 1.2.3.4$
68+
becomes $Revision$) in working CVS checkout before applying patch.
69+
6670
-w::
6771
Specify the location of the CVS checkout to use for the export. This
6872
option does not require GIT_DIR to be set before execution if the

git-cvsexportcommit.perl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use File::Spec;
99
use Git;
1010

11-
our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w, $opt_W);
11+
our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w, $opt_W, $opt_k);
1212

13-
getopts('uhPpvcfam:d:w:W');
13+
getopts('uhPpvcfkam:d:w:W');
1414

1515
$opt_h && usage();
1616

@@ -287,7 +287,26 @@
287287
$dirty = 1;
288288
warn "File $f not up to date but has status '$cvsstat{$f}' in your CVS checkout!\n";
289289
}
290+
291+
# Depending on how your GIT tree got imported from CVS you may
292+
# have a conflict between expanded keywords in your CVS tree and
293+
# unexpanded keywords in the patch about to be applied.
294+
if ($opt_k) {
295+
my $orig_file ="$f.orig";
296+
rename $f, $orig_file;
297+
open(FILTER_IN, "<$orig_file") or die "Cannot open $orig_file\n";
298+
open(FILTER_OUT, ">$f") or die "Cannot open $f\n";
299+
while (<FILTER_IN>)
300+
{
301+
my $line = $_;
302+
$line =~ s/\$([A-Z][a-z]+):[^\$]+\$/\$\1\$/g;
303+
print FILTER_OUT $line;
304+
}
305+
close FILTER_IN;
306+
close FILTER_OUT;
307+
}
290308
}
309+
291310
if ($dirty) {
292311
if ($opt_f) { warn "The tree is not clean -- forced merge\n";
293312
$dirty = 0;
@@ -391,7 +410,7 @@
391410

392411
sub usage {
393412
print STDERR <<END;
394-
Usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c] [-f] [-u] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
413+
Usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c] [-f] [-u] [-k] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
395414
END
396415
exit(1);
397416
}

0 commit comments

Comments
 (0)