3 #==============================================================================
5 # File ID: 92d46e22-d5a1-11e4-9769-000df06acc56
7 # Wait until the current Git repository is clean before continuing.
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname
=git-wait-until-clean
24 -e|
--exit-val) opt_exit_val
=1; shift ;;
25 -h|
--help) opt_help
=1; shift ;;
26 -i|
--ignored) opt_ignored
=1; shift ;;
27 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
28 -u|
--untracked) opt_untracked
=1; shift ;;
29 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
30 --version) echo $progname $VERSION; exit 0 ;;
33 if printf '%s\n' "$1" |
grep -q ^
-; then
34 echo "$progname: $1: Unknown option" >&2
42 opt_verbose
=$
(($opt_verbose - $opt_quiet))
44 if test "$opt_help" = "1"; then
45 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
48 Wait until the current Git repository is clean before continuing.
49 Does nothing in bare repositories.
51 Usage: $progname [options]
56 Don't wait if the repository is modified, but exit immediately and
57 use the return value to tell if it's modified or not.
58 0: Repository is not modified
59 1: Repository is modified
63 Also wait if there are any ignored files in the repository.
65 Be more quiet. Can be repeated to increase silence.
67 Allow untracked files in the repository.
69 Increase level of verbosity. Can be repeated.
71 Print version information.
78 test "$(git config --get core.bare)" = "true" && is_bare
=1
80 test "$is_bare" = "1" && exit 0
83 test "$opt_ignored" = "1" && i_str
=" --ignored"
86 test "$opt_untracked" = "1" && u_str
=" --untracked-files=no"
89 while test "$(git status --porcelain$i_str$u_str "$@
")" != ""; do
90 if test "$opt_exit_val" = "1"; then
91 if test $opt_verbose -ge 1; then
92 echo -n "$progname: $(pwd) is modified, " >&2
93 echo exit with value
1 >&2
97 echo -n "Waiting for $(hostname):$(pwd) to be cleaned up " >&2
98 echo \
(opt
: $i_str$u_str\
)... \
($
(date)\
) >&2
102 test -n "$did_wait" && echo $
(hostname
):$
(pwd) is clean. Continuing...
>&2
103 if test $opt_verbose -ge 1; then
104 echo $progname: $
(pwd) is clean
, exit with value
0 >&2
108 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :