diff options
| author | Patrick | 2025-12-30 20:15:05 +0100 |
|---|---|---|
| committer | Patrick | 2025-12-30 20:15:05 +0100 |
| commit | dabc7e8ded98204a5157c4404510c8e84eeeacb3 (patch) | |
| tree | 6faab5ff889015af42ca9774f26977643bded01e | |
| parent | 2db3968e88c001ab05f747d7cf6e66787c19a352 (diff) | |
| download | ps-cgit-dabc7e8ded98204a5157c4404510c8e84eeeacb3.tar.gz ps-cgit-dabc7e8ded98204a5157c4404510c8e84eeeacb3.zip | |
remove unused functinos
| -rw-r--r-- | ui-summary.c | 75 |
1 files changed, 8 insertions, 67 deletions
diff --git a/ui-summary.c b/ui-summary.c index bf75039..7a11cb1 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -149,79 +149,20 @@ done: cgit_print_layout_end(); } -// int read_tree_recursive(struct repository *r, -// struct tree *tree, -// const char *base, int baselen, -// int stage, const struct pathspec *pathspec, -// read_tree_fn_t fn, void *context); -struct get_readme_oid_ctx { - struct object_id *oid; - char **filename; - const char *path; - bool found; -}; -static int get_readme_oid_cb(const struct object_id *oid, struct strbuf *base, - const char *pathname, unsigned mode, int stage, void *cbdata) { - - struct get_readme_oid_ctx *ctx = (struct get_readme_oid_ctx*)cbdata; - - // TODO: make readme.md configurable - const char *readme_name = "readme.md"; - - struct strbuf buffer = STRBUF_INIT; - if (base->len > 0) - strbuf_addbuf(&buffer, base); - - bool match_base = false; - if (ctx->path == NULL) - match_base = base->len == 0; - else if (strncmp(buffer.buf, ctx->path, buffer.len > 0 ? buffer.len - 1 : 0) == 0) - match_base = true; - - strbuf_addstr(&buffer, pathname); - - bool match_path = false; - if (ctx->path == NULL) - match_path = false; - else if (strcmp(buffer.buf, ctx->path) == 0) - match_path = true; - - strbuf_release(&buffer); - - if (match_base && strcmp(pathname, readme_name) == 0) { - *(ctx->oid) = *oid; - *(ctx->filename) = xstrdup(pathname); - ctx->found = true; - } - else if (match_path) { - return READ_TREE_RECURSIVE; - } - - return 0; -} -bool get_readme_oid(const struct tree *tree, struct pathspec *paths, struct object_id *oid, char **filename) { - struct get_readme_oid_ctx gro_ctx = (struct get_readme_oid_ctx){ - .oid = oid, - .filename = filename, - .path = (paths->nr == 1 ? paths->items[0].match : NULL), - .found = false }; - read_tree_recursive(the_repository, tree, "", 0, 0, - paths, get_readme_oid_cb, &gro_ctx); - return gro_ctx.found; -} - void cgit_print_repo_readme_no_layout(const struct tree *tree, struct pathspec *paths) { - char *filename = NULL; - struct object_id readme_oid; - if (get_readme_oid(tree, paths, &readme_oid, &filename)) { + if (ctx.repo->readme.nr) { + const char *filename = ctx.repo->readme.items[0].string; + html("<div id='summary'>"); + cgit_open_filter(ctx.repo->about_filter, filename); - cgit_print_oid(&readme_oid); + + char *ref = ctx.repo->readme.items[0].util; + cgit_print_file(filename, ref, 1); + cgit_close_filter(ctx.repo->about_filter); html("</div>"); - - free(filename); } } |
