Merge branch 'pb/stash-refuse-to-kill'
[gitweb.git] / contrib / mw-to-git / git-remote-mediawiki.perl
index 9ff45fd9268f28322bd5222070ca48eec8f23dac..d09f5da6681fa62dbb87582031c12fe9dceddb69 100755 (executable)
 
 use constant HTTP_CODE_OK => 200;
 
+if (@ARGV != 2) {
+       exit_error_usage();
+}
+
 my $remotename = $ARGV[0];
 my $url = $ARGV[1];
 
 
 ########################## Functions ##############################
 
+## error handling
+sub exit_error_usage {
+       die "ERROR: git-remote-mediawiki module was not called with a correct number of\n" .
+           "parameters\n" .
+           "You may obtain this error because you attempted to run the git-remote-mediawiki\n" .
+            "module directly.\n" .
+           "This module can be used the following way:\n" .
+           "\tgit clone mediawiki://<address of a mediawiki>\n" .
+           "Then, use git commit, push and pull as with every normal git repository.\n";
+}
+
 sub parse_command {
        my ($line) = @_;
        my @cmd = split(/ /, $line);
@@ -620,9 +635,9 @@ sub literal_data_raw {
        my ($content) = @_;
        # Avoid confusion between size in bytes and in characters
        utf8::downgrade($content);
-       binmode {*STDOUT}, ':raw';
+       binmode STDOUT, ':raw';
        print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
-       binmode {*STDOUT}, ':encoding(UTF-8)';
+       binmode STDOUT, ':encoding(UTF-8)';
        return;
 }