ly/: Create one .ly file for every .ily instrument file
[sunny256-utils.git] / git-upstream
blob5df6089fe706703da3558225387c9723c6f9836d
1 #!/bin/sh
3 #==============================================================================
4 # git-upstream
5 # File ID: cb907ea4-4d42-11e5-8090-fefdb24f8e10
7 # Set up local branches to track remote branches.
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=git-upstream
14 VERSION=0.4.1
16 opt_help=0
17 opt_quiet=0
18 opt_verbose=0
19 while test -n "$1"; do
20 case "$1" in
21 -h|--help) opt_help=1; shift ;;
22 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
23 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
24 --version) echo $progname $VERSION; exit 0 ;;
25 --) shift; break ;;
27 if printf '%s\n' "$1" | grep -q ^-; then
28 echo "$progname: $1: Unknown option" >&2
29 exit 1
30 else
31 break
33 break ;;
34 esac
35 done
36 opt_verbose=$(($opt_verbose - $opt_quiet))
38 if test "$opt_help" = "1"; then
39 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
40 cat <<END
42 Set up local branches to track remote branches. If no remote is
43 specified, 'origin' is used.
45 Usage: $progname [options] [remote [branches]]
47 Options:
49 -h, --help
50 Show this help.
51 -q, --quiet
52 Be more quiet. Can be repeated to increase silence.
53 -v, --verbose
54 Increase level of verbosity. Can be repeated.
55 --version
56 Print version information.
58 END
59 exit 0
62 remote=origin
63 test -n "$1" && { remote="$1"; shift; }
64 git remote | grep -q "^$remote\$" || {
65 echo $progname: $remote: No local remote with that name found >&2
66 exit 1
69 if test -n "$1"; then
70 branches="$@"
71 else
72 branches="$(
73 git branch |
74 grep -v HEAD |
75 cut -c 3-
79 for f in $branches; do
80 git -c "advice.setupstreamfailure=false" branch -u "$remote/$f" "$f"
81 done
83 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :