{"thread":{"id":"34103","subject":"[PATCH] git-remote-mediawiki: display message when launched directly","startedAt":"2013-06-11T13:38:48Z","lastAt":"2013-06-11T13:44:32Z","messageCount":2,"participants":["Célestin Matte","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"220434","messageId":"1370957928-19303-1-git-send-email-celestin.matte@ensimag.fr","threadId":"34103","inReplyTo":null,"subject":"[PATCH] git-remote-mediawiki: display message when launched directly","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-11T13:38:48Z","receivedAt":"2013-06-11T13:38:48Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"Users may be confused when they run the perl script directly.\nA good way to detect this is to check the number of parameters used to call the\nscript, which is never different from 2 in a normal use.\nDisplay a proper error message to avoid any confusion.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl |   15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 9c14c1f..9b71972 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -41,6 +41,10 @@ use constant NULL_SHA1 => \"0000000000000000000000000000000000000000\";\n # Used on Git's side to reflect empty edit messages on the wiki\n use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';\n \n+if (@ARGV != 2) {\n+\texit_error_usage();\n+}\n+\n my $remotename = $ARGV[0];\n my $url = $ARGV[1];\n \n@@ -156,6 +160,17 @@ while (<STDIN>) {\n \n ########################## Functions ##############################\n \n+## error handling\n+sub exit_error_usage {\n+\tdie \"ERROR: git-remote-mediawiki module was not called with a correct number of\\n\" .\n+\t    \"parameters\\n\" .\n+\t    \"You may obtain this error because you attempted to run the git-remote-mediawiki\\n\" .\n+            \"module directly.\\n\" .\n+\t    \"This module can be used the following way:\\n\" .\n+\t    \"\\tgit clone mediawiki://<address of a mediawiki>\\n\" .\n+\t    \"Then, use git commit, push and pull as with every normal git repository.\\n\";\n+}\n+\n ## credential API management (generic functions)\n \n sub credential_read {\n-- \n1.7.9.5\n"},{"id":"220438","messageId":"vpqsj0o3gov.fsf@anie.imag.fr","threadId":"34103","inReplyTo":"1370957928-19303-1-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH] git-remote-mediawiki: display message when launched directly","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-11T13:44:32Z","receivedAt":"2013-06-11T13:44:32Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> Users may be confused when they run the perl script directly.\n> A good way to detect this is to check the number of parameters used to call the\n> script, which is never different from 2 in a normal use.\n> Display a proper error message to avoid any confusion.\n\nSounds good, thanks.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}