tstagit.c: allow specifying alternate clone url in alturl file - stagit - [fork] customized build of stagit, the static git page generator
(HTM) git clone git://src.adamsgaard.dk/stagit
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 7e58463ae5df8c8ff71767d71257388c9f8a11c3
(DIR) parent 02b67e7268ee2cb11a0fe254a832f7e6f0dcf85d
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Sat, 28 Nov 2020 00:29:38 +0100
stagit.c: allow specifying alternate clone url in alturl file
Diffstat:
M stagit.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/stagit.c b/stagit.c
t@@ -66,6 +66,7 @@ static char *name = "";
static char *strippedname = "";
static char description[255];
static char cloneurl[1024];
+static char altcloneurl[1024];
static char *submodules;
static char *releasedir = "../releases";
static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:LICENSE.txt", "HEAD:LICENSE.rst", "HEAD:COPYING" };
t@@ -479,7 +480,15 @@ writeheader(FILE *fp, const char *title)
xmlencode(fp, cloneurl, strlen(cloneurl));
fputs("\">", fp);
xmlencode(fp, cloneurl, strlen(cloneurl));
- fputs("</a></td></tr>", fp);
+ fputs("</a>", fp);
+ if (altcloneurl[0]) {
+ fputs("<br />\ngit clone <a href=\"", fp);
+ xmlencode(fp, altcloneurl, strlen(altcloneurl));
+ fputs("\">", fp);
+ xmlencode(fp, altcloneurl, strlen(altcloneurl));
+ fputs("</a>", fp);
+ }
+ fputs("</td></tr>", fp);
}
fputs("<tr><td></td><td>\n", fp);
fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
t@@ -1242,6 +1251,19 @@ main(int argc, char *argv[])
fclose(fpread);
}
+ /* read alturl or .git/alturl */
+ joinpath(path, sizeof(path), repodir, "alturl");
+ if (!(fpread = fopen(path, "r"))) {
+ joinpath(path, sizeof(path), repodir, ".git/alturl");
+ fpread = fopen(path, "r");
+ }
+ if (fpread) {
+ if (!fgets(altcloneurl, sizeof(altcloneurl), fpread))
+ altcloneurl[0] = '\0';
+ altcloneurl[strcspn(altcloneurl, "\n")] = '\0';
+ fclose(fpread);
+ }
+
/* check LICENSE */
for (i = 0; i < LEN(licensefiles) && !license; i++) {
if (!git_revparse_single(&obj, repo, licensefiles[i]) &&