3 #==============================================================================
5 # File ID: dd770008-300f-11df-b5fc-90e6ba3022ac
7 # Commit all files in current directory tree to Git.
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
16 opt_store_empty_dirs
=0
22 while test -n "$1"; do
24 -d|
--store-empty-dirs) opt_store_empty_dirs
=1; shift ;;
25 -e|
--edit) opt_edit
=1; shift ;;
26 -h|
--help) opt_help
=1; shift ;;
27 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
28 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
29 -y|
--yes) opt_yes
=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 Commit all files in current directory tree to Git.
50 Usage: $progname [options]
55 Edit the log message in your favourite editor, using the value of
56 the EDITOR environment variable.
57 -d, --store-empty-dirs
58 Also store empty directories in ".emptydirs".
62 Be more quiet. Can be repeated to increase silence.
64 Increase level of verbosity. Can be repeated.
66 Answer "yes" to commit prompt, commit automatically.
68 Print version information.
75 test "$opt_store_empty_dirs" = "1" && {
77 test "$(git config --get ciall.noemptydirs)" = "true" && {
78 echo $progname: -d option not allowed here
>&2
81 echo -n $progname: Executing git-store-dirs...
>&2
83 echo git-store-dirs error
>&2;
89 test "$opt_yes" = "1" && { besafe
=y
; opt_str
=-y; }
90 echo $progname: git status
1...
>&2
91 LC_ALL
=C git status . |
grep "^nothing to commit" && {
92 echo $progname: Nothing to
do here.
97 test ! -z "$1" && logmsg
="$*"
99 echo $progname: git status
2...
>&2
102 echo "Log message: $opt_str '$logmsg'"
103 until test "$besafe" = "y"; do
104 echo -n "Press 'y' + Enter to commit all new changes " >&2
105 echo -n or
\'n
\' to abort...
>&2
107 test "$besafe" = "n" && exit 0;
110 if test "$opt_edit" = "1"; then
111 if test -z "$EDITOR"; then
112 echo -n "$progname: The EDITOR environment variable " >&2
113 echo is not defined
>&2
116 tmpmsgfile
=/tmp
/$
(date +%s
)-$$.tmp
118 logmsg
=$
(cat $tmpmsgfile)
119 test -z "$logmsg" && {
120 echo $progname: No text entered
in editor
, aborting.
>&2
125 echo $progname: git status
3...
>&2
126 LC_ALL
=C git status . |
grep "^nothing to commit" ||
(
127 echo $progname: git add
--all .
129 echo $progname: git commit
>&2
130 git commit
-m "$logmsg$(
133 suuid -t $progname -c "$logmsg" -wa
137 echo ========== git status
==========
141 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :