git-server

git server-side stuff | stagit
git clone git://git.ckyln.com/~cem/hooks.git
Log | Files | Refs | README

commit 3e9aa6d333097d6d557254b7a3b2b4b5aaa63509
parent b7ec02433bb14004a5ecc6e32ebe17d15a16f4ec
Author: Cem Keylan <cem@ckyln.com>
Date:   Fri, 19 Jun 2020 08:40:56 +0300

post-receive: fix archive creation

Diffstat:
Mpost-receive | 41++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/post-receive b/post-receive @@ -69,21 +69,19 @@ ln -sf log.html index.html # Create archives and plain raw files [ "$ARCHIVE_ALL" = 1 ] || [ -f archive ] && { mkdir -p "$STAGIT_DIR/archive/$repository" - for file in $(git show-ref --tags --heads); do - file=${file#* } - - # Skip tarball recreation for tags, but always recreate branches. - case "$file" in refs/heads/*) recreate=1 ;; *) unset recreate; esac - tag=${file#refs/*/} - tarball="$STAGIT_DIR/archive/$repository/$repository-$tag.tar.gz" - [ "$recreate" != 1 ] && [ -f "$tarball" ] && continue - - git archive \ - --format tar.gz \ - --prefix "$repository-$tag/" \ - -o "$tarball" \ - -- "$tag" - done + git show-ref --tags --heads | + while read -r _ ref; do + case "$ref" in refs/heads/*) recreate=1 ;; *) unset recreate; esac + tag=${file#refs/*/} + tarball="$STAGIT_DIR/archive/$repository/$repository-$tag.tar.gz" + [ "$recreate" != 1 ] && [ -f "$tarball" ] && continue + + git archive \ + --format tar.gz \ + --prefix "$repository-$tag/" \ + -o "$tarball" \ + -- "$tag" + done for dir in archive "archive/$repository"; do ( cd "$STAGIT_DIR/$dir" lsindex "$STAGIT_DIR" > index.html @@ -91,10 +89,11 @@ ln -sf log.html index.html } [ "$RAW_ALL" = 1 ] || [ -f raw ] && { - for file in $(git show-ref --heads); do - branch=${file##*/} - mkdir -p "$STAGIT_DIR/raw/$repository/$branch" - git archive --format tar -- "$branch" | - (cd "$STAGIT_DIR/raw/$repository/$branch" || return 1 ; tar xf -) - done + git show-ref --heads | + while read -r _ ref; do + branch=${ref##*/} + mkdir -p "$STAGIT_DIR/raw/$repository/$branch" + git archive --format tar -- "$branch" | + (cd "$STAGIT_DIR/raw/$repository/$branch" || return 1 ; tar xf -) + done }