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

1  2 
cgit.c
cgit.css
cgit.h
cgitrc.5.txt
cmd.c
shared.c
ui-commit.c

diff --combined cgit.c
index 38bc136596ce610cfe6cb08450658ecee5e590ca,2c3ad73e064b556a23629194b9ca0a0a696186ee..d4fcfa70b18952e72bf4bde7b1050cc148db5188
--- 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,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 6198403c5c5c6ff26a6bd21b69c2286f2c21994a,28a2eeb8bfb014f9b62ee7266c62d1003f21e4cb..6e47eb3acfbf2eac8ce763575fa5b03a64030a74
+++ 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 8884f9e500dddb7d403ed1877217d8f3600bb041,f990b1506e29cdc10e89697041da06959319fdaa..80c3902b5e5dec8e16b6b2bbaf60207ada344854
--- 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;
+       char *vpath;
  };
  
  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;
diff --combined cgitrc.5.txt
index 5c2438103285241f25aaf37ff68ca3f923a6f6a6,1f7ac1eab2e1f779a20f50deda2c87578343005c..a85352219caabc1ec27b394fc04f34a188a73e49
@@@ -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: <enable-remote-branches>.
  
 +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 ad784fce0773ea6bc85ed406f1904f723b6ee3fb,605876bd88385e7065f2eb631dac0a50e25d112f..6dc9f5ea0757ff38d7bad5981279ca7ade2eec48
--- 1/cmd.c
--- 2/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 8b3a0457748a3f3ef30b48c8d1aecffa4a2c6b66,6e8f0ce89f5be4c0d53b29a12f200c1c10f7cbc7..58837dc76ec4830d9bf82c6b613c1f7d6899a7e4
+++ 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;
        }
  
        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 41313b9d7d08fb6b5fa17f4d3bfa73db04ba50e2,2d98ed9ea956cef5f71272e1473293c0c1b32338..a11bc5f3b00d21368c3ba826e7060aeb14de83d7
  #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)
        html("</td></tr>\n");
        html("<tr><th>commit</th><td colspan='2' class='sha1'>");
        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(")</td></tr>\n");
        html("<tr><th>tree</th><td colspan='2' class='sha1'>");
        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("</td></tr>\n");
                for (p = commit->parents; p ; p = p->next) {
                parent = lookup_commit_reference(p->item->object.sha1);
                }
                html("<tr><th>parent</th>"
                     "<td colspan='2' class='sha1'>");
 -              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(")</td></tr>");
                parents++;
        }
                        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);
  }