dotfiles

My configuration files
git clone git://git.finwo.net/misc/dotfiles
Log | Files | Refs

commit e90548592bb45be0fc4ee378e5148905186081ad
parent 2ff25fd3edd6d40500c97b595300f099c7a2c7d5
Author: finwo <finwo@pm.me>
Date:   Fri,  2 Jul 2021 10:57:51 +0200

Added bare git init

Diffstat:
Agit/home/git/init.sh | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+), 0 deletions(-)

diff --git a/git/home/git/init.sh b/git/home/git/init.sh @@ -0,0 +1,53 @@ +#!bash + +# Crash and verbose +set -ex + +# cd to the right dir +cd $(dirname $0) +git init --bare $1 + +rm -rf $1/hooks/*.sample +cat << 'EOF' > "$1/hooks/post-receive" +#!/bin/sh + +# Detect a force push +force=0 +while read -r old new ref; do + hasrevs=$(git rev-list "$old" "^$new" | sed 1q) + if test -n "$hasrevs"; then + force=1 + break + fi +done + +# Forward to other remotes +git remote | while read remote; do + if test "$force" = "1"; then + git push --force --all ${remote} + else + git push --all ${remote} + fi +done +EOF + +chmod +x "$1/hooks/post-receive" + +# # Remove old data on force push +# if test "$force" = "1"; then +# rm -rf archives +# fi + +# # Build archives +# mkdir -p archives +# git for-each-ref --format="%(refname:short)" | while read -r ref; do +# filename="archives/$(echo "${ref}" | tr '/' '_').tar.gz" +# prefix=$(cat name | tr '/' '-') +# git archive \ +# --format tar.gz \ +# --prefix "${prefix}-${ref}/" \ +# -o "${filename}" \ +# -- \ +# "${ref}" +# done +