iDon't fail on submodules - stagit-gopher - A git gopher frontend. (mirror) Err bitreich.org 70 hgit clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ URL:git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ bitreich.org 70 1Log /scm/stagit-gopher/log.gph bitreich.org 70 1Files /scm/stagit-gopher/files.gph bitreich.org 70 1Refs /scm/stagit-gopher/refs.gph bitreich.org 70 1Tags /scm/stagit-gopher/tag bitreich.org 70 1README /scm/stagit-gopher/file/README.gph bitreich.org 70 1LICENSE /scm/stagit-gopher/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 571076b419daec91efb5e5d39dd17066e43805bc /scm/stagit-gopher/commit/571076b419daec91efb5e5d39dd17066e43805bc.gph bitreich.org 70 1parent 28730218c4b68e9b3a0f7ce628868bb647d97f9e /scm/stagit-gopher/commit/28730218c4b68e9b3a0f7ce628868bb647d97f9e.gph bitreich.org 70 hAuthor: z3bra URL:mailto:willyatmailoodotorg bitreich.org 70 iDate: Fri, 29 Apr 2016 01:40:30 +0200 Err bitreich.org 70 i Err bitreich.org 70 iDon't fail on submodules Err bitreich.org 70 i Err bitreich.org 70 iSubmodules will get listed prefixed with a '@', using a specific CSS class for Err bitreich.org 70 istyling. The href will be set to the url of the submodule. Err bitreich.org 70 iFilesize will appear as 0 and filemode will not be printed to avoid an awkward Err bitreich.org 70 imode: "?---------". Err bitreich.org 70 i Err bitreich.org 70 iIn writefilestree, we don't return anymore if an entry can't be categorized as Err bitreich.org 70 ian object, but rather, fail if we can't retrieve its name. Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M stagit.c | 69 ++++++++++++++++++------------- Err bitreich.org 70 i M style.css | 4 ++++ Err bitreich.org 70 i Err bitreich.org 70 i2 files changed, 44 insertions(+), 29 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/stagit.c b/stagit.c /scm/stagit-gopher/file/stagit.c.gph bitreich.org 70 i@@ -653,6 +653,7 @@ int Err bitreich.org 70 i writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path) Err bitreich.org 70 i { Err bitreich.org 70 i const git_tree_entry *entry = NULL; Err bitreich.org 70 i+ git_submodule *module = NULL; Err bitreich.org 70 i const char *entryname; Err bitreich.org 70 i char filepath[PATH_MAX], entrypath[PATH_MAX]; Err bitreich.org 70 i git_object *obj = NULL; Err bitreich.org 70 i@@ -663,29 +664,13 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path) Err bitreich.org 70 i count = git_tree_entrycount(tree); Err bitreich.org 70 i for (i = 0; i < count; i++) { Err bitreich.org 70 i if (!(entry = git_tree_entry_byindex(tree, i)) || Err bitreich.org 70 i- git_tree_entry_to_object(&obj, repo, entry)) Err bitreich.org 70 i+ !(entryname = git_tree_entry_name(entry))) Err bitreich.org 70 i return -1; Err bitreich.org 70 i- entryname = git_tree_entry_name(entry); Err bitreich.org 70 i r = snprintf(entrypath, sizeof(entrypath), "%s%s%s", Err bitreich.org 70 i path, path[0] ? "/" : "", entryname); Err bitreich.org 70 i if (r == -1 || (size_t)r >= sizeof(entrypath)) Err bitreich.org 70 i errx(1, "path truncated: '%s%s%s'", Err bitreich.org 70 i path, path[0] ? "/" : "", entryname); Err bitreich.org 70 i- switch (git_object_type(obj)) { Err bitreich.org 70 i- case GIT_OBJ_BLOB: Err bitreich.org 70 i- break; Err bitreich.org 70 i- case GIT_OBJ_TREE: Err bitreich.org 70 i- /* NOTE: recurses */ Err bitreich.org 70 i- ret = writefilestree(fp, (git_tree *)obj, branch, Err bitreich.org 70 i- entrypath); Err bitreich.org 70 i- git_object_free(obj); Err bitreich.org 70 i- if (ret) Err bitreich.org 70 i- return ret; Err bitreich.org 70 i- continue; Err bitreich.org 70 i- default: Err bitreich.org 70 i- git_object_free(obj); Err bitreich.org 70 i- continue; Err bitreich.org 70 i- } Err bitreich.org 70 i Err bitreich.org 70 i r = snprintf(filepath, sizeof(filepath), "file/%s%s%s.html", Err bitreich.org 70 i path, path[0] ? "/" : "", entryname); Err bitreich.org 70 i@@ -693,20 +678,46 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path) Err bitreich.org 70 i errx(1, "path truncated: 'file/%s%s%s.html'", Err bitreich.org 70 i path, path[0] ? "/" : "", entryname); Err bitreich.org 70 i Err bitreich.org 70 i- filesize = git_blob_rawsize((git_blob *)obj); Err bitreich.org 70 i+ if (!git_tree_entry_to_object(&obj, repo, entry)) { Err bitreich.org 70 i+ switch (git_object_type(obj)) { Err bitreich.org 70 i+ case GIT_OBJ_BLOB: Err bitreich.org 70 i+ break; Err bitreich.org 70 i+ case GIT_OBJ_TREE: Err bitreich.org 70 i+ /* NOTE: recurses */ Err bitreich.org 70 i+ ret = writefilestree(fp, (git_tree *)obj, branch, Err bitreich.org 70 i+ entrypath); Err bitreich.org 70 i+ git_object_free(obj); Err bitreich.org 70 i+ if (ret) Err bitreich.org 70 i+ return ret; Err bitreich.org 70 i+ continue; Err bitreich.org 70 i+ default: Err bitreich.org 70 i+ git_object_free(obj); Err bitreich.org 70 i+ continue; Err bitreich.org 70 i+ } Err bitreich.org 70 i Err bitreich.org 70 i- lc = writeblob(obj, filepath, entryname, filesize); Err bitreich.org 70 i+ filesize = git_blob_rawsize((git_blob *)obj); Err bitreich.org 70 i+ lc = writeblob(obj, filepath, entryname, filesize); Err bitreich.org 70 i Err bitreich.org 70 i- fputs("", fp); Err bitreich.org 70 i- fputs(filemode(git_tree_entry_filemode(entry)), fp); Err bitreich.org 70 i- fprintf(fp, "", relpath, filepath); Err bitreich.org 70 i- xmlencode(fp, entrypath, strlen(entrypath)); Err bitreich.org 70 i- fputs("", fp); Err bitreich.org 70 i- if (showlinecount && lc > 0) Err bitreich.org 70 i- fprintf(fp, "%dL", lc); Err bitreich.org 70 i- else Err bitreich.org 70 i- fprintf(fp, "%juB", (uintmax_t)filesize); Err bitreich.org 70 i- fputs("\n", fp); Err bitreich.org 70 i+ fputs("", fp); Err bitreich.org 70 i+ fputs(filemode(git_tree_entry_filemode(entry)), fp); Err bitreich.org 70 i+ fprintf(fp, "", relpath, filepath); Err bitreich.org 70 i+ xmlencode(fp, entrypath, strlen(entrypath)); Err bitreich.org 70 i+ fputs("", fp); Err bitreich.org 70 i+ if (showlinecount && lc > 0) Err bitreich.org 70 i+ fprintf(fp, "%dL", lc); Err bitreich.org 70 i+ else Err bitreich.org 70 i+ fprintf(fp, "%juB", (uintmax_t)filesize); Err bitreich.org 70 i+ fputs("\n", fp); Err bitreich.org 70 i+ } else if (git_submodule_lookup(&module, repo, entryname) == 0) { Err bitreich.org 70 i+ Err bitreich.org 70 i+ fprintf(fp, "@", Err bitreich.org 70 i+ git_submodule_url(module)); Err bitreich.org 70 i+ xmlencode(fp, entrypath, strlen(entrypath)); Err bitreich.org 70 i+ fprintf(fp, "0%c", Err bitreich.org 70 i+ showlinecount ? 'L' : 'B'); Err bitreich.org 70 i+ git_submodule_free(module); Err bitreich.org 70 i+ fputs("\n", fp); Err bitreich.org 70 i+ } Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i return 0; Err bitreich.org 70 1diff --git a/style.css b/style.css /scm/stagit-gopher/file/style.css.gph bitreich.org 70 i@@ -58,6 +58,10 @@ table td { Err bitreich.org 70 i white-space: normal; Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i+a.module { Err bitreich.org 70 i+ color: #777; Err bitreich.org 70 i+} Err bitreich.org 70 i+ Err bitreich.org 70 i td.num { Err bitreich.org 70 i text-align: right; Err bitreich.org 70 i } Err bitreich.org 70 .