56
57
# Accept both space-separated and multiple keys in config file.
58
# Spaces should be written as _ anyway because we'll use chomp.
59
-my @tracked_pages = split(/[ \n]/, run_git("config --get-all remote.${remotename}.pages"));
59
+my @tracked_pages = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.pages"]));
60
chomp(@tracked_pages);
61
62
# Just like @tracked_pages, but for MediaWiki categories.
63
-my @tracked_categories = split(/[ \n]/, run_git("config --get-all remote.${remotename}.categories"));
63
+my @tracked_categories = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.categories"]));
64
chomp(@tracked_categories);
65
66
# Just like @tracked_categories, but for MediaWiki namespaces.
67
-my @tracked_namespaces = split(/[ \n]/, run_git("config --get-all remote.${remotename}.namespaces"));
67
+my @tracked_namespaces = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.namespaces"]));
68
for (@tracked_namespaces) { s/_/ /g; }
69
chomp(@tracked_namespaces);
70
71
# Import media files on pull
72
-my $import_media = run_git("config --get --bool remote.${remotename}.mediaimport");
72
+my $import_media = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.mediaimport"]);
73
chomp($import_media);
74
$import_media = ($import_media eq 'true');
75
76
# Export media files on push
77
-my $export_media = run_git("config --get --bool remote.${remotename}.mediaexport");
77
+my $export_media = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.mediaexport"]);
78
chomp($export_media);
79
$export_media = !($export_media eq 'false');
80
81
-my $wiki_login = run_git("config --get remote.${remotename}.mwLogin");
81
+my $wiki_login = run_git_quoted(["config", "--get", "remote.${remotename}.mwLogin"]);
82
# Note: mwPassword is discouraged. Use the credential system instead.
83
-my $wiki_passwd = run_git("config --get remote.${remotename}.mwPassword");
84
-my $wiki_domain = run_git("config --get remote.${remotename}.mwDomain");
83
+my $wiki_passwd = run_git_quoted(["config", "--get", "remote.${remotename}.mwPassword"]);
84
+my $wiki_domain = run_git_quoted(["config", "--get", "remote.${remotename}.mwDomain"]);
85
chomp($wiki_login);
86
chomp($wiki_passwd);
87
chomp($wiki_domain);
88
89
# Import only last revisions (both for clone and fetch)
90
-my $shallow_import = run_git("config --get --bool remote.${remotename}.shallow");
90
+my $shallow_import = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.shallow"]);
91
chomp($shallow_import);
92
$shallow_import = ($shallow_import eq 'true');
93
97
# Possible values:
98
# - by_rev: perform one query per new revision on the remote wiki
99
# - by_page: query each tracked page for new revision
100
-my $fetch_strategy = run_git("config --get remote.${remotename}.fetchStrategy");
100
+my $fetch_strategy = run_git_quoted(["config", "--get", "remote.${remotename}.fetchStrategy"]);
101
if (!$fetch_strategy) {
102
- $fetch_strategy = run_git('config --get mediawiki.fetchStrategy');
102
+ $fetch_strategy = run_git_quoted(["config", "--get", "mediawiki.fetchStrategy"]);
103
}
104
chomp($fetch_strategy);
105
if (!$fetch_strategy) {
123
# will get the history with information lost). If the import is
124
# deterministic, this means everybody gets the same sha1 for each
125
# MediaWiki revision.
126
-my $dumb_push = run_git("config --get --bool remote.${remotename}.dumbPush");
126
+my $dumb_push = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.dumbPush"]);
127
if (!$dumb_push) {
128
- $dumb_push = run_git('config --get --bool mediawiki.dumbPush');
128
+ $dumb_push = run_git_quoted(["config", "--get", "--bool", "mediawiki.dumbPush"]);
129
}
130
chomp($dumb_push);
131
$dumb_push = ($dumb_push eq 'true');
984
}
985
986
sub error_non_fast_forward {
987
- my $advice = run_git('config --bool advice.pushNonFastForward');
987
+ my $advice = run_git_quoted(["config", "--bool", "advice.pushNonFastForward"]);
988
chomp($advice);
989
if ($advice ne 'false') {
990
# Native git-push would show this after the summary.
1028
}
1029
} else {
1030
# Don't let perl try to interpret file content as UTF-8 => use "raw"
1031
- my $content = run_git("cat-file blob ${new_sha1}", 'raw');
1031
+ my $content = run_git_quoted(["cat-file", "blob", $new_sha1], 'raw');
1032
if ($content ne EMPTY) {
1033
$mediawiki = connect_maybe($mediawiki, $remotename, $url);
1034
$mediawiki->{config}->{upload_url} =
1098
# with this content instead:
1099
$file_content = DELETED_CONTENT;
1100
} else {
1101
- $file_content = run_git("cat-file blob ${new_sha1}");
1101
+ $file_content = run_git_quoted(["cat-file", "blob", $new_sha1]);
1102
}
1103
1104
$mediawiki = connect_maybe($mediawiki, $remotename, $url);
1211
my $parsed_sha1 = $remoteorigin_sha1;
1212
# Find a path from last MediaWiki commit to pushed commit
1213
print {*STDERR} "Computing path from local to remote ...\n";
1214
- my @local_ancestry = split(/\n/, run_git("rev-list --boundary --parents ${local} ^${parsed_sha1}"));
1214
+ my @local_ancestry = split(/\n/, run_git_quoted(["rev-list", "--boundary", "--parents", $local, "^${parsed_sha1}"]));
1215
my %local_ancestry;
1216
foreach my $line (@local_ancestry) {
1217
if (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
1235
# No remote mediawiki revision. Export the whole
1236
# history (linearized with --first-parent)
1237
print {*STDERR} "Warning: no common ancestor, pushing complete history\n";
1238
- my $history = run_git("rev-list --first-parent --children ${local}");
1238
+ my $history = run_git_quoted(["rev-list", "--first-parent", "--children", $local]);
1239
my @history = split(/\n/, $history);
1240
@history = @history[1..$#history];
1241
foreach my $line (reverse @history) {
1247
foreach my $commit_info_split (@commit_pairs) {
1248
my $sha1_child = @{$commit_info_split}[0];
1249
my $sha1_commit = @{$commit_info_split}[1];
1250
- my $diff_infos = run_git("diff-tree -r --raw -z ${sha1_child} ${sha1_commit}");
1250
+ my $diff_infos = run_git_quoted(["diff-tree", "-r", "--raw", "-z", $sha1_child, $sha1_commit]);
1251
# TODO: we could detect rename, and encode them with a #redirect on the wiki.
1252
# TODO: for now, it's just a delete+add
1253
my @diff_info_list = split(/\0/, $diff_infos);
1254
# Keep the subject line of the commit message as mediawiki comment for the revision
1255
- my $commit_msg = run_git(qq(log --no-walk --format="%s" ${sha1_commit}));
1255
+ my $commit_msg = run_git_quoted(["log", "--no-walk", '--format="%s"', $sha1_commit]);
1256
chomp($commit_msg);
1257
# Push every blob
1258
while (@diff_info_list) {
1277
}
1278
}
1279
if (!$dumb_push) {
1280
- run_git(qq(notes --ref=${remotename}/mediawiki add -f -m "mediawiki_revision: ${mw_revision}" ${sha1_commit}));
1280
+ run_git_quoted(["notes", "--ref=${remotename}/mediawiki",
1281
+ "add", "-f", "-m",
1282
+ "mediawiki_revision: ${mw_revision}",
1283
+ $sha1_commit]);
1284
}
1285
}
1286
1321
# already cached. Namespaces are stored in form:
1322
# "Name_of_namespace:Id_namespace", ex.: "File:6".
1323
my @temp = split(/\n/,
1321
- run_git("config --get-all remote.${remotename}.namespaceCache"));
1324
+ run_git_quoted(["config", "--get-all", "remote.${remotename}.namespaceCache"]));
1325
chomp(@temp);
1326
foreach my $ns (@temp) {
1327
my ($n, $id) = split(/:/, $ns);
1375
1376
# Store explicitly requested namespaces on disk
1377
if (!exists $cached_mw_namespace_id{$name}) {
1375
- run_git(qq(config --add remote.${remotename}.namespaceCache "${name}:${store_id}"));
1378
+ run_git_quoted(["config", "--add", "remote.${remotename}.namespaceCache", "${name}:${store_id}"]);
1379
$cached_mw_namespace_id{$name} = 1;
1380
}
1381
return $id;