- if (get_sha1_hex(hex, sha1)){
- htmlf(cgit_error, "Bad hex value");
- return;
- }
-
- if (sha1_object_info(sha1, type, NULL)){
- htmlf(cgit_error, "Bad object name");
- return;
- }
-
- buf = read_sha1_file(sha1, type, &size);
- if (!buf) {
- htmlf(cgit_error, "Error reading object");
- return;
- }
-
- buf[size] = '\0';
- html("<h2>Object view</h2>");
- htmlf("sha1=%s<br/>type=%s<br/>size=%i<br/>", hex, type, size);
- html("<pre>");
- html_txt(buf);
- html("</pre>");
-}
-
-static void cgit_print_repo_page()
-{
- if (chdir(fmt("%s/%s", cgit_root, cgit_query_repo)) ||
- cgit_read_config("info/cgit", cgit_repo_config_cb)) {
- char *title = fmt("%s - %s", cgit_root_title, "Bad request");
- cgit_print_docstart(title);
- cgit_print_pageheader(title);
- htmlf(cgit_lib_error, "Unable to scan repository",
- strerror(errno));
- cgit_print_docend();
- return;
- }
- setenv("GIT_DIR", fmt("%s/%s", cgit_root, cgit_query_repo), 1);
- char *title = fmt("%s - %s", cgit_repo_name, cgit_repo_desc);
- cgit_print_docstart(title);
- cgit_print_pageheader(title);
- if (!cgit_query_page)
- cgit_print_repo_summary();
- else if (!strcmp(cgit_query_page, "log")) {
- cgit_print_log(cgit_query_head, 0, 100);
- } else if (!strcmp(cgit_query_page, "view")) {
- cgit_print_object(cgit_query_sha1);
- }
- cgit_print_docend();
-}
-
-static void cgit_fill_cache(struct cacheitem *item)
-{
- htmlfd = item->fd;
- item->st.st_mtime = time(NULL);
- if (cgit_query_repo)
- cgit_print_repo_page();
- else
- cgit_print_repolist();
-}
-
-static void cgit_refresh_cache(struct cacheitem *item)
-{