tj.git-extras/helper/is-git-repo
spacewander d9724f3b46 use mixin to add 'is git repo' check for some commands
When those commands are used outside a git repo, 'Not a git repo!' will be
printed to stderr
2014-09-25 00:41:43 +08:00

15 lines
240 B
Plaintext
Executable file

#
# check whether current directory is inside a git repository
#
is_git_repo() {
git rev-parse --show-toplevel > /dev/null 2>&1
result=$?
if test $result != 0; then
>&2 echo 'Not a git repo!'
exit $result
fi
}
is_git_repo