commit 6a11ed8ec429faed8f08110cb7709291b912fec0
parent cd9b4bf66e42cb6ceda5460fd61a86f6eaedba96
Author: Michael Neuper <michael@michaelneuper.com>
Date: Wed, 28 Oct 2026 10:58:42 +0200
Revert "prefix dot path components with '_' in output paths"
This reverts commit d99a6b727de6cf19a40b0ccbc7634e04cd257761.
The site moves to Cloudflare, which deploys dotfiles, so the prefix isn't
needed. The README link resolution added since then uses the path as is.
Diffstat:
| M | README.md | | | 3 | --- |
| M | stagit.c | | | 78 | ++++++++++++++++++++++-------------------------------------------------------- |
2 files changed, 22 insertions(+), 59 deletions(-)
diff --git a/README.md b/README.md
@@ -16,9 +16,6 @@ mirror of my public GitHub repos. The upstream README is in `README`.
- Files are browsed by directory: `files.html` lists the top level, each
directory gets a page at `tree/<path>.html`, and file and directory pages
start with a linked path.
-- Path components that start with a dot get a `_` prefix in output paths
- (`file/_.gitignore.html`), because netlify-cli skips dotfiles when
- deploying. Names are still shown with the dot.
- cgit-flavoured `style.css`, and my own logo and favicon.
- The Makefile also finds libraries installed by Homebrew.
diff --git a/stagit.c b/stagit.c
@@ -394,35 +394,6 @@ percentencode(FILE *fp, const char *s, size_t len)
}
}
-/* Static hosts like Netlify skip files and directories whose name starts
- * with a dot, so in output paths such components get a '_' prefix. */
-void
-outpath(char *buf, size_t bufsiz, const char *path, size_t len)
-{
- size_t i, j;
-
- for (i = 0, j = 0; i < len && path[i]; i++) {
- if (path[i] == '.' && (i == 0 || path[i - 1] == '/')) {
- if (j + 1 >= bufsiz)
- errx(1, "path truncated: '%s'", path);
- buf[j++] = '_';
- }
- if (j + 1 >= bufsiz)
- errx(1, "path truncated: '%s'", path);
- buf[j++] = path[i];
- }
- buf[j] = '\0';
-}
-
-void
-percentencodepath(FILE *fp, const char *s, size_t len)
-{
- char buf[PATH_MAX];
-
- outpath(buf, sizeof(buf), s, len);
- percentencode(fp, buf, strlen(buf));
-}
-
/* Escape characters below as HTML 2.0 / XML 1.0. */
void
xmlencode(FILE *fp, const char *s, size_t len)
@@ -572,11 +543,9 @@ writeheader(FILE *fp, const char *title)
fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath);
fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath);
fprintf(fp, "<a href=\"%srefs.html\">Refs</a>", relpath);
- if (submodules) {
- fprintf(fp, " | <a href=\"%sfile/", relpath);
- percentencodepath(fp, submodules, strlen(submodules));
- fputs(".html\">Submodules</a>", fp);
- }
+ if (submodules)
+ fprintf(fp, " | <a href=\"%sfile/%s.html\">Submodules</a>",
+ relpath, submodules);
if (license)
fprintf(fp, " | <a href=\"%sfile/%s.html\">LICENSE</a>",
relpath, license);
@@ -822,11 +791,11 @@ printshowfile(FILE *fp, struct commitinfo *ci)
patch = ci->deltas[i]->patch;
delta = git_patch_get_delta(patch);
fprintf(fp, "<b>diff --git a/<a id=\"h%zu\" href=\"%sfile/", i, relpath);
- percentencodepath(fp, delta->old_file.path, strlen(delta->old_file.path));
+ percentencode(fp, delta->old_file.path, strlen(delta->old_file.path));
fputs(".html\">", fp);
xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path));
fprintf(fp, "</a> b/<a href=\"%sfile/", relpath);
- percentencodepath(fp, delta->new_file.path, strlen(delta->new_file.path));
+ percentencode(fp, delta->new_file.path, strlen(delta->new_file.path));
fprintf(fp, ".html\">");
xmlencode(fp, delta->new_file.path, strlen(delta->new_file.path));
fprintf(fp, "</a></b>\n");
@@ -1085,7 +1054,7 @@ int
writereadmeurl(FILE *fp, const char *url, size_t len, int img)
{
git_object *obj = NULL;
- char path[PATH_MAX], spec[PATH_MAX], out[PATH_MAX], fpath[PATH_MAX];
+ char path[PATH_MAX], spec[PATH_MAX], fpath[PATH_MAX];
char tmp[PATH_MAX], hex[3] = "", *d;
const char *s;
size_t i, j;
@@ -1145,29 +1114,28 @@ writereadmeurl(FILE *fp, const char *url, size_t len, int img)
git_object_free(obj);
return 0;
}
- outpath(out, sizeof(out), s, strlen(s));
switch (git_object_type(obj)) {
case GIT_OBJ_TREE:
if (img)
break;
fputs("tree/", fp);
- percentencode(fp, out, strlen(out));
+ percentencode(fp, s, strlen(s));
fputs(".html", fp);
git_object_free(obj);
return 1;
case GIT_OBJ_BLOB:
if (!img && !git_blob_is_binary((git_blob *)obj)) {
fputs("file/", fp);
- percentencode(fp, out, strlen(out));
+ percentencode(fp, s, strlen(s));
fputs(".html", fp);
git_object_free(obj);
return 1;
}
- r = snprintf(fpath, sizeof(fpath), "raw/%s", out);
+ r = snprintf(fpath, sizeof(fpath), "raw/%s", s);
if (r < 0 || (size_t)r >= sizeof(fpath))
- errx(1, "path truncated: 'raw/%s'", out);
+ errx(1, "path truncated: 'raw/%s'", s);
if (strlcpy(tmp, fpath, sizeof(tmp)) >= sizeof(tmp))
errx(1, "path truncated: '%s'", fpath);
if (!(d = dirname(tmp)))
@@ -1182,7 +1150,7 @@ writereadmeurl(FILE *fp, const char *url, size_t len, int img)
fclose(rawfp);
fputs("raw/", fp);
- percentencode(fp, out, strlen(out));
+ percentencode(fp, s, strlen(s));
git_object_free(obj);
return 1;
default:
@@ -1342,7 +1310,7 @@ writepath(FILE *fp, const char *path)
fputs("</a>", fp);
for (s = path; (e = strchr(s, '/')); s = e + 1) {
fprintf(fp, "/<a href=\"%stree/", relpath);
- percentencodepath(fp, path, e - path);
+ percentencode(fp, path, e - path);
fputs(".html\">", fp);
xmlencode(fp, s, e - s);
fputs("</a>", fp);
@@ -1461,10 +1429,9 @@ writetree(git_tree *tree, const char *path)
FILE *fp;
int r, ret;
- outpath(tmp, sizeof(tmp), path, strlen(path));
- r = snprintf(fpath, sizeof(fpath), "tree/%s.html", tmp);
+ r = snprintf(fpath, sizeof(fpath), "tree/%s.html", path);
if (r < 0 || (size_t)r >= sizeof(fpath))
- errx(1, "path truncated: 'tree/%s.html'", tmp);
+ errx(1, "path truncated: 'tree/%s.html'", path);
if (strlcpy(tmp, fpath, sizeof(tmp)) >= sizeof(tmp))
errx(1, "path truncated: '%s'", fpath);
@@ -1500,7 +1467,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path, const char *rel)
const git_tree_entry *entry = NULL;
git_object *obj = NULL;
const char *entryname, *p;
- char filepath[PATH_MAX], entrypath[PATH_MAX], tmp[PATH_MAX], oid[8];
+ char filepath[PATH_MAX], entrypath[PATH_MAX], oid[8];
size_t count, i, lc, filesize;
int r, ret;
@@ -1508,7 +1475,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path, const char *rel)
fprintf(fp, "<tr><td></td><td><a href=\"%s", rel);
if ((p = strrchr(path, '/'))) {
fputs("tree/", fp);
- percentencodepath(fp, path, p - path);
+ percentencode(fp, path, p - path);
fputs(".html", fp);
} else {
fputs("files.html", fp);
@@ -1538,7 +1505,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path, const char *rel)
fputs("<tr><td>", fp);
fputs(filemode(git_tree_entry_filemode(entry)), fp);
fprintf(fp, "</td><td><a href=\"%stree/", rel);
- percentencodepath(fp, entrypath, strlen(entrypath));
+ percentencode(fp, entrypath, strlen(entrypath));
fputs(".html\">", fp);
xmlencode(fp, entryname, strlen(entryname));
fputs("/</a></td><td class=\"num\" align=\"right\"></td></tr>\n", fp);
@@ -1552,10 +1519,10 @@ writefilestree(FILE *fp, git_tree *tree, const char *path, const char *rel)
continue;
joinpath(entrypath, sizeof(entrypath), path, entryname);
- outpath(tmp, sizeof(tmp), entrypath, strlen(entrypath));
- r = snprintf(filepath, sizeof(filepath), "file/%s.html", tmp);
+ r = snprintf(filepath, sizeof(filepath), "file/%s.html",
+ entrypath);
if (r < 0 || (size_t)r >= sizeof(filepath))
- errx(1, "path truncated: 'file/%s.html'", tmp);
+ errx(1, "path truncated: 'file/%s.html'", entrypath);
if (!git_tree_entry_to_object(&obj, repo, entry)) {
switch (git_object_type(obj)) {
@@ -1584,9 +1551,8 @@ writefilestree(FILE *fp, git_tree *tree, const char *path, const char *rel)
git_object_free(obj);
} else if (git_tree_entry_type(entry) == GIT_OBJ_COMMIT) {
/* commit object in tree is a submodule */
- fprintf(fp, "<tr><td>m---------</td><td><a href=\"%sfile/", rel);
- percentencodepath(fp, ".gitmodules", strlen(".gitmodules"));
- fputs(".html\">", fp);
+ fprintf(fp, "<tr><td>m---------</td><td><a href=\"%sfile/.gitmodules.html\">",
+ rel);
xmlencode(fp, entryname, strlen(entryname));
fputs("</a> @ ", fp);
git_oid_tostr(oid, sizeof(oid), git_tree_entry_id(entry));