Git must know the GIT_DIR and the GIT_WORK_TREE
… otherwise it looks for content in the current working directory (where the script is executed from) which is catastrophic for the repository.
This commit is contained in:
parent
786db8b60b
commit
25d7f786bc
|
@ -55,22 +55,22 @@ echo "${BLOB}" >> "${LOGFILE}"
|
||||||
GIT_BIN=$(command -v git)
|
GIT_BIN=$(command -v git)
|
||||||
|
|
||||||
if test -x "${GIT_BIN}"; then
|
if test -x "${GIT_BIN}"; then
|
||||||
# loop on possible GIT repositories
|
# loop on possible directories managed by GIT
|
||||||
for dir in /etc/.git /etc/bind/.git; do
|
for dir in /etc /etc/bind; do
|
||||||
# tell Git where to find the repository (no need to `cd …` there)
|
# tell Git where to find the repository and the work tree (no need to `cd …` there)
|
||||||
export GIT_DIR="${dir}"
|
export GIT_DIR="${dir}/.git" GIT_WORK_TREE="${dir}"
|
||||||
# If the repository exists, try to commit changes
|
# If the repository and the work tree exist, try to commit changes
|
||||||
if test -d "${GIT_DIR}"; then
|
if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
|
||||||
${GIT_BIN} add .
|
${GIT_BIN} add --all
|
||||||
${GIT_BIN} commit --all --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet
|
${GIT_BIN} commit --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet
|
||||||
# Add the SHA to the log file if something has been committed
|
# Add the SHA to the log file if something has been committed
|
||||||
if [ "$?" = "0" ]; then
|
if [ "$?" = "0" ]; then
|
||||||
SHA=$(git rev-parse --short HEAD)
|
SHA=$(git rev-parse HEAD)
|
||||||
echo "${GIT_DIR} : ${SHA}" >> "${LOGFILE}"
|
echo "${dir} : ${SHA}" >> "${LOGFILE}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# unset environment variables to prevent accidental influence on other git commands
|
||||||
unset GIT_DIR
|
unset GIT_DIR GIT_WORK_TREE
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue