Test commit
[cogito/jonas.git] / cg-branch-ls
blob8c4915931d2e4df812be25132d3c31989584aa94
1 #!/usr/bin/env bash
3 # List configured remote branches
4 # Copyright (c) Steven Cole 2005
6 # Print a listing of all known branches.
8 # The output has the following format:
10 # BRANCH LOCATION
12 # For example
14 # origin http://www.kernel.org/pub/scm/cogito/cogito.git
16 # Terminology note: This command concerns remote branches, not the local
17 # ones (those managed by `cg-switch` and listed by `cg-status -g`).
19 # Testsuite: TODO
21 USAGE="cg-branch-ls"
22 _git_wc_unneeded=1
24 . "${COGITO_LIB}"cg-Xlib || exit 1
25 msg_no_branches="list of branches is empty (see cg-branch-add(1))"
27 [ -d "$_git/branches" ] || die "$msg_no_branches"
29 [ "$(find "$_git/branches" -follow -type f)" ] \
30 || die "$msg_no_branches"
32 maxlen="$(find "$_git/branches" -name '*' -a ! -type d |
33 column_width "$_git/branches/")"
35 find "$_git/branches" -name '*' -a ! -type d | sort | while read branch; do
36 name="${branch#$_git/branches/}"
37 url="$(cat "$branch")"
38 columns_print "$name" t$maxlen "$url" -
39 done