summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-06-17 12:53:02 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-17 12:53:02 (UTC)
commit42a7eb9c73457319a3fd5441ff26046fc9b31dad (patch) (unidiff)
tree4771b955e031005e7c222ef0cbabb719f7cd003a
parent48c487d72daef7e71683a85f775db8d36ab20341 (diff)
downloadcgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.zip
cgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.tar.gz
cgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.tar.bz2
Add cgit_commit_link() + support for id=sha1 to commit view
This adds a function to generate links to the commit page and extends said page to use id from querystring as primary revision specified (fallback to h). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
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
@@ -102,3 +102,3 @@ static void cgit_print_repo_page(struct cacheitem *item)
102 case CMD_COMMIT: 102 case CMD_COMMIT:
103 cgit_print_commit(cgit_query_head); 103 cgit_print_commit(cgit_query_sha1);
104 break; 104 break;
diff --git a/cgit.h b/cgit.h
index b2f6361..c276a24 100644
--- a/cgit.h
+++ b/cgit.h
@@ -207,2 +207,4 @@ extern void cgit_log_link(char *name, char *title, char *class, char *head,
207 char *rev, char *path); 207 char *rev, char *path);
208extern void cgit_commit_link(char *name, char *title, char *class, char *head,
209 char *rev);
208 210
diff --git a/ui-commit.c b/ui-commit.c
index 885f870..8864fc6 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -158,2 +158,5 @@ void cgit_print_commit(const char *hex)
158 158
159 if (!hex)
160 hex = cgit_query_head;
161
159 if (get_sha1(hex, sha1)) { 162 if (get_sha1(hex, sha1)) {
diff --git a/ui-log.c b/ui-log.c
index bb17e1d..8d774b0 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -33,7 +33,4 @@ void print_commit(struct commit *commit)
33 html("</td><td>"); 33 html("</td><td>");
34 char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1)); 34 cgit_commit_link(info->subject, NULL, NULL, cgit_query_head,
35 char *url = cgit_pageurl(cgit_query_repo, "commit", qry); 35 sha1_to_hex(commit->object.sha1));
36 html_link_open(url, NULL, NULL);
37 html_ntxt(cgit_max_msg_len, info->subject);
38 html_link_close();
39 if (cgit_repo->enable_log_filecount) { 36 if (cgit_repo->enable_log_filecount) {
diff --git a/ui-shared.c b/ui-shared.c
index 64ee79c..71c899a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -138,4 +138,4 @@ static char *repolink(char *title, char *class, char *page, char *head,
138 138
139static char *reporevlink(char *page, char *name, char *title, char *class, 139static void reporevlink(char *page, char *name, char *title, char *class,
140 char *head, char *rev, char *path) 140 char *head, char *rev, char *path)
141{ 141{
@@ -166,2 +166,14 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
166 166
167void cgit_commit_link(char *name, char *title, char *class, char *head,
168 char *rev)
169{
170 if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
171 name[cgit_max_msg_len] = '\0';
172 name[cgit_max_msg_len - 1] = '.';
173 name[cgit_max_msg_len - 2] = '.';
174 name[cgit_max_msg_len - 3] = '.';
175 }
176 reporevlink("commit", name, title, class, head, rev, NULL);
177}
178
167void cgit_print_date(time_t secs, char *format) 179void cgit_print_date(time_t secs, char *format)
diff --git a/ui-summary.c b/ui-summary.c
index 29b76e3..03dd078 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -17,4 +17,6 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
17 struct commitinfo *info; 17 struct commitinfo *info;
18 char buf[256], *url; 18 char buf[256];
19 char *ref;
19 20
21 ref = xstrdup(refname);
20 strncpy(buf, refname, sizeof(buf)); 22 strncpy(buf, refname, sizeof(buf));
@@ -27,3 +29,3 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
27 html("<tr><td>"); 29 html("<tr><td>");
28 cgit_log_link(refname, NULL, NULL, refname, NULL, NULL); 30 cgit_log_link(ref, NULL, NULL, ref, NULL, NULL);
29 html("</td><td>"); 31 html("</td><td>");
@@ -33,7 +35,3 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
33 html("</td><td>"); 35 html("</td><td>");
34 url = cgit_pageurl(cgit_query_repo, "commit", 36 cgit_commit_link(info->subject, NULL, NULL, ref, NULL);
35 fmt("h=%s", sha1_to_hex(sha1)));
36 html_link_open(url, NULL, NULL);
37 html_ntxt(cgit_max_msg_len, info->subject);
38 html_link_close();
39 html("</td></tr>\n"); 37 html("</td></tr>\n");
@@ -47,2 +45,3 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
47 } 45 }
46 free(ref);
48 return 0; 47 return 0;
@@ -56,4 +55,5 @@ static void cgit_print_object_ref(struct object *obj)
56 if (obj->type == OBJ_COMMIT) { 55 if (obj->type == OBJ_COMMIT) {
57 page = "commit"; 56 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
58 arg = "h"; 57 cgit_query_head, sha1_to_hex(obj->sha1));
58 return;
59 } else if (obj->type == OBJ_TREE) { 59 } else if (obj->type == OBJ_TREE) {
diff --git a/ui-tree.c b/ui-tree.c
index e16b638..1037c82 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -60,3 +60,2 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
60 unsigned long size = 0; 60 unsigned long size = 0;
61 char *url, *qry;
62 61