summaryrefslogtreecommitdiffstatshomepage
path: root/ui-commit.c
Commit message (Expand)AuthorAge
* Use GIT-1.7.2.2Lars Hjemli2010-08-22
* ui-commit: Display git notes when presentJeff Smith2010-08-04
* Merge branch 'jh/path-limit'Lars Hjemli2010-06-22
|\
| * ui-commit: Preserve path limit in links to commit pageJohan Herland2010-06-19
| * ui-commit: Preserve path limit in links to tree and diff pagesJohan Herland2010-06-19
| * ui-patch: Apply path limit to generated patchJohan Herland2010-06-19
| * ui-commit: Limit diff based on path limit in qry.pathJohan Herland2010-06-19
* | Optionally generate verbose parent linksLars Hjemli2010-02-27
* | display subject instead of sha1 as link title of parentsStefan Naewe2010-02-27
|/
* Add possibility to switch between unidiff and side-by-side-diff.Ragnar Ouchterlony2009-09-16
* Use GIT-1.6.4.3Lars Hjemli2009-09-13
* Merge branch 'lh/plugins'Lars Hjemli2009-08-09
|\
| * Add support for repo.commit-filter and repo.source-filterLars Hjemli2009-08-09
| * ui-commit: add support for 'commit-filter' optionLars Hjemli2009-07-31
* | Introduce noplainemail option to hide email adresses from spambotsMartin Szulecki2009-08-08
|/
* Add decorations to commit pagesJustin Waters2009-01-27
* Added `local-time` option to cgitrcStefan Naewe2008-08-01
* ui-commit: handle root commitsLars Hjemli2008-05-18
* Integrate diffstat with diffLars Hjemli2008-04-24
* Fix commitdiff annoyanceLars Hjemli2008-04-17
* Remove 'patch' link from tab, add to commit viewLars Hjemli2008-04-13
* Include diff in commit viewLars Hjemli2008-04-12
* Add ui-shared.hLars Hjemli2008-03-24
* Introduce html.hLars Hjemli2008-03-18
* Move cgit_repo into cgit_contextLars Hjemli2008-02-16
* Introduce struct cgit_contextLars Hjemli2008-02-16
* Fix html error detected by test-suiteLars Hjemli2007-11-11
* ui-commit.c: link to diff instead of tree from diffstatLars Hjemli2007-10-01
* cgit_print_snapshot_links: use url to specify snapshot nameLars Hjemli2007-07-23
* allow selective enabling of snapshotsMichael Krelin2007-07-21
* add support for snapshot tarballsMichael Krelin2007-07-18
* Add cgit_diff_link()Lars Hjemli2007-06-17
* ui-commit: use cgit_commit_link() for parent linksLars Hjemli2007-06-17
* Add cgit_commit_link() + support for id=sha1 to commit viewLars Hjemli2007-06-17
* Add and use cgit_tree_link()Lars Hjemli2007-06-17
* ui-tree: unify with ui-view, use path to select tree/blobLars Hjemli2007-06-16
* Use & instead of & in URLs.Ondrej Jirman2007-05-31
* Fixed unexpected tags in html output.Ondrej Jirman2007-05-31
* Add cgit_print_age() functionLars Hjemli2007-05-22
* Add link to commitdiff below diffstatLars Hjemli2007-05-16
* Change commit-view to expect h parameter, not idLars Hjemli2007-05-16
* Use tables and css to create the diffstat graph, fix scalingLars Hjemli2007-05-15
* Specify static storage class for file-local declarationsLars Hjemli2007-05-15
* Add log filtering by path and link to it from tree viewLars Hjemli2007-05-14
* Add commitdiff between commit and each of it's parentLars Hjemli2007-05-13
* Add graphical diffstat to commit viewLars Hjemli2007-05-13
* Use standard tree-diff function when showing diffstat for single commitLars Hjemli2007-05-13
* Make snapshot feature configurableLars Hjemli2007-02-08
* Add support for snapshotsLars Hjemli2007-02-08
* Add missing diff-link in ui-commit.cLars Hjemli2006-12-22
an class="n">result; FILE *fd; char line[1024]; char *mimetype; char *token; if (!filename) return NULL; fd = fopen(filename, "r"); if (!fd) return NULL; delimiters = " \t\r\n"; result = NULL; /* loop over all lines in the file */ while (!result && fgets(line, sizeof(line), fd)) { mimetype = strtok(line, delimiters); /* skip empty lines and comment lines */ if (!mimetype || (mimetype[0] == '#')) continue; /* loop over all extensions of mimetype */ while ((token = strtok(NULL, delimiters))) { if (!strcasecmp(ext, token)) { result = xstrdup(mimetype); break; } } } fclose(fd); return result; } static int print_object(const unsigned char *sha1, const char *path) { enum object_type type; char *buf, *ext; unsigned long size; struct string_list_item *mime; int freemime; type = sha1_object_info(sha1, &size); if (type == OBJ_BAD) { html_status(404, "Not found", 0); return 0; } buf = read_sha1_file(sha1, &type, &size); if (!buf) { html_status(404, "Not found", 0); return 0; } ctx.page.mimetype = NULL; ext = strrchr(path, '.'); freemime = 0; if (ext && *(++ext)) { mime = string_list_lookup(&ctx.cfg.mimetypes, ext); if (mime) { ctx.page.mimetype = (char *)mime->util; } else { ctx.page.mimetype = get_mimetype_from_file(ctx.cfg.mimetype_file, ext); if (ctx.page.mimetype) freemime = 1; } } if (!ctx.page.mimetype) { if (buffer_is_binary(buf, size)) ctx.page.mimetype = "application/octet-stream"; else ctx.page.mimetype = "text/plain"; } ctx.page.filename = path; ctx.page.size = size; ctx.page.etag = sha1_to_hex(sha1); cgit_print_http_headers(&ctx); html_raw(buf, size); /* If we allocated this, then casting away const is safe. */ if (freemime) free((char*) ctx.page.mimetype); return 1; } static char *buildpath(const char *base, int baselen, const char *path) { if (path[0]) return fmtalloc("%.*s%s/", baselen, base, path); else return fmtalloc("%.*s/", baselen, base); } static void print_dir(const unsigned char *sha1, const char *base, int baselen, const char *path) { char *fullpath, *slash; size_t len; fullpath = buildpath(base, baselen, path); slash = (fullpath[0] == '/' ? "" : "/"); ctx.page.etag = sha1_to_hex(sha1); cgit_print_http_headers(&ctx); htmlf("<html><head><title>%s", slash); html_txt(fullpath); htmlf("</title></head>\n<body>\n<h2>%s", slash); html_txt(fullpath); html("</h2>\n<ul>\n"); len = strlen(fullpath); if (len > 1) { fullpath[len - 1] = 0; slash = strrchr(fullpath, '/'); if (slash) *(slash + 1) = 0; else fullpath = NULL; html("<li>"); cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.sha1, fullpath); html("</li>\n"); } free(fullpath); } static void print_dir_entry(const unsigned char *sha1, const char *base, int baselen, const char *path, unsigned mode) { char *fullpath; fullpath = buildpath(base, baselen, path); if (!S_ISDIR(mode) && !S_ISGITLINK(mode)) fullpath[strlen(fullpath) - 1] = 0; html(" <li>"); if (S_ISGITLINK(mode)) { cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1)); } else cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, fullpath); html("</li>\n"); free(fullpath); } static void print_dir_tail(void) { html(" </ul>\n</body></html>\n"); } static int walk_tree(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata; if (baselen == walk_tree_ctx->match_baselen) { if (S_ISREG(mode)) { if (print_object(sha1, pathname)) walk_tree_ctx->match = 1; } else if (S_ISDIR(mode)) { print_dir(sha1, base, baselen, pathname); walk_tree_ctx->match = 2; return READ_TREE_RECURSIVE; } } else if (baselen > walk_tree_ctx->match_baselen) { print_dir_entry(sha1, base, baselen, pathname, mode); walk_tree_ctx->match = 2; } else if (S_ISDIR(mode)) { return READ_TREE_RECURSIVE; } return 0; } static int basedir_len(const char *path) { char *p = strrchr(path, '/'); if (p) return p - path + 1; return 0; } void cgit_print_plain(struct cgit_context *ctx) { const char *rev = ctx->qry.sha1; unsigned char sha1[20]; struct commit *commit; struct pathspec_item path_items = { .match = ctx->qry.path, .len = ctx->qry.path ? strlen(ctx->qry.path) : 0 }; struct pathspec paths = { .nr = 1, .items = &path_items }; struct walk_tree_context walk_tree_ctx = { .match = 0 }; if (!rev) rev = ctx->qry.head; if (get_sha1(rev, sha1)) { html_status(404, "Not found", 0); return; } commit = lookup_commit_reference(sha1); if (!commit || parse_commit(commit)) { html_status(404, "Not found", 0); return; } if (!path_items.match) { path_items.match = ""; walk_tree_ctx.match_baselen = -1; print_dir(commit->tree->object.sha1, "", 0, ""); walk_tree_ctx.match = 2; } else walk_tree_ctx.match_baselen = basedir_len(path_items.match); read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.match) html_status(404, "Not found", 0); else if (walk_tree_ctx.match == 2) print_dir_tail(); }