{"thread":{"id":"26159","subject":"[PATCH 0/2] Handle cvsimport config for uppercase options","startedAt":"2010-12-29T21:55:32Z","lastAt":"2010-12-29T21:55:34Z","messageCount":3,"participants":["Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"158731","messageId":"cover.1293659350.git.git@drmicha.warpmail.net","threadId":"26159","inReplyTo":null,"subject":"[PATCH 0/2] Handle cvsimport config for uppercase options","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-29T21:55:32Z","receivedAt":"2010-12-29T21:55:32Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Sorry for rushing this out (no in-reply-to etc.) , I'm mostly offline\nthese days and pressed by the rc phase.\n\nThis is the version (n+1) as suggested by Junio, so 2/2 is mostly by JC\n(only that his patch didn't apply, it probably was for maint).\n\nI dropped the documentation patch, since the discussion resulted in short\nconfig option names being frowned upon, so we should leave them undocumented\nand return to rewrite them one day.\n\nMichael J Gruber (2):\n  cvsimport: partial whitespace cleanup\n  cvsimport: handle the parsing of uppercase config options\n\n git-cvsimport.perl   |   33 +++++++++++++++++++++++++--------\n t/t9600-cvsimport.sh |    7 +++++--\n 2 files changed, 30 insertions(+), 10 deletions(-)\n\n-- \n1.7.3.4.865.ga2bc4\n"},{"id":"158732","messageId":"468f815beeede312f98daa66986ce8bf887724b3.1293659350.git.git@drmicha.warpmail.net","threadId":"26159","inReplyTo":"cover.1293659350.git.git@drmicha.warpmail.net","subject":"[PATCH 1/2] cvsimport: partial whitespace cleanup","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-29T21:55:33Z","receivedAt":"2010-12-29T21:55:33Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"in preparation of the config parse patch\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n git-cvsimport.perl |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex d27abfe..7888b77 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -91,8 +91,8 @@ sub write_author_info($) {\n \n # convert getopts specs for use by git config\n sub read_repo_config {\n-    # Split the string between characters, unless there is a ':'\n-    # So \"abc:de\" becomes [\"a\", \"b\", \"c:\", \"d\", \"e\"]\n+\t# Split the string between characters, unless there is a ':'\n+\t# So \"abc:de\" becomes [\"a\", \"b\", \"c:\", \"d\", \"e\"]\n \tmy @opts = split(/ *(?!:)/, shift);\n \tforeach my $o (@opts) {\n \t\tmy $key = $o;\n@@ -100,13 +100,13 @@ sub read_repo_config {\n \t\tmy $arg = 'git config';\n \t\t$arg .= ' --bool' if ($o !~ /:$/);\n \n-        chomp(my $tmp = `$arg --get cvsimport.$key`);\n+\t\tchomp(my $tmp = `$arg --get cvsimport.$key`);\n \t\tif ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {\n-            no strict 'refs';\n-            my $opt_name = \"opt_\" . $key;\n-            if (!$$opt_name) {\n-                $$opt_name = $tmp;\n-            }\n+\t\t\tno strict 'refs';\n+\t\t\tmy $opt_name = \"opt_\" . $key;\n+\t\t\tif (!$$opt_name) {\n+\t\t\t\t$$opt_name = $tmp;\n+\t\t\t}\n \t\t}\n \t}\n }\n-- \n1.7.3.4.865.ga2bc4\n"},{"id":"158733","messageId":"1f8628ba77f5aaeb00a627c851b431274b60c740.1293659350.git.git@drmicha.warpmail.net","threadId":"26159","inReplyTo":"cover.1293659350.git.git@drmicha.warpmail.net","subject":"[PATCH 2/2] cvsimport: handle the parsing of uppercase config options","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-29T21:55:34Z","receivedAt":"2010-12-29T21:55:34Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"The current code leads to\n\nfatal: bad config value for 'cvsimport.r' in .git/config\n\nfor a standard use case with cvsimport.r set:\n\ncvsimport sets internal variables by checking the config for each\npossible command line option. The problem is that config items are case\ninsensitive, so config.r and config.R are the same. The ugly error is\ndue to that fact that cvsimport expects a bool for -R (and thus\nconfig.R) but a remote name for -r (and thus config.r).\n\nFix this by making cvsimport expect long names for uppercase options.\n\nconfig options for cvsimport have been undocumented so far, though\npresent in the code and advertised in several tutorials. So one may read\n\"enhance\" for \"fix\". Similarly, the names for the options are\n\"documented\" in the code, waitiing for their lowercase equivalents to be\ntransformed into long config options, as well.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n git-cvsimport.perl   |   19 ++++++++++++++++++-\n t/t9600-cvsimport.sh |    7 +++++--\n 2 files changed, 23 insertions(+), 3 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 7888b77..8e683e5 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -90,6 +90,14 @@ sub write_author_info($) {\n }\n \n # convert getopts specs for use by git config\n+my %longmap = (\n+\t'A:' => 'authors-file',\n+\t'M:' => 'merge-regex',\n+\t'P:' => undef,\n+\t'R' => 'track-revisions',\n+\t'S:' => 'ignore-paths',\n+);\n+\n sub read_repo_config {\n \t# Split the string between characters, unless there is a ':'\n \t# So \"abc:de\" becomes [\"a\", \"b\", \"c:\", \"d\", \"e\"]\n@@ -99,8 +107,17 @@ sub read_repo_config {\n \t\t$key =~ s/://g;\n \t\tmy $arg = 'git config';\n \t\t$arg .= ' --bool' if ($o !~ /:$/);\n-\n-\t\tchomp(my $tmp = `$arg --get cvsimport.$key`);\n+\t\tmy $ckey = $key;\n+\n+\t\tif (exists $longmap{$o}) {\n+\t\t\t# An uppercase option like -R cannot be\n+\t\t\t# expressed in the configuration, as the\n+\t\t\t# variable names are downcased.\n+\t\t\t$ckey = $longmap{$o};\n+\t\t\tnext if (! defined $ckey);\n+\t\t\t$ckey =~ s/-//g;\n+\t\t}\n+\t\tchomp(my $tmp = `$arg --get cvsimport.$ckey`);\n \t\tif ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {\n \t\t\tno strict 'refs';\n \t\t\tmy $opt_name = \"opt_\" . $key;\ndiff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh\nindex 432b82e..4c384ff 100755\n--- a/t/t9600-cvsimport.sh\n+++ b/t/t9600-cvsimport.sh\n@@ -89,7 +89,8 @@ EOF\n test_expect_success PERL 'update git module' '\n \n \t(cd module-git &&\n-\tgit cvsimport -a -R -z 0 module &&\n+\tgit config cvsimport.trackRevisions true &&\n+\tgit cvsimport -a -z 0 module &&\n \tgit merge origin\n \t) &&\n \ttest_cmp module-cvs/o_fortuna module-git/o_fortuna\n@@ -117,7 +118,8 @@ test_expect_success PERL 'cvsimport.module config works' '\n \n \t(cd module-git &&\n \t\tgit config cvsimport.module module &&\n-\t\tgit cvsimport -a -R -z0 &&\n+\t\tgit config cvsimport.trackRevisions true &&\n+\t\tgit cvsimport -a -z0 &&\n \t\tgit merge origin\n \t) &&\n \ttest_cmp module-cvs/tick module-git/tick\n@@ -137,6 +139,7 @@ test_expect_success PERL 'import from a CVS working tree' '\n \n \t$CVS co -d import-from-wt module &&\n \t(cd import-from-wt &&\n+\t\tgit config cvsimport.trackRevisions false &&\n \t\tgit cvsimport -a -z0 &&\n \t\techo 1 >expect &&\n \t\tgit log -1 --pretty=format:%s%n >actual &&\n-- \n1.7.3.4.865.ga2bc4\n"}]}