From 8efe972cd5002ebe386b738d13e99ad82856debd Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 24 Sep 2021 21:34:35 -0400 Subject: [PATCH] stagit: Add -r flag to override logo link This is needed for subdirectory installations (see stagit-index -r). If the repo is in a subdirectory, the ".." default relpath for the logo is the subdirectory, and not the root. --- stagit.1 | 4 ++++ stagit.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/stagit.1 b/stagit.1 index 6585f65..10794c6 100644 --- a/stagit.1 +++ b/stagit.1 @@ -9,6 +9,7 @@ .Op Fl c Ar cachefile .Op Fl l Ar commits .Op Fl u Ar baseurl +.Op Fl r Ar rooturl .Ar repodir .Sh DESCRIPTION .Nm @@ -35,6 +36,9 @@ However the commit files are written as usual. .It Fl u Ar baseurl Base URL to make links in the Atom feeds absolute. For example: "https://git.codemadness.org/stagit/". +.It Fl r Ar rooturl +Root URL to link to for the logo. +Defaults to "..". .El .Pp The options diff --git a/stagit.c b/stagit.c index d8fbc64..3c1a9e7 100644 --- a/stagit.c +++ b/stagit.c @@ -59,6 +59,7 @@ struct referenceinfo { static git_repository *repo; static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */ +static const char *rooturl = ""; /* logo.png links to this (used in multi-dir solutions) */ static const char *relpath = ""; static const char *repodir; @@ -486,8 +487,13 @@ writeheader(FILE *fp, const char *title) name, relpath); fprintf(fp, "\n", relpath); fputs("\n\n
", fp); - fprintf(fp, "\"\"", - relpath, relpath); + if (rooturl) { + fprintf(fp, "\"\"", + rooturl, relpath); + } else { + fprintf(fp, "\"\"", + relpath, relpath); + } fputs("

", fp); xmlencode(fp, strippedname, strlen(strippedname)); fputs("

", fp); @@ -1182,6 +1188,10 @@ main(int argc, char *argv[]) if (i + 1 >= argc) usage(argv[0]); baseurl = argv[++i]; + } else if (argv[i][1] == 'r') { + if (i + 1 >= argc) + usage(argv[0]); + rooturl = argv[++i]; } } if (!repodir) -- libgit2 1.1.1