| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | cgit.c | 25 | ||||
| -rw-r--r-- | cgit.css | 347 | ||||
| -rw-r--r-- | cgit.h | 2 | ||||
| -rw-r--r-- | cgitrc.5.txt | 13 | ||||
| -rwxr-xr-x | filters/syntax-highlighting.sh | 28 | ||||
| -rw-r--r-- | html.c | 4 | ||||
| -rw-r--r-- | parsing.c | 2 | ||||
| -rw-r--r-- | shared.c | 5 | ||||
| -rwxr-xr-x | tests/setup.sh | 5 | ||||
| -rwxr-xr-x | tests/t0108-patch.sh | 2 | ||||
| -rw-r--r-- | ui-diff.c | 17 | ||||
| -rw-r--r-- | ui-log.c | 3 | ||||
| -rw-r--r-- | ui-plain.c | 9 | ||||
| -rw-r--r-- | ui-repolist.c | 9 | ||||
| -rw-r--r-- | ui-shared.c | 86 | ||||
| -rw-r--r-- | ui-shared.h | 5 | ||||
| -rw-r--r-- | ui-ssdiff.c | 29 | ||||
| -rw-r--r-- | ui-ssdiff.h | 12 | ||||
| -rw-r--r-- | ui-tree.c | 13 |
20 files changed, 227 insertions, 393 deletions
@@ -1,4 +1,4 @@ -CGIT_VERSION = v0.9.0.3 +CGIT_VERSION = v0.9.0.1 CGIT_SCRIPT_NAME = cgit.cgi CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) @@ -13,7 +13,7 @@ pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = <openssl/sha.h> GIT_VER = 1.7.4 -GIT_URL = http://hjemli.net/git/git/snapshot/git-$(GIT_VER).tar.bz2 +GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 INSTALL = install MAN5_TXT = $(wildcard *.5.txt) MAN_TXT = $(MAN5_TXT) @@ -60,8 +60,6 @@ static void process_cached_repolist(const char *path); void repo_config(struct cgit_repo *repo, const char *name, const char *value) { - struct string_list_item *item; - if (!strcmp(name, "name")) repo->name = xstrdup(value); else if (!strcmp(name, "clone-url")) @@ -88,10 +86,7 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) repo->max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "module-link")) repo->module_link= xstrdup(value); - else if (!prefixcmp(name, "module-link.")) { - item = string_list_append(&repo->submodules, name + 12); - item->util = xstrdup(value); - } else if (!strcmp(name, "section")) + else if (!strcmp(name, "section")) repo->section = xstrdup(value); else if (!strcmp(name, "readme") && value != NULL) repo->readme = xstrdup(value); @@ -305,7 +300,6 @@ static void querystring_cb(const char *name, const char *value) ctx.qry.period = xstrdup(value); } else if (!strcmp(name, "ss")) { ctx.qry.ssdiff = atoi(value); - ctx.qry.has_ssdiff = 1; } else if (!strcmp(name, "all")) { ctx.qry.show_all = atoi(value); } else if (!strcmp(name, "context")) { @@ -346,6 +340,7 @@ static void prepare_context(struct cgit_context *ctx) 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.project_list = NULL; ctx->cfg.renamelimit = -1; ctx->cfg.remove_suffix = 0; @@ -423,17 +418,6 @@ char *find_default_branch(struct cgit_repo *repo) return ref; } -static char *guess_defbranch(const char *repo_path) -{ - const char *ref; - unsigned char sha1[20]; - - ref = resolve_ref("HEAD", sha1, 0, NULL); - if (!ref || prefixcmp(ref, "refs/heads/")) - return "master"; - return xstrdup(ref + 11); -} - static int prepare_repo_cmd(struct cgit_context *ctx) { char *tmp; @@ -460,12 +444,10 @@ static int prepare_repo_cmd(struct cgit_context *ctx) } ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); - if (!ctx->repo->defbranch) - ctx->repo->defbranch = guess_defbranch(ctx->repo->path); - if (!ctx->qry.head) { ctx->qry.nohead = 1; ctx->qry.head = find_default_branch(ctx->repo); + ctx->repo->defbranch = ctx->qry.head; } if (!ctx->qry.head) { @@ -489,7 +471,6 @@ static int prepare_repo_cmd(struct cgit_context *ctx) cgit_print_docend(); return 1; } - sort_string_list(&ctx->repo->submodules); cgit_prepare_repo_env(ctx->repo); return 0; } @@ -1,4 +1,4 @@ -body, div#cgit table, div#cgit form { +body, table, form { padding: 0em; margin: 0em; } @@ -11,40 +11,39 @@ body { padding: 4px; } -div#cgit a { +a { color: blue; text-decoration: none; } -div#cgit a:hover { +a:hover { text-decoration: underline; } -div#cgit table { +table { border-collapse: collapse; } -div#cgit table#header { +table#header { width: 100%; margin-bottom: 1em; } -div#cgit table#header td.logo { +table#header td.logo { width: 96px; - vertical-align: top; } -div#cgit table#header td.main { +table#header td.main { font-size: 250%; padding-left: 10px; white-space: nowrap; } -div#cgit table#header td.main a { +table#header td.main a { color: #000; } -div#cgit table#header td.form { +table#header td.form { text-align: right; vertical-align: bottom; padding-right: 1em; @@ -52,19 +51,19 @@ div#cgit table#header td.form { white-space: nowrap; } -div#cgit table#header td.form form, -div#cgit table#header td.form input, -div#cgit table#header td.form select { +table#header td.form form, +table#header td.form input, +table#header td.form select { font-size: 90%; } -div#cgit table#header td.sub { +table#header td.sub { color: #777; border-top: solid 1px #ccc; padding-left: 10px; } -div#cgit table.tabs { +table.tabs { border-bottom: solid 3px #ccc; border-collapse: collapse; margin-top: 2em; @@ -72,74 +71,74 @@ div#cgit table.tabs { width: 100%; } -div#cgit table.tabs td { +table.tabs td { padding: 0px 1em; vertical-align: bottom; } -div#cgit table.tabs td a { +table.tabs td a { padding: 2px 0.75em; color: #777; font-size: 110%; } -div#cgit table.tabs td a.active { +table.tabs td a.active { color: #000; background-color: #ccc; } -div#cgit table.tabs td.form { +table.tabs td.form { text-align: right; } -div#cgit table.tabs td.form form { +table.tabs td.form form { padding-bottom: 2px; font-size: 90%; white-space: nowrap; } -div#cgit table.tabs td.form input, -div#cgit table.tabs td.form select { +table.tabs td.form input, +table.tabs td.form select { font-size: 90%; } -div#cgit div.path { +div.path { margin: 0px; padding: 5px 2em 2px 2em; color: #000; background-color: #eee; } -div#cgit div.content { +div.content { margin: 0px; padding: 2em; border-bottom: solid 3px #ccc; } -div#cgit table.list { +table.list { width: 100%; border: none; border-collapse: collapse; } -div#cgit table.list tr { +table.list tr { background: white; } -div#cgit table.list tr.logheader { +table.list tr.logheader { background: #eee; } -div#cgit table.list tr:hover { +table.list tr:hover { background: #eee; } -div#cgit table.list tr.nohover:hover { +table.list tr.nohover:hover { background: white; } -div#cgit table.list th { +table.list th { font-weight: bold; /* color: #888; border-top: dashed 1px #888; @@ -149,93 +148,93 @@ div#cgit table.list th { vertical-align: baseline; } -div#cgit table.list td { +table.list td { border: none; padding: 0.1em 0.5em 0.1em 0.5em; } -div#cgit table.list td.commitgraph { +table.list td.commitgraph { font-family: monospace; white-space: pre; } -div#cgit table.list td.commitgraph .column1 { +table.list td.commitgraph .column1 { color: #a00; } -div#cgit table.list td.commitgraph .column2 { +table.list td.commitgraph .column2 { color: #0a0; } -div#cgit table.list td.commitgraph .column3 { +table.list td.commitgraph .column3 { color: #aa0; } -div#cgit table.list td.commitgraph .column4 { +table.list td.commitgraph .column4 { color: #00a; } -div#cgit table.list td.commitgraph .column5 { +table.list td.commitgraph .column5 { color: #a0a; } -div#cgit table.list td.commitgraph .column6 { +table.list td.commitgraph .column6 { color: #0aa; } -div#cgit table.list td.logsubject { +table.list td.logsubject { font-family: monospace; font-weight: bold; } -div#cgit table.list td.logmsg { +table.list td.logmsg { font-family: monospace; white-space: pre; padding: 0 0.5em; } -div#cgit table.list td a { +table.list td a { color: black; } -div#cgit table.list td a.ls-dir { +table.list td a.ls-dir { font-weight: bold; color: #00f; } -div#cgit table.list td a:hover { +table.list td a:hover { color: #00f; } -div#cgit img { +img { border: none; } -div#cgit input#switch-btn { +input#switch-btn { margin: 2px 0px 0px 0px; } -div#cgit td#sidebar input.txt { +td#sidebar input.txt { width: 100%; margin: 2px 0px 0px 0px; } -div#cgit table#grid { +table#grid { margin: 0px; } -div#cgit td#content { +td#content { vertical-align: top; padding: 1em 2em 1em 1em; border: none; } -div#cgit div#summary { +div#summary { vertical-align: top; margin-bottom: 1em; } -div#cgit table#downloads { +table#downloads { float: right; border-collapse: collapse; border: solid 1px #777; @@ -243,152 +242,152 @@ div#cgit table#downloads { margin-bottom: 0.5em; } -div#cgit table#downloads th { +table#downloads th { background-color: #ccc; } -div#cgit div#blob { +div#blob { border: solid 1px black; } -div#cgit div.error { +div.error { color: red; font-weight: bold; margin: 1em 2em; } -div#cgit a.ls-blob, div#cgit a.ls-dir, div#cgit a.ls-mod { +a.ls-blob, a.ls-dir, a.ls-mod { font-family: monospace; } -div#cgit td.ls-size { +td.ls-size { text-align: right; font-family: monospace; width: 10em; } -div#cgit td.ls-mode { +td.ls-mode { font-family: monospace; width: 10em; } -div#cgit table.blob { +table.blob { margin-top: 0.5em; border-top: solid 1px black; } -div#cgit table.blob td.lines { +table.blob td.lines { margin: 0; padding: 0 0 0 0.5em; vertical-align: top; color: black; } -div#cgit table.blob td.linenumbers { +table.blob td.linenumbers { margin: 0; padding: 0 0.5em 0 0.5em; vertical-align: top; text-align: right; border-right: 1px solid gray; } -div#cgit table.blob pre { +table.blob pre { padding: 0; margin: 0; } -div#cgit table.blob a.no, div#cgit table.ssdiff a.no { +table.blob a.no, table.ssdiff a.no { color: gray; text-align: right; text-decoration: none; } -div#cgit table.blob a.no a:hover { +table.blob a.no a:hover { color: black; } -div#cgit table.bin-blob { +table.bin-blob { margin-top: 0.5em; border: solid 1px black; } -div#cgit table.bin-blob th { +table.bin-blob th { font-family: monospace; white-space: pre; border: solid 1px #777; padding: 0.5em 1em; } -div#cgit table.bin-blob td { +table.bin-blob td { font-family: monospace; white-space: pre; border-left: solid 1px #777; padding: 0em 1em; } -div#cgit table.nowrap td { +table.nowrap td { white-space: nowrap; } -div#cgit table.commit-info { +table.commit-info { border-collapse: collapse; margin-top: 1.5em; } -div#cgit div.cgit-panel { +div.cgit-panel { float: right; margin-top: 1.5em; } -div#cgit div.cgit-panel table { +div.cgit-panel table { border-collapse: collapse; border: solid 1px #aaa; background-color: #eee; } -div#cgit div.cgit-panel th { +div.cgit-panel th { text-align: center; } -div#cgit div.cgit-panel td { +div.cgit-panel td { padding: 0.25em 0.5em; } -div#cgit div.cgit-panel td.label { +div.cgit-panel td.label { padding-right: 0.5em; } -div#cgit div.cgit-panel td.ctrl { +div.cgit-panel td.ctrl { padding-left: 0.5em; } -div#cgit table.commit-info th { +table.commit-info th { text-align: left; font-weight: normal; padding: 0.1em 1em 0.1em 0.1em; vertical-align: top; } -div#cgit table.commit-info td { +table.commit-info td { font-weight: normal; padding: 0.1em 1em 0.1em 0.1em; } -div#cgit div.commit-subject { +div.commit-subject { font-weight: bold; font-size: 125%; margin: 1.5em 0em 0.5em 0em; padding: 0em; } -div#cgit div.commit-msg { +div.commit-msg { white-space: pre; font-family: monospace; } -div#cgit div.notes-header { +div.notes-header { font-weight: bold; padding-top: 1.5em; } -div#cgit div.notes { +div.notes { white-space: pre; font-family: monospace; border: solid 1px #ee9; @@ -397,22 +396,22 @@ div#cgit div.notes { float: left; } -div#cgit div.notes-footer { +div.notes-footer { clear: left; } -div#cgit div.diffstat-header { +div.diffstat-header { font-weight: bold; padding-top: 1.5em; } -div#cgit table.diffstat { +table.diffstat { border-collapse: collapse; border: solid 1px #aaa; background-color: #eee; } -div#cgit table.diffstat th { +table.diffstat th { font-weight: normal; text-align: left; text-decoration: underline; @@ -420,286 +419,282 @@ div#cgit table.diffstat th { font-size: 100%; } -div#cgit table.diffstat td { +table.diffstat td { padding: 0.2em 0.2em 0.1em 0.1em; font-size: 100%; border: none; } -div#cgit table.diffstat td.mode { +table.diffstat td.mode { white-space: nowrap; } -div#cgit table.diffstat td span.modechange { +table.diffstat td span.modechange { padding-left: 1em; color: red; } -div#cgit table.diffstat td.add a { +table.diffstat td.add a { color: green; } -div#cgit table.diffstat td.del a { +table.diffstat td.del a { color: red; } -div#cgit table.diffstat td.upd a { +table.diffstat td.upd a { color: blue; } -div#cgit table.diffstat td.graph { +table.diffstat td.graph { width: 500px; vertical-align: middle; } -div#cgit table.diffstat td.graph table { +table.diffstat td.graph table { border: none; } -div#cgit table.diffstat td.graph td { +table.diffstat td.graph td { padding: 0px; border: 0px; height: 7pt; } -div#cgit table.diffstat td.graph td.add { +table.diffstat td.graph td.add { background-color: #5c5; } -div#cgit table.diffstat td.graph td.rem { +table.diffstat td.graph td.rem { background-color: #c55; } -div#cgit div.diffstat-summary { +div.diffstat-summary { color: #888; padding-top: 0.5em; } -div#cgit table.diff { +table.diff { width: 100%; } -div#cgit table.diff td { +table.diff td { font-family: monospace; white-space: pre; } -div#cgit table.diff td div.head { +table.diff td div.head { font-weight: bold; margin-top: 1em; color: black; } -div#cgit table.diff td div.hunk { +table.diff td div.hunk { color: #009; } -div#cgit table.diff td div.add { +table.diff td div.add { color: green; } -div#cgit table.diff td div.del { +table.diff td div.del { color: red; } -div#cgit .sha1 { +.sha1 { font-family: monospace; font-size: 90%; } -div#cgit .left { +.left { text-align: left; } -div#cgit .right { +.right { text-align: right; } -div#cgit table.list td.reposection { +table.list td.reposection { font-style: italic; color: #888; } -div#cgit a.button { +a.button { font-size: 80%; padding: 0em 0.5em; } -div#cgit a.primary { +a.primary { font-size: 100%; } -div#cgit a.secondary { +a.secondary { font-size: 90%; } -div#cgit td.toplevel-repo { +td.toplevel-repo { } -div#cgit table.list td.sublevel-repo { +table.list td.sublevel-repo { padding-left: 1.5em; } -div#cgit div.pager { +div.pager { text-align: center; margin: 1em 0em 0em 0em; } -div#cgit div.pager a { +div.pager a { color: #777; margin: 0em 0.5em; } -div#cgit span.age-mins { +span.age-mins { font-weight: bold; color: #080; } -div#cgit span.age-hours { +span.age-hours { color: #080; } -div#cgit span.age-days { +span.age-days { color: #040; } -div#cgit span.age-weeks { +span.age-weeks { color: #444; } -div#cgit span.age-months { +span.age-months { color: #888; } -div#cgit span.age-years { +span.age-years { color: #bbb; } -div#cgit div.footer { +div.footer { margin-top: 0.5em; text-align: center; font-size: 80%; color: #ccc; } -div#cgit a.branch-deco { - color: #000; +a.branch-deco { margin: 0px 0.5em; padding: 0px 0.25em; background-color: #88ff88; border: solid 1px #007700; } -div#cgit a.tag-deco { - color: #000; +a.tag-deco { margin: 0px 0.5em; padding: 0px 0.25em; background-color: #ffff88; border: solid 1px #777700; } -div#cgit a.remote-deco { - color: #000; +a.remote-deco { margin: 0px 0.5em; padding: 0px 0.25em; background-color: #ccccff; border: solid 1px #000077; } -div#cgit a.deco { - color: #000; +a.deco { margin: 0px 0.5em; padding: 0px 0.25em; background-color: #ff8888; border: solid 1px #770000; } -div#cgit div.commit-subject a.branch-deco, -div#cgit div.commit-subject a.tag-deco, -div#cgit div.commit-subject a.remote-deco, -div#cgit div.commit-subject a.deco { +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%; } -div#cgit table.stats { +table.stats { border: solid 1px black; border-collapse: collapse; } -div#cgit table.stats th { +table.stats th { text-align: left; padding: 1px 0.5em; background-color: #eee; border: solid 1px black; } -div#cgit table.stats td { +table.stats td { text-align: right; padding: 1px 0.5em; border: solid 1px black; } -div#cgit table.stats td.total { +table.stats td.total { font-weight: bold; text-align: left; } -div#cgit table.stats td.sum { +table.stats td.sum { color: #c00; font-weight: bold; /* background-color: #eee; */ } -div#cgit table.stats td.left { +table.stats td.left { text-align: left; } -div#cgit table.vgraph { +table.vgraph { border-collapse: separate; border: solid 1px black; height: 200px; } -div#cgit table.vgraph th { +table.vgraph th { background-color: #eee; font-weight: bold; border: solid 1px white; padding: 1px 0.5em; } -div#cgit table.vgraph td { +table.vgraph td { vertical-align: bottom; padding: 0px 10px; } -div#cgit table.vgraph div.bar { +table.vgraph div.bar { background-color: #eee; } -div#cgit table.hgraph { +table.hgraph { border: solid 1px black; width: 800px; } -div#cgit table.hgraph th { +table.hgraph th { background-color: #eee; font-weight: bold; border: solid 1px black; padding: 1px 0.5em; } -div#cgit table.hgraph td { - vertical-align: middle; +table.hgraph td { + vertical-align: center; padding: 2px 2px; } -div#cgit table.hgraph div.bar { +table.hgraph div.bar { background-color: #eee; height: 1em; } -div#cgit table.ssdiff { +table.ssdiff { width: 100%; } -div#cgit table.ssdiff td { +table.ssdiff td { font-size: 75%; font-family: monospace; white-space: pre; @@ -708,53 +703,53 @@ div#cgit table.ssdiff td { border-right: solid 1px #aaa; } -div#cgit table.ssdiff td.add { +table.ssdiff td.add { color: black; background: #cfc; min-width: 50%; } -div#cgit table.ssdiff td.add_dark { +table.ssdiff td.add_dark { color: black; background: #aca; min-width: 50%; } -div#cgit table.ssdiff span.add { +table.ssdiff span.add { background: #cfc; font-weight: bold; } -div#cgit table.ssdiff td.del { +table.ssdiff td.del { color: black; background: #fcc; min-width: 50%; } -div#cgit table.ssdiff td.del_dark { +table.ssdiff td.del_dark { color: black; background: #caa; min-width: 50%; } -div#cgit table.ssdiff span.del { +table.ssdiff span.del { background: #fcc; font-weight: bold; } -div#cgit table.ssdiff td.changed { +table.ssdiff td.changed { color: black; background: #ffc; min-width: 50%; } -div#cgit table.ssdiff td.changed_dark { +table.ssdiff td.changed_dark { color: black; background: #cca; min-width: 50%; } -div#cgit table.ssdiff td.lineno { +table.ssdiff td.lineno { color: black; background: #eee; text-align: right; @@ -762,48 +757,48 @@ div#cgit table.ssdiff td.lineno { min-width: 3em; } -div#cgit table.ssdiff td.hunk { - color: black; +table.ssdiff td.hunk { + color: #black; background: #ccf; border-top: solid 1px #aaa; border-bottom: solid 1px #aaa; } -div#cgit table.ssdiff td.head { +table.ssdiff td.head { border-top: solid 1px #aaa; border-bottom: solid 1px #aaa; } -div#cgit table.ssdiff td.head div.head { +table.ssdiff td.head div.head { font-weight: bold; color: black; } -div#cgit table.ssdiff td.foot { +table.ssdiff td.foot { border-top: solid 1px #aaa; border-left: none; border-right: none; border-bottom: none; } -div#cgit table.ssdiff td.space { +table.ssdiff td.space { border: none; } -div#cgit table.ssdiff td.space div { +table.ssdiff td.space div { min-height: 3em; } /* Syntax highlighting */ -div#cgit table.blob .num { color:#2928ff; } -div#cgit table.blob .esc { color:#ff00ff; } -div#cgit table.blob .str { color:#ff0000; } -div#cgit table.blob .dstr { color:#818100; } -div#cgit table.blob .slc { color:#838183; font-style:italic; } -div#cgit table.blob .com { color:#838183; font-style:italic; } -div#cgit table.blob .dir { color:#008200; } -div#cgit table.blob .sym { color:#000000; } -div#cgit table.blob .kwa { color:#000000; font-weight:bold; } -div#cgit table.blob .kwb { color:#830000; } -div#cgit table.blob .kwc { color:#000000; font-weight:bold; } -div#cgit table.blob .kwd { color:#010181; } +table.blob .num { color:#2928ff; } +table.blob .esc { color:#ff00ff; } +table.blob .str { color:#ff0000; } +table.blob .dstr { color:#818100; } +table.blob .slc { color:#838183; font-style:italic; } +table.blob .com { color:#838183; font-style:italic; } +table.blob .dir { color:#008200; } +table.blob .sym { color:#000000; } +table.blob .kwa { color:#000000; font-weight:bold; } +table.blob .kwb { color:#830000; } +table.blob .kwc { color:#000000; font-weight:bold; } +table.blob .kwd { color:#010181; } @@ -88,7 +88,6 @@ struct cgit_repo { struct cgit_filter *about_filter; struct cgit_filter *commit_filter; struct cgit_filter *source_filter; - struct string_list submodules; }; typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name, @@ -138,7 +137,6 @@ struct reflist { struct cgit_query { int has_symref; int has_sha1; - int has_ssdiff; char *raw; char *repo; char *page; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a72241f..22a0dc3 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -241,7 +241,7 @@ module-link:: Text which will be used as the formatstring for a hyperlink when a submodule is printed in a directory listing. The arguments for the formatstring are the path and SHA1 of the submodule commit. Default - value: none. + value: "./?repo=%s&page=commit&id=%s" nocache:: If set to the value "1" caching will be disabled. This settings is @@ -388,8 +388,7 @@ repo.commit-filter:: repo.defbranch:: The name of the default branch for this repository. If no such branch exists in the repository, the first branch name (when sorted) is used - as default instead. Default value: branch pointed to by HEAD, or - "master" if there is no suitable HEAD. + as default instead. Default value: "master". repo.desc:: The value to show as repository description. Default value: none. @@ -429,12 +428,6 @@ repo.module-link:: formatstring are the path and SHA1 of the submodule commit. Default value: <module-link> -repo.module-link.<path>:: - Text which will be used as the formatstring for a hyperlink when a - submodule with the specified subdirectory path is printed in a - directory listing. The only argument for the formatstring is the SHA1 - of the submodule commit. 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 @@ -518,7 +511,7 @@ Also, all filters are handed the following environment variables: If a setting is not defined for a repository and the corresponding global setting is also not defined (if applicable), then the corresponding -environment variable will be unset. +environment variable will be an empty string. MACRO EXPANSION diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 5fcc9c9..6283ce9 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh @@ -42,32 +42,4 @@ EXTENSION="${BASENAME##*.}" # map Makefile and Makefile.* to .mk [ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk -# highlight versions 2 and 3 have different commandline options. Specifically, -# the -X option that is used for version 2 is replaced by the -O xhtml option -# for version 3. -# -# Version 2 can be found (for example) on EPEL 5, while version 3 can be -# found (for example) on EPEL 6. -# -# This is for version 2 exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null - -# This is for version 3 -# -# On CentOS 6.2 (using highlight from EPEL), when highlight doesn't know about -# an EXTENSION, it outputs a lua error and _no_ text, even when the --force -# option is used. -# -# Also see the bug reports at: -# http://sourceforge.net/tracker/?func=detail&aid=3490017&group_id=215618&atid=1034391 -# https://bugzilla.redhat.com/show_bug.cgi?id=795567 -# -# This workaround can be removed when the bug is fixed upstream and the new -# version is packaged in most distributions. -# -# The workaround is to set the extension to 'txt' (plain text) when highlight -# exits with an error (doesn't know the format). -# -#echo "test" | highlight -f -I -O xhtml -S $EXTENSION &>/dev/null -#[ ${?} -ne 0 ] && EXTENSION="txt" -#exec highlight --force -f -I -O xhtml -S $EXTENSION 2>/dev/null @@ -162,7 +162,7 @@ void html_url_path(const char *txt) { const char *t = txt; while(t && *t){ - unsigned char c = *t; + int c = *t; const char *e = url_escape_table[c]; if (e && c!='+' && c!='&') { html_raw(txt, t - txt); @@ -179,7 +179,7 @@ void html_url_arg(const char *txt) { const char *t = txt; while(t && *t){ - unsigned char c = *t; + int c = *t; const char *e = url_escape_table[c]; if (c == ' ') e = "+"; @@ -125,7 +125,7 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc) struct commitinfo *cgit_parse_commit(struct commit *commit) { struct commitinfo *ret; - char *p = commit->buffer, *t; + char *p = commit->buffer, *t = commit->buffer; ret = xmalloc(sizeof(*ret)); ret->commit = commit; @@ -8,6 +8,7 @@ #include "cgit.h" #include <stdio.h> +#include <linux/limits.h> struct cgit_repolist cgit_repolist; struct cgit_context ctx; @@ -55,6 +56,7 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->desc = "[no description]"; ret->owner = NULL; ret->section = ctx.cfg.section; + ret->defbranch = "master"; ret->snapshots = ctx.cfg.snapshots; ret->enable_commit_graph = ctx.cfg.enable_commit_graph; ret->enable_log_filecount = ctx.cfg.enable_log_filecount; @@ -69,7 +71,6 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->commit_filter = ctx.cfg.commit_filter; ret->source_filter = ctx.cfg.source_filter; ret->clone_url = ctx.cfg.clone_url; - ret->submodules.strdup_strings = 1; return ret; } @@ -392,7 +393,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo) p = env_vars; q = p + env_var_count; for (; p < q; p++) - if (p->value && setenv(p->name, p->value, 1)) + if (setenv(p->name, p->value, 1)) fprintf(stderr, warn, p->name, p->value); } diff --git a/tests/setup.sh b/tests/setup.sh index e3c6c17..1e06107 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -15,14 +15,13 @@ # run_test 'repo index' 'cgit_url "/" | tidy -e' # run_test 'repo summary' 'cgit_url "/foo" | tidy -e' -unset CDPATH mkrepo() { name=$1 count=$2 dir=$PWD test -d "$name" && return - printf "Creating testrepo %s\n" "$name" + printf "Creating testrepo %s\n" $name mkdir -p "$name" cd "$name" git init @@ -41,7 +40,7 @@ mkrepo() { git commit -m "add a+b" git branch "1+2" fi - cd "$dir" + cd $dir } setup_repos() diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh index 6ee70b3..e608104 100755 --- a/tests/t0108-patch.sh +++ b/tests/t0108-patch.sh @@ -25,7 +25,7 @@ run_test 'find `cgit` signature' ' ' run_test 'find initial commit' ' - root=$(git --git-dir="$PWD/trash/repos/foo/.git" rev-list HEAD | tail -1) + root=$(git --git-dir=$PWD/trash/repos/foo/.git rev-list HEAD | tail -1) ' run_test 'generate patch for initial commit' ' @@ -97,12 +97,10 @@ static void print_fileinfo(struct fileinfo *info) htmlf("</td><td class='%s'>", class); cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, ctx.qry.sha2, info->new_path, 0); - if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) { - htmlf(" (%s from ", - info->status == DIFF_STATUS_COPIED ? "copied" : "renamed"); - html_txt(info->old_path); - html(")"); - } + if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) + htmlf(" (%s from %s)", + info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", + info->old_path); html("</td><td class='right'>"); if (info->binary) { htmlf("bin</td><td class='graph'>%ld -> %ld bytes", @@ -341,7 +339,9 @@ void cgit_print_diff_ctrls() html("<td class='label'>mode:</td>"); html("<td class='ctrl'>"); html("<select name='ss' onchange='this.form.submit();'>"); - curr = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff; + curr = ctx.qry.ssdiff; + if (!curr && ctx.cfg.ssdiff) + curr = 1; html_intoption(0, "unified", curr); html_intoption(1, "ssdiff", curr); html("</select></td></tr>"); @@ -393,7 +393,8 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, } } - use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff; + if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) + use_ssdiff = 1; if (show_ctrls) cgit_print_diff_ctrls(); @@ -76,8 +76,6 @@ void show_commit_decorations(struct commit *commit) cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); } else if (!prefixcmp(deco->name, "refs/remotes/")) { - if (!ctx.repo->enable_remote_branches) - goto next; strncpy(buf, deco->name + 13, sizeof(buf) - 1); cgit_log_link(buf, NULL, "remote-deco", NULL, sha1_to_hex(commit->object.sha1), @@ -90,7 +88,6 @@ void show_commit_decorations(struct commit *commit) sha1_to_hex(commit->object.sha1), ctx.qry.vpath, 0); } -next: deco = deco->next; } } @@ -147,14 +147,11 @@ static void print_dir_entry(const unsigned char *sha1, const char *base, char *fullpath; fullpath = buildpath(base, baselen, path); - if (!S_ISDIR(mode) && !S_ISGITLINK(mode)) + if (!S_ISDIR(mode)) fullpath[strlen(fullpath) - 1] = 0; html(" <li>"); - if (S_ISGITLINK(mode)) { - cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1)); - } else - cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, - fullpath); + cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, + fullpath); html("</li>\n"); match = 2; } diff --git a/ui-repolist.c b/ui-repolist.c index d946f32..25c36ce 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -45,8 +45,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime) return 1; } - path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch ? - repo->defbranch : "master"); + path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); if (stat(path, &s) == 0) { *mtime = s.st_mtime; r->mtime = *mtime; @@ -119,13 +118,13 @@ void print_header(int columns) } -void print_pager(int items, int pagelen, char *search, char *sort) +void print_pager(int items, int pagelen, char *search) { int i; html("<div class='pager'>"); for(i = 0; i * pagelen < items; i++) cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, - search, sort, i * pagelen); + search, i * pagelen); html("</div>"); } @@ -292,7 +291,7 @@ void cgit_print_repolist() if (!hits) cgit_print_error("No repositories found"); else if (hits > ctx.cfg.max_repo_count) - print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort); + print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search); cgit_print_docend(); } diff --git a/ui-shared.c b/ui-shared.c index 43166af..5aa9119 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -133,7 +133,7 @@ char *cgit_currurl() return fmt("%s/", ctx.cfg.virtual_root); } -static void site_url(const char *page, const char *search, const char *sort, int ofs) +static void site_url(const char *page, const char *search, int ofs) { char *delim = "?"; @@ -154,12 +154,6 @@ static void site_url(const char *page, const char *search, const char *sort, int html_attr(search); delim = "&"; } - if (sort) { - html(delim); - html("s="); - html_attr(sort); - delim = "&"; - } if (ofs) { html(delim); htmlf("ofs=%d", ofs); @@ -167,7 +161,7 @@ static void site_url(const char *page, const char *search, const char *sort, int } static void site_link(const char *page, const char *name, const char *title, - const char *class, const char *search, const char *sort, int ofs) + const char *class, const char *search, int ofs) { html("<a"); if (title) { @@ -181,16 +175,16 @@ static void site_link(const char *page, const char *name, const char *title, html("'"); } html(" href='"); - site_url(page, search, sort, ofs); + site_url(page, search, ofs); html("'>"); html_txt(name); html("</a>"); } void cgit_index_link(const char *name, const char *title, const char *class, - const char *pattern, const char *sort, int ofs) + const char *pattern, int ofs) { - site_link(NULL, name, title, class, pattern, sort, ofs); + site_link(NULL, name, title, class, pattern, ofs); } static char *repolink(const char *title, const char *class, const char *page, @@ -294,7 +288,7 @@ void cgit_log_link(const char *name, const char *title, const char *class, char *delim; delim = repolink(title, class, "log", head, path); - if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) { + if (rev && strcmp(rev, ctx.qry.head)) { html(delim); html("id="); html_url_arg(rev); @@ -338,7 +332,7 @@ void cgit_commit_link(char *name, const char *title, const char *class, char *delim; delim = repolink(title, class, "commit", head, path); - if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) { + if (rev && strcmp(rev, ctx.qry.head)) { html(delim); html("id="); html_url_arg(rev); @@ -434,7 +428,7 @@ void cgit_self_link(char *name, const char *title, const char *class, struct cgit_context *ctx) { if (!strcmp(ctx->qry.page, "repolist")) - return cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort, + return cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.ofs); else if (!strcmp(ctx->qry.page, "summary")) return cgit_summary_link(name, title, class, ctx->qry.head); @@ -509,62 +503,6 @@ void cgit_object_link(struct object *obj) reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); } -struct string_list_item *lookup_path(struct string_list *list, - const char *path) -{ - struct string_list_item *item; - - while (path && path[0]) { - if ((item = string_list_lookup(list, path))) - return item; - if (!(path = strchr(path, '/'))) - break; - path++; - } - return NULL; -} - -void cgit_submodule_link(const char *class, char *path, const char *rev) -{ - struct string_list *list; - struct string_list_item *item; - char tail, *dir; - size_t len; - - tail = 0; - list = &ctx.repo->submodules; - item = lookup_path(list, path); - if (!item) { - len = strlen(path); - tail = path[len - 1]; - if (tail == '/') { - path[len - 1] = 0; - item = lookup_path(list, path); - } - } - html("<a "); - if (class) - htmlf("class='%s' ", class); - html("href='"); - if (item) { - html_attr(fmt(item->util, rev)); - } else if (ctx.repo->module_link) { - dir = strrchr(path, '/'); - if (dir) - dir++; - else - dir = path; - html_attr(fmt(ctx.repo->module_link, dir, rev)); - } else { - html("#"); - } - html("'>"); - html_txt(path); - html("</a>"); - if (item && tail) - path[len - 1] = tail; -} - void cgit_print_date(time_t secs, const char *format, int local_time) { char buf[64]; @@ -675,7 +613,7 @@ void cgit_print_docstart(struct cgit_context *ctx) html_attr(ctx->cfg.favicon); html("'/>\n"); } - if (host && ctx->repo && ctx->qry.head) { + if (host && ctx->repo) { html("<link rel='alternate' title='Atom feed' href='"); html(cgit_httpscheme()); html_attr(cgit_hosturl()); @@ -844,7 +782,7 @@ static void print_header(struct cgit_context *ctx) html("<td class='main'>"); if (ctx->repo) { - cgit_index_link("index", NULL, NULL, NULL, NULL, 0); + cgit_index_link("index", NULL, NULL, NULL, 0); html(" : "); cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); html("</td><td class='form'>"); @@ -920,10 +858,10 @@ void cgit_print_pageheader(struct cgit_context *ctx) html("<input type='submit' value='search'/>\n"); html("</form>\n"); } else { - site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, NULL, 0); + site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0); if (ctx->cfg.root_readme) site_link("about", "about", NULL, hc(ctx, "about"), - NULL, NULL, 0); + NULL, 0); html("</td><td class='form'>"); html("<form method='get' action='"); html_attr(cgit_rooturl()); diff --git a/ui-shared.h b/ui-shared.h index 87a7dac..3cc1258 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -11,7 +11,7 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query); extern void cgit_index_link(const char *name, const char *title, - const char *class, const char *pattern, const char *sort, int ofs); + const char *class, const char *pattern, int ofs); extern void cgit_summary_link(const char *name, const char *title, const char *class, const char *head); extern void cgit_tag_link(const char *name, const char *title, @@ -51,9 +51,6 @@ extern void cgit_self_link(char *name, const char *title, const char *class, struct cgit_context *ctx); extern void cgit_object_link(struct object *obj); -extern void cgit_submodule_link(const char *class, char *path, - const char *rev); - extern void cgit_print_error(const char *msg); extern void cgit_print_date(time_t secs, const char *format, int local_time); extern void cgit_print_age(time_t t, time_t max_relative, const char *format); diff --git a/ui-ssdiff.c b/ui-ssdiff.c index 0cff4b8..2481585 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -2,12 +2,10 @@ #include "html.h" #include "ui-shared.h" #include "ui-diff.h" -#include "ui-ssdiff.h" extern int use_ssdiff; static int current_old_line, current_new_line; -static int **L = NULL; struct deferred_lines { int line_no; @@ -18,40 +16,16 @@ struct deferred_lines { static struct deferred_lines *deferred_old, *deferred_old_last; static struct deferred_lines *deferred_new, *deferred_new_last; -static void create_or_reset_lcs_table() -{ - int i; - - if (L != NULL) { - memset(*L, 0, sizeof(int) * MAX_SSDIFF_SIZE); - return; - } - - // xcalloc will die if we ran out of memory; - // not very helpful for debugging - L = (int**)xcalloc(MAX_SSDIFF_M, sizeof(int *)); - *L = (int*)xcalloc(MAX_SSDIFF_SIZE, sizeof(int)); - - for (i = 1; i < MAX_SSDIFF_M; i++) { - L[i] = *L + i * MAX_SSDIFF_N; - } -} - static char *longest_common_subsequence(char *A, char *B) { int i, j, ri; int m = strlen(A); int n = strlen(B); + int L[m + 1][n + 1]; int tmp1, tmp2; int lcs_length; char *result; - // We bail if the lines are too long - if (m >= MAX_SSDIFF_M || n >= MAX_SSDIFF_N) - return NULL; - - create_or_reset_lcs_table(); - for (i = m; i >= 0; i--) { for (j = n; j >= 0; j--) { if (A[i] == '\0' || B[j] == '\0') { @@ -85,7 +59,6 @@ static char *longest_common_subsequence(char *A, char *B) j += 1; } } - return result; } diff --git a/ui-ssdiff.h b/ui-ssdiff.h index 88627e2..64b4b12 100644 --- a/ui-ssdiff.h +++ b/ui-ssdiff.h @@ -1,18 +1,6 @@ #ifndef UI_SSDIFF_H #define UI_SSDIFF_H -/* - * ssdiff line limits - */ -#ifndef MAX_SSDIFF_M -#define MAX_SSDIFF_M 128 -#endif - -#ifndef MAX_SSDIFF_N -#define MAX_SSDIFF_N 128 -#endif -#define MAX_SSDIFF_SIZE ((MAX_SSDIFF_M) * (MAX_SSDIFF_N)) - extern void cgit_ssdiff_print_deferred_lines(); extern void cgit_ssdiff_line_cb(char *line, int len); @@ -150,7 +150,13 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, cgit_print_filemode(mode); html("</td><td>"); if (S_ISGITLINK(mode)) { - cgit_submodule_link("ls-mod", fullpath, sha1_to_hex(sha1)); + htmlf("<a class='ls-mod' href='"); + html_attr(fmt(ctx.repo->module_link, + name, + sha1_to_hex(sha1))); + html("'>"); + html_txt(name); + html("</a>"); } else if (S_ISDIR(mode)) { cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, curr_rev, fullpath); @@ -171,9 +177,8 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, if (ctx.repo->max_stats) cgit_stats_link("stats", NULL, "button", ctx.qry.head, fullpath); - if (!S_ISGITLINK(mode)) - cgit_plain_link("plain", NULL, "button", ctx.qry.head, curr_rev, - fullpath); + cgit_plain_link("plain", NULL, "button", ctx.qry.head, curr_rev, + fullpath); html("</td></tr>\n"); free(name); return 0; |