git-remote-mediawiki: don't use quotes for empty strings
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b8b4e1b385
commit
aeb95eeaff
@ -40,6 +40,8 @@ use constant NULL_SHA1 => '0000000000000000000000000000000000000000';
|
|||||||
# Used on Git's side to reflect empty edit messages on the wiki
|
# Used on Git's side to reflect empty edit messages on the wiki
|
||||||
use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
|
use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
|
||||||
|
|
||||||
|
use constant EMPTY => q{};
|
||||||
|
|
||||||
my $remotename = $ARGV[0];
|
my $remotename = $ARGV[0];
|
||||||
my $url = $ARGV[1];
|
my $url = $ARGV[1];
|
||||||
|
|
||||||
@ -150,11 +152,11 @@ sub parse_command {
|
|||||||
mw_list($cmd[1]);
|
mw_list($cmd[1]);
|
||||||
} elsif ($cmd[0] eq 'import') {
|
} elsif ($cmd[0] eq 'import') {
|
||||||
die("Invalid arguments for import\n")
|
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]);
|
mw_import($cmd[1]);
|
||||||
} elsif ($cmd[0] eq 'option') {
|
} elsif ($cmd[0] eq 'option') {
|
||||||
die("Too many arguments for option\n")
|
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]);
|
mw_option($cmd[1],$cmd[2]);
|
||||||
} elsif ($cmd[0] eq 'push') {
|
} elsif ($cmd[0] eq 'push') {
|
||||||
mw_push($cmd[1]);
|
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.
|
# 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
|
# This function right trims a string and adds a \n at the end to follow this rule
|
||||||
$string =~ s/\s+$//;
|
$string =~ s/\s+$//;
|
||||||
if ($string eq "" && $page_created) {
|
if ($string eq EMPTY && $page_created) {
|
||||||
# Creating empty pages is forbidden.
|
# Creating empty pages is forbidden.
|
||||||
$string = EMPTY_CONTENT;
|
$string = EMPTY_CONTENT;
|
||||||
}
|
}
|
||||||
@ -566,7 +568,7 @@ sub mediawiki_clean {
|
|||||||
sub mediawiki_smudge {
|
sub mediawiki_smudge {
|
||||||
my $string = shift;
|
my $string = shift;
|
||||||
if ($string eq EMPTY_CONTENT) {
|
if ($string eq EMPTY_CONTENT) {
|
||||||
$string = "";
|
$string = EMPTY;
|
||||||
}
|
}
|
||||||
# This \n is important. This is due to mediawiki's way to handle end of files.
|
# This \n is important. This is due to mediawiki's way to handle end of files.
|
||||||
return "${string}\n";
|
return "${string}\n";
|
||||||
@ -992,7 +994,7 @@ sub mw_upload_file {
|
|||||||
} else {
|
} else {
|
||||||
# Don't let perl try to interpret file content as UTF-8 => use "raw"
|
# Don't let perl try to interpret file content as UTF-8 => use "raw"
|
||||||
my $content = run_git("cat-file blob ${new_sha1}", 'raw');
|
my $content = run_git("cat-file blob ${new_sha1}", 'raw');
|
||||||
if ($content ne "") {
|
if ($content ne EMPTY) {
|
||||||
mw_connect_maybe();
|
mw_connect_maybe();
|
||||||
$mediawiki->{config}->{upload_url} =
|
$mediawiki->{config}->{upload_url} =
|
||||||
"${url}/index.php/Special:Upload";
|
"${url}/index.php/Special:Upload";
|
||||||
@ -1034,7 +1036,7 @@ sub mw_push_file {
|
|||||||
my $newrevid;
|
my $newrevid;
|
||||||
|
|
||||||
if ($summary eq EMPTY_MESSAGE) {
|
if ($summary eq EMPTY_MESSAGE) {
|
||||||
$summary = '';
|
$summary = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $new_sha1 = $diff_info_split[3];
|
my $new_sha1 = $diff_info_split[3];
|
||||||
@ -1045,7 +1047,7 @@ sub mw_push_file {
|
|||||||
|
|
||||||
my ($title, $extension) = $complete_file_name =~ /^(.*)\.([^\.]*)$/;
|
my ($title, $extension) = $complete_file_name =~ /^(.*)\.([^\.]*)$/;
|
||||||
if (!defined($extension)) {
|
if (!defined($extension)) {
|
||||||
$extension = "";
|
$extension = EMPTY;
|
||||||
}
|
}
|
||||||
if ($extension eq 'mw') {
|
if ($extension eq 'mw') {
|
||||||
my $ns = get_mw_namespace_id_for_page($complete_file_name);
|
my $ns = get_mw_namespace_id_for_page($complete_file_name);
|
||||||
@ -1113,7 +1115,7 @@ sub mw_push {
|
|||||||
if ($force) {
|
if ($force) {
|
||||||
print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
|
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 {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
|
||||||
print {*STDOUT} "error ${remote} cannot delete\n";
|
print {*STDOUT} "error ${remote} cannot delete\n";
|
||||||
next;
|
next;
|
||||||
|
Loading…
Reference in New Issue
Block a user