remote-mediawiki: annotate unquoted uses of run_git()
Explicitly annotate the invocations of run_git() which don't use quoted arguments. I'm not converting these to run_git_quoted() because these invocations pipe stderr to /dev/null, which the Perl open() API doesn't support. We could do a quoted version of this with IPC::Open3, but I don't think it's worth it to go through that here. Let's instead just mark these sites, and comment on why it's OK to use the variables we're using. This eliminates the last uses of run_git(), so we can remove the alias for it introduced in an earlier commit. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Sep 21, 2020 at 12:39 UTC
878d150106b0050253390623a8fd5acf553f4be0
1 file changed
+13
-6
contrib/mw-to-git/git-remote-mediawiki.perl
+13
-6
@@ -395,8 +395,6 @@ sub run_git_unquoted {
395
_run_git(["git $_[0]"], $_[1]);
396
}
397
398
-BEGIN { *run_git = \&run_git_unquoted }
399
-
398
sub get_all_mediafiles {
399
my $pages = shift;
400
# Attach list of all pages for media files from the API,
@@ -522,8 +520,11 @@ sub download_mw_mediafile {
520
}
521
522
sub get_last_local_revision {
525
- # Get note regarding last mediawiki revision
526
- my $note = run_git("notes --ref=${remotename}/mediawiki show refs/mediawiki/${remotename}/master 2>/dev/null");
523
+ # Get note regarding last mediawiki revision.
524
+ #
525
+ # It's OK to use run_git_unquoted() here because $remotename is
526
+ # supplied by the local git itself.
527
+ my $note = run_git_unquoted("notes --ref=${remotename}/mediawiki show refs/mediawiki/${remotename}/master 2>/dev/null");
528
my @note_info = split(/ /, $note);
529
530
my $lastrevision_number;
@@ -1188,10 +1189,16 @@ sub mw_push_revision {
1189
my $mw_revision = $last_remote_revid;
1190
1191
# Get sha1 of commit pointed by local HEAD
1191
- my $HEAD_sha1 = run_git("rev-parse ${local} 2>/dev/null");
1192
+ #
1193
+ # It's OK to use run_git_unquoted() because $local is supplied
1194
+ # by the local git itself.
1195
+ my $HEAD_sha1 = run_git_unquoted("rev-parse ${local} 2>/dev/null");
1196
chomp($HEAD_sha1);
1197
# Get sha1 of commit pointed by remotes/$remotename/master
1194
- my $remoteorigin_sha1 = run_git("rev-parse refs/remotes/${remotename}/master 2>/dev/null");
1198
+ #
1199
+ # It's OK to use run_git_unquoted() here because $remotename is
1200
+ # supplied by the local git itself.
1201
+ my $remoteorigin_sha1 = run_git_unquoted("rev-parse refs/remotes/${remotename}/master 2>/dev/null");
1202
chomp($remoteorigin_sha1);
1203
1204
if ($last_local_revid > 0 &&