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

[TopGit PATCH 06/11] tg-summary: accept -i/-w

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Oct 9, 2010, 20:56 UTC
Message-ID
<62e3424559a93dc0f7c3ed55aafce738f2b0f6d3.1286657607.git.bert.wesarg@googlemail.com>
In-Reply-To
<b765e0da80781182bf6c3af8f28d9496ed49cc1b.1286657607.git.bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 README                     |    4 ++++
 contrib/tg-completion.bash |    4 ++++
 tg-summary.sh              |   21 +++++++++++++++------
 3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/README b/README
index 5ca0424..eea0d72 100644 README
--- a/README
+++ b/README
@@ -362,6 +362,10 @@ tg summary
 	branches in a machine-readable format.  Feed this to "tsort"
 	to get the output from --sort.
 
+	Options:
+	  -i		Use TopGit meta data from the index instead of branch
+	  -w		Use TopGit meta data from the working tree instead of branch
+
 	TODO: Speed up by an order of magnitude
 	TODO: Text graph view
 
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index ccf1a32..6a1e182 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -426,7 +426,11 @@ _tg_summary ()
 	*)
 		__tgcomp "
 			--graphviz
+			--sort
+			--deps
 			-t
+			-i
+			-w
 		"
 	esac
 }
diff --git a/tg-summary.sh b/tg-summary.sh
index af16888..113efc2 100644 tg-summary.sh
--- a/tg-summary.sh
+++ b/tg-summary.sh
@@ -7,13 +7,16 @@ terse=
 graphviz=
 sort=
 deps=
-
+head_from=
 
 ## Parse options
 
 while [ -n "$1" ]; do
 	arg="$1"; shift
 	case "$arg" in
+	-i|-w)
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from="$arg";;
 	-t)
 		terse=1;;
 	--graphviz)
@@ -23,7 +26,7 @@ while [ -n "$1" ]; do
 	--deps)
 		deps=1;;
 	*)
-		echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz]" >&2
+		echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz] [-i | -w]" >&2
 		exit 1;;
 	esac
 done
@@ -69,8 +72,11 @@ process_branch()
 
 	current=' '
 	[ "$name" != "$curname" ] || current='>'
+	from=$head_from
+	[ "$name" = "$curname" ] ||
+		from=
 	nonempty=' '
-	! branch_empty "$name" || nonempty='0'
+	! branch_empty "$name" $from || nonempty='0'
 	remote=' '
 	[ -z "$base_remote" ] || remote='l'
 	! has_remote "$name" || remote='r'
@@ -89,7 +95,7 @@ process_branch()
 	branch_contains "$name" "refs/top-bases/$name" || base_update='B'
 
 	if [ "$(git rev-parse "$name")" != "$rev" ]; then
-		subject="$(git cat-file blob "$name:.topmsg" | sed -n 's/^Subject: //p')"
+		subject="$(cat_file "$name:.topmsg" $from | sed -n 's/^Subject: //p')"
 	else
 		# No commits yet
 		subject="(No commits)"
@@ -100,7 +106,7 @@ process_branch()
 }
 
 if [ -n "$deps" ]; then
-	list_deps
+	list_deps $head_from
 	exit 0
 fi
 
@@ -114,7 +120,10 @@ git for-each-ref refs/top-bases |
 		if [ -n "$terse" ]; then
 			echo "$name"
 		elif [ -n "$graphviz$sort" ]; then
-			git cat-file blob "$name:.topdeps" | while read dep; do
+			from=$head_from
+			[ "$name" = "$curname" ] ||
+				from=
+			cat_file "$name:.topdeps" $from | while read dep; do
 				dep_is_tgish=true
 				ref_exists "refs/top-bases/$dep"  ||
 					dep_is_tgish=false
-- 
1.7.1.1067.g5aeb7
Previous: Bert WesargNext: Bert Wesarg
Message 6 of 11 in “cat_file: take -i/-w parameters”
  1. 01/11 cat_file: take -i/-w parametersBert Wesarg, Oct 9, 2010
  2. 02/11 pretty_tree: globalize and respect -i/-w optionsBert Wesarg, Oct 9, 2010
  3. 03/11 branch_empty: use pretty_tree and therefore respect -i/-wBert Wesarg, Oct 9, 2010
  4. 04/11 tg-path: use pretty_tree and diff-tree to generate the patchBert Wesarg, Oct 9, 2010
  5. 05/11 list_deps: accept -i/-wBert Wesarg, Oct 9, 2010
  6. 06/11 tg-summary: accept -i/-wBert Wesarg, Oct 9, 2010
  7. 07/11 tg-mail: accept -i/-wBert Wesarg, Oct 9, 2010
  8. 08/11 tg-files: list files changed by the topic branchBert Wesarg, Oct 9, 2010
  9. 09/11 tg-prev/tg-next: commands to explore dependenciesBert Wesarg, Oct 9, 2010
  10. 10/11 [RFC] tg-patch: use ui diff when pager is activeBert Wesarg, Oct 9, 2010
  11. 11/11 [RFC] tg-patch: simulate mnemonic prefixesBert Wesarg, Oct 9, 2010

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.