summaryrefslogtreecommitdiffabout
path: root/cgit.c
Unidiff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index 7b7afba..fedf355 100644
--- a/cgit.c
+++ b/cgit.c
@@ -67,53 +67,62 @@ static void cgit_print_repo_page(struct cacheitem *item)
67 67
68 if (chdir(cgit_repo->path)) { 68 if (chdir(cgit_repo->path)) {
69 title = fmt("%s - %s", cgit_root_title, "Bad request"); 69 title = fmt("%s - %s", cgit_root_title, "Bad request");
70 cgit_print_docstart(title, item); 70 cgit_print_docstart(title, item);
71 cgit_print_pageheader(title, 0); 71 cgit_print_pageheader(title, 0);
72 cgit_print_error(fmt("Unable to scan repository: %s", 72 cgit_print_error(fmt("Unable to scan repository: %s",
73 strerror(errno))); 73 strerror(errno)));
74 cgit_print_docend(); 74 cgit_print_docend();
75 return; 75 return;
76 } 76 }
77 77
78 title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); 78 title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc);
79 show_search = 0; 79 show_search = 0;
80 setenv("GIT_DIR", cgit_repo->path, 1); 80 setenv("GIT_DIR", cgit_repo->path, 1);
81 81
82 if (cgit_repo->snapshots && cgit_query_page && 82 if (cgit_repo->snapshots && cgit_query_page &&
83 !strcmp(cgit_query_page, "snapshot")) { 83 !strcmp(cgit_query_page, "snapshot")) {
84 cgit_print_snapshot(item, cgit_query_sha1, "zip", 84 cgit_print_snapshot(item, cgit_query_sha1, "zip",
85 cgit_repo->url, cgit_query_name); 85 cgit_repo->url, cgit_query_name);
86 return; 86 return;
87 } 87 }
88 88
89 if (cgit_query_page && !strcmp(cgit_query_page, "log")) 89 if (cgit_query_page && !strcmp(cgit_query_page, "log"))
90 show_search = 1; 90 show_search = 1;
91
91 cgit_print_docstart(title, item); 92 cgit_print_docstart(title, item);
92 cgit_print_pageheader(title, show_search); 93
94
93 if (!cgit_query_page) { 95 if (!cgit_query_page) {
96 cgit_print_pageheader("summary", show_search);
94 cgit_print_summary(); 97 cgit_print_summary();
95 } else if (!strcmp(cgit_query_page, "log")) { 98 cgit_print_docend();
99 return;
100 }
101
102 cgit_print_pageheader(cgit_query_page, show_search);
103
104 if (!strcmp(cgit_query_page, "log")) {
96 cgit_print_log(cgit_query_head, cgit_query_ofs, 100, 105 cgit_print_log(cgit_query_head, cgit_query_ofs, 100,
97 cgit_query_search); 106 cgit_query_search);
98 } else if (!strcmp(cgit_query_page, "tree")) { 107 } else if (!strcmp(cgit_query_page, "tree")) {
99 cgit_print_tree(cgit_query_sha1, cgit_query_path); 108 cgit_print_tree(cgit_query_sha1, cgit_query_path);
100 } else if (!strcmp(cgit_query_page, "commit")) { 109 } else if (!strcmp(cgit_query_page, "commit")) {
101 cgit_print_commit(cgit_query_sha1); 110 cgit_print_commit(cgit_query_sha1);
102 } else if (!strcmp(cgit_query_page, "view")) { 111 } else if (!strcmp(cgit_query_page, "view")) {
103 cgit_print_view(cgit_query_sha1); 112 cgit_print_view(cgit_query_sha1);
104 } else if (!strcmp(cgit_query_page, "diff")) { 113 } else if (!strcmp(cgit_query_page, "diff")) {
105 cgit_print_diff(cgit_query_sha1, cgit_query_sha2); 114 cgit_print_diff(cgit_query_sha1, cgit_query_sha2);
106 } else { 115 } else {
107 cgit_print_error("Invalid request"); 116 cgit_print_error("Invalid request");
108 } 117 }
109 cgit_print_docend(); 118 cgit_print_docend();
110} 119}
111 120
112static void cgit_fill_cache(struct cacheitem *item, int use_cache) 121static void cgit_fill_cache(struct cacheitem *item, int use_cache)
113{ 122{
114 static char buf[PATH_MAX]; 123 static char buf[PATH_MAX];
115 int stdout2; 124 int stdout2;
116 125
117 getcwd(buf, sizeof(buf)); 126 getcwd(buf, sizeof(buf));
118 item->st.st_mtime = time(NULL); 127 item->st.st_mtime = time(NULL);
119 128