commit 403caa5e9fb401e8b8aa62fc02ab60c60568b6d0
parent 2780792a7bf3beb1e1c1fa6c3c24652823cef72a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 24 May 2022 12:26:23 +0200
parent 2780792a7bf3beb1e1c1fa6c3c24652823cef72a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 24 May 2022 12:26:23 +0200
writeblob: link to parent-folder with path before filename
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/stagit.c b/stagit.c @@ -930,6 +930,7 @@ writeblob(git_object *obj, const char *fpath, const char *rpath, const char *fil char tmp[PATH_MAX] = ""; const char *p, *oldrelpath; int lc = 0; + int parent_path_len = strlen(filepath) - strlen(filename); FILE *fp; mkdirfile(fpath); @@ -948,6 +949,19 @@ writeblob(git_object *obj, const char *fpath, const char *rpath, const char *fil fp = efopen(fpath, "w"); fputs("<p> ", fp); writeheader(fp, filename, "tree"); + + if (parent_path_len > 0) { + parent_path_len--; + + fprintf(fp, "<a href=\"%stree/", relpath); + percentencode(fp, filepath, parent_path_len); + fputs(".html\">/", fp); + xmlencode(fp, filepath, parent_path_len); + fputs("/</a>", fp); + } else { + fprintf(fp, "<a href=\"%stree.html\">/</a>", relpath); + } + xmlencode(fp, filename, strlen(filename)); fprintf(fp, " (%zuB)", filesize); fprintf(fp, " - <a href=\"%s%s\">raw</a></p><hr/>", relpath, rpath);