[PATCH 14/18] Don't use quotes for empty strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Empty strings are replaced by an $EMPTY constant.

Signed-off-by: Célestin Matte <celestin.matte@xxxxxxxxxx>
Signed-off-by: Matthieu Moy <matthieu.moy@xxxxxxxxxxxxxxx>
---
 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 b7a7012..059bd1a 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -41,6 +41,8 @@ Readonly my $NULL_SHA1 => '0000000000000000000000000000000000000000';
 # Used on Git's side to reflect empty edit messages on the wiki
 Readonly my $EMPTY_MESSAGE => '*Empty MediaWiki Message*';
 
+Readonly my $EMPTY => q{};
+
 if (@ARGV != 2) {
 	exit_error_usage();
 }
@@ -161,11 +163,11 @@ sub parse_commands {
 		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]);
@@ -556,7 +558,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;
 	}
@@ -567,7 +569,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";
@@ -993,7 +995,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";
@@ -1035,7 +1037,7 @@ sub mw_push_file {
 	my $newrevid;
 
 	if ($summary eq $EMPTY_MESSAGE) {
-		$summary = '';
+		$summary = $EMPTY;
 	}
 
 	my $new_sha1 = $diff_info_split[3];
@@ -1046,7 +1048,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);
@@ -1114,7 +1116,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.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]