From: W. Trevor King Date: Sun, 6 Jul 2014 20:40:20 +0000 (+1700) Subject: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=81165a5d9b0fcd587d7da39150df1ed47a697e86;p=notmuch-archives.git [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged --- diff --git a/8b/c32d0b11e808ffa21c629da618308fc59adec6 b/8b/c32d0b11e808ffa21c629da618308fc59adec6 new file mode 100644 index 000000000..0497c6ea3 --- /dev/null +++ b/8b/c32d0b11e808ffa21c629da618308fc59adec6 @@ -0,0 +1,106 @@ +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 7EB01431FAF + 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 TgKg9rJ1ab6w 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 39AB4431FC3 + for ; Sun, 6 Jul 2014 13:41:05 -0700 (PDT) +Received: from omta07.westchester.pa.mail.comcast.net ([76.96.62.59]) + by qmta05.westchester.pa.mail.comcast.net with comcast + id P8ac1o0031GhbT8558h2NN; Sun, 06 Jul 2014 20:41:02 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta07.westchester.pa.mail.comcast.net with comcast + id P8h01o00c152l3L3T8h1q8; 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 6BAE812700E7; + Sun, 6 Jul 2014 13:41:00 -0700 (PDT) +Received: (nullmailer pid 1911 invoked by uid 1000); + Sun, 06 Jul 2014 20:40:28 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged +Date: Sun, 6 Jul 2014 13:40:20 -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=kmAt1x+8LgmwxUpoIKGCFxWxJj8pdO2KcEVrLC0x2mk=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=hHsmtjdgoucnAwpYT1itRBijI+KNxP6LkbcOxPvyUhPw0gZEI0Uy8QdLvR6Stcimv + b1f/6KIJd5M+9epsE2BwvcjhbXCEouId2Dv93LTw6pIkWSqyvfUxNpGAR2eBIWS2XR + PLjysd1U6nuG29cGckQ8t0lkGk0DgehhNTSj8zb48hJWCMcueGpq29E5UuYGe7W3CL + vnP1ddza/VluaIT3IOxxVSXthxYJ7a5SSJSljGnYtMsjNxdPpJKbfSIF9SswqzJWxr + ICI0Moz5u+GBdM0Yt0VjAVg6dkUbgYzG+9lr0T/cM5WDPw4eBaQTnNVgaQ+YEAdAz2 + PLsN6FumL3cQA== +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 + +If we don't have an upstream, there is nothing to merge, so nothing is +unmerged. This avoids errors like: + + $ nmbug status + error: No upstream configured for branch 'master' + error: No upstream configured for branch 'master' + fatal: ambiguous argument '@{upstream}': unknown revision or path not in the working tree. + Use '--' to separate paths from revisions, like this: + 'git [...] -- [...]' + 'git rev-parse @{upstream}' exited with nonzero value + +You might not have an upstream if you're only using nmbug locally to +version-control your tags. +--- + devel/nmbug/nmbug | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug +index 4a79722..998ee6b 100755 +--- a/devel/nmbug/nmbug ++++ b/devel/nmbug/nmbug +@@ -430,7 +430,10 @@ sub do_status { + sub is_unmerged { + my $commit = shift || '@{upstream}'; + +- my $fetch_head = git ('rev-parse', $commit); ++ my ($fetch_head, $status) = git_with_status ('rev-parse', $commit); ++ if ($status) { ++ return 0; ++ } + my $base = git ( 'merge-base', 'HEAD', $commit); + + return ($base ne $fetch_head); +-- +1.9.1.353.gc66d89d +