From fb921ca742c3f61612965955e79dc374ad9ba574 Mon Sep 17 00:00:00 2001 From: gutmet Date: Wed, 24 Feb 2021 15:26:48 +0100 Subject: [PATCH] minimalist replacement for cgit * just dump current HEAD, nobody cares about anything else anyway * and if they do, they can use git as once intended --- git-dump | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 git-dump diff --git a/git-dump b/git-dump new file mode 100755 index 0000000..f3a7e35 --- /dev/null +++ b/git-dump @@ -0,0 +1,26 @@ +#!/bin/sh + +# USAGE: +# Working directory needs to be git repo +# call with name of directory you'd like to dump to + +set -eu + +DIR="/var/www/git-dump/$1" + +files=`git ls-tree --full-tree -r --name-only HEAD` + +rm -rf "$DIR" + +echo "$files" | while IFS=$'\n' read -r f; do + subdir=`dirname $f` + fulldir="$DIR/$subdir" + mkdir -p "$fulldir" + fullpath="$DIR/$f.txt" + git show HEAD:"$f" > "$fullpath" + if file "$fullpath" | grep -q "text"; then + : + else + echo "Binary file" > "$fullpath" + fi +done