From 164ba68e506c5a23583e29c29a217d212b62f543 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 28 Aug 2021 07:54:01 +0200 Subject: Adding upstream version 20210828. Signed-off-by: Daniel Baumann --- git/bin/git-checkout-branches | 29 ++++++++++++++++++++++++ git/bin/git-hook.d | 13 +++++++++++ git/bin/git-remove-origin-branches | 10 +++++++++ git/bin/git-remove-origin-tags | 10 +++++++++ git/bin/git-repo-repack | 45 ++++++++++++++++++++++++++++++++++++++ git/bin/git-whoami | 33 ++++++++++++++++++++++++++++ 6 files changed, 140 insertions(+) create mode 100755 git/bin/git-checkout-branches create mode 100755 git/bin/git-hook.d create mode 100755 git/bin/git-remove-origin-branches create mode 100755 git/bin/git-remove-origin-tags create mode 100755 git/bin/git-repo-repack create mode 100755 git/bin/git-whoami (limited to 'git/bin') diff --git a/git/bin/git-checkout-branches b/git/bin/git-checkout-branches new file mode 100755 index 0000000..5b1ef15 --- /dev/null +++ b/git/bin/git-checkout-branches @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e + +CURRENT_BRANCH="$(git branch --show-current)" +REMOTE_BRANCHES="$(git branch -r | awk '{ print $1 }')" + +for REMOTE_BRANCH in ${REMOTE_BRANCHES} +do + BRANCH="$(echo "${REMOTE_BRANCH}" | cut -d/ -f 2-)" + + case "${BRANCH}" in + HEAD) + continue + ;; + esac + + if git branch | grep -Eq "^ *${BRANCH}$" + then + continue + fi + + git checkout -b "${BRANCH}" "${REMOTE_BRANCH}" +done + +if [ "$(git branch --show-current)" != "${CURRENT_BRANCH}" ] +then + git checkout "${CURRENT_BRANCH}" +fi diff --git a/git/bin/git-hook.d b/git/bin/git-hook.d new file mode 100755 index 0000000..1c0ab10 --- /dev/null +++ b/git/bin/git-hook.d @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +HOOKS="${0}.d" + +for HOOK in "${HOOKS}"/* +do + if [ -x "${HOOK}" ] + then + "${HOOK}" "${@}" || true + fi +done diff --git a/git/bin/git-remove-origin-branches b/git/bin/git-remove-origin-branches new file mode 100755 index 0000000..f2b580f --- /dev/null +++ b/git/bin/git-remove-origin-branches @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +BRANCHES="${*}" + +for BRANCH in ${BRANCHES} +do + git push origin :"${BRANCH}" +done diff --git a/git/bin/git-remove-origin-tags b/git/bin/git-remove-origin-tags new file mode 100755 index 0000000..bcbf192 --- /dev/null +++ b/git/bin/git-remove-origin-tags @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +TAGS="${*}" + +for TAG in ${TAGS} +do + git push origin :refs/tags/"${TAG}" +done diff --git a/git/bin/git-repo-repack b/git/bin/git-repo-repack new file mode 100755 index 0000000..d9d7357 --- /dev/null +++ b/git/bin/git-repo-repack @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +case "${1}" in + --quiet) + QUIET="true" + shift + + GIT_REPACK_OPTIONS="-q" + GIT_GC_OPTIONS="--quiet" + ;; +esac + +REPOSITORIES="${*}" + +if [ -z "${REPOSITORIES}" ] +then + if [ ! -e HEAD ] + then + REPOSITORIES="*.git" + else + REPOSITORIES="$(pwd)" + fi +fi + +for REPOSITORY in ${REPOSITORIES} +do + [ "${QUIET}" ] || echo "================================================================================" + [ "${QUIET}" ] || echo "${REPOSITORY}" + [ "${QUIET}" ] || echo "================================================================================" + + cd "${REPOSITORY}" + git repack "${GIT_REPACK_OPTIONS}" -a -b -d -f -F + git gc "${GIT_GC_OPTIONS}" --aggressive --prune + cd "${OLDPWD}" + + if [ "$(id -u)" -eq "0" ] + then + USER_ID="$(stat -c %u "${REPOSITORY}")" + GROUP_ID="$(stat -c %g "${REPOSITORY}")" + + chown "${USER_ID}":"${GROUP_ID}" "${REPOSITORY}" -R + fi +done diff --git a/git/bin/git-whoami b/git/bin/git-whoami new file mode 100755 index 0000000..9cab9bc --- /dev/null +++ b/git/bin/git-whoami @@ -0,0 +1,33 @@ +#!/bin/sh + +# git-whoami +# Author: Peter Eisentraut +# Created: 2011-10-27 +# License: WTFPL; see http://sam.zoy.org/wtfpl/ + +# exact logic in ident.c in git source tree + +set -e + +get_email() { + git config user.email || ( [ -n "$EMAIL" ] && echo "$EMAIL" ) || echo "$(id -nu)@$(hostname --fqdn)" +} + +get_name() { + git config user.name || getent passwd $(id -un) | cut -d : -f 5 | cut -d , -f 1 +} + +: ${GIT_AUTHOR_NAME=$(get_name)} +: ${GIT_COMMITTER_NAME=$(get_name)} +: ${GIT_AUTHOR_EMAIL=$(get_email)} +: ${GIT_COMMITTER_EMAIL=$(get_email)} + +author="$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" +commit="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" + +if [ "$author" = "$commit" ]; then + echo "$author" +else + echo "Author: $author" + echo "Commit: $commit" +fi -- cgit v1.2.3