From ed7a928da76e0d3bb8bc3011c54ac532e6c70006 Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@alientrap.org>
Date: Tue, 4 May 2010 07:31:37 +0200
Subject: [PATCH] small change to ./all, not done yet (command branches_short)

---
 all | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/all b/all
index b2e91062..c5914d8e 100755
--- a/all
+++ b/all
@@ -261,6 +261,7 @@ case "$cmd" in
 						else
 							b="`repobranch "$d"`"
 						fi
+						# TODO do this without pushing
 						verbose git push "$remote" "$b":"$branch"
 						verbose git checkout --track -b "$branch" "$remote/$branch"
 					fi
@@ -299,6 +300,43 @@ case "$cmd" in
 			done
 		done
 		;;
+	branches_short)
+		for d in $repos; do
+			cd "$d0/$d" # am in a pipe, shouldn't use enter
+			git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
+			cd "$d0"
+		done | {
+			branches_list=
+			# branches_repos_*=
+			while read -r d BRANCH REV UPSTREAM TEXT; do
+				case "$UPSTREAM" in
+					\[*)
+						UPSTREAM=${UPSTREAM#\[}
+						UPSTREAM=${UPSTREAM%\]}
+						UPSTREAM=${UPSTREAM%:*}
+						;;
+					*)
+						TEXT="$UPSTREAM $TEXT"
+						UPSTREAM=
+						;;
+				esac
+				if [ x"$REV" = x"->" ]; then
+					continue
+				fi
+				BRANCH=${BRANCH#remotes/}
+				ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
+				branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
+				eval "r=\$branches_repos_$ID"
+				r="$r $d:$UPSTREAM"
+				eval "branches_repos_$ID=\$r"
+			done
+			echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
+				ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
+				eval "r=\$branches_repos_$ID"
+				echo "$BRANCH: $r"
+			done
+		}
+		;;
 	merge)
 		for d in $repos; do
 			dv=`visible_repo_name "$d"`
-- 
2.39.5