Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0D981431FD5 for ; Sun, 6 Jul 2014 13:41:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xCaDQjXAm5Uj for ; Sun, 6 Jul 2014 13:41:03 -0700 (PDT) Received: from qmta02.westchester.pa.mail.comcast.net (qmta02.westchester.pa.mail.comcast.net [76.96.62.24]) by olra.theworths.org (Postfix) with ESMTP id 68AA3431FAF for ; Sun, 6 Jul 2014 13:41:03 -0700 (PDT) Received: from omta11.westchester.pa.mail.comcast.net ([76.96.62.36]) by qmta02.westchester.pa.mail.comcast.net with comcast id P8Wk1o0020mv7h0518h2fB; Sun, 06 Jul 2014 20:41:02 +0000 Received: from odin.tremily.us ([24.18.63.50]) by omta11.westchester.pa.mail.comcast.net with comcast id P8h01o00Y152l3L3X8h1kw; Sun, 06 Jul 2014 20:41:02 +0000 Received: from mjolnir.tremily.us (unknown [192.168.0.140]) by odin.tremily.us (Postfix) with ESMTPS id DBDB212700E5; Sun, 6 Jul 2014 13:40:59 -0700 (PDT) Received: (nullmailer pid 1903 invoked by uid 1000); Sun, 06 Jul 2014 20:40:27 -0000 From: "W. Trevor King" To: notmuch@notmuchmail.org Subject: [PATCH 1/4] nmbug: Add a git_with_status helper function Date: Sun, 6 Jul 2014 13:40:19 -0700 Message-Id: <6ed6edd459cd50402d7e4abc50a6967709e08f16.1404678709.git.wking@tremily.us> X-Mailer: git-send-email 1.9.1.353.gc66d89d In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1404679262; bh=F8943E/wKjGwJI6o5yUo8yKieldJZmtDMJYcSp0mvB0=; h=Received:Received:Received:Received:From:To:Subject:Date: Message-Id; b=ffL4y7Es10phNqbHXfZElBlRZpYeNx3stg7ER4TEko5NMVR20W8i/Z/R6T1sj63gS EI3RU5/RksOZxtBZktUmoEZ9W0lS02nj/0z1C0bMT2xdCeJMl/E/ntvCpT1beDg21u 3a3y0F7CBFsO1AblQ8LNUpVj8kA2/DqUzOkQv1reDzLNtE9tVgxNufUhc5GrS+ecKb SHlBrlkUcIcoJ4VSCx+f9G7Ueq/6aOoP+ZXklYOzLi0BzJmyhK1fzha2kIBf2OXOX6 pca5EC9vxi8N2v17WWUqgTs/JDLbpHxW02LXSkIYcN/8j3lWrkrc3R8vxRGMR/Rxb3 5nLy16PaIBr8w== Cc: Tomi Ollila , David Bremner X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jul 2014 20:41:09 -0000 Sometimes we want to catch Git errors and handle them, instead of dying with an error message. This lower-level version of git() allows us to get the error status when we want it. --- devel/nmbug/nmbug | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug index b18ded7..4a79722 100755 --- a/devel/nmbug/nmbug +++ b/devel/nmbug/nmbug @@ -63,13 +63,20 @@ sub git_pipe { spawn ($envref, defined $ioref ? $ioref : (), defined $dir ? $dir : (), @_); } -sub git { +sub git_with_status { my $fh = git_pipe (@_); my $str = join ('', <$fh>); - unless (close $fh) { + close $fh; + my $status = $?; + chomp($str); + return ($str, $status); +} + +sub git { + my ($str, $status) = git_with_status (@_); + if ($status) { die "'git @_' exited with nonzero value\n"; } - chomp($str); return $str; } -- 1.9.1.353.gc66d89d