summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h2
-rw-r--r--ui-commit.c3
-rw-r--r--ui-log.c7
-rw-r--r--ui-shared.c16
-rw-r--r--ui-summary.c18
-rw-r--r--ui-tree.c1
7 files changed, 31 insertions, 18 deletions
diff --git a/cgit.c b/cgit.c
index 1c213c7..f5135d9 100644
--- a/cgit.c
+++ b/cgit.c
@@ -97,13 +97,13 @@ static void cgit_print_repo_page(struct cacheitem *item)
cgit_query_path, 1);
break;
case CMD_TREE:
cgit_print_tree(cgit_query_sha1, cgit_query_path);
break;
case CMD_COMMIT:
- cgit_print_commit(cgit_query_head);
+ cgit_print_commit(cgit_query_sha1);
break;
case CMD_DIFF:
cgit_print_diff(cgit_query_head, cgit_query_sha1, cgit_query_sha2,
cgit_query_path);
break;
default:
diff --git a/cgit.h b/cgit.h
index b2f6361..c276a24 100644
--- a/cgit.h
+++ b/cgit.h
@@ -202,12 +202,14 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query);
extern void cgit_tree_link(char *name, char *title, char *class, char *head,
char *rev, char *path);
extern void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path);
+extern void cgit_commit_link(char *name, char *title, char *class, char *head,
+ char *rev);
extern void cgit_print_error(char *msg);
extern void cgit_print_date(time_t secs, char *format);
extern void cgit_print_age(time_t t, time_t max_relative, char *format);
extern void cgit_print_docstart(char *title, struct cacheitem *item);
extern void cgit_print_docend();
diff --git a/ui-commit.c b/ui-commit.c
index 885f870..8864fc6 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -153,12 +153,15 @@ void cgit_print_commit(const char *hex)
unsigned char sha1[20];
char *query;
char *filename;
char *tmp;
int i;
+ if (!hex)
+ hex = cgit_query_head;
+
if (get_sha1(hex, sha1)) {
cgit_print_error(fmt("Bad object id: %s", hex));
return;
}
commit = lookup_commit_reference(sha1);
if (!commit) {
diff --git a/ui-log.c b/ui-log.c
index bb17e1d..8d774b0 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -28,17 +28,14 @@ void print_commit(struct commit *commit)
struct commitinfo *info;
info = cgit_parse_commit(commit);
html("<tr><td>");
cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
html("</td><td>");
- char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1));
- char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
- html_link_open(url, NULL, NULL);
- html_ntxt(cgit_max_msg_len, info->subject);
- html_link_close();
+ cgit_commit_link(info->subject, NULL, NULL, cgit_query_head,
+ sha1_to_hex(commit->object.sha1));
if (cgit_repo->enable_log_filecount) {
files = 0;
lines = 0;
cgit_diff_commit(commit, inspect_files);
html("</td><td class='right'>");
htmlf("%d", files);
diff --git a/ui-shared.c b/ui-shared.c
index 64ee79c..71c899a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -133,14 +133,14 @@ static char *repolink(char *title, char *class, char *page, char *head,
html_attr(head);
delim = "&amp;";
}
return fmt("%s", delim);
}
-static char *reporevlink(char *page, char *name, char *title, char *class,
- char *head, char *rev, char *path)
+static void reporevlink(char *page, char *name, char *title, char *class,
+ char *head, char *rev, char *path)
{
char *delim;
delim = repolink(title, class, page, head, path);
if (rev && strcmp(rev, cgit_query_head)) {
html(delim);
@@ -161,12 +161,24 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path)
{
reporevlink("log", name, title, class, head, rev, path);
}
+void cgit_commit_link(char *name, char *title, char *class, char *head,
+ char *rev)
+{
+ if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
+ name[cgit_max_msg_len] = '\0';
+ name[cgit_max_msg_len - 1] = '.';
+ name[cgit_max_msg_len - 2] = '.';
+ name[cgit_max_msg_len - 3] = '.';
+ }
+ reporevlink("commit", name, title, class, head, rev, NULL);
+}
+
void cgit_print_date(time_t secs, char *format)
{
char buf[64];
struct tm *time;
time = gmtime(&secs);
diff --git a/ui-summary.c b/ui-summary.c
index 29b76e3..03dd078 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -12,53 +12,53 @@ static int header;
static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
{
struct commit *commit;
struct commitinfo *info;
- char buf[256], *url;
+ char buf[256];
+ char *ref;
+ ref = xstrdup(refname);
strncpy(buf, refname, sizeof(buf));
commit = lookup_commit(sha1);
// object is not really parsed at this point, because of some fallout
// from previous calls to git functions in cgit_print_log()
commit->object.parsed = 0;
if (commit && !parse_commit(commit)){
info = cgit_parse_commit(commit);
html("<tr><td>");
- cgit_log_link(refname, NULL, NULL, refname, NULL, NULL);
+ cgit_log_link(ref, NULL, NULL, ref, NULL, NULL);
html("</td><td>");
cgit_print_age(commit->date, -1, NULL);
html("</td><td>");
html_txt(info->author);
html("</td><td>");
- url = cgit_pageurl(cgit_query_repo, "commit",
- fmt("h=%s", sha1_to_hex(sha1)));
- html_link_open(url, NULL, NULL);
- html_ntxt(cgit_max_msg_len, info->subject);
- html_link_close();
+ cgit_commit_link(info->subject, NULL, NULL, ref, NULL);
html("</td></tr>\n");
cgit_free_commitinfo(info);
} else {
html("<tr><td>");
html_txt(buf);
html("</td><td colspan='3'>");
htmlf("*** bad ref %s ***", sha1_to_hex(sha1));
html("</td></tr>\n");
}
+ free(ref);
return 0;
}
static void cgit_print_object_ref(struct object *obj)
{
char *page, *arg, *url;
if (obj->type == OBJ_COMMIT) {
- page = "commit";
- arg = "h";
+ cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
+ cgit_query_head, sha1_to_hex(obj->sha1));
+ return;
} else if (obj->type == OBJ_TREE) {
page = "tree";
arg = "id";
} else {
page = "view";
arg = "id";
diff --git a/ui-tree.c b/ui-tree.c
index e16b638..1037c82 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -55,13 +55,12 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
const char *pathname, unsigned int mode, int stage)
{
char *name;
char *fullpath;
enum object_type type;
unsigned long size = 0;
- char *url, *qry;
name = xstrdup(pathname);
fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "",
cgit_query_path ? "/" : "", name);
type = sha1_object_info(sha1, &size);