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

[PATCH] [TOPGIT] allow working with annihilated branches

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Feb 25, 2009, 20:03 UTC
Message-ID
<1235592240-12616-2-git-send-email-u.kleine-koenig@pengutronix.de>
In-Reply-To
<1235592240-12616-1-git-send-email-u.kleine-koenig@pengutronix.de>

If you decide that you want to drop a patch, you can just merge in its base with strategy "theirs". Then you have base=topic and so no .top* files any more. This patch fixes tg summary and the helper function recurse_deps() to handle these annihilated branches as if they don't exist and don't show up in .topdeps files.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 tg-summary.sh |   11 ++++++++++-
 tg.sh         |   17 ++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/tg-summary.sh b/tg-summary.sh
index 842d95a..50ee883 100644
--- a/tg-summary.sh
+++ b/tg-summary.sh
@@ -53,13 +53,22 @@ fi
 git for-each-ref refs/top-bases |
 	while read rev type ref; do
 		name="${ref#refs/top-bases/}"
+		if branch_annihilated "$name"; then
+			continue;
+		fi;
+
 		if [ -n "$terse" ]; then
 			echo "$name"
 			continue
 		fi
 		if [ -n "$graphviz" ]; then
 			git cat-file blob "$name:.topdeps" | while read dep; do
-				echo "\"$name\" -> \"$dep\";"
+				dep_is_tgish=true
+				ref_exists "refs/top-bases/$dep"  ||
+					dep_is_tgish=false
+				if ! "$dep_is_tgish" || ! branch_annihilated $dep; then
+					echo "\"$name\" -> \"$dep\";"
+				fi
 			done
 			continue
 		fi
diff --git a/tg.sh b/tg.sh
index ccb40cd..5bb2d0c 100644
--- a/tg.sh
+++ b/tg.sh
@@ -94,6 +94,16 @@ has_remote()
 	[ -n "$base_remote" ] && ref_exists "remotes/$base_remote/$1"
 }
 
+branch_annihilated()
+{
+	_name="$1";
+
+	# use the merge base in case the base is ahead.
+	mb="$(git merge-base "refs/top-bases/$_name" "$_name")";
+
+	test "$(git rev-parse "$mb^{tree}")" = "$(git rev-parse "$_name^{tree}")";
+}
+
 # recurse_deps CMD NAME [BRANCHPATH...]
 # Recursively eval CMD on all dependencies of NAME.
 # CMD can refer to $_name for queried branch name,
@@ -116,7 +126,12 @@ recurse_deps()
 	if has_remote "top-bases/$_name"; then
 		echo "refs/remotes/$base_remote/top-bases/$_name" >>"$_depsfile"
 	fi
-	git cat-file blob "$_name:.topdeps" >>"$_depsfile"
+
+	# if the branch was annihilated, there exists no .topdeps file
+	if ! branch_annihilated "$_name"; then
+		#TODO: handle nonexisting .topdeps?
+		git cat-file blob "$_name:.topdeps" >>"$_depsfile";
+	fi;
 
 	_ret=0
 	while read _dep; do
-- 
1.5.6.5
Previous: Uwe Kleine-KönigNext: Uwe Kleine-König
Message 3 of 16 in “topgit patches”
  1. Uwe Kleine-KönigFeb 25, 2009
  2. [TOPGIT] limit rev-list in branch_contains to a single revUwe Kleine-König, Feb 25, 2009
  3. [TOPGIT] allow working with annihilated branchesUwe Kleine-König, Feb 25, 2009
  4. [TOPGIT] make tg remote idempotentUwe Kleine-König, Feb 25, 2009
  5. [TOPGIT] make creating a commit from a topgit branch a functionUwe Kleine-König, Feb 25, 2009
  6. [TOPGIT] implement linearize export methodUwe Kleine-König, Feb 25, 2009
  7. Petr BaudisFeb 25, 2009
  8. Uwe Kleine-KönigFeb 25, 2009
  9. Petr BaudisFeb 25, 2009
  10. Uwe Kleine-KönigFeb 26, 2009
  11. martin f krafftFeb 26, 2009
  12. Uwe Kleine-KönigFeb 26, 2009
  13. martin f krafftFeb 27, 2009
  14. Uwe Kleine-KönigFeb 27, 2009
  15. Uwe Kleine-KönigMar 2, 2009
  16. martin f krafftMar 3, 2009

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.