neocgit

a more 'modern' version of cgit
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/neocgit

commit f47c28be72a1deaf5fe3e5eca8f315a539fcc191
parent 4675c4396345c0177d73c8927b2290fa4577ff8b
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon,  2 Jul 2018 09:06:23 +0200

NEW: Sort on tree listing, and work on commit caches

Signed-off-by: Ne02ptzero <louis@ne02ptzero.me>

Diffstat:
Mparsing.c | 2+-
Mui-log.c | 6++----
Mui-shared.c | 4++--
Mui-summary.c | 2+-
Mui-tree.c | 39++++++++++++++++++++++++++++++++-------
5 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/parsing.c b/parsing.c @@ -130,7 +130,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) { const int sha1hex_len = 40; struct commitinfo *ret; - const char *p = get_cached_commit_buffer(commit, NULL); + const char *p = get_commit_buffer(commit, NULL); const char *t; ret = xcalloc(1, sizeof(struct commitinfo)); diff --git a/ui-log.c b/ui-log.c @@ -380,7 +380,6 @@ struct commit *cgit_get_last_commit_from_path(const char *path) int must_free_tip = 0; const char *tip; - tip = ctx.qry.head; argv_array_push(&rev_argv, "log_rev_setup"); tip = disambiguate_ref(tip, &must_free_tip); @@ -389,15 +388,14 @@ struct commit *cgit_get_last_commit_from_path(const char *path) argv_array_push(&rev_argv, path); init_revisions(&rev, NULL); + setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL); load_ref_decorations(NULL, DECORATE_FULL_REFS); + rev.max_count = 1; prepare_revision_walk(&rev); commit = get_revision(&rev); - while (get_revision(&rev)) - ; - object_array_clear(&rev.pending); reset_revision_walk(); diff --git a/ui-shared.c b/ui-shared.c @@ -1022,9 +1022,9 @@ void cgit_print_pageheader(void) if (ctx.env.authenticated && ctx.repo) { _html("<div class='summary-header'>") { if (ctx.repo->logo != NULL) - htmlf("<img src='/%s' />", ctx.repo->logo); + htmlf("<img src='%s' />", ctx.repo->logo); else - htmlf("<img src='/%s' />", ctx.cfg.logo); + htmlf("<img src='%s' />", ctx.cfg.logo); html("<br />"); htmlf("<h3>%s</h3>", ctx.repo->name); htmlf("<span>%s</span>", ctx.repo->desc); diff --git a/ui-summary.c b/ui-summary.c @@ -54,7 +54,7 @@ void cgit_print_summary(void) cgit_print_tree(ctx.qry.sha1, ctx.qry.path, false); /*cgit_print_repo_readme(ctx.qry.path, false);*/ - /*cgit_print_layout_end();*/ + cgit_print_layout_end(); } /* The caller must free the return value. */ diff --git a/ui-tree.c b/ui-tree.c @@ -19,6 +19,7 @@ struct tree_link { unsigned mode; int stage; struct tree_link *next; + struct tree_link *prev; }; struct walk_tree_context { @@ -233,7 +234,9 @@ static void print_tree_item(struct tree_link *ptr, struct walk_tree_context *tre _html("<td class='table-left'>") { if (info) + { htmlf("%s", info->subject); + } else html("[ERROR]"); } _html("</td>"); @@ -250,7 +253,10 @@ static void print_tree_item(struct tree_link *ptr, struct walk_tree_context *tre } _html("</tr>"); if (commit) + { free_commit_buffer(commit); + free(info); + } } static int ls_item(const struct object_id *oid, struct strbuf *base, @@ -259,9 +265,6 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, struct tree_link *obj; struct walk_tree_context *walk_tree_ctx = cbdata; - if (pathname[0] == '.') - return 0; - obj = calloc(1, sizeof(*obj)); obj->oid = oid; obj->base = base; @@ -274,10 +277,33 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, else { struct tree_link *tmp; + for (tmp = walk_tree_ctx->head; tmp->next != NULL; tmp = tmp->next) - ; + { + if (strcmp(tmp->pathname, pathname) > 0 + || (S_ISDIR(mode) && !S_ISDIR(tmp->mode))) + { + break ; + } + } - tmp->next = obj; + if (tmp->next == NULL) + { + obj->prev = tmp; + tmp->next = obj; + } + else if (tmp->prev == NULL) + { + tmp->prev = obj; + obj->next = tmp; + walk_tree_ctx->head = obj; + } + else + { + tmp->prev->next = obj; + obj->next = tmp; + obj->next->prev = obj; + } } /* char *name;*/ /*struct strbuf fullpath = STRBUF_INIT;*/ @@ -404,8 +430,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co walk_tree_ctx->head = NULL; read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx); free_tree_buffer(tree); - reset_revision_walk(); - update_main_cache_tree(0); + for (struct tree_link *tmp = walk_tree_ctx->head; tmp; tmp = tmp->next) { print_tree_item(tmp, walk_tree_ctx);