stagit-gopher

[fork] gopher git frontend
Log | Files | Refs | README | LICENSE

commit 708600cc294ea1046570cd99bfc4276ae05fe8cf
parent 674aea73d030474a8fd66537768ea19c9b426f87
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri, 23 Jun 2017 13:15:30 +0200

Empty default relpath and prefix selector with '/'

Diffstat:
Mstagit-gopher.c | 28++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/stagit-gopher.c b/stagit-gopher.c @@ -49,7 +49,7 @@ struct commitinfo { static git_repository *repo; -static const char *relpath = "/"; +static const char *relpath = ""; static const char *repodir; static char *name = ""; @@ -439,15 +439,15 @@ writeheader(FILE *fp, const char *title) gphlink(fp, cloneurl, strlen(cloneurl)); fputs("|server|port]\n", fp); } - fprintf(fp, "[1|Log|%slog.gph|server|port]\n", relpath); - fprintf(fp, "[1|Files|%sfiles.gph|server|port]\n", relpath); - fprintf(fp, "[1|Refs|%srefs.gph|server|port]\n", relpath); + fprintf(fp, "[1|Log|%s/log.gph|server|port]\n", relpath); + fprintf(fp, "[1|Files|%s/files.gph|server|port]\n", relpath); + fprintf(fp, "[1|Refs|%s/refs.gph|server|port]\n", relpath); if (hassubmodules) - fprintf(fp, "[1|Submodules|%sfile/.gitmodules.gph|server|port]\n", relpath); + fprintf(fp, "[1|Submodules|%s/file/.gitmodules.gph|server|port]\n", relpath); if (hasreadme) - fprintf(fp, "[1|README|%sfile/README.gph|server|port]\n", relpath); + fprintf(fp, "[1|README|%s/file/README.gph|server|port]\n", relpath); if (haslicense) - fprintf(fp, "[1|LICENSE|%sfile/LICENSE.gph|server|port]\n", relpath); + fprintf(fp, "[1|LICENSE|%s/file/LICENSE.gph|server|port]\n", relpath); fputs("---\n", fp); } @@ -499,11 +499,11 @@ writeblobgph(FILE *fp, const git_blob *blob) void printcommit(FILE *fp, struct commitinfo *ci) { - fprintf(fp, "[1|commit %s|%scommit/%s.gph|server|port]\n", + fprintf(fp, "[1|commit %s|%s/commit/%s.gph|server|port]\n", ci->oid, relpath, ci->oid); if (ci->parentoid[0]) - fprintf(fp, "[1|parent %s|%scommit/%s.gph|server|port]\n", + fprintf(fp, "[1|parent %s|%s/commit/%s.gph|server|port]\n", ci->parentoid, relpath, ci->parentoid); if (ci->author) { @@ -594,7 +594,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) /* NOTE: only links to new path */ fprintf(fp, "[1|diff --git a/%s b/%s", delta->old_file.path, delta->new_file.path); - fprintf(fp, "|%sfile/%s.gph|server|port]\n", relpath, delta->new_file.path); + fprintf(fp, "|%s/file/%s.gph|server|port]\n", relpath, delta->new_file.path); /* check binary data */ if (delta->flags & GIT_DIFF_FLAG_BINARY) { @@ -642,7 +642,7 @@ writelogline(FILE *fp, struct commitinfo *ci) trim(buf, sizeof(buf), ci->author->name); printutf8pad(fp, buf, 25, ' '); } - fprintf(fp, "|%scommit/%s.gph", relpath, ci->oid); + fprintf(fp, "|%s/commit/%s.gph", relpath, ci->oid); fputs("|server|port]\n", fp); } @@ -909,14 +909,14 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) fprintf(fp, "%7dL", lc); else fprintf(fp, "%7juB", (uintmax_t)filesize); - fprintf(fp, "|%s%s", relpath, filepath); + fprintf(fp, "|%s/%s", relpath, filepath); fputs("|server|port]\n", fp); git_object_free(obj); } else if (!git_submodule_lookup(&module, repo, entryname)) { fputs("[1|m--------- ", fp); trim(buf, sizeof(buf), entrypath); printutf8pad(fp, buf, 50, ' '); - fprintf(fp, "|%sfile/.gitmodules.gph|server|port]\n", relpath); + fprintf(fp, "|%s/file/.gitmodules.gph|server|port]\n", relpath); /* NOTE: linecount omitted */ git_submodule_free(module); } @@ -1217,7 +1217,7 @@ main(int argc, char *argv[]) if (head) writelog(fp, head); } - fprintf(fp, "\n[0|Atom feed|%satom.xml|server|port]\n", relpath); + fprintf(fp, "\n[0|Atom feed|%s/atom.xml|server|port]\n", relpath); writefooter(fp); fclose(fp);