aboutsummaryrefslogtreecommitdiff
path: root/git-show-branches-script
blob: 90018a9e88d7a5ec607fb6530449c0a56cca52ac (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
54
55
56
57
58
59
60
61
#!/bin/sh
#
# Show refs and their recent commits.
#

. git-sh-setup-script || die "Not a git repository"

usage () {
    die "usage: $0 <ref>..."
}

headref=`readlink $GIT_DIR/HEAD`

case "$(git-rev-parse --no-revs)" in '') ;; *) usage ;; esac
revs=$(git-rev-parse --revs-only --symbolic --no-flags "$@")
flags=$(git-rev-parse --revs-only --flags "$@")
case "$revs" in
'')
	revs=$(git-rev-parse --symbolic --all | sed -ne 's|^refs/heads/||p' |
	       sort)
	shift ;;
esac
set x $revs
shift

hh= in=
for ref
do
	case "/$headref" in
	*/"$ref") H='*' ;;
	*) H='!' ;;
	esac
	h=`git-rev-parse --verify "$ref^0" 2>/dev/null` || continue
	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 $flags $@ |
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