summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--cgit.c5
-rw-r--r--cgit.h2
-rw-r--r--shared.c2
-rw-r--r--ui-patch.c105
-rw-r--r--ui-shared.c8
6 files changed, 122 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 72c189c..eed59df 100644
--- a/Makefile
+++ b/Makefile
@@ -1,43 +1,43 @@
1CGIT_VERSION = v0.7.1 1CGIT_VERSION = v0.7.1
2CGIT_SCRIPT_NAME = cgit.cgi 2CGIT_SCRIPT_NAME = cgit.cgi
3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit 3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
4CGIT_CONFIG = /etc/cgitrc 4CGIT_CONFIG = /etc/cgitrc
5CACHE_ROOT = /var/cache/cgit 5CACHE_ROOT = /var/cache/cgit
6SHA1_HEADER = <openssl/sha.h> 6SHA1_HEADER = <openssl/sha.h>
7GIT_VER = 1.5.3.5 7GIT_VER = 1.5.3.5
8GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 8GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
9 9
10# 10#
11# Let the user override the above settings. 11# Let the user override the above settings.
12# 12#
13-include cgit.conf 13-include cgit.conf
14 14
15 15
16EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto 16EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
17OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ 17OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
18 ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ 18 ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \
19 ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o 19 ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o ui-patch.o
20 20
21 21
22ifdef NEEDS_LIBICONV 22ifdef NEEDS_LIBICONV
23 EXTLIBS += -liconv 23 EXTLIBS += -liconv
24endif 24endif
25 25
26 26
27.PHONY: all git test install clean distclean emptycache force-version get-git 27.PHONY: all git test install clean distclean emptycache force-version get-git
28 28
29all: cgit git 29all: cgit git
30 30
31VERSION: force-version 31VERSION: force-version
32 @./gen-version.sh "$(CGIT_VERSION)" 32 @./gen-version.sh "$(CGIT_VERSION)"
33-include VERSION 33-include VERSION
34 34
35 35
36CFLAGS += -g -Wall -Igit 36CFLAGS += -g -Wall -Igit
37CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' 37CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
38CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' 38CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
39CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' 39CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
40CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' 40CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
41CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' 41CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
42 42
43 43
diff --git a/cgit.c b/cgit.c
index 142e416..9ca93a7 100644
--- a/cgit.c
+++ b/cgit.c
@@ -54,48 +54,53 @@ static void cgit_print_repo_page(struct cacheitem *item)
54 cgit_query_head = cgit_repo->defbranch; 54 cgit_query_head = cgit_repo->defbranch;
55 55
56 if (chdir(cgit_repo->path)) { 56 if (chdir(cgit_repo->path)) {
57 title = fmt("%s - %s", cgit_root_title, "Bad request"); 57 title = fmt("%s - %s", cgit_root_title, "Bad request");
58 cgit_print_docstart(title, item); 58 cgit_print_docstart(title, item);
59 cgit_print_pageheader(title, 0); 59 cgit_print_pageheader(title, 0);
60 cgit_print_error(fmt("Unable to scan repository: %s", 60 cgit_print_error(fmt("Unable to scan repository: %s",
61 strerror(errno))); 61 strerror(errno)));
62 cgit_print_docend(); 62 cgit_print_docend();
63 return; 63 return;
64 } 64 }
65 65
66 title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); 66 title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc);
67 show_search = 0; 67 show_search = 0;
68 setenv("GIT_DIR", cgit_repo->path, 1); 68 setenv("GIT_DIR", cgit_repo->path, 1);
69 69
70 if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { 70 if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) {
71 cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1, 71 cgit_print_snapshot(item, cgit_query_head, cgit_query_sha1,
72 cgit_repobasename(cgit_repo->url), 72 cgit_repobasename(cgit_repo->url),
73 cgit_query_path, 73 cgit_query_path,
74 cgit_repo->snapshots ); 74 cgit_repo->snapshots );
75 return; 75 return;
76 } 76 }
77 77
78 if (cgit_cmd == CMD_PATCH) {
79 cgit_print_patch(cgit_query_sha1, item);
80 return;
81 }
82
78 if (cgit_cmd == CMD_BLOB) { 83 if (cgit_cmd == CMD_BLOB) {
79 cgit_print_blob(item, cgit_query_sha1, cgit_query_path); 84 cgit_print_blob(item, cgit_query_sha1, cgit_query_path);
80 return; 85 return;
81 } 86 }
82 87
83 show_search = (cgit_cmd == CMD_LOG); 88 show_search = (cgit_cmd == CMD_LOG);
84 cgit_print_docstart(title, item); 89 cgit_print_docstart(title, item);
85 if (!cgit_cmd) { 90 if (!cgit_cmd) {
86 cgit_print_pageheader("summary", show_search); 91 cgit_print_pageheader("summary", show_search);
87 cgit_print_summary(); 92 cgit_print_summary();
88 cgit_print_docend(); 93 cgit_print_docend();
89 return; 94 return;
90 } 95 }
91 96
92 cgit_print_pageheader(cgit_query_page, show_search); 97 cgit_print_pageheader(cgit_query_page, show_search);
93 98
94 switch(cgit_cmd) { 99 switch(cgit_cmd) {
95 case CMD_LOG: 100 case CMD_LOG:
96 cgit_print_log(cgit_query_sha1, cgit_query_ofs, 101 cgit_print_log(cgit_query_sha1, cgit_query_ofs,
97 cgit_max_commit_count, cgit_query_grep, cgit_query_search, 102 cgit_max_commit_count, cgit_query_grep, cgit_query_search,
98 cgit_query_path, 1); 103 cgit_query_path, 1);
99 break; 104 break;
100 case CMD_TREE: 105 case CMD_TREE:
101 cgit_print_tree(cgit_query_sha1, cgit_query_path); 106 cgit_print_tree(cgit_query_sha1, cgit_query_path);
diff --git a/cgit.h b/cgit.h
index f223dbc..66c40b9 100644
--- a/cgit.h
+++ b/cgit.h
@@ -9,48 +9,49 @@
9#include <tree.h> 9#include <tree.h>
10#include <commit.h> 10#include <commit.h>
11#include <tag.h> 11#include <tag.h>
12#include <diff.h> 12#include <diff.h>
13#include <diffcore.h> 13#include <diffcore.h>
14#include <refs.h> 14#include <refs.h>
15#include <revision.h> 15#include <revision.h>
16#include <log-tree.h> 16#include <log-tree.h>
17#include <archive.h> 17#include <archive.h>
18#include <xdiff/xdiff.h> 18#include <xdiff/xdiff.h>
19#include <utf8.h> 19#include <utf8.h>
20 20
21 21
22/* 22/*
23 * The valid cgit repo-commands 23 * The valid cgit repo-commands
24 */ 24 */
25#define CMD_LOG 1 25#define CMD_LOG 1
26#define CMD_COMMIT 2 26#define CMD_COMMIT 2
27#define CMD_DIFF 3 27#define CMD_DIFF 3
28#define CMD_TREE 4 28#define CMD_TREE 4
29#define CMD_BLOB 5 29#define CMD_BLOB 5
30#define CMD_SNAPSHOT 6 30#define CMD_SNAPSHOT 6
31#define CMD_TAG 7 31#define CMD_TAG 7
32#define CMD_REFS 8 32#define CMD_REFS 8
33#define CMD_PATCH 9
33 34
34/* 35/*
35 * Dateformats used on misc. pages 36 * Dateformats used on misc. pages
36 */ 37 */
37#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" 38#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
38#define FMT_SHORTDATE "%Y-%m-%d" 39#define FMT_SHORTDATE "%Y-%m-%d"
39 40
40 41
41/* 42/*
42 * Limits used for relative dates 43 * Limits used for relative dates
43 */ 44 */
44#define TM_MIN 60 45#define TM_MIN 60
45#define TM_HOUR (TM_MIN * 60) 46#define TM_HOUR (TM_MIN * 60)
46#define TM_DAY (TM_HOUR * 24) 47#define TM_DAY (TM_HOUR * 24)
47#define TM_WEEK (TM_DAY * 7) 48#define TM_WEEK (TM_DAY * 7)
48#define TM_YEAR (TM_DAY * 365) 49#define TM_YEAR (TM_DAY * 365)
49#define TM_MONTH (TM_YEAR / 12.0) 50#define TM_MONTH (TM_YEAR / 12.0)
50 51
51 52
52/* 53/*
53 * Default encoding 54 * Default encoding
54 */ 55 */
55#define PAGE_ENCODING "UTF-8" 56#define PAGE_ENCODING "UTF-8"
56 57
@@ -262,32 +263,33 @@ extern void cgit_diff_link(char *name, char *title, char *class, char *head,
262extern void cgit_object_link(struct object *obj); 263extern void cgit_object_link(struct object *obj);
263 264
264extern void cgit_print_error(char *msg); 265extern void cgit_print_error(char *msg);
265extern void cgit_print_date(time_t secs, char *format); 266extern void cgit_print_date(time_t secs, char *format);
266extern void cgit_print_age(time_t t, time_t max_relative, char *format); 267extern void cgit_print_age(time_t t, time_t max_relative, char *format);
267extern void cgit_print_docstart(char *title, struct cacheitem *item); 268extern void cgit_print_docstart(char *title, struct cacheitem *item);
268extern void cgit_print_docend(); 269extern void cgit_print_docend();
269extern void cgit_print_pageheader(char *title, int show_search); 270extern void cgit_print_pageheader(char *title, int show_search);
270extern void cgit_print_snapshot_start(const char *mimetype, 271extern void cgit_print_snapshot_start(const char *mimetype,
271 const char *filename, 272 const char *filename,
272 struct cacheitem *item); 273 struct cacheitem *item);
273extern void cgit_print_branches(int maxcount); 274extern void cgit_print_branches(int maxcount);
274extern void cgit_print_tags(int maxcount); 275extern void cgit_print_tags(int maxcount);
275 276
276extern void cgit_print_repolist(struct cacheitem *item); 277extern void cgit_print_repolist(struct cacheitem *item);
277extern void cgit_print_summary(); 278extern void cgit_print_summary();
278extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, 279extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
279 char *pattern, char *path, int pager); 280 char *pattern, char *path, int pager);
280extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); 281extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);
281extern void cgit_print_tree(const char *rev, char *path); 282extern void cgit_print_tree(const char *rev, char *path);
282extern void cgit_print_commit(char *hex); 283extern void cgit_print_commit(char *hex);
283extern void cgit_print_refs(); 284extern void cgit_print_refs();
284extern void cgit_print_tag(char *revname); 285extern void cgit_print_tag(char *revname);
285extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); 286extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix);
287extern void cgit_print_patch(char *hex, struct cacheitem *item);
286extern void cgit_print_snapshot(struct cacheitem *item, const char *head, 288extern void cgit_print_snapshot(struct cacheitem *item, const char *head,
287 const char *hex, const char *prefix, 289 const char *hex, const char *prefix,
288 const char *filename, int snapshot); 290 const char *filename, int snapshot);
289extern void cgit_print_snapshot_links(const char *repo, const char *head, 291extern void cgit_print_snapshot_links(const char *repo, const char *head,
290 const char *hex, int snapshots); 292 const char *hex, int snapshots);
291extern int cgit_parse_snapshots_mask(const char *str); 293extern int cgit_parse_snapshots_mask(const char *str);
292 294
293#endif /* CGIT_H */ 295#endif /* CGIT_H */
diff --git a/shared.c b/shared.c
index 2c309f5..9c992c8 100644
--- a/shared.c
+++ b/shared.c
@@ -49,49 +49,49 @@ int cgit_max_msg_len = 60;
49int cgit_max_repodesc_len = 60; 49int cgit_max_repodesc_len = 60;
50int cgit_max_commit_count = 50; 50int cgit_max_commit_count = 50;
51 51
52int cgit_query_has_symref = 0; 52int cgit_query_has_symref = 0;
53int cgit_query_has_sha1 = 0; 53int cgit_query_has_sha1 = 0;
54 54
55char *cgit_querystring = NULL; 55char *cgit_querystring = NULL;
56char *cgit_query_repo = NULL; 56char *cgit_query_repo = NULL;
57char *cgit_query_page = NULL; 57char *cgit_query_page = NULL;
58char *cgit_query_head = NULL; 58char *cgit_query_head = NULL;
59char *cgit_query_search = NULL; 59char *cgit_query_search = NULL;
60char *cgit_query_grep = NULL; 60char *cgit_query_grep = NULL;
61char *cgit_query_sha1 = NULL; 61char *cgit_query_sha1 = NULL;
62char *cgit_query_sha2 = NULL; 62char *cgit_query_sha2 = NULL;
63char *cgit_query_path = NULL; 63char *cgit_query_path = NULL;
64char *cgit_query_name = NULL; 64char *cgit_query_name = NULL;
65int cgit_query_ofs = 0; 65int cgit_query_ofs = 0;
66 66
67int htmlfd = 0; 67int htmlfd = 0;
68 68
69 69
70int cgit_get_cmd_index(const char *cmd) 70int cgit_get_cmd_index(const char *cmd)
71{ 71{
72 static char *cmds[] = {"log", "commit", "diff", "tree", "blob", 72 static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
73 "snapshot", "tag", "refs", NULL}; 73 "snapshot", "tag", "refs", "patch", NULL};
74 int i; 74 int i;
75 75
76 for(i = 0; cmds[i]; i++) 76 for(i = 0; cmds[i]; i++)
77 if (!strcmp(cmd, cmds[i])) 77 if (!strcmp(cmd, cmds[i]))
78 return i + 1; 78 return i + 1;
79 return 0; 79 return 0;
80} 80}
81 81
82int chk_zero(int result, char *msg) 82int chk_zero(int result, char *msg)
83{ 83{
84 if (result != 0) 84 if (result != 0)
85 die("%s: %s", msg, strerror(errno)); 85 die("%s: %s", msg, strerror(errno));
86 return result; 86 return result;
87} 87}
88 88
89int chk_positive(int result, char *msg) 89int chk_positive(int result, char *msg)
90{ 90{
91 if (result <= 0) 91 if (result <= 0)
92 die("%s: %s", msg, strerror(errno)); 92 die("%s: %s", msg, strerror(errno));
93 return result; 93 return result;
94} 94}
95 95
96int chk_non_negative(int result, char *msg) 96int chk_non_negative(int result, char *msg)
97{ 97{
diff --git a/ui-patch.c b/ui-patch.c
new file mode 100644
index 0000000..ef79c7c
--- a/dev/null
+++ b/ui-patch.c
@@ -0,0 +1,105 @@
1/* ui-patch.c: generate patch view
2 *
3 * Copyright (C) 2007 Lars Hjemli
4 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
8
9#include "cgit.h"
10
11static void print_line(char *line, int len)
12{
13 char c = line[len-1];
14
15 line[len-1] = '\0';
16 htmlf("%s\n", line);
17 line[len-1] = c;
18}
19
20static void header(unsigned char *sha1, char *path1, int mode1,
21 unsigned char *sha2, char *path2, int mode2)
22{
23 char *abbrev1, *abbrev2;
24 int subproject;
25
26 subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2));
27 htmlf("diff --git a/%s b/%s\n", path1, path2);
28
29 if (is_null_sha1(sha1))
30 path1 = "dev/null";
31 if (is_null_sha1(sha2))
32 path2 = "dev/null";
33
34 if (mode1 == 0)
35 htmlf("new file mode %.6o\n", mode2);
36
37 if (mode2 == 0)
38 htmlf("deleted file mode %.6o\n", mode1);
39
40 if (!subproject) {
41 abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV));
42 abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV));
43 htmlf("index %s..%s", abbrev1, abbrev2);
44 free(abbrev1);
45 free(abbrev2);
46 if (mode1 != 0 && mode2 != 0) {
47 htmlf(" %.6o", mode1);
48 if (mode2 != mode1)
49 htmlf("..%.6o", mode2);
50 }
51 htmlf("\n--- a/%s\n", path1);
52 htmlf("+++ b/%s\n", path2);
53 }
54}
55
56static void filepair_cb(struct diff_filepair *pair)
57{
58 header(pair->one->sha1, pair->one->path, pair->one->mode,
59 pair->two->sha1, pair->two->path, pair->two->mode);
60 if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
61 if (S_ISGITLINK(pair->one->mode))
62 print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
63 if (S_ISGITLINK(pair->two->mode))
64 print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
65 return;
66 }
67 if (cgit_diff_files(pair->one->sha1, pair->two->sha1, print_line))
68 html("Error running diff");
69}
70
71void cgit_print_patch(char *hex, struct cacheitem *item)
72{
73 struct commit *commit;
74 struct commitinfo *info;
75 unsigned char sha1[20], old_sha1[20];
76 char *patchname;
77
78 if (!hex)
79 hex = cgit_query_head;
80
81 if (get_sha1(hex, sha1)) {
82 cgit_print_error(fmt("Bad object id: %s", hex));
83 return;
84 }
85 commit = lookup_commit_reference(sha1);
86 if (!commit) {
87 cgit_print_error(fmt("Bad commit reference: %s", hex));
88 return;
89 }
90 info = cgit_parse_commit(commit);
91 hashcpy(old_sha1, commit->parents->item->object.sha1);
92
93 patchname = fmt("%s.patch", sha1_to_hex(sha1));
94 cgit_print_snapshot_start("text/plain", patchname, item);
95 htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
96 htmlf("From: %s%s\n", info->author, info->author_email);
97 html("Date: ");
98 cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n");
99 htmlf("Subject: %s\n\n%s", info->subject, info->msg);
100 html("---\n");
101 cgit_diff_tree(old_sha1, sha1, filepair_cb, NULL);
102 html("--\n");
103 htmlf("cgit %s\n", CGIT_VERSION);
104 cgit_free_commitinfo(info);
105}
diff --git a/ui-shared.c b/ui-shared.c
index ece041c..60aa2e3 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -251,48 +251,54 @@ void cgit_snapshot_link(char *name, char *title, char *class, char *head,
251} 251}
252 252
253void cgit_diff_link(char *name, char *title, char *class, char *head, 253void cgit_diff_link(char *name, char *title, char *class, char *head,
254 char *new_rev, char *old_rev, char *path) 254 char *new_rev, char *old_rev, char *path)
255{ 255{
256 char *delim; 256 char *delim;
257 257
258 delim = repolink(title, class, "diff", head, path); 258 delim = repolink(title, class, "diff", head, path);
259 if (new_rev && strcmp(new_rev, cgit_query_head)) { 259 if (new_rev && strcmp(new_rev, cgit_query_head)) {
260 html(delim); 260 html(delim);
261 html("id="); 261 html("id=");
262 html_attr(new_rev); 262 html_attr(new_rev);
263 delim = "&amp;"; 263 delim = "&amp;";
264 } 264 }
265 if (old_rev) { 265 if (old_rev) {
266 html(delim); 266 html(delim);
267 html("id2="); 267 html("id2=");
268 html_attr(old_rev); 268 html_attr(old_rev);
269 } 269 }
270 html("'>"); 270 html("'>");
271 html_txt(name); 271 html_txt(name);
272 html("</a>"); 272 html("</a>");
273} 273}
274 274
275void cgit_patch_link(char *name, char *title, char *class, char *head,
276 char *rev)
277{
278 reporevlink("patch", name, title, class, head, rev, NULL);
279}
280
275void cgit_object_link(struct object *obj) 281void cgit_object_link(struct object *obj)
276{ 282{
277 char *page, *arg, *url; 283 char *page, *arg, *url;
278 284
279 if (obj->type == OBJ_COMMIT) { 285 if (obj->type == OBJ_COMMIT) {
280 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, 286 cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL,
281 cgit_query_head, sha1_to_hex(obj->sha1)); 287 cgit_query_head, sha1_to_hex(obj->sha1));
282 return; 288 return;
283 } else if (obj->type == OBJ_TREE) { 289 } else if (obj->type == OBJ_TREE) {
284 page = "tree"; 290 page = "tree";
285 arg = "id"; 291 arg = "id";
286 } else if (obj->type == OBJ_TAG) { 292 } else if (obj->type == OBJ_TAG) {
287 page = "tag"; 293 page = "tag";
288 arg = "id"; 294 arg = "id";
289 } else { 295 } else {
290 page = "blob"; 296 page = "blob";
291 arg = "id"; 297 arg = "id";
292 } 298 }
293 299
294 url = cgit_pageurl(cgit_query_repo, page, 300 url = cgit_pageurl(cgit_query_repo, page,
295 fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); 301 fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
296 html_link_open(url, NULL, NULL); 302 html_link_open(url, NULL, NULL);
297 htmlf("%s %s", typename(obj->type), 303 htmlf("%s %s", typename(obj->type),
298 sha1_to_hex(obj->sha1)); 304 sha1_to_hex(obj->sha1));
@@ -469,48 +475,50 @@ void cgit_print_pageheader(char *title, int show_search)
469 html_attr(cgit_rooturl()); 475 html_attr(cgit_rooturl());
470 htmlf("'><img src='%s' alt='cgit'/></a>\n", 476 htmlf("'><img src='%s' alt='cgit'/></a>\n",
471 cgit_logo); 477 cgit_logo);
472 html("</td></tr>\n<tr><td class='sidebar'>\n"); 478 html("</td></tr>\n<tr><td class='sidebar'>\n");
473 if (cgit_query_repo) { 479 if (cgit_query_repo) {
474 html("<h1 class='first'>"); 480 html("<h1 class='first'>");
475 html_txt(strrpart(cgit_repo->name, 20)); 481 html_txt(strrpart(cgit_repo->name, 20));
476 html("</h1>\n"); 482 html("</h1>\n");
477 html_txt(cgit_repo->desc); 483 html_txt(cgit_repo->desc);
478 if (cgit_repo->owner) { 484 if (cgit_repo->owner) {
479 html("<h1>owner</h1>\n"); 485 html("<h1>owner</h1>\n");
480 html_txt(cgit_repo->owner); 486 html_txt(cgit_repo->owner);
481 } 487 }
482 html("<h1>navigate</h1>\n"); 488 html("<h1>navigate</h1>\n");
483 reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, 489 reporevlink(NULL, "summary", NULL, "menu", cgit_query_head,
484 NULL, NULL); 490 NULL, NULL);
485 cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL, 491 cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL,
486 0, NULL, NULL); 492 0, NULL, NULL);
487 cgit_tree_link("tree", NULL, "menu", cgit_query_head, 493 cgit_tree_link("tree", NULL, "menu", cgit_query_head,
488 cgit_query_sha1, NULL); 494 cgit_query_sha1, NULL);
489 cgit_commit_link("commit", NULL, "menu", cgit_query_head, 495 cgit_commit_link("commit", NULL, "menu", cgit_query_head,
490 cgit_query_sha1); 496 cgit_query_sha1);
491 cgit_diff_link("diff", NULL, "menu", cgit_query_head, 497 cgit_diff_link("diff", NULL, "menu", cgit_query_head,
492 cgit_query_sha1, cgit_query_sha2, NULL); 498 cgit_query_sha1, cgit_query_sha2, NULL);
499 cgit_patch_link("patch", NULL, "menu", cgit_query_head,
500 cgit_query_sha1);
493 501
494 for_each_ref(print_archive_ref, &header); 502 for_each_ref(print_archive_ref, &header);
495 503
496 if (cgit_repo->clone_url || cgit_clone_prefix) { 504 if (cgit_repo->clone_url || cgit_clone_prefix) {
497 html("<h1>clone</h1>\n"); 505 html("<h1>clone</h1>\n");
498 if (cgit_repo->clone_url) 506 if (cgit_repo->clone_url)
499 url = cgit_repo->clone_url; 507 url = cgit_repo->clone_url;
500 else 508 else
501 url = fmt("%s%s", cgit_clone_prefix, 509 url = fmt("%s%s", cgit_clone_prefix,
502 cgit_repo->url); 510 cgit_repo->url);
503 html("<a class='menu' href='"); 511 html("<a class='menu' href='");
504 html_attr(url); 512 html_attr(url);
505 html("' title='"); 513 html("' title='");
506 html_attr(url); 514 html_attr(url);
507 html("'>\n"); 515 html("'>\n");
508 html_txt(strrpart(url, 20)); 516 html_txt(strrpart(url, 20));
509 html("</a>\n"); 517 html("</a>\n");
510 } 518 }
511 519
512 html("<h1>branch</h1>\n"); 520 html("<h1>branch</h1>\n");
513 html("<form method='get' action=''>\n"); 521 html("<form method='get' action=''>\n");
514 add_hidden_formfields(0, 1, cgit_query_page); 522 add_hidden_formfields(0, 1, cgit_query_page);
515 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>"); 523 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
516 html("<select name='h' onchange='this.form.submit();'>\n"); 524 html("<select name='h' onchange='this.form.submit();'>\n");