Add support for submodules.
[git-scripts.git] / git-ls-branch
blobd3ad44d9687f4b042573fd245db717a99785d385
1 #!/bin/bash
3 # List the most recently-active (10 by default) branches
5 USAGE='[-h|--help|-<N>]'
6 LONG_USAGE='list the N most recently-active branches
7 (N is optional, default to 8)
10 exec_path=$(git --exec-path)
11 . $exec_path/git-sh-setup
12 require_work_tree
14 # Output format string
16 fmt='
17 spaces=" "
18 r=%(refname:short)
19 s=%(subject)
20 sr=$(echo $r | wc -c)
21 pad1=$((45 - $sr))
22 if [[ "$pad1" < "0" ]]; then
23 echo $r "%09" "$s";
24 else
25 echo $r "${spaces:1:$pad1}" "$s";
26 fi;
28 list_branches ()
30 count=$1
31 result=$(git for-each-ref --shell --format="$fmt" \
32 --sort=-authordate --count=$count refs/heads/)
33 eval "$result"
36 case "$#" in
38 list_branches 8 ;;
40 cmd="$1"
41 case "$cmd" in
42 -h|*help)
43 usage ;;
45 list_branches ${cmd:1} ;;
46 esac
47 esac