diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-04 14:52:20 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-04 14:52:20 -0700 |
commit | f4bc5c4dbd713b78dec06a042fb26dd50594bc8a (patch) | |
tree | ed2702fdb6414050eb0c5b4189c3e04f58a3d8d4 | |
parent | da34e9e629a1dda284064396eda8290ec5d6c90b (diff) | |
download | p5-Git-Annex-f4bc5c4dbd713b78dec06a042fb26dd50594bc8a.tar.gz |
avoid invoking the shell during constructor
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | lib/Git/Annex.pm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Git/Annex.pm b/lib/Git/Annex.pm index ad56ca8..0877697 100644 --- a/lib/Git/Annex.pm +++ b/lib/Git/Annex.pm @@ -69,6 +69,7 @@ use Data::Compare; use List::Util qw(all); use Time::HiRes qw(stat time); use Git::Annex::BatchCommand; +use IPC::System::Simple qw(capturex); use Moo; use namespace::clean; @@ -298,14 +299,17 @@ around BUILDARGS => sub { die "fork() failed: $!" unless defined $pid; if ($pid) { wait; - if ($?) { - chomp($toplevel = `git -C $toplevel rev-parse --show-toplevel`); - die "git rev-parse --show-toplevel failed" if $?; - } + chomp($toplevel = capturex "git", + "-C", $toplevel, "rev-parse", "--show-toplevel") + if $?; } else { close STDERR; - chomp(my $output = `git -C $toplevel rev-parse --is-inside-work-tree`); - exit ($output and $output eq "true"); + my $output; + try { + $output = capturex "git", "-C", $toplevel, "rev-parse", + "--is-inside-work-tree"; + }; + exit($output and $output =~ /true/); } return { toplevel => $toplevel }; |