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("<tr><td class='ls-mode'>");
        cgit_print_filemode(mode);
        html("</td><td>");
@@ -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("</td><td style='text-align:right'>");
+               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("</td><td style='text-align:right'>");
+               cgit_print_age(info->committer_date, info->committer_tz, 
TM_WEEK * 2);
        }
        htmlf("</td><td class='ls-size'>%li</td>", size);
 
@@ -289,6 +301,7 @@ static void ls_head(void)
        html("<tr class='nohover'>");
        html("<th class='left'>Mode</th>");
        html("<th class='left'>Name</th>");
+       html("<th class='right'>Age</th>");
        html("<th class='right'>Size</th>");
        html("<th/>");
        html("</tr>\n");
_______________________________________________
CGit mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to