From: "Célestin Matte" <celestin.matte@ensimag.fr>
To: git@vger.kernel.org
Cc: benoit.person@ensimag.fr, matthieu.moy@grenoble-inp.fr,
"Célestin Matte" <celestin.matte@ensimag.fr>
Subject: [PATCH v5 25/31] git-remote-mediawiki: Don't use quotes for empty strings
Date: Wed, 12 Jun 2013 17:43:42 +0200 [thread overview]
Message-ID: <1371051828-12866-26-git-send-email-celestin.matte@ensimag.fr> (raw)
In-Reply-To: <1371051828-12866-1-git-send-email-celestin.matte@ensimag.fr>
Empty strings are replaced by an $EMPTY constant.
Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
---
contrib/mw-to-git/git-remote-mediawiki.perl | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 3f04d14..209dbe1 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -40,6 +40,8 @@ use constant NULL_SHA1 => '0000000000000000000000000000000000000000';
# Used on Git's side to reflect empty edit messages on the wiki
use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
+use constant EMPTY => q{};
+
if (@ARGV != 2) {
exit_error_usage();
}
@@ -160,11 +162,11 @@ sub parse_command {
mw_list($cmd[1]);
} elsif ($cmd[0] eq 'import') {
die("Invalid arguments for import\n")
- if ($cmd[1] eq "" || defined($cmd[2]));
+ if ($cmd[1] eq EMPTY || defined($cmd[2]));
mw_import($cmd[1]);
} elsif ($cmd[0] eq 'option') {
die("Too many arguments for option\n")
- if ($cmd[1] eq "" || $cmd[2] eq "" || defined($cmd[3]));
+ if ($cmd[1] eq EMPTY || $cmd[2] eq EMPTY || defined($cmd[3]));
mw_option($cmd[1],$cmd[2]);
} elsif ($cmd[0] eq 'push') {
mw_push($cmd[1]);
@@ -555,7 +557,7 @@ sub mediawiki_clean {
# Mediawiki does not allow blank space at the end of a page and ends with a single \n.
# This function right trims a string and adds a \n at the end to follow this rule
$string =~ s/\s+$//;
- if ($string eq "" && $page_created) {
+ if ($string eq EMPTY && $page_created) {
# Creating empty pages is forbidden.
$string = EMPTY_CONTENT;
}
@@ -566,7 +568,7 @@ sub mediawiki_clean {
sub mediawiki_smudge {
my $string = shift;
if ($string eq EMPTY_CONTENT) {
- $string = "";
+ $string = EMPTY;
}
# This \n is important. This is due to mediawiki's way to handle end of files.
return "${string}\n";
@@ -992,7 +994,7 @@ sub mw_upload_file {
} else {
# Don't let perl try to interpret file content as UTF-8 => use "raw"
my $content = run_git("cat-file blob ${new_sha1}", 'raw');
- if ($content ne "") {
+ if ($content ne EMPTY) {
mw_connect_maybe();
$mediawiki->{config}->{upload_url} =
"${url}/index.php/Special:Upload";
@@ -1034,7 +1036,7 @@ sub mw_push_file {
my $newrevid;
if ($summary eq EMPTY_MESSAGE) {
- $summary = '';
+ $summary = EMPTY;
}
my $new_sha1 = $diff_info_split[3];
@@ -1045,7 +1047,7 @@ sub mw_push_file {
my ($title, $extension) = $complete_file_name =~ /^(.*)\.([^\.]*)$/;
if (!defined($extension)) {
- $extension = "";
+ $extension = EMPTY;
}
if ($extension eq 'mw') {
my $ns = get_mw_namespace_id_for_page($complete_file_name);
@@ -1113,7 +1115,7 @@ sub mw_push {
if ($force) {
print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
}
- if ($local eq "") {
+ if ($local eq EMPTY) {
print {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
print {*STDOUT} "error ${remote} cannot delete\n";
next;
--
1.8.3.rc3.18.g21a7b2c
next prev parent reply other threads:[~2013-06-12 15:44 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-12 15:43 [PATCH v5 00/31] Follow perlcritic's recommandations Célestin Matte
2013-06-12 15:43 ` [PATCH v5 01/31] git-remote-mediawiki: Make a regexp clearer Célestin Matte
2013-06-12 15:43 ` [PATCH v5 02/31] git-remote-mediawiki: Move "use warnings;" before any instruction Célestin Matte
2013-06-12 15:43 ` [PATCH v5 03/31] git-remote-mediawiki: Replace :utf8 by :encoding(UTF-8) Célestin Matte
2013-06-12 15:43 ` [PATCH v5 04/31] git-remote-mediawiki: Always end a subroutine with a return Célestin Matte
2013-06-12 15:43 ` [PATCH v5 05/31] git-remote-mediawiki: Move a variable declaration at the top of the code Célestin Matte
2013-06-12 15:43 ` [PATCH v5 06/31] git-remote-mediawiki: Change syntax of map calls Célestin Matte
2013-06-12 15:43 ` [PATCH v5 07/31] git-remote-mediawiki: Rewrite unclear line of instructions Célestin Matte
2013-06-12 15:43 ` [PATCH v5 08/31] git-remote-mediawiki: Remove useless regexp modifier (m) Célestin Matte
2013-06-12 15:43 ` [PATCH v5 09/31] git-remote-mediawiki: Change the behaviour of a split Célestin Matte
2013-06-12 15:43 ` [PATCH v5 10/31] git-remote-mediawiki: Change separator of some regexps Célestin Matte
2013-06-12 15:43 ` [PATCH v5 11/31] git-remote-mediawiki: Change style in a regexp Célestin Matte
2013-06-12 15:43 ` [PATCH v5 12/31] " Célestin Matte
2013-06-12 15:43 ` [PATCH v5 13/31] git-remote-mediawiki: Add newline in the end of die() error messages Célestin Matte
2013-06-12 15:43 ` [PATCH v5 14/31] git-remote-mediawiki: Change the name of a variable Célestin Matte
2013-06-12 15:43 ` [PATCH v5 15/31] git-remote-mediawiki: Turn double-negated expressions into simple expressions Célestin Matte
2013-06-12 15:43 ` [PATCH v5 16/31] git-remote-mediawiki: Remove unused variable $entry Célestin Matte
2013-06-12 15:43 ` [PATCH v5 17/31] git-remote-mediawiki: Rename a variable ($last) which has the name of a keyword Célestin Matte
2013-06-12 15:43 ` [PATCH v5 18/31] git-remote-mediawiki: Assign a variable as undef and make proper indentation Célestin Matte
2013-06-12 15:43 ` [PATCH v5 19/31] git-remote-mediawiki: Check return value of open Célestin Matte
2013-06-12 15:43 ` [PATCH v5 20/31] git-remote-mediawiki: remove import of unused open2 Célestin Matte
2013-06-12 15:43 ` [PATCH v5 21/31] git-remote-mediawiki: Put long code into a subroutine Célestin Matte
2013-06-12 15:43 ` [PATCH v5 22/31] git-remote-mediawiki: Modify strings for a better coding-style Célestin Matte
2013-06-12 15:43 ` [PATCH v5 23/31] git-remote-mediawiki: Brace file handles for print for more clarity Célestin Matte
2013-06-12 15:43 ` [PATCH v5 24/31] git-remote-mediawiki: Replace "unless" statements with negated "if" statements Célestin Matte
2013-06-12 15:43 ` Célestin Matte [this message]
2013-06-12 15:43 ` [PATCH v5 26/31] git-remote-mediawiki: Put non-trivial numeric values in constants Célestin Matte
2013-06-12 15:43 ` [PATCH v5 27/31] git-remote-mediawiki: Fix a typo ("mediwiki" instead of "mediawiki") Célestin Matte
2013-06-12 15:43 ` [PATCH v5 28/31] git-remote-mediawiki: Clearly rewrite double dereference Célestin Matte
2013-06-12 15:43 ` [PATCH v5 29/31] git-remote-mediawiki: Add a .perlcriticrc file Célestin Matte
2013-06-12 15:43 ` [PATCH v5 30/31] git-remote-mediawiki: add a perlcritic rule in Makefile Célestin Matte
2013-06-12 15:43 ` [PATCH v5 31/31] git-remote-mediawiki: Make error message more precise Célestin Matte
2013-06-12 20:02 ` [PATCH v5 00/31] Follow perlcritic's recommandations Matthieu Moy
2013-06-12 20:34 ` Célestin Matte
2013-06-12 20:47 ` Célestin Matte
2013-06-12 21:23 ` Eric Sunshine
2013-06-12 21:12 ` Matthieu Moy
2013-06-12 21:15 ` Célestin Matte
2013-06-12 22:53 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371051828-12866-26-git-send-email-celestin.matte@ensimag.fr \
--to=celestin.matte@ensimag.fr \
--cc=benoit.person@ensimag.fr \
--cc=git@vger.kernel.org \
--cc=matthieu.moy@grenoble-inp.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).