]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'ro/ssdiff'
authorLars Hjemli <hjemli@gmail.com>
Tue, 8 Dec 2009 18:32:48 +0000 (19:32 +0100)
committerLars Hjemli <hjemli@gmail.com>
Tue, 8 Dec 2009 18:32:48 +0000 (19:32 +0100)
1  2 
Makefile
cgit.c
cgit.css
cgit.h
cgitrc.5.txt
ui-shared.c
ui-shared.h

diff --combined Makefile
index 4e101d368e193919cc9e9ac52f5f5c21bd10f6ad,cb7875e7c321594fbd1ccad3cf3bf26a01c7ed2b..f8a4d471fea4dbddd515e347b7b8bf8b73bd92dc
+++ b/Makefile
@@@ -11,9 -11,6 +11,9 @@@ INSTALL = instal
  
  # Define NO_STRCASESTR if you don't have strcasestr.
  #
 +# Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
 +# implementation (slower).
 +#
  # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
  #
  
@@@ -71,7 -68,7 +71,7 @@@ endi
        $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
  
  
 -EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
 +EXTLIBS = git/libgit.a git/xdiff/lib.a -lz
  OBJECTS =
  OBJECTS += cache.o
  OBJECTS += cgit.o
@@@ -93,6 -90,7 +93,7 @@@ OBJECTS += ui-refs.
  OBJECTS += ui-repolist.o
  OBJECTS += ui-shared.o
  OBJECTS += ui-snapshot.o
+ OBJECTS += ui-ssdiff.o
  OBJECTS += ui-stats.o
  OBJECTS += ui-summary.o
  OBJECTS += ui-tag.o
@@@ -126,12 -124,6 +127,12 @@@ endi
  ifdef NO_STRCASESTR
        CFLAGS += -DNO_STRCASESTR
  endif
 +ifdef NO_OPENSSL
 +      CFLAGS += -DNO_OPENSSL
 +      GIT_OPTIONS += NO_OPENSSL=1
 +else
 +      EXTLIBS += -lcrypto
 +endif
  
  cgit: $(OBJECTS) libgit
        $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
@@@ -141,8 -133,8 +142,8 @@@ cgit.o: VERSIO
  -include $(OBJECTS:.o=.d)
  
  libgit:
 -      $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 libgit.a
 -      $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 xdiff/lib.a
 +      $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a
 +      $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a
  
  test: all
        $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
diff --combined cgit.c
index 08cb5d25621c2bd120982c86c0898e08497a083b,ff678fb210ea4ec073970b8c59ed0b429695ec60..4f68a4bbd7434f597aac6d6f8b3c59a11a371b47
--- 1/cgit.c
--- 2/cgit.c
+++ b/cgit.c
@@@ -68,9 -68,9 +68,9 @@@ void repo_config(struct cgit_repo *repo
                repo->section = xstrdup(value);
        else if (!strcmp(name, "readme") && value != NULL) {
                if (*value == '/')
 -                      ctx.repo->readme = xstrdup(value);
 +                      repo->readme = xstrdup(value);
                else
 -                      ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
 +                      repo->readme = xstrdup(fmt("%s/%s", repo->path, value));
        } else if (ctx.cfg.enable_filter_overrides) {
                if (!strcmp(name, "about-filter"))
                        repo->about_filter = new_filter(value, 0);
@@@ -165,8 -165,6 +165,8 @@@ void config_cb(const char *name, const 
                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"))
@@@ -211,8 -211,6 +213,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);
        }
  }
  
@@@ -272,7 -272,6 +276,7 @@@ static void prepare_context(struct cgit
        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 cgit.css
index ef7d3c1e863584ab4eae062408c17a34fe8dffbf,9e6d2a496edf058bac0acf86d4e7920cb2fe820e..0cb894a6f20950597d0a53cc8c7a2f727ea9e70c
+++ b/cgit.css
@@@ -162,11 -162,6 +162,11 @@@ table.list td a 
        color: black;
  }
  
 +table.list td a.ls-dir {
 +      font-weight: bold;
 +      color: #00f;
 +}
 +
  table.list td a:hover {
        color: #00f;
  }
@@@ -606,3 -601,102 +606,102 @@@ table.hgraph div.bar 
        background-color: #eee;
        height: 1em;
  }
+ table.ssdiff {
+       width: 100%;
+ }
+ table.ssdiff td {
+       font-size: 75%;
+       font-family: monospace;
+       white-space: pre;
+       padding: 1px 4px 1px 4px;
+       border-left: solid 1px #aaa;
+       border-right: solid 1px #aaa;
+ }
+ table.ssdiff td.add {
+       color: black;
+       background: #cfc;
+       min-width: 50%;
+ }
+ table.ssdiff td.add_dark {
+       color: black;
+       background: #aca;
+       min-width: 50%;
+ }
+ table.ssdiff span.add {
+       background: #cfc;
+       font-weight: bold;
+ }
+ table.ssdiff td.del {
+       color: black;
+       background: #fcc;
+       min-width: 50%;
+ }
+ table.ssdiff td.del_dark {
+       color: black;
+       background: #caa;
+       min-width: 50%;
+ }
+ table.ssdiff span.del {
+       background: #fcc;
+       font-weight: bold;
+ }
+ table.ssdiff td.changed {
+       color: black;
+       background: #ffc;
+       min-width: 50%;
+ }
+ table.ssdiff td.changed_dark {
+       color: black;
+       background: #cca;
+       min-width: 50%;
+ }
+ table.ssdiff td.lineno {
+       color: black;
+       background: #eee;
+       text-align: right;
+       width: 3em;
+       min-width: 3em;
+ }
+ table.ssdiff td.hunk {
+       color: #black;
+       background: #ccf;
+       border-top: solid 1px #aaa;
+       border-bottom: solid 1px #aaa;
+ }
+ table.ssdiff td.head {
+       border-top: solid 1px #aaa;
+       border-bottom: solid 1px #aaa;
+ }
+ table.ssdiff td.head div.head {
+       font-weight: bold;
+       color: black;
+ }
+ table.ssdiff td.foot {
+       border-top: solid 1px #aaa;
+         border-left: none;
+         border-right: none;
+         border-bottom: none;
+ }
+ table.ssdiff td.space {
+       border: none;
+ }
+ table.ssdiff td.space div {
+       min-height: 3em;
+ }
diff --combined cgit.h
index 39853dfe2f8d75df6c2eeae4013173012775dc8a,b7b0adb36b250c01ee5eb8d943e68bdfef0f5233..5941ec00a36c89ceef3b07fb880a8f970134729d
--- 1/cgit.h
--- 2/cgit.h
+++ b/cgit.h
@@@ -143,6 -143,7 +143,7 @@@ struct cgit_query 
        int nohead;
        char *sort;
        int showmsg;
