aboutsummaryrefslogtreecommitdiff
path: root/git-show-branches-script
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-15 01:42:15 -0700
committerJunio C Hamano <junkio@cox.net>2005-08-15 03:00:22 -0700
commit7c27558c6236225b07c5d5def76299d2b5fe7635 (patch)
treea82cb780921131e30bdc1d646f7ca6bc1b667db6 /git-show-branches-script
parent365a00a3f280f8697e4735e1ac5b42a1c50f7887 (diff)
downloadgit-7c27558c6236225b07c5d5def76299d2b5fe7635.tar.gz
git-7c27558c6236225b07c5d5def76299d2b5fe7635.tar.xz
Add git-show-branches-script
Often I find myself wanting to do quick branches check when I am not in the windowing environment and cannot run gitk. This stupid script shows commits leading to the heads of interesting branches with indication which ones belong to which branches, so that fork point is somewhat discernible without using gitk. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-show-branches-script')
-rwxr-xr-xgit-show-branches-script53
1 files changed, 53 insertions, 0 deletions
diff --git a/git-show-branches-script b/git-show-branches-script
new file mode 100755
index 000000000..263025c47
--- /dev/null
+++ b/git-show-branches-script
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Show refs and their recent commits.
+#
+
+. git-sh-setup-script || die "Not a git repository"
+
+headref=`readlink $GIT_DIR/HEAD`
+case "$#" in
+0)
+ set x `cd $GIT_DIR/refs &&
+ find heads -type f -print |
+ sed -e 's|heads/||' |
+ sort`
+ shift ;;
+esac
+
+hh= in=
+for ref
+do
+ case "/$headref" in
+ */"$ref") H='*' ;;
+ *) H='!' ;;
+ esac
+ h=`git-rev-parse --verify "$ref^0"` || exit
+ l=`git-log-script --max-count=1 --pretty=oneline "$h" |
+ sed -e 's/^[^ ]* //'`
+ hh="$hh $h"
+ echo "$in$H [$ref] $l"
+ in="$in "
+done
+set x $hh
+shift
+
+git-rev-list --pretty=oneline "$@" |
+while read v l
+do
+ in=''
+ for h
+ do
+ b=`git-merge-base $h $v`
+ case "$b" in
+ $v) in="$in+" ;;
+ *) in="$in " ;;
+ esac
+ done
+
+ echo "$in $l"
+ case "$in" in
+ *' '*) ;;
+ *) break ;;
+ esac
+done