Skip to content

Commit aeb95ee

Browse files
Perdugitster
authored andcommitted
git-remote-mediawiki: don't use quotes for empty strings
Empty strings are replaced by an $EMPTY constant. Signed-off-by: Célestin Matte <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b8b4e1b commit aeb95ee

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
# Used on Git's side to reflect empty edit messages on the wiki
4141
use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
4242

43+
use constant EMPTY => q{};
44+
4345
my $remotename = $ARGV[0];
4446
my $url = $ARGV[1];
4547

@@ -150,11 +152,11 @@ sub parse_command {
150152
mw_list($cmd[1]);
151153
} elsif ($cmd[0] eq 'import') {
152154
die("Invalid arguments for import\n")
153-
if ($cmd[1] eq "" || defined($cmd[2]));
155+
if ($cmd[1] eq EMPTY || defined($cmd[2]));
154156
mw_import($cmd[1]);
155157
} elsif ($cmd[0] eq 'option') {
156158
die("Too many arguments for option\n")
157-
if ($cmd[1] eq "" || $cmd[2] eq "" || defined($cmd[3]));
159+
if ($cmd[1] eq EMPTY || $cmd[2] eq EMPTY || defined($cmd[3]));
158160
mw_option($cmd[1],$cmd[2]);
159161
} elsif ($cmd[0] eq 'push') {
160162
mw_push($cmd[1]);
@@ -555,7 +557,7 @@ sub mediawiki_clean {
555557
# Mediawiki does not allow blank space at the end of a page and ends with a single \n.
556558
# This function right trims a string and adds a \n at the end to follow this rule
557559
$string =~ s/\s+$//;
558-
if ($string eq "" && $page_created) {
560+
if ($string eq EMPTY && $page_created) {
559561
# Creating empty pages is forbidden.
560562
$string = EMPTY_CONTENT;
561563
}
@@ -566,7 +568,7 @@ sub mediawiki_clean {
566568
sub mediawiki_smudge {
567569
my $string = shift;
568570
if ($string eq EMPTY_CONTENT) {
569-
$string = "";
571+
$string = EMPTY;
570572
}
571573
# This \n is important. This is due to mediawiki's way to handle end of files.
572574
return "${string}\n";
@@ -992,7 +994,7 @@ sub mw_upload_file {
992994
} else {
993995
# Don't let perl try to interpret file content as UTF-8 => use "raw"
994996
my $content = run_git("cat-file blob ${new_sha1}", 'raw');
995-
if ($content ne "") {
997+
if ($content ne EMPTY) {
996998
mw_connect_maybe();
997999
$mediawiki->{config}->{upload_url} =
9981000
"${url}/index.php/Special:Upload";
@@ -1034,7 +1036,7 @@ sub mw_push_file {
10341036
my $newrevid;
10351037

10361038
if ($summary eq EMPTY_MESSAGE) {
1037-
$summary = '';
1039+
$summary = EMPTY;
10381040
}
10391041

10401042
my $new_sha1 = $diff_info_split[3];
@@ -1045,7 +1047,7 @@ sub mw_push_file {
10451047

10461048
my ($title, $extension) = $complete_file_name =~ /^(.*)\.([^\.]*)$/;
10471049
if (!defined($extension)) {
1048-
$extension = "";
1050+
$extension = EMPTY;
10491051
}
10501052
if ($extension eq 'mw') {
10511053
my $ns = get_mw_namespace_id_for_page($complete_file_name);
@@ -1113,7 +1115,7 @@ sub mw_push {
11131115
if ($force) {
11141116
print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
11151117
}
1116-
if ($local eq "") {
1118+
if ($local eq EMPTY) {
11171119
print {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
11181120
print {*STDOUT} "error ${remote} cannot delete\n";
11191121
next;

0 commit comments

Comments
 (0)