From mboxrd@z Thu Jan 1 00:00:00 1970 From: sillyslux at net.hr (=?utf-8?q?Silly_Slux?=) Date: Sun, 30 Oct 2016 13:22:24 +0100 Subject: =?utf-8?q?Feature_Request=3A_show_ages_in_tree_view?= Message-ID: <20161030132224.9B9784EB@net.hr> Hello, i want to see when a file or tree was last changed when i'm watching the tree of a repository. I've tried to implement it myself, but it seems i can't, though i have something to illustrate what i mean. diff --git a/ui-tree.c b/ui-tree.c index b310242..78e5676 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -232,6 +232,10 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, enum object_type type; unsigned long size = 0; + struct commitinfo *info; + struct commit *commit; + unsigned char c_sha1[20]; + name = xstrdup(pathname); strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "", ctx.qry.path ? "/" : "", name); @@ -247,6 +251,10 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, } } + get_sha1(walk_tree_ctx->curr_rev, c_sha1); + commit = lookup_commit_reference(c_sha1); + info = cgit_parse_commit(commit); + html(""); cgit_print_filemode(mode); html(""); @@ -255,6 +263,8 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, } else if (S_ISDIR(mode)) { write_tree_link(sha1, name, walk_tree_ctx->curr_rev, &fullpath); + html(""); + cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); } else { char *ext = strrchr(name, '.'); strbuf_addstr(&class, "ls-blob"); @@ -262,6 +272,8 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, strbuf_addf(&class, " %s", ext + 1); cgit_tree_link(name, NULL, class.buf, ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); + html(""); + cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); } htmlf("%li", size); @@ -289,6 +301,7 @@ static void ls_head(void) html(""); html("Mode"); html("Name"); + html("Age"); html("Size"); html(""); html("\n");