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 055F0431FAF for ; Sun, 6 Jul 2014 13:41:15 -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 39ChE9zv4cvo for ; Sun, 6 Jul 2014 13:41:09 -0700 (PDT) Received: from qmta05.westchester.pa.mail.comcast.net (qmta05.westchester.pa.mail.comcast.net [76.96.62.48]) by olra.theworths.org (Postfix) with ESMTP id 391EB431FBF for ; Sun, 6 Jul 2014 13:41:05 -0700 (PDT) Received: from omta20.westchester.pa.mail.comcast.net ([76.96.62.71]) by qmta05.westchester.pa.mail.comcast.net with comcast id P8DP1o0021YDfWL558h2NP; Sun, 06 Jul 2014 20:41:02 +0000 Received: from odin.tremily.us ([24.18.63.50]) by omta20.westchester.pa.mail.comcast.net with comcast id P8h11o00C152l3L3g8h1uR; 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 03D6D12700E9; Sun, 6 Jul 2014 13:41:01 -0700 (PDT) Received: (nullmailer pid 1919 invoked by uid 1000); Sun, 06 Jul 2014 20:40:28 -0000 From: "W. Trevor King" To: notmuch@notmuchmail.org Subject: [PATCH 3/4] nmbug: Catch stderr in is_unmerged Date: Sun, 6 Jul 2014 13:40:21 -0700 Message-Id: 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=lXcf0zWTcgH6bbxfJZoxTktKlJbNvM03i7CRd8nlNJE=; h=Received:Received:Received:Received:From:To:Subject:Date: Message-Id; b=MVQVdq9Ip+WFirjgW/QRjiUmcP46ups4dcfp4Sta0pAMl9r5vE8Zd8q3qMl2dhlvl +2LaBRjILpDTvaxMYPOZYO81mxw0SzLpMnPdQoKgZ3i+yiKNtfJfrD1mz7lJz2glBE BwhcxmBoNyx0O3cnAs3o29D57cAr1JcL984Q0nDYvnyDmB6NnbgYz41xfdbLbJZOc8 TDhaEqCWBtkSkqGr34aUNQE5tA1yzd7srKclLJnEwrNzfqTmJOrVdsj5OMKX0x9LpJ aIywRi9vePWJUzF0cRp8pe8En2DsRmRssZBAA1l3z8r3O7P+dEOTD6oiD4Vmuyxlfy qNH/qbp8xikzA== Cc: 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:15 -0000 Add a '-2|' dir for "execute the command and pipe both stdout and stderr to us". Use this to catch stderr from the rev-parse call in is_unmerged. We already check the status, so we don't want to confuse users with stuff like: error: No upstream configured for branch 'master' on nmbug's stderr. --- devel/nmbug/nmbug | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug index 998ee6b..c9ac046 100755 --- a/devel/nmbug/nmbug +++ b/devel/nmbug/nmbug @@ -56,7 +56,7 @@ my $EMPTYBLOB = git (qw{hash-object -t blob /dev/null}); sub git_pipe { my $envref = (ref $_[0] eq 'HASH') ? shift : {}; my $ioref = (ref $_[0] eq 'ARRAY') ? shift : undef; - my $dir = ($_[0] eq '-|' or $_[0] eq '|-') ? shift : undef; + my $dir = ($_[0] eq '-|' or $_[0] eq '-2|' or $_[0] eq '|-') ? shift : undef; unshift @_, 'git'; $envref->{GIT_DIR} ||= $NMBGIT; @@ -83,10 +83,15 @@ sub git { sub spawn { my $envref = (ref $_[0] eq 'HASH') ? shift : {}; my $ioref = (ref $_[0] eq 'ARRAY') ? shift : undef; - my $dir = ($_[0] eq '-|' or $_[0] eq '|-') ? shift : '-|'; + my $dir = ($_[0] eq '-|' or $_[0] eq '-2|' or $_[0] eq '|-') ? shift : '-|'; + my $stderr_to_stdout = $dir eq '-2|'; die unless @_; + if ($dir eq '-2|') { + $dir = '-|'; + } + if (open my $child, $dir) { return $child; } @@ -105,6 +110,9 @@ sub spawn { if ($dir ne '|-') { open STDIN, '<', '/dev/null' or die "reopening stdin: $!" } + if ($stderr_to_stdout) { + open(STDERR, ">&STDOUT"); + } exec @_; die "exec @_: $!"; } @@ -430,7 +438,7 @@ sub do_status { sub is_unmerged { my $commit = shift || '@{upstream}'; - my ($fetch_head, $status) = git_with_status ('rev-parse', $commit); + my ($fetch_head, $status) = git_with_status ('-2|', 'rev-parse', $commit); if ($status) { return 0; } -- 1.9.1.353.gc66d89d