Subject: Feature Request: show ages in tree view
Date: Sun, 30 Oct 2016 13:22:24 +0100 [thread overview]
Message-ID: <20161030132224.9B9784EB@net.hr> (raw)
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");
next reply other threads:[~2016-10-30 12:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-30 12:22 [this message]
2016-11-24 18:56 ` john
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161030132224.9B9784EB@net.hr \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).