+       int ssdiff;
  };
  
  struct cgit_config {
        int max_lock_attempts;
        int max_msg_len;
        int max_repodesc_len;
 +      int max_blob_size;
        int max_stats;
        int nocache;
        int noplainemail;
        int summary_branches;
        int summary_log;
        int summary_tags;
+       int ssdiff;
        struct string_list mimetypes;
        struct cgit_filter *about_filter;
        struct cgit_filter *commit_filter;
diff --combined cgitrc.5.txt
index e69140bbfe4553c0e131a14248cf23799a16d221,252d546401d32ca93148df31e5328054da3eeb2a..70e4c78417992d3bdeb8fb6ba828cc59914f5983
@@@ -1,6 -1,3 +1,6 @@@
 +:man source:   cgit
 +:man manual:   cgit
 +
  CGITRC(5)
  ========
  
@@@ -177,10 -174,6 +177,10 @@@ max-repodesc-length:
        Specifies the maximum number of repo description characters to display
        on the repository index page. Default value: "80".
  
 +max-blob-size::
 +      Specifies the maximum size of a blob to display HTML for in KBytes.
 +      Default value: "0" (limit disabled).
 +
  max-stats::
        Set the default maximum statistics period. Valid values are "week",
        "month", "quarter" and "year". If unspecified, statistics are
@@@ -245,6 -238,10 +245,10 @@@ section:
        after this option will inherit the current section name. Default value:
        none.
  
+ side-by-side-diffs::
+       If set to "1" shows side-by-side diffs instead of unidiffs per
+       default. Default value: "0".
  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
@@@ -428,8 -425,8 +432,8 @@@ mimetype.svg=image/svg+xm
  
  ##
  ## List of repositories.
 -## PS: Any repositories listed when repo.group is unset will not be
 -##     displayed under a group heading
 +## PS: Any repositories listed when section is unset will not be
 +##     displayed under a section heading
  ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos')
  ##      and included like this:
  ##        include=/etc/cgitrepos
@@@ -451,7 -448,7 +455,7 @@@ repo.readme=info/web/about.htm
  
  
  # The next repositories will be displayed under the 'extras' heading
 -repo.group=extras
 +section=extras
  
  
  repo.url=baz
@@@ -464,7 -461,7 +468,7 @@@ repo.desc=the wizard of fo
  
  
  # Add some mirrored repositories
 -repo.group=mirrors
 +section=mirrors
  
  
  repo.url=git
diff --combined ui-shared.c
index 3a9e67b16ebeee56c05c82d08d766b33e748cc17,de55effb9b027dbaa1db0c33d9ba28c291183a1e..08ea003c2da84378189303ebe99c8fe30216dcc3
@@@ -20,7 -20,7 +20,7 @@@ static char *http_date(time_t t
                {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
        static char month[][4] =
                {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
 -               "Jul", "Aug", "Sep", "Oct", "Now", "Dec"};
 +               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
        struct tm *tm = gmtime(&t);
        return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
                   tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
@@@ -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,
@@@ -341,7 -357,8 +357,8 @@@ 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;
  
                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);
@@@ -383,7 -405,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";
@@@ -695,9 -717,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);
@@@ -760,18 -782,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/>");
        }
diff --combined ui-shared.h
index b12aa893fbe99918727d5415045e09ea8f0ef1ea,166246dc7868e038b7a05a66b8fcd55f2c5d5c96..9ebc1f955fbad9978c08a1880b81a9f461cef015
@@@ -3,7 -3,6 +3,7 @@@
  
  extern char *cgit_httpscheme();
  extern char *cgit_hosturl();
 +extern char *cgit_rooturl();
  extern char *cgit_repourl(const char *reponame);
  extern char *cgit_fileurl(const char *reponame, const char *pagename,
                          const char *filename, const char *query);
@@@ -23,7 -22,7 +23,7 @@@ extern void cgit_log_link(char *name, c
                          char *rev, char *path, int ofs, char *grep,
                          char *pattern, int showmsg);
  extern void cgit_commit_link(char *name, char *title, char *class, char *head,
-                            char *rev);
+                            char *rev, int toggle_ssdiff);
  extern void cgit_patch_link(char *name, char *title, char *class, char *head,
                            char *rev);
  extern void cgit_refs_link(char *name, char *title, char *class, char *head,
@@@ -31,7 -30,8 +31,8 @@@
  extern void cgit_snapshot_link(char *name, char *title, char *class,
                               char *head, char *rev, char *archivename);
  extern 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);
  extern void cgit_stats_link(char *name, char *title, char *class, char *head,
                            char *path);
  extern void cgit_object_link(struct object *obj);