{"thread":{"id":"19830","subject":"[PATCH] Add -k option to cvsexportcommit to revert expanded CVS keywords in CVS working tree before applying commit patch","startedAt":"2009-06-16T14:21:04Z","lastAt":"2009-06-16T14:21:04Z","messageCount":1,"participants":["Alex Bennee"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116414","messageId":"b2cdc9f30906160721re87e2efvd342dc60e0f24c75@mail.gmail.com","threadId":"19830","inReplyTo":null,"subject":"[PATCH] Add -k option to cvsexportcommit to revert expanded CVS keywords in CVS working tree before applying commit patch","fromName":"Alex Bennee","fromEmail":"kernel-hacker@bennee.com","sentAt":"2009-06-16T14:21:04Z","receivedAt":"2009-06-16T14:21:04Z","isPatch":true,"sender":{"key":"kernel-hacker@bennee.com","avatar":null},"body":"Depending on how your CVS->GIT conversion went you will have some\nunexpanded CVS keywords in your GIT repo. If any of your git commits\ntouch these lines then the patch application will fail. This patch\naddresses that by adding an option that will revert and expanded CVS\nkeywords to files in the working CVS directory that are affected by\nthe commit being applied.\n\nSigned-off-by: Alex Benn�e <alex@bennee.com>\n---\n Documentation/git-cvsexportcommit.txt |    4 ++++\n git-cvsexportcommit.perl              |   25 ++++++++++++++++++++++---\n 2 files changed, 26 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-cvsexportcommit.txt\nb/Documentation/git-cvsexportcommit.txt\nindex 2da8588..7488b6d 100644\n--- a/Documentation/git-cvsexportcommit.txt\n+++ b/Documentation/git-cvsexportcommit.txt\n@@ -63,6 +63,10 @@ OPTIONS\n -u::\n \tUpdate affected files from CVS repository before attempting export.\n\n+-k::\n+\tReverse CVS keyword expansion (e.g. $Revision: 1.2.3.4$\n+\tbecomes $Revision$) in working CVS checkout before applying patch.\n+\t\n -w::\n \tSpecify the location of the CVS checkout to use for the export. This\n \toption does not require GIT_DIR to be set before execution if the\ndiff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\nindex 6d9f0ef..c3ebeac 100755\n--- a/git-cvsexportcommit.perl\n+++ b/git-cvsexportcommit.perl\n@@ -8,9 +8,9 @@ use File::Basename qw(basename dirname);\n use File::Spec;\n use Git;\n\n-our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m,\n$opt_d, $opt_u, $opt_w, $opt_W);\n+our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m,\n$opt_d, $opt_u, $opt_w, $opt_W, $opt_k);\n\n-getopts('uhPpvcfam:d:w:W');\n+getopts('uhPpvcfkam:d:w:W');\n\n $opt_h && usage();\n\n@@ -266,7 +266,26 @@ foreach my $f (@files) {\n \t$dirty = 1;\n \twarn \"File $f not up to date but has status '$cvsstat{$f}' in your\nCVS checkout!\\n\";\n     }\n+\n+    # Depending on how your GIT tree got imported from CVS you may\n+    # have a conflict between expanded keywords in your CVS tree and\n+    # unexpanded keywords in the patch about to be applied.\n+    if ($opt_k) {\n+\tmy $orig_file =\"$f.orig\";\n+\trename $f, $orig_file;\n+\topen(FILTER_IN, \"<$orig_file\") or die \"Cannot open $orig_file\\n\";\n+\topen(FILTER_OUT, \">$f\") or die \"Cannot open $f\\n\";\n+\twhile (<FILTER_IN>)\n+\t{\n+\t    my $line = $_;\n+\t    $line =~ s/\\$([A-Z][a-z]+):[^\\$]+\\$/\\$\\1\\$/g;\n+\t    print FILTER_OUT $line;\n+\t}\n+\tclose FILTER_IN;\n+\tclose FILTER_OUT;\n+    }\n }\n+\n if ($dirty) {\n     if ($opt_f) {\twarn \"The tree is not clean -- forced merge\\n\";\n \t$dirty = 0;\n@@ -370,7 +389,7 @@ sleep(1);\n\n sub usage {\n \tprint STDERR <<END;\n-Usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c]\n[-f] [-u] [-w cvsworkdir] [-m msgprefix] [ parent ] commit\n+Usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c]\n[-f] [-u] [-k] [-w cvsworkdir] [-m msgprefix] [ parent ] commit\n END\n \texit(1);\n }\n-- \n1.6.0.2.95.g72d40\n\n\n--\nAlex, homepage: http://www.bennee.com/~alex/\nhttp://www.half-llama.co.uk\n"}]}