diff --git a/libexec/portzap/commands/portzap-clone b/libexec/portzap/commands/portzap-clone index 5ec255e..79776f5 100755 --- a/libexec/portzap/commands/portzap-clone +++ b/libexec/portzap/commands/portzap-clone @@ -5,17 +5,13 @@ set -e # variables localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap +git="${libexec}"/utils/git/run giturl=$1 gitdir=$2 branch=$3 ## # functions -git() -{ - "${libexec}"/utils/gitexec "${1}" -} - printok() { "${libexec}"/utils/printok "${1}" } @@ -41,8 +37,8 @@ if [ -e "${gitdir}/.git" ]; then exit 1 fi -git clone "${giturl}" "${gitdir}" +"${git}" clone "${giturl}" "${gitdir}" cd "${gitdir}" -git config core.filemode off -git checkout -t origin/"${branch}" +"${git}" config core.filemode off +"${git}" checkout -t origin/"${branch}" printok "clone complete" diff --git a/libexec/portzap/commands/portzap-install b/libexec/portzap/commands/portzap-install index 2160c79..4963858 100755 --- a/libexec/portzap/commands/portzap-install +++ b/libexec/portzap/commands/portzap-install @@ -6,6 +6,7 @@ set -e localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap mode=u=rwX,g=rX,o= +git="${libexec}"/utils/git/run gitdir=$1 installdir=$2 revfile=$3 @@ -15,8 +16,8 @@ revfile=$3 perform_update() { rev=$(cat "${revfile}") - add=$("${libexec}"/utils/git-changed-files "${gitdir}" "${rev}") - del=$("${libexec}"/utils/git-removed-files "${gitdir}" "${rev}") + add=$("${libexec}"/utils/git/get-changed-files "${gitdir}" "${rev}") + del=$("${libexec}"/utils/git/get-removed-files "${gitdir}" "${rev}") for file in ${del}; do target="${installdir}/${file}" parent=$(dirname "${target}") @@ -72,7 +73,7 @@ if [ "$(id -u)" != "0" ]; then exit 1 fi -umask ${mode} +umask "${mode}" cd "${gitdir}" run_install "-d" "${installdir}" chmod ${mode} "${installdir}" @@ -81,5 +82,5 @@ if [ -e "${revfile}" ]; then else perform_install fi -"${libexec}"/utils/git-rev "${gitdir}" > "${revfile}" +"${git}" rev-parse HEAD > "${revfile}" printok "install complete" diff --git a/libexec/portzap/commands/portzap-pull b/libexec/portzap/commands/portzap-pull index 9bd7786..27b4c1a 100755 --- a/libexec/portzap/commands/portzap-pull +++ b/libexec/portzap/commands/portzap-pull @@ -5,15 +5,11 @@ set -e # variables localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} libexec="${localbase}"/libexec/portzap +git="${libexec}"/utils/git/run gitdir=$1 ## # functions -git() -{ - "${libexec}"/utils/git "${@}" -} - printok() { "${libexec}"/utils/printok "${1}" } @@ -40,6 +36,6 @@ if [ ! -e "${gitdir}/.git" ]; then fi cd "${gitdir}" -branch=$(gitexec "branch --show-current") -gitexec "pull --rebase origin ${branch}" +branch=$("${git}" branch --show-current) +"${git}" pull --rebase origin "${branch}" printok "pull complete" diff --git a/libexec/portzap/utils/git-changed-files b/libexec/portzap/utils/git-changed-files deleted file mode 100644 index 8d1fcf7..0000000 --- a/libexec/portzap/utils/git-changed-files +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -set -e - -## -# variables -localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} -libexec="${localbase}"/libexec/portzap -gitdir=$1 -commit=$2 - -## -# functions -diff() -{ - "${libexec}"/utils/gitdiff ${@} -} - -## -# main -cd "${gitdir}" -diff "--name-only" "--diff-filter=A" "${commit}" "HEAD" -diff "--name-only" "--diff-filter=M" "${commit}" "HEAD" diff --git a/libexec/portzap/utils/git-removed-files b/libexec/portzap/utils/git-removed-files deleted file mode 100644 index 158f73b..0000000 --- a/libexec/portzap/utils/git-removed-files +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -set -e - -## -# variables -localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} -libexec="${localbase}"/libexec/portzap -gitdir=$1 -commit=$2 - -## -# functions -diff() -{ - "${libexec}"/utils/gitdiff ${@} -} - -## -# main -cd "${gitdir}" -diff "--name-only" "--diff-filter=D" "${commit}" "HEAD" diff --git a/libexec/portzap/utils/git-rev b/libexec/portzap/utils/git-rev deleted file mode 100644 index 045e4bd..0000000 --- a/libexec/portzap/utils/git-rev +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -e - -## -# variables -localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} -libexec="${localbase}"/libexec/portzap -gitdir=$1 - -## -# functions -gitexec() -{ - "${libexec}"/utils/gitexec "${1}" -} - -## -# main -cd "${gitdir}" -gitexec "rev-parse HEAD" diff --git a/libexec/portzap/utils/git/get-changed-files b/libexec/portzap/utils/git/get-changed-files new file mode 100644 index 0000000..7c64d41 --- /dev/null +++ b/libexec/portzap/utils/git/get-changed-files @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +## +# variables +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} +libexec="${localbase}"/libexec/portzap +git="${libexec}"/utils/git/run +gitdir=$1 +commit=$2 + +## +# main +cd "${gitdir}" +"${git}" diff -l0 --name-only --diff-filter=A "${commit}" "HEAD" +"${git}" diff -l0 --name-only --diff-filter=M "${commit}" "HEAD" diff --git a/libexec/portzap/utils/git/get-removed-files b/libexec/portzap/utils/git/get-removed-files new file mode 100644 index 0000000..4ad32dc --- /dev/null +++ b/libexec/portzap/utils/git/get-removed-files @@ -0,0 +1,15 @@ +#!/bin/sh +set -e + +## +# variables +localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)} +libexec="${localbase}"/libexec/portzap +git="${libexec}"/utils/git/run +gitdir=$1 +commit=$2 + +## +# main +cd "${gitdir}" +"${git}" diff -l0 --name-only --diff-filter=D "${commit}" "HEAD" diff --git a/libexec/portzap/utils/git b/libexec/portzap/utils/git/run similarity index 70% rename from libexec/portzap/utils/git rename to libexec/portzap/utils/git/run index decaea3..92da168 100644 --- a/libexec/portzap/utils/git +++ b/libexec/portzap/utils/git/run @@ -10,4 +10,4 @@ mode=u=rwX,g=rX,o= # main doas -n \ -u _portzap \ - /bin/sh -c "umask ${mode}; ${git} ${1}" + /bin/sh -c "umask ${mode}; ${git} ${*}" diff --git a/libexec/portzap/utils/gitdiff b/libexec/portzap/utils/gitdiff deleted file mode 100644 index afb2a29..0000000 --- a/libexec/portzap/utils/gitdiff +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -set -e - -## -# variables -localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)} -libexec="${localbase}"/libexec/portzap - -## -# main -"${libexec}"/utils/gitexec diff -l0 ${@} diff --git a/share/portzap/RELNOTES b/share/portzap/RELNOTES index e4b1a0e..e1acade 100644 --- a/share/portzap/RELNOTES +++ b/share/portzap/RELNOTES @@ -1,4 +1,10 @@ v?.?.? +| Replace utils/gitexec with utils/git/run + After this change, we talk to git via utils/git/run + +| Add utils/git + A dedicated directory for git-related scripts + | Remove "set -x" After this change, portzap emits less output