src/Makefile: Ignore fldb/ and personnr/ and add fixmes with reasoning
[sunny256-utils.git] / git-up
blob2456fc4a932e904631d8cd94b97156eca3f7fc0c
1 #!/bin/sh
3 #==============================================================================
4 # git-up
5 # File ID: 96b89f6a-d1eb-11e7-9056-f74d993421b0
7 # Make a full Git update in the current repository
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=git-up
14 VERSION=0.1.2
16 T_GREEN=$(tput setaf 2)
17 T_RED=$(tput setaf 1)
18 T_RESET=$(tput sgr0)
20 opt_help=0
21 opt_quiet=0
22 opt_verbose=0
23 while test -n "$1"; do
24 case "$1" in
25 -h|--help) opt_help=1; shift ;;
26 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
27 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
28 --version) echo $progname $VERSION; exit 0 ;;
29 --) shift; break ;;
31 if printf '%s\n' "$1" | grep -q ^-; then
32 echo "$progname: $1: Unknown option" >&2
33 exit 1
34 else
35 break
37 break ;;
38 esac
39 done
40 opt_verbose=$(($opt_verbose - $opt_quiet))
42 runcmd() {
43 echo >&2
44 echo "$T_GREEN$progname: $*$T_RESET" >&2
48 if test "$opt_help" = "1"; then
49 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
50 cat <<END
52 Make a full Git update in the current repository. Fetch everything,
53 update all local branches, create commit-* branches from dangling heads
54 and push the result to all remotes.
56 Usage: $progname [options]
58 Options:
60 -h, --help
61 Show this help.
62 -q, --quiet
63 Be more quiet. Can be repeated to increase silence.
64 -v, --verbose
65 Increase level of verbosity. Can be repeated.
66 --version
67 Print version information.
69 END
70 exit 0
73 currbranch=$(git rev-parse --abbrev-ref HEAD)
75 safe_checkout() {
76 local branch=$1
78 if test -n "$currbranch" -a "$currbranch" != "HEAD"; then
79 runcmd git checkout "$branch"
80 else
81 echo -n "$T_RED$progname: " >&2
82 echo "No current branch, skip \"git checkout $branch\"$T_RESET" >&2
86 runcmd git fetch --all --prune
87 runcmd git merge --ff-only
88 safe_checkout $(git rev-parse HEAD)
89 runcmd git allbr -a
90 safe_checkout -
91 runcmd git dangling
92 runcmd git pa
94 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :