{"thread":{"id":"34081","subject":"[PATCH v3 00/28] Follow perlcritic's recommandations","startedAt":"2013-06-09T22:22:25Z","lastAt":"2013-06-11T22:24:43Z","messageCount":48,"participants":["Célestin Matte","Eric Sunshine","Matthieu Moy","Junio C Hamano","Benoît Person"],"isPatch":true,"patchVersion":3,"patchTotal":28},"messages":[{"id":"220173","messageId":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":null,"subject":"[PATCH v3 00/28] Follow perlcritic's recommandations","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:25Z","receivedAt":"2013-06-09T22:22:25Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Changes with v2:\n- Remove patch [02/22] about using the Readonly module\n- Split commit [07/22] into 5 different ones\n- Split commit [14/22] into 2 different ones\n- Patch [17/22] was *not* split: tell me if it is necessary\n- Remove wrong change in patch [22/22]\n\nPatch about fixing a bug in a regexp (with has been renames \"Make a regexp\nclearer\"), which had been sent as a separate patch, is reintegrated into this\nseries of patches.\n\nChanges with v1:\n- split first commit into 6 different commits\n- remove commit [17/18] about moving open() call\n- took every other comment into account\n\nCélestin Matte (28):\n  git-remote-mediawiki: Make a regexp clearer\n  git-remote-mediawiki: Move \"use warnings;\" before any instruction\n  git-remote-mediawiki: Replace :utf8 by :encoding(UTF-8)\n  git-remote-mediawiki: Always end a subroutine with a return\n  git-remote-mediawiki: Move a variable declaration at the top of the\n    code\n  git-remote-mediawiki: Change syntax of map calls\n  git-remote-mediawiki: Rewrite unclear line of instructions\n  git-remote-mediawiki: Remove useless regexp modifier (m)\n  git-remote-mediawiki: Change the behaviour of a split\n  git-remote-mediawiki: Change separator of some regexps\n  git-remote-mediawiki: Change style in a regexp\n  git-remote-mediawiki: Change style in a regexp\n  git-remote-mediawiki: Add newline in the end of die() error messages\n  git-remote-mediawiki: Change the name of a variable\n  git-remote-mediawiki: Turn double-negated expressions into simple\n    expressions\n  git-remote-mediawiki: Remove unused variable $entry\n  git-remote-mediawiki: Rename a variable ($last) which has the name of\n    a keyword\n  git-remote-mediawiki: Assign a variable as undef and make proper\n    indentation\n  git-remote-mediawiki: Check return value of open\n  git-remote-mediawiki: remove import of unused open2\n  git-remote-mediawiki: Put long code into a subroutine\n  git-remote-mediawiki: Modify strings for a better coding-style\n  git-remote-mediawiki: Brace file handles for print for more clarity\n  git-remote-mediawiki: Replace \"unless\" statements with negated \"if\"\n    statements\n  git-remote-mediawiki: Don't use quotes for empty strings\n  git-remote-mediawiki: Put non-trivial numeric values in constants.\n  git-remote-mediawiki: Fix a typo (\"mediwiki\" instead of \"mediawiki\")\n  git-remote-mediawiki: Clearly rewrite double dereference\n\n contrib/mw-to-git/git-remote-mediawiki.perl |  534 +++++++++++++++------------\n 1 file changed, 288 insertions(+), 246 deletions(-)\n\n-- \n1.7.9.5\n"},{"id":"220175","messageId":"1370816573-3808-2-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 01/28] git-remote-mediawiki: Make a regexp clearer","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:26Z","receivedAt":"2013-06-09T22:22:26Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Perl's split function takes a regex pattern argument. You can also\nfeed it an expression, which is then compiled into a regex at runtime.\nIt therefore works to pass your pattern via single quotes, but it is\nmuch less obvious to a reader that the argument is meant to be a\nregex, not a static string. Using the traditional slash-delimiters\nmakes this easier to read.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 410eae9..a7bb397 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -1170,7 +1170,7 @@ sub mw_push_revision {\n \t\t# history (linearized with --first-parent)\n \t\tprint STDERR \"Warning: no common ancestor, pushing complete history\\n\";\n \t\tmy $history = run_git(\"rev-list --first-parent --children $local\");\n-\t\tmy @history = split('\\n', $history);\n+\t\tmy @history = split(/\\n/, $history);\n \t\t@history = @history[1..$#history];\n \t\tforeach my $line (reverse @history) {\n \t\t\tmy @commit_info_split = split(/ |\\n/, $line);\n-- \n1.7.9.5\n"},{"id":"220174","messageId":"1370816573-3808-3-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 02/28] git-remote-mediawiki: Move \"use warnings;\" before any instruction","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:27Z","receivedAt":"2013-06-09T22:22:27Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex a7bb397..863ecc9 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -15,6 +15,7 @@ use strict;\n use MediaWiki::API;\n use Git;\n use DateTime::Format::ISO8601;\n+use warnings;\n \n # By default, use UTF-8 to communicate with Git and the user\n binmode STDERR, \":utf8\";\n@@ -23,8 +24,6 @@ binmode STDOUT, \":utf8\";\n use URI::Escape;\n use IPC::Open2;\n \n-use warnings;\n-\n # Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n use constant SLASH_REPLACEMENT => \"%2F\";\n \n-- \n1.7.9.5\n"},{"id":"220201","messageId":"1370816573-3808-4-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 03/28] git-remote-mediawiki: Replace :utf8 by :encoding(UTF-8)","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:28Z","receivedAt":"2013-06-09T22:22:28Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Follow perlcritic's InputOutput::RequireEncodingWithUTF8Layer policy\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 863ecc9..5e198e0 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -18,8 +18,8 @@ use DateTime::Format::ISO8601;\n use warnings;\n \n # By default, use UTF-8 to communicate with Git and the user\n-binmode STDERR, \":utf8\";\n-binmode STDOUT, \":utf8\";\n+binmode STDERR, \":encoding(UTF-8)\";\n+binmode STDOUT, \":encoding(UTF-8)\";\n \n use URI::Escape;\n use IPC::Open2;\n@@ -587,7 +587,7 @@ sub literal_data_raw {\n \tutf8::downgrade($content);\n \tbinmode STDOUT, \":raw\";\n \tprint STDOUT \"data \", bytes::length($content), \"\\n\", $content;\n-\tbinmode STDOUT, \":utf8\";\n+\tbinmode STDOUT, \":encoding(UTF-8)\";\n }\n \n sub mw_capabilities {\n-- \n1.7.9.5\n"},{"id":"220178","messageId":"1370816573-3808-5-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 04/28] git-remote-mediawiki: Always end a subroutine with a return","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:29Z","receivedAt":"2013-06-09T22:22:29Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Follow Subroutines::RequireFinalReturn\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   18 ++++++++++++++++++\n 1 file changed, 18 insertions(+)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 5e198e0..f19b276 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -197,12 +197,14 @@ sub mw_connect_maybe {\n \t\t\texit 1;\n \t\t}\n \t}\n+\treturn;\n }\n \n ## Functions for listing pages on the remote wiki\n sub get_mw_tracked_pages {\n \tmy $pages = shift;\n \tget_mw_page_list(\\@tracked_pages, $pages);\n+\treturn;\n }\n \n sub get_mw_page_list {\n@@ -218,6 +220,7 @@ sub get_mw_page_list {\n \t\tget_mw_first_pages(\\@slice, $pages);\n \t\t@some_pages = @some_pages[51..$#some_pages];\n \t}\n+\treturn;\n }\n \n sub get_mw_tracked_categories {\n@@ -240,6 +243,7 @@ sub get_mw_tracked_categories {\n \t\t\t$pages->{$page->{title}} = $page;\n \t\t}\n \t}\n+\treturn;\n }\n \n sub get_mw_all_pages {\n@@ -259,6 +263,7 @@ sub get_mw_all_pages {\n \tforeach my $page (@{$mw_pages}) {\n \t\t$pages->{$page->{title}} = $page;\n \t}\n+\treturn;\n }\n \n # queries the wiki for a set of pages. Meant to be used within a loop\n@@ -289,6 +294,7 @@ sub get_mw_first_pages {\n \t\t\t$pages->{$page->{title}} = $page;\n \t\t}\n \t}\n+\treturn;\n }\n \n # Get the list of pages to be fetched according to configuration.\n@@ -357,6 +363,7 @@ sub get_all_mediafiles {\n \tforeach my $page (@{$mw_pages}) {\n \t\t$pages->{$page->{title}} = $page;\n \t}\n+\treturn;\n }\n \n sub get_linked_mediafiles {\n@@ -403,6 +410,7 @@ sub get_linked_mediafiles {\n \n \t\t@titles = @titles[($batch+1)..$#titles];\n \t}\n+\treturn;\n }\n \n sub get_mw_mediafile_for_page_revision {\n@@ -578,6 +586,7 @@ sub mediawiki_smudge_filename {\n sub literal_data {\n \tmy ($content) = @_;\n \tprint STDOUT \"data \", bytes::length($content), \"\\n\", $content;\n+\treturn;\n }\n \n sub literal_data_raw {\n@@ -588,6 +597,7 @@ sub literal_data_raw {\n \tbinmode STDOUT, \":raw\";\n \tprint STDOUT \"data \", bytes::length($content), \"\\n\", $content;\n \tbinmode STDOUT, \":encoding(UTF-8)\";\n+\treturn;\n }\n \n sub mw_capabilities {\n@@ -599,6 +609,7 @@ sub mw_capabilities {\n \tprint STDOUT \"list\\n\";\n \tprint STDOUT \"push\\n\";\n \tprint STDOUT \"\\n\";\n+\treturn;\n }\n \n sub mw_list {\n@@ -607,11 +618,13 @@ sub mw_list {\n \tprint STDOUT \"? refs/heads/master\\n\";\n \tprint STDOUT \"\\@refs/heads/master HEAD\\n\";\n \tprint STDOUT \"\\n\";\n+\treturn;\n }\n \n sub mw_option {\n \tprint STDERR \"remote-helper command 'option $_[0]' not yet implemented\\n\";\n \tprint STDOUT \"unsupported\\n\";\n+\treturn;\n }\n \n sub fetch_mw_revisions_for_page {\n@@ -733,6 +746,7 @@ sub import_file_revision {\n \tprint STDOUT \"N inline :$n\\n\";\n \tliteral_data(\"mediawiki_revision: \" . $commit{mw_revision});\n \tprint STDOUT \"\\n\\n\";\n+\treturn;\n }\n \n # parse a sequence of\n@@ -753,6 +767,7 @@ sub get_more_refs {\n \t\t\tdie(\"Invalid command in a '$cmd' batch: \". $_);\n \t\t}\n \t}\n+\treturn;\n }\n \n sub mw_import {\n@@ -762,6 +777,7 @@ sub mw_import {\n \t\tmw_import_ref($ref);\n \t}\n \tprint STDOUT \"done\\n\";\n+\treturn;\n }\n \n sub mw_import_ref {\n@@ -805,6 +821,7 @@ sub mw_import_ref {\n \t\t# thrown saying that HEAD is referring to unknown object 0000000000000000000\n \t\t# and the clone fails.\n \t}\n+\treturn;\n }\n \n sub mw_import_ref_by_pages {\n@@ -1111,6 +1128,7 @@ sub mw_push {\n \t\tprint STDERR \"  git pull --rebase\\n\";\n \t\tprint STDERR \"\\n\";\n \t}\n+\treturn;\n }\n \n sub mw_push_revision {\n-- \n1.7.9.5\n"},{"id":"220200","messageId":"1370816573-3808-6-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 05/28] git-remote-mediawiki: Move a variable declaration at the top of the code","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:30Z","receivedAt":"2013-06-09T22:22:30Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"%basetimestamps declaration was lost in the middle of subroutines\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex f19b276..fe1343d 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -95,6 +95,9 @@ unless ($fetch_strategy) {\n \t$fetch_strategy = \"by_page\";\n }\n \n+# Remember the timestamp corresponding to a revision id.\n+my %basetimestamps;\n+\n # Dumb push: don't update notes and mediawiki ref to reflect the last push.\n #\n # Configurable with mediawiki.dumbPush, or per-remote with\n@@ -480,9 +483,6 @@ sub get_last_local_revision {\n \treturn $lastrevision_number;\n }\n \n-# Remember the timestamp corresponding to a revision id.\n-my %basetimestamps;\n-\n # Get the last remote revision without taking in account which pages are\n # tracked or not. This function makes a single request to the wiki thus\n # avoid a loop onto all tracked pages. This is useful for the fetch-by-rev\n-- \n1.7.9.5\n"},{"id":"220193","messageId":"1370816573-3808-7-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 06/28] git-remote-mediawiki: Change syntax of map calls","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:31Z","receivedAt":"2013-06-09T22:22:31Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Put first parameter of map inside a block, for better readability.\nFollow BuiltinFunctions::RequireBlockMap\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   14 ++++++++------\n 1 file changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex fe1343d..431e063 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -371,7 +371,7 @@ sub get_all_mediafiles {\n \n sub get_linked_mediafiles {\n \tmy $pages = shift;\n-\tmy @titles = map $_->{title}, values(%{$pages});\n+\tmy @titles = map { $_->{title} } values(%{$pages});\n \n \t# The query is split in small batches because of the MW API limit of\n \t# the number of links to be returned (500 links max).\n@@ -399,11 +399,13 @@ sub get_linked_mediafiles {\n \t\twhile (my ($id, $page) = each(%{$result->{query}->{pages}})) {\n \t\t\tmy @media_titles;\n \t\t\tif (defined($page->{links})) {\n-\t\t\t\tmy @link_titles = map $_->{title}, @{$page->{links}};\n+\t\t\t\tmy @link_titles\n+\t\t\t\t    = map { $_->{title} } @{$page->{links}};\n \t\t\t\tpush(@media_titles, @link_titles);\n \t\t\t}\n \t\t\tif (defined($page->{images})) {\n-\t\t\t\tmy @image_titles = map $_->{title}, @{$page->{images}};\n+\t\t\t\tmy @image_titles\n+\t\t\t\t    = map { $_->{title} } @{$page->{images}};\n \t\t\t\tpush(@media_titles, @image_titles);\n \t\t\t}\n \t\t\tif (@media_titles) {\n@@ -833,7 +835,7 @@ sub mw_import_ref_by_pages {\n \tmy ($n, @revisions) = fetch_mw_revisions(\\@pages, $fetch_from);\n \n \t@revisions = sort {$a->{revid} <=> $b->{revid}} @revisions;\n-\tmy @revision_ids = map $_->{revid}, @revisions;\n+\tmy @revision_ids = map { $_->{revid} } @revisions;\n \n \treturn mw_import_revids($fetch_from, \\@revision_ids, \\%pages_hash);\n }\n@@ -1246,8 +1248,8 @@ sub get_allowed_file_extensions {\n \t\tsiprop => 'fileextensions'\n \t\t};\n \tmy $result = $mediawiki->api($query);\n-\tmy @file_extensions= map $_->{ext},@{$result->{query}->{fileextensions}};\n-\tmy %hashFile = map {$_ => 1}@file_extensions;\n+\tmy @file_extensions = map { $_->{ext}} @{$result->{query}->{fileextensions}};\n+\tmy %hashFile = map { $_ => 1 } @file_extensions;\n \n \treturn %hashFile;\n }\n-- \n1.7.9.5\n"},{"id":"220176","messageId":"1370816573-3808-8-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:32Z","receivedAt":"2013-06-09T22:22:32Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Subroutines' parameters should be affected to variable before doing anything\nelse\nBesides, existing instruction affected a variable inside a \"if\", which break\nGit's coding style\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 431e063..2db6467 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -1333,7 +1333,8 @@ sub get_mw_namespace_id {\n }\n \n sub get_mw_namespace_id_for_page {\n-\tif (my ($namespace) = $_[0] =~ /^([^:]*):/) {\n+\tmy $namespace = shift;\n+\tif ($namespace =~ /^([^:]*):/) {\n \t\treturn get_mw_namespace_id($namespace);\n \t} else {\n \t\treturn;\n-- \n1.7.9.5\n"},{"id":"220198","messageId":"1370816573-3808-9-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 08/28] git-remote-mediawiki: Remove useless regexp modifier (m)","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:33Z","receivedAt":"2013-06-09T22:22:33Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"m// and // is used randomly. It is better to use the m modifier only when\nneeded, e.g., when the regexp uses another separator than //.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 2db6467..7ce640f 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -761,7 +761,7 @@ sub get_more_refs {\n \tmy @refs;\n \twhile (1) {\n \t\tmy $line = <STDIN>;\n-\t\tif ($line =~ m/^$cmd (.*)$/) {\n+\t\tif ($line =~ /^$cmd (.*)$/) {\n \t\t\tpush(@refs, $1);\n \t\t} elsif ($line eq \"\\n\") {\n \t\t\treturn @refs;\n@@ -1167,11 +1167,11 @@ sub mw_push_revision {\n \t\tmy @local_ancestry = split(/\\n/, run_git(\"rev-list --boundary --parents $local ^$parsed_sha1\"));\n \t\tmy %local_ancestry;\n \t\tforeach my $line (@local_ancestry) {\n-\t\t\tif (my ($child, $parents) = $line =~ m/^-?([a-f0-9]+) ([a-f0-9 ]+)/) {\n+\t\t\tif (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {\n \t\t\t\tforeach my $parent (split(' ', $parents)) {\n \t\t\t\t\t$local_ancestry{$parent} = $child;\n \t\t\t\t}\n-\t\t\t} elsif (!$line =~ m/^([a-f0-9]+)/) {\n+\t\t\t} elsif (!$line =~ /^([a-f0-9]+)/) {\n \t\t\t\tdie \"Unexpected output from git rev-list: $line\";\n \t\t\t}\n \t\t}\n-- \n1.7.9.5\n"},{"id":"220197","messageId":"1370816573-3808-10-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 09/28] git-remote-mediawiki: Change the behaviour of a split","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:34Z","receivedAt":"2013-06-09T22:22:34Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"A \"split ' '\" is turned into a \"split / /\", which changes its behaviour: the\nold method matched a run of whtespaces (/\\s*/), while the new one will match a\nsingle whitespace, which is what we want here. Indeed, in other contexts,\nchanging split(' ') to split(/ /) could potentially be a regression, however,\nhere, when parsing the output of \"rev-list --parents\", whose output SHA-1's are\neach separated by a single space, splitting on a single space is perfectly\ncorrect.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 7ce640f..7537305 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -1168,7 +1168,7 @@ sub mw_push_revision {\n \t\tmy %local_ancestry;\n \t\tforeach my $line (@local_ancestry) {\n \t\t\tif (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {\n-\t\t\t\tforeach my $parent (split(' ', $parents)) {\n+\t\t\t\tforeach my $parent (split(/ /, $parents)) {\n \t\t\t\t\t$local_ancestry{$parent} = $child;\n \t\t\t\t}\n \t\t\t} elsif (!$line =~ /^([a-f0-9]+)/) {\n-- \n1.7.9.5\n"},{"id":"220180","messageId":"1370816573-3808-11-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 10/28] git-remote-mediawiki: Change separator of some regexps","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:35Z","receivedAt":"2013-06-09T22:22:35Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Use {}{} instead of /// when slashes are used inside the regexp so as not to\nescape it.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 7537305..b01d402 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -120,7 +120,7 @@ chomp($dumb_push);\n $dumb_push = ($dumb_push eq \"true\");\n \n my $wiki_name = $url;\n-$wiki_name =~ s/[^\\/]*:\\/\\///;\n+$wiki_name =~ s{[^/]*://}{};\n # If URL is like http://user:password@example.com/, we clearly don't\n # want the password in $wiki_name. While we're there, also remove user\n # and '@' sign, to avoid author like MWUser@HTTPUser@host.com\n@@ -564,7 +564,7 @@ sub mediawiki_smudge {\n \n sub mediawiki_clean_filename {\n \tmy $filename = shift;\n-\t$filename =~ s/@{[SLASH_REPLACEMENT]}/\\//g;\n+\t$filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;\n \t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n \t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n \t# but with _ added to prevent MediaWiki from thinking this is\n@@ -578,7 +578,7 @@ sub mediawiki_clean_filename {\n \n sub mediawiki_smudge_filename {\n \tmy $filename = shift;\n-\t$filename =~ s/\\//@{[SLASH_REPLACEMENT]}/g;\n+\t$filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;\n \t$filename =~ s/ /_/g;\n \t# Decode forbidden characters encoded in mediawiki_clean_filename\n \t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n-- \n1.7.9.5\n"},{"id":"220199","messageId":"1370816573-3808-12-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 11/28] git-remote-mediawiki: Change style in a regexp","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:36Z","receivedAt":"2013-06-09T22:22:36Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"In this regexp, ' |\\n' is used, whereas its equivalent '[ \\n]', which is\nclearer, is used elsewhere. Make the style coherent.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex b01d402..267c164 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -1192,7 +1192,7 @@ sub mw_push_revision {\n \t\tmy @history = split(/\\n/, $history);\n \t\t@history = @history[1..$#history];\n \t\tforeach my $line (reverse @history) {\n-\t\t\tmy @commit_info_split = split(/ |\\n/, $line);\n+\t\t\tmy @commit_info_split = split(/[ \\n]/, $line);\n \t\t\tpush(@commit_pairs, \\@commit_info_split);\n \t\t}\n \t}\n-- \n1.7.9.5\n"},{"id":"220196","messageId":"1370816573-3808-13-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 12/28] git-remote-mediawiki: Change style in a regexp","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:37Z","receivedAt":"2013-06-09T22:22:37Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Change '[\\n]' to '\\n': brackets are useless here.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 267c164..86229a1 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -1271,7 +1271,7 @@ sub get_mw_namespace_id {\n \t\t# Look at configuration file, if the record for that namespace is\n \t\t# already cached. Namespaces are stored in form:\n \t\t# \"Name_of_namespace:Id_namespace\", ex.: \"File:6\".\n-\t\tmy @temp = split(/[\\n]/, run_git(\"config --get-all remote.\"\n+\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.\"\n \t\t\t\t\t\t. $remotename .\".namespaceCache\"));\n \t\tchomp(@temp);\n \t\tforeach my $ns (@temp) {\n-- \n1.7.9.5\n"},{"id":"220189","messageId":"1370816573-3808-14-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 13/28] git-remote-mediawiki: Add newline in the end of die() error messages","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:38Z","receivedAt":"2013-06-09T22:22:38Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 86229a1..44c5e0e 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -135,16 +135,16 @@ while (<STDIN>) {\n \tif (defined($cmd[0])) {\n \t\t# Line not blank\n \t\tif ($cmd[0] eq \"capabilities\") {\n-\t\t\tdie(\"Too many arguments for capabilities\") unless (!defined($cmd[1]));\n+\t\t\tdie(\"Too many arguments for capabilities\\n\") unless (!defined($cmd[1]));\n \t\t\tmw_capabilities();\n \t\t} elsif ($cmd[0] eq \"list\") {\n-\t\t\tdie(\"Too many arguments for list\") unless (!defined($cmd[2]));\n+\t\t\tdie(\"Too many arguments for list\\n\") unless (!defined($cmd[2]));\n \t\t\tmw_list($cmd[1]);\n \t\t} elsif ($cmd[0] eq \"import\") {\n-\t\t\tdie(\"Invalid arguments for import\") unless ($cmd[1] ne \"\" && !defined($cmd[2]));\n+\t\t\tdie(\"Invalid arguments for import\\n\") unless ($cmd[1] ne \"\" && !defined($cmd[2]));\n \t\t\tmw_import($cmd[1]);\n \t\t} elsif ($cmd[0] eq \"option\") {\n-\t\t\tdie(\"Too many arguments for option\") unless ($cmd[1] ne \"\" && $cmd[2] ne \"\" && !defined($cmd[3]));\n+\t\t\tdie(\"Too many arguments for option\\n\") unless ($cmd[1] ne \"\" && $cmd[2] ne \"\" && !defined($cmd[3]));\n \t\t\tmw_option($cmd[1],$cmd[2]);\n \t\t} elsif ($cmd[0] eq \"push\") {\n \t\t\tmw_push($cmd[1]);\n@@ -241,7 +241,7 @@ sub get_mw_tracked_categories {\n \t\t\tcmtitle => $category,\n \t\t\tcmlimit => 'max' } )\n \t\t\t|| die $mediawiki->{error}->{code} . ': '\n-\t\t\t\t. $mediawiki->{error}->{details};\n+\t\t\t\t. $mediawiki->{error}->{details} . \"\\n\";\n \t\tforeach my $page (@{$mw_pages}) {\n \t\t\t$pages->{$page->{title}} = $page;\n \t\t}\n@@ -766,7 +766,7 @@ sub get_more_refs {\n \t\t} elsif ($line eq \"\\n\") {\n \t\t\treturn @refs;\n \t\t} else {\n-\t\t\tdie(\"Invalid command in a '$cmd' batch: \". $_);\n+\t\t\tdie(\"Invalid command in a '$cmd' batch: $_\\n\");\n \t\t}\n \t}\n \treturn;\n@@ -878,7 +878,7 @@ sub mw_import_revids {\n \t\tmy $result = $mediawiki->api($query);\n \n \t\tif (!$result) {\n-\t\t\tdie \"Failed to retrieve modified page for revision $pagerevid\";\n+\t\t\tdie \"Failed to retrieve modified page for revision $pagerevid\\n\";\n \t\t}\n \n \t\tif (defined($result->{query}->{badrevids}->{$pagerevid})) {\n@@ -887,7 +887,7 @@ sub mw_import_revids {\n \t\t}\n \n \t\tif (!defined($result->{query}->{pages})) {\n-\t\t\tdie \"Invalid revision $pagerevid.\";\n+\t\t\tdie \"Invalid revision $pagerevid.\\n\";\n \t\t}\n \n \t\tmy @result_pages = values(%{$result->{query}->{pages}});\n@@ -998,7 +998,7 @@ sub mw_upload_file {\n \t\t\t}, {\n \t\t\t\tskip_encoding => 1\n \t\t\t} ) || die $mediawiki->{error}->{code} . ':'\n-\t\t\t\t . $mediawiki->{error}->{details};\n+\t\t\t\t . $mediawiki->{error}->{details} . \"\\n\";\n \t\t\tmy $last_file_page = $mediawiki->get_page({title => $path});\n \t\t\t$newrevid = $last_file_page->{revid};\n \t\t\tprint STDERR \"Pushed file: $new_sha1 - $complete_file_name.\\n\";\n@@ -1078,7 +1078,7 @@ sub mw_push_file {\n \t\t\t\t# Other errors. Shouldn't happen => just die()\n \t\t\t\tdie 'Fatal: Error ' .\n \t\t\t\t    $mediawiki->{error}->{code} .\n-\t\t\t\t    ' from mediwiki: ' . $mediawiki->{error}->{details};\n+\t\t\t\t    ' from mediwiki: ' . $mediawiki->{error}->{details} . \"\\n\";\n \t\t\t}\n \t\t}\n \t\t$newrevid = $result->{edit}->{newrevid};\n@@ -1100,7 +1100,7 @@ sub mw_push {\n \tmy $pushed;\n \tfor my $refspec (@refsspecs) {\n \t\tmy ($force, $local, $remote) = $refspec =~ /^(\\+)?([^:]*):([^:]*)$/\n-\t\t    or die(\"Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\");\n+\t\t    or die(\"Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\\n\");\n \t\tif ($force) {\n \t\t\tprint STDERR \"Warning: forced push not allowed on a MediaWiki.\\n\";\n \t\t}\n@@ -1172,7 +1172,7 @@ sub mw_push_revision {\n \t\t\t\t\t$local_ancestry{$parent} = $child;\n \t\t\t\t}\n \t\t\t} elsif (!$line =~ /^([a-f0-9]+)/) {\n-\t\t\t\tdie \"Unexpected output from git rev-list: $line\";\n+\t\t\t\tdie \"Unexpected output from git rev-list: $line\\n\";\n \t\t\t}\n \t\t}\n \t\twhile ($parsed_sha1 ne $HEAD_sha1) {\n@@ -1226,7 +1226,7 @@ sub mw_push_revision {\n \t\t\t\treturn error_non_fast_forward($remote);\n \t\t\t}\n \t\t\tif ($status ne \"ok\") {\n-\t\t\t\tdie(\"Unknown error from mw_push_file()\");\n+\t\t\t\tdie(\"Unknown error from mw_push_file()\\n\");\n \t\t\t}\n \t\t}\n \t\tunless ($dumb_push) {\n-- \n1.7.9.5\n"},{"id":"220191","messageId":"1370816573-3808-15-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 14/28] git-remote-mediawiki: Change the name of a variable","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:39Z","receivedAt":"2013-06-09T22:22:39Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Local variable $url has the same name as a global variable. Changing the name\nof the local variable prevents future possible misunderstanding.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 44c5e0e..63d1530 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -454,14 +454,14 @@ sub get_mw_mediafile_for_page_revision {\n }\n \n sub download_mw_mediafile {\n-\tmy $url = shift;\n+\tmy $download_url = shift;\n \n-\tmy $response = $mediawiki->{ua}->get($url);\n+\tmy $response = $mediawiki->{ua}->get($download_url);\n \tif ($response->code == 200) {\n \t\treturn $response->decoded_content;\n \t} else {\n \t\tprint STDERR \"Error downloading mediafile from :\\n\";\n-\t\tprint STDERR \"URL: $url\\n\";\n+\t\tprint STDERR \"URL: $download_url\\n\";\n \t\tprint STDERR \"Server response: \" . $response->code . \" \" . $response->message . \"\\n\";\n \t\texit 1;\n \t}\n-- \n1.7.9.5\n"},{"id":"220184","messageId":"1370816573-3808-16-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 15/28] git-remote-mediawiki: Turn double-negated expressions into simple expressions","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:40Z","receivedAt":"2013-06-09T22:22:40Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 63d1530..6024791 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -135,16 +135,16 @@ while (<STDIN>) {\n \tif (defined($cmd[0])) {\n \t\t# Line not blank\n \t\tif ($cmd[0] eq \"capabilities\") {\n-\t\t\tdie(\"Too many arguments for capabilities\\n\") unless (!defined($cmd[1]));\n+\t\t\tdie(\"Too many arguments for capabilities\\n\") if (defined($cmd[1]));\n \t\t\tmw_capabilities();\n \t\t} elsif ($cmd[0] eq \"list\") {\n-\t\t\tdie(\"Too many arguments for list\\n\") unless (!defined($cmd[2]));\n+\t\t\tdie(\"Too many arguments for list\\n\") if (defined($cmd[2]));\n \t\t\tmw_list($cmd[1]);\n \t\t} elsif ($cmd[0] eq \"import\") {\n-\t\t\tdie(\"Invalid arguments for import\\n\") unless ($cmd[1] ne \"\" && !defined($cmd[2]));\n+\t\t\tdie(\"Invalid arguments for import\\n\") if ($cmd[1] eq \"\" || defined($cmd[2]));\n \t\t\tmw_import($cmd[1]);\n \t\t} elsif ($cmd[0] eq \"option\") {\n-\t\t\tdie(\"Too many arguments for option\\n\") unless ($cmd[1] ne \"\" && $cmd[2] ne \"\" && !defined($cmd[3]));\n+\t\t\tdie(\"Too many arguments for option\\n\") if ($cmd[1] eq \"\" || $cmd[2] eq \"\" || defined($cmd[3]));\n \t\t\tmw_option($cmd[1],$cmd[2]);\n \t\t} elsif ($cmd[0] eq \"push\") {\n \t\t\tmw_push($cmd[1]);\n-- \n1.7.9.5\n"},{"id":"220177","messageId":"1370816573-3808-17-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 16/28] git-remote-mediawiki: Remove unused variable $entry","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:41Z","receivedAt":"2013-06-09T22:22:41Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 6024791..ef9e60a 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -127,7 +127,6 @@ $wiki_name =~ s{[^/]*://}{};\n $wiki_name =~ s/^.*@//;\n \n # Commands parser\n-my $entry;\n my @cmd;\n while (<STDIN>) {\n \tchomp;\n-- \n1.7.9.5\n"},{"id":"220195","messageId":"1370816573-3808-18-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 17/28] git-remote-mediawiki: Rename a variable ($last) which has the name of a keyword","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:42Z","receivedAt":"2013-06-09T22:22:42Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex ef9e60a..0610daa 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -214,11 +214,11 @@ sub get_mw_page_list {\n \tmy $pages = shift;\n \tmy @some_pages = @$page_list;\n \twhile (@some_pages) {\n-\t\tmy $last = 50;\n-\t\tif ($#some_pages < $last) {\n-\t\t\t$last = $#some_pages;\n+\t\tmy $last_page = 50;\n+\t\tif ($#some_pages < $last_page) {\n+\t\t\t$last_page = $#some_pages;\n \t\t}\n-\t\tmy @slice = @some_pages[0..$last];\n+\t\tmy @slice = @some_pages[0..$last_page];\n \t\tget_mw_first_pages(\\@slice, $pages);\n \t\t@some_pages = @some_pages[51..$#some_pages];\n \t}\n-- \n1.7.9.5\n"},{"id":"220179","messageId":"1370816573-3808-19-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 18/28] git-remote-mediawiki: Assign a variable as undef and make proper indentation","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:43Z","receivedAt":"2013-06-09T22:22:43Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Explicitly assign local variable $/ as undef and make a proper\none-instruction-by-line indentation\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 0610daa..50b3452 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -338,7 +338,10 @@ sub run_git {\n \tmy $args = shift;\n \tmy $encoding = (shift || \"encoding(UTF-8)\");\n \topen(my $git, \"-|:$encoding\", \"git \" . $args);\n-\tmy $res = do { local $/; <$git> };\n+\tmy $res = do { \n+\t\tlocal $/ = undef;\n+\t\t<$git>\n+\t};\n \tclose($git);\n \n \treturn $res;\n-- \n1.7.9.5\n"},{"id":"220192","messageId":"1370816573-3808-20-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 19/28] git-remote-mediawiki: Check return value of open","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:44Z","receivedAt":"2013-06-09T22:22:44Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 50b3452..fb6bca3 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -337,7 +337,8 @@ sub get_mw_pages {\n sub run_git {\n \tmy $args = shift;\n \tmy $encoding = (shift || \"encoding(UTF-8)\");\n-\topen(my $git, \"-|:$encoding\", \"git \" . $args);\n+\topen(my $git, \"-|:$encoding\", \"git \" . $args)\n+\t    or die \"Unable to open: $!\\n\";\n \tmy $res = do { \n \t\tlocal $/ = undef;\n \t\t<$git>\n-- \n1.7.9.5\n"},{"id":"220181","messageId":"1370816573-3808-21-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 20/28] git-remote-mediawiki: remove import of unused open2","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:45Z","receivedAt":"2013-06-09T22:22:45Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex fb6bca3..c404e7b 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -22,7 +22,6 @@ binmode STDERR, \":encoding(UTF-8)\";\n binmode STDOUT, \":encoding(UTF-8)\";\n \n use URI::Escape;\n-use IPC::Open2;\n \n # Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n use constant SLASH_REPLACEMENT => \"%2F\";\n-- \n1.7.9.5\n"},{"id":"220194","messageId":"1370816573-3808-22-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 21/28] git-remote-mediawiki: Put long code into a subroutine","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:46Z","receivedAt":"2013-06-09T22:22:46Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   50 +++++++++++++++++----------\n 1 file changed, 31 insertions(+), 19 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex c404e7b..a66cef4 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -126,28 +126,13 @@ $wiki_name =~ s{[^/]*://}{};\n $wiki_name =~ s/^.*@//;\n \n # Commands parser\n-my @cmd;\n+my @cmds;\n while (<STDIN>) {\n \tchomp;\n-\t@cmd = split(/ /);\n-\tif (defined($cmd[0])) {\n+\t@cmds = split(/ /);\n+\tif (defined($cmds[0])) {\n \t\t# Line not blank\n-\t\tif ($cmd[0] eq \"capabilities\") {\n-\t\t\tdie(\"Too many arguments for capabilities\\n\") if (defined($cmd[1]));\n-\t\t\tmw_capabilities();\n-\t\t} elsif ($cmd[0] eq \"list\") {\n-\t\t\tdie(\"Too many arguments for list\\n\") if (defined($cmd[2]));\n-\t\t\tmw_list($cmd[1]);\n-\t\t} elsif ($cmd[0] eq \"import\") {\n-\t\t\tdie(\"Invalid arguments for import\\n\") if ($cmd[1] eq \"\" || defined($cmd[2]));\n-\t\t\tmw_import($cmd[1]);\n-\t\t} elsif ($cmd[0] eq \"option\") {\n-\t\t\tdie(\"Too many arguments for option\\n\") if ($cmd[1] eq \"\" || $cmd[2] eq \"\" || defined($cmd[3]));\n-\t\t\tmw_option($cmd[1],$cmd[2]);\n-\t\t} elsif ($cmd[0] eq \"push\") {\n-\t\t\tmw_push($cmd[1]);\n-\t\t} else {\n-\t\t\tprint STDERR \"Unknown command. Aborting...\\n\";\n+\t\tif (!parse_command(\\@cmds)) {\n \t\t\tlast;\n \t\t}\n \t} else {\n@@ -167,6 +152,33 @@ sub exit_error_usage {\n     die \"ERROR: git-remote-mediawiki module was not called with a correct number of parameters\\n\";\n }\n \n+sub parse_command {\n+\tmy $cmdref = shift;\n+\tmy @cmd = @{$cmdref};\n+\tif ($cmd[0] eq \"capabilities\") {\n+\t\tdie(\"Too many arguments for capabilities\\n\")\n+\t\t    if (defined($cmd[1]));\n+\t\tmw_capabilities();\n+\t} elsif ($cmd[0] eq \"list\") {\n+\t\tdie(\"Too many arguments for list\\n\") if (defined($cmd[2]));\n+\t\tmw_list($cmd[1]);\n+\t} elsif ($cmd[0] eq \"import\") {\n+\t\tdie(\"Invalid arguments for import\\n\")\n+\t\t    if ($cmd[1] eq \"\" || defined($cmd[2]));\n+\t\tmw_import($cmd[1]);\n+\t} elsif ($cmd[0] eq \"option\") {\n+\t\tdie(\"Too many arguments for option\\n\")\n+\t\t    if ($cmd[1] eq \"\" || $cmd[2] eq \"\" || defined($cmd[3]));\n+\t\tmw_option($cmd[1],$cmd[2]);\n+\t} elsif ($cmd[0] eq \"push\") {\n+\t\tmw_push($cmd[1]);\n+\t} else {\n+\t\tprint STDERR \"Unknown command. Aborting...\\n\";\n+\t\treturn 0;\n+\t}\n+\treturn 1;\n+}\n+\n # MediaWiki API instance, created lazily.\n my $mediawiki;\n \n-- \n1.7.9.5\n"},{"id":"220183","messageId":"1370816573-3808-23-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:47Z","receivedAt":"2013-06-09T22:22:47Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"- strings which don't need interpolation are single-quoted for more clarity and\nslight gain of performance\n- interpolation is preferred over concatenation in many cases, for more clarity\n- variables are always used with the ${} operator inside strings\n- strings including double-quotes are written with qq() so that the quotes do\nnot have to be escaped\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |  242 +++++++++++++--------------\n 1 file changed, 120 insertions(+), 122 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex a66cef4..efc376a 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -18,13 +18,13 @@ use DateTime::Format::ISO8601;\n use warnings;\n \n # By default, use UTF-8 to communicate with Git and the user\n-binmode STDERR, \":encoding(UTF-8)\";\n-binmode STDOUT, \":encoding(UTF-8)\";\n+binmode STDERR, ':encoding(UTF-8)';\n+binmode STDOUT, ':encoding(UTF-8)';\n \n use URI::Escape;\n \n # Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n-use constant SLASH_REPLACEMENT => \"%2F\";\n+use constant SLASH_REPLACEMENT => '%2F';\n \n # It's not always possible to delete pages (may require some\n # privileges). Deleted pages are replaced with this content.\n@@ -35,7 +35,7 @@ use constant DELETED_CONTENT => \"[[Category:Deleted]]\\n\";\n use constant EMPTY_CONTENT => \"<!-- empty page -->\\n\";\n \n # used to reflect file creation or deletion in diff.\n-use constant NULL_SHA1 => \"0000000000000000000000000000000000000000\";\n+use constant NULL_SHA1 => '0000000000000000000000000000000000000000';\n \n # Used on Git's side to reflect empty edit messages on the wiki\n use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';\n@@ -49,35 +49,35 @@ my $url = $ARGV[1];\n \n # Accept both space-separated and multiple keys in config file.\n # Spaces should be written as _ anyway because we'll use chomp.\n-my @tracked_pages = split(/[ \\n]/, run_git(\"config --get-all remote.\". $remotename .\".pages\"));\n+my @tracked_pages = split(/[ \\n]/, run_git(\"config --get-all remote.${remotename}.pages\"));\n chomp(@tracked_pages);\n \n # Just like @tracked_pages, but for MediaWiki categories.\n-my @tracked_categories = split(/[ \\n]/, run_git(\"config --get-all remote.\". $remotename .\".categories\"));\n+my @tracked_categories = split(/[ \\n]/, run_git(\"config --get-all remote.${remotename}.categories\"));\n chomp(@tracked_categories);\n \n # Import media files on pull\n-my $import_media = run_git(\"config --get --bool remote.\". $remotename .\".mediaimport\");\n+my $import_media = run_git(\"config --get --bool remote.${remotename}.mediaimport\");\n chomp($import_media);\n-$import_media = ($import_media eq \"true\");\n+$import_media = ($import_media eq 'true');\n \n # Export media files on push\n-my $export_media = run_git(\"config --get --bool remote.\". $remotename .\".mediaexport\");\n+my $export_media = run_git(\"config --get --bool remote.${remotename}.mediaexport\");\n chomp($export_media);\n-$export_media = !($export_media eq \"false\");\n+$export_media = !($export_media eq 'false');\n \n-my $wiki_login = run_git(\"config --get remote.\". $remotename .\".mwLogin\");\n+my $wiki_login = run_git(\"config --get remote.${remotename}.mwLogin\");\n # Note: mwPassword is discourraged. Use the credential system instead.\n-my $wiki_passwd = run_git(\"config --get remote.\". $remotename .\".mwPassword\");\n-my $wiki_domain = run_git(\"config --get remote.\". $remotename .\".mwDomain\");\n+my $wiki_passwd = run_git(\"config --get remote.${remotename}.mwPassword\");\n+my $wiki_domain = run_git(\"config --get remote.${remotename}.mwDomain\");\n chomp($wiki_login);\n chomp($wiki_passwd);\n chomp($wiki_domain);\n \n # Import only last revisions (both for clone and fetch)\n-my $shallow_import = run_git(\"config --get --bool remote.\". $remotename .\".shallow\");\n+my $shallow_import = run_git(\"config --get --bool remote.${remotename}.shallow\");\n chomp($shallow_import);\n-$shallow_import = ($shallow_import eq \"true\");\n+$shallow_import = ($shallow_import eq 'true');\n \n # Fetch (clone and pull) by revisions instead of by pages. This behavior\n # is more efficient when we have a wiki with lots of pages and we fetch\n@@ -85,13 +85,13 @@ $shallow_import = ($shallow_import eq \"true\");\n # Possible values:\n # - by_rev: perform one query per new revision on the remote wiki\n # - by_page: query each tracked page for new revision\n-my $fetch_strategy = run_git(\"config --get remote.$remotename.fetchStrategy\");\n+my $fetch_strategy = run_git(\"config --get remote.${remotename}.fetchStrategy\");\n unless ($fetch_strategy) {\n-\t$fetch_strategy = run_git(\"config --get mediawiki.fetchStrategy\");\n+\t$fetch_strategy = run_git('config --get mediawiki.fetchStrategy');\n }\n chomp($fetch_strategy);\n unless ($fetch_strategy) {\n-\t$fetch_strategy = \"by_page\";\n+\t$fetch_strategy = 'by_page';\n }\n \n # Remember the timestamp corresponding to a revision id.\n@@ -111,12 +111,12 @@ my %basetimestamps;\n # will get the history with information lost). If the import is\n # deterministic, this means everybody gets the same sha1 for each\n # MediaWiki revision.\n-my $dumb_push = run_git(\"config --get --bool remote.$remotename.dumbPush\");\n+my $dumb_push = run_git(\"config --get --bool remote.${remotename}.dumbPush\");\n unless ($dumb_push) {\n-\t$dumb_push = run_git(\"config --get --bool mediawiki.dumbPush\");\n+\t$dumb_push = run_git('config --get --bool mediawiki.dumbPush');\n }\n chomp($dumb_push);\n-$dumb_push = ($dumb_push eq \"true\");\n+$dumb_push = ($dumb_push eq 'true');\n \n my $wiki_name = $url;\n $wiki_name =~ s{[^/]*://}{};\n@@ -155,22 +155,22 @@ sub exit_error_usage {\n sub parse_command {\n \tmy $cmdref = shift;\n \tmy @cmd = @{$cmdref};\n-\tif ($cmd[0] eq \"capabilities\") {\n+\tif ($cmd[0] eq 'capabilities') {\n \t\tdie(\"Too many arguments for capabilities\\n\")\n \t\t    if (defined($cmd[1]));\n \t\tmw_capabilities();\n-\t} elsif ($cmd[0] eq \"list\") {\n+\t} elsif ($cmd[0] eq 'list') {\n \t\tdie(\"Too many arguments for list\\n\") if (defined($cmd[2]));\n \t\tmw_list($cmd[1]);\n-\t} elsif ($cmd[0] eq \"import\") {\n+\t} elsif ($cmd[0] eq 'import') {\n \t\tdie(\"Invalid arguments for import\\n\")\n \t\t    if ($cmd[1] eq \"\" || defined($cmd[2]));\n \t\tmw_import($cmd[1]);\n-\t} elsif ($cmd[0] eq \"option\") {\n+\t} elsif ($cmd[0] eq 'option') {\n \t\tdie(\"Too many arguments for option\\n\")\n \t\t    if ($cmd[1] eq \"\" || $cmd[2] eq \"\" || defined($cmd[3]));\n \t\tmw_option($cmd[1],$cmd[2]);\n-\t} elsif ($cmd[0] eq \"push\") {\n+\t} elsif ($cmd[0] eq 'push') {\n \t\tmw_push($cmd[1]);\n \t} else {\n \t\tprint STDERR \"Unknown command. Aborting...\\n\";\n@@ -187,7 +187,7 @@ sub mw_connect_maybe {\n \t\treturn;\n \t}\n \t$mediawiki = MediaWiki::API->new;\n-\t$mediawiki->{config}->{api_url} = \"$url/api.php\";\n+\t$mediawiki->{config}->{api_url} = \"${url}/api.php\";\n \tif ($wiki_login) {\n \t\tmy %credential = (\n \t\t\t'url' => $url,\n@@ -200,10 +200,10 @@ sub mw_connect_maybe {\n \t\t\t       lgdomain => $wiki_domain};\n \t\tif ($mediawiki->login($request)) {\n \t\t\tGit::credential \\%credential, 'approve';\n-\t\t\tprint STDERR \"Logged in mediawiki user \\\"$credential{username}\\\".\\n\";\n+\t\t\tprint STDERR qq(Logged in mediawiki user \"$credential{username}\".\\n);\n \t\t} else {\n-\t\t\tprint STDERR \"Failed to log in mediawiki user \\\"$credential{username}\\\" on $url\\n\";\n-\t\t\tprint STDERR \"  (error \" .\n+\t\t\tprint STDERR qq(Failed to log in mediawiki user \"$credential{username}\" on ${url}\\n);\n+\t\t\tprint STDERR '  (error ' .\n \t\t\t\t$mediawiki->{error}->{code} . ': ' .\n \t\t\t\t$mediawiki->{error}->{details} . \")\\n\";\n \t\t\tGit::credential \\%credential, 'reject';\n@@ -243,7 +243,7 @@ sub get_mw_tracked_categories {\n \t\t\t# Mediawiki requires the Category\n \t\t\t# prefix, but let's not force the user\n \t\t\t# to specify it.\n-\t\t\t$category = \"Category:\" . $category;\n+\t\t\t$category = \"Category:${category}\";\n \t\t}\n \t\tmy $mw_pages = $mediawiki->list( {\n \t\t\taction => 'query',\n@@ -269,8 +269,8 @@ sub get_mw_all_pages {\n \t});\n \tif (!defined($mw_pages)) {\n \t\tprint STDERR \"fatal: could not get the list of wiki pages.\\n\";\n-\t\tprint STDERR \"fatal: '$url' does not appear to be a mediawiki\\n\";\n-\t\tprint STDERR \"fatal: make sure '$url/api.php' is a valid page.\\n\";\n+\t\tprint STDERR \"fatal: '${url}' does not appear to be a mediawiki\\n\";\n+\t\tprint STDERR \"fatal: make sure '${url}/api.php' is a valid page.\\n\";\n \t\texit 1;\n \t}\n \tforeach my $page (@{$mw_pages}) {\n@@ -296,8 +296,8 @@ sub get_mw_first_pages {\n \t});\n \tif (!defined($mw_pages)) {\n \t\tprint STDERR \"fatal: could not query the list of wiki pages.\\n\";\n-\t\tprint STDERR \"fatal: '$url' does not appear to be a mediawiki\\n\";\n-\t\tprint STDERR \"fatal: make sure '$url/api.php' is a valid page.\\n\";\n+\t\tprint STDERR \"fatal: '${url}' does not appear to be a mediawiki\\n\";\n+\t\tprint STDERR \"fatal: make sure '${url}/api.php' is a valid page.\\n\";\n \t\texit 1;\n \t}\n \twhile (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {\n@@ -347,10 +347,10 @@ sub get_mw_pages {\n #        $out = run_git(\"command args\", \"raw\"); # don't interpret output as UTF-8.\n sub run_git {\n \tmy $args = shift;\n-\tmy $encoding = (shift || \"encoding(UTF-8)\");\n-\topen(my $git, \"-|:$encoding\", \"git \" . $args)\n-\t    or die \"Unable to open: $!\\n\";\n-\tmy $res = do { \n+\tmy $encoding = (shift || 'encoding(UTF-8)');\n+\topen(my $git, \"-|:${encoding}\", \"git ${args}\")\n+\t    or die \"Unable to fork: $!\\n\";\n+\tmy $res = do {\n \t\tlocal $/ = undef;\n \t\t<$git>\n \t};\n@@ -368,7 +368,7 @@ sub get_all_mediafiles {\n \tmy $mw_pages = $mediawiki->list({\n \t\taction => 'query',\n \t\tlist => 'allpages',\n-\t\tapnamespace => get_mw_namespace_id(\"File\"),\n+\t\tapnamespace => get_mw_namespace_id('File'),\n \t\taplimit => 'max'\n \t});\n \tif (!defined($mw_pages)) {\n@@ -405,7 +405,7 @@ sub get_linked_mediafiles {\n \t\t\taction => 'query',\n \t\t\tprop => 'links|images',\n \t\t\ttitles => $mw_titles,\n-\t\t\tplnamespace => get_mw_namespace_id(\"File\"),\n+\t\t\tplnamespace => get_mw_namespace_id('File'),\n \t\t\tpllimit => 'max'\n \t\t};\n \t\tmy $result = $mediawiki->api($query);\n@@ -443,7 +443,7 @@ sub get_mw_mediafile_for_page_revision {\n \tmy $query = {\n \t\taction => 'query',\n \t\tprop => 'imageinfo',\n-\t\ttitles => \"File:\" . $filename,\n+\t\ttitles => \"File:${filename}\",\n \t\tiistart => $timestamp,\n \t\tiiend => $timestamp,\n \t\tiiprop => 'timestamp|archivename|url',\n@@ -475,26 +475,26 @@ sub download_mw_mediafile {\n \t\treturn $response->decoded_content;\n \t} else {\n \t\tprint STDERR \"Error downloading mediafile from :\\n\";\n-\t\tprint STDERR \"URL: $download_url\\n\";\n-\t\tprint STDERR \"Server response: \" . $response->code . \" \" . $response->message . \"\\n\";\n+\t\tprint STDERR \"URL: ${download_url}\\n\";\n+\t\tprint STDERR 'Server response: ' . $response->code . q{ } . $response->message . \"\\n\";\n \t\texit 1;\n \t}\n }\n \n sub get_last_local_revision {\n \t# Get note regarding last mediawiki revision\n-\tmy $note = run_git(\"notes --ref=$remotename/mediawiki show refs/mediawiki/$remotename/master 2>/dev/null\");\n+\tmy $note = run_git(\"notes --ref=${remotename}/mediawiki show refs/mediawiki/${remotename}/master 2>/dev/null\");\n \tmy @note_info = split(/ /, $note);\n \n \tmy $lastrevision_number;\n-\tif (!(defined($note_info[0]) && $note_info[0] eq \"mediawiki_revision:\")) {\n-\t\tprint STDERR \"No previous mediawiki revision found\";\n+\tif (!(defined($note_info[0]) && $note_info[0] eq 'mediawiki_revision:')) {\n+\t\tprint STDERR 'No previous mediawiki revision found';\n \t\t$lastrevision_number = 0;\n \t} else {\n \t\t# Notes are formatted : mediawiki_revision: #number\n \t\t$lastrevision_number = $note_info[1];\n \t\tchomp($lastrevision_number);\n-\t\tprint STDERR \"Last local mediawiki revision found is $lastrevision_number\";\n+\t\tprint STDERR \"Last local mediawiki revision found is ${lastrevision_number}\";\n \t}\n \treturn $lastrevision_number;\n }\n@@ -573,7 +573,7 @@ sub mediawiki_smudge {\n \t\t$string = \"\";\n \t}\n \t# This \\n is important. This is due to mediawiki's way to handle end of files.\n-\treturn $string.\"\\n\";\n+\treturn \"${string}\\n\";\n }\n \n sub mediawiki_clean_filename {\n@@ -595,13 +595,13 @@ sub mediawiki_smudge_filename {\n \t$filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;\n \t$filename =~ s/ /_/g;\n \t# Decode forbidden characters encoded in mediawiki_clean_filename\n-\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n+\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;\n \treturn $filename;\n }\n \n sub literal_data {\n \tmy ($content) = @_;\n-\tprint STDOUT \"data \", bytes::length($content), \"\\n\", $content;\n+\tprint STDOUT 'data ', bytes::length($content), \"\\n\", $content;\n \treturn;\n }\n \n@@ -620,7 +620,7 @@ sub mw_capabilities {\n \t# Revisions are imported to the private namespace\n \t# refs/mediawiki/$remotename/ by the helper and fetched into\n \t# refs/remotes/$remotename later by fetch.\n-\tprint STDOUT \"refspec refs/heads/*:refs/mediawiki/$remotename/*\\n\";\n+\tprint STDOUT \"refspec refs/heads/*:refs/mediawiki/${remotename}/*\\n\";\n \tprint STDOUT \"import\\n\";\n \tprint STDOUT \"list\\n\";\n \tprint STDOUT \"push\\n\";\n@@ -679,7 +679,7 @@ sub fetch_mw_revisions_for_page {\n \t\t@page_revs = sort {$b->{revid} <=> $a->{revid}} (@page_revs);\n \t\treturn $page_revs[0];\n \t}\n-\tprint STDERR \"  Found \", $revnum, \" revision(s).\\n\";\n+\tprint STDERR \"  Found ${revnum} revision(s).\\n\";\n \treturn @page_revs;\n }\n \n@@ -691,8 +691,7 @@ sub fetch_mw_revisions {\n \tmy $n = 1;\n \tforeach my $page (@pages) {\n \t\tmy $id = $page->{pageid};\n-\n-\t\tprint STDERR \"page $n/\", scalar(@pages), \": \". $page->{title} .\"\\n\";\n+\t\tprint STDERR \"page ${n}/\", scalar(@pages), ': ', $page->{title}, \"\\n\";\n \t\t$n++;\n \t\tmy @page_revs = fetch_mw_revisions_for_page($page, $id, $fetch_from);\n \t\t@revisions = (@page_revs, @revisions);\n@@ -706,7 +705,7 @@ sub fe_escape_path {\n     $path =~ s/\\\\/\\\\\\\\/g;\n     $path =~ s/\"/\\\\\"/g;\n     $path =~ s/\\n/\\\\n/g;\n-    return '\"' . $path . '\"';\n+    return qq(\"${path}\");\n }\n \n sub import_file_revision {\n@@ -726,41 +725,41 @@ sub import_file_revision {\n \tmy $author = $commit{author};\n \tmy $date = $commit{date};\n \n-\tprint STDOUT \"commit refs/mediawiki/$remotename/master\\n\";\n-\tprint STDOUT \"mark :$n\\n\";\n-\tprint STDOUT \"committer $author <$author\\@$wiki_name> \", $date->epoch, \" +0000\\n\";\n+\tprint STDOUT \"commit refs/mediawiki/${remotename}/master\\n\";\n+\tprint STDOUT \"mark :${n}\\n\";\n+\tprint STDOUT \"committer ${author} <${author}\\@${wiki_name}> \" . $date->epoch . \" +0000\\n\";\n \tliteral_data($comment);\n \n \t# If it's not a clone, we need to know where to start from\n \tif (!$full_import && $n == 1) {\n-\t\tprint STDOUT \"from refs/mediawiki/$remotename/master^0\\n\";\n+\t\tprint STDOUT \"from refs/mediawiki/${remotename}/master^0\\n\";\n \t}\n \tif ($content ne DELETED_CONTENT) {\n-\t\tprint STDOUT \"M 644 inline \" .\n-\t\t    fe_escape_path($title . \".mw\") . \"\\n\";\n+\t\tprint STDOUT 'M 644 inline ' .\n+\t\t    fe_escape_path(\"${title}.mw\") . \"\\n\";\n \t\tliteral_data($content);\n \t\tif (%mediafile) {\n-\t\t\tprint STDOUT \"M 644 inline \"\n+\t\t\tprint STDOUT 'M 644 inline '\n \t\t\t    . fe_escape_path($mediafile{title}) . \"\\n\";\n \t\t\tliteral_data_raw($mediafile{content});\n \t\t}\n \t\tprint STDOUT \"\\n\\n\";\n \t} else {\n-\t\tprint STDOUT \"D \" . fe_escape_path($title . \".mw\") . \"\\n\";\n+\t\tprint STDOUT 'D ' . fe_escape_path(\"${title}.mw\") . \"\\n\";\n \t}\n \n \t# mediawiki revision number in the git note\n \tif ($full_import && $n == 1) {\n-\t\tprint STDOUT \"reset refs/notes/$remotename/mediawiki\\n\";\n+\t\tprint STDOUT \"reset refs/notes/${remotename}/mediawiki\\n\";\n \t}\n-\tprint STDOUT \"commit refs/notes/$remotename/mediawiki\\n\";\n-\tprint STDOUT \"committer $author <$author\\@$wiki_name> \", $date->epoch, \" +0000\\n\";\n-\tliteral_data(\"Note added by git-mediawiki during import\");\n+\tprint STDOUT \"commit refs/notes/${remotename}/mediawiki\\n\";\n+\tprint STDOUT \"committer ${author} <${author}\\@${wiki_name}> \" . $date->epoch . \" +0000\\n\";\n+\tliteral_data('Note added by git-mediawiki during import');\n \tif (!$full_import && $n == 1) {\n-\t\tprint STDOUT \"from refs/notes/$remotename/mediawiki^0\\n\";\n+\t\tprint STDOUT \"from refs/notes/${remotename}/mediawiki^0\\n\";\n \t}\n-\tprint STDOUT \"N inline :$n\\n\";\n-\tliteral_data(\"mediawiki_revision: \" . $commit{mw_revision});\n+\tprint STDOUT \"N inline :${n}\\n\";\n+\tliteral_data(\"mediawiki_revision: $commit{mw_revision}\");\n \tprint STDOUT \"\\n\\n\";\n \treturn;\n }\n@@ -788,7 +787,7 @@ sub get_more_refs {\n \n sub mw_import {\n \t# multiple import commands can follow each other.\n-\tmy @refs = (shift, get_more_refs(\"import\"));\n+\tmy @refs = (shift, get_more_refs('import'));\n \tforeach my $ref (@refs) {\n \t\tmw_import_ref($ref);\n \t}\n@@ -803,7 +802,7 @@ sub mw_import_ref {\n \t# Since HEAD is a symbolic ref to master (by convention,\n \t# followed by the output of the command \"list\" that we gave),\n \t# we don't need to do anything in this case.\n-\tif ($ref eq \"HEAD\") {\n+\tif ($ref eq 'HEAD') {\n \t\treturn;\n \t}\n \n@@ -819,15 +818,15 @@ sub mw_import_ref {\n \t}\n \n \tmy $n = 0;\n-\tif ($fetch_strategy eq \"by_rev\") {\n+\tif ($fetch_strategy eq 'by_rev') {\n \t\tprint STDERR \"Fetching & writing export data by revs...\\n\";\n \t\t$n = mw_import_ref_by_revs($fetch_from);\n-\t} elsif ($fetch_strategy eq \"by_page\") {\n+\t} elsif ($fetch_strategy eq 'by_page') {\n \t\tprint STDERR \"Fetching & writing export data by pages...\\n\";\n \t\t$n = mw_import_ref_by_pages($fetch_from);\n \t} else {\n-\t\tprint STDERR \"fatal: invalid fetch strategy \\\"$fetch_strategy\\\".\\n\";\n-\t\tprint STDERR \"Check your configuration variables remote.$remotename.fetchStrategy and mediawiki.fetchStrategy\\n\";\n+\t\tprint STDERR qq(fatal: invalid fetch strategy \"${fetch_strategy}\".\\n);\n+\t\tprint STDERR \"Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\\n\";\n \t\texit 1;\n \t}\n \n@@ -901,7 +900,7 @@ sub mw_import_revids {\n \t\t}\n \n \t\tif (!defined($result->{query}->{pages})) {\n-\t\t\tdie \"Invalid revision $pagerevid.\\n\";\n+\t\t\tdie \"Invalid revision ${pagerevid}.\\n\";\n \t\t}\n \n \t\tmy @result_pages = values(%{$result->{query}->{pages}});\n@@ -911,8 +910,8 @@ sub mw_import_revids {\n \t\tmy $page_title = $result_page->{title};\n \n \t\tif (!exists($pages->{$page_title})) {\n-\t\t\tprint STDERR \"$n/\", scalar(@$revision_ids),\n-\t\t\t\t\": Skipping revision #$rev->{revid} of $page_title\\n\";\n+\t\t\tprint STDERR \"${n}/\", scalar(@$revision_ids),\n+\t\t\t\t\": Skipping revision #$rev->{revid} of ${page_title}\\n\";\n \t\t\tnext;\n \t\t}\n \n@@ -937,14 +936,14 @@ sub mw_import_revids {\n \t\tmy %mediafile;\n \t\tif ($namespace) {\n \t\t\tmy $id = get_mw_namespace_id($namespace);\n-\t\t\tif ($id && $id == get_mw_namespace_id(\"File\")) {\n+\t\t\tif ($id && $id == get_mw_namespace_id('File')) {\n \t\t\t\t%mediafile = get_mw_mediafile_for_page_revision($filename, $rev->{timestamp});\n \t\t\t}\n \t\t}\n \t\t# If this is a revision of the media page for new version\n \t\t# of a file do one common commit for both file and media page.\n \t\t# Else do commit only for that page.\n-\t\tprint STDERR \"$n/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n+\t\tprint STDERR \"${n}/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n \t\timport_file_revision(\\%commit, ($fetch_from == 1), $n_actual, \\%mediafile);\n \t}\n \n@@ -952,9 +951,9 @@ sub mw_import_revids {\n }\n \n sub error_non_fast_forward {\n-\tmy $advice = run_git(\"config --bool advice.pushNonFastForward\");\n+\tmy $advice = run_git('config --bool advice.pushNonFastForward');\n \tchomp($advice);\n-\tif ($advice ne \"false\") {\n+\tif ($advice ne 'false') {\n \t\t# Native git-push would show this after the summary.\n \t\t# We can't ask it to display it cleanly, so print it\n \t\t# ourselves before.\n@@ -962,7 +961,7 @@ sub error_non_fast_forward {\n \t\tprint STDERR \"Merge the remote changes (e.g. 'git pull') before pushing again. See the\\n\";\n \t\tprint STDERR \"'Note about fast-forwards' section of 'git push --help' for details.\\n\";\n \t}\n-\tprint STDOUT \"error $_[0] \\\"non-fast-forward\\\"\\n\";\n+\tprint STDOUT qq(error $_[0] \"non-fast-forward\"\\n);\n \treturn 0;\n }\n \n@@ -973,10 +972,10 @@ sub mw_upload_file {\n \tmy $file_deleted = shift;\n \tmy $summary = shift;\n \tmy $newrevid;\n-\tmy $path = \"File:\" . $complete_file_name;\n+\tmy $path = \"File:${complete_file_name}\";\n \tmy %hashFiles = get_allowed_file_extensions();\n \tif (!exists($hashFiles{$extension})) {\n-\t\tprint STDERR \"$complete_file_name is not a permitted file on this wiki.\\n\";\n+\t\tprint STDERR \"${complete_file_name} is not a permitted file on this wiki.\\n\";\n \t\tprint STDERR \"Check the configuration of file uploads in your mediawiki.\\n\";\n \t\treturn $newrevid;\n \t}\n@@ -996,11 +995,11 @@ sub mw_upload_file {\n \t\t}\n \t} else {\n \t\t# Don't let perl try to interpret file content as UTF-8 => use \"raw\"\n-\t\tmy $content = run_git(\"cat-file blob $new_sha1\", \"raw\");\n+\t\tmy $content = run_git(\"cat-file blob ${new_sha1}\", 'raw');\n \t\tif ($content ne \"\") {\n \t\t\tmw_connect_maybe();\n \t\t\t$mediawiki->{config}->{upload_url} =\n-\t\t\t\t\"$url/index.php/Special:Upload\";\n+\t\t\t\t\"${url}/index.php/Special:Upload\";\n \t\t\t$mediawiki->edit({\n \t\t\t\taction => 'upload',\n \t\t\t\tfilename => $complete_file_name,\n@@ -1015,9 +1014,9 @@ sub mw_upload_file {\n \t\t\t\t . $mediawiki->{error}->{details} . \"\\n\";\n \t\t\tmy $last_file_page = $mediawiki->get_page({title => $path});\n \t\t\t$newrevid = $last_file_page->{revid};\n-\t\t\tprint STDERR \"Pushed file: $new_sha1 - $complete_file_name.\\n\";\n+\t\t\tprint STDERR \"Pushed file: ${new_sha1} - ${complete_file_name}.\\n\";\n \t\t} else {\n-\t\t\tprint STDERR \"Empty file $complete_file_name not pushed.\\n\";\n+\t\t\tprint STDERR \"Empty file ${complete_file_name} not pushed.\\n\";\n \t\t}\n \t}\n \treturn $newrevid;\n@@ -1052,11 +1051,11 @@ sub mw_push_file {\n \tif (!defined($extension)) {\n \t\t$extension = \"\";\n \t}\n-\tif ($extension eq \"mw\") {\n+\tif ($extension eq 'mw') {\n \t\tmy $ns = get_mw_namespace_id_for_page($complete_file_name);\n-\t\tif ($ns && $ns == get_mw_namespace_id(\"File\") && (!$export_media)) {\n-\t\t\tprint STDERR \"Ignoring media file related page: $complete_file_name\\n\";\n-\t\t\treturn ($oldrevid, \"ok\");\n+\t\tif ($ns && $ns == get_mw_namespace_id('File') && (!$export_media)) {\n+\t\t\tprint STDERR \"Ignoring media file related page: ${complete_file_name}\\n\";\n+\t\t\treturn ($oldrevid, 'ok');\n \t\t}\n \t\tmy $file_content;\n \t\tif ($page_deleted) {\n@@ -1066,7 +1065,7 @@ sub mw_push_file {\n \t\t\t# with this content instead:\n \t\t\t$file_content = DELETED_CONTENT;\n \t\t} else {\n-\t\t\t$file_content = run_git(\"cat-file blob $new_sha1\");\n+\t\t\t$file_content = run_git(\"cat-file blob ${new_sha1}\");\n \t\t}\n \n \t\tmw_connect_maybe();\n@@ -1087,7 +1086,7 @@ sub mw_push_file {\n \t\t\t\t    $mediawiki->{error}->{code} .\n \t\t\t\t    ' from mediwiki: ' . $mediawiki->{error}->{details} .\n \t\t\t\t    \".\\n\";\n-\t\t\t\treturn ($oldrevid, \"non-fast-forward\");\n+\t\t\t\treturn ($oldrevid, 'non-fast-forward');\n \t\t\t} else {\n \t\t\t\t# Other errors. Shouldn't happen => just die()\n \t\t\t\tdie 'Fatal: Error ' .\n@@ -1096,21 +1095,21 @@ sub mw_push_file {\n \t\t\t}\n \t\t}\n \t\t$newrevid = $result->{edit}->{newrevid};\n-\t\tprint STDERR \"Pushed file: $new_sha1 - $title\\n\";\n+\t\tprint STDERR \"Pushed file: ${new_sha1} - ${title}\\n\";\n \t} elsif ($export_media) {\n \t\t$newrevid = mw_upload_file($complete_file_name, $new_sha1,\n \t\t\t\t\t   $extension, $page_deleted,\n \t\t\t\t\t   $summary);\n \t} else {\n-\t\tprint STDERR \"Ignoring media file $title\\n\";\n+\t\tprint STDERR \"Ignoring media file ${title}\\n\";\n \t}\n \t$newrevid = ($newrevid or $oldrevid);\n-\treturn ($newrevid, \"ok\");\n+\treturn ($newrevid, 'ok');\n }\n \n sub mw_push {\n \t# multiple push statements can follow each other\n-\tmy @refsspecs = (shift, get_more_refs(\"push\"));\n+\tmy @refsspecs = (shift, get_more_refs('push'));\n \tmy $pushed;\n \tfor my $refspec (@refsspecs) {\n \t\tmy ($force, $local, $remote) = $refspec =~ /^(\\+)?([^:]*):([^:]*)$/\n@@ -1120,12 +1119,12 @@ sub mw_push {\n \t\t}\n \t\tif ($local eq \"\") {\n \t\t\tprint STDERR \"Cannot delete remote branch on a MediaWiki\\n\";\n-\t\t\tprint STDOUT \"error $remote cannot delete\\n\";\n+\t\t\tprint STDOUT \"error ${remote} cannot delete\\n\";\n \t\t\tnext;\n \t\t}\n-\t\tif ($remote ne \"refs/heads/master\") {\n+\t\tif ($remote ne 'refs/heads/master') {\n \t\t\tprint STDERR \"Only push to the branch 'master' is supported on a MediaWiki\\n\";\n-\t\t\tprint STDOUT \"error $remote only master allowed\\n\";\n+\t\t\tprint STDOUT \"error ${remote} only master allowed\\n\";\n \t\t\tnext;\n \t\t}\n \t\tif (mw_push_revision($local, $remote)) {\n@@ -1156,9 +1155,10 @@ sub mw_push_revision {\n \tmy $mw_revision = $last_remote_revid;\n \n \t# Get sha1 of commit pointed by local HEAD\n-\tmy $HEAD_sha1 = run_git(\"rev-parse $local 2>/dev/null\"); chomp($HEAD_sha1);\n+\tmy $HEAD_sha1 = run_git(\"rev-parse ${local} 2>/dev/null\");\n+\tchomp($HEAD_sha1);\n \t# Get sha1 of commit pointed by remotes/$remotename/master\n-\tmy $remoteorigin_sha1 = run_git(\"rev-parse refs/remotes/$remotename/master 2>/dev/null\");\n+\tmy $remoteorigin_sha1 = run_git(\"rev-parse refs/remotes/${remotename}/master 2>/dev/null\");\n \tchomp($remoteorigin_sha1);\n \n \tif ($last_local_revid > 0 &&\n@@ -1178,7 +1178,7 @@ sub mw_push_revision {\n \t\tmy $parsed_sha1 = $remoteorigin_sha1;\n \t\t# Find a path from last MediaWiki commit to pushed commit\n \t\tprint STDERR \"Computing path from local to remote ...\\n\";\n-\t\tmy @local_ancestry = split(/\\n/, run_git(\"rev-list --boundary --parents $local ^$parsed_sha1\"));\n+\t\tmy @local_ancestry = split(/\\n/, run_git(\"rev-list --boundary --parents ${local} ^${parsed_sha1}\"));\n \t\tmy %local_ancestry;\n \t\tforeach my $line (@local_ancestry) {\n \t\t\tif (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {\n@@ -1186,7 +1186,7 @@ sub mw_push_revision {\n \t\t\t\t\t$local_ancestry{$parent} = $child;\n \t\t\t\t}\n \t\t\t} elsif (!$line =~ /^([a-f0-9]+)/) {\n-\t\t\t\tdie \"Unexpected output from git rev-list: $line\\n\";\n+\t\t\t\tdie \"Unexpected output from git rev-list: ${line}\\n\";\n \t\t\t}\n \t\t}\n \t\twhile ($parsed_sha1 ne $HEAD_sha1) {\n@@ -1202,7 +1202,7 @@ sub mw_push_revision {\n \t\t# No remote mediawiki revision. Export the whole\n \t\t# history (linearized with --first-parent)\n \t\tprint STDERR \"Warning: no common ancestor, pushing complete history\\n\";\n-\t\tmy $history = run_git(\"rev-list --first-parent --children $local\");\n+\t\tmy $history = run_git(\"rev-list --first-parent --children ${local}\");\n \t\tmy @history = split(/\\n/, $history);\n \t\t@history = @history[1..$#history];\n \t\tforeach my $line (reverse @history) {\n@@ -1214,12 +1214,12 @@ sub mw_push_revision {\n \tforeach my $commit_info_split (@commit_pairs) {\n \t\tmy $sha1_child = @{$commit_info_split}[0];\n \t\tmy $sha1_commit = @{$commit_info_split}[1];\n-\t\tmy $diff_infos = run_git(\"diff-tree -r --raw -z $sha1_child $sha1_commit\");\n+\t\tmy $diff_infos = run_git(\"diff-tree -r --raw -z ${sha1_child} ${sha1_commit}\");\n \t\t# TODO: we could detect rename, and encode them with a #redirect on the wiki.\n \t\t# TODO: for now, it's just a delete+add\n \t\tmy @diff_info_list = split(/\\0/, $diff_infos);\n \t\t# Keep the subject line of the commit message as mediawiki comment for the revision\n-\t\tmy $commit_msg = run_git(\"log --no-walk --format=\\\"%s\\\" $sha1_commit\");\n+\t\tmy $commit_msg = run_git(qq(log --no-walk --format=\"%s\" ${sha1_commit}));\n \t\tchomp($commit_msg);\n \t\t# Push every blob\n \t\twhile (@diff_info_list) {\n@@ -1231,7 +1231,7 @@ sub mw_push_revision {\n \t\t\tmy $info = shift(@diff_info_list);\n \t\t\tmy $file = shift(@diff_info_list);\n \t\t\t($mw_revision, $status) = mw_push_file($info, $file, $commit_msg, $mw_revision);\n-\t\t\tif ($status eq \"non-fast-forward\") {\n+\t\t\tif ($status eq 'non-fast-forward') {\n \t\t\t\t# we may already have sent part of the\n \t\t\t\t# commit to MediaWiki, but it's too\n \t\t\t\t# late to cancel it. Stop the push in\n@@ -1239,17 +1239,17 @@ sub mw_push_revision {\n \t\t\t\t# accurate error message.\n \t\t\t\treturn error_non_fast_forward($remote);\n \t\t\t}\n-\t\t\tif ($status ne \"ok\") {\n+\t\t\tif ($status ne 'ok') {\n \t\t\t\tdie(\"Unknown error from mw_push_file()\\n\");\n \t\t\t}\n \t\t}\n \t\tunless ($dumb_push) {\n-\t\t\trun_git(\"notes --ref=$remotename/mediawiki add -f -m \\\"mediawiki_revision: $mw_revision\\\" $sha1_commit\");\n-\t\t\trun_git(\"update-ref -m \\\"Git-MediaWiki push\\\" refs/mediawiki/$remotename/master $sha1_commit $sha1_child\");\n+\t\t\trun_git(qq(notes --ref=${remotename}/mediawiki add -f -m \"mediawiki_revision: ${mw_revision}\" ${sha1_commit}));\n+\t\t\trun_git(qq(update-ref -m \"Git-MediaWiki push\" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));\n \t\t}\n \t}\n \n-\tprint STDOUT \"ok $remote\\n\";\n+\tprint STDOUT \"ok ${remote}\\n\";\n \treturn 1;\n }\n \n@@ -1285,8 +1285,7 @@ sub get_mw_namespace_id {\n \t\t# Look at configuration file, if the record for that namespace is\n \t\t# already cached. Namespaces are stored in form:\n \t\t# \"Name_of_namespace:Id_namespace\", ex.: \"File:6\".\n-\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.\"\n-\t\t\t\t\t\t. $remotename .\".namespaceCache\"));\n+\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n \t\tchomp(@temp);\n \t\tforeach my $ns (@temp) {\n \t\t\tmy ($n, $id) = split(/:/, $ns);\n@@ -1300,7 +1299,7 @@ sub get_mw_namespace_id {\n \t}\n \n \tif (!exists $namespace_id{$name}) {\n-\t\tprint STDERR \"Namespace $name not found in cache, querying the wiki ...\\n\";\n+\t\tprint STDERR \"Namespace ${name} not found in cache, querying the wiki ...\\n\";\n \t\t# NS not found => get namespace id from MW and store it in\n \t        # configuration file.\n \t        my $query = {\n@@ -1325,7 +1324,7 @@ sub get_mw_namespace_id {\n \tmy $id;\n \n \tunless (defined $ns) {\n-\t\tprint STDERR \"No such namespace $name on MediaWiki.\\n\";\n+\t\tprint STDERR \"No such namespace ${name} on MediaWiki.\\n\";\n \t\t$ns = {is_namespace => 0};\n \t\t$namespace_id{$name} = $ns;\n \t}\n@@ -1339,8 +1338,7 @@ sub get_mw_namespace_id {\n \n \t# Store explicitely requested namespaces on disk\n \tif (!exists $cached_mw_namespace_id{$name}) {\n-\t\trun_git(\"config --add remote.\". $remotename\n-\t\t\t.\".namespaceCache \\\"\". $name .\":\". $store_id .\"\\\"\");\n+\t\trun_git(qq(config --add remote.${remotename}.namespaceCache \"${name}:${store_id}\"));\n \t\t$cached_mw_namespace_id{$name} = 1;\n \t}\n \treturn $id;\n-- \n1.7.9.5\n"},{"id":"220182","messageId":"1370816573-3808-24-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 23/28] git-remote-mediawiki: Brace file handles for print for more clarity","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:48Z","receivedAt":"2013-06-09T22:22:48Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"This follows the following rule:\nInputOutput::RequireBracedFileHandleWithPrint (Severity: 1)\n    The `print' and `printf' functions have a unique syntax that supports an\n    optional file handle argument. Conway suggests wrapping this argument in\n    braces to make it visually stand out from the other arguments. When you\n    put braces around any of the special package-level file handles like\n    `STDOUT', `STDERR', and `DATA', you must the `'*'' sigil or else it\n    won't compile under `use strict 'subs''.\n\n      print $FH   \"Mary had a little lamb\\n\";  #not ok\n      print {$FH} \"Mary had a little lamb\\n\";  #ok\n\n      print   STDERR   $foo, $bar, $baz;  #not ok\n      print  {STDERR}  $foo, $bar, $baz;  #won't compile under 'strict'\n      print {*STDERR}  $foo, $bar, $baz;  #perfect!\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |  196 +++++++++++++--------------\n 1 file changed, 98 insertions(+), 98 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex efc376a..1cda460 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -173,7 +173,7 @@ sub parse_command {\n \t} elsif ($cmd[0] eq 'push') {\n \t\tmw_push($cmd[1]);\n \t} else {\n-\t\tprint STDERR \"Unknown command. Aborting...\\n\";\n+\t\tprint {*STDERR} \"Unknown command. Aborting...\\n\";\n \t\treturn 0;\n \t}\n \treturn 1;\n@@ -200,10 +200,10 @@ sub mw_connect_maybe {\n \t\t\t       lgdomain => $wiki_domain};\n \t\tif ($mediawiki->login($request)) {\n \t\t\tGit::credential \\%credential, 'approve';\n-\t\t\tprint STDERR qq(Logged in mediawiki user \"$credential{username}\".\\n);\n+\t\t\tprint {*STDERR} qq(Logged in mediawiki user \"$credential{username}\".\\n);\n \t\t} else {\n-\t\t\tprint STDERR qq(Failed to log in mediawiki user \"$credential{username}\" on ${url}\\n);\n-\t\t\tprint STDERR '  (error ' .\n+\t\t\tprint {*STDERR} qq(Failed to log in mediawiki user \"$credential{username}\" on ${url}\\n);\n+\t\t\tprint {*STDERR} '  (error ' .\n \t\t\t\t$mediawiki->{error}->{code} . ': ' .\n \t\t\t\t$mediawiki->{error}->{details} . \")\\n\";\n \t\t\tGit::credential \\%credential, 'reject';\n@@ -268,9 +268,9 @@ sub get_mw_all_pages {\n \t\taplimit => 'max'\n \t});\n \tif (!defined($mw_pages)) {\n-\t\tprint STDERR \"fatal: could not get the list of wiki pages.\\n\";\n-\t\tprint STDERR \"fatal: '${url}' does not appear to be a mediawiki\\n\";\n-\t\tprint STDERR \"fatal: make sure '${url}/api.php' is a valid page.\\n\";\n+\t\tprint {*STDERR} \"fatal: could not get the list of wiki pages.\\n\";\n+\t\tprint {*STDERR} \"fatal: '${url}' does not appear to be a mediawiki\\n\";\n+\t\tprint {*STDERR} \"fatal: make sure '${url}/api.php' is a valid page.\\n\";\n \t\texit 1;\n \t}\n \tforeach my $page (@{$mw_pages}) {\n@@ -295,14 +295,14 @@ sub get_mw_first_pages {\n \t\ttitles => $titles,\n \t});\n \tif (!defined($mw_pages)) {\n-\t\tprint STDERR \"fatal: could not query the list of wiki pages.\\n\";\n-\t\tprint STDERR \"fatal: '${url}' does not appear to be a mediawiki\\n\";\n-\t\tprint STDERR \"fatal: make sure '${url}/api.php' is a valid page.\\n\";\n+\t\tprint {*STDERR} \"fatal: could not query the list of wiki pages.\\n\";\n+\t\tprint {*STDERR} \"fatal: '${url}' does not appear to be a mediawiki\\n\";\n+\t\tprint {*STDERR} \"fatal: make sure '${url}/api.php' is a valid page.\\n\";\n \t\texit 1;\n \t}\n \twhile (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {\n \t\tif ($id < 0) {\n-\t\t\tprint STDERR \"Warning: page $page->{title} not found on wiki\\n\";\n+\t\t\tprint {*STDERR} \"Warning: page $page->{title} not found on wiki\\n\";\n \t\t} else {\n \t\t\t$pages->{$page->{title}} = $page;\n \t\t}\n@@ -314,7 +314,7 @@ sub get_mw_first_pages {\n sub get_mw_pages {\n \tmw_connect_maybe();\n \n-\tprint STDERR \"Listing pages on remote wiki...\\n\";\n+\tprint {*STDERR} \"Listing pages on remote wiki...\\n\";\n \n \tmy %pages; # hash on page titles to avoid duplicates\n \tmy $user_defined;\n@@ -332,14 +332,14 @@ sub get_mw_pages {\n \t\tget_mw_all_pages(\\%pages);\n \t}\n \tif ($import_media) {\n-\t\tprint STDERR \"Getting media files for selected pages...\\n\";\n+\t\tprint {*STDERR} \"Getting media files for selected pages...\\n\";\n \t\tif ($user_defined) {\n \t\t\tget_linked_mediafiles(\\%pages);\n \t\t} else {\n \t\t\tget_all_mediafiles(\\%pages);\n \t\t}\n \t}\n-\tprint STDERR (scalar keys %pages) . \" pages found.\\n\";\n+\tprint {*STDERR} (scalar keys %pages) . \" pages found.\\n\";\n \treturn %pages;\n }\n \n@@ -372,9 +372,9 @@ sub get_all_mediafiles {\n \t\taplimit => 'max'\n \t});\n \tif (!defined($mw_pages)) {\n-\t\tprint STDERR \"fatal: could not get the list of pages for media files.\\n\";\n-\t\tprint STDERR \"fatal: '$url' does not appear to be a mediawiki\\n\";\n-\t\tprint STDERR \"fatal: make sure '$url/api.php' is a valid page.\\n\";\n+\t\tprint {*STDERR} \"fatal: could not get the list of pages for media files.\\n\";\n+\t\tprint {*STDERR} \"fatal: '$url' does not appear to be a mediawiki\\n\";\n+\t\tprint {*STDERR} \"fatal: make sure '$url/api.php' is a valid page.\\n\";\n \t\texit 1;\n \t}\n \tforeach my $page (@{$mw_pages}) {\n@@ -461,7 +461,7 @@ sub get_mw_mediafile_for_page_revision {\n \t\t$mediafile{timestamp} = $fileinfo->{timestamp};\n \t\t# Mediawiki::API's download function doesn't support https URLs\n \t\t# and can't download old versions of files.\n-\t\tprint STDERR \"\\tDownloading file $mediafile{title}, version $mediafile{timestamp}\\n\";\n+\t\tprint {*STDERR} \"\\tDownloading file $mediafile{title}, version $mediafile{timestamp}\\n\";\n \t\t$mediafile{content} = download_mw_mediafile($fileinfo->{url});\n \t}\n \treturn %mediafile;\n@@ -474,9 +474,9 @@ sub download_mw_mediafile {\n \tif ($response->code == 200) {\n \t\treturn $response->decoded_content;\n \t} else {\n-\t\tprint STDERR \"Error downloading mediafile from :\\n\";\n-\t\tprint STDERR \"URL: ${download_url}\\n\";\n-\t\tprint STDERR 'Server response: ' . $response->code . q{ } . $response->message . \"\\n\";\n+\t\tprint {*STDERR} \"Error downloading mediafile from :\\n\";\n+\t\tprint {*STDERR} \"URL: ${download_url}\\n\";\n+\t\tprint {*STDERR} 'Server response: ' . $response->code . q{ } . $response->message . \"\\n\";\n \t\texit 1;\n \t}\n }\n@@ -488,13 +488,13 @@ sub get_last_local_revision {\n \n \tmy $lastrevision_number;\n \tif (!(defined($note_info[0]) && $note_info[0] eq 'mediawiki_revision:')) {\n-\t\tprint STDERR 'No previous mediawiki revision found';\n+\t\tprint {*STDERR} 'No previous mediawiki revision found';\n \t\t$lastrevision_number = 0;\n \t} else {\n \t\t# Notes are formatted : mediawiki_revision: #number\n \t\t$lastrevision_number = $note_info[1];\n \t\tchomp($lastrevision_number);\n-\t\tprint STDERR \"Last local mediawiki revision found is ${lastrevision_number}\";\n+\t\tprint {*STDERR} \"Last local mediawiki revision found is ${lastrevision_number}\";\n \t}\n \treturn $lastrevision_number;\n }\n@@ -527,7 +527,7 @@ sub get_last_remote_revision {\n \n \tmy $max_rev_num = 0;\n \n-\tprint STDERR \"Getting last revision id on tracked pages...\\n\";\n+\tprint {*STDERR} \"Getting last revision id on tracked pages...\\n\";\n \n \tforeach my $page (@pages) {\n \t\tmy $id = $page->{pageid};\n@@ -548,7 +548,7 @@ sub get_last_remote_revision {\n \t\t$max_rev_num = ($lastrev->{revid} > $max_rev_num ? $lastrev->{revid} : $max_rev_num);\n \t}\n \n-\tprint STDERR \"Last remote revision found is $max_rev_num.\\n\";\n+\tprint {*STDERR} \"Last remote revision found is $max_rev_num.\\n\";\n \treturn $max_rev_num;\n }\n \n@@ -601,7 +601,7 @@ sub mediawiki_smudge_filename {\n \n sub literal_data {\n \tmy ($content) = @_;\n-\tprint STDOUT 'data ', bytes::length($content), \"\\n\", $content;\n+\tprint {*STDOUT} 'data ', bytes::length($content), \"\\n\", $content;\n \treturn;\n }\n \n@@ -620,26 +620,26 @@ sub mw_capabilities {\n \t# Revisions are imported to the private namespace\n \t# refs/mediawiki/$remotename/ by the helper and fetched into\n \t# refs/remotes/$remotename later by fetch.\n-\tprint STDOUT \"refspec refs/heads/*:refs/mediawiki/${remotename}/*\\n\";\n-\tprint STDOUT \"import\\n\";\n-\tprint STDOUT \"list\\n\";\n-\tprint STDOUT \"push\\n\";\n-\tprint STDOUT \"\\n\";\n+\tprint {*STDOUT} \"refspec refs/heads/*:refs/mediawiki/${remotename}/*\\n\";\n+\tprint {*STDOUT} \"import\\n\";\n+\tprint {*STDOUT} \"list\\n\";\n+\tprint {*STDOUT} \"push\\n\";\n+\tprint {*STDOUT} \"\\n\";\n \treturn;\n }\n \n sub mw_list {\n \t# MediaWiki do not have branches, we consider one branch arbitrarily\n \t# called master, and HEAD pointing to it.\n-\tprint STDOUT \"? refs/heads/master\\n\";\n-\tprint STDOUT \"\\@refs/heads/master HEAD\\n\";\n-\tprint STDOUT \"\\n\";\n+\tprint {*STDOUT} \"? refs/heads/master\\n\";\n+\tprint {*STDOUT} \"\\@refs/heads/master HEAD\\n\";\n+\tprint {*STDOUT} \"\\n\";\n \treturn;\n }\n \n sub mw_option {\n-\tprint STDERR \"remote-helper command 'option $_[0]' not yet implemented\\n\";\n-\tprint STDOUT \"unsupported\\n\";\n+\tprint {*STDERR} \"remote-helper command 'option $_[0]' not yet implemented\\n\";\n+\tprint {*STDOUT} \"unsupported\\n\";\n \treturn;\n }\n \n@@ -675,11 +675,11 @@ sub fetch_mw_revisions_for_page {\n \t\t$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};\n \t}\n \tif ($shallow_import && @page_revs) {\n-\t\tprint STDERR \"  Found 1 revision (shallow import).\\n\";\n+\t\tprint {*STDERR} \"  Found 1 revision (shallow import).\\n\";\n \t\t@page_revs = sort {$b->{revid} <=> $a->{revid}} (@page_revs);\n \t\treturn $page_revs[0];\n \t}\n-\tprint STDERR \"  Found ${revnum} revision(s).\\n\";\n+\tprint {*STDERR} \"  Found ${revnum} revision(s).\\n\";\n \treturn @page_revs;\n }\n \n@@ -691,7 +691,7 @@ sub fetch_mw_revisions {\n \tmy $n = 1;\n \tforeach my $page (@pages) {\n \t\tmy $id = $page->{pageid};\n-\t\tprint STDERR \"page ${n}/\", scalar(@pages), ': ', $page->{title}, \"\\n\";\n+\t\tprint {*STDERR} \"page ${n}/\", scalar(@pages), ': ', $page->{title}, \"\\n\";\n \t\t$n++;\n \t\tmy @page_revs = fetch_mw_revisions_for_page($page, $id, $fetch_from);\n \t\t@revisions = (@page_revs, @revisions);\n@@ -725,42 +725,42 @@ sub import_file_revision {\n \tmy $author = $commit{author};\n \tmy $date = $commit{date};\n \n-\tprint STDOUT \"commit refs/mediawiki/${remotename}/master\\n\";\n-\tprint STDOUT \"mark :${n}\\n\";\n-\tprint STDOUT \"committer ${author} <${author}\\@${wiki_name}> \" . $date->epoch . \" +0000\\n\";\n+\tprint {*STDOUT} \"commit refs/mediawiki/${remotename}/master\\n\";\n+\tprint {*STDOUT} \"mark :${n}\\n\";\n+\tprint {*STDOUT} \"committer ${author} <${author}\\@${wiki_name}> \" . $date->epoch . \" +0000\\n\";\n \tliteral_data($comment);\n \n \t# If it's not a clone, we need to know where to start from\n \tif (!$full_import && $n == 1) {\n-\t\tprint STDOUT \"from refs/mediawiki/${remotename}/master^0\\n\";\n+\t\tprint {*STDOUT} \"from refs/mediawiki/${remotename}/master^0\\n\";\n \t}\n \tif ($content ne DELETED_CONTENT) {\n-\t\tprint STDOUT 'M 644 inline ' .\n+\t\tprint {*STDOUT} 'M 644 inline ' .\n \t\t    fe_escape_path(\"${title}.mw\") . \"\\n\";\n \t\tliteral_data($content);\n \t\tif (%mediafile) {\n-\t\t\tprint STDOUT 'M 644 inline '\n+\t\t\tprint {*STDOUT} 'M 644 inline '\n \t\t\t    . fe_escape_path($mediafile{title}) . \"\\n\";\n \t\t\tliteral_data_raw($mediafile{content});\n \t\t}\n-\t\tprint STDOUT \"\\n\\n\";\n+\t\tprint {*STDOUT} \"\\n\\n\";\n \t} else {\n-\t\tprint STDOUT 'D ' . fe_escape_path(\"${title}.mw\") . \"\\n\";\n+\t\tprint {*STDOUT} 'D ' . fe_escape_path(\"${title}.mw\") . \"\\n\";\n \t}\n \n \t# mediawiki revision number in the git note\n \tif ($full_import && $n == 1) {\n-\t\tprint STDOUT \"reset refs/notes/${remotename}/mediawiki\\n\";\n+\t\tprint {*STDOUT} \"reset refs/notes/${remotename}/mediawiki\\n\";\n \t}\n-\tprint STDOUT \"commit refs/notes/${remotename}/mediawiki\\n\";\n-\tprint STDOUT \"committer ${author} <${author}\\@${wiki_name}> \" . $date->epoch . \" +0000\\n\";\n+\tprint {*STDOUT} \"commit refs/notes/${remotename}/mediawiki\\n\";\n+\tprint {*STDOUT} \"committer ${author} <${author}\\@${wiki_name}> \" . $date->epoch . \" +0000\\n\";\n \tliteral_data('Note added by git-mediawiki during import');\n \tif (!$full_import && $n == 1) {\n-\t\tprint STDOUT \"from refs/notes/${remotename}/mediawiki^0\\n\";\n+\t\tprint {*STDOUT} \"from refs/notes/${remotename}/mediawiki^0\\n\";\n \t}\n-\tprint STDOUT \"N inline :${n}\\n\";\n+\tprint {*STDOUT} \"N inline :${n}\\n\";\n \tliteral_data(\"mediawiki_revision: $commit{mw_revision}\");\n-\tprint STDOUT \"\\n\\n\";\n+\tprint {*STDOUT} \"\\n\\n\";\n \treturn;\n }\n \n@@ -791,7 +791,7 @@ sub mw_import {\n \tforeach my $ref (@refs) {\n \t\tmw_import_ref($ref);\n \t}\n-\tprint STDOUT \"done\\n\";\n+\tprint {*STDOUT} \"done\\n\";\n \treturn;\n }\n \n@@ -808,30 +808,30 @@ sub mw_import_ref {\n \n \tmw_connect_maybe();\n \n-\tprint STDERR \"Searching revisions...\\n\";\n+\tprint {*STDERR} \"Searching revisions...\\n\";\n \tmy $last_local = get_last_local_revision();\n \tmy $fetch_from = $last_local + 1;\n \tif ($fetch_from == 1) {\n-\t\tprint STDERR \", fetching from beginning.\\n\";\n+\t\tprint {*STDERR} \", fetching from beginning.\\n\";\n \t} else {\n-\t\tprint STDERR \", fetching from here.\\n\";\n+\t\tprint {*STDERR} \", fetching from here.\\n\";\n \t}\n \n \tmy $n = 0;\n \tif ($fetch_strategy eq 'by_rev') {\n-\t\tprint STDERR \"Fetching & writing export data by revs...\\n\";\n+\t\tprint {*STDERR} \"Fetching & writing export data by revs...\\n\";\n \t\t$n = mw_import_ref_by_revs($fetch_from);\n \t} elsif ($fetch_strategy eq 'by_page') {\n-\t\tprint STDERR \"Fetching & writing export data by pages...\\n\";\n+\t\tprint {*STDERR} \"Fetching & writing export data by pages...\\n\";\n \t\t$n = mw_import_ref_by_pages($fetch_from);\n \t} else {\n-\t\tprint STDERR qq(fatal: invalid fetch strategy \"${fetch_strategy}\".\\n);\n-\t\tprint STDERR \"Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\\n\";\n+\t\tprint {*STDERR} qq(fatal: invalid fetch strategy \"${fetch_strategy}\".\\n);\n+\t\tprint {*STDERR} \"Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\\n\";\n \t\texit 1;\n \t}\n \n \tif ($fetch_from == 1 && $n == 0) {\n-\t\tprint STDERR \"You appear to have cloned an empty MediaWiki.\\n\";\n+\t\tprint {*STDERR} \"You appear to have cloned an empty MediaWiki.\\n\";\n \t\t# Something has to be done remote-helper side. If nothing is done, an error is\n \t\t# thrown saying that HEAD is referring to unknown object 0000000000000000000\n \t\t# and the clone fails.\n@@ -910,7 +910,7 @@ sub mw_import_revids {\n \t\tmy $page_title = $result_page->{title};\n \n \t\tif (!exists($pages->{$page_title})) {\n-\t\t\tprint STDERR \"${n}/\", scalar(@$revision_ids),\n+\t\t\tprint {*STDERR} \"${n}/\", scalar(@$revision_ids),\n \t\t\t\t\": Skipping revision #$rev->{revid} of ${page_title}\\n\";\n \t\t\tnext;\n \t\t}\n@@ -943,7 +943,7 @@ sub mw_import_revids {\n \t\t# If this is a revision of the media page for new version\n \t\t# of a file do one common commit for both file and media page.\n \t\t# Else do commit only for that page.\n-\t\tprint STDERR \"${n}/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n+\t\tprint {*STDERR} \"${n}/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n \t\timport_file_revision(\\%commit, ($fetch_from == 1), $n_actual, \\%mediafile);\n \t}\n \n@@ -957,11 +957,11 @@ sub error_non_fast_forward {\n \t\t# Native git-push would show this after the summary.\n \t\t# We can't ask it to display it cleanly, so print it\n \t\t# ourselves before.\n-\t\tprint STDERR \"To prevent you from losing history, non-fast-forward updates were rejected\\n\";\n-\t\tprint STDERR \"Merge the remote changes (e.g. 'git pull') before pushing again. See the\\n\";\n-\t\tprint STDERR \"'Note about fast-forwards' section of 'git push --help' for details.\\n\";\n+\t\tprint {*STDERR} \"To prevent you from losing history, non-fast-forward updates were rejected\\n\";\n+\t\tprint {*STDERR} \"Merge the remote changes (e.g. 'git pull') before pushing again. See the\\n\";\n+\t\tprint {*STDERR} \"'Note about fast-forwards' section of 'git push --help' for details.\\n\";\n \t}\n-\tprint STDOUT qq(error $_[0] \"non-fast-forward\"\\n);\n+\tprint {*STDOUT} qq(error $_[0] \"non-fast-forward\"\\n);\n \treturn 0;\n }\n \n@@ -975,8 +975,8 @@ sub mw_upload_file {\n \tmy $path = \"File:${complete_file_name}\";\n \tmy %hashFiles = get_allowed_file_extensions();\n \tif (!exists($hashFiles{$extension})) {\n-\t\tprint STDERR \"${complete_file_name} is not a permitted file on this wiki.\\n\";\n-\t\tprint STDERR \"Check the configuration of file uploads in your mediawiki.\\n\";\n+\t\tprint {*STDERR} \"${complete_file_name} is not a permitted file on this wiki.\\n\";\n+\t\tprint {*STDERR} \"Check the configuration of file uploads in your mediawiki.\\n\";\n \t\treturn $newrevid;\n \t}\n \t# Deleting and uploading a file requires a priviledged user\n@@ -988,9 +988,9 @@ sub mw_upload_file {\n \t\t\treason => $summary\n \t\t};\n \t\tif (!$mediawiki->edit($query)) {\n-\t\t\tprint STDERR \"Failed to delete file on remote wiki\\n\";\n-\t\t\tprint STDERR \"Check your permissions on the remote site. Error code:\\n\";\n-\t\t\tprint STDERR $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};\n+\t\t\tprint {*STDERR} \"Failed to delete file on remote wiki\\n\";\n+\t\t\tprint {*STDERR} \"Check your permissions on the remote site. Error code:\\n\";\n+\t\t\tprint {*STDERR} $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};\n \t\t\texit 1;\n \t\t}\n \t} else {\n@@ -1014,9 +1014,9 @@ sub mw_upload_file {\n \t\t\t\t . $mediawiki->{error}->{details} . \"\\n\";\n \t\t\tmy $last_file_page = $mediawiki->get_page({title => $path});\n \t\t\t$newrevid = $last_file_page->{revid};\n-\t\t\tprint STDERR \"Pushed file: ${new_sha1} - ${complete_file_name}.\\n\";\n+\t\t\tprint {*STDERR} \"Pushed file: ${new_sha1} - ${complete_file_name}.\\n\";\n \t\t} else {\n-\t\t\tprint STDERR \"Empty file ${complete_file_name} not pushed.\\n\";\n+\t\t\tprint {*STDERR} \"Empty file ${complete_file_name} not pushed.\\n\";\n \t\t}\n \t}\n \treturn $newrevid;\n@@ -1054,7 +1054,7 @@ sub mw_push_file {\n \tif ($extension eq 'mw') {\n \t\tmy $ns = get_mw_namespace_id_for_page($complete_file_name);\n \t\tif ($ns && $ns == get_mw_namespace_id('File') && (!$export_media)) {\n-\t\t\tprint STDERR \"Ignoring media file related page: ${complete_file_name}\\n\";\n+\t\t\tprint {*STDERR} \"Ignoring media file related page: ${complete_file_name}\\n\";\n \t\t\treturn ($oldrevid, 'ok');\n \t\t}\n \t\tmy $file_content;\n@@ -1082,7 +1082,7 @@ sub mw_push_file {\n \t\tif (!$result) {\n \t\t\tif ($mediawiki->{error}->{code} == 3) {\n \t\t\t\t# edit conflicts, considered as non-fast-forward\n-\t\t\t\tprint STDERR 'Warning: Error ' .\n+\t\t\t\tprint {*STDERR} 'Warning: Error ' .\n \t\t\t\t    $mediawiki->{error}->{code} .\n \t\t\t\t    ' from mediwiki: ' . $mediawiki->{error}->{details} .\n \t\t\t\t    \".\\n\";\n@@ -1095,13 +1095,13 @@ sub mw_push_file {\n \t\t\t}\n \t\t}\n \t\t$newrevid = $result->{edit}->{newrevid};\n-\t\tprint STDERR \"Pushed file: ${new_sha1} - ${title}\\n\";\n+\t\tprint {*STDERR} \"Pushed file: ${new_sha1} - ${title}\\n\";\n \t} elsif ($export_media) {\n \t\t$newrevid = mw_upload_file($complete_file_name, $new_sha1,\n \t\t\t\t\t   $extension, $page_deleted,\n \t\t\t\t\t   $summary);\n \t} else {\n-\t\tprint STDERR \"Ignoring media file ${title}\\n\";\n+\t\tprint {*STDERR} \"Ignoring media file ${title}\\n\";\n \t}\n \t$newrevid = ($newrevid or $oldrevid);\n \treturn ($newrevid, 'ok');\n@@ -1115,16 +1115,16 @@ sub mw_push {\n \t\tmy ($force, $local, $remote) = $refspec =~ /^(\\+)?([^:]*):([^:]*)$/\n \t\t    or die(\"Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\\n\");\n \t\tif ($force) {\n-\t\t\tprint STDERR \"Warning: forced push not allowed on a MediaWiki.\\n\";\n+\t\t\tprint {*STDERR} \"Warning: forced push not allowed on a MediaWiki.\\n\";\n \t\t}\n \t\tif ($local eq \"\") {\n-\t\t\tprint STDERR \"Cannot delete remote branch on a MediaWiki\\n\";\n-\t\t\tprint STDOUT \"error ${remote} cannot delete\\n\";\n+\t\t\tprint {*STDERR} \"Cannot delete remote branch on a MediaWiki\\n\";\n+\t\t\tprint {*STDOUT} \"error ${remote} cannot delete\\n\";\n \t\t\tnext;\n \t\t}\n \t\tif ($remote ne 'refs/heads/master') {\n-\t\t\tprint STDERR \"Only push to the branch 'master' is supported on a MediaWiki\\n\";\n-\t\t\tprint STDOUT \"error ${remote} only master allowed\\n\";\n+\t\t\tprint {*STDERR} \"Only push to the branch 'master' is supported on a MediaWiki\\n\";\n+\t\t\tprint {*STDOUT} \"error ${remote} only master allowed\\n\";\n \t\t\tnext;\n \t\t}\n \t\tif (mw_push_revision($local, $remote)) {\n@@ -1133,15 +1133,15 @@ sub mw_push {\n \t}\n \n \t# Notify Git that the push is done\n-\tprint STDOUT \"\\n\";\n+\tprint {*STDOUT} \"\\n\";\n \n \tif ($pushed && $dumb_push) {\n-\t\tprint STDERR \"Just pushed some revisions to MediaWiki.\\n\";\n-\t\tprint STDERR \"The pushed revisions now have to be re-imported, and your current branch\\n\";\n-\t\tprint STDERR \"needs to be updated with these re-imported commits. You can do this with\\n\";\n-\t\tprint STDERR \"\\n\";\n-\t\tprint STDERR \"  git pull --rebase\\n\";\n-\t\tprint STDERR \"\\n\";\n+\t\tprint {*STDERR} \"Just pushed some revisions to MediaWiki.\\n\";\n+\t\tprint {*STDERR} \"The pushed revisions now have to be re-imported, and your current branch\\n\";\n+\t\tprint {*STDERR} \"needs to be updated with these re-imported commits. You can do this with\\n\";\n+\t\tprint {*STDERR} \"\\n\";\n+\t\tprint {*STDERR} \"  git pull --rebase\\n\";\n+\t\tprint {*STDERR} \"\\n\";\n \t}\n \treturn;\n }\n@@ -1150,7 +1150,7 @@ sub mw_push_revision {\n \tmy $local = shift;\n \tmy $remote = shift; # actually, this has to be \"refs/heads/master\" at this point.\n \tmy $last_local_revid = get_last_local_revision();\n-\tprint STDERR \".\\n\"; # Finish sentence started by get_last_local_revision()\n+\tprint {*STDERR} \".\\n\"; # Finish sentence started by get_last_local_revision()\n \tmy $last_remote_revid = get_last_remote_revision();\n \tmy $mw_revision = $last_remote_revid;\n \n@@ -1177,7 +1177,7 @@ sub mw_push_revision {\n \tif ($last_local_revid > 0) {\n \t\tmy $parsed_sha1 = $remoteorigin_sha1;\n \t\t# Find a path from last MediaWiki commit to pushed commit\n-\t\tprint STDERR \"Computing path from local to remote ...\\n\";\n+\t\tprint {*STDERR} \"Computing path from local to remote ...\\n\";\n \t\tmy @local_ancestry = split(/\\n/, run_git(\"rev-list --boundary --parents ${local} ^${parsed_sha1}\"));\n \t\tmy %local_ancestry;\n \t\tforeach my $line (@local_ancestry) {\n@@ -1192,7 +1192,7 @@ sub mw_push_revision {\n \t\twhile ($parsed_sha1 ne $HEAD_sha1) {\n \t\t\tmy $child = $local_ancestry{$parsed_sha1};\n \t\t\tif (!$child) {\n-\t\t\t\tprintf STDERR \"Cannot find a path in history from remote commit to last commit\\n\";\n+\t\t\t\tprint {*STDERR} \"Cannot find a path in history from remote commit to last commit\\n\";\n \t\t\t\treturn error_non_fast_forward($remote);\n \t\t\t}\n \t\t\tpush(@commit_pairs, [$parsed_sha1, $child]);\n@@ -1201,7 +1201,7 @@ sub mw_push_revision {\n \t} else {\n \t\t# No remote mediawiki revision. Export the whole\n \t\t# history (linearized with --first-parent)\n-\t\tprint STDERR \"Warning: no common ancestor, pushing complete history\\n\";\n+\t\tprint {*STDERR} \"Warning: no common ancestor, pushing complete history\\n\";\n \t\tmy $history = run_git(\"rev-list --first-parent --children ${local}\");\n \t\tmy @history = split(/\\n/, $history);\n \t\t@history = @history[1..$#history];\n@@ -1249,7 +1249,7 @@ sub mw_push_revision {\n \t\t}\n \t}\n \n-\tprint STDOUT \"ok ${remote}\\n\";\n+\tprint {*STDOUT} \"ok ${remote}\\n\";\n \treturn 1;\n }\n \n@@ -1299,7 +1299,7 @@ sub get_mw_namespace_id {\n \t}\n \n \tif (!exists $namespace_id{$name}) {\n-\t\tprint STDERR \"Namespace ${name} not found in cache, querying the wiki ...\\n\";\n+\t\tprint {*STDERR} \"Namespace ${name} not found in cache, querying the wiki ...\\n\";\n \t\t# NS not found => get namespace id from MW and store it in\n \t        # configuration file.\n \t        my $query = {\n@@ -1324,7 +1324,7 @@ sub get_mw_namespace_id {\n \tmy $id;\n \n \tunless (defined $ns) {\n-\t\tprint STDERR \"No such namespace ${name} on MediaWiki.\\n\";\n+\t\tprint {*STDERR} \"No such namespace ${name} on MediaWiki.\\n\";\n \t\t$ns = {is_namespace => 0};\n \t\t$namespace_id{$name} = $ns;\n \t}\n-- \n1.7.9.5\n"},{"id":"220187","messageId":"1370816573-3808-25-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 24/28] git-remote-mediawiki: Replace \"unless\" statements with negated \"if\" statements","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:49Z","receivedAt":"2013-06-09T22:22:49Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 1cda460..bfb8a96 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -86,11 +86,11 @@ $shallow_import = ($shallow_import eq 'true');\n # - by_rev: perform one query per new revision on the remote wiki\n # - by_page: query each tracked page for new revision\n my $fetch_strategy = run_git(\"config --get remote.${remotename}.fetchStrategy\");\n-unless ($fetch_strategy) {\n+if (!$fetch_strategy) {\n \t$fetch_strategy = run_git('config --get mediawiki.fetchStrategy');\n }\n chomp($fetch_strategy);\n-unless ($fetch_strategy) {\n+if (!$fetch_strategy) {\n \t$fetch_strategy = 'by_page';\n }\n \n@@ -112,7 +112,7 @@ my %basetimestamps;\n # deterministic, this means everybody gets the same sha1 for each\n # MediaWiki revision.\n my $dumb_push = run_git(\"config --get --bool remote.${remotename}.dumbPush\");\n-unless ($dumb_push) {\n+if (!$dumb_push) {\n \t$dumb_push = run_git('config --get --bool mediawiki.dumbPush');\n }\n chomp($dumb_push);\n@@ -671,7 +671,7 @@ sub fetch_mw_revisions_for_page {\n \t\t\tpush(@page_revs, $page_rev_ids);\n \t\t\t$revnum++;\n \t\t}\n-\t\tlast unless $result->{'query-continue'};\n+\t\tlast if (!$result->{'query-continue'});\n \t\t$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};\n \t}\n \tif ($shallow_import && @page_revs) {\n@@ -1243,7 +1243,7 @@ sub mw_push_revision {\n \t\t\t\tdie(\"Unknown error from mw_push_file()\\n\");\n \t\t\t}\n \t\t}\n-\t\tunless ($dumb_push) {\n+\t\tif (!$dumb_push) {\n \t\t\trun_git(qq(notes --ref=${remotename}/mediawiki add -f -m \"mediawiki_revision: ${mw_revision}\" ${sha1_commit}));\n \t\t\trun_git(qq(update-ref -m \"Git-MediaWiki push\" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));\n \t\t}\n@@ -1323,7 +1323,7 @@ sub get_mw_namespace_id {\n \tmy $ns = $namespace_id{$name};\n \tmy $id;\n \n-\tunless (defined $ns) {\n+\tif (!defined $ns) {\n \t\tprint {*STDERR} \"No such namespace ${name} on MediaWiki.\\n\";\n \t\t$ns = {is_namespace => 0};\n \t\t$namespace_id{$name} = $ns;\n-- \n1.7.9.5\n"},{"id":"220186","messageId":"1370816573-3808-26-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 25/28] git-remote-mediawiki: Don't use quotes for empty strings","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:50Z","receivedAt":"2013-06-09T22:22:50Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Empty strings are replaced by an $EMPTY constant.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   18 ++++++++++--------\n 1 file changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex bfb8a96..45a8804 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -40,6 +40,8 @@ use constant NULL_SHA1 => '0000000000000000000000000000000000000000';\n # Used on Git's side to reflect empty edit messages on the wiki\n use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';\n \n+use constant EMPTY => q{};\n+\n if (@ARGV != 2) {\n \texit_error_usage();\n }\n@@ -164,11 +166,11 @@ sub parse_command {\n \t\tmw_list($cmd[1]);\n \t} elsif ($cmd[0] eq 'import') {\n \t\tdie(\"Invalid arguments for import\\n\")\n-\t\t    if ($cmd[1] eq \"\" || defined($cmd[2]));\n+\t\t    if ($cmd[1] eq EMPTY || defined($cmd[2]));\n \t\tmw_import($cmd[1]);\n \t} elsif ($cmd[0] eq 'option') {\n \t\tdie(\"Too many arguments for option\\n\")\n-\t\t    if ($cmd[1] eq \"\" || $cmd[2] eq \"\" || defined($cmd[3]));\n+\t\t    if ($cmd[1] eq EMPTY || $cmd[2] eq EMPTY || defined($cmd[3]));\n \t\tmw_option($cmd[1],$cmd[2]);\n \t} elsif ($cmd[0] eq 'push') {\n \t\tmw_push($cmd[1]);\n@@ -559,7 +561,7 @@ sub mediawiki_clean {\n \t# Mediawiki does not allow blank space at the end of a page and ends with a single \\n.\n \t# This function right trims a string and adds a \\n at the end to follow this rule\n \t$string =~ s/\\s+$//;\n-\tif ($string eq \"\" && $page_created) {\n+\tif ($string eq EMPTY && $page_created) {\n \t\t# Creating empty pages is forbidden.\n \t\t$string = EMPTY_CONTENT;\n \t}\n@@ -570,7 +572,7 @@ sub mediawiki_clean {\n sub mediawiki_smudge {\n \tmy $string = shift;\n \tif ($string eq EMPTY_CONTENT) {\n-\t\t$string = \"\";\n+\t\t$string = EMPTY;\n \t}\n \t# This \\n is important. This is due to mediawiki's way to handle end of files.\n \treturn \"${string}\\n\";\n@@ -996,7 +998,7 @@ sub mw_upload_file {\n \t} else {\n \t\t# Don't let perl try to interpret file content as UTF-8 => use \"raw\"\n \t\tmy $content = run_git(\"cat-file blob ${new_sha1}\", 'raw');\n-\t\tif ($content ne \"\") {\n+\t\tif ($content ne EMPTY) {\n \t\t\tmw_connect_maybe();\n \t\t\t$mediawiki->{config}->{upload_url} =\n \t\t\t\t\"${url}/index.php/Special:Upload\";\n@@ -1038,7 +1040,7 @@ sub mw_push_file {\n \tmy $newrevid;\n \n \tif ($summary eq EMPTY_MESSAGE) {\n-\t\t$summary = '';\n+\t\t$summary = EMPTY;\n \t}\n \n \tmy $new_sha1 = $diff_info_split[3];\n@@ -1049,7 +1051,7 @@ sub mw_push_file {\n \n \tmy ($title, $extension) = $complete_file_name =~ /^(.*)\\.([^\\.]*)$/;\n \tif (!defined($extension)) {\n-\t\t$extension = \"\";\n+\t\t$extension = EMPTY;\n \t}\n \tif ($extension eq 'mw') {\n \t\tmy $ns = get_mw_namespace_id_for_page($complete_file_name);\n@@ -1117,7 +1119,7 @@ sub mw_push {\n \t\tif ($force) {\n \t\t\tprint {*STDERR} \"Warning: forced push not allowed on a MediaWiki.\\n\";\n \t\t}\n-\t\tif ($local eq \"\") {\n+\t\tif ($local eq EMPTY) {\n \t\t\tprint {*STDERR} \"Cannot delete remote branch on a MediaWiki\\n\";\n \t\t\tprint {*STDOUT} \"error ${remote} cannot delete\\n\";\n \t\t\tnext;\n-- \n1.7.9.5\n"},{"id":"220188","messageId":"1370816573-3808-27-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 26/28] git-remote-mediawiki: Put non-trivial numeric values in constants.","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:51Z","receivedAt":"2013-06-09T22:22:51Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Non-trivial numeric values (e.g., different from 0, 1 and 2) are placed in\nconstants at the top of the code to be easily modifiable and to make more sense\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   20 ++++++++++++++------\n 1 file changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 45a8804..c2b1afd 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -42,6 +42,16 @@ use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';\n \n use constant EMPTY => q{};\n \n+# Number of pages taken into account at once in submodule get_mw_page_list\n+use constant SLICE_SIZE => 50;\n+\n+# Number of linked mediafile to get at once in get_linked_mediafiles\n+# The query is split in small batches because of the MW API limit of\n+# the number of links to be returned (500 links max).\n+use constant BATCH_SIZE => 10;\n+\n+use constant HTTP_CODE_OK => 200;\n+\n if (@ARGV != 2) {\n \texit_error_usage();\n }\n@@ -227,13 +237,13 @@ sub get_mw_page_list {\n \tmy $pages = shift;\n \tmy @some_pages = @$page_list;\n \twhile (@some_pages) {\n-\t\tmy $last_page = 50;\n+\t\tmy $last_page = SLICE_SIZE;\n \t\tif ($#some_pages < $last_page) {\n \t\t\t$last_page = $#some_pages;\n \t\t}\n \t\tmy @slice = @some_pages[0..$last_page];\n \t\tget_mw_first_pages(\\@slice, $pages);\n-\t\t@some_pages = @some_pages[51..$#some_pages];\n+\t\t@some_pages = @some_pages[(SLICE_SIZE + 1)..$#some_pages];\n \t}\n \treturn;\n }\n@@ -389,9 +399,7 @@ sub get_linked_mediafiles {\n \tmy $pages = shift;\n \tmy @titles = map { $_->{title} } values(%{$pages});\n \n-\t# The query is split in small batches because of the MW API limit of\n-\t# the number of links to be returned (500 links max).\n-\tmy $batch = 10;\n+\tmy $batch = BATCH_SIZE;\n \twhile (@titles) {\n \t\tif ($#titles < $batch) {\n \t\t\t$batch = $#titles;\n@@ -473,7 +481,7 @@ sub download_mw_mediafile {\n \tmy $download_url = shift;\n \n \tmy $response = $mediawiki->{ua}->get($download_url);\n-\tif ($response->code == 200) {\n+\tif ($response->code == HTTP_CODE_OK) {\n \t\treturn $response->decoded_content;\n \t} else {\n \t\tprint {*STDERR} \"Error downloading mediafile from :\\n\";\n-- \n1.7.9.5\n"},{"id":"220190","messageId":"1370816573-3808-28-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 27/28] git-remote-mediawiki: Fix a typo (\"mediwiki\" instead of \"mediawiki\")","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:52Z","receivedAt":"2013-06-09T22:22:52Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex c2b1afd..b0e540b 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -1094,14 +1094,14 @@ sub mw_push_file {\n \t\t\t\t# edit conflicts, considered as non-fast-forward\n \t\t\t\tprint {*STDERR} 'Warning: Error ' .\n \t\t\t\t    $mediawiki->{error}->{code} .\n-\t\t\t\t    ' from mediwiki: ' . $mediawiki->{error}->{details} .\n+\t\t\t\t    ' from mediawiki: ' . $mediawiki->{error}->{details} .\n \t\t\t\t    \".\\n\";\n \t\t\t\treturn ($oldrevid, 'non-fast-forward');\n \t\t\t} else {\n \t\t\t\t# Other errors. Shouldn't happen => just die()\n \t\t\t\tdie 'Fatal: Error ' .\n \t\t\t\t    $mediawiki->{error}->{code} .\n-\t\t\t\t    ' from mediwiki: ' . $mediawiki->{error}->{details} . \"\\n\";\n+\t\t\t\t    ' from mediawiki: ' . $mediawiki->{error}->{details} . \"\\n\";\n \t\t\t}\n \t\t}\n \t\t$newrevid = $result->{edit}->{newrevid};\n-- \n1.7.9.5\n"},{"id":"220185","messageId":"1370816573-3808-29-git-send-email-celestin.matte@ensimag.fr","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH v3 28/28] git-remote-mediawiki: Clearly rewrite double dereference","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-09T22:22:53Z","receivedAt":"2013-06-09T22:22:53Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"@$var structures are re-written in the following way: @{$var}\nIt makes them more readable.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |    8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex b0e540b..e0b2fd2 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -235,7 +235,7 @@ sub get_mw_tracked_pages {\n sub get_mw_page_list {\n \tmy $page_list = shift;\n \tmy $pages = shift;\n-\tmy @some_pages = @$page_list;\n+\tmy @some_pages = @{$page_list};\n \twhile (@some_pages) {\n \t\tmy $last_page = SLICE_SIZE;\n \t\tif ($#some_pages < $last_page) {\n@@ -885,7 +885,7 @@ sub mw_import_revids {\n \tmy $n_actual = 0;\n \tmy $last_timestamp = 0; # Placeholer in case $rev->timestamp is undefined\n \n-\tforeach my $pagerevid (@$revision_ids) {\n+\tforeach my $pagerevid (@{$revision_ids}) {\n \t        # Count page even if we skip it, since we display\n \t\t# $n/$total and $total includes skipped pages.\n \t\t$n++;\n@@ -920,7 +920,7 @@ sub mw_import_revids {\n \t\tmy $page_title = $result_page->{title};\n \n \t\tif (!exists($pages->{$page_title})) {\n-\t\t\tprint {*STDERR} \"${n}/\", scalar(@$revision_ids),\n+\t\t\tprint {*STDERR} \"${n}/\", scalar(@{$revision_ids}),\n \t\t\t\t\": Skipping revision #$rev->{revid} of ${page_title}\\n\";\n \t\t\tnext;\n \t\t}\n@@ -953,7 +953,7 @@ sub mw_import_revids {\n \t\t# If this is a revision of the media page for new version\n \t\t# of a file do one common commit for both file and media page.\n \t\t# Else do commit only for that page.\n-\t\tprint {*STDERR} \"${n}/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n+\t\tprint {*STDERR} \"${n}/\", scalar(@{$revision_ids}), \": Revision #$rev->{revid} of $commit{title}\\n\";\n \t\timport_file_revision(\\%commit, ($fetch_from == 1), $n_actual, \\%mediafile);\n \t}\n \n-- \n1.7.9.5\n"},{"id":"220219","messageId":"CAPig+cQWQ842-ZG3_JQxZ=-2qLPpijx9z3vtXns+G3xxp6PsyQ@mail.gmail.com","threadId":"34081","inReplyTo":"1370816573-3808-23-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-06-10T00:50:40Z","receivedAt":"2013-06-10T00:50:40Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jun 9, 2013 at 6:22 PM, Célestin Matte\n<celestin.matte@ensimag.fr> wrote:\n> - strings which don't need interpolation are single-quoted for more clarity and\n> slight gain of performance\n> - interpolation is preferred over concatenation in many cases, for more clarity\n> - variables are always used with the ${} operator inside strings\n> - strings including double-quotes are written with qq() so that the quotes do\n> not have to be escaped\n> ---\n> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\n> index a66cef4..efc376a 100755\n> --- a/contrib/mw-to-git/git-remote-mediawiki.perl\n> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n> @@ -200,10 +200,10 @@ sub mw_connect_maybe {\n>                                lgdomain => $wiki_domain};\n>                 if ($mediawiki->login($request)) {\n>                         Git::credential \\%credential, 'approve';\n> -                       print STDERR \"Logged in mediawiki user \\\"$credential{username}\\\".\\n\";\n> +                       print STDERR qq(Logged in mediawiki user \"$credential{username}\".\\n);\n\nGiven this patch's intention to use ${} within strings, should this be\n${credential{username}}?\n\n(I don't have a preference, but it's a genuine question since it's not\nclear if this was an oversight or intentional.)\n\n>                 } else {\n> -                       print STDERR \"Failed to log in mediawiki user \\\"$credential{username}\\\" on $url\\n\";\n> -                       print STDERR \"  (error \" .\n> +                       print STDERR qq(Failed to log in mediawiki user \"$credential{username}\" on ${url}\\n);\n\nDitto: ${credential{username}}\n\n> +                       print STDERR '  (error ' .\n>                                 $mediawiki->{error}->{code} . ': ' .\n>                                 $mediawiki->{error}->{details} . \")\\n\";\n>                         Git::credential \\%credential, 'reject';\n> @@ -347,10 +347,10 @@ sub get_mw_pages {\n>  #        $out = run_git(\"command args\", \"raw\"); # don't interpret output as UTF-8.\n>  sub run_git {\n>         my $args = shift;\n> -       my $encoding = (shift || \"encoding(UTF-8)\");\n> -       open(my $git, \"-|:$encoding\", \"git \" . $args)\n> -           or die \"Unable to open: $!\\n\";\n> -       my $res = do {\n> +       my $encoding = (shift || 'encoding(UTF-8)');\n> +       open(my $git, \"-|:${encoding}\", \"git ${args}\")\n> +           or die \"Unable to fork: $!\\n\";\n> +       my $res = do {\n\nThe whitespace-only change to line \"my $res = do {\" is effectively\nnoise. The reviewer has to stop and puzzle out what changed on the\nline before continuing with review of the remaining _real_ changes. It\nis a good idea to avoid noise changes if possible.\n\nIn this particular case, it's easy to avoid the noise since the\ntrailing space on that line could/should have been removed in patch\n18/28 when the statement was split over multiple lines.\n\n>                 local $/ = undef;\n>                 <$git>\n>         };\n> @@ -475,26 +475,26 @@ sub download_mw_mediafile {\n>                 return $response->decoded_content;\n>         } else {\n>                 print STDERR \"Error downloading mediafile from :\\n\";\n> -               print STDERR \"URL: $download_url\\n\";\n> -               print STDERR \"Server response: \" . $response->code . \" \" . $response->message . \"\\n\";\n> +               print STDERR \"URL: ${download_url}\\n\";\n> +               print STDERR 'Server response: ' . $response->code . q{ } . $response->message . \"\\n\";\n\nTo meet the goals of this patch, would you want to do this instead?\n\n    \"Server response: @{[$response->code]} @{[$response->message]}\\n\";\n\nWhether this is easier or more difficult to read is a matter of\nopinion. (Again, this is a genuine question rather than a show of\npreference on my part.)\n\n>                 exit 1;\n>         }\n>  }\n> @@ -691,8 +691,7 @@ sub fetch_mw_revisions {\n>         my $n = 1;\n>         foreach my $page (@pages) {\n>                 my $id = $page->{pageid};\n> -\n> -               print STDERR \"page $n/\", scalar(@pages), \": \". $page->{title} .\"\\n\";\n> +               print STDERR \"page ${n}/\", scalar(@pages), ': ', $page->{title}, \"\\n\";\n\nSimilarly:\n\n  \"page ${n}/@{[scalar(@pages)]}: @{[$page->{title}]}\\n\"\n\n>                 $n++;\n>                 my @page_revs = fetch_mw_revisions_for_page($page, $id, $fetch_from);\n>                 @revisions = (@page_revs, @revisions);\n> @@ -706,7 +705,7 @@ sub fe_escape_path {\n>         }\n> -       print STDOUT \"N inline :$n\\n\";\n> -       literal_data(\"mediawiki_revision: \" . $commit{mw_revision});\n> +       print STDOUT \"N inline :${n}\\n\";\n> +       literal_data(\"mediawiki_revision: $commit{mw_revision}\");\n\nAs questioned earlier, do you want ${commit{mw_revision}}?\n\n>         print STDOUT \"\\n\\n\";\n>         return;\n>  }\n> @@ -911,8 +910,8 @@ sub mw_import_revids {\n>                 my $page_title = $result_page->{title};\n>\n>                 if (!exists($pages->{$page_title})) {\n> -                       print STDERR \"$n/\", scalar(@$revision_ids),\n> -                               \": Skipping revision #$rev->{revid} of $page_title\\n\";\n> +                       print STDERR \"${n}/\", scalar(@$revision_ids),\n> +                               \": Skipping revision #$rev->{revid} of ${page_title}\\n\";\n\nSame question as above regarding formatting via \"@{[...]}\".\n\n>                         next;\n>                 }\n>\n> @@ -937,14 +936,14 @@ sub mw_import_revids {\n>                 # If this is a revision of the media page for new version\n>                 # of a file do one common commit for both file and media page.\n>                 # Else do commit only for that page.\n> -               print STDERR \"$n/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n> +               print STDERR \"${n}/\", scalar(@$revision_ids), \": Revision #$rev->{revid} of $commit{title}\\n\";\n\nDitto.\n\n>                 import_file_revision(\\%commit, ($fetch_from == 1), $n_actual, \\%mediafile);\n>         }\n"},{"id":"220220","messageId":"CAPig+cR1=32TwatmTdVBDnkpkhwtUNyKL_Z9f=V_FPtt_Y-xiA@mail.gmail.com","threadId":"34081","inReplyTo":"1370816573-3808-1-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH v3 00/28] Follow perlcritic's recommandations","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-06-10T01:09:52Z","receivedAt":"2013-06-10T01:09:52Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jun 9, 2013 at 6:22 PM, Célestin Matte\n<celestin.matte@ensimag.fr> wrote:\n> Changes with v2:\n> - Remove patch [02/22] about using the Readonly module\n> - Split commit [07/22] into 5 different ones\n\nThis was easier to review after being split. Thanks.\n\n> - Split commit [14/22] into 2 different ones\n> - Patch [17/22] was *not* split: tell me if it is necessary\n\n[now patch 22/28]\n\nYou, Matthieu, and Junio should decide, but I again found it\ntime-consuming and onerous to review with all the changes mashed\ntogether.\n\n> - Remove wrong change in patch [22/22]\n>\n> Patch about fixing a bug in a regexp (with has been renames \"Make a regexp\n> clearer\"), which had been sent as a separate patch, is reintegrated into this\n> series of patches.\n\nOverall, this series was more pleasant and easy to read than previous\nversions. With the exception of minor comments, questions, and the\nwhitespace noise in 22/28, I did not spot any issues worth mentioning\nin the remainder of the series.\n"},{"id":"220259","messageId":"vpqppvuqsg4.fsf@anie.imag.fr","threadId":"34081","inReplyTo":"1370816573-3808-10-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH v3 09/28] git-remote-mediawiki: Change the behaviour of a split","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-10T08:29:47Z","receivedAt":"2013-06-10T08:29:47Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> A \"split ' '\" is turned into a \"split / /\", which changes its behaviour: the\n> old method matched a run of whtespaces (/\\s*/)\n\nIt case there's a v4: whtespaces -> whitespaces.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220261","messageId":"vpqk3m2qs2r.fsf@anie.imag.fr","threadId":"34081","inReplyTo":"1370816573-3808-23-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-10T08:37:48Z","receivedAt":"2013-06-10T08:37:48Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> @@ -1285,8 +1285,7 @@ sub get_mw_namespace_id {\n>  \t\t# Look at configuration file, if the record for that namespace is\n>  \t\t# already cached. Namespaces are stored in form:\n>  \t\t# \"Name_of_namespace:Id_namespace\", ex.: \"File:6\".\n> -\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.\"\n> -\t\t\t\t\t\t. $remotename .\".namespaceCache\"));\n> +\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n\nI tend to prefer the former, as it avoids long lines (> 80 columns)\n\n> @@ -1339,8 +1338,7 @@ sub get_mw_namespace_id {\n>  \n>  \t# Store explicitely requested namespaces on disk\n>  \tif (!exists $cached_mw_namespace_id{$name}) {\n> -\t\trun_git(\"config --add remote.\". $remotename\n> -\t\t\t.\".namespaceCache \\\"\". $name .\":\". $store_id .\"\\\"\");\n> +\t\trun_git(qq(config --add remote.${remotename}.namespaceCache \"${name}:${store_id}\"));\n\nSame.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220263","messageId":"vpq7gi2qrnz.fsf@anie.imag.fr","threadId":"34081","inReplyTo":"CAPig+cR1=32TwatmTdVBDnkpkhwtUNyKL_Z9f=V_FPtt_Y-xiA@mail.gmail.com","subject":"Re: [PATCH v3 00/28] Follow perlcritic's recommandations","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-10T08:46:40Z","receivedAt":"2013-06-10T08:46:40Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Sun, Jun 9, 2013 at 6:22 PM, Célestin Matte\n> <celestin.matte@ensimag.fr> wrote:\n>> Changes with v2:\n>> - Remove patch [02/22] about using the Readonly module\n>> - Split commit [07/22] into 5 different ones\n>\n> This was easier to review after being split. Thanks.\n>\n>> - Split commit [14/22] into 2 different ones\n>> - Patch [17/22] was *not* split: tell me if it is necessary\n>\n> [now patch 22/28]\n>\n> You, Matthieu, and Junio should decide, but I again found it\n> time-consuming and onerous to review with all the changes mashed\n> together.\n\nI agree that it would have been better to split the patches in v1, but\nnow that we've already spent time reviewing it, it seems unecessary to\nspend more time splitting and re-reviewing.\n\nI went through the series once more, all my remarks are minor. I'm OK\nwith the series as it is (i.e. perhaps it's time to say \"stop the\nbikeshedding and start coding real stuff\" ;-) ). As a reminder: Celestin\nis in a school project that ends in a week. The goal is both to be\nproductive and to learn stuff.\n\nIn any case, thanks a lot for your review, Eric.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220269","messageId":"51B5AEE6.8010102@ensimag.fr","threadId":"34081","inReplyTo":"CAPig+cQWQ842-ZG3_JQxZ=-2qLPpijx9z3vtXns+G3xxp6PsyQ@mail.gmail.com","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-10T10:48:06Z","receivedAt":"2013-06-10T10:48:06Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Le 10/06/2013 02:50, Eric Sunshine a écrit :\n> Given this patch's intention to use ${} within strings, should this be\n> ${credential{username}}?\n> \n> (I don't have a preference, but it's a genuine question since it's not\n> clear if this was an oversight or intentional.)\n\nThe answer is simple: I didn't know the exact syntax, so I didn't bother\ndoing it.\n\n\n> The whitespace-only change to line \"my $res = do {\" is effectively\n> noise. The reviewer has to stop and puzzle out what changed on the\n> line before continuing with review of the remaining _real_ changes. It\n> is a good idea to avoid noise changes if possible.\n> \n> In this particular case, it's easy to avoid the noise since the\n> trailing space on that line could/should have been removed in patch\n> 18/28 when the statement was split over multiple lines.\n\nActually, I noticed this but didn't find what the difference between the\ntwo lines was. I assumed git was making some kind of mistake - but eh,\nit seems git is never wrong :)\n\n>>                 local $/ = undef;\n>>                 <$git>\n>>         };\n>> @@ -475,26 +475,26 @@ sub download_mw_mediafile {\n>>                 return $response->decoded_content;\n>>         } else {\n>>                 print STDERR \"Error downloading mediafile from :\\n\";\n>> -               print STDERR \"URL: $download_url\\n\";\n>> -               print STDERR \"Server response: \" . $response->code . \" \" . $response->message . \"\\n\";\n>> +               print STDERR \"URL: ${download_url}\\n\";\n>> +               print STDERR 'Server response: ' . $response->code . q{ } . $response->message . \"\\n\";\n> \n> To meet the goals of this patch, would you want to do this instead?\n> \n>     \"Server response: @{[$response->code]} @{[$response->message]}\\n\";\n> \n> Whether this is easier or more difficult to read is a matter of\n> opinion. (Again, this is a genuine question rather than a show of\n> preference on my part.)\n\nSame as above, I tried to change it but didn't know the exact syntax, so\nI gave up.\n\n\n-- \nCélestin Matte\n"},{"id":"220270","messageId":"51B5B1B6.4000206@ensimag.fr","threadId":"34081","inReplyTo":"vpqk3m2qs2r.fsf@anie.imag.fr","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-10T11:00:06Z","receivedAt":"2013-06-10T11:00:06Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Le 10/06/2013 10:37, Matthieu Moy a écrit :\n> Célestin Matte <celestin.matte@ensimag.fr> writes:\n> \n>> @@ -1285,8 +1285,7 @@ sub get_mw_namespace_id {\n>>  \t\t# Look at configuration file, if the record for that namespace is\n>>  \t\t# already cached. Namespaces are stored in form:\n>>  \t\t# \"Name_of_namespace:Id_namespace\", ex.: \"File:6\".\n>> -\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.\"\n>> -\t\t\t\t\t\t. $remotename .\".namespaceCache\"));\n>> +\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n> \n> I tend to prefer the former, as it avoids long lines (> 80 columns)\n\nThe 80-columns rule is already broken in *many* places in this file.\nI know this is not a valid reason to do it more often, but in my opinion\nthe second version is easier to read (it's easy to miss the dots in the\nfirst version), so we would gain from the change.\n\n\n-- \nCélestin Matte\n"},{"id":"220318","messageId":"7vhah5kje8.fsf@alter.siamese.dyndns.org","threadId":"34081","inReplyTo":"vpqk3m2qs2r.fsf@anie.imag.fr","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-10T16:41:51Z","receivedAt":"2013-06-10T16:41:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Célestin Matte <celestin.matte@ensimag.fr> writes:\n>\n>> @@ -1285,8 +1285,7 @@ sub get_mw_namespace_id {\n>>  \t\t# Look at configuration file, if the record for that namespace is\n>>  \t\t# already cached. Namespaces are stored in form:\n>>  \t\t# \"Name_of_namespace:Id_namespace\", ex.: \"File:6\".\n>> -\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.\"\n>> -\t\t\t\t\t\t. $remotename .\".namespaceCache\"));\n>> +\t\tmy @temp = split(/\\n/, run_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n>\n> I tend to prefer the former, as it avoids long lines (> 80 columns)\n\nBut you split the name of a single variable across lines by doing so.\n\nYou could split lines to make it a bit more readable.\n\n\t\tmy @temp = split(/\\n/,\n\t\t\trun_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n\nIt still overflows the 80-column limit, but the \"namespaceCache\" is\nthe only thing that overflows; not much harm is done.\n\nThis is totally outside of the topic of \"coding-style\" series, but I\nwould be more concerned about the use of ${remotename}, though.  Has\nit (and in general the parameters to all calls to run_git()) been\nsanitized for shell metacharacters?  If we had a variant of run_git\nthat took an array of command line arguments given to git, you could\ndo this\n\n\t\tmy @temp = split(/\\n/,\n\t\t\trun_git([qw(config --get-all),\n                        \t\"remote.${remotename}.namespaceCache\")]);\n\nwhich would be safer and easier to read.\n\n>> @@ -1339,8 +1338,7 @@ sub get_mw_namespace_id {\n>>  \n>>  \t# Store explicitely requested namespaces on disk\n>>  \tif (!exists $cached_mw_namespace_id{$name}) {\n>> -\t\trun_git(\"config --add remote.\". $remotename\n>> -\t\t\t.\".namespaceCache \\\"\". $name .\":\". $store_id .\"\\\"\");\n>> +\t\trun_git(qq(config --add remote.${remotename}.namespaceCache \"${name}:${store_id}\"));\n>\n> Same.\n"},{"id":"220325","messageId":"CAETqRCh2OLq=gj-fEGrO1vyQQfTJNAFp_z_Bf0sirbBgRKPrdw@mail.gmail.com","threadId":"34081","inReplyTo":"7vhah5kje8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Benoît Person","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-10T17:18:39Z","receivedAt":"2013-06-10T17:18:39Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"Well, I think next step would be to replace all those calls with\nGit.pm `command`, `command_oneline` and `config``which take an array\nof arguments after the \"command\". In the preview tool we use those but\nI don't know if we will find the time to clean that up too in\ngit-remote-mediawiki :) .\n\nDon't know though if it's better to mix that with this serie which is\nmainly based on what perlcritic returns.\n\nOn 10 June 2013 18:41, Junio C Hamano <gitster@pobox.com> wrote:\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> Célestin Matte <celestin.matte@ensimag.fr> writes:\n>>\n>>> @@ -1285,8 +1285,7 @@ sub get_mw_namespace_id {\n>>>              # Look at configuration file, if the record for that namespace is\n>>>              # already cached. Namespaces are stored in form:\n>>>              # \"Name_of_namespace:Id_namespace\", ex.: \"File:6\".\n>>> -            my @temp = split(/\\n/, run_git(\"config --get-all remote.\"\n>>> -                                            . $remotename .\".namespaceCache\"));\n>>> +            my @temp = split(/\\n/, run_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n>>\n>> I tend to prefer the former, as it avoids long lines (> 80 columns)\n>\n> But you split the name of a single variable across lines by doing so.\n>\n> You could split lines to make it a bit more readable.\n>\n>                 my @temp = split(/\\n/,\n>                         run_git(\"config --get-all remote.${remotename}.namespaceCache\"));\n>\n> It still overflows the 80-column limit, but the \"namespaceCache\" is\n> the only thing that overflows; not much harm is done.\n>\n> This is totally outside of the topic of \"coding-style\" series, but I\n> would be more concerned about the use of ${remotename}, though.  Has\n> it (and in general the parameters to all calls to run_git()) been\n> sanitized for shell metacharacters?  If we had a variant of run_git\n> that took an array of command line arguments given to git, you could\n> do this\n>\n>                 my @temp = split(/\\n/,\n>                         run_git([qw(config --get-all),\n>                                 \"remote.${remotename}.namespaceCache\")]);\n>\n> which would be safer and easier to read.\n>\n>>> @@ -1339,8 +1338,7 @@ sub get_mw_namespace_id {\n>>>\n>>>      # Store explicitely requested namespaces on disk\n>>>      if (!exists $cached_mw_namespace_id{$name}) {\n>>> -            run_git(\"config --add remote.\". $remotename\n>>> -                    .\".namespaceCache \\\"\". $name .\":\". $store_id .\"\\\"\");\n>>> +            run_git(qq(config --add remote.${remotename}.namespaceCache \"${name}:${store_id}\"));\n>>\n>> Same.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"220330","messageId":"vpqa9mxeuvf.fsf@anie.imag.fr","threadId":"34081","inReplyTo":"CAETqRCh2OLq=gj-fEGrO1vyQQfTJNAFp_z_Bf0sirbBgRKPrdw@mail.gmail.com","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-10T17:30:28Z","receivedAt":"2013-06-10T17:30:28Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Please, don't top-post. Quote the part of the message you're replying\nto, and reply below.\n\nBenoît Person <benoit.person@ensimag.fr> writes:\n\n> Well, I think next step would be to replace all those calls with\n> Git.pm `command`, `command_oneline` and `config``which take an array\n> of arguments after the \"command\". In the preview tool we use those but\n> I don't know if we will find the time to clean that up too in\n> git-remote-mediawiki :) .\n\nAgreed. run_git was written to avoid having to depend on Git.pm, but now\nthat we do, we should do it the Git.pm way (although this is not a\nhigh priority for now).\n\n> Don't know though if it's better to mix that with this serie which is\n> mainly based on what perlcritic returns.\n\nIf you go this way, I'd rather have it on top (i.e. a separate patch\nseries).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220359","messageId":"7vsj0phjt4.fsf@alter.siamese.dyndns.org","threadId":"34081","inReplyTo":"vpqa9mxeuvf.fsf@anie.imag.fr","subject":"Re: [PATCH v3 22/28] git-remote-mediawiki: Modify strings for a better coding-style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-10T19:01:11Z","receivedAt":"2013-06-10T19:01:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Please, don't top-post. Quote the part of the message you're replying\n> to, and reply below.\n>\n> Benoît Person <benoit.person@ensimag.fr> writes:\n>\n>> Well, I think next step would be to replace all those calls with\n>> Git.pm `command`, `command_oneline` and `config``which take an array\n>> of arguments after the \"command\". In the preview tool we use those but\n>> I don't know if we will find the time to clean that up too in\n>> git-remote-mediawiki :) .\n>\n> Agreed. run_git was written to avoid having to depend on Git.pm, but now\n> that we do, we should do it the Git.pm way (although this is not a\n> high priority for now).\n>\n>> Don't know though if it's better to mix that with this serie which is\n>> mainly based on what perlcritic returns.\n>\n> If you go this way, I'd rather have it on top (i.e. a separate patch\n> series).\n\nOr not worry too much about it in the 3-week long school project.\nFinish one that you started and then build on top.\n"},{"id":"220430","messageId":"51B71E1E.8020103@ensimag.fr","threadId":"34081","inReplyTo":"vpq7gi2qrnz.fsf@anie.imag.fr","subject":"Re: [PATCH v3 00/28] Follow perlcritic's recommandations","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-11T12:54:54Z","receivedAt":"2013-06-11T12:54:54Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"So, do I send a last version of the patch? What is left is quick fix:\n- removing whitespace in [18/28]\n- typo in [09/28]\n- better line split in [22/28]\nI already fixed first two problems, so it would be done rapidly.\n\n-- \nCélestin Matte\n"},{"id":"220447","messageId":"7vsj0od6z5.fsf@alter.siamese.dyndns.org","threadId":"34081","inReplyTo":"1370816573-3808-8-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-11T15:04:14Z","receivedAt":"2013-06-11T15:04:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> Subroutines' parameters should be affected to variable before doing anything\n> else\n> Besides, existing instruction affected a variable inside a \"if\", which break\n> Git's coding style\n\nI think s/affect/assign/g is what you meant.\n\nBy the way, I often see two styles of the \"let's take arguments into\nparameters before doing anything else\" at the beginning of subs:\n\n        my ($namespace) = @_;\n\tmy $namespace = shift;\n\nMy impression has been that both are equally common, but the latter\nis done more often when picking out small and fixed number of\nmandatory parameters upfront (and later, optional parameters are\nused by directly reading what remains in @_).  Does Perlcritique say\nanything about this issue?\n\n> Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\n> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> ---\n>  contrib/mw-to-git/git-remote-mediawiki.perl |    3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\n> index 431e063..2db6467 100755\n> --- a/contrib/mw-to-git/git-remote-mediawiki.perl\n> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n> @@ -1333,7 +1333,8 @@ sub get_mw_namespace_id {\n>  }\n>  \n>  sub get_mw_namespace_id_for_page {\n> -\tif (my ($namespace) = $_[0] =~ /^([^:]*):/) {\n> +\tmy $namespace = shift;\n> +\tif ($namespace =~ /^([^:]*):/) {\n>  \t\treturn get_mw_namespace_id($namespace);\n>  \t} else {\n>  \t\treturn;\n"},{"id":"220451","messageId":"7vli6gd582.fsf@alter.siamese.dyndns.org","threadId":"34081","inReplyTo":"1370816573-3808-22-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH v3 21/28] git-remote-mediawiki: Put long code into a subroutine","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-11T15:42:05Z","receivedAt":"2013-06-11T15:42:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>\n> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> ---\n>  contrib/mw-to-git/git-remote-mediawiki.perl |   50 +++++++++++++++++----------\n>  1 file changed, 31 insertions(+), 19 deletions(-)\n>\n> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\n> index c404e7b..a66cef4 100755\n> --- a/contrib/mw-to-git/git-remote-mediawiki.perl\n> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n> @@ -126,28 +126,13 @@ $wiki_name =~ s{[^/]*://}{};\n>  $wiki_name =~ s/^.*@//;\n>  \n>  # Commands parser\n> -my @cmd;\n> +my @cmds;\n\nI am guessing that the new sub, parse_command, uses a local @cmd and\nthis is an attempt to avoid using the same name, but this renaming\nof the variable is not explained.\n\nI also wonder if you need this global @cmd/@cmds.  Instead of\npassing cmdref, wouldn't it be simpler to have the helper split the\nline, i.e. something like...\n\n\tsub parse_command {\n\t\tmy ($line) = @_;\n                my @cmd = split(/ /, $line);\n\t\tunless (defined @cmd) {\n\t                return 0;\n\t\t}\n                ... check capabilities, list, etc....\n\t\treturn 1;\n\t}\n\n        while (<STDIN>) {\n        \tchomp;\n                if (!parse_command($_)) {\n\t\t\tunknown command, aborting\n                        last;\n\t\t}\n\t}\n"},{"id":"220458","messageId":"vpq1u8838rv.fsf@anie.imag.fr","threadId":"34081","inReplyTo":"7vsj0od6z5.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-11T16:35:32Z","receivedAt":"2013-06-11T16:35:32Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Célestin Matte <celestin.matte@ensimag.fr> writes:\n>\n>> Subroutines' parameters should be affected to variable before doing anything\n>> else\n>> Besides, existing instruction affected a variable inside a \"if\", which break\n>> Git's coding style\n>\n> I think s/affect/assign/g is what you meant.\n\nYes, common false friends for French people ;-).\n\n>       my ($namespace) = @_;\n> \tmy $namespace = shift;\n>\n> My impression has been that both are equally common,\n\nThe second is the most common in git-remote-mediawiki (but I don't have\nany preference nor know what is recommended elsewhere).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220477","messageId":"7vhah4bjtf.fsf@alter.siamese.dyndns.org","threadId":"34081","inReplyTo":"vpq1u8838rv.fsf@anie.imag.fr","subject":"Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-11T18:09:48Z","receivedAt":"2013-06-11T18:09:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n>>       my ($namespace) = @_;\n>> \tmy $namespace = shift;\n>>\n>> My impression has been that both are equally common,\n>\n> The second is the most common in git-remote-mediawiki (but I don't have\n> any preference nor know what is recommended elsewhere).\n\nI wasn't implying I prefer the former.  I was just being curious,\nand if the latter is more prevalent in the code _and_ Perlcritique\ndoes not have any issue with it, it is perfectly fine.\n\nThanks.\n"},{"id":"220507","messageId":"51B784E8.8020700@ensimag.fr","threadId":"34081","inReplyTo":"7vhah4bjtf.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-11T20:13:28Z","receivedAt":"2013-06-11T20:13:28Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Le 11/06/2013 20:09, Junio C Hamano a écrit :\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n> \n>>>       my ($namespace) = @_;\n>>> \tmy $namespace = shift;\n>>>\n>>> My impression has been that both are equally common,\n>>\n>> The second is the most common in git-remote-mediawiki (but I don't have\n>> any preference nor know what is recommended elsewhere).\n> \n> I wasn't implying I prefer the former.  I was just being curious,\n> and if the latter is more prevalent in the code _and_ Perlcritique\n> does not have any issue with it, it is perfectly fine.\n\nPerlcritic doesn't have an issue with any of both cases.\nI think the second method is clearer when there is only one argument,\nbecause it makes it clear that there is only one.\n\n-- \nCélestin Matte\n"},{"id":"220528","messageId":"7vwqq08g7u.fsf@alter.siamese.dyndns.org","threadId":"34081","inReplyTo":"51B784E8.8020700@ensimag.fr","subject":"Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-11T21:55:49Z","receivedAt":"2013-06-11T21:55:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> Le 11/06/2013 20:09, Junio C Hamano a écrit :\n>> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>> \n>>>>       my ($namespace) = @_;\n>>>> \tmy $namespace = shift;\n>>>>\n>>>> My impression has been that both are equally common,\n>>>\n>>> The second is the most common in git-remote-mediawiki (but I don't have\n>>> any preference nor know what is recommended elsewhere).\n>> \n>> I wasn't implying I prefer the former.  I was just being curious,\n>> and if the latter is more prevalent in the code _and_ Perlcritique\n>> does not have any issue with it, it is perfectly fine.\n>\n> Perlcritic doesn't have an issue with any of both cases.\n\nOK.  As this topic is about matching the opinion of Perlcritique, I\nthink it is fine either way (which was the primary thing that I\nwanted to find out).\n\n> I think the second method is clearer when there is only one argument,\n> because it makes it clear that there is only one.\n\nHmm, from the maintenance point of view, the second one invites the\nnext person to extend this function like this:\n\n\tmy $namespace = shift;\n+       my $newargument = shift;\n+\tmy $anotherargument = shift;\n\nIf your original were in the first style, instead you would likely to\nget this:\n\n-\tmy ($namespace) = @_;\n+\tmy ($namespace, $newargument, $anotherargument) = @_;\n\nWhen there is only one argument, it is clear that there is only one\nargument in either style.  It is not a strong factor to pick one\nstyle over the other.  Once you start taking more than one argument,\nhowever, I think \"it makes it clear what arguments the function\ntakes\" would actually favor the style to split @_ into a list of\nlocal variables.\n\nBut as I said earlier, this patch is about following Perlcritique's\nadvice, and because it does not have opinion on these styles, it is\noutside the scope of this patch.\n\nThanks for checking.\n"},{"id":"220566","messageId":"51B7A3AB.5090803@ensimag.fr","threadId":"34081","inReplyTo":"7vli6gd582.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 21/28] git-remote-mediawiki: Put long code into a subroutine","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-11T22:24:43Z","receivedAt":"2013-06-11T22:24:43Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Oops, forgot to take this into account before sending v4 of my series of\npatch. I just noticed that, sorry...\n\nLe 11/06/2013 17:42, Junio C Hamano a écrit :\n> I am guessing that the new sub, parse_command, uses a local @cmd and\n> this is an attempt to avoid using the same name, but this renaming\n> of the variable is not explained.\n\nThis is indeed what I intended to do.\n\n> I also wonder if you need this global @cmd/@cmds.  Instead of\n> passing cmdref, wouldn't it be simpler to have the helper split the\n> line, i.e. something like...\n> \n> \tsub parse_command {\n> \t\tmy ($line) = @_;\n>                 my @cmd = split(/ /, $line);\n> \t\tunless (defined @cmd) {\n> \t                return 0;\n> \t\t}\n>                 ... check capabilities, list, etc....\n> \t\treturn 1;\n> \t}\n> \n>         while (<STDIN>) {\n>         \tchomp;\n>                 if (!parse_command($_)) {\n> \t\t\tunknown command, aborting\n>                         last;\n> \t\t}\n> \t}\n> \n> \n\n\n-- \nCélestin Matte\n"}]}