{"thread":{"id":"40204","subject":"[PATCH] git-remote-mediawiki: support subpages as subdirectories","startedAt":"2015-08-28T06:14:46Z","lastAt":"2015-08-28T17:31:59Z","messageCount":2,"participants":["Lyubomyr Shaydariv","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"268824","messageId":"1440742486-4356-1-git-send-email-lyubomyr-shaydariv@users.noreply.github.com","threadId":"40204","inReplyTo":null,"subject":"[PATCH] git-remote-mediawiki: support subpages as subdirectories","fromName":"Lyubomyr Shaydariv","fromEmail":"dev.konsole@gmail.com","sentAt":"2015-08-28T06:14:46Z","receivedAt":"2015-08-28T06:14:46Z","isPatch":true,"sender":{"key":"dev.konsole@gmail.com","avatar":null},"body":"This is a fix for https://github.com/moy/Git-Mediawiki/issues/22\nThe subdirectories option is enabled using -c remote.origin.subpageDirs=true\nduring the cloning and it is not recommended to be modified in or\nremoved from .git/config after the cloning.\n\nSigned-off-by: Lyubomyr Shaydariv <lyubomyr-shaydariv@users.noreply.github.com>\nReported-by: David Garcia Garzon\nReviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl | 10 +++++++++-\n 1 file changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 8dd74a9..f3624be 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -63,6 +63,11 @@ chomp(@tracked_pages);\n my @tracked_categories = split(/[ \\n]/, run_git(\"config --get-all remote.${remotename}.categories\"));\n chomp(@tracked_categories);\n \n+# Use subdirectories for subpages\n+my $use_subpage_dirs = run_git(\"config --get --bool remote.${remotename}.subpageDirs\");\n+chomp($use_subpage_dirs);\n+$use_subpage_dirs = ($use_subpage_dirs eq 'true');\n+\n # Import media files on pull\n my $import_media = run_git(\"config --get --bool remote.${remotename}.mediaimport\");\n chomp($import_media);\n@@ -689,6 +694,9 @@ sub fe_escape_path {\n     $path =~ s/\\\\/\\\\\\\\/g;\n     $path =~ s/\"/\\\\\"/g;\n     $path =~ s/\\n/\\\\n/g;\n+    if ($use_subpage_dirs) {\n+        $path =~ s/%2F/\\//g;\n+    }\n     return qq(\"${path}\");\n }\n \n@@ -927,7 +935,7 @@ sub mw_import_revids {\n \t\t# If this is a revision of the media page for new version\n \t\t# of a file do one common commit for both file and media page.\n \t\t# Else do commit only for that page.\n-\t\tprint {*STDERR} \"${n}/\", scalar(@{$revision_ids}), \": Revision #$rev->{revid} of $commit{title}\\n\";\n+\t\tprint {*STDERR} \"${n}/\", scalar(@{$revision_ids}), \": Revision #$rev->{revid} of \", fe_escape_path($commit{title}), \"\\n\";\n \t\timport_file_revision(\\%commit, ($fetch_from == 1), $n_actual, \\%mediafile);\n \t}\n \n-- \n1.9.1\n"},{"id":"268854","messageId":"xmqq7fof2ub4.fsf@gitster.mtv.corp.google.com","threadId":"40204","inReplyTo":"1440742486-4356-1-git-send-email-lyubomyr-shaydariv@users.noreply.github.com","subject":"Re: [PATCH] git-remote-mediawiki: support subpages as subdirectories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-28T17:31:59Z","receivedAt":"2015-08-28T17:31:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lyubomyr Shaydariv <dev.konsole@gmail.com> writes:\n\n> This is a fix for https://github.com/moy/Git-Mediawiki/issues/22\n\nDo not force readers of \"git log\" to go to the web.  Please have a\nreal problem description (I notice that the initial description of\nissues/22 by vokimon very much readable and you can just use that)\nbefore that URL.\n\n> The subdirectories option is enabled using -c remote.origin.subpageDirs=true\n> during the cloning and it is not recommended to be modified in or\n> removed from .git/config after the cloning.\n\nWhat happens when I clone without setting it and then later set it\n(or vice versa)?  Does it completely break the resulting repository\nand/or the MediaWiki side?\n\nWhat I am wondering is if it is merely \"it is not recommended\" or it\nshould be a bit stronger in order to save users from hurting\nthemselves.  If the possible breakage is minor, a casual mention\nlike the above in the log message may be OK.  On the other hand, if\nit is major enough, we may even want to have a code that forbids\nflipping the setting in the middle (which may mean that you would\nhave this recorded somewhere outside of the config file).\n\n> Signed-off-by: Lyubomyr Shaydariv <lyubomyr-shaydariv@users.noreply.github.com>\n> Reported-by: David Garcia Garzon\n> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n>  contrib/mw-to-git/git-remote-mediawiki.perl | 10 +++++++++-\n>  1 file changed, 9 insertions(+), 1 deletion(-)\n>\n> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\n> index 8dd74a9..f3624be 100755\n> --- a/contrib/mw-to-git/git-remote-mediawiki.perl\n> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n> @@ -63,6 +63,11 @@ chomp(@tracked_pages);\n>  my @tracked_categories = split(/[ \\n]/, run_git(\"config --get-all remote.${remotename}.categories\"));\n>  chomp(@tracked_categories);\n>  \n> +# Use subdirectories for subpages\n> +my $use_subpage_dirs = run_git(\"config --get --bool remote.${remotename}.subpageDirs\");\n> +chomp($use_subpage_dirs);\n> +$use_subpage_dirs = ($use_subpage_dirs eq 'true');\n> +\n>  # Import media files on pull\n>  my $import_media = run_git(\"config --get --bool remote.${remotename}.mediaimport\");\n>  chomp($import_media);\n> @@ -689,6 +694,9 @@ sub fe_escape_path {\n>      $path =~ s/\\\\/\\\\\\\\/g;\n>      $path =~ s/\"/\\\\\"/g;\n>      $path =~ s/\\n/\\\\n/g;\n> +    if ($use_subpage_dirs) {\n> +        $path =~ s/%2F/\\//g;\n> +    }\n>      return qq(\"${path}\");\n>  }\n>  \n> @@ -927,7 +935,7 @@ sub mw_import_revids {\n>  \t\t# If this is a revision of the media page for new version\n>  \t\t# of a file do one common commit for both file and media page.\n>  \t\t# Else do commit only for that page.\n> -\t\tprint {*STDERR} \"${n}/\", scalar(@{$revision_ids}), \": Revision #$rev->{revid} of $commit{title}\\n\";\n> +\t\tprint {*STDERR} \"${n}/\", scalar(@{$revision_ids}), \": Revision #$rev->{revid} of \", fe_escape_path($commit{title}), \"\\n\";\n>  \t\timport_file_revision(\\%commit, ($fetch_from == 1), $n_actual, \\%mediafile);\n>  \t}\n"}]}