std.h: Don't use `extern` in function prototypes
[sunny256-utils.git] / git-delrembr
blob30442071de5f72b49fbf5fd5b279d577b63634c7
1 #!/bin/sh
3 #==============================================================================
4 # git-delrembr
5 # File ID: bb8f9564-dfd3-11e2-b044-0800274013ad
7 # Delete the specified Git branches or tags locally and from all remotes
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=git-delrembr
14 VERSION=0.5.0
16 opt_help=0
17 opt_dry_run=0
18 opt_quiet=0
19 opt_verbose=0
20 while test -n "$1"; do
21 case "$1" in
22 -h|--help) opt_help=1; shift ;;
23 -n|--dry-run) opt_dry_run=1; shift ;;
24 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
25 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
26 --version) echo $progname $VERSION; exit 0 ;;
27 --) shift; break ;;
29 if printf '%s\n' "$1" | grep -q ^-; then
30 echo "$progname: $1: Unknown option" >&2
31 exit 1
32 else
33 break
35 break ;;
36 esac
37 done
38 opt_verbose=$(($opt_verbose - $opt_quiet))
40 if test "$opt_help" = "1"; then
41 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
42 cat <<END
44 Delete the specified Git branches or tags locally and from all remotes
46 Usage: $progname [options] ref [...]
48 Options:
50 -h, --help
51 Show this help.
52 -n, --dry-run
53 Don't delete anything, only print out what would be done.
54 -q, --quiet
55 Be more quiet. Can be repeated to increase silence.
56 -v, --verbose
57 Increase level of verbosity. Can be repeated.
58 --version
59 Print version information.
61 END
62 exit 0
65 if test "$opt_dry_run" = "1"; then
66 sim=echo
67 else
68 sim=
71 msg() {
72 if test $opt_verbose -ge $1; then
73 shift
74 echo "$progname: $*" >&2
78 branches="$@"
79 remotes="$(git remote)"
80 for b in $branches; do
81 echo ==== $progname: branch \"$b\" ====
82 git branch | grep -q "^ $b\$" && {
83 msg 1 Executing $sim git branch -D $b
84 $sim git branch -D $b
86 for r in $remotes; do
87 git branch -a | grep -q "^ remotes/$r/$b\$" && {
88 msg 1 Executing $sim git push $r :$b
89 $sim git push $r :$b
91 done
92 done
94 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :