From 0ef94550c7340d40f7ce75b4617460d6a1b79ae2 Mon Sep 17 00:00:00 2001 From: Evilham Date: Thu, 18 Jun 2020 11:57:27 +0200 Subject: [PATCH] [__git] Fix quoting error, improve readability in various places. --- cdist/conf/type/__git/explorer/needs-update | 5 ++--- cdist/conf/type/__git/gencode-remote | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__git/explorer/needs-update b/cdist/conf/type/__git/explorer/needs-update index 1b05b536..d00f3597 100755 --- a/cdist/conf/type/__git/explorer/needs-update +++ b/cdist/conf/type/__git/explorer/needs-update @@ -18,14 +18,13 @@ git_user="${owner:-root}" if [ "$state_should" = "present" ] && [ -d "$destination/.git" ]; then # First fetch the remote # 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")" # 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 - 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}^{}'")" if [ "${head}" != "$upstream" ]; then echo "YES" - exit fi fi diff --git a/cdist/conf/type/__git/gencode-remote b/cdist/conf/type/__git/gencode-remote index 48fa8e58..02078785 100755 --- a/cdist/conf/type/__git/gencode-remote +++ b/cdist/conf/type/__git/gencode-remote @@ -79,13 +79,13 @@ EOF repo_changed="YES" elif [ "$branch_should" != "$branch_is" ]; then # 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" 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. # 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" repo_changed="YES" fi