[PATCH 1/4] nmbug: Add a git_with_status helper function
authorW. Trevor King <wking@tremily.us>
Sun, 6 Jul 2014 20:40:19 +0000 (13:40 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:03:26 +0000 (10:03 -0800)
3f/7719ece55e1d5acde63e15016a39677dd478b1 [new file with mode: 0644]

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