1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 23:08:07 +00:00

Merge pull request #1040 from pi-hole/fix/updater_git-C

Remove git -C from update.sh
This commit is contained in:
Dan Schaper 2016-12-25 12:28:42 -08:00 committed by GitHub
commit 62d001225a

24
advanced/Scripts/update.sh Normal file → Executable file
View File

@ -22,9 +22,15 @@ readonly PI_HOLE_FILES_DIR="/etc/.pihole"
is_repo() {
# Use git to check if directory is currently under VCS, return the value
local directory="${1}"
local curdir
local rc
git -C "${directory}" status --short &> /dev/null
return
curdir="${PWD}"
cd "${directory}" &> /dev/null || return 1
git status --short &> /dev/null
rc=$?
cd "${curdir}" &> /dev/null || return 1
return $rc
}
prep_repo() {
@ -46,16 +52,20 @@ make_repo() {
update_repo() {
local directory="${1}"
local retVal=0
local curdir
# Pull the latest commits
curdir="${PWD}"
cd "${directory}" &> /dev/null || return 1
# Stash all files not tracked for later retrieval
git -C "${directory}" stash --all --quiet &> /dev/null || ${retVal}=1
git stash --all --quiet &> /dev/null
# Force a clean working directory for cloning
git -C "${directory}" clean --force -d &> /dev/null || ${retVal}=1
git clean --force -d &> /dev/null
# Fetch latest changes and apply
git -C "${directory}" pull --quiet &> /dev/null || ${retVal}=1
return ${retVal}
git pull --quiet &> /dev/null
cd "${curdir}" &> /dev/null || return 1
return
}
getGitFiles() {