summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.css18
-rw-r--r--cgit.h1
-rw-r--r--ui-commit.c15
3 files changed, 34 insertions, 0 deletions
diff --git a/cgit.css b/cgit.css
index 6e47eb3..3675697 100644
--- a/cgit.css
+++ b/cgit.css
@@ -281,96 +281,114 @@ table.bin-blob {
table.bin-blob th {
font-family: monospace;
white-space: pre;
border: solid 1px #777;
padding: 0.5em 1em;
}
table.bin-blob td {
font-family: monospace;
white-space: pre;
border-left: solid 1px #777;
padding: 0em 1em;
}
table.nowrap td {
white-space: nowrap;
}
table.commit-info {
border-collapse: collapse;
margin-top: 1.5em;
}
table.commit-info th {
text-align: left;
font-weight: normal;
padding: 0.1em 1em 0.1em 0.1em;
vertical-align: top;
}
table.commit-info td {
font-weight: normal;
padding: 0.1em 1em 0.1em 0.1em;
}
div.commit-subject {
font-weight: bold;
font-size: 125%;
margin: 1.5em 0em 0.5em 0em;
padding: 0em;
}
div.commit-msg {
white-space: pre;
font-family: monospace;
}
+div.notes-header {
+ font-weight: bold;
+ padding-top: 1.5em;
+}
+
+div.notes {
+ white-space: pre;
+ font-family: monospace;
+ border: solid 1px #ee9;
+ background-color: #ffd;
+ padding: 0.3em 2em 0.3em 1em;
+ float: left;
+}
+
+div.notes-footer {
+ clear: left;
+}
+
div.diffstat-header {
font-weight: bold;
padding-top: 1.5em;
}
table.diffstat {
border-collapse: collapse;
border: solid 1px #aaa;
background-color: #eee;
}
table.diffstat th {
font-weight: normal;
text-align: left;
text-decoration: underline;
padding: 0.1em 1em 0.1em 0.1em;
font-size: 100%;
}
table.diffstat td {
padding: 0.2em 0.2em 0.1em 0.1em;
font-size: 100%;
border: none;
}
table.diffstat td.mode {
white-space: nowrap;
}
table.diffstat td span.modechange {
padding-left: 1em;
color: red;
}
table.diffstat td.add a {
color: green;
}
table.diffstat td.del a {
color: red;
}
table.diffstat td.upd a {
color: blue;
}
table.diffstat td.graph {
width: 500px;
diff --git a/cgit.h b/cgit.h
index e9e2718..32d9d2b 100644
--- a/cgit.h
+++ b/cgit.h
@@ -1,69 +1,70 @@
#ifndef CGIT_H
#define CGIT_H
#include <git-compat-util.h>
#include <cache.h>
#include <grep.h>
#include <object.h>
#include <tree.h>
#include <commit.h>
#include <tag.h>
#include <diff.h>
#include <diffcore.h>
#include <refs.h>
#include <revision.h>
#include <log-tree.h>
#include <archive.h>
#include <string-list.h>
#include <xdiff-interface.h>
#include <xdiff/xdiff.h>
#include <utf8.h>
+#include <notes.h>
/*
* Dateformats used on misc. pages
*/
#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
#define FMT_SHORTDATE "%Y-%m-%d"
#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ"
/*
* Limits used for relative dates
*/
#define TM_MIN 60
#define TM_HOUR (TM_MIN * 60)
#define TM_DAY (TM_HOUR * 24)
#define TM_WEEK (TM_DAY * 7)
#define TM_YEAR (TM_DAY * 365)
#define TM_MONTH (TM_YEAR / 12.0)
/*
* Default encoding
*/
#define PAGE_ENCODING "UTF-8"
typedef void (*configfn)(const char *name, const char *value);
typedef void (*filepair_fn)(struct diff_filepair *pair);
typedef void (*linediff_fn)(char *line, int len);
struct cgit_filter {
char *cmd;
char **argv;
int old_stdout;
int pipe_fh[2];
int pid;
int exitstatus;
};
struct cgit_repo {
char *url;
char *name;
char *path;
char *desc;
char *owner;
char *defbranch;
char *module_link;
char *readme;
diff --git a/ui-commit.c b/ui-commit.c
index a11bc5f..45af450 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -1,131 +1,146 @@
/* ui-commit.c: generate commit view
*
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
#include "html.h"
#include "ui-shared.h"
#include "ui-diff.h"
#include "ui-log.h"
void cgit_print_commit(char *hex, const char *prefix)
{
struct commit *commit, *parent;
struct commitinfo *info, *parent_info;
struct commit_list *p;
+ struct strbuf notes = STRBUF_INIT;
unsigned char sha1[20];
char *tmp, *tmp2;
int parents = 0;
if (!hex)
hex = ctx.qry.head;
if (get_sha1(hex, sha1)) {
cgit_print_error(fmt("Bad object id: %s", hex));
return;
}
commit = lookup_commit_reference(sha1);
if (!commit) {
cgit_print_error(fmt("Bad commit reference: %s", hex));
return;
}
info = cgit_parse_commit(commit);
+ get_commit_notes(commit, &notes, PAGE_ENCODING, 0);
+
load_ref_decorations(DECORATE_FULL_REFS);
html("<table summary='commit info' class='commit-info'>\n");
html("<tr><th>author</th><td>");
html_txt(info->author);
if (!ctx.cfg.noplainemail) {
html(" ");
html_txt(info->author_email);
}
html("</td><td class='right'>");
cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>committer</th><td>");
html_txt(info->committer);
if (!ctx.cfg.noplainemail) {
html(" ");
html_txt(info->committer_email);
}
html("</td><td class='right'>");
cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>commit</th><td colspan='2' class='sha1'>");
tmp = sha1_to_hex(commit->object.sha1);
cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
html(" (");
cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
html(") (");
if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
else
cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
html(")</td></tr>\n");
html("<tr><th>tree</th><td colspan='2' class='sha1'>");
tmp = xstrdup(hex);
cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
ctx.qry.head, tmp, NULL);
if (prefix) {
html(" /");
cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
}
html("</td></tr>\n");
for (p = commit->parents; p ; p = p->next) {
parent = lookup_commit_reference(p->item->object.sha1);
if (!parent) {
html("<tr><td colspan='3'>");
cgit_print_error("Error reading parent commit");
html("</td></tr>");
continue;
}
html("<tr><th>parent</th>"
"<td colspan='2' class='sha1'>");
tmp = tmp2 = sha1_to_hex(p->item->object.sha1);
if (ctx.repo->enable_subject_links) {
parent_info = cgit_parse_commit(parent);
tmp2 = parent_info->subject;
}
cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
html(" (");
cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
sha1_to_hex(p->item->object.sha1), prefix, 0);
html(")</td></tr>");
parents++;
}
if (ctx.repo->snapshots) {
html("<tr><th>download</th><td colspan='2' class='sha1'>");
cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
hex, ctx.repo->snapshots);
html("</td></tr>");
}
html("</table>\n");
html("<div class='commit-subject'>");
if (ctx.repo->commit_filter)
cgit_open_filter(ctx.repo->commit_filter);
html_txt(info->subject);
if (ctx.repo->commit_filter)
cgit_close_filter(ctx.repo->commit_filter);
show_commit_decorations(commit);
html("</div>");
html("<div class='commit-msg'>");
if (ctx.repo->commit_filter)
cgit_open_filter(ctx.repo->commit_filter);
html_txt(info->msg);
if (ctx.repo->commit_filter)
cgit_close_filter(ctx.repo->commit_filter);
html("</div>");
+ if (notes.len != 0) {
+ html("<div class='notes-header'>Notes</div>");
+ html("<div class='notes'>");
+ if (ctx.repo->commit_filter)
+ cgit_open_filter(ctx.repo->commit_filter);
+ html_txt(notes.buf);
+ if (ctx.repo->commit_filter)
+ cgit_close_filter(ctx.repo->commit_filter);
+ html("</div>");
+ html("<div class='notes-footer'></div>");
+ }
if (parents < 3) {
if (parents)
tmp = sha1_to_hex(commit->parents->item->object.sha1);
else
tmp = NULL;
cgit_print_diff(ctx.qry.sha1, tmp, prefix);
}
+ strbuf_release(&notes);
cgit_free_commitinfo(info);
}