From 1c229dbfee0db09de2c5db5921bed99dee522f2a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kr=C3=BCger?= Date: Mon, 15 Nov 2010 22:19:49 +0100 Subject: [PATCH] Girocco::Project: more robust method to detect errors when changing HEAD MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Apparently, Perl does interesting things with the return code of system(), so instead check $? afterwards... and bypass the shell by passing system() a list, for added efficiency and security. Signed-off-by: Jan Krüger --- Girocco/Project.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Girocco/Project.pm b/Girocco/Project.pm index d53ca1c..7e24c43 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -543,7 +543,8 @@ sub set_HEAD { if ($newHEAD =~ /^\/|['<>]|\.\.|\/$/) { die "grossly invalid new HEAD: $newHEAD"; } - system("$Girocco::Config::git_bin --git-dir=$self->{path} symbolic-ref HEAD 'refs/heads/$newHEAD'") or die "could not set HEAD"; + system($Girocco::Config::git_bin, "--git-dir=$self->{path}", 'symbolic-ref', 'HEAD', "refs/heads/$newHEAD"); + die "could not set HEAD" if ($? >> 8); } ### static methods -- 2.11.4.GIT