mkimage-profiles/bin/mp-commit
Michael Shigorin c4311108ea git usage refactoring
There were heaps of "if type -t git" there already;
it wasn't an unintentional mishap but rather a moderate
copy-paste to get the use cases, and now these seem to
have essentially settled.

So time to scrap some dups.

NB: the scripts in the generated profile can't rely on
the contents of the metaprofile (these need to be able
to work in standalone case either), so a bit of crap
still lurks there.
2012-08-10 00:12:46 +03:00

22 lines
466 B
Bash
Executable File

#!/bin/sh
# commit the directory ($1) with a message ($2) to git
. shell-error
[ -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 [ ! -d .git ]; then
git init -q || fatal "git init failed"
fi
if [ -n "$(git status -s)" ]; then
git add . \
&& git commit -qam "$2" \
|| fatal "git add/commit failed"
fi
popd >/dev/null
fi