stagit

static git page generator - with my changes
git clone https://pi.duncano.de/git/stagit.git
Log | Files | Refs | README | LICENSE

commit 7c8d6ceaae505647a8eabd2cdb129ccc8a3f7696
parent d7e003a51924d1686574598f7db5557faf65000e
Author: Duncaen <mail@duncano.de>
Date:   Mon, 13 Feb 2017 03:35:32 +0100

add archives for refs

Diffstat:
example_create.sh | 13+++++++++++++
stagit.c | 29++++++++++++++++++++++++-----
2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/example_create.sh b/example_create.sh @@ -33,6 +33,19 @@ for dir in "${reposdir}/"*/; do cd "${curdir}/${d}" stagit -c ".cache" "${reposdir}/${r}" + # archives + git -C "${reposdir}/${r}" show-ref --tags --heads \ + | while read commit ref; do + ref="${ref#refs/*/}" + ref=$(echo "$ref" | tr "[;:<>'&\\/\* \"]" "_") + [ -z "${ref}" ] && continue + [ -e "./.cache-${ref}-${commit}" ] && continue + git -C "${reposdir}/${r}" archive --format tar --prefix="${d}-${ref}/" "${ref}" \ + | xz -z9 > "${ref}.tar.xz" \ + && touch "./.cache-${ref}-${commit}" + done + + # symlinks ln -sf log.html index.html ln -sf ../style.css style.css diff --git a/stagit.c b/stagit.c @@ -891,10 +891,10 @@ writerefs(FILE *fp) git_reference *dref = NULL, *r, *ref = NULL; git_reference_iterator *it = NULL; git_reference **refs = NULL; - size_t count, i, j, refcount; + size_t count, i, j, k, refcount, len; const char *titles[] = { "Branches", "Tags" }; const char *ids[] = { "branches", "tags" }; - const char *name; + const char *name, *s; if (git_reference_iterator_new(&it, repo)) return -1; @@ -948,9 +948,28 @@ writerefs(FILE *fp) relpath = ""; name = git_reference_shorthand(r); - fputs("<tr><td>", fp); - xmlencode(fp, name, strlen(name)); - fputs("</td><td>", fp); + fputs("<tr><td><a href=\"", fp); + len = strlen(name); + s = name; + for (k = 0; *s && k < len; s++, k++) { + switch(*s) { + case ';': + case ':': + case '<': + case '>': + case '\'': + case '&': + case '\\': + case '/': + case '*': + case ' ': + case '"': fputs("_", fp); break; + default: fputc(*s, fp); + } + } + fputs(".tar.xz\">", fp); + xmlencode(fp, name, len); + fputs("</a></td><td>", fp); if (ci->author) printtimeshort(fp, &(ci->author->when)); fputs("</td><td>", fp);