Introduction
Introduction Statistics Contact Development Disclaimer Help
detect more names for README and LICENSE - stagit - static git page generator
git clone git://git.codemadness.org/stagit
Log
Files
Refs
README
LICENSE
---
commit 84bb2212e86c54f67dc18cf803bd2ac6edf24804
parent 8c45dfc58edc069a3787224f522c7f62da501a80
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 11 Nov 2018 18:23:28 +0100
detect more names for README and LICENSE
- for license: LICENSE, LICENSE.md, COPYING.
- for readme: README, README.md.
Diffstat:
M stagit.c | 46 ++++++++++++++++++++---------…
1 file changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/stagit.c b/stagit.c
@@ -56,12 +56,16 @@ static char *name = "";
static char *strippedname = "";
static char description[255];
static char cloneurl[1024];
-static int haslicense, hasreadme, hassubmodules;
+static char *submodules;
+static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:COPYI…
+static char *license;
+static char *readmefiles[] = { "HEAD:README", "HEAD:README.md" };
+static char *readme;
static long long nlogcommits = -1; /* < 0 indicates not used */
/* cache */
static git_oid lastoid;
-static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + nul byte */
+static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + NUL byte */
static FILE *rcachefp, *wcachefp;
static const char *cachefile;
@@ -366,12 +370,15 @@ writeheader(FILE *fp, const char *title)
fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath);
- if (hassubmodules)
- fprintf(fp, " | <a href=\"%sfile/.gitmodules.html\">Submodules…
- if (hasreadme)
- fprintf(fp, " | <a href=\"%sfile/README.html\">README</a>", re…
- if (haslicense)
- fprintf(fp, " | <a href=\"%sfile/LICENSE.html\">LICENSE</a>", …
+ if (submodules)
+ fprintf(fp, " | <a href=\"%sfile/%s.html\">Submodules</a>",
+ relpath, submodules);
+ if (readme)
+ fprintf(fp, " | <a href=\"%sfile/%s.html\">README</a>",
+ relpath, readme);
+ if (license)
+ fprintf(fp, " | <a href=\"%sfile/%s.html\">LICENSE</a>",
+ relpath, license);
fputs("</td></tr></table>\n<hr/>\n<div id=\"content\">\n", fp);
}
@@ -1124,17 +1131,24 @@ main(int argc, char *argv[])
}
/* check LICENSE */
- haslicense = (!git_revparse_single(&obj, repo, "HEAD:LICENSE") &&
- git_object_type(obj) == GIT_OBJ_BLOB);
- git_object_free(obj);
+ for (i = 0; i < sizeof(licensefiles) / sizeof(*licensefiles) && !licen…
+ if (!git_revparse_single(&obj, repo, licensefiles[i]) &&
+ git_object_type(obj) == GIT_OBJ_BLOB)
+ license = licensefiles[i] + strlen("HEAD:");
+ git_object_free(obj);
+ }
/* check README */
- hasreadme = (!git_revparse_single(&obj, repo, "HEAD:README") &&
- git_object_type(obj) == GIT_OBJ_BLOB);
- git_object_free(obj);
+ for (i = 0; i < sizeof(readmefiles) / sizeof(*readmefiles) && !readme;…
+ if (!git_revparse_single(&obj, repo, readmefiles[i]) &&
+ git_object_type(obj) == GIT_OBJ_BLOB)
+ readme = readmefiles[i] + strlen("HEAD:");
+ git_object_free(obj);
+ }
- hassubmodules = (!git_revparse_single(&obj, repo, "HEAD:.gitmodules") …
- git_object_type(obj) == GIT_OBJ_BLOB);
+ if (!git_revparse_single(&obj, repo, "HEAD:.gitmodules") &&
+ git_object_type(obj) == GIT_OBJ_BLOB)
+ submodules = ".gitmodules";
git_object_free(obj);
/* log for HEAD */
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.