diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2020-09-21 13:39:57 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-21 22:37:38 +0300 |
commit | 2d6b08aff41026019e2051abec05e52785450e83 (patch) | |
tree | 485385c384cda33bf7709f3e0a81a41ad0d951b0 /contrib | |
parent | f8ab018dafc2ecbea29397c2112c9e7156d7f080 (diff) |
remote-mediawiki: provide a list form of run_git()
Invoking commands as "git $args" doesn't quote $args. Let's support
["git", $args] as well, and create corresponding run_git_quoted() and
run_git_unquoted() aliases for subsequent changes when we move the
code over to the new style of invoking this function. At that point
we'll delete the then-unused run_git() wrapper.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/mw-to-git/git-remote-mediawiki.perl | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl index 26d5e1a174..59cb277517 100755 --- a/contrib/mw-to-git/git-remote-mediawiki.perl +++ b/contrib/mw-to-git/git-remote-mediawiki.perl @@ -369,12 +369,14 @@ sub get_mw_pages { return %pages; } -# usage: $out = run_git("command args"); -# $out = run_git("command args", "raw"); # don't interpret output as UTF-8. -sub run_git { +# usage: $out = run_git_quoted(["command", "args", ...]); +# $out = run_git_quoted(["command", "args", ...], "raw"); # don't interpret output as UTF-8. +# $out = run_git_unquoted(["command args"); # don't quote arguments +# $out = run_git_unquoted(["command args", "raw"); # ditto but raw instead of UTF-8 as above +sub _run_git { my $args = shift; my $encoding = (shift || 'encoding(UTF-8)'); - open(my $git, "-|:${encoding}", "git ${args}") + open(my $git, "-|:${encoding}", @$args) or die "Unable to fork: $!\n"; my $res = do { local $/ = undef; @@ -385,6 +387,15 @@ sub run_git { return $res; } +sub run_git_quoted { + _run_git(["git", @{$_[0]}], $_[1]); +} + +sub run_git_unquoted { + _run_git(["git $_[0]"], $_[1]); +} + +BEGIN { *run_git = \&run_git_unquoted } sub get_all_mediafiles { my $pages = shift; |