summaryrefslogtreecommitdiffabout
path: root/cgit.c
Unidiff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index 1281bfa..4b91829 100644
--- a/cgit.c
+++ b/cgit.c
@@ -72,64 +72,67 @@ static void cgit_print_repo_page(struct cacheitem *item)
72 cgit_repo->url, cgit_query_name); 72 cgit_repo->url, cgit_query_name);
73 return; 73 return;
74 } 74 }
75 75
76 if (cgit_cmd == CMD_BLOB) { 76 if (cgit_cmd == CMD_BLOB) {
77 cgit_print_blob(item, cgit_query_sha1, cgit_query_path); 77 cgit_print_blob(item, cgit_query_sha1, cgit_query_path);
78 return; 78 return;
79 } 79 }
80 80
81 show_search = (cgit_cmd == CMD_LOG); 81 show_search = (cgit_cmd == CMD_LOG);
82 cgit_print_docstart(title, item); 82 cgit_print_docstart(title, item);
83 if (!cgit_cmd) { 83 if (!cgit_cmd) {
84 cgit_print_pageheader("summary", show_search); 84 cgit_print_pageheader("summary", show_search);
85 cgit_print_summary(); 85 cgit_print_summary();
86 cgit_print_docend(); 86 cgit_print_docend();
87 return; 87 return;
88 } 88 }
89 89
90 cgit_print_pageheader(cgit_query_page, show_search); 90 cgit_print_pageheader(cgit_query_page, show_search);
91 91
92 switch(cgit_cmd) { 92 switch(cgit_cmd) {
93 case CMD_LOG: 93 case CMD_LOG:
94 cgit_print_log(cgit_query_sha1, cgit_query_ofs, 94 cgit_print_log(cgit_query_sha1, cgit_query_ofs,
95 cgit_max_commit_count, cgit_query_search, 95 cgit_max_commit_count, cgit_query_search,
96 cgit_query_path, 1); 96 cgit_query_path, 1);
97 break; 97 break;
98 case CMD_TREE: 98 case CMD_TREE:
99 cgit_print_tree(cgit_query_sha1, cgit_query_path); 99 cgit_print_tree(cgit_query_sha1, cgit_query_path);
100 break; 100 break;
101 case CMD_COMMIT: 101 case CMD_COMMIT:
102 cgit_print_commit(cgit_query_sha1); 102 cgit_print_commit(cgit_query_sha1);
103 break; 103 break;
104 case CMD_TAG:
105 cgit_print_tag(cgit_query_sha1);
106 break;
104 case CMD_DIFF: 107 case CMD_DIFF:
105 cgit_print_diff(cgit_query_sha1, cgit_query_sha2); 108 cgit_print_diff(cgit_query_sha1, cgit_query_sha2);
106 break; 109 break;
107 default: 110 default:
108 cgit_print_error("Invalid request"); 111 cgit_print_error("Invalid request");
109 } 112 }
110 cgit_print_docend(); 113 cgit_print_docend();
111} 114}
112 115
113static void cgit_fill_cache(struct cacheitem *item, int use_cache) 116static void cgit_fill_cache(struct cacheitem *item, int use_cache)
114{ 117{
115 static char buf[PATH_MAX]; 118 static char buf[PATH_MAX];
116 int stdout2; 119 int stdout2;
117 120
118 getcwd(buf, sizeof(buf)); 121 getcwd(buf, sizeof(buf));
119 item->st.st_mtime = time(NULL); 122 item->st.st_mtime = time(NULL);
120 123
121 if (use_cache) { 124 if (use_cache) {
122 stdout2 = chk_positive(dup(STDOUT_FILENO), 125 stdout2 = chk_positive(dup(STDOUT_FILENO),
123 "Preserving STDOUT"); 126 "Preserving STDOUT");
124 chk_zero(close(STDOUT_FILENO), "Closing STDOUT"); 127 chk_zero(close(STDOUT_FILENO), "Closing STDOUT");
125 chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); 128 chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)");
126 } 129 }
127 130
128 if (cgit_repo) 131 if (cgit_repo)
129 cgit_print_repo_page(item); 132 cgit_print_repo_page(item);
130 else 133 else
131 cgit_print_repolist(item); 134 cgit_print_repolist(item);
132 135
133 if (use_cache) { 136 if (use_cache) {
134 chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT"); 137 chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT");
135 chk_positive(dup2(stdout2, STDOUT_FILENO), 138 chk_positive(dup2(stdout2, STDOUT_FILENO),