git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add -k option to cvsexportcommit to revert expanded CVS keywords in CVS working tree before applying commit patch

From
ABAlex Bennee <kernel-hacker@bennee.com>
Date
Jun 16, 2009, 14:21 UTC
Message-ID
<b2cdc9f30906160721re87e2efvd342dc60e0f24c75@mail.gmail.com>

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>
---
 Documentation/git-cvsexportcommit.txt |    4 ++++
 git-cvsexportcommit.perl              |   25 ++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-cvsexportcommit.txt
b/Documentation/git-cvsexportcommit.txt
index 2da8588..7488b6d 100644
--- a/Documentation/git-cvsexportcommit.txt
+++ b/Documentation/git-cvsexportcommit.txt
@@ -63,6 +63,10 @@ OPTIONS
 -u::
 	Update affected files from CVS repository before attempting export.

+-k::
+	Reverse CVS keyword expansion (e.g. $Revision: 1.2.3.4$
+	becomes $Revision$) in working CVS checkout before applying patch.
+	
 -w::
 	Specify the location of the CVS checkout to use for the export. This
 	option does not require GIT_DIR to be set before execution if the
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 6d9f0ef..c3ebeac 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -8,9 +8,9 @@ use File::Basename qw(basename dirname);
 use File::Spec;
 use Git;

-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);
+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);

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

 $opt_h && usage();

@@ -266,7 +266,26 @@ foreach my $f (@files) {
 	$dirty = 1;
 	warn "File $f not up to date but has status '$cvsstat{$f}' in your
CVS checkout!\n";
     }
+
+    # Depending on how your GIT tree got imported from CVS you may
+    # have a conflict between expanded keywords in your CVS tree and
+    # unexpanded keywords in the patch about to be applied.
+    if ($opt_k) {
+	my $orig_file ="$f.orig";
+	rename $f, $orig_file;
+	open(FILTER_IN, "<$orig_file") or die "Cannot open $orig_file\n";
+	open(FILTER_OUT, ">$f") or die "Cannot open $f\n";
+	while (<FILTER_IN>)
+	{
+	    my $line = $_;
+	    $line =~ s/\$([A-Z][a-z]+):[^\$]+\$/\$\1\$/g;
+	    print FILTER_OUT $line;
+	}
+	close FILTER_IN;
+	close FILTER_OUT;
+    }
 }
+
 if ($dirty) {
     if ($opt_f) {	warn "The tree is not clean -- forced merge\n";
 	$dirty = 0;
@@ -370,7 +389,7 @@ sleep(1);

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


--
Alex, homepage: http://www.bennee.com/~alex/
http://www.half-llama.co.uk
Message 1 of 1 in “Add -k option to cvsexportcommit to revert expanded CVS keywords in CVS working tree before applying commit patch”
  1. Add -k option to cvsexportcommit to revert expanded CVS keywords in CVS working tree before applying commit patchAlex Bennee, Jun 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.