Skip to content

Commit 878d150

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4842a11 commit 878d150

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,6 @@ sub run_git_unquoted {
395395
_run_git(["git $_[0]"], $_[1]);
396396
}
397397

398-
BEGIN { *run_git = \&run_git_unquoted }
399-
400398
sub get_all_mediafiles {
401399
my $pages = shift;
402400
# Attach list of all pages for media files from the API,
@@ -522,8 +520,11 @@ sub download_mw_mediafile {
522520
}
523521

524522
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");
527528
my @note_info = split(/ /, $note);
528529

529530
my $lastrevision_number;
@@ -1188,10 +1189,16 @@ sub mw_push_revision {
11881189
my $mw_revision = $last_remote_revid;
11891190

11901191
# 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");
11921196
chomp($HEAD_sha1);
11931197
# 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");
11951202
chomp($remoteorigin_sha1);
11961203

11971204
if ($last_local_revid > 0 &&

0 commit comments

Comments
 (0)