git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-remote-mediawiki: support subpages as subdirectories

From
LSLyubomyr Shaydariv <dev.konsole@gmail.com>
Date
Aug 28, 2015, 06:14 UTC
Message-ID
<1440742486-4356-1-git-send-email-lyubomyr-shaydariv@users.noreply.github.com>

This is a fix for https://github.com/moy/Git-Mediawiki/issues/22 The subdirectories option is enabled using -c remote.origin.subpageDirs=true during the cloning and it is not recommended to be modified in or removed from .git/config after the cloning.

Signed-off-by: Lyubomyr Shaydariv <lyubomyr-shaydariv@users.noreply.github.com>
Reported-by: David Garcia Garzon
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 contrib/mw-to-git/git-remote-mediawiki.perl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 8dd74a9..f3624be 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -63,6 +63,11 @@ chomp(@tracked_pages);
 my @tracked_categories = split(/[ \n]/, run_git("config --get-all remote.${remotename}.categories"));
 chomp(@tracked_categories);
 
+# Use subdirectories for subpages
+my $use_subpage_dirs = run_git("config --get --bool remote.${remotename}.subpageDirs");
+chomp($use_subpage_dirs);
+$use_subpage_dirs = ($use_subpage_dirs eq 'true');
+
 # Import media files on pull
 my $import_media = run_git("config --get --bool remote.${remotename}.mediaimport");
 chomp($import_media);
@@ -689,6 +694,9 @@ sub fe_escape_path {
     $path =~ s/\\/\\\\/g;
     $path =~ s/"/\\"/g;
     $path =~ s/\n/\\n/g;
+    if ($use_subpage_dirs) {
+        $path =~ s/%2F/\//g;
+    }
     return qq("${path}");
 }
 
@@ -927,7 +935,7 @@ sub mw_import_revids {
 		# If this is a revision of the media page for new version
 		# of a file do one common commit for both file and media page.
 		# Else do commit only for that page.
-		print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of $commit{title}\n";
+		print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of ", fe_escape_path($commit{title}), "\n";
 		import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
 	}
 
-- 
1.9.1
Next: Junio C Hamano
Message 1 of 2 in “git-remote-mediawiki: support subpages as subdirectories”
  1. git-remote-mediawiki: support subpages as subdirectoriesLyubomyr Shaydariv, Aug 28, 2015
  2. Junio C HamanoAug 28, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.