summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--cgit.c2
-rw-r--r--cgit.css50
-rw-r--r--cgit.h5
-rw-r--r--parsing.c1
-rw-r--r--ui-commit.c80
-rw-r--r--ui-log.c11
-rw-r--r--ui-tree.c6
-rw-r--r--ui-view.c2
9 files changed, 140 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 2a4d62a..58a583b 100644
--- a/Makefile
+++ b/Makefile
@@ -8,3 +8,3 @@ EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto
OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
- ui-summary.o ui-log.o ui-view.c ui-tree.c
+ ui-summary.o ui-log.o ui-view.c ui-tree.c ui-commit.c
diff --git a/cgit.c b/cgit.c
index d7e586d..37cdb83 100644
--- a/cgit.c
+++ b/cgit.c
@@ -34,2 +34,4 @@ static void cgit_print_repo_page(struct cacheitem *item)
cgit_print_tree(cgit_query_sha1);
+ } else if (!strcmp(cgit_query_page, "commit")) {
+ cgit_print_commit(cgit_query_sha1);
} else if (!strcmp(cgit_query_page, "view")) {
diff --git a/cgit.css b/cgit.css
index 97b4e27..3579598 100644
--- a/cgit.css
+++ b/cgit.css
@@ -23,3 +23,2 @@ table.list {
table.list th {
- text-align: left;
font-weight: bold;
@@ -27,3 +26,3 @@ table.list th {
border-bottom: solid 1px #aaa;
- padding: 0.1em 0.5em 0.1em;
+ padding: 0.1em 0.5em 0.1em 0.5em;
vertical-align: baseline;
@@ -32,3 +31,3 @@ table.list td {
border: none;
- padding: 0.1em 1em 0.1em 0.5em;
+ padding: 0.1em 0.5em 0.1em 0.5em;
background: white;
@@ -58,2 +57,6 @@ div#content {
+div#blob {
+ border: solid 1px black;
+}
+
div.error {
@@ -77,2 +80,41 @@ td.blob {
font-size: 100%;
-} \ No newline at end of file
+}
+
+table.log td {
+ white-space: nowrap;
+}
+
+table.commit-info {
+ border-collapse: collapse;
+ margin-top: 1em;
+
+}
+table.commit-info th {
+ text-align: left;
+ font-weight: normal;
+ padding: 0.1em 1em 0.1em 0.1em;
+}
+table.commit-info td {
+ font-weight: normal;
+ padding: 0.1em 1em 0.1em 0.1em;
+}
+div.commit-subject {
+ font-weight: bold;
+ font-size: 110%;
+ margin: 1em 0em 1em;
+}
+div.commit-msg {
+ white-space: pre;
+ font-family: courier;
+ font-size: 100%;
+}
+.sha1 {
+ font-family: courier;
+ font-size: 90%;
+}
+.left {
+ text-align: left;
+}
+.right {
+ text-align: right;
+}
diff --git a/cgit.h b/cgit.h
index 268db53..a905e47 100644
--- a/cgit.h
+++ b/cgit.h
@@ -94,4 +94,5 @@ extern void cgit_print_summary();
extern void cgit_print_log(const char *tip, int ofs, int cnt);
-extern void cgit_print_view(char *hex);
-extern void cgit_print_tree(const char *sha1);
+extern void cgit_print_view(const char *hex);
+extern void cgit_print_tree(const char *hex);
+extern void cgit_print_commit(const char *hex);
diff --git a/parsing.c b/parsing.c
index 6cab0e9..be471b5 100644
--- a/parsing.c
+++ b/parsing.c
@@ -152,2 +152,3 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
ret->subject = substr(p, t);
+ p = t + 1;
diff --git a/ui-commit.c b/ui-commit.c
new file mode 100644
index 0000000..1c0e7e5
--- a/dev/null
+++ b/ui-commit.c
@@ -0,0 +1,80 @@
+#include "cgit.h"
+
+void cgit_print_date(unsigned long secs)
+{
+ char buf[32];
+ struct tm *time;
+
+ time = gmtime(&secs);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
+ html_txt(buf);
+
+}
+
+void cgit_print_commit(const char *hex)
+{
+ struct commit *commit;
+ struct commitinfo *info;
+ struct commit_list *p;
+ unsigned long size;
+ char type[20];
+ char *buf;
+
+ unsigned char sha1[20];
+
+ if (get_sha1(hex, sha1)) {
+ cgit_print_error(fmt("Bad object id: %s", hex));
+ return;
+ }
+
+ buf = read_sha1_file(sha1, type, &size);
+ if (!buf) {
+ cgit_print_error(fmt("Bad object reference: %s", hex));
+ return;
+ }
+
+ commit = lookup_commit(sha1);
+ if (!commit) {
+ cgit_print_error(fmt("Bad commit reference: %s", hex));
+ return;
+ }
+
+ commit->buffer = buf;
+ if (parse_commit_buffer(commit, buf, size)) {
+ cgit_print_error(fmt("Malformed commit buffer: %s", hex));
+ return;
+ }
+
+ info = cgit_parse_commit(commit);
+
+ html("<table class='commit-info'>\n");
+ html("<tr><th>author</th><td colspan='2'>");
+ html_txt(info->author);
+ html("</td></tr>\n");
+ html("<tr><th>committer</th><td>");
+ html_txt(info->committer);
+ html("</td><td class='right'>");
+ cgit_print_date(commit->date);
+ html("</td></tr>\n");
+ html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='");
+ html_attr(cgit_pageurl(cgit_query_repo, "tree", fmt("id=%s", sha1_to_hex(commit->tree->object.sha1))));
+ htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1));
+
+ for (p = commit->parents; p ; p = p->next) {
+ html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='");
+ html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1))));
+ htmlf("'>%s</a></td></tr>\n",
+ sha1_to_hex(p->item->object.sha1));
+ }
+ html("</table>\n");
+ html("<div class='commit-subject'>");
+ html_txt(info->subject);
+ html("</div>");
+ html("<div class='commit-msg'>");
+ html_txt(info->msg);
+ html("</div>");
+ free(info->author);
+ free(info->committer);
+ free(info->subject);
+ free(info);
+}
diff --git a/ui-log.c b/ui-log.c
index 31331ef..c52af79 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -23,3 +23,3 @@ void print_commit(struct commit *commit)
char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
- char *url = cgit_pageurl(cgit_query_repo, "view", qry);
+ char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
html_link_open(url, NULL, NULL);
@@ -29,7 +29,2 @@ void print_commit(struct commit *commit)
html_txt(info->author);
- html("</td><td><a href='");
- html_attr(cgit_pageurl(cgit_query_repo, "tree",
- fmt("id=%s",
- sha1_to_hex(commit->tree->object.sha1))));
- html("'>tree</a>");
html("</td></tr>\n");
@@ -58,4 +53,4 @@ void cgit_print_log(const char *tip, int ofs, int cnt)
html("<h2>Log</h2>");
- html("<table class='list'>");
- html("<tr><th>Date</th><th>Message</th><th>Author</th><th>Link</th></tr>\n");
+ html("<table class='list log'>");
+ html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n");
diff --git a/ui-tree.c b/ui-tree.c
index 84930cb..c4d75ab 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -64,5 +64,5 @@ void cgit_print_tree(const char *hex)
html("<table class='list'>\n");
- html("<tr><th>Name</th>");
- html("<th class='filesize'>Size</th>");
- html("<th class='filemode'>Mode</th></tr>\n");
+ html("<tr><th class='left'>Name</th>");
+ html("<th class='right'>Size</th>");
+ html("<th class='right'>Mode</th></tr>\n");
read_tree_recursive(tree, "", 0, 1, NULL, print_entry);
diff --git a/ui-view.c b/ui-view.c
index 9d13be1..b75ce9a 100644
--- a/ui-view.c
+++ b/ui-view.c
@@ -10,3 +10,3 @@
-void cgit_print_view(char *hex)
+void cgit_print_view(const char *hex)
{