-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcg-branch-ls
executable file
·39 lines (32 loc) · 979 Bytes
/
cg-branch-ls
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
#!/usr/bin/env bash
#
# List configured remote branches
# Copyright (c) Steven Cole 2005
#
# Print a listing of all known branches.
#
# The output has the following format:
#
# BRANCH LOCATION
#
# For example
#
# origin http://www.kernel.org/pub/scm/cogito/cogito.git
#
# Terminology note: This command concerns remote branches, not the local
# ones (those managed by `cg-switch` and listed by `cg-status -g`).
# Testsuite: TODO
USAGE="cg-branch-ls"
_git_wc_unneeded=1
. "${COGITO_LIB}"cg-Xlib || exit 1
msg_no_branches="list of branches is empty (see cg-branch-add(1))"
[ -d "$_git/branches" ] || die "$msg_no_branches"
[ "$(find "$_git/branches" -follow -type f)" ] \
|| die "$msg_no_branches"
maxlen="$(find "$_git/branches" -name '*' -a ! -type d |
column_width "$_git/branches/")"
find "$_git/branches" -name '*' -a ! -type d | sort | while read branch; do
name="${branch#$_git/branches/}"
url="$(cat "$branch")"
columns_print "$name" t$maxlen "$url" -
done