summaryrefslogtreecommitdiff
path: root/contrib/mw-to-git/git-remote-mediawiki.perl
diff options
context:
space:
mode:
authorCélestin Matte <celestin.matte@ensimag.fr>2013-06-11 13:38:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-11 21:27:15 (GMT)
commit5ada8687995fadea01f755d52ceec58337d003a3 (patch)
treefaa4b55145e54ceca527cc839cf87351d9e69dce /contrib/mw-to-git/git-remote-mediawiki.perl
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
downloadgit-5ada8687995fadea01f755d52ceec58337d003a3.zip
git-5ada8687995fadea01f755d52ceec58337d003a3.tar.gz
git-5ada8687995fadea01f755d52ceec58337d003a3.tar.bz2
git-remote-mediawiki: display message when launched directly
Users may be confused when they run the perl script directly. A good way to detect this is to check the number of parameters used to call the script, which is never different from 2 in a normal use. Display a proper error message to avoid any confusion. 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>
Diffstat (limited to 'contrib/mw-to-git/git-remote-mediawiki.perl')
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki.perl15
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 9c14c1f..9b71972 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -41,6 +41,10 @@ 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*';
+if (@ARGV != 2) {
+ exit_error_usage();
+}
+
my $remotename = $ARGV[0];
my $url = $ARGV[1];
@@ -156,6 +160,17 @@ while (<STDIN>) {
########################## 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";
+}
+
## credential API management (generic functions)
sub credential_read {