From: Lars Hjemli Date: Tue, 22 Jun 2010 14:15:48 +0000 (+0200) Subject: Merge branch 'jh/path-limit' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/37a24e4e39737edaa5cdde501346a65eeb280e63?hp=-c Merge branch 'jh/path-limit' Conflicts: cgit.h ui-commit.c --- 37a24e4e39737edaa5cdde501346a65eeb280e63 diff --combined cgit.c index 38bc136,2c3ad73..d4fcfa7 --- a/cgit.c +++ b/cgit.c @@@ -62,8 -62,6 +62,8 @@@ void repo_config(struct cgit_repo *repo repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); else if (!strcmp(name, "enable-remote-branches")) repo->enable_remote_branches = atoi(value); + else if (!strcmp(name, "enable-subject-links")) + repo->enable_subject_links = atoi(value); else if (!strcmp(name, "max-stats")) repo->max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "module-link")) @@@ -143,8 -141,6 +143,8 @@@ void config_cb(const char *name, const ctx.cfg.enable_log_linecount = atoi(value); else if (!strcmp(name, "enable-remote-branches")) ctx.cfg.enable_remote_branches = atoi(value); + else if (!strcmp(name, "enable-subject-links")) + ctx.cfg.enable_subject_links = atoi(value); else if (!strcmp(name, "enable-tree-linenumbers")) ctx.cfg.enable_tree_linenumbers = atoi(value); else if (!strcmp(name, "max-stats")) @@@ -169,8 -165,6 +169,8 @@@ ctx.cfg.commit_filter = new_filter(value, 0); else if (!strcmp(name, "embedded")) ctx.cfg.embedded = atoi(value); + else if (!strcmp(name, "max-atom-items")) + ctx.cfg.max_atom_items = atoi(value); else if (!strcmp(name, "max-message-length")) ctx.cfg.max_msg_len = atoi(value); else if (!strcmp(name, "max-repodesc-length")) @@@ -256,8 -250,6 +256,8 @@@ static void querystring_cb(const char * ctx.qry.period = xstrdup(value); } else if (!strcmp(name, "ss")) { ctx.qry.ssdiff = atoi(value); + } else if (!strcmp(name, "all")) { + ctx.qry.show_all = atoi(value); } } @@@ -300,7 -292,6 +300,7 @@@ static void prepare_context(struct cgit ctx->cfg.summary_branches = 10; ctx->cfg.summary_log = 10; ctx->cfg.summary_tags = 10; + ctx->cfg.max_atom_items = 10; ctx->cfg.ssdiff = 0; ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); @@@ -433,6 -424,12 +433,12 @@@ static void process_request(void *cbdat return; } + /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" + * in-project path limit to be made available at ctx->qry.vpath. + * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). + */ + ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL; + if (cmd->want_repo && !ctx->repo) { cgit_print_http_headers(ctx); cgit_print_docstart(ctx); diff --combined cgit.css index 6198403,28a2eeb..6e47eb3 --- a/cgit.css +++ b/cgit.css @@@ -64,7 -64,7 +64,7 @@@ table#header td.sub } table.tabs { - /* border-bottom: solid 2px #ccc; */ + border-bottom: solid 3px #ccc; border-collapse: collapse; margin-top: 2em; margin-bottom: 0px; @@@ -102,10 -102,16 +102,16 @@@ table.tabs td.form select font-size: 90%; } + div.path { + margin: 0px; + padding: 5px 2em 2px 2em; + color: #000; + background-color: #eee; + } + div.content { margin: 0px; padding: 2em; - border-top: solid 3px #ccc; border-bottom: solid 3px #ccc; } @@@ -525,10 -531,7 +531,10 @@@ a.deco border: solid 1px #770000; } -div.commit-subject a { +div.commit-subject a.branch-deco, +div.commit-subject a.tag-deco, +div.commit-subject a.remote-deco, +div.commit-subject a.deco { margin-left: 1em; font-size: 75%; } diff --combined cgit.h index 8884f9e,f990b15..80c3902 --- a/cgit.h +++ b/cgit.h @@@ -73,7 -73,6 +73,7 @@@ struct cgit_repo int enable_log_filecount; int enable_log_linecount; int enable_remote_branches; + int enable_subject_links; int max_stats; time_t mtime; struct cgit_filter *about_filter; @@@ -146,7 -145,7 +146,8 @@@ struct cgit_query char *sort; int showmsg; int ssdiff; + int show_all; + char *vpath; }; struct cgit_config { @@@ -183,10 -182,8 +184,10 @@@ int enable_log_filecount; int enable_log_linecount; int enable_remote_branches; + int enable_subject_links; int enable_tree_linenumbers; int local_time; + int max_atom_items; int max_repo_count; int max_commit_count; int max_lock_attempts; diff --combined cgitrc.5.txt index 5c24381,1f7ac1e..a853522 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@@ -115,12 -115,6 +115,12 @@@ enable-remote-branches: in the summary and refs views. Default value: "0". See also: "repo.enable-remote-branches". +enable-subject-links:: + Flag which, when set to "1", will make cgit use the subject of the + parent commit as link text when generating links to parent commits + in commit view. Default value: "0". See also: + "repo.enable-subject-links". + enable-tree-linenumbers:: Flag which, when set to "1", will make cgit generate linenumber links for plaintext blobs printed in the tree view. Default value: "1". @@@ -172,10 -166,6 +172,10 @@@ logo-link: calculated url of the repository index page will be used. Default value: none. +max-atom-items:: + Specifies the number of items to display in atom feeds view. Default + value: "10". + max-commit-count:: Specifies the number of entries to list per page in "log" view. Default value: "50". @@@ -331,10 -321,6 +331,10 @@@ repo.enable-remote-branches: Flag which, when set to "1", will make cgit display remote branches in the summary and refs views. Default value: . +repo.enable-subject-links:: + A flag which can be used to override the global setting + `enable-subject-links'. Default value: none. + repo.max-stats:: Override the default maximum statistics period. Valid values are equal to the values specified for the global "max-stats" setting. Default @@@ -444,7 -430,7 +444,7 @@@ snapshots=tar.gz tar.bz2 zi ## List of common mimetypes ## - mimetype.git=image/git + mimetype.gif=image/gif mimetype.html=text/html mimetype.jpg=image/jpeg mimetype.jpeg=image/jpeg diff --combined cmd.c index ad784fc,605876b..6dc9f5e --- a/cmd.c +++ b/cmd.c @@@ -33,7 -33,7 +33,7 @@@ static void HEAD_fn(struct cgit_contex static void atom_fn(struct cgit_context *ctx) { - cgit_print_atom(ctx->qry.head, ctx->qry.path, 10); + cgit_print_atom(ctx->qry.head, ctx->qry.path, ctx->cfg.max_atom_items); } static void about_fn(struct cgit_context *ctx) @@@ -51,7 -51,7 +51,7 @@@ static void blob_fn(struct cgit_contex static void commit_fn(struct cgit_context *ctx) { - cgit_print_commit(ctx->qry.sha1); + cgit_print_commit(ctx->qry.sha1, ctx->qry.path); } static void diff_fn(struct cgit_context *ctx) @@@ -90,7 -90,7 +90,7 @@@ static void repolist_fn(struct cgit_con static void patch_fn(struct cgit_context *ctx) { - cgit_print_patch(ctx->qry.sha1); + cgit_print_patch(ctx->qry.sha1, ctx->qry.path); } static void plain_fn(struct cgit_context *ctx) @@@ -129,31 -129,31 +129,31 @@@ static void tree_fn(struct cgit_contex cgit_print_tree(ctx->qry.sha1, ctx->qry.path); } - #define def_cmd(name, want_repo, want_layout) \ - {#name, name##_fn, want_repo, want_layout} + #define def_cmd(name, want_repo, want_layout, want_vpath) \ + {#name, name##_fn, want_repo, want_layout, want_vpath} struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) { static struct cgit_cmd cmds[] = { - def_cmd(HEAD, 1, 0), - def_cmd(atom, 1, 0), - def_cmd(about, 0, 1), - def_cmd(blob, 1, 0), - def_cmd(commit, 1, 1), - def_cmd(diff, 1, 1), - def_cmd(info, 1, 0), - def_cmd(log, 1, 1), - def_cmd(ls_cache, 0, 0), - def_cmd(objects, 1, 0), - def_cmd(patch, 1, 0), - def_cmd(plain, 1, 0), - def_cmd(refs, 1, 1), - def_cmd(repolist, 0, 0), - def_cmd(snapshot, 1, 0), - def_cmd(stats, 1, 1), - def_cmd(summary, 1, 1), - def_cmd(tag, 1, 1), - def_cmd(tree, 1, 1), + def_cmd(HEAD, 1, 0, 0), + def_cmd(atom, 1, 0, 0), + def_cmd(about, 0, 1, 0), + def_cmd(blob, 1, 0, 0), + def_cmd(commit, 1, 1, 1), + def_cmd(diff, 1, 1, 1), + def_cmd(info, 1, 0, 0), + def_cmd(log, 1, 1, 1), + def_cmd(ls_cache, 0, 0, 0), + def_cmd(objects, 1, 0, 0), + def_cmd(patch, 1, 0, 1), + def_cmd(plain, 1, 0, 0), + def_cmd(refs, 1, 1, 0), + def_cmd(repolist, 0, 0, 0), + def_cmd(snapshot, 1, 0, 0), + def_cmd(stats, 1, 1, 1), + def_cmd(summary, 1, 1, 0), + def_cmd(tag, 1, 1, 0), + def_cmd(tree, 1, 1, 1), }; int i; diff --combined shared.c index 8b3a045,6e8f0ce..58837dc --- a/shared.c +++ b/shared.c @@@ -10,7 -10,6 +10,6 @@@ struct cgit_repolist cgit_repolist; struct cgit_context ctx; - int cgit_cmd; int chk_zero(int result, char *msg) { @@@ -60,7 -59,6 +59,7 @@@ struct cgit_repo *cgit_add_repo(const c ret->enable_log_filecount = ctx.cfg.enable_log_filecount; ret->enable_log_linecount = ctx.cfg.enable_log_linecount; ret->enable_remote_branches = ctx.cfg.enable_remote_branches; + ret->enable_subject_links = ctx.cfg.enable_subject_links; ret->max_stats = ctx.cfg.max_stats; ret->module_link = ctx.cfg.module_link; ret->readme = NULL; @@@ -280,10 -278,6 +279,10 @@@ int cgit_diff_files(const unsigned cha if ((file1.ptr && buffer_is_binary(file1.ptr, file1.size)) || (file2.ptr && buffer_is_binary(file2.ptr, file2.size))) { *binary = 1; + if (file1.size) + free(file1.ptr); + if (file2.size) + free(file2.ptr); return 0; } @@@ -296,10 -290,6 +295,10 @@@ emit_cb.outf = filediff_cb; emit_cb.priv = fn; xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); + if (file1.size) + free(file1.ptr); + if (file2.size) + free(file2.ptr); return 0; } diff --combined ui-commit.c index 41313b9,2d98ed9..a11bc5f --- a/ui-commit.c +++ b/ui-commit.c @@@ -12,13 -12,13 +12,13 @@@ #include "ui-diff.h" #include "ui-log.h" - void cgit_print_commit(char *hex) + void cgit_print_commit(char *hex, const char *prefix) { struct commit *commit, *parent; - struct commitinfo *info; + struct commitinfo *info, *parent_info; struct commit_list *p; unsigned char sha1[20]; - char *tmp; + char *tmp, *tmp2; int parents = 0; if (!hex) @@@ -58,19 -58,23 +58,23 @@@ html("\n"); html("commit"); tmp = sha1_to_hex(commit->object.sha1); - cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0); + cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0); html(" ("); - cgit_patch_link("patch", NULL, NULL, NULL, tmp); + cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix); html(") ("); if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) - cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, 1); + cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); else - cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1); + cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1); html(")\n"); html("tree"); tmp = xstrdup(hex); cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, ctx.qry.head, tmp, NULL); + if (prefix) { + html(" /"); + cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); + } html("\n"); for (p = commit->parents; p ; p = p->next) { parent = lookup_commit_reference(p->item->object.sha1); @@@ -82,15 -86,12 +86,15 @@@ } html("parent" ""); - cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, - ctx.qry.head, - sha1_to_hex(p->item->object.sha1), prefix, 0); + tmp = tmp2 = sha1_to_hex(p->item->object.sha1); + if (ctx.repo->enable_subject_links) { + parent_info = cgit_parse_commit(parent); + tmp2 = parent_info->subject; + } - cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, 0); ++ cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix, 0); html(" ("); cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, - sha1_to_hex(p->item->object.sha1), NULL, 0); + sha1_to_hex(p->item->object.sha1), prefix, 0); html(")"); parents++; } @@@ -121,7 -122,7 +125,7 @@@ tmp = sha1_to_hex(commit->parents->item->object.sha1); else tmp = NULL; - cgit_print_diff(ctx.qry.sha1, tmp, NULL); + cgit_print_diff(ctx.qry.sha1, tmp, prefix); } cgit_free_commitinfo(info); }