summaryrefslogtreecommitdiff
path: root/git-show-branches-script
blob: 263025c476a2e243d568c2709773381fd1c179ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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