1f63af0159
These commits are temporary, so we do not care about stuff like trailing whitespaces at all.
28 lines
535 B
Bash
Executable File
28 lines
535 B
Bash
Executable File
#!/bin/sh
|
|
# commit the directory ($1) with a message ($2) to git
|
|
|
|
. shell-error
|
|
|
|
INIT=
|
|
if [ "$1" = "-i" ]; then
|
|
INIT=yes
|
|
shift
|
|
fi
|
|
|
|
[ -d "$1" ] || fatal "$1 is not an existing directory"
|
|
|
|
if type -t git >&/dev/null && pushd "$1" >/dev/null; then
|
|
if [ -z "$(git config --global user.name)" ]; then
|
|
exit 0
|
|
fi
|
|
if [ -n "$INIT" -a ! -d .git ]; then
|
|
git init -q || fatal "git init failed"
|
|
fi
|
|
if [ -n "$(git status -s)" ]; then
|
|
git add . \
|
|
&& git commit -anq -m "$2" \
|
|
|| fatal "git add/commit failed"
|
|
fi
|
|
popd >/dev/null
|
|
fi
|