git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH TopGit] tg.sh: check for removed branch in branch_annihilated
Date: Fri, 11 Mar 2011 10:28:06 +0300	[thread overview]
Message-ID: <1299828486-13167-1-git-send-email-arvidjaar@gmail.com> (raw)

Check that branch was not deleted by external means; prevents
errors from further git commands due to non-existing refs.

Signed-off-by: Andrey Borzenkov <arvidjaar@gmail.com>

---
 tg.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tg.sh b/tg.sh
index 9082d88..e8447cb 100644
--- a/tg.sh
+++ b/tg.sh
@@ -175,9 +175,9 @@ branch_annihilated()
 	_name="$1";
 
 	# use the merge base in case the base is ahead.
-	mb="$(git merge-base "refs/top-bases/$_name" "$_name")";
+	mb="$(git merge-base "refs/top-bases/$_name" "$_name" 2> /dev/null)";
 
-	test "$(git rev-parse "$mb^{tree}")" = "$(git rev-parse "$_name^{tree}")";
+	test -z "$mb" || test "$(git rev-parse "$mb^{tree}")" = "$(git rev-parse "$_name^{tree}")";
 }
 
 # is_sha1 REF
-- 
tg: (d279e29..) u/removed-branch (depends on: origin/master)

                 reply	other threads:[~2011-03-11  7:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1299828486-13167-1-git-send-email-arvidjaar@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).