[__git] Fix quoting error, improve readability in various places.

This commit is contained in:
evilham 2020-06-18 11:57:27 +02:00
parent a837797ee3
commit 0ef94550c7
2 changed files with 5 additions and 6 deletions

View file

@ -18,14 +18,13 @@ git_user="${owner:-root}"
if [ "$state_should" = "present" ] && [ -d "$destination/.git" ]; then if [ "$state_should" = "present" ] && [ -d "$destination/.git" ]; then
# First fetch the remote # First fetch the remote
# Whenever possible run git as non-root, see history of CVEs. # Whenever possible run git as non-root, see history of CVEs.
su -m "$git_user" -c "git -C '$destination' fetch -q" su -m "$git_user" -c "git -C '$destination' fetch --quiet"
head="$(su -m "$git_user" -c "git -C '$destination' rev-parse HEAD")" head="$(su -m "$git_user" -c "git -C '$destination' rev-parse HEAD")"
# Try first to get the latest commit in the remote current branch, # Try first to get the latest commit in the remote current branch,
# if it fails try to get the commit for the expected tag name # if it fails try to get the commit for the expected tag name
upstream="$(su -m "$git_user" -c "git -C '$destination' rev-parse @{u}" 2>/dev/null || upstream="$(su -m "$git_user" -c "git -C '$destination' rev-parse '@{u}'" 2>/dev/null ||
su -m "$git_user" -c "git -C '$destination' rev-parse '${branch_should}^{}'")" su -m "$git_user" -c "git -C '$destination' rev-parse '${branch_should}^{}'")"
if [ "${head}" != "$upstream" ]; then if [ "${head}" != "$upstream" ]; then
echo "YES" echo "YES"
exit
fi fi
fi fi

View file

@ -79,13 +79,13 @@ EOF
repo_changed="YES" repo_changed="YES"
elif [ "$branch_should" != "$branch_is" ]; then elif [ "$branch_should" != "$branch_is" ]; then
# User has changed tag / branch, let's update that # User has changed tag / branch, let's update that
echo "su -m '$git_user' -c \"git checkout '$branch_should'\"" echo "su -m '$git_user' -c \"git checkout --quiet '$branch_should'\""
echo "change $branch_is -> $branch_should" >> "$__messages_out" echo "change $branch_is -> $branch_should" >> "$__messages_out"
repo_changed="YES" repo_changed="YES"
elif [ -z "$no_updates" ] && [ "$needs_update" = "YES" ]; then elif [ -z "$no_updates" ] && [ -n "$needs_update" ]; then
# The remote has newer information than our repository. # The remote has newer information than our repository.
# Fetch was done in the explorer, here we can just pull # Fetch was done in the explorer, here we can just pull
echo "su -m '$git_user' -c \"git -C '$destination' pull\"" echo "su -m '$git_user' -c \"git -C '$destination' pull --quiet\""
echo update >> "$__messages_out" echo update >> "$__messages_out"
repo_changed="YES" repo_changed="YES"
fi fi