From: Lars Hjemli Date: Tue, 8 Dec 2009 18:32:48 +0000 (+0100) Subject: Merge branch 'ro/ssdiff' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/f4f6210b4f9c214dc247567bbd06b1135c9ecd06?hp=-c Merge branch 'ro/ssdiff' --- f4f6210b4f9c214dc247567bbd06b1135c9ecd06 diff --combined Makefile index 4e101d3,cb7875e..f8a4d47 --- a/Makefile +++ 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 08cb5d2,ff678fb..4f68a4b --- a/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")) @@@ -184,6 -182,8 +184,8 @@@ 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")) { @@@ -242,6 -240,8 +244,8 @@@ 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; @@@ -284,6 -283,7 +288,7 @@@ 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 ef7d3c1,9e6d2a4..0cb894a --- a/cgit.css +++ 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 39853df,b7b0adb..5941ec0 --- a/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 { @@@ -185,7 -186,6 +186,7 @@@ int max_lock_attempts; int max_msg_len; int max_repodesc_len; + int max_blob_size; int max_stats; int nocache; int noplainemail; @@@ -195,6 -195,7 +196,7 @@@ 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 e69140b,252d546..70e4c78 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@@ -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 3a9e67b,de55eff..08ea003 --- a/ui-shared.c +++ b/ui-shared.c @@@ -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'; @@@ -325,7 -325,23 +325,23 @@@ 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 = "&"; + } + if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { + html(delim); + html("ss=1"); + } + html("'>"); + html_txt(name); + html(""); } 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; @@@ -356,6 -373,11 +373,11 @@@ html(delim); html("id2="); html_url_arg(old_rev); + delim = "&"; + } + 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("
"); } diff --combined ui-shared.h index b12aa89,166246d..9ebc1f9 --- a/ui-shared.h +++ b/ui-shared.h @@@ -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);