Merge branch 'mm/mediawiki-encoding-fix'
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 Jun 2014 19:06:44 +0000 (12:06 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jun 2014 19:06:44 +0000 (12:06 -0700)
* mm/mediawiki-encoding-fix:
git-remote-mediawiki: fix encoding issue for UTF-8 media files
git-remote-mediawiki: allow stop/start-ing the test server

contrib/mw-to-git/git-remote-mediawiki.perl
contrib/mw-to-git/t/install-wiki.sh
contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh
contrib/mw-to-git/t/test-gitmw-lib.sh
index 3f8d993afaca53024aa75b4118da9ee80e6a6313..8dd74a9a406e9cfd685ea1af3947e4bea4c82f90 100755 (executable)
@@ -461,7 +461,12 @@ sub download_mw_mediafile {
 
        my $response = $mediawiki->{ua}->get($download_url);
        if ($response->code == HTTP_CODE_OK) {
-               return $response->decoded_content;
+               # It is tempting to return
+               # $response->decoded_content({charset => "none"}), but
+               # when doing so, utf8::downgrade($content) fails with
+               # "Wide character in subroutine entry".
+               $response->decode();
+               return $response->content();
        } else {
                print {*STDERR} "Error downloading mediafile from :\n";
                print {*STDERR} "URL: ${download_url}\n";
index 70a53f67fd06bd2ce6f2f544655b03b99c6b2ee9..c215213c4bfddb583fb3de0eb624e0cffdb8cc7c 100755 (executable)
@@ -20,6 +20,8 @@ usage () {
        echo "          install | -i :  Install a wiki on your computer."
        echo "          delete | -d : Delete the wiki and all its pages and "
        echo "                  content."
+       echo "          start  | -s : Start the previously configured lighttpd daemon"
+       echo "          stop        : Stop lighttpd daemon."
 }
 
 
@@ -33,6 +35,14 @@ case "$1" in
                wiki_delete
                exit 0
                ;;
+       "start" | "-s")
+               start_lighttpd
+               exit
+               ;;
+       "stop")
+               stop_lighttpd
+               exit
+               ;;
        "--help" | "-h")
                usage
                exit 0
index 5a0373935f1f4b66c4521158e4b3c41508c908ea..3ff3a095670ecdf578dc9f4d51841c102c5a10fd 100755 (executable)
@@ -58,6 +58,25 @@ test_expect_success 'git clone works on previously created wiki with media files
        test_cmp mw_dir_clone/Foo.txt mw_dir/Foo.txt
 '
 
+test_expect_success 'git push can upload media (File:) files containing valid UTF-8' '
+       wiki_reset &&
+       git clone mediawiki::'"$WIKI_URL"' mw_dir &&
+       (
+               cd mw_dir &&
+               "$PERL_PATH" -e "print STDOUT \"UTF-8 content: éèàéê€.\";" >Bar.txt &&
+               git add Bar.txt &&
+               git commit -m "add a text file with UTF-8 content" &&
+               git push
+       )
+'
+
+test_expect_success 'git clone works on previously created wiki with media files containing valid UTF-8' '
+       test_when_finished "rm -rf mw_dir mw_dir_clone" &&
+       git clone -c remote.origin.mediaimport=true \
+               mediawiki::'"$WIKI_URL"' mw_dir_clone &&
+       test_cmp mw_dir_clone/Bar.txt mw_dir/Bar.txt
+'
+
 test_expect_success 'git push & pull work with locally renamed media files' '
        wiki_reset &&
        git clone mediawiki::'"$WIKI_URL"' mw_dir &&
index 3372b2af346ac23a73a7723ac6d0c81fb8c5e705..d9a114995a0f75434fc105ce7be508293da49227 100755 (executable)
@@ -289,7 +289,6 @@ start_lighttpd () {
 # Kill daemon lighttpd and removes files and folders associated.
 stop_lighttpd () {
        test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid")
-       rm -rf "$WEB"
 }
 
 # Create the SQLite database of the MediaWiki. If the database file already
@@ -415,6 +414,7 @@ wiki_reset () {
 wiki_delete () {
        if test $LIGHTTPD = "true"; then
                stop_lighttpd
+               rm -fr "$WEB"
        else
                # Delete the wiki's directory.
                rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||