Skip to content

Commit

Permalink
git-remote-mediawiki: display message when launched directly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Célestin Matte authored and Junio C Hamano committed Jun 11, 2013
1 parent edca415 commit 5ada868
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions contrib/mw-to-git/git-remote-mediawiki.perl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
# 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];

Expand Down Expand Up @@ -156,6 +160,17 @@

########################## 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 {
Expand Down

0 comments on commit 5ada868

Please sign in to comment.