From: Lars Hjemli Date: Tue, 22 Jun 2010 14:16:12 +0000 (+0200) Subject: Merge branch 'jh/context-lines' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/6f92f332e6a9ee3e16051bda9fe148607af67f65?hp=-c Merge branch 'jh/context-lines' Conflicts: cgit.c cgit.h --- 6f92f332e6a9ee3e16051bda9fe148607af67f65 diff --combined cgit.c index d4fcfa7,e9bafb5..ab25b6a --- 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,8 +256,10 @@@ 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); + } else if (!strcmp(name, "context")) { + ctx.qry.context = atoi(value); } } @@@ -300,7 -294,6 +302,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")); diff --combined cgit.h index 80c3902,bb8f598..2b28d63 --- 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; + int context; char *vpath; }; @@@ -184,10 -183,8 +185,10 @@@ struct cgit_config 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; @@@ -278,7 -275,7 +279,7 @@@ extern void *cgit_free_commitinfo(struc extern int cgit_diff_files(const unsigned char *old_sha1, const unsigned char *new_sha1, unsigned long *old_size, unsigned long *new_size, - int *binary, linediff_fn fn); + int *binary, int context, linediff_fn fn); extern void cgit_diff_tree(const unsigned char *old_sha1, const unsigned char *new_sha1, diff --combined shared.c index 58837dc,7cf1e59..06f70bb --- a/shared.c +++ b/shared.c @@@ -59,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; @@@ -263,7 -262,8 +263,8 @@@ int filediff_cb(void *priv, mmbuffer_t int cgit_diff_files(const unsigned char *old_sha1, const unsigned char *new_sha1, unsigned long *old_size, - unsigned long *new_size, int *binary, linediff_fn fn) + unsigned long *new_size, int *binary, int context, + linediff_fn fn) { mmfile_t file1, file2; xpparam_t diff_params; @@@ -279,10 -279,6 +280,10 @@@ 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; } @@@ -290,15 -286,11 +291,15 @@@ memset(&emit_params, 0, sizeof(emit_params)); memset(&emit_cb, 0, sizeof(emit_cb)); diff_params.flags = XDF_NEED_MINIMAL; - emit_params.ctxlen = 3; + emit_params.ctxlen = context > 0 ? context : 3; emit_params.flags = XDL_EMIT_FUNCNAMES; 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; }