]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'stable'
authorLars Hjemli <hjemli@gmail.com>
Sat, 27 Feb 2010 11:53:27 +0000 (12:53 +0100)
committerLars Hjemli <hjemli@gmail.com>
Sat, 27 Feb 2010 11:53:27 +0000 (12:53 +0100)
1  2 
cgit.c
ui-shared.c

diff --combined cgit.c
index e46c00a48e9e97f78a38d41b87b1a98f088e941f,6c7e8111c4cf31456983fe9f946cd5eb8410c3c8..9305d0a873a191e730d622d14067a2eee56003a6
--- 1/cgit.c
--- 2/cgit.c
+++ b/cgit.c
@@@ -60,8 -60,6 +60,8 @@@ void repo_config(struct cgit_repo *repo
                repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
                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, "max-stats"))
                repo->max_stats = cgit_find_stats_period(value, NULL);
        else if (!strcmp(name, "module-link"))
@@@ -139,8 -137,6 +139,8 @@@ void config_cb(const char *name, const 
                ctx.cfg.enable_log_filecount = atoi(value);
        else if (!strcmp(name, "enable-log-linecount"))
                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-tree-linenumbers"))
                ctx.cfg.enable_tree_linenumbers = atoi(value);
        else if (!strcmp(name, "max-stats"))
                ctx.cfg.max_msg_len = atoi(value);
        else if (!strcmp(name, "max-repodesc-length"))
                ctx.cfg.max_repodesc_len = atoi(value);
 +      else if (!strcmp(name, "max-blob-size"))
 +              ctx.cfg.max_blob_size = atoi(value);
        else if (!strcmp(name, "max-repo-count"))
                ctx.cfg.max_repo_count = atoi(value);
        else if (!strcmp(name, "max-commit-count"))
                ctx.cfg.summary_branches = atoi(value);
        else if (!strcmp(name, "summary-tags"))
                ctx.cfg.summary_tags = atoi(value);
 +      else if (!strcmp(name, "side-by-side-diffs"))
 +              ctx.cfg.ssdiff = atoi(value);
        else if (!strcmp(name, "agefile"))
                ctx.cfg.agefile = xstrdup(value);
        else if (!strcmp(name, "renamelimit"))
@@@ -217,8 -209,6 +217,8 @@@ static void querystring_cb(const char *
        } else if (!strcmp(name, "p")) {
                ctx.qry.page = xstrdup(value);
        } else if (!strcmp(name, "url")) {
 +              if (*value == '/')
 +                      value++;
                ctx.qry.url = xstrdup(value);
                cgit_parse_url(value);
        } else if (!strcmp(name, "qt")) {
                ctx.qry.showmsg = atoi(value);
        } else if (!strcmp(name, "period")) {
                ctx.qry.period = xstrdup(value);
 +      } else if (!strcmp(name, "ss")) {
 +              ctx.qry.ssdiff = atoi(value);
        }
  }
  
