]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'dm/disable-clone'
authorLars Hjemli <hjemli@gmail.com>
Sat, 14 May 2011 18:00:33 +0000 (20:00 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sat, 14 May 2011 18:00:33 +0000 (20:00 +0200)
1  2 
cgit.c
cgit.h
cgitrc.5.txt
cmd.c

diff --combined cgit.c
index e302a7c8c387cf096a4f387792c41223cc048b01,e0c2d9fb45e252d107853d03317c99c4b08d83ae..349d6e035cd05130579ba4feb763b805f095116d
--- 1/cgit.c
--- 2/cgit.c
+++ b/cgit.c
@@@ -29,17 -29,15 +29,17 @@@ void add_mimetype(const char *name, con
  struct cgit_filter *new_filter(const char *cmd, int extra_args)
  {
        struct cgit_filter *f;
 +      int args_size = 0;
  
        if (!cmd || !cmd[0])
                return NULL;
  
        f = xmalloc(sizeof(struct cgit_filter));
        f->cmd = xstrdup(cmd);
 -      f->argv = xmalloc((2 + extra_args) * sizeof(char *));
 +      args_size = (2 + extra_args) * sizeof(char *);
 +      f->argv = xmalloc(args_size);
 +      memset(f->argv, 0, args_size);
        f->argv[0] = f->cmd;
 -      f->argv[1] = NULL;
        return f;
  }
  
@@@ -59,8 -57,6 +59,8 @@@ void repo_config(struct cgit_repo *repo
                repo->defbranch = xstrdup(value);
        else if (!strcmp(name, "snapshots"))
                repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
 +      else if (!strcmp(name, "enable-commit-graph"))
 +              repo->enable_commit_graph = ctx.cfg.enable_commit_graph * atoi(value);
        else if (!strcmp(name, "enable-log-filecount"))
                repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
                repo->module_link= xstrdup(value);
        else if (!strcmp(name, "section"))
                repo->section = xstrdup(value);
 -      else if (!strcmp(name, "readme") && value != NULL) {
 +      else if (!strcmp(name, "readme") && value != NULL)
                repo->readme = xstrdup(value);
 -      } else if (ctx.cfg.enable_filter_overrides) {
 +      else if (!strcmp(name, "logo") && value != NULL)
 +              repo->logo = xstrdup(value);
 +      else if (!strcmp(name, "logo-link") && value != NULL)
 +              repo->logo_link = xstrdup(value);
 +      else if (ctx.cfg.enable_filter_overrides) {
                if (!strcmp(name, "about-filter"))
                        repo->about_filter = new_filter(value, 0);
                else if (!strcmp(name, "commit-filter"))
@@@ -147,10 -139,10 +147,12 @@@ void config_cb(const char *name, const 
                ctx.cfg.enable_filter_overrides = atoi(value);
        else if (!strcmp(name, "enable-gitweb-owner"))
                ctx.cfg.enable_gitweb_owner = atoi(value);
+       else if (!strcmp(name, "enable-http-clone"))
+               ctx.cfg.enable_http_clone = atoi(value);
        else if (!strcmp(name, "enable-index-links"))
                ctx.cfg.enable_index_links = atoi(value);
 +      else if (!strcmp(name, "enable-commit-graph"))
 +              ctx.cfg.enable_commit_graph = atoi(value);
        else if (!strcmp(name, "enable-log-filecount"))
                ctx.cfg.enable_log_filecount = atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
                                      ctx.cfg.project_list, repo_config);
                else
                        scan_tree(expand_macros(value), repo_config);
 +      else if (!strcmp(name, "scan-hidden-path"))
 +              ctx.cfg.scan_hidden_path = atoi(value);
        else if (!strcmp(name, "section-from-path"))
                ctx.cfg.section_from_path = atoi(value);
        else if (!strcmp(name, "source-filter"))
@@@ -312,6 -302,7 +314,7 @@@ static void prepare_context(struct cgit
        ctx->cfg.logo = "/cgit.png";
        ctx->cfg.local_time = 0;
        ctx->cfg.enable_gitweb_owner = 1;
+       ctx->cfg.enable_http_clone = 1;
        ctx->cfg.enable_tree_linenumbers = 1;
        ctx->cfg.max_repo_count = 50;
        ctx->cfg.max_commit_count = 50;
        ctx->cfg.robots = "index, nofollow";
        ctx->cfg.root_title = "Git repository browser";
        ctx->cfg.root_desc = "a fast webinterface for the git dscm";
 +      ctx->cfg.scan_hidden_path = 0;
        ctx->cfg.script_name = CGIT_SCRIPT_NAME;
        ctx->cfg.section = "";
        ctx->cfg.summary_branches = 10;
@@@ -439,7 -429,7 +442,7 @@@ static int prepare_repo_cmd(struct cgit
                tmp = xstrdup(ctx->qry.head);
                ctx->qry.head = ctx->repo->defbranch;
                ctx->page.status = 404;
-               ctx->page.statusmsg = "not found";
+               ctx->page.statusmsg = "Not found";
                cgit_print_http_headers(ctx);
                cgit_print_docstart(ctx);
                cgit_print_pageheader(ctx);
@@@ -458,6 -448,8 +461,8 @@@ static void process_request(void *cbdat
        cmd = cgit_get_cmd(ctx);
        if (!cmd) {
                ctx->page.title = "cgit error";
+               ctx->page.status = 404;
+               ctx->page.statusmsg = "Not found";
                cgit_print_http_headers(ctx);
                cgit_print_docstart(ctx);
                cgit_print_pageheader(ctx);
                return;
        }
  
+       if (!ctx->cfg.enable_http_clone && cmd->is_clone) {
+               html_status(404, "Not found", 0);
+               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).
@@@ -553,8 -550,6 +563,8 @@@ void print_repo(FILE *f, struct cgit_re
                fprintf(f, "repo.section=%s\n", repo->section);
        if (repo->clone_url)
                fprintf(f, "repo.clone-url=%s\n", repo->clone_url);
 +      fprintf(f, "repo.enable-commit-graph=%d\n",
 +              repo->enable_commit_graph);
        fprintf(f, "repo.enable-log-filecount=%d\n",
                repo->enable_log_filecount);
        fprintf(f, "repo.enable-log-linecount=%d\n",
@@@ -754,11 -749,10 +764,11 @@@ int main(int argc, const char **argv
        http_parse_querystring(ctx.qry.raw, querystring_cb);
  
        /* If virtual-root isn't specified in cgitrc, lets pretend
 -       * that virtual-root equals SCRIPT_NAME.
 +       * that virtual-root equals SCRIPT_NAME, minus any possibly
 +       * trailing slashes.
         */
        if (!ctx.cfg.virtual_root)
 -              ctx.cfg.virtual_root = ctx.cfg.script_name;
 +              ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/');
  
        /* If no url parameter is specified on the querystring, lets
         * use PATH_INFO as url. This allows cgit to work with virtual
diff --combined cgit.h
index b5f00fc9c1c1d6d6e7f7a8cdc2695cab334752ab,c119712c0a9f4e5fc9b336208fc2f01c575ec5ad..ecae4537a6b3cfc72d78e33026c9a053b65b69f4
--- 1/cgit.h
--- 2/cgit.h
+++ b/cgit.h
@@@ -20,7 -20,6 +20,7 @@@
  #include <xdiff/xdiff.h>
  #include <utf8.h>
  #include <notes.h>
 +#include <graph.h>
  
  
  /*
@@@ -71,10 -70,7 +71,10 @@@ struct cgit_repo 
        char *readme;
        char *section;
        char *clone_url;
 +      char *logo;
 +      char *logo_link;
        int snapshots;
 +      int enable_commit_graph;
        int enable_log_filecount;
        int enable_log_linecount;
        int enable_remote_branches;
@@@ -191,8 -187,8 +191,9 @@@ struct cgit_config 
        int embedded;
        int enable_filter_overrides;
        int enable_gitweb_owner;
+       int enable_http_clone;
        int enable_index_links;
 +      int enable_commit_graph;
        int enable_log_filecount;
        int enable_log_linecount;
        int enable_remote_branches;
        int noheader;
        int renamelimit;
        int remove_suffix;
 +      int scan_hidden_path;
        int section_from_path;
        int snapshots;
        int summary_branches;
diff --combined cgitrc.5.txt
index 65b210f3cfb49aae3825fc563c2176c88c160e22,b8c69b893ec5c1b5255274dd69ff1d972878f43f..875d51f8847519da360b66ff3f1e63e400fc4d24
@@@ -90,12 -90,7 +90,12 @@@ embedded:
        Flag which, when set to "1", will make cgit generate a html fragment
        suitable for embedding in other html pages. Default value: none. See
        also: "noheader".
 -      
 +
 +enable-commit-graph::
 +      Flag which, when set to "1", will make cgit print an ASCII-art commit
 +      history graph to the left of the commit messages in the repository
 +      log page. Default value: "0".
 +
  enable-filter-overrides::
        Flag which, when set to "1", allows all filter settings to be
        overridden in repository-specific cgitrc files. Default value: none.
@@@ -105,6 -100,11 +105,11 @@@ enable-gitweb-owner:
        for the git config value "gitweb.owner" to determine the owner.
        Default value: "1". See also: scan-path.
  
+ enable-http-clone::
+       If set to "1", cgit will act as an dumb HTTP endpoint for git clones.
+       If you use an alternate way of serving git repositories, you may wish
+       to disable this. Default value: "1".
  enable-index-links::
        Flag which, when set to "1", will make cgit generate extra links for
        each repo in the repository index (specifically, to the "summary",
@@@ -274,22 -274,13 +279,22 @@@ root-title:
        Text printed as heading on the repository index page. Default value:
        "Git Repository Browser".
  
 +scan-hidden-path::
 +      If set to "1" and scan-path is enabled, scan-path will recurse into
 +      directories whose name starts with a period ('.'). Otherwise,
 +      scan-path will stay away from such directories (considered as
 +      "hidden"). Note that this does not apply to the ".git" directory in
 +      non-bare repos. This must be defined prior to scan-path.
 +      Default value: 0. See also: scan-path.
 +
  scan-path::
        A path which will be scanned for repositories. If caching is enabled,
        the result will be cached as a cgitrc include-file in the cache
        directory. If project-list has been defined prior to scan-path,
        scan-path loads only the directories listed in the file pointed to by
 -      project-list. Default value: none. See also: cache-scanrc-ttl,
 -      project-list.
 +      project-list. Be advised that only the global settings taken
 +      before the scan-path directive will be applied to each repository.
 +      Default value: none. See also: cache-scanrc-ttl, project-list.
  
  section::
        The name of the current repository section - all repositories defined
@@@ -309,8 -300,7 +314,8 @@@ side-by-side-diffs:
  snapshots::
        Text which specifies the default set of snapshot formats generated by
        cgit. The value is a space-separated list of zero or more of the
 -      values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none.
 +      values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Default value:
 +      none.
  
  source-filter::
        Specifies a command which will be invoked to format plaintext blobs
@@@ -369,10 -359,6 +374,10 @@@ repo.defbranch:
  repo.desc::
        The value to show as repository description. Default value: none.
  
 +repo.enable-commit-graph::
 +      A flag which can be used to disable the global setting
 +      `enable-commit-graph'. Default value: none.
 +
  repo.enable-log-filecount::
        A flag which can be used to disable the global setting
        `enable-log-filecount'. Default value: none.
@@@ -389,15 -375,6 +394,15 @@@ repo.enable-subject-links:
        A flag which can be used to override the global setting
        `enable-subject-links'. Default value: none.
  
 +repo.logo::
 +      Url which specifies the source of an image which will be used as a logo
 +      on this repo's pages. Default value: global logo.
 +
 +repo.logo-link::
 +      Url loaded when clicking on the cgit logo image. If unspecified the
 +      calculated url of the repository index page will be used. Default
 +      value: global logo-link.
 +
  repo.max-stats::
        Override the default maximum statistics period. Valid values are equal
        to the values specified for the global "max-stats" setting. Default
@@@ -469,10 -446,6 +474,10 @@@ css=/css/cgit.cs
  enable-index-links=1
  
  
 +# Enable ASCII art commit history graph on the log pages
 +enable-commit-graph=1
 +
 +
  # Show number of affected files per commit on the log pages
  enable-log-filecount=1
  
diff --combined cmd.c
index 536515b7bb135dafefc5b5ed4e55c0dc7d2eb98a,0224ee912feca676a84f4700db454d2aabd69a48..d114eb3fd6dc46a49d2180304b394e3423a430a7
--- 1/cmd.c
--- 2/cmd.c
+++ b/cmd.c
@@@ -67,8 -67,7 +67,8 @@@ static void info_fn(struct cgit_contex
  static void log_fn(struct cgit_context *ctx)
  {
        cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,
 -                     ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1);
 +                     ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1,
 +                     ctx->repo->enable_commit_graph);
  }
  
  static void ls_cache_fn(struct cgit_context *ctx)
@@@ -130,31 -129,31 +130,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, want_vpath) \
-       {#name, name##_fn, want_repo, want_layout, want_vpath}
+ #define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \
+       {#name, name##_fn, want_repo, want_layout, want_vpath, is_clone}
  
  struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
  {
        static struct cgit_cmd cmds[] = {
-               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),
+               def_cmd(HEAD, 1, 0, 0, 1),
+               def_cmd(atom, 1, 0, 0, 0),
+               def_cmd(about, 0, 1, 0, 0),
+               def_cmd(blob, 1, 0, 0, 0),
+               def_cmd(commit, 1, 1, 1, 0),
+               def_cmd(diff, 1, 1, 1, 0),
+               def_cmd(info, 1, 0, 0, 1),
+               def_cmd(log, 1, 1, 1, 0),
+               def_cmd(ls_cache, 0, 0, 0, 0),
+               def_cmd(objects, 1, 0, 0, 1),
+               def_cmd(patch, 1, 0, 1, 0),
+               def_cmd(plain, 1, 0, 0, 0),
+               def_cmd(refs, 1, 1, 0, 0),
+               def_cmd(repolist, 0, 0, 0, 0),
+               def_cmd(snapshot, 1, 0, 0, 0),
+               def_cmd(stats, 1, 1, 1, 0),
+               def_cmd(summary, 1, 1, 0, 0),
+               def_cmd(tag, 1, 1, 0, 0),
+               def_cmd(tree, 1, 1, 1, 0),
        };
        int i;