commit eed0237b83a32392e6d4d11a992d865974677827
parent df9d7d24460db69f09a400eba699f37108482a00
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Thu, 10 Jun 2021 22:50:11 +0200

Merge tag '0.9.6'

Diffstat:
MMakefile | 2+-
MREADME.md | 11++++++++---
Mstagit-index.c | 6+++---
Mstagit.1 | 5+++--
Mstagit.c | 25++++++++++++++++++++++---
5 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,7 +1,7 @@ .POSIX: NAME = stagit -VERSION = 0.9.5 +VERSION = 0.9.6 # paths PREFIX = /usr/local diff --git a/README.md b/README.md @@ -15,12 +15,17 @@ Usage Make files per repository: - $ mkdir -p htmldir && cd htmldir - $ stagit path-to-repo + $ mkdir -p htmlroot/htmlrepo1 && cd htmlroot/htmlrepo1 + $ stagit path/to/gitrepo1 + repeat for other repositories + $ ... Make index file for repositories: - $ stagit-index repodir1 repodir2 repodir3 > index.html + $ cd htmlroot + $ stagit-index path/to/gitrepo1 \ + path/to/gitrepo2 \ + path/to/gitrepo3 > index.html Build and install diff --git a/stagit-index.c b/stagit-index.c @@ -68,8 +68,9 @@ writeheader(FILE *fp) "<html>\n<head>\n" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n" - "<title>Git Repositories | Oscar Benedito</title>\n", fp); - fprintf(fp, "<link rel=\"icon\" type=\"image/png\" href=\"%sfavicon.ico\" />\n", relpath); + "<title>", fp); + xmlencode(fp, description, strlen(description)); + fprintf(fp, "</title>\n<link rel=\"icon\" href=\"%sfavicon.ico\" />\n", relpath); fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", relpath); fputs("</head>\n<body id=\"home\">\n<h1>", fp); xmlencode(fp, description, strlen(description)); @@ -103,7 +104,6 @@ writelog(FILE *fp) git_revwalk_new(&w, repo); git_revwalk_push_head(w); - git_revwalk_simplify_first_parent(w); if (git_revwalk_next(&id, w) || git_commit_lookup(&commit, repo, &id)) { diff --git a/stagit.1 b/stagit.1 @@ -1,4 +1,4 @@ -.Dd March 5, 2021 +.Dd May 18, 2021 .Dt STAGIT 1 .Os .Sh NAME @@ -92,7 +92,8 @@ description .It .git/owner or owner (bare repo). owner of repository .It .git/url or url (bare repo). -primary clone url of the repository, for example: git://git.2f30.org/stagit +primary clone url of the repository, for example: +git://git.codemadness.org/stagit .El .Pp When a README or LICENSE file exists in HEAD or a .gitmodules submodules file diff --git a/stagit.c b/stagit.c @@ -380,6 +380,26 @@ xmlencode(FILE *fp, const char *s, size_t len) } } +/* Escape characters below as HTML 2.0 / XML 1.0, ignore printing '\r', '\n' */ +void +xmlencodeline(FILE *fp, const char *s, size_t len) +{ + size_t i; + + for (i = 0; *s && i < len; s++, i++) { + switch(*s) { + case '<': fputs("&lt;", fp); break; + case '>': fputs("&gt;", fp); break; + case '\'': fputs("&#39;", fp); break; + case '&': fputs("&amp;", fp); break; + case '"': fputs("&quot;", fp); break; + case '\r': break; /* ignore CR */ + case '\n': break; /* ignore LF */ + default: putc(*s, fp); + } + } +} + int mkdirp(const char *path) { @@ -698,7 +718,8 @@ printshowfile(FILE *fp, struct commitinfo *ci) i, j, k, i, j, k); else putc(' ', fp); - xmlencode(fp, line->content, line->content_len); + xmlencodeline(fp, line->content, line->content_len); + putc('\n', fp); if (line->old_lineno == -1 || line->new_lineno == -1) fputs("</a>", fp); } @@ -742,7 +763,6 @@ writelog(FILE *fp, const git_oid *oid) git_revwalk_new(&w, repo); git_revwalk_push(w, oid); - git_revwalk_simplify_first_parent(w); while (!git_revwalk_next(&id, w)) { relpath = ""; @@ -880,7 +900,6 @@ writeatom(FILE *fp, int all) if (all) { git_revwalk_new(&w, repo); git_revwalk_push_head(w); - git_revwalk_simplify_first_parent(w); for (i = 0; i < m && !git_revwalk_next(&id, w); i++) { if (!(ci = commitinfo_getbyoid(&id))) break;