commit 087ea43dfe50c143443256cde3a3db8985a67a2a
parent 554979a6c8d7d97d7c23022dfb1f27298f8b965e
Author: root <root>
Date: Sat, 26 Apr 2025 17:07:12 +0200
Change display of files from table to html list, allow for directories to be expanded/collapsed - this way there's less stuff on the screen at once for bulkier repos
Diffstat:
3 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/stagit b/stagit
Binary files differ.
diff --git a/stagit.c b/stagit.c
@@ -1041,7 +1041,8 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
if (!(entry = git_tree_entry_byindex(tree, i)) ||
!(entryname = git_tree_entry_name(entry)))
return -1;
- joinpath(entrypath, sizeof(entrypath), path, entryname);
+
+ joinpath(entrypath, sizeof(entrypath), path, entryname);
r = snprintf(filepath, sizeof(filepath), "file/%s.html",
entrypath);
@@ -1054,9 +1055,10 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
break;
case GIT_OBJ_TREE:
/* NOTE: recurses */
- ret = writefilestree(fp, (git_tree *)obj,
- entrypath);
+ fprintf(fp, "<details>\n<summary>%s/</summary>\n<ul>\n", entrypath);
+ ret = writefilestree(fp, (git_tree *)obj, entrypath);
git_object_free(obj);
+ fprintf(fp,"</ul>\n</details>\n");
if (ret)
return ret;
continue;
@@ -1068,28 +1070,25 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
filesize = git_blob_rawsize((git_blob *)obj);
lc = writeblob(obj, filepath, entryname, filesize);
- fputs("<tr><td>", fp);
- fputs(filemode(git_tree_entry_filemode(entry)), fp);
- fprintf(fp, "</td><td><a href=\"%s", relpath);
+ fprintf(fp, "<li><a href=\"%s", relpath);
percentencode(fp, filepath, strlen(filepath));
fputs("\">", fp);
xmlencode(fp, entrypath, strlen(entrypath));
- fputs("</a></td><td class=\"num\" align=\"right\">", fp);
+ fputs("</a> (", fp);
if (lc > 0)
fprintf(fp, "%zuL", lc);
else
fprintf(fp, "%zuB", filesize);
- fputs("</td></tr>\n", fp);
+ fputs(")</li>\n", fp);
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/.gitmodules.html\">",
- relpath);
+ fprintf(fp, "<li><b>submodule:</b><a href=\"%sfile/.gitmodules.html\">", relpath);
xmlencode(fp, entrypath, strlen(entrypath));
fputs("</a> @ ", fp);
git_oid_tostr(oid, sizeof(oid), git_tree_entry_id(entry));
xmlencode(fp, oid, strlen(oid));
- fputs("</td><td class=\"num\" align=\"right\"></td></tr>\n", fp);
+ fputs("</li>\n", fp);
}
}
@@ -1103,17 +1102,10 @@ writefiles(FILE *fp, const git_oid *id)
git_commit *commit = NULL;
int ret = -1;
- fputs("<table id=\"files\"><thead>\n<tr>"
- "<td><b>Mode</b></td><td><b>Name</b></td>"
- "<td class=\"num\" align=\"right\"><b>Size</b></td>"
- "</tr>\n</thead><tbody>\n", fp);
-
if (!git_commit_lookup(&commit, repo, id) &&
!git_commit_tree(&tree, commit))
ret = writefilestree(fp, tree, "");
- fputs("</tbody></table>", fp);
-
git_commit_free(commit);
git_tree_free(tree);
diff --git a/stagit.o b/stagit.o
Binary files differ.