@@@ -260,7 -248,7 +260,7 @@@ char *xstrdupn(const char *str
  
  static void prepare_context(struct cgit_context *ctx)
  {
-       memset(ctx, 0, sizeof(ctx));
+       memset(ctx, 0, sizeof(*ctx));
        ctx->cfg.agefile = "info/web/last-modified";
        ctx->cfg.nocache = 0;
        ctx->cfg.cache_size = 0;
        ctx->cfg.max_lock_attempts = 5;
        ctx->cfg.max_msg_len = 80;
        ctx->cfg.max_repodesc_len = 80;
 +      ctx->cfg.max_blob_size = 0;
        ctx->cfg.max_stats = 0;
        ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
        ctx->cfg.renamelimit = -1;
        ctx->cfg.summary_branches = 10;
        ctx->cfg.summary_log = 10;
        ctx->cfg.summary_tags = 10;
 +      ctx->cfg.ssdiff = 0;
        ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG"));
        ctx->env.http_host = xstrdupn(getenv("HTTP_HOST"));
        ctx->env.https = xstrdupn(getenv("HTTPS"));
diff --combined ui-shared.c
index 08ea003c2da84378189303ebe99c8fe30216dcc3,8a7cc323363cc39837092609fee076300be95f60..8827fff4b19ed6b231a09f6870d4c2615deea82a
@@@ -246,7 -246,7 +246,7 @@@ static void reporevlink(char *page, cha
        char *delim;
  
        delim = repolink(title, class, page, head, path);
-       if (rev && strcmp(rev, ctx.qry.head)) {
+       if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) {
                html(delim);
                html("id=");
                html_url_arg(rev);
@@@ -317,7 -317,7 +317,7 @@@ void cgit_log_link(char *name, char *ti
  }
  
  void cgit_commit_link(char *name, char *title, char *class, char *head,
 -                    char *rev)
 +                    char *rev, int toggle_ssdiff)
  {
        if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
                name[ctx.cfg.max_msg_len] = '\0';
                name[ctx.cfg.max_msg_len - 2] = '.';
                name[ctx.cfg.max_msg_len - 3] = '.';
        }
 -      reporevlink("commit", name, title, class, head, rev, NULL);
 +
 +      char *delim;
 +
 +      delim = repolink(title, class, "commit", head, NULL);
 +      if (rev && strcmp(rev, ctx.qry.head)) {
 +              html(delim);
 +              html("id=");
 +              html_url_arg(rev);
 +              delim = "&amp;";
 +      }
 +      if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
 +              html(delim);
 +              html("ss=1");
 +      }
 +      html("'>");
 +      html_txt(name);
 +      html("</a>");
  }
  
  void cgit_refs_link(char *name, char *title, char *class, char *head,
@@@ -357,13 -341,12 +357,13 @@@ void cgit_snapshot_link(char *name, cha
  }
  
  void cgit_diff_link(char *name, char *title, char *class, char *head,
 -                  char *new_rev, char *old_rev, char *path)
 +                  char *new_rev, char *old_rev, char *path,
 +                  int toggle_ssdiff)
  {
        char *delim;
  
        delim = repolink(title, class, "diff", head, path);
-       if (new_rev && strcmp(new_rev, ctx.qry.head)) {
+       if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
                html(delim);
                html("id=");
                html_url_arg(new_rev);
                html(delim);
                html("id2=");
                html_url_arg(old_rev);
 +              delim = "&amp;";
 +      }
 +      if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
 +              html(delim);
 +              html("ss=1");
        }
        html("'>");
        html_txt(name);
@@@ -405,7 -383,7 +405,7 @@@ void cgit_object_link(struct object *ob
        shortrev[10] = '\0';
        if (obj->type == OBJ_COMMIT) {
                  cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
 -                               ctx.qry.head, fullrev);
 +                               ctx.qry.head, fullrev, 0);
                return;
        } else if (obj->type == OBJ_TREE)
                page = "tree";
@@@ -717,9 -695,9 +717,9 @@@ void cgit_print_pageheader(struct cgit_
                cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
                               ctx->qry.sha1, NULL);
                cgit_commit_link("commit", NULL, hc(cmd, "commit"),
 -                               ctx->qry.head, ctx->qry.sha1);
 +                               ctx->qry.head, ctx->qry.sha1, 0);
                cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
 -                             ctx->qry.sha1, ctx->qry.sha2, NULL);
 +                             ctx->qry.sha1, ctx->qry.sha2, NULL, 0);
                if (ctx->repo->max_stats)
                        cgit_stats_link("stats", NULL, hc(cmd, "stats"),
                                        ctx->qry.head, NULL);
@@@ -782,18 -760,13 +782,18 @@@ void cgit_print_snapshot_links(const ch
                               const char *hex, int snapshots)
  {
        const struct cgit_snapshot_format* f;
 +      char *prefix;
        char *filename;
 +      unsigned char sha1[20];
  
 +      if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
 +          (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
 +              hex++;
 +      prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex));
        for (f = cgit_snapshot_formats; f->suffix; f++) {
                if (!(snapshots & f->bit))
                        continue;
 -              filename = fmt("%s-%s%s", cgit_repobasename(repo), hex,
 -                             f->suffix);
 +              filename = fmt("%s%s", prefix, f->suffix);
                cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
                html("<br/>");
        }