]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'jh/context-lines'
authorLars Hjemli <hjemli@gmail.com>
Tue, 22 Jun 2010 14:16:12 +0000 (16:16 +0200)
committerLars Hjemli <hjemli@gmail.com>
Tue, 22 Jun 2010 14:16:12 +0000 (16:16 +0200)
Conflicts:
cgit.c
cgit.h

1  2 
cgit.c
cgit.h
shared.c

diff --combined cgit.c
index d4fcfa70b18952e72bf4bde7b1050cc148db5188,e9bafb506ef38c24c4b4300de08d0b5965a738f6..ab25b6a00efe4889863b7625c22e9ea180d0fe61
--- 1/cgit.c
--- 2/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"))
                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 80c3902b5e5dec8e16b6b2bbaf60207ada344854,bb8f598b1f60457cebbf1beeb8f7de8e673e59e0..2b28d636e20ba1f79c398a83f9383d43cba9e2e0
--- 1/cgit.h
--- 2/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 58837dc76ec4830d9bf82c6b613c1f7d6899a7e4,7cf1e59a2bdac66900592cc87827332b767eb492..06f70bb141587c25565664ef42cbdd9b1addec09
+++ 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;
        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;
        }
  
        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;
  }