Skip to content

Commit

Permalink
archimport: use safe_pipe_capture for user input
Browse files Browse the repository at this point in the history
Refnames can contain shell metacharacters which need to be
passed verbatim to sub-processes. Using safe_pipe_capture
skips the shell entirely.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Sep 12, 2017
1 parent 4d4165b commit 8d0fad0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-archimport.perl
Expand Up @@ -983,7 +983,7 @@ sub find_parents {
# check that we actually know about the branch
next unless -e "$git_dir/refs/heads/$branch";

my $mergebase = `git-merge-base $branch $ps->{branch}`;
my $mergebase = safe_pipe_capture(qw(git-merge-base), $branch, $ps->{branch});
if ($?) {
# Don't die here, Arch supports one-way cherry-picking
# between branches with no common base (or any relationship
Expand Down Expand Up @@ -1074,7 +1074,7 @@ sub find_parents {

sub git_rev_parse {
my $name = shift;
my $val = `git-rev-parse $name`;
my $val = safe_pipe_capture(qw(git-rev-parse), $name);
die "Error: git-rev-parse $name" if $?;
chomp $val;
return $val;
Expand Down

0 comments on commit 8d0fad0

Please sign in to comment.