diff options
author | Florian Pritz <bluewind@xinu.at> | 2020-01-17 15:26:09 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2020-01-17 15:26:09 +0100 |
commit | 6c66430e9658616e118d10af9c9ab48858a04e67 (patch) | |
tree | 2e83a411ed158f151df085c7f3836827753aecf7 | |
parent | 42f8840323a219d3eca59a7a2a388c3a28eeb8fb (diff) | |
parent | fa146ccabdd0de746a7076f0630af550e43d9088 (diff) | |
download | cgit-6c66430e9658616e118d10af9c9ab48858a04e67.tar.gz cgit-6c66430e9658616e118d10af9c9ab48858a04e67.tar.xz |
Merge tag 'v1.2.2' into local
CGIT v1.2.2
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | cgit.c | 25 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | cmd.c | 2 | ||||
-rw-r--r-- | filters/email-gravatar.lua | 17 | ||||
-rw-r--r-- | filters/email-libravatar.lua | 17 | ||||
-rw-r--r-- | filters/file-authentication.lua | 31 | ||||
-rw-r--r-- | filters/gentoo-ldap-authentication.lua | 31 | ||||
-rwxr-xr-x | filters/html-converters/md2html | 17 | ||||
-rw-r--r-- | filters/simple-authentication.lua | 31 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | parsing.c | 7 | ||||
-rw-r--r-- | shared.c | 5 | ||||
-rwxr-xr-x | tests/t0001-validate-git-versions.sh | 2 | ||||
-rwxr-xr-x | tests/t0109-gitconfig.sh | 6 | ||||
-rw-r--r-- | ui-atom.c | 4 | ||||
-rw-r--r-- | ui-atom.h | 2 | ||||
-rw-r--r-- | ui-blame.c | 7 | ||||
-rw-r--r-- | ui-blob.c | 13 | ||||
-rw-r--r-- | ui-clone.c | 4 | ||||
-rw-r--r-- | ui-commit.c | 4 | ||||
-rw-r--r-- | ui-diff.c | 6 | ||||
-rw-r--r-- | ui-log.c | 10 | ||||
-rw-r--r-- | ui-log.h | 2 | ||||
-rw-r--r-- | ui-patch.c | 11 | ||||
-rw-r--r-- | ui-plain.c | 5 | ||||
-rw-r--r-- | ui-refs.c | 2 | ||||
-rw-r--r-- | ui-repolist.c | 4 | ||||
-rw-r--r-- | ui-shared.c | 71 | ||||
-rw-r--r-- | ui-shared.h | 1 | ||||
-rw-r--r-- | ui-snapshot.c | 5 | ||||
-rw-r--r-- | ui-ssdiff.c | 23 | ||||
-rw-r--r-- | ui-stats.c | 2 | ||||
-rw-r--r-- | ui-summary.c | 2 | ||||
-rw-r--r-- | ui-summary.h | 2 | ||||
-rw-r--r-- | ui-tag.c | 8 | ||||
-rw-r--r-- | ui-tree.c | 22 |
38 files changed, 263 insertions, 152 deletions
@@ -1,6 +1,6 @@ all:: -CGIT_VERSION = v1.2.1 +CGIT_VERSION = v1.2.2 CGIT_SCRIPT_NAME = cgit.cgi CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) @@ -14,8 +14,8 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = <openssl/sha.h> -GIT_VER = 2.18.0 -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz +GIT_VER = 2.25.0 +GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r MAN5_TXT = $(wildcard *.5.txt) @@ -157,7 +157,7 @@ clean-doc: $(RM) cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo get-git: - curl -L $(GIT_URL) | tar -xzf - && rm -rf git && mv git-$(GIT_VER) git + curl -L $(GIT_URL) | tar -xJf - && rm -rf git && mv git-$(GIT_VER) git tags: $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags @@ -19,6 +19,16 @@ const char *cgit_version = CGIT_VERSION; +__attribute__((constructor)) +static void constructor_environment() +{ + /* Do not look in /etc/ for gitconfig and gitattributes. */ + setenv("GIT_CONFIG_NOSYSTEM", "1", 1); + setenv("GIT_ATTR_NOSYSTEM", "1", 1); + unsetenv("HOME"); + unsetenv("XDG_CONFIG_HOME"); +} + static void add_mimetype(const char *name, const char *value) { struct string_list_item *item; @@ -50,6 +60,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->extra_head_content = xstrdup(value); else if (!strcmp(name, "snapshots")) repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); + else if (!strcmp(name, "enable-blame")) + repo->enable_blame = atoi(value); else if (!strcmp(name, "enable-commit-graph")) repo->enable_commit_graph = atoi(value); else if (!strcmp(name, "enable-log-filecount")) @@ -563,18 +575,13 @@ static void prepare_repo_env(int *nongit) /* The path to the git repository. */ setenv("GIT_DIR", ctx.repo->path, 1); - /* Do not look in /etc/ for gitconfig and gitattributes. */ - setenv("GIT_CONFIG_NOSYSTEM", "1", 1); - setenv("GIT_ATTR_NOSYSTEM", "1", 1); - unsetenv("HOME"); - unsetenv("XDG_CONFIG_HOME"); - /* Setup the git directory and initialize the notes system. Both of these * load local configuration from the git repository, so we do them both while * the HOME variables are unset. */ setup_git_directory_gently(nongit); - init_display_notes(NULL); + load_display_notes(NULL); } + static int prepare_repo_cmd(int nongit) { struct object_id oid; @@ -645,7 +652,7 @@ static inline void open_auth_filter(const char *function) ctx.env.https ? ctx.env.https : "", ctx.qry.repo ? ctx.qry.repo : "", ctx.qry.page ? ctx.qry.page : "", - ctx.qry.url ? ctx.qry.url : "", + cgit_currentfullurl(), cgit_loginurl()); } @@ -809,6 +816,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.homepage=%s\n", repo->homepage); if (repo->clone_url) fprintf(f, "repo.clone-url=%s\n", repo->clone_url); + fprintf(f, "repo.enable-blame=%d\n", + repo->enable_blame); fprintf(f, "repo.enable-commit-graph=%d\n", repo->enable_commit_graph); fprintf(f, "repo.enable-log-filecount=%d\n", @@ -8,6 +8,7 @@ #include <cache.h> #include <grep.h> #include <object.h> +#include <object-store.h> #include <tree.h> #include <commit.h> #include <tag.h> @@ -93,6 +94,7 @@ struct cgit_repo { char *logo_link; char *snapshot_prefix; int snapshots; + int enable_blame; int enable_commit_graph; int enable_log_filecount; int enable_log_linecount; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 34b351b..ba77826 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -485,6 +485,10 @@ repo.email-filter:: Override the default email-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". +repo.enable-blame:: + A flag which can be used to disable the global setting + `enable-blame'. Default value: none. + repo.enable-commit-graph:: A flag which can be used to disable the global setting `enable-commit-graph'. Default value: none. @@ -66,7 +66,7 @@ static void about_fn(void) static void blame_fn(void) { - if (ctx.cfg.enable_blame) + if (ctx.repo->enable_blame) cgit_print_blame(); else cgit_print_error_page(403, "Forbidden", "Blame is disabled"); diff --git a/filters/email-gravatar.lua b/filters/email-gravatar.lua index 52cf426..c39b490 100644 --- a/filters/email-gravatar.lua +++ b/filters/email-gravatar.lua @@ -3,15 +3,24 @@ -- prefix in filters. It is much faster than the corresponding python script. -- -- Requirements: --- luacrypto >= 0.3 --- <http://mkottman.github.io/luacrypto/> +-- luaossl +-- <http://25thandclement.com/~william/projects/luaossl.html> -- -local crypto = require("crypto") +local digest = require("openssl.digest") + +function md5_hex(input) + local b = digest.new("md5"):final(input) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end function filter_open(email, page) buffer = "" - md5 = crypto.digest("md5", email:sub(2, -2):lower()) + md5 = md5_hex(email:sub(2, -2):lower()) end function filter_close() diff --git a/filters/email-libravatar.lua b/filters/email-libravatar.lua index b0e2447..7336baf 100644 --- a/filters/email-libravatar.lua +++ b/filters/email-libravatar.lua @@ -3,15 +3,24 @@ -- prefix in filters. -- -- Requirements: --- luacrypto >= 0.3 --- <http://mkottman.github.io/luacrypto/> +-- luaossl +-- <http://25thandclement.com/~william/projects/luaossl.html> -- -local crypto = require("crypto") +local digest = require("openssl.digest") + +function md5_hex(input) + local b = digest.new("md5"):final(input) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end function filter_open(email, page) buffer = "" - md5 = crypto.digest("md5", email:sub(2, -2):lower()) + md5 = md5_hex(email:sub(2, -2):lower()) end function filter_close() diff --git a/filters/file-authentication.lua b/filters/file-authentication.lua index 6ee1e19..0248804 100644 --- a/filters/file-authentication.lua +++ b/filters/file-authentication.lua @@ -1,15 +1,15 @@ -- This script may be used with the auth-filter. -- -- Requirements: --- luacrypto >= 0.3 --- <http://mkottman.github.io/luacrypto/> +-- luaossl +-- <http://25thandclement.com/~william/projects/luaossl.html> -- luaposix -- <https://github.com/luaposix/luaposix> -- local sysstat = require("posix.sys.stat") local unistd = require("posix.unistd") -local crypto = require("crypto") - +local rand = require("openssl.rand") +local hmac = require("openssl.hmac") -- This file should contain a series of lines in the form of: -- username1:hash1 @@ -225,6 +225,13 @@ function get_cookie(cookies, name) return url_decode(string.match(cookies, ";" .. name .. "=(.-);")) end +function tohex(b) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end -- -- @@ -242,12 +249,12 @@ function get_secret() local secret_file = io.open(secret_filename, "r") if secret_file == nil then local old_umask = sysstat.umask(63) - local temporary_filename = secret_filename .. ".tmp." .. crypto.hex(crypto.rand.bytes(16)) + local temporary_filename = secret_filename .. ".tmp." .. tohex(rand.bytes(16)) local temporary_file = io.open(temporary_filename, "w") if temporary_file == nil then os.exit(177) end - temporary_file:write(crypto.hex(crypto.rand.bytes(32))) + temporary_file:write(tohex(rand.bytes(32))) temporary_file:close() unistd.link(temporary_filename, secret_filename) -- Intentionally fails in the case that another process is doing the same. unistd.unlink(temporary_filename) @@ -272,7 +279,7 @@ function validate_value(expected_field, cookie) local field = "" local expiration = 0 local salt = "" - local hmac = "" + local chmac = "" if cookie == nil or cookie:len() < 3 or cookie:sub(1, 1) == "|" then return nil @@ -291,19 +298,19 @@ function validate_value(expected_field, cookie) elseif i == 3 then salt = component elseif i == 4 then - hmac = component + chmac = component else break end i = i + 1 end - if hmac == nil or hmac:len() == 0 then + if chmac == nil or chmac:len() == 0 then return nil end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, get_secret()) then + if chmac ~= tohex(hmac.new(get_secret(), "sha256"):final(field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt)) then return nil end @@ -324,11 +331,11 @@ function secure_value(field, value, expiration) end local authstr = "" - local salt = crypto.hex(crypto.rand.bytes(16)) + local salt = tohex(rand.bytes(16)) value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, get_secret()) + authstr = authstr .. "|" .. tohex(hmac.new(get_secret(), "sha256"):final(authstr)) return authstr end diff --git a/filters/gentoo-ldap-authentication.lua b/filters/gentoo-ldap-authentication.lua index b4d98c2..673c88d 100644 --- a/filters/gentoo-ldap-authentication.lua +++ b/filters/gentoo-ldap-authentication.lua @@ -1,8 +1,8 @@ -- This script may be used with the auth-filter. Be sure to configure it as you wish. -- -- Requirements: --- luacrypto >= 0.3 --- <http://mkottman.github.io/luacrypto/> +-- luaossl +-- <http://25thandclement.com/~william/projects/luaossl.html> -- lualdap >= 1.2 -- <https://git.zx2c4.com/lualdap/about/> -- luaposix @@ -10,9 +10,9 @@ -- local sysstat = require("posix.sys.stat") local unistd = require("posix.unistd") -local crypto = require("crypto") local lualdap = require("lualdap") - +local rand = require("openssl.rand") +local hmac = require("openssl.hmac") -- -- @@ -226,6 +226,13 @@ function get_cookie(cookies, name) return string.match(cookies, ";" .. name .. "=(.-);") end +function tohex(b) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end -- -- @@ -243,12 +250,12 @@ function get_secret() local secret_file = io.open(secret_filename, "r") if secret_file == nil then local old_umask = sysstat.umask(63) - local temporary_filename = secret_filename .. ".tmp." .. crypto.hex(crypto.rand.bytes(16)) + local temporary_filename = secret_filename .. ".tmp." .. tohex(rand.bytes(16)) local temporary_file = io.open(temporary_filename, "w") if temporary_file == nil then os.exit(177) end - temporary_file:write(crypto.hex(crypto.rand.bytes(32))) + temporary_file:write(tohex(rand.bytes(32))) temporary_file:close() unistd.link(temporary_filename, secret_filename) -- Intentionally fails in the case that another process is doing the same. unistd.unlink(temporary_filename) @@ -273,7 +280,7 @@ function validate_value(expected_field, cookie) local field = "" local expiration = 0 local salt = "" - local hmac = "" + local chmac = "" if cookie == nil or cookie:len() < 3 or cookie:sub(1, 1) == "|" then return nil @@ -292,19 +299,19 @@ function validate_value(expected_field, cookie) elseif i == 3 then salt = component elseif i == 4 then - hmac = component + chmac = component else break end i = i + 1 end - if hmac == nil or hmac:len() == 0 then + if chmac == nil or chmac:len() == 0 then return nil end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, get_secret()) then + if chmac ~= tohex(hmac.new(get_secret(), "sha256"):final(field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt)) then return nil end @@ -325,11 +332,11 @@ function secure_value(field, value, expiration) end local authstr = "" - local salt = crypto.hex(crypto.rand.bytes(16)) + local salt = tohex(rand.bytes(16)) value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, get_secret()) + authstr = authstr .. "|" .. tohex(hmac.new(get_secret(), "sha256"):final(authstr)) return authstr end diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index ebf3856..dc20f42 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -3,6 +3,7 @@ import markdown import sys import io from pygments.formatters import HtmlFormatter +from markdown.extensions.toc import TocExtension sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') sys.stdout.write(''' @@ -48,10 +49,14 @@ sys.stdout.write(''' line-height: 1; padding-left: 0; margin-left: -22px; - top: 15%} + top: 15%; +} .markdown-body h1:hover a.anchor .mini-icon-link, .markdown-body h2:hover a.anchor .mini-icon-link, .markdown-body h3:hover a.anchor .mini-icon-link, .markdown-body h4:hover a.anchor .mini-icon-link, .markdown-body h5:hover a.anchor .mini-icon-link, .markdown-body h6:hover a.anchor .mini-icon-link { display: inline-block; } +div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink { + color: black; +} .markdown-body h1 tt, .markdown-body h1 code, .markdown-body h2 tt, .markdown-body h2 code, .markdown-body h3 tt, .markdown-body h3 code, .markdown-body h4 tt, .markdown-body h4 code, .markdown-body h5 tt, .markdown-body h5 code, .markdown-body h6 tt, .markdown-body h6 code { font-size: inherit; } @@ -290,5 +295,13 @@ sys.stdout.write(''' sys.stdout.write("<div class='markdown-body'>") sys.stdout.flush() # Note: you may want to run this through bleach for sanitization -markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}}) +markdown.markdownFromFile( + output_format="html5", + extensions=[ + "markdown.extensions.fenced_code", + "markdown.extensions.codehilite", + "markdown.extensions.tables", + TocExtension(anchorlink=True)], + extension_configs={ + "markdown.extensions.codehilite":{"css_class":"highlight"}}) sys.stdout.write("</div>") diff --git a/filters/simple-authentication.lua b/filters/simple-authentication.lua index 77d1fd0..23d3457 100644 --- a/filters/simple-authentication.lua +++ b/filters/simple-authentication.lua @@ -1,15 +1,15 @@ -- This script may be used with the auth-filter. Be sure to configure it as you wish. -- -- Requirements: --- luacrypto >= 0.3 --- <http://mkottman.github.io/luacrypto/> +-- luaossl +-- <http://25thandclement.com/~william/projects/luaossl.html> -- luaposix -- <https://github.com/luaposix/luaposix> -- local sysstat = require("posix.sys.stat") local unistd = require("posix.unistd") -local crypto = require("crypto") - +local rand = require("openssl.rand") +local hmac = require("openssl.hmac") -- -- @@ -180,6 +180,13 @@ function get_cookie(cookies, name) return url_decode(string.match(cookies, ";" .. name .. "=(.-);")) end +function tohex(b) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end -- -- @@ -197,12 +204,12 @@ function get_secret() local secret_file = io.open(secret_filename, "r") if secret_file == nil then local old_umask = sysstat.umask(63) - local temporary_filename = secret_filename .. ".tmp." .. crypto.hex(crypto.rand.bytes(16)) + local temporary_filename = secret_filename .. ".tmp." .. tohex(rand.bytes(16)) local temporary_file = io.open(temporary_filename, "w") if temporary_file == nil then os.exit(177) end - temporary_file:write(crypto.hex(crypto.rand.bytes(32))) + temporary_file:write(tohex(rand.bytes(32))) temporary_file:close() unistd.link(temporary_filename, secret_filename) -- Intentionally fails in the case that another process is doing the same. unistd.unlink(temporary_filename) @@ -227,7 +234,7 @@ function validate_value(expected_field, cookie) local field = "" local expiration = 0 local salt = "" - local hmac = "" + local chmac = "" if cookie == nil or cookie:len() < 3 or cookie:sub(1, 1) == "|" then return nil @@ -246,19 +253,19 @@ function validate_value(expected_field, cookie) elseif i == 3 then salt = component elseif i == 4 then - hmac = component + chmac = component else break end i = i + 1 end - if hmac == nil or hmac:len() == 0 then + if chmac == nil or chmac:len() == 0 then return nil end -- Lua hashes strings, so these comparisons are time invariant. - if hmac ~= crypto.hmac.digest("sha256", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, get_secret()) then + if chmac ~= tohex(hmac.new(get_secret(), "sha256"):final(field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt)) then return nil end @@ -279,11 +286,11 @@ function secure_value(field, value, expiration) end local authstr = "" - local salt = crypto.hex(crypto.rand.bytes(16)) + local salt = tohex(rand.bytes(16)) value = url_encode(value) field = url_encode(field) authstr = field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt - authstr = authstr .. "|" .. crypto.hmac.digest("sha256", authstr, get_secret()) + authstr = authstr .. "|" .. tohex(hmac.new(get_secret(), "sha256"):final(authstr)) return authstr end diff --git a/git b/git -Subproject 53f9a3e157dbbc901a02ac2c73346d375e24978 +Subproject d0654dc308b0ba76dd8ed7bbb33c8d8f7aacd78 @@ -63,8 +63,7 @@ static char *substr(const char *head, const char *tail) if (tail < head) return xstrdup(""); buf = xmalloc(tail - head + 1); - strncpy(buf, head, tail - head); - buf[tail - head] = '\0'; + strlcpy(buf, head, tail - head + 1); return buf; } @@ -78,7 +77,7 @@ static void parse_user(const char *t, char **name, char **email, unsigned long * email_len = ident.mail_end - ident.mail_begin; *email = xmalloc(strlen("<") + email_len + strlen(">") + 1); - sprintf(*email, "<%.*s>", email_len, ident.mail_begin); + xsnprintf(*email, email_len + 3, "<%.*s>", email_len, ident.mail_begin); if (ident.date_begin) *date = strtoul(ident.date_begin, NULL, 10); @@ -130,7 +129,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) { const int sha1hex_len = 40; struct commitinfo *ret; - const char *p = get_cached_commit_buffer(commit, NULL); + const char *p = repo_get_commit_buffer(the_repository, commit, NULL); const char *t; ret = xcalloc(1, sizeof(struct commitinfo)); @@ -58,6 +58,7 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->homepage = NULL; ret->section = ctx.cfg.section; ret->snapshots = ctx.cfg.snapshots; + ret->enable_blame = ctx.cfg.enable_blame; ret->enable_commit_graph = ctx.cfg.enable_commit_graph; ret->enable_log_filecount = ctx.cfg.enable_log_filecount; ret->enable_log_linecount = ctx.cfg.enable_log_linecount; @@ -161,7 +162,7 @@ static struct refinfo *cgit_mk_refinfo(const char *refname, const struct object_ ref = xmalloc(sizeof (struct refinfo)); ref->refname = xstrdup(refname); - ref->object = parse_object(oid); + ref->object = parse_object(the_repository, oid); switch (ref->object->type) { case OBJ_TAG: ref->tag = cgit_parse_tag((struct tag *)ref->object); @@ -325,7 +326,7 @@ int cgit_diff_files(const struct object_id *old_oid, diff_params.flags |= XDF_IGNORE_WHITESPACE; emit_params.ctxlen = context > 0 ? context : 3; emit_params.flags = XDL_EMIT_FUNCNAMES; - emit_cb.outf = filediff_cb; + emit_cb.out_line = filediff_cb; emit_cb.priv = fn; xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); if (file1.size) diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh index a65b35e..3200f31 100755 --- a/tests/t0001-validate-git-versions.sh +++ b/tests/t0001-validate-git-versions.sh @@ -33,7 +33,7 @@ test_expect_success 'test submodule version matches Makefile' ' sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") && cd git && git describe --match "v[0-9]*" $sm_sha1 - ) | sed -e "s/^v//" >sm_version && + ) | sed -e "s/^v//" -e "s/-/./" >sm_version && test_cmp sm_version makefile_version fi ' diff --git a/tests/t0109-gitconfig.sh b/tests/t0109-gitconfig.sh index 3ba6684..8cee75c 100755 --- a/tests/t0109-gitconfig.sh +++ b/tests/t0109-gitconfig.sh @@ -9,6 +9,12 @@ test -n "$(which strace 2>/dev/null)" || { exit } +strace true 2>/dev/null || { + skip_all='Skipping access validation tests: strace not functional' + test_done + exit +} + test_no_home_access () { non_existent_path="/path/to/some/place/that/does/not/possibly/exist" while test -d "$non_existent_path"; do @@ -83,7 +83,7 @@ static void add_entry(struct commit *commit, const char *host) } -void cgit_print_atom(char *tip, char *path, int max_count) +void cgit_print_atom(char *tip, const char *path, int max_count) { char *host; const char *argv[] = {NULL, tip, NULL, NULL, NULL}; @@ -140,7 +140,7 @@ void cgit_print_atom(char *tip, char *path, int max_count) } while ((commit = get_revision(&rev)) != NULL) { add_entry(commit, host); - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -1,6 +1,6 @@ #ifndef UI_ATOM_H #define UI_ATOM_H -extern void cgit_print_atom(char *tip, char *path, int max_count); +extern void cgit_print_atom(char *tip, const char *path, int max_count); #endif @@ -131,6 +131,7 @@ static void print_object(const struct object_id *oid, const char *path, setup_revisions(rev_argv.argc, rev_argv.argv, &revs, NULL); init_scoreboard(&sb); sb.revs = &revs; + sb.repo = the_repository; setup_scoreboard(&sb, path, &o); o->suspects = blame_entry_prepend(NULL, 0, sb.num_lines, o); prio_queue_put(&sb.commits, o->commit); @@ -278,7 +279,7 @@ void cgit_print_blame(void) "Invalid revision name: %s", rev); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); @@ -289,8 +290,8 @@ void cgit_print_blame(void) walk_tree_ctx.match_baselen = (path_items.match) ? basedir_len(path_items.match) : -1; - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, - &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0, + &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.state) cgit_print_error_page(404, "Not found", "Not found"); else if (walk_tree_ctx.state == 2) @@ -56,7 +56,8 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; - read_tree_recursive(lookup_commit_reference(&oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, lookup_commit_reference(the_repository, &oid)->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); done: free(path_items.match); @@ -89,8 +90,9 @@ int cgit_print_file(char *path, const char *head, int file_only) return -1; type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { - commit = lookup_commit_reference(&oid); - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + commit = lookup_commit_reference(the_repository, &oid); + read_tree_recursive(the_repository, commit->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.found_path) return -1; type = oid_object_info(the_repository, &oid, &size); @@ -145,8 +147,9 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl type = oid_object_info(the_repository, &oid, &size); if ((!hex) && type == OBJ_COMMIT && path) { - commit = lookup_commit_reference(&oid); - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + commit = lookup_commit_reference(the_repository, &oid); + read_tree_recursive(the_repository, commit->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); type = oid_object_info(the_repository, &oid, &size); } @@ -19,12 +19,12 @@ static int print_ref_info(const char *refname, const struct object_id *oid, { struct object *obj; - if (!(obj = parse_object(oid))) + if (!(obj = parse_object(the_repository, oid))) return 0; htmlf("%s\t%s\n", oid_to_hex(oid), refname); if (obj->type == OBJ_TAG) { - if (!(obj = deref_tag(obj, refname, 0))) + if (!(obj = deref_tag(the_repository, obj, refname, 0))) return 0; htmlf("%s\t%s^{}\n", oid_to_hex(&obj->oid), refname); } diff --git a/ui-commit.c b/ui-commit.c index 995cb93..9a47b54 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -31,7 +31,7 @@ void cgit_print_commit(char *hex, const char *prefix) "Bad object id: %s", hex); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit) { cgit_print_error_page(404, "Not found", "Bad commit reference: %s", hex); @@ -87,7 +87,7 @@ void cgit_print_commit(char *hex, const char *prefix) free(tmp); html("</td></tr>\n"); for (p = commit->parents; p; p = p->next) { - parent = lookup_commit_reference(&p->item->object.oid); + parent = lookup_commit_reference(the_repository, &p->item->object.oid); if (!parent) { html("<tr><td colspan='3'>"); cgit_print_error("Error reading parent commit"); @@ -82,7 +82,7 @@ static void print_fileinfo(struct fileinfo *info) } html("<tr>"); - htmlf("<td class='mode'>"); + html("<td class='mode'>"); if (is_null_oid(info->new_oid)) { cgit_print_filemode(info->old_mode); } else { @@ -407,7 +407,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, "Bad object name: %s", new_rev); return; } - commit = lookup_commit_reference(new_rev_oid); + commit = lookup_commit_reference(the_repository, new_rev_oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(new_rev_oid)); @@ -428,7 +428,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, } if (!is_null_oid(old_rev_oid)) { - commit2 = lookup_commit_reference(old_rev_oid); + commit2 = lookup_commit_reference(the_repository, old_rev_oid); if (!commit2 || parse_commit(commit2)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(old_rev_oid)); @@ -67,7 +67,7 @@ void show_commit_decorations(struct commit *commit) while (deco) { struct object_id peeled; int is_annotated = 0; - strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1); + strlcpy(buf, prettify_refname(deco->name), sizeof(buf)); switch(deco->type) { case DECORATION_NONE: /* If the git-core doesn't recognize it, @@ -234,7 +234,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) strbuf_add(&msgbuf, "\n\n", 2); /* Place wrap_symbol at position i in info->subject */ - strcpy(info->subject + i, wrap_symbol); + strlcpy(info->subject + i, wrap_symbol, subject_len - i + 1); } } cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, @@ -362,7 +362,7 @@ static char *next_token(char **src) } void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, - char *path, int pager, int commit_graph, int commit_sort) + const char *path, int pager, int commit_graph, int commit_sort) { struct rev_info rev; struct commit *commit; @@ -488,7 +488,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; /* nop */) { if (show_commit(commit, &rev)) i++; - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -510,7 +510,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern i++; print_commit(commit, &rev); } - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -2,7 +2,7 @@ #define UI_LOG_H extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, - char *pattern, char *path, int pager, + char *pattern, const char *path, int pager, int commit_graph, int commit_sort); extern void show_commit_decorations(struct commit *commit); @@ -11,13 +11,16 @@ #include "html.h" #include "ui-shared.h" +/* two commit hashes with two dots in between and termination */ +#define REV_RANGE_LEN 2 * GIT_MAX_HEXSZ + 3 + void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix) { struct rev_info rev; struct commit *commit; struct object_id new_rev_oid, old_rev_oid; - char rev_range[2 * 40 + 3]; + char rev_range[REV_RANGE_LEN]; const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL }; int rev_argc = ARRAY_SIZE(rev_argv) - 1; char *patchname; @@ -33,7 +36,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "Bad object id: %s", new_rev); return; } - commit = lookup_commit_reference(&new_rev_oid); + commit = lookup_commit_reference(the_repository, &new_rev_oid); if (!commit) { cgit_print_error_page(404, "Not found", "Bad commit reference: %s", new_rev); @@ -46,7 +49,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "Bad object id: %s", old_rev); return; } - if (!lookup_commit_reference(&old_rev_oid)) { + if (!lookup_commit_reference(the_repository, &old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad commit reference: %s", old_rev); return; @@ -60,7 +63,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (is_null_oid(&old_rev_oid)) { memcpy(rev_range, oid_to_hex(&new_rev_oid), GIT_SHA1_HEXSZ + 1); } else { - sprintf(rev_range, "%s..%s", oid_to_hex(&old_rev_oid), + xsnprintf(rev_range, REV_RANGE_LEN, "%s..%s", oid_to_hex(&old_rev_oid), oid_to_hex(&new_rev_oid)); } @@ -185,7 +185,7 @@ void cgit_print_plain(void) cgit_print_error_page(404, "Not found", "Not found"); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Not found"); return; @@ -198,7 +198,8 @@ void cgit_print_plain(void) } else walk_tree_ctx.match_baselen = basedir_len(path_items.match); - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, + "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.match) cgit_print_error_page(404, "Not found", "Not found"); else if (walk_tree_ctx.match == 2) @@ -136,7 +136,7 @@ static int print_tag(struct refinfo *ref) return 0; } -static void print_refs_link(char *path) +static void print_refs_link(const char *path) { html("<tr class='nohover'><td colspan='5'>"); cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); diff --git a/ui-repolist.c b/ui-repolist.c index 41424c0..529a203 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -11,7 +11,7 @@ #include "html.h" #include "ui-shared.h" -static time_t read_agefile(char *path) +static time_t read_agefile(const char *path) { time_t result; size_t size; @@ -20,7 +20,7 @@ static time_t read_agefile(char *path) if (readfile(path, &buf, &size)) { free(buf); - return -1; + return 0; } if (parse_date(buf, &date_buf) == 0) diff --git a/ui-shared.c b/ui-shared.c index 739505a..d2358f2 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -68,15 +68,48 @@ char *cgit_hosturl(void) char *cgit_currenturl(void) { const char *root = cgit_rooturl(); - size_t len = strlen(root); if (!ctx.qry.url) return xstrdup(root); - if (len && root[len - 1] == '/') + if (root[0] && root[strlen(root) - 1] == '/') return fmtalloc("%s%s", root, ctx.qry.url); return fmtalloc("%s/%s", root, ctx.qry.url); } +char *cgit_currentfullurl(void) +{ + const char *root = cgit_rooturl(); + const char *orig_query = ctx.env.query_string ? ctx.env.query_string : ""; + size_t len = strlen(orig_query); + char *query = xmalloc(len + 2), *start_url, *ret; + + /* Remove all url=... parts from query string */ + memcpy(query + 1, orig_query, len + 1); + query[0] = '?'; + start_url = query; + while ((start_url = strstr(start_url, "url=")) != NULL) { + if (start_url[-1] == '?' || start_url[-1] == '&') { + const char *end_url = strchr(start_url, '&'); + if (end_url) + memmove(start_url, end_url + 1, strlen(end_url)); + else + start_url[0] = '\0'; + } else + ++start_url; + } + if (!query[1]) + query[0] = '\0'; + + if (!ctx.qry.url) + ret = fmtalloc("%s%s", root, query); + else if (root[0] && root[strlen(root) - 1] == '/') + ret = fmtalloc("%s%s%s", root, ctx.qry.url, query); + else + ret = fmtalloc("%s/%s%s", root, ctx.qry.url, query); + free(query); + return ret; +} + const char *cgit_rooturl(void) { if (ctx.cfg.virtual_root) @@ -912,12 +945,13 @@ static void cgit_print_path_crumbs(char *path) { char *old_path = ctx.qry.path; char *p = path, *q, *end = path + strlen(path); + int levels = 0; ctx.qry.path = NULL; cgit_self_link("root", NULL, NULL); ctx.qry.path = p = path; while (p < end) { - if (!(q = strchr(p, '/'))) + if (!(q = strchr(p, '/')) || levels > 15) q = end; *q = '\0'; html_txt("/"); @@ -925,6 +959,7 @@ static void cgit_print_path_crumbs(char *path) if (q < end) *q = '/'; p = q + 1; + ++levels; } ctx.qry.path = old_path; } @@ -1159,31 +1194,17 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, void cgit_set_title_from_path(const char *path) { - size_t path_len, path_index, path_last_end; - char *new_title; + struct strbuf sb = STRBUF_INIT; + const char *slash, *last_slash; if (!path) return; - path_len = strlen(path); - new_title = xmalloc(path_len + 3 + strlen(ctx.page.title) + 1); - new_title[0] = '\0'; - - for (path_index = path_len, path_last_end = path_len; path_index-- > 0;) { - if (path[path_index] == '/') { - if (path_index == path_len - 1) { - path_last_end = path_index - 1; - continue; - } - strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1); - strcat(new_title, "\\"); - path_last_end = path_index; - } + for (last_slash = path + strlen(path); (slash = memrchr(path, '/', last_slash - path)) != NULL; last_slash = slash) { + strbuf_add(&sb, slash + 1, last_slash - slash - 1); + strbuf_addstr(&sb, " \xc2\xab "); } - if (path_last_end) - strncat(new_title, path, path_last_end); - - strcat(new_title, " - "); - strcat(new_title, ctx.page.title); - ctx.page.title = new_title; + strbuf_add(&sb, path, last_slash - path); + strbuf_addf(&sb, " - %s", ctx.page.title); + ctx.page.title = strbuf_detach(&sb, NULL); } diff --git a/ui-shared.h b/ui-shared.h index 4d5978b..6964873 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -5,6 +5,7 @@ extern const char *cgit_httpscheme(void); extern char *cgit_hosturl(void); extern const char *cgit_rooturl(void); extern char *cgit_currenturl(void); +extern char *cgit_currentfullurl(void); extern const char *cgit_loginurl(void); extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, diff --git a/ui-snapshot.c b/ui-snapshot.c index fa3ceaf..9461d51 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -37,7 +37,7 @@ static int write_archive_type(const char *format, const char *hex, const char *p /* argv_array guarantees a trailing NULL entry. */ memcpy(nargv, argv.argv, sizeof(char *) * (argv.argc + 1)); - result = write_archive(argv.argc, nargv, NULL, NULL, 0); + result = write_archive(argv.argc, nargv, NULL, the_repository, NULL, 0); argv_array_clear(&argv); free(nargv); return result; @@ -147,7 +147,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, "Bad object id: %s", hex); return 1; } - if (!lookup_commit_reference(&oid)) { + if (!lookup_commit_reference(the_repository, &oid)) { cgit_print_error_page(400, "Bad request", "Not a commit reference: %s", hex); return 1; @@ -156,6 +156,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, ctx.page.mimetype = xstrdup(format->mimetype); ctx.page.filename = xstrdup(filename); cgit_print_http_headers(); + init_archivers(); format->write_func(hex, prefix); return 0; } diff --git a/ui-ssdiff.c b/ui-ssdiff.c index 68c2044..af8bc9e 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -103,8 +103,7 @@ static int line_from_hunk(char *line, char type) return 0; len = buf2 - buf1; buf2 = xmalloc(len + 1); - strncpy(buf2, buf1, len); - buf2[len] = '\0'; + strlcpy(buf2, buf1, len + 1); res = atoi(buf2); free(buf2); return res; @@ -118,6 +117,7 @@ static char *replace_tabs(char *line) int n_tabs = 0; int i; char *result; + size_t result_len; if (linelen == 0) { result = xmalloc(1); @@ -129,16 +129,19 @@ static char *replace_tabs(char *line) if (line[i] == '\t') n_tabs += 1; } - result = xmalloc(linelen + n_tabs * 8 + 1); + result_len = linelen + n_tabs * 8; + result = xmalloc(result_len + 1); result[0] = '\0'; for (;;) { cur_buf = strchr(prev_buf, '\t'); if (!cur_buf) { - strcat(result, prev_buf); + linelen = strlen(result); + strlcpy(&result[linelen], prev_buf, result_len - linelen + 1); break; } else { - strncat(result, prev_buf, cur_buf - prev_buf); + linelen = strlen(result); + strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1); linelen = strlen(result); memset(&result[linelen], ' ', 8 - (linelen % 8)); result[linelen + 8 - (linelen % 8)] = '\0'; @@ -206,11 +209,13 @@ static void print_part_with_lcs(char *class, char *line, char *lcs) } } else if (line[i] == lcs[j]) { same = 1; - htmlf("</span>"); + html("</span>"); j += 1; } html_txt(c); } + if (!same) + html("</span>"); } static void print_ssdiff_line(char *class, @@ -235,7 +240,7 @@ static void print_ssdiff_line(char *class, char *fileurl = cgit_fileurl(ctx.repo->url, "tree", old_file->path, id_str); html("<td class='lineno'><a href='"); html(fileurl); - htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1); + htmlf("'>%s</a>", lineno_str + 1); html("</td>"); htmlf("<td class='%s'>", class); free(fileurl); @@ -258,7 +263,7 @@ static void print_ssdiff_line(char *class, char *fileurl = cgit_fileurl(ctx.repo->url, "tree", new_file->path, id_str); html("<td class='lineno'><a href='"); html(fileurl); - htmlf("' id='%s'>%s</a>", lineno_str, lineno_str + 1); + htmlf("'>%s</a>", lineno_str + 1); html("</td>"); htmlf("<td class='%s'>", class); free(fileurl); @@ -404,7 +409,7 @@ void cgit_ssdiff_header_begin(void) void cgit_ssdiff_header_end(void) { - html("</td><tr>"); + html("</td></tr>"); } void cgit_ssdiff_footer(void) @@ -241,7 +241,7 @@ static struct string_list collect_stats(const struct cgit_period *period) memset(&authors, 0, sizeof(authors)); while ((commit = get_revision(&rev)) != NULL) { add_commit(&authors, commit, period); - free_commit_buffer(commit); + free_commit_buffer(the_repository->parsed_objects, commit); free_commit_list(commit->parents); commit->parents = NULL; } diff --git a/ui-summary.c b/ui-summary.c index 8e81ac4..947812a 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -99,7 +99,7 @@ static char* append_readme_path(const char *filename, const char *ref, const cha return full_path; } -void cgit_print_repo_readme(char *path) +void cgit_print_repo_readme(const char *path) { char *filename, *ref, *mimetype; int free_filename = 0; diff --git a/ui-summary.h b/ui-summary.h index 0896650..cba696a 100644 --- a/ui-summary.h +++ b/ui-summary.h @@ -2,6 +2,6 @@ #define UI_SUMMARY_H extern void cgit_print_summary(void); -extern void cgit_print_repo_readme(char *path); +extern void cgit_print_repo_readme(const char *path); #endif /* UI_SUMMARY_H */ @@ -53,7 +53,7 @@ void cgit_print_tag(char *revname) "Bad tag reference: %s", revname); goto cleanup; } - obj = parse_object(&oid); + obj = parse_object(the_repository, &oid); if (!obj) { cgit_print_error_page(500, "Internal server error", "Bad object id: %s", oid_to_hex(&oid)); @@ -63,7 +63,7 @@ void cgit_print_tag(char *revname) struct tag *tag; struct taginfo *info; - tag = lookup_tag(&oid); + tag = lookup_tag(the_repository, &oid); if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { cgit_print_error_page(500, "Internal server error", "Bad tag object: %s", revname); @@ -71,7 +71,7 @@ void cgit_print_tag(char *revname) } cgit_print_layout_start(); html("<table class='commit-info'>\n"); - htmlf("<tr><td>tag name</td><td>"); + html("<tr><td>tag name</td><td>"); html_txt(revname); htmlf(" (%s)</td></tr>\n", oid_to_hex(&oid)); if (info->tagger_date > 0) { @@ -103,7 +103,7 @@ void cgit_print_tag(char *revname) } else { cgit_print_layout_start(); html("<table class='commit-info'>\n"); - htmlf("<tr><td>tag name</td><td>"); + html("<tr><td>tag name</td><td>"); html_txt(revname); html("</td></tr>\n"); html("<tr><td>tagged object</td><td class='sha1'>"); @@ -84,7 +84,7 @@ static void print_binary_buffer(char *buf, unsigned long size) html("</table>\n"); } -static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev) +static void print_object(const struct object_id *oid, const char *path, const char *basename, const char *rev) { enum object_type type; char *buf; @@ -110,7 +110,7 @@ static void print_object(const struct object_id *oid, char *path, const char *ba htmlf("blob: %s (", oid_to_hex(oid)); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); - if (ctx.cfg.enable_blame) { + if (ctx.repo->enable_blame) { html(") ("); cgit_blame_link("blame", NULL, NULL, ctx.qry.head, rev, path); @@ -177,7 +177,7 @@ static void write_tree_link(const struct object_id *oid, char *name, cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, fullpath->buf); - tree = lookup_tree(&tree_ctx.oid); + tree = lookup_tree(the_repository, &tree_ctx.oid); if (!tree) return; @@ -185,8 +185,8 @@ static void write_tree_link(const struct object_id *oid, char *name, tree_ctx.name = NULL; tree_ctx.count = 0; - read_tree_recursive(tree, "", 0, 1, &paths, single_tree_cb, - &tree_ctx); + read_tree_recursive(the_repository, tree, "", 0, 1, + &paths, single_tree_cb, &tree_ctx); if (tree_ctx.count != 1) break; @@ -251,7 +251,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, if (!S_ISGITLINK(mode)) cgit_plain_link("plain", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); - if (!S_ISDIR(mode) && ctx.cfg.enable_blame) + if (!S_ISDIR(mode) && ctx.repo->enable_blame) cgit_blame_link("blame", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); html("</td></tr>\n"); @@ -279,7 +279,7 @@ static void ls_tail(void) cgit_print_layout_end(); } -static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_context *walk_tree_ctx) +static void ls_tree(const struct object_id *oid, const char *path, struct walk_tree_context *walk_tree_ctx) { struct tree *tree; struct pathspec paths = { @@ -294,7 +294,8 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co } ls_head(); - read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx); + read_tree_recursive(the_repository, tree, "", 0, 1, + &paths, ls_item, walk_tree_ctx); ls_tail(); } @@ -359,7 +360,7 @@ void cgit_print_tree(const char *rev, char *path) "Invalid revision name: %s", rev); return; } - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit || parse_commit(commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); @@ -373,7 +374,8 @@ void cgit_print_tree(const char *rev, char *path) goto cleanup; } - read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); + read_tree_recursive(the_repository, commit->maybe_tree, "", 0, 0, + &paths, walk_tree, &walk_tree_ctx); if (walk_tree_ctx.state == 1) ls_tail(); else if (walk_tree_ctx.state == 2) |