git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH TopGit] tg.sh: check for removed branch in branch_annihilated

From
ABAndrey Borzenkov <arvidjaar@gmail.com>
Date
Mar 11, 2011, 07:28 UTC
Message-ID
<1299828486-13167-1-git-send-email-arvidjaar@gmail.com>

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)
Message 1 of 1 in “tg.sh: check for removed branch in branch_annihilated”
  1. tg.sh: check for removed branch in branch_annihilatedAndrey Borzenkov, Mar 11, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.