{"thread":{"id":"34330","subject":"[PATCH v7 7/7] git-remote-mediawiki: Add preview subcommand into git mw","startedAt":"2013-07-02T22:39:42Z","lastAt":"2013-07-03T21:50:26Z","messageCount":20,"participants":["benoit.person@ensimag.fr","Junio C Hamano","Benoît Person","Matthieu Moy","Michael Haggerty"],"isPatch":true,"patchVersion":7,"patchTotal":7},"messages":[{"id":"222412","messageId":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":null,"subject":"[PATCH v7 0/7] git-remote-mediawiki: new tool to preview local changes without pushing","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:42Z","receivedAt":"2013-07-02T22:39:42Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nThe #7 issue on git-mediawiki's issue tracker [1] states that the ability to\npreview content without pushing would be a nice thing to have.\n\nchanges from v6:\n  - Rewrite of bin-wrapper/git in 3/7\n  - Update wrap-for-bin.sh and make bin-wrappers chainable it\n    removes the need for a GPLEXTEA since we only have to first\n    define GITPERLLIB, the bin-wrappers will no longer overwrite\n    it. (2/7)\n    Maybe we should apply the same mechanism to all variables in\n    wrap-for-bin.sh ? (there is no need for it right now though)\n  - Replace the symlink created in the test suite (if git-remote-mediawiki\n    was not installed) by the new bin-wrapper introduced in 3/4 (4/7).\n  - Small typos in the commit messages\n\nchanges from v5:\n  - Move git bin-wrapper 'git' into bin-wrapper/\n  - Updates its GIT_ROOT_DIR accordingly\n  - Updates the Makefile to use that new path in the comments\n\nchanges from v4:\n  - Rebase on latest master\n  - Typos in commits messages and code\n  - Comments in Makefile\n  - Factoring the conversion from relatives links to absolute ones in\n    `git mw preview`\n  - Updating that \"conversion\" mechanism to not convert links with an\n    anchor '#'.\n  - git-mw should be executable now.\n\nchanges from v3:\n  - Rewrite all commit messages.\n  - No more \"\\ No newline at end of file\".\n  - Rename GitMediawiki.pm into Git::Mediawiki.pm (so it moves GitMedawiki.pm\n    into Git/Mediawiki.pm).\n  - Remove from the Makefile the copy_pm target (see below 'Add a bin-wrapper').\n  - Use of 'install' insted of 'cp' in the Makefile.\n  - Comment on the install_pm target in the Makefile.\n  - Add a bin-wrapper for git to test scripts without 'make install'-ing them.\n  - Move verbose option handling from previous v3-4/4 (introduction of preview\n  \ttool) into v4-4/5 (introduction of git-mw).\n  - Refactor some code into subroutines to clean the global 'preview'\n    subroutine.\n  - Rewrite some error messages to make them more concise while still giving\n    the same amount of information.\n  - Use 'remote.${remote_name}.mwIDcontent' instead of 'mediawiki.IDContent'\n    as config item for the lookup ID used to combine template + new content.\n  - Remove comments about what's going on in the preview subroutine.\n  - Use 'clean_filename' (and not 'smudge_filename') in the preview tool to find\n    the correct mediawiki page name based on a filename.\n  - Remove space/tab mixup in the 'help' subroutine.\n\nchanges from v2:\n  - Add a way to test, without installation, code that uses GitMediawiki.pm.\n  - Move more constants to GitMediawiki.pm\n  - Remove the encapsulation of Git::config calls into a git_cmd_try one.\n  - Remove the --blob option, distinction between files and blobs is now \n    automatic.\n  - Add a --verbose option to output more information on what's going on.\n  - Rewrote the doc and the commit message.\n  - Rewrote of the template retrieving code (see 'get_template' sub).\n  - Use a configuration variable to define the content ID search in the\n    template. Default value set as 'bodyContent' since it seems more standard\n    than 'mw-content-text'.\n  - Final content is now saved as utf-8 to solve encoding issues.\n  - Perlcritic changes: \n    - Update for loops style to a more perlish one.\n    - All 'print's specify their output streams.\n    --> Same useless warnings left in git-remote-mediawiki.perl after célestin's \n        work and git-mw.perl after this patch :) .\n\nchanges from v1:\n  - add new package GitMediawiki\n    - move some of git-remote-mediawiki functions into the package\n    - update git-remote-mediawiki to use those \"moved\" functions\n    - add a hacky-way to install it in the Makefile\n    - use it in the new git mw tool\n  - add a way to give to the preview tool blobs as argument\n  - add a fallback when the upstream's branch remote is not a mediawiki remote\n  - update the `autoload` option to use `git web--browse` and not `xdg-open`\n  - update the way we find the upstream's branch remote name\n\n[1] https://github.com/moy/Git-Mediawiki/issues/7\n\nBenoit Person (7):\n  git-remote-mediawiki: Introduction of Git::Mediawiki.pm\n  wrap-for-bin: Make bin-wrappers chainable\n  git-remote-mediawiki: New git bin-wrapper for developement\n  git-remote-mediawiki: Update tests to run with the new bin-wrapper\n  git-remote-mediawiki: Factoring code between git-remote-mediawiki and\n    Git::Mediawiki\n  git-remote-mediawiki: Adding git-mw command\n  git-remote-mediawiki: Add preview subcommand into git mw\n\n contrib/mw-to-git/Git/Mediawiki.pm          | 100 ++++++++\n contrib/mw-to-git/Makefile                  |  33 ++-\n contrib/mw-to-git/bin-wrapper/git           |  14 ++\n contrib/mw-to-git/git-mw.perl               | 368 ++++++++++++++++++++++++++++\n contrib/mw-to-git/git-remote-mediawiki.perl |  85 +------\n contrib/mw-to-git/t/test-gitmw-lib.sh       |   8 +-\n wrap-for-bin.sh                             |   2 +-\n 7 files changed, 527 insertions(+), 83 deletions(-)\n create mode 100644 contrib/mw-to-git/Git/Mediawiki.pm\n create mode 100755 contrib/mw-to-git/bin-wrapper/git\n create mode 100755 contrib/mw-to-git/git-mw.perl\n\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222415","messageId":"1372804789-12732-2-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 1/7] git-remote-mediawiki: Introduction of Git::Mediawiki.pm","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:43Z","receivedAt":"2013-07-02T22:39:43Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nCurrently, the mw-to-git project contains only a remote helper\n(git-remote-mediawiki.perl). To improve the user experience while\nworking with mediawiki remotes, new tools, designed for such cases,\nshould be created. To achieve this goal, the project needs a way to\nshare code between several scripts (remote helper, commands, ... ).\n\nA perl package offers the best way to handle such case: Each script\ncan select what should be imported in its namespace.  The package\nnamespacing limits the use of side effects in the shared code.\n\nAn alternate solution is to concatenate a \"toolset\" file with each\n*.perl when 'make'-ing the project. In that scheme, everything is\nimported in the script's namespace. Plus, files should be renamed in\norder to chain to Git's toplevel makefile. Hence, this solution is not\nacceptable.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/Git/Mediawiki.pm | 24 ++++++++++++++++++++++++\n contrib/mw-to-git/Makefile         | 24 +++++++++++++++++++++---\n 2 files changed, 45 insertions(+), 3 deletions(-)\n create mode 100644 contrib/mw-to-git/Git/Mediawiki.pm\n\ndiff --git a/contrib/mw-to-git/Git/Mediawiki.pm b/contrib/mw-to-git/Git/Mediawiki.pm\nnew file mode 100644\nindex 0000000..805f42a\n--- /dev/null\n+++ b/contrib/mw-to-git/Git/Mediawiki.pm\n@@ -0,0 +1,24 @@\n+package Git::Mediawiki;\n+\n+use 5.008;\n+use strict;\n+use Git;\n+\n+BEGIN {\n+\n+our ($VERSION, @ISA, @EXPORT, @EXPORT_OK);\n+\n+# Totally unstable API.\n+$VERSION = '0.01';\n+\n+require Exporter;\n+\n+@ISA = qw(Exporter);\n+\n+@EXPORT = ();\n+\n+# Methods which can be called as standalone functions as well:\n+@EXPORT_OK = ();\n+}\n+\n+1; # Famous last words\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nindex 1fb2424..a6f8b24 100644\n--- a/contrib/mw-to-git/Makefile\n+++ b/contrib/mw-to-git/Makefile\n@@ -2,18 +2,36 @@\n # Copyright (C) 2013\n #     Matthieu Moy <Matthieu.Moy@imag.fr>\n #\n-## Build git-remote-mediawiki\n+# To install, run Git's toplevel 'make install' then run:\n+#\n+#   make install\n \n+GIT_MEDIAWIKI_PM=Git/Mediawiki.pm\n SCRIPT_PERL=git-remote-mediawiki.perl\n GIT_ROOT_DIR=../..\n HERE=contrib/mw-to-git/\n \n SCRIPT_PERL_FULL=$(patsubst %,$(HERE)/%,$(SCRIPT_PERL))\n+INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/perl \\\n+                -s --no-print-directory instlibdir)\n \n all: build\n \n-build install clean:\n+install_pm:\n+\tinstall $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)\n+\n+build:\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+                build-perl-script\n+\n+install: install_pm\n \t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n-                $@-perl-script\n+                install-perl-script\n+\n+clean:\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+                clean-perl-script\n+\trm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)\n+\n perlcritic:\n \tperlcritic -2 *.perl\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222411","messageId":"1372804789-12732-3-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:44Z","receivedAt":"2013-07-02T22:39:44Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nFor now, bin-wrappers (based on wrap-for-bin.sh) redefine some\nenvironnement variables (like $GITPERLLIB). If we want to chain to\nthose scripts and define one of those variables before, our changes\nwill be overwritten.\n\nThis patch simply makes the bin-wrappers prepend their modifications\nrather than redefine the vars.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n wrap-for-bin.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\nindex 53a8dd0..dbebe49 100644\n--- a/wrap-for-bin.sh\n+++ b/wrap-for-bin.sh\n@@ -14,7 +14,7 @@ else\n \tGIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'\n \texport GIT_TEMPLATE_DIR\n fi\n-GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n+GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib:'\"$GITPERLLIB\"\n GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'\n PATH='@@BUILD_DIR@@/bin-wrappers:'\"$PATH\"\n export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222416","messageId":"1372804789-12732-4-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 3/7] git-remote-mediawiki: New git bin-wrapper for developement","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:45Z","receivedAt":"2013-07-02T22:39:45Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nThe introduction of the Git::Mediawiki package makes it impossible to test,\nwithout installation, git-remote-mediawiki and git-mw.\n\nUsing a git bin-wrapper enables us to define proper $GITPERLLIB to force the\nuse of the developement version of the Git::Mediawiki package, bypassing its\ninstalled version if any.\n\nAn alternate solution was to 'install' all the files required at each build\nbut it pollutes the toplevel with untracked files.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/Makefile        |  6 ++++++\n contrib/mw-to-git/bin-wrapper/git | 14 ++++++++++++++\n 2 files changed, 20 insertions(+)\n create mode 100755 contrib/mw-to-git/bin-wrapper/git\n\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nindex a6f8b24..c5e66df 100644\n--- a/contrib/mw-to-git/Makefile\n+++ b/contrib/mw-to-git/Makefile\n@@ -2,6 +2,12 @@\n # Copyright (C) 2013\n #     Matthieu Moy <Matthieu.Moy@imag.fr>\n #\n+# To build and test:\n+#\n+#   make:\n+#     bin-wrapper/git mw preview Some_page.mw\n+#     bin-wrapper/git clone mediawiki::http://example.com/wiki/\n+#\n # To install, run Git's toplevel 'make install' then run:\n #\n #   make install\ndiff --git a/contrib/mw-to-git/bin-wrapper/git b/contrib/mw-to-git/bin-wrapper/git\nnew file mode 100755\nindex 0000000..1aa51f7\n--- /dev/null\n+++ b/contrib/mw-to-git/bin-wrapper/git\n@@ -0,0 +1,14 @@\n+#!/bin/sh\n+\n+# git executable wrapper script for Git-Mediawiki to run tests without\n+# installing all the scripts and perl packages.\n+\n+GIT_ROOT_DIR=../../..\n+GIT_EXEC_PATH=$(cd \"$(dirname \"$0\")\" && cd ${GIT_ROOT_DIR} && pwd)\n+\n+GITPERLLIB=\"$GIT_EXEC_PATH\"'/contrib/mw-to-git:'\"$GITPERLLIB\"\n+PATH=\"$GIT_EXEC_PATH\"'/contrib/mw-to-git:'\"$PATH\"\n+\n+export GITPERLLIB PATH\n+\n+exec \"${GIT_EXEC_PATH}/bin-wrappers/git\" \"$@\"\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222410","messageId":"1372804789-12732-5-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 4/7] git-remote-mediawiki: Update tests to run with the new bin-wrapper","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:46Z","receivedAt":"2013-07-02T22:39:46Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nUntil now, if git-remote-mediawiki was not installed, the test suite\ncopied it to the toplevel directory. This solution pollutes the\ndirectory with untracked files. Plus, we would need to copy the new\ngit-mw.perl file to test it too.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/t/test-gitmw-lib.sh | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nindex bb76cee..ca6860f 100755\n--- a/contrib/mw-to-git/t/test-gitmw-lib.sh\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -62,12 +62,8 @@ test_check_precond () {\n \t\ttest_done\n \tfi\n \n-\tif [ ! -f \"$GIT_BUILD_DIR\"/git-remote-mediawiki ];\n-\tthen\n-\t\techo \"No remote mediawiki for git found. Copying it in git\"\n-\t\techo \"cp $GIT_BUILD_DIR/contrib/mw-to-git/git-remote-mediawiki $GIT_BUILD_DIR/\"\n-\t\tln -s \"$GIT_BUILD_DIR\"/contrib/mw-to-git/git-remote-mediawiki \"$GIT_BUILD_DIR\"\n-\tfi\n+\tGIT_EXEC_PATH=$(cd \"$(dirname \"$0\")\" && cd \"../..\" && pwd)\n+\tPATH=\"$GIT_EXEC_PATH\"'/bin-wrapper:'\"$PATH\"\n \n \tif [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ];\n \tthen\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222413","messageId":"1372804789-12732-6-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 5/7] git-remote-mediawiki: Factoring code between git-remote-mediawiki and Git::Mediawiki","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:47Z","receivedAt":"2013-07-02T22:39:47Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nFor now, Git::Mediawiki contains nothing.\n\nThis first patch moves some of git-remote-mediawiki.perl's factorisable code\ninto Git::Mediawiki. In the same time, it removes the side effects of that code\nand renames the fucntions and constants moved to expose a better API.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/Git/Mediawiki.pm          | 77 +++++++++++++++++++++++++-\n contrib/mw-to-git/git-remote-mediawiki.perl | 85 +++++------------------------\n 2 files changed, 89 insertions(+), 73 deletions(-)\n\ndiff --git a/contrib/mw-to-git/Git/Mediawiki.pm b/contrib/mw-to-git/Git/Mediawiki.pm\nindex 805f42a..47fe4f4 100644\n--- a/contrib/mw-to-git/Git/Mediawiki.pm\n+++ b/contrib/mw-to-git/Git/Mediawiki.pm\n@@ -18,7 +18,82 @@ require Exporter;\n @EXPORT = ();\n \n # Methods which can be called as standalone functions as well:\n-@EXPORT_OK = ();\n+@EXPORT_OK = qw(clean_filename smudge_filename connect_maybe\n+\t\t\t\tEMPTY HTTP_CODE_OK);\n+}\n+\n+# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n+use constant SLASH_REPLACEMENT => '%2F';\n+\n+# Used to test for empty strings\n+use constant EMPTY => q{};\n+\n+# HTTP codes\n+use constant HTTP_CODE_OK => 200;\n+\n+sub clean_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;\n+\t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n+\t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n+\t# but with _ added to prevent MediaWiki from thinking this is\n+\t# an actual special character.\n+\t$filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n+\t# If we use the uri escape before\n+\t# we should unescape here, before anything\n+\n+\treturn $filename;\n+}\n+\n+sub smudge_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;\n+\t$filename =~ s/ /_/g;\n+\t# Decode forbidden characters encoded in clean_filename\n+\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;\n+\treturn $filename;\n+}\n+\n+sub connect_maybe {\n+\tmy $wiki = shift;\n+\tif ($wiki) {\n+\t\treturn $wiki;\n+\t}\n+\n+\tmy $remote_name = shift;\n+\tmy $remote_url = shift;\n+\tmy ($wiki_login, $wiki_password, $wiki_domain);\n+\n+\t$wiki_login = Git::config(\"remote.${remote_name}.mwLogin\");\n+\t$wiki_password = Git::config(\"remote.${remote_name}.mwPassword\");\n+\t$wiki_domain = Git::config(\"remote.${remote_name}.mwDomain\");\n+\n+\t$wiki = MediaWiki::API->new;\n+\t$wiki->{config}->{api_url} = \"${remote_url}/api.php\";\n+\tif ($wiki_login) {\n+\t\tmy %credential = (\n+\t\t\t'url' => $remote_url,\n+\t\t\t'username' => $wiki_login,\n+\t\t\t'password' => $wiki_password\n+\t\t);\n+\t\tGit::credential(\\%credential);\n+\t\tmy $request = {lgname => $credential{username},\n+\t\t\t       lgpassword => $credential{password},\n+\t\t\t       lgdomain => $wiki_domain};\n+\t\tif ($wiki->login($request)) {\n+\t\t\tGit::credential(\\%credential, 'approve');\n+\t\t\tprint {*STDERR} qq(Logged in mediawiki user \"$credential{username}\".\\n);\n+\t\t} else {\n+\t\t\tprint {*STDERR} qq(Failed to log in mediawiki user \"$credential{username}\" on ${remote_url}\\n);\n+\t\t\tprint {*STDERR} '  (error ' .\n+\t\t\t\t$wiki->{error}->{code} . ': ' .\n+\t\t\t\t$wiki->{error}->{details} . \")\\n\";\n+\t\t\tGit::credential(\\%credential, 'reject');\n+\t\t\texit 1;\n+\t\t}\n+\t}\n+\n+\treturn $wiki;\n }\n \n 1; # Famous last words\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 71baf8a..e40c034 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -14,6 +14,8 @@\n use strict;\n use MediaWiki::API;\n use Git;\n+use Git::Mediawiki qw(clean_filename smudge_filename connect_maybe\n+\t\t\t\t\tEMPTY HTTP_CODE_OK);\n use DateTime::Format::ISO8601;\n use warnings;\n \n@@ -23,9 +25,6 @@ binmode STDOUT, ':encoding(UTF-8)';\n \n use URI::Escape;\n \n-# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n-use constant SLASH_REPLACEMENT => '%2F';\n-\n # It's not always possible to delete pages (may require some\n # privileges). Deleted pages are replaced with this content.\n use constant DELETED_CONTENT => \"[[Category:Deleted]]\\n\";\n@@ -40,8 +39,6 @@ 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-use constant EMPTY => q{};\n-\n # Number of pages taken into account at once in submodule get_mw_page_list\n use constant SLICE_SIZE => 50;\n \n@@ -50,8 +47,6 @@ use constant SLICE_SIZE => 50;\n # the number of links to be returned (500 links max).\n use constant BATCH_SIZE => 10;\n \n-use constant HTTP_CODE_OK => 200;\n-\n if (@ARGV != 2) {\n \texit_error_usage();\n }\n@@ -199,37 +194,6 @@ sub parse_command {\n # MediaWiki API instance, created lazily.\n my $mediawiki;\n \n-sub mw_connect_maybe {\n-\tif ($mediawiki) {\n-\t\treturn;\n-\t}\n-\t$mediawiki = MediaWiki::API->new;\n-\t$mediawiki->{config}->{api_url} = \"${url}/api.php\";\n-\tif ($wiki_login) {\n-\t\tmy %credential = (\n-\t\t\t'url' => $url,\n-\t\t\t'username' => $wiki_login,\n-\t\t\t'password' => $wiki_passwd\n-\t\t);\n-\t\tGit::credential(\\%credential);\n-\t\tmy $request = {lgname => $credential{username},\n-\t\t\t       lgpassword => $credential{password},\n-\t\t\t       lgdomain => $wiki_domain};\n-\t\tif ($mediawiki->login($request)) {\n-\t\t\tGit::credential(\\%credential, 'approve');\n-\t\t\tprint {*STDERR} qq(Logged in mediawiki user \"$credential{username}\".\\n);\n-\t\t} else {\n-\t\t\tprint {*STDERR} qq(Failed to log in mediawiki user \"$credential{username}\" on ${url}\\n);\n-\t\t\tprint {*STDERR} '  (error ' .\n-\t\t\t\t$mediawiki->{error}->{code} . ': ' .\n-\t\t\t\t$mediawiki->{error}->{details} . \")\\n\";\n-\t\t\tGit::credential(\\%credential, 'reject');\n-\t\t\texit 1;\n-\t\t}\n-\t}\n-\treturn;\n-}\n-\n sub fatal_mw_error {\n \tmy $action = shift;\n \tprint STDERR \"fatal: could not $action.\\n\";\n@@ -339,7 +303,7 @@ sub get_mw_first_pages {\n \n # Get the list of pages to be fetched according to configuration.\n sub get_mw_pages {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tprint {*STDERR} \"Listing pages on remote wiki...\\n\";\n \n@@ -529,7 +493,7 @@ sub get_last_local_revision {\n # avoid a loop onto all tracked pages. This is useful for the fetch-by-rev\n # option.\n sub get_last_global_remote_rev {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tmy $query = {\n \t\taction => 'query',\n@@ -545,7 +509,7 @@ sub get_last_global_remote_rev {\n # Get the last remote revision concerning the tracked pages and the tracked\n # categories.\n sub get_last_remote_revision {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tmy %pages_hash = get_mw_pages();\n \tmy @pages = values(%pages_hash);\n@@ -601,29 +565,6 @@ sub mediawiki_smudge {\n \treturn \"${string}\\n\";\n }\n \n-sub mediawiki_clean_filename {\n-\tmy $filename = shift;\n-\t$filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;\n-\t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n-\t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n-\t# but with _ added to prevent MediaWiki from thinking this is\n-\t# an actual special character.\n-\t$filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n-\t# If we use the uri escape before\n-\t# we should unescape here, before anything\n-\n-\treturn $filename;\n-}\n-\n-sub mediawiki_smudge_filename {\n-\tmy $filename = shift;\n-\t$filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;\n-\t$filename =~ s/ /_/g;\n-\t# Decode forbidden characters encoded in mediawiki_clean_filename\n-\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;\n-\treturn $filename;\n-}\n-\n sub literal_data {\n \tmy ($content) = @_;\n \tprint {*STDOUT} 'data ', bytes::length($content), \"\\n\", $content;\n@@ -831,7 +772,7 @@ sub mw_import_ref {\n \t\treturn;\n \t}\n \n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tprint {*STDERR} \"Searching revisions...\\n\";\n \tmy $last_local = get_last_local_revision();\n@@ -945,7 +886,7 @@ sub mw_import_revids {\n \t\tmy %commit;\n \t\t$commit{author} = $rev->{user} || 'Anonymous';\n \t\t$commit{comment} = $rev->{comment} || EMPTY_MESSAGE;\n-\t\t$commit{title} = mediawiki_smudge_filename($page_title);\n+\t\t$commit{title} = smudge_filename($page_title);\n \t\t$commit{mw_revision} = $rev->{revid};\n \t\t$commit{content} = mediawiki_smudge($rev->{'*'});\n \n@@ -1006,7 +947,7 @@ sub mw_upload_file {\n \t}\n \t# Deleting and uploading a file requires a priviledged user\n \tif ($file_deleted) {\n-\t\tmw_connect_maybe();\n+\t\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \t\tmy $query = {\n \t\t\taction => 'delete',\n \t\t\ttitle => $path,\n@@ -1022,7 +963,7 @@ sub mw_upload_file {\n \t\t# Don't let perl try to interpret file content as UTF-8 => use \"raw\"\n \t\tmy $content = run_git(\"cat-file blob ${new_sha1}\", 'raw');\n \t\tif ($content ne EMPTY) {\n-\t\t\tmw_connect_maybe();\n+\t\t\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \t\t\t$mediawiki->{config}->{upload_url} =\n \t\t\t\t\"${url}/index.php/Special:Upload\";\n \t\t\t$mediawiki->edit({\n@@ -1070,7 +1011,7 @@ sub mw_push_file {\n \tmy $old_sha1 = $diff_info_split[2];\n \tmy $page_created = ($old_sha1 eq NULL_SHA1);\n \tmy $page_deleted = ($new_sha1 eq NULL_SHA1);\n-\t$complete_file_name = mediawiki_clean_filename($complete_file_name);\n+\t$complete_file_name = clean_filename($complete_file_name);\n \n \tmy ($title, $extension) = $complete_file_name =~ /^(.*)\\.([^\\.]*)$/;\n \tif (!defined($extension)) {\n@@ -1093,7 +1034,7 @@ sub mw_push_file {\n \t\t\t$file_content = run_git(\"cat-file blob ${new_sha1}\");\n \t\t}\n \n-\t\tmw_connect_maybe();\n+\t\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \t\tmy $result = $mediawiki->edit( {\n \t\t\taction => 'edit',\n@@ -1279,7 +1220,7 @@ sub mw_push_revision {\n }\n \n sub get_allowed_file_extensions {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tmy $query = {\n \t\taction => 'query',\n@@ -1303,7 +1244,7 @@ my %cached_mw_namespace_id;\n # Return MediaWiki id for a canonical namespace name.\n # Ex.: \"File\", \"Project\".\n sub get_mw_namespace_id {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \tmy $name = shift;\n \n \tif (!exists $namespace_id{$name}) {\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222414","messageId":"1372804789-12732-7-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 6/7] git-remote-mediawiki: Adding git-mw command","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:48Z","receivedAt":"2013-07-02T22:39:48Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nFor now, git-remote-mediawiki is only a remote-helper. This patch adds a new\ntoolset script in which we will be able to build new tools for\ngit-remote-mediawiki.\n\nThis toolset uses a subcommand-mechanism to launch the proper action. For now\nonly the 'help' subcommand is implemented. It also provides some generic code\nfor the verbose and help command line options.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/Makefile    |  7 ++---\n contrib/mw-to-git/git-mw.perl | 60 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 64 insertions(+), 3 deletions(-)\n create mode 100755 contrib/mw-to-git/git-mw.perl\n\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nindex c5e66df..775cb07 100644\n--- a/contrib/mw-to-git/Makefile\n+++ b/contrib/mw-to-git/Makefile\n@@ -14,6 +14,7 @@\n \n GIT_MEDIAWIKI_PM=Git/Mediawiki.pm\n SCRIPT_PERL=git-remote-mediawiki.perl\n+SCRIPT_PERL+=git-mw.perl\n GIT_ROOT_DIR=../..\n HERE=contrib/mw-to-git/\n \n@@ -27,15 +28,15 @@ install_pm:\n \tinstall $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)\n \n build:\n-\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=\"$(SCRIPT_PERL_FULL)\" \\\n                 build-perl-script\n \n install: install_pm\n-\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=\"$(SCRIPT_PERL_FULL)\" \\\n                 install-perl-script\n \n clean:\n-\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=\"$(SCRIPT_PERL_FULL)\" \\\n                 clean-perl-script\n \trm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)\n \ndiff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\nnew file mode 100755\nindex 0000000..4a3e4a9\n--- /dev/null\n+++ b/contrib/mw-to-git/git-mw.perl\n@@ -0,0 +1,60 @@\n+#!/usr/bin/perl\n+\n+# Copyright (C) 2013\n+#     Benoit Person <benoit.person@ensimag.imag.fr>\n+#     Celestin Matte <celestin.matte@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+# Set of tools for git repo with a mediawiki remote.\n+# Documentation & bugtracker: https://github.com/moy/Git-Mediawiki/\n+\n+use strict;\n+use warnings;\n+\n+use Getopt::Long;\n+\n+# By default, use UTF-8 to communicate with Git and the user\n+binmode STDERR, ':encoding(UTF-8)';\n+binmode STDOUT, ':encoding(UTF-8)';\n+\n+# Global parameters\n+my $verbose = 0;\n+sub v_print {\n+\tif ($verbose) {\n+\t\treturn print {*STDERR} @_;\n+\t}\n+\treturn;\n+}\n+\n+my %commands = (\n+\t'help' =>\n+\t\t[\\&help, {}, \\&help]\n+);\n+\n+# Search for sub-command\n+my $cmd = $commands{'help'};\n+for (0..@ARGV-1) {\n+\tif (defined $commands{$ARGV[$_]}) {\n+\t\t$cmd = $commands{$ARGV[$_]};\n+\t\tsplice @ARGV, $_, 1;\n+\t\tlast;\n+\t}\n+};\n+GetOptions( %{$cmd->[1]},\n+\t'help|h' => \\&{$cmd->[2]},\n+\t'verbose|v'  => \\$verbose);\n+\n+# Launch command\n+&{$cmd->[0]};\n+\n+############################## Help Functions ##################################\n+\n+sub help {\n+\tprint {*STDOUT} <<'END';\n+usage: git mw <command> <args>\n+\n+git mw commands are:\n+    help        Display help information about git mw\n+END\n+\texit;\n+}\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222409","messageId":"1372804789-12732-8-git-send-email-benoit.person@ensimag.fr","threadId":"34330","inReplyTo":"1372804789-12732-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH v7 7/7] git-remote-mediawiki: Add preview subcommand into git mw","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T22:39:49Z","receivedAt":"2013-07-02T22:39:49Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nIn the current state, a user of git-remote-mediawiki can edit the markup text\nlocally, but has to push to the remote wiki to see how the page is rendererd.\nAdd a new 'git mw preview' command that allows rendering the markup text on\nthe remote wiki without actually pushing any change on the wiki.\n\nThis uses Mediawiki's API to render the markup and inserts it in an actual\nHTML page from the wiki so that CSS can be rendered properly. Most links\nshould work when the page exists on the remote.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/Git/Mediawiki.pm |   3 +-\n contrib/mw-to-git/git-mw.perl      | 310 ++++++++++++++++++++++++++++++++++++-\n 2 files changed, 311 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/mw-to-git/Git/Mediawiki.pm b/contrib/mw-to-git/Git/Mediawiki.pm\nindex 47fe4f4..d13c4df 100644\n--- a/contrib/mw-to-git/Git/Mediawiki.pm\n+++ b/contrib/mw-to-git/Git/Mediawiki.pm\n@@ -19,7 +19,7 @@ require Exporter;\n \n # Methods which can be called as standalone functions as well:\n @EXPORT_OK = qw(clean_filename smudge_filename connect_maybe\n-\t\t\t\tEMPTY HTTP_CODE_OK);\n+\t\t\t\tEMPTY HTTP_CODE_OK HTTP_CODE_PAGE_NOT_FOUND);\n }\n \n # Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n@@ -30,6 +30,7 @@ use constant EMPTY => q{};\n \n # HTTP codes\n use constant HTTP_CODE_OK => 200;\n+use constant HTTP_CODE_PAGE_NOT_FOUND => 404;\n \n sub clean_filename {\n \tmy $filename = shift;\ndiff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\nindex 4a3e4a9..28df3ee 100755\n--- a/contrib/mw-to-git/git-mw.perl\n+++ b/contrib/mw-to-git/git-mw.perl\n@@ -12,6 +12,14 @@ use strict;\n use warnings;\n \n use Getopt::Long;\n+use URI::URL qw(url);\n+use LWP::UserAgent;\n+use HTML::TreeBuilder;\n+\n+use Git;\n+use MediaWiki::API;\n+use Git::Mediawiki qw(clean_filename connect_maybe\n+\t\t\t\t\tEMPTY HTTP_CODE_PAGE_NOT_FOUND);\n \n # By default, use UTF-8 to communicate with Git and the user\n binmode STDERR, ':encoding(UTF-8)';\n@@ -26,9 +34,26 @@ sub v_print {\n \treturn;\n }\n \n+# Preview parameters\n+my $file_name = EMPTY;\n+my $remote_name = EMPTY;\n+my $preview_file_name = EMPTY;\n+my $autoload = 0;\n+sub file {\n+\t$file_name = shift;\n+\treturn $file_name;\n+}\n+\n my %commands = (\n \t'help' =>\n-\t\t[\\&help, {}, \\&help]\n+\t\t[\\&help, {}, \\&help],\n+\t'preview' =>\n+\t\t[\\&preview, {\n+\t\t\t'<>' => \\&file,\n+\t\t\t'output|o=s' => \\$preview_file_name,\n+\t\t\t'remote|r=s' => \\$remote_name,\n+\t\t\t'autoload|a' => \\$autoload\n+\t\t}, \\&preview_help]\n );\n \n # Search for sub-command\n@@ -47,6 +72,288 @@ GetOptions( %{$cmd->[1]},\n # Launch command\n &{$cmd->[0]};\n \n+############################# Preview Functions ################################\n+\n+sub preview_help {\n+\tprint {*STDOUT} <<'END';\n+USAGE: git mw preview [--remote|-r <remote name>] [--autoload|-a]\n+                      [--output|-o <output filename>] [--verbose|-v]\n+                      <blob> | <filename>\n+\n+DESCRIPTION:\n+Preview is an utiliy to preview local content of a mediawiki repo as if it was\n+pushed on the remote.\n+\n+For that, preview searches for the remote name of the current branch's\n+upstream if --remote is not set. If that remote is not found or if it\n+is not a mediawiki, it lists all mediawiki remotes configured and asks\n+you to replay your command with the --remote option set properly.\n+\n+Then, it searches for a file named 'filename'. If it's not found in\n+the current dir, it will assume it's a blob.\n+\n+The content retrieved in the file (or in the blob) will then be parsed\n+by the remote mediawiki and combined with a template retrieved from\n+the mediawiki.\n+\n+Finally, preview will save the HTML result in a file. and autoload it\n+in your default web browser if the option --autoload is present.\n+\n+OPTIONS:\n+    -r <remote name>, --remote <remote name>\n+        If the remote is a mediawiki, the template and the parse engine\n+        used for the preview will be those of that remote.\n+        If not, a list of valid remotes will be shown.\n+\n+    -a, --autoload\n+        Try to load the HTML output in a new tab (or new window) of your\n+        default web browser.\n+\n+    -o <output filename>, --output <output filename>\n+        Change the HTML output filename. Default filename is based on the\n+        input filename with its extension replaced by '.html'.\n+\n+    -v, --verbose\n+        Show more information on what's going on under the hood.\n+END\n+\texit;\n+}\n+\n+sub preview {\n+\tmy $wiki;\n+\tmy ($remote_url, $wiki_page_name);\n+\tmy ($new_content, $template);\n+\tmy $file_content;\n+\n+\tif ($file_name eq EMPTY) {\n+\t\tdie \"Missing file argument, see `git mw help`\\n\";\n+\t}\n+\n+\tv_print(\"### Selecting remote\\n\");\n+\tif ($remote_name eq EMPTY) {\n+\t\t$remote_name = find_upstream_remote_name();\n+\t\tif ($remote_name) {\n+\t\t\t$remote_url = mediawiki_remote_url_maybe($remote_name);\n+\t\t}\n+\n+\t\tif (! $remote_url) {\n+\t\t\tmy @valid_remotes = find_mediawiki_remotes();\n+\n+\t\t\tif ($#valid_remotes == 0) {\n+\t\t\t\tprint {*STDERR} \"No mediawiki remote in this repo. \\n\";\n+\t\t\t\texit 1;\n+\t\t\t} else {\n+\t\t\t\tmy $remotes_list = join(\"\\n\\t\", @valid_remotes);\n+\t\t\t\tprint {*STDERR} <<\"MESSAGE\";\n+There are multiple mediawiki remotes, which of:\n+\t${remotes_list}\n+do you want ? Use the -r option to specify the remote.\n+MESSAGE\n+\t\t\t}\n+\n+\t\t\texit 1;\n+\t\t}\n+\t} else {\n+\t\tif (!is_valid_remote($remote_name)) {\n+\t\t\tdie \"${remote_name} is not a remote\\n\";\n+\t\t}\n+\n+\t\t$remote_url = mediawiki_remote_url_maybe($remote_name);\n+\t\tif (! $remote_url) {\n+\t\t\tdie \"${remote_name} is not a mediawiki remote\\n\";\n+\t\t}\n+\t}\n+\tv_print(\"selected remote:\\n\\tname: ${remote_name}\\n\\turl: ${remote_url}\\n\");\n+\n+\t$wiki = connect_maybe($wiki, $remote_name, $remote_url);\n+\n+\t# Read file content\n+\tif (! -e $file_name) {\n+\t\t$file_content = git_cmd_try {\n+\t\t\tGit::command('cat-file', 'blob', $file_name); }\n+\t\t\t\"%s failed w/ code %d\";\n+\n+\t\tif ($file_name =~ /(.+):(.+)/) {\n+\t\t\t$file_name = $2;\n+\t\t}\n+\t} else {\n+\t\topen my $read_fh, \"<\", $file_name\n+\t\t\tor die \"could not open ${file_name}: $!\\n\";\n+\t\t$file_content = do { local $/ = undef; <$read_fh> };\n+\t\tclose $read_fh\n+\t\t\tor die \"unable to close: $!\\n\";\n+\t}\n+\n+\tv_print(\"### Retrieving template\\n\");\n+\t($wiki_page_name = clean_filename($file_name)) =~ s/\\.[^.]+$//;\n+\t$template = get_template($remote_url, $wiki_page_name);\n+\n+\tv_print(\"### Parsing local content\\n\");\n+\t$new_content = $wiki->api({\n+\t\taction => 'parse',\n+\t\ttext => $file_content,\n+\t\ttitle => $wiki_page_name\n+\t}, {\n+\t\tskip_encoding => 1\n+\t}) or die \"No response from remote mediawiki\\n\";\n+\t$new_content = $new_content->{'parse'}->{'text'}->{'*'};\n+\n+\tv_print(\"### Merging contents\\n\");\n+\tif ($preview_file_name eq EMPTY) {\n+\t\t($preview_file_name = $file_name) =~ s/\\.[^.]+$/.html/;\n+\t}\n+\topen(my $save_fh, '>:encoding(UTF-8)', $preview_file_name)\n+\t\tor die \"Could not open: $!\\n\";\n+\tprint {$save_fh} merge_contents($template, $new_content, $remote_url);\n+\tclose($save_fh)\n+\t\tor die \"Could not close: $!\\n\";\n+\n+\tv_print(\"### Results\\n\");\n+\tif ($autoload) {\n+\t\tv_print(\"Launching browser w/ file: ${preview_file_name}\");\n+\t\tsystem('git', 'web--browse', $preview_file_name);\n+\t} else {\n+\t\tprint {*STDERR} \"Preview file saved as: ${preview_file_name}\\n\";\n+\t}\n+\n+\texit;\n+}\n+\n+# uses global scope variable: $remote_name\n+sub merge_contents {\n+\tmy $template = shift;\n+\tmy $content = shift;\n+\tmy $remote_url = shift;\n+\tmy ($content_tree, $html_tree, $mw_content_text);\n+\tmy $template_content_id = 'bodyContent';\n+\n+\t$html_tree = HTML::TreeBuilder->new;\n+\t$html_tree->parse($template);\n+\n+\t$content_tree = HTML::TreeBuilder->new;\n+\t$content_tree->parse($content);\n+\n+\t$template_content_id = Git::config(\"remote.${remote_name}.mwIDcontent\")\n+\t\t|| $template_content_id;\n+\tv_print(\"Using '${template_content_id}' as the content ID\\n\");\n+\n+\t$mw_content_text = $html_tree->look_down('id', $template_content_id);\n+\tif (!defined $mw_content_text) {\n+\t\tprint {*STDERR} <<\"CONFIG\";\n+Could not combine the new content with the template. You might want to\n+configure `mediawiki.IDContent` in your config:\n+\tgit config --add remote.${remote_name}.mwIDcontent <id>\n+and re-run the command afterward.\n+CONFIG\n+\t\texit 1;\n+\t}\n+\t$mw_content_text->delete_content();\n+\t$mw_content_text->push_content($content_tree);\n+\n+\tmake_links_absolute($html_tree, $remote_url);\n+\n+\treturn $html_tree->as_HTML;\n+}\n+\n+sub make_links_absolute {\n+\tmy $html_tree = shift;\n+\tmy $remote_url = shift;\n+\tfor (@{ $html_tree->extract_links() }) {\n+\t\tmy ($link, $element, $attr) = @{ $_ };\n+\t\tmy $url = url($link)->canonical;\n+\t\tif ($url !~ /#/) {\n+\t\t\t$element->attr($attr, URI->new_abs($url, $remote_url));\n+\t\t}\n+\t}\n+\treturn $html_tree;\n+}\n+\n+sub is_valid_remote {\n+\tmy $remote = shift;\n+\tmy @remotes = git_cmd_try {\n+\t\tGit::command('remote') }\n+\t\t\"%s failed w/ code %d\";\n+\tmy $found_remote = 0;\n+\tforeach my $remote (@remotes) {\n+\t\tif ($remote eq $remote) {\n+\t\t\t$found_remote = 1;\n+\t\t\tlast;\n+\t\t}\n+\t}\n+\treturn $found_remote;\n+}\n+\n+sub find_mediawiki_remotes {\n+\tmy @remotes = git_cmd_try {\n+\t\tGit::command('remote'); }\n+\t\t\"%s failed w/ code %d\";\n+\tmy $remote_url;\n+\tmy @valid_remotes = ();\n+\tforeach my $remote (@remotes) {\n+\t\t$remote_url = mediawiki_remote_url_maybe($remote);\n+\t\tif ($remote_url) {\n+\t\t\tpush(@valid_remotes, $remote);\n+\t\t}\n+\t}\n+\treturn @valid_remotes;\n+}\n+\n+sub find_upstream_remote_name {\n+\tmy $current_branch = git_cmd_try {\n+\t\tGit::command_oneline('symbolic-ref', '--short', 'HEAD') }\n+\t\t\"%s failed w/ code %d\";\n+\treturn Git::config(\"branch.${current_branch}.remote\");\n+}\n+\n+sub mediawiki_remote_url_maybe {\n+\tmy $remote = shift;\n+\n+\t# Find remote url\n+\tmy $remote_url = Git::config(\"remote.${remote}.url\");\n+\tif ($remote_url =~ s/mediawiki::(.*)/$1/) {\n+\t\treturn url($remote_url)->canonical;\n+\t}\n+\n+\treturn;\n+}\n+\n+sub get_template {\n+\tmy $url = shift;\n+\tmy $page_name = shift;\n+\tmy ($req, $res, $code, $url_after);\n+\n+\t$req = LWP::UserAgent->new;\n+\tif ($verbose) {\n+\t\t$req->show_progress(1);\n+\t}\n+\n+\t$res = $req->get(\"${url}/index.php?title=${page_name}\");\n+\tif (!$res->is_success) {\n+\t\t$code = $res->code;\n+\t\t$url_after = $res->request()->uri(); # resolve all redirections\n+\t\tif ($code == HTTP_CODE_PAGE_NOT_FOUND) {\n+\t\t\tif ($verbose) {\n+\t\t\t\tprint {*STDERR} <<\"WARNING\";\n+Warning: Failed to retrieve '$page_name'. Create it on the mediawiki if you want\n+all the links to work properly.\n+Trying to use the mediawiki homepage as a fallback template ...\n+WARNING\n+\t\t\t}\n+\n+\t\t\t# LWP automatically redirects GET request\n+\t\t\t$res = $req->get(\"${url}/index.php\");\n+\t\t\tif (!$res->is_success) {\n+\t\t\t\t$url_after = $res->request()->uri(); # resolve all redirections\n+\t\t\t\tdie \"Failed to get homepage @ ${url_after} w/ code ${code}\\n\";\n+\t\t\t}\n+\t\t} else {\n+\t\t\tdie \"Failed to get '${page_name}' @ ${url_after} w/ code ${code}\\n\";\n+\t\t}\n+\t}\n+\n+\treturn $res->decoded_content;\n+}\n+\n ############################## Help Functions ##################################\n \n sub help {\n@@ -55,6 +362,7 @@ usage: git mw <command> <args>\n \n git mw commands are:\n     help        Display help information about git mw\n+    preview     Parse and render local file into HTML\n END\n \texit;\n }\n-- \n1.8.3.1.590.gc07d91b\n"},{"id":"222418","messageId":"7vobakin4g.fsf@alter.siamese.dyndns.org","threadId":"34330","inReplyTo":"1372804789-12732-2-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH v7 1/7] git-remote-mediawiki: Introduction of Git::Mediawiki.pm","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-02T22:59:59Z","receivedAt":"2013-07-02T22:59:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"benoit.person@ensimag.fr writes:\n\n> From: Benoit Person <benoit.person@ensimag.fr>\n>\n> Currently, the mw-to-git project contains only a remote helper\n> (git-remote-mediawiki.perl). To improve the user experience while\n> working with mediawiki remotes, new tools, designed for such cases,\n> should be created.\n\nThe above is too vague to be meaningful justification behind \"should\nbe created\".  It is unclear what \"new tools\" are being built, what\nthe success criteria to judge such \"new tools\" to see if they are\nwell \"designed for such cases\", etc.\n\nPerhaps you meant something like \"we would want to allow the user\nto preview what he has edited locally before pushing it out\".\n\n> To achieve this goal, the project needs a way to\n> share code between several scripts (remote helper, commands, ... ).\n\nThat is sensible, no matter what new things you are building, you\nwould want to build them on a solid foundation.\n"},{"id":"222419","messageId":"7vk3l8in2c.fsf@alter.siamese.dyndns.org","threadId":"34330","inReplyTo":"1372804789-12732-3-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-02T23:01:15Z","receivedAt":"2013-07-02T23:01:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"benoit.person@ensimag.fr writes:\n\n> From: Benoit Person <benoit.person@ensimag.fr>\n>\n> For now, bin-wrappers (based on wrap-for-bin.sh) redefine some\n> environnement variables (like $GITPERLLIB). If we want to chain to\n> those scripts and define one of those variables before, our changes\n> will be overwritten.\n>\n> This patch simply makes the bin-wrappers prepend their modifications\n> rather than redefine the vars.\n>\n> Signed-off-by: Benoit Person <benoit.person@ensimag.fr>\n> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> ---\n>  wrap-for-bin.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\n> index 53a8dd0..dbebe49 100644\n> --- a/wrap-for-bin.sh\n> +++ b/wrap-for-bin.sh\n> @@ -14,7 +14,7 @@ else\n>  \tGIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'\n>  \texport GIT_TEMPLATE_DIR\n>  fi\n> -GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n> +GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib:'\"$GITPERLLIB\"\n\nDo we want to add that ':' unconditionally?  Could GITPERLLIB be\nempty?\n\n>  GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'\n>  PATH='@@BUILD_DIR@@/bin-wrappers:'\"$PATH\"\n>  export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR\n"},{"id":"222420","messageId":"7vfvvwimxg.fsf@alter.siamese.dyndns.org","threadId":"34330","inReplyTo":"1372804789-12732-4-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH v7 3/7] git-remote-mediawiki: New git bin-wrapper for developement","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-02T23:04:11Z","receivedAt":"2013-07-02T23:04:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"benoit.person@ensimag.fr writes:\n\n> +GIT_ROOT_DIR=../../..\n> +GIT_EXEC_PATH=$(cd \"$(dirname \"$0\")\" && cd ${GIT_ROOT_DIR} && pwd)\n> +\n> +GITPERLLIB=\"$GIT_EXEC_PATH\"'/contrib/mw-to-git:'\"$GITPERLLIB\"\n\nThe same comment on ':' applies here.\n\n> +PATH=\"$GIT_EXEC_PATH\"'/contrib/mw-to-git:'\"$PATH\"\n\nBut not to this, as PATH is unlikely to be empty ;-)\n\n> +\n> +export GITPERLLIB PATH\n> +\n> +exec \"${GIT_EXEC_PATH}/bin-wrappers/git\" \"$@\"\n"},{"id":"222421","messageId":"CAETqRChiW49TwrZiZoi6vCwe9yOjurn97QpPEcJ2pb6fvp3ZBQ@mail.gmail.com","threadId":"34330","inReplyTo":"7vk3l8in2c.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Benoît Person","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-02T23:19:19Z","receivedAt":"2013-07-02T23:19:19Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"> Do we want to add that ':' unconditionally?  Could GITPERLLIB be\n> empty?\n\nFor now, GITPERLLIB is only used in that kind of statements:\nuse lib (split(/:/, $ENV{GITPERLLIB} || ... ));\n\nThe trailing ':' does not really matter, split will ignore it.\n\nWith the current codebase, I think it's nicer to do it that way (makes\nwrap-for-bin.sh more readable).\n"},{"id":"222443","messageId":"7vhagcgh0e.fsf@alter.siamese.dyndns.org","threadId":"34330","inReplyTo":"CAETqRChiW49TwrZiZoi6vCwe9yOjurn97QpPEcJ2pb6fvp3ZBQ@mail.gmail.com","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-03T08:54:57Z","receivedAt":"2013-07-03T08:54:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Benoît Person <benoit.person@ensimag.fr> writes:\n\n>> Do we want to add that ':' unconditionally?  Could GITPERLLIB be\n>> empty?\n>\n> For now, GITPERLLIB is only used in that kind of statements:\n> use lib (split(/:/, $ENV{GITPERLLIB} || ... ));\n>\n> The trailing ':' does not really matter, split will ignore it.\n\nThat may be true with the current use, but \"For now\" leaves funny\ntaste, doesn't it?\n\nIt is not too much trouble to fix by writing\n\n  GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\"${GITPERLLIB:+:$GITPERLLIB}\"\n\nand we will not have to be worried about future changes breaking\ntoday's assumption.\n"},{"id":"222448","messageId":"vpqobakrog6.fsf@anie.imag.fr","threadId":"34330","inReplyTo":"1372804789-12732-5-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH v7 4/7] git-remote-mediawiki: Update tests to run with the new bin-wrapper","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-07-03T09:18:49Z","receivedAt":"2013-07-03T09:18:49Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> --- a/contrib/mw-to-git/t/test-gitmw-lib.sh\n> +++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n> @@ -62,12 +62,8 @@ test_check_precond () {\n>  \t\ttest_done\n>  \tfi\n>  \n> -\tif [ ! -f \"$GIT_BUILD_DIR\"/git-remote-mediawiki ];\n> -\tthen\n> -\t\techo \"No remote mediawiki for git found. Copying it in git\"\n> -\t\techo \"cp $GIT_BUILD_DIR/contrib/mw-to-git/git-remote-mediawiki $GIT_BUILD_DIR/\"\n> -\t\tln -s \"$GIT_BUILD_DIR\"/contrib/mw-to-git/git-remote-mediawiki \"$GIT_BUILD_DIR\"\n> -\tfi\n> +\tGIT_EXEC_PATH=$(cd \"$(dirname \"$0\")\" && cd \"../..\" && pwd)\n> +\tPATH=\"$GIT_EXEC_PATH\"'/bin-wrapper:'\"$PATH\"\n>  \n>  \tif [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ];\n>  \tthen\n\nCool!\n\nI like the way adding a new feature has positive side effects on the\nrest of the code.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"222451","messageId":"CAETqRCjPkjZiKDmRc8TP-kZXOJwKn-_X2Bvnuqp=fJKRcwtuEw@mail.gmail.com","threadId":"34330","inReplyTo":"7vhagcgh0e.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Benoît Person","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-07-03T09:46:50Z","receivedAt":"2013-07-03T09:46:50Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":">> For now, GITPERLLIB is only used in that kind of statements:\n>> use lib (split(/:/, $ENV{GITPERLLIB} || ... ));\n>>\n>> The trailing ':' does not really matter, split will ignore it.\n>\n> That may be true with the current use, but \"For now\" leaves funny\n> taste, doesn't it?\ndefinitely. For me, the issue was that we were trading that \"funny\ntaste\" for less\nreadable code in wrap-for-bin.sh but with that default-substitution\nconstruct, it seems\nworth it. (a huge if-block seemed even funnier in fact :) )\n\n> It is not too much trouble to fix by writing\n>\n>   GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\"${GITPERLLIB:+:$GITPERLLIB}\"\n>\n> and we will not have to be worried about future changes breaking\n> today's assumption.\nThat construct is really nice :) did not know there was such a thing\nin bash, thanks.\n"},{"id":"222460","messageId":"51D3FD59.7090701@alum.mit.edu","threadId":"34330","inReplyTo":"1372804789-12732-3-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2013-07-03T10:30:49Z","receivedAt":"2013-07-03T10:30:49Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 07/03/2013 12:39 AM, benoit.person@ensimag.fr wrote:\n> From: Benoit Person <benoit.person@ensimag.fr>\n> \n> For now, bin-wrappers (based on wrap-for-bin.sh) redefine some\n> environnement variables (like $GITPERLLIB). If we want to chain to\n> those scripts and define one of those variables before, our changes\n> will be overwritten.\n> \n> This patch simply makes the bin-wrappers prepend their modifications\n> rather than redefine the vars.\n\nYour commit message makes it sound like GITPERLLIB is only one example\nof a general class of environment variables fixed by the patch, but in\nfact the patch address *only* GITPERLLIB.  Please make the commit\nmessage better match the patch.\n\nAnd maybe you could mention for posterity whether you have seen other\nvariables that will need fixing vs. you did an audit and think that\nGITPERLLIB is the only problematic one vs. you haven't looked for other\nsimilar problems at all.  This could save some time for the next person\nwith a similar itch and/or maybe inspire somebody to do an audit.\n\nThanks,\nMichael\n\n> Signed-off-by: Benoit Person <benoit.person@ensimag.fr>\n> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> ---\n>  wrap-for-bin.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\n> index 53a8dd0..dbebe49 100644\n> --- a/wrap-for-bin.sh\n> +++ b/wrap-for-bin.sh\n> @@ -14,7 +14,7 @@ else\n>  \tGIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'\n>  \texport GIT_TEMPLATE_DIR\n>  fi\n> -GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n> +GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib:'\"$GITPERLLIB\"\n>  GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'\n>  PATH='@@BUILD_DIR@@/bin-wrappers:'\"$PATH\"\n>  export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR\n> \n\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"222462","messageId":"vpqfvvvq5bl.fsf@anie.imag.fr","threadId":"34330","inReplyTo":"1372804789-12732-3-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-07-03T10:57:18Z","receivedAt":"2013-07-03T10:57:18Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\n> index 53a8dd0..dbebe49 100644\n> --- a/wrap-for-bin.sh\n> +++ b/wrap-for-bin.sh\n> @@ -14,7 +14,7 @@ else\n>  \tGIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'\n>  \texport GIT_TEMPLATE_DIR\n>  fi\n> -GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n> +GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib:'\"$GITPERLLIB\"\n\nThen you need to do something like this to prevent broken $GITPERLLIB in\nuser's configuration from interfering with the testsuite:\n\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -92,6 +92,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $(\"$PERL_PATH\" -e '\n        print join(\"\\n\", @vars);\n ')\n unset XDG_CONFIG_HOME\n+unset GITPERLLIB\n GIT_AUTHOR_EMAIL=author@example.com\n GIT_AUTHOR_NAME='A U Thor'\n GIT_COMMITTER_EMAIL=committer@example.com\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"222497","messageId":"7v38rve6i9.fsf@alter.siamese.dyndns.org","threadId":"34330","inReplyTo":"vpqfvvvq5bl.fsf@anie.imag.fr","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-03T20:24:46Z","receivedAt":"2013-07-03T20:24:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> benoit.person@ensimag.fr writes:\n>\n>> diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\n>> index 53a8dd0..dbebe49 100644\n>> --- a/wrap-for-bin.sh\n>> +++ b/wrap-for-bin.sh\n>> @@ -14,7 +14,7 @@ else\n>>  \tGIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'\n>>  \texport GIT_TEMPLATE_DIR\n>>  fi\n>> -GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n>> +GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib:'\"$GITPERLLIB\"\n>\n> Then you need to do something like this to prevent broken $GITPERLLIB in\n> user's configuration from interfering with the testsuite:\n>\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -92,6 +92,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $(\"$PERL_PATH\" -e '\n>         print join(\"\\n\", @vars);\n>  ')\n>  unset XDG_CONFIG_HOME\n> +unset GITPERLLIB\n>  GIT_AUTHOR_EMAIL=author@example.com\n>  GIT_AUTHOR_NAME='A U Thor'\n>  GIT_COMMITTER_EMAIL=committer@example.com\n\nYes, that is a good point.\n\nIt introduces a chicken-and-egg circularity for git-mw tests to use\nthe common test infrastructure by dot-sourcing this file, though,\nno?\n"},{"id":"222499","messageId":"vpqvc4r751g.fsf@anie.imag.fr","threadId":"34330","inReplyTo":"7v38rve6i9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-07-03T20:38:19Z","receivedAt":"2013-07-03T20:38:19Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> benoit.person@ensimag.fr writes:\n>>\n>>> diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\n>>> index 53a8dd0..dbebe49 100644\n>>> --- a/wrap-for-bin.sh\n>>> +++ b/wrap-for-bin.sh\n>>> @@ -14,7 +14,7 @@ else\n>>>  \tGIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'\n>>>  \texport GIT_TEMPLATE_DIR\n>>>  fi\n>>> -GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n>>> +GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib:'\"$GITPERLLIB\"\n>>\n>> Then you need to do something like this to prevent broken $GITPERLLIB in\n>> user's configuration from interfering with the testsuite:\n>>\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -92,6 +92,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $(\"$PERL_PATH\" -e '\n>>         print join(\"\\n\", @vars);\n>>  ')\n>>  unset XDG_CONFIG_HOME\n>> +unset GITPERLLIB\n>>  GIT_AUTHOR_EMAIL=author@example.com\n>>  GIT_AUTHOR_NAME='A U Thor'\n>>  GIT_COMMITTER_EMAIL=committer@example.com\n>\n> Yes, that is a good point.\n>\n> It introduces a chicken-and-egg circularity for git-mw tests to use\n> the common test infrastructure by dot-sourcing this file, though,\n> no?\n\nI don't get it. It Git Mediawiki's tests, the tests scripts source\ntest-lib.sh, that unsets GITPERLLIB. Then, it calls the\nmw-to-git/bin-wrapper/git that sets it properly, and calls the\ntoplevel's bin-wrapper.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"222508","messageId":"7vmwq3cnz1.fsf@alter.siamese.dyndns.org","threadId":"34330","inReplyTo":"vpqvc4r751g.fsf@anie.imag.fr","subject":"Re: [PATCH v7 2/7] wrap-for-bin: Make bin-wrappers chainable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-03T21:50:26Z","receivedAt":"2013-07-03T21:50:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> I don't get it. It Git Mediawiki's tests, the tests scripts source\n> test-lib.sh, that unsets GITPERLLIB. Then, it calls the\n> mw-to-git/bin-wrapper/git that sets it properly, and calls the\n> toplevel's bin-wrapper.\n\nAh, OK.  I somehow was assuming that a wrapper sets GITPERLLIB to\npoint at mediawiki stuff before running tests, which is the other\nway around.\n\nPlease ignore the noise, and thanks for a dose of sanity.\n"}]}