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

[PATCH v2 17/18] remote-mediawiki: annotate unquoted uses of run_git()

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 21, 2020, 10:39 UTC
Message-ID
<20200921104000.2304-18-avarab@gmail.com>
In-Reply-To
<20200916102918.29805-1-avarab@gmail.com>

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>
---
 contrib/mw-to-git/git-remote-mediawiki.perl | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index bbf68ddc46..d21c18df7b 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -395,8 +395,6 @@ sub run_git_unquoted {
     _run_git(["git $_[0]"], $_[1]);
 }
 
-BEGIN { *run_git = \&run_git_unquoted }
-
 sub get_all_mediafiles {
 	my $pages = shift;
 	# Attach list of all pages for media files from the API,
@@ -522,8 +520,11 @@ sub download_mw_mediafile {
 }
 
 sub get_last_local_revision {
-	# Get note regarding last mediawiki revision
-	my $note = run_git("notes --ref=${remotename}/mediawiki show refs/mediawiki/${remotename}/master 2>/dev/null");
+	# Get note regarding last mediawiki revision.
+	#
+	# It's OK to use run_git_unquoted() here because $remotename is
+	# supplied by the local git itself.
+	my $note = run_git_unquoted("notes --ref=${remotename}/mediawiki show refs/mediawiki/${remotename}/master 2>/dev/null");
 	my @note_info = split(/ /, $note);
 
 	my $lastrevision_number;
@@ -1188,10 +1189,16 @@ sub mw_push_revision {
 	my $mw_revision = $last_remote_revid;
 
 	# Get sha1 of commit pointed by local HEAD
-	my $HEAD_sha1 = run_git("rev-parse ${local} 2>/dev/null");
+	#
+	# It's OK to use run_git_unquoted() because $local is supplied
+	# by the local git itself.
+	my $HEAD_sha1 = run_git_unquoted("rev-parse ${local} 2>/dev/null");
 	chomp($HEAD_sha1);
 	# Get sha1 of commit pointed by remotes/$remotename/master
-	my $remoteorigin_sha1 = run_git("rev-parse refs/remotes/${remotename}/master 2>/dev/null");
+	#
+	# It's OK to use run_git_unquoted() here because $remotename is
+	# supplied by the local git itself.
+	my $remoteorigin_sha1 = run_git_unquoted("rev-parse refs/remotes/${remotename}/master 2>/dev/null");
 	chomp($remoteorigin_sha1);
 
 	if ($last_local_revid > 0 &&
-- 
2.28.0.297.g1956fa8f8d
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 48 of 54 in “remote-mediawiki: various fixes to make tests pass”
  1. 00/15 remote-mediawiki: various fixes to make tests passÆvar Arnfjörð Bjarmason, Sep 16, 2020
  2. 13/15 remote-mediawiki tests: use CLI installerÆvar Arnfjörð Bjarmason, Sep 16, 2020
  3. 15/15 remote-mediawiki tests: annotate failing testsÆvar Arnfjörð Bjarmason, Sep 16, 2020
  4. 14/15 remote-mediawiki: fix duplicate revisions being importedÆvar Arnfjörð Bjarmason, Sep 16, 2020
  5. 06/15 remote-mediawiki tests: use test_cmp in testsÆvar Arnfjörð Bjarmason, Sep 16, 2020
  6. Jeff KingSep 16, 2020
  7. 12/15 remote-mediawiki tests: use inline PerlIO for readabilityÆvar Arnfjörð Bjarmason, Sep 16, 2020
  8. 09/15 remote-mediawiki tests: use "$dir/" instead of "$dir."Ævar Arnfjörð Bjarmason, Sep 16, 2020
  9. Jeff KingSep 16, 2020
  10. Junio C HamanoSep 16, 2020
  11. 07/15 remote-mediawiki tests: guard test_cmp with test_path_is_fileÆvar Arnfjörð Bjarmason, Sep 16, 2020
  12. Jeff KingSep 16, 2020
  13. Đoàn Trần Công DanhSep 16, 2020
  14. Eric SunshineSep 16, 2020
  15. Junio C HamanoSep 16, 2020
  16. test_cmp: diagnose incorrect arguments more preciselyEric Sunshine, Oct 3, 2020
  17. Junio C HamanoOct 3, 2020
  18. Ævar Arnfjörð BjarmasonSep 21, 2020
  19. Ævar Arnfjörð BjarmasonSep 21, 2020
  20. 11/15 remote-mediawiki tests: replace deprecated Perl constructÆvar Arnfjörð Bjarmason, Sep 16, 2020
  21. Jeff KingSep 16, 2020
  22. 08/15 remote-mediawiki tests: change `[]` to `test`Ævar Arnfjörð Bjarmason, Sep 16, 2020
  23. 10/15 remote-mediawiki tests: use a more idiomatic dispatch tableÆvar Arnfjörð Bjarmason, Sep 16, 2020
  24. 03/15 remote-mediawiki doc: bump recommended PHP version to 7.3Ævar Arnfjörð Bjarmason, Sep 16, 2020
  25. Đoàn Trần Công DanhSep 16, 2020
  26. Junio C HamanoSep 16, 2020
  27. 02/15 remote-mediawiki doc: link to MediaWiki's current versionÆvar Arnfjörð Bjarmason, Sep 16, 2020
  28. 01/15 remote-mediawiki doc: correct link to GitHub projectÆvar Arnfjörð Bjarmason, Sep 16, 2020
  29. Jeff KingSep 16, 2020
  30. Junio C HamanoSep 17, 2020
  31. 04/15 remote-mediawiki tests: use the login/password variablesÆvar Arnfjörð Bjarmason, Sep 16, 2020
  32. Johannes SchindelinSep 16, 2020
  33. Ævar Arnfjörð BjarmasonSep 21, 2020
  34. 05/15 remote-mediawiki tests: use a 10 character passwordÆvar Arnfjörð Bjarmason, Sep 16, 2020
  35. 00/18 remote-mediawiki: fix RCE issue, and the testsÆvar Arnfjörð Bjarmason, Sep 21, 2020
  36. Jeff KingSep 25, 2020
  37. 03/18 remote-mediawiki doc: don't hardcode Debian PHP versionsÆvar Arnfjörð Bjarmason, Sep 21, 2020
  38. 01/18 remote-mediawiki doc: correct link to GitHub projectÆvar Arnfjörð Bjarmason, Sep 21, 2020
  39. 02/18 remote-mediawiki doc: link to MediaWiki's current versionÆvar Arnfjörð Bjarmason, Sep 21, 2020
  40. 07/18 remote-mediawiki tests: change `[]` to `test`Ævar Arnfjörð Bjarmason, Sep 21, 2020
  41. 09/18 remote-mediawiki tests: use a more idiomatic dispatch tableÆvar Arnfjörð Bjarmason, Sep 21, 2020
  42. 11/18 remote-mediawiki tests: use inline PerlIO for readabilityÆvar Arnfjörð Bjarmason, Sep 21, 2020
  43. 06/18 remote-mediawiki tests: use test_cmp in testsÆvar Arnfjörð Bjarmason, Sep 21, 2020
  44. 08/18 remote-mediawiki tests: use "$dir/" instead of "$dir."Ævar Arnfjörð Bjarmason, Sep 21, 2020
  45. 04/18 remote-mediawiki tests: use the login/password variablesÆvar Arnfjörð Bjarmason, Sep 21, 2020
  46. 05/18 remote-mediawiki tests: use a 10 character passwordÆvar Arnfjörð Bjarmason, Sep 21, 2020
  47. 10/18 remote-mediawiki tests: replace deprecated Perl constructÆvar Arnfjörð Bjarmason, Sep 21, 2020
  48. 17/18 remote-mediawiki: annotate unquoted uses of run_git()Ævar Arnfjörð Bjarmason, Sep 21, 2020
  49. 12/18 remote-mediawiki tests: use CLI installerÆvar Arnfjörð Bjarmason, Sep 21, 2020
  50. 18/18 remote-mediawiki: use "sh" to eliminate unquoted commandsÆvar Arnfjörð Bjarmason, Sep 21, 2020
  51. 16/18 remote-mediawiki: convert to quoted run_git() invocationÆvar Arnfjörð Bjarmason, Sep 21, 2020
  52. 15/18 remote-mediawiki: provide a list form of run_git()Ævar Arnfjörð Bjarmason, Sep 21, 2020
  53. 13/18 remote-mediawiki: fix duplicate revisions being importedÆvar Arnfjörð Bjarmason, Sep 21, 2020
  54. 14/18 remote-mediawiki tests: annotate failing testsÆvar Arnfjörð Bjarmason, Sep 21, 2020

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.