[PATCH] Add merge detection to git-cvsimport
[git.git] / git-show-branches-script
1 #!/bin/sh
2 #
3 # Show refs and their recent commits.
4 #
5
6 . git-sh-setup-script || die "Not a git repository"
7
8 usage () {
9     die "usage: $0 <ref>..."
10 }
11
12 headref=`readlink $GIT_DIR/HEAD`
13
14 case "$(git-rev-parse --no-revs)" in '') ;; *) usage ;; esac
15 revs=$(git-rev-parse --revs-only --symbolic --no-flags "$@")
16 flags=$(git-rev-parse --revs-only --flags "$@")
17 case "$revs" in
18 '')
19         revs=$(git-rev-parse --symbolic --all | sed -ne 's|^refs/heads/||p' |
20                sort)
21         shift ;;
22 esac
23 set x $revs
24 shift
25
26 hh= in=
27 for ref
28 do
29         case "/$headref" in
30         */"$ref") H='*' ;;
31         *) H='!' ;;
32         esac
33         h=`git-rev-parse --verify "$ref^0" 2>/dev/null` || continue
34         l=`git-log-script --max-count=1 --pretty=oneline "$h" |
35                 sed -e 's/^[^ ]* //'`
36         hh="$hh $h"
37         echo "$in$H [$ref] $l"
38         in="$in "
39 done
40 set x $hh
41 shift
42
43 git-rev-list --pretty=oneline $flags $@ |
44 while read v l
45 do
46         in=''
47         for h
48         do
49                 b=`git-merge-base $h $v`
50                 case "$b" in
51                 $v) in="$in+" ;;
52                 *)  in="$in " ;;
53                 esac
54         done
55
56         echo "$in $l"
57         case "$in" in
58         *' '*) ;;
59         *) break ;;
60         esac
61 done