* [PATCH] git-remote-mediawiki: display message when launched directly
@ 2013-06-11 13:38 Célestin Matte
2013-06-11 13:44 ` Matthieu Moy
0 siblings, 1 reply; 2+ messages in thread
From: Célestin Matte @ 2013-06-11 13:38 UTC (permalink / raw)
To: git; +Cc: benoit.person, matthieu.moy, Célestin Matte
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>
---
contrib/mw-to-git/git-remote-mediawiki.perl | 15 +++++++++++++++
1 file changed, 15 insertions(+)
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 {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] git-remote-mediawiki: display message when launched directly
2013-06-11 13:38 [PATCH] git-remote-mediawiki: display message when launched directly Célestin Matte
@ 2013-06-11 13:44 ` Matthieu Moy
0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Moy @ 2013-06-11 13:44 UTC (permalink / raw)
To: Célestin Matte; +Cc: git, benoit.person
Célestin Matte <celestin.matte@ensimag.fr> writes:
> 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.
Sounds good, thanks.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-11 13:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-11 13:38 [PATCH] git-remote-mediawiki: display message when launched directly Célestin Matte
2013-06-11 13:44 ` Matthieu Moy
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).