summaryrefslogtreecommitdiffstats
path: root/development
diff options
context:
space:
mode:
author Robby Workman2017-08-25 02:22:28 +0200
committer Willy Sudiarto Raharjo2017-08-26 02:20:38 +0200
commit4174da45a36fdf2f65914f22865dcc48433554c2 (patch)
tree14e161231bc5a8675857dbd5e124af8cc5864659 /development
parentdf75f0401ee693208abfaf397f480ae1f61862d1 (diff)
downloadslackbuilds-4174da45a36fdf2f65914f22865dcc48433554c2.tar.gz
development/cgit: Include some upstream git patches
Some general bugfixes, but more importantly, patch 0005 fixes a segfault in git's pathspec.c that we were seeing on the SBo git server. Thanks to John Keeping (cgit contributor) for helping with debug suggestions and identifying the specific commit we needed to fix it. Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'development')
-rw-r--r--development/cgit/cgit.SlackBuild13
-rw-r--r--development/cgit/patches/0004-syntax-highlighting-replace-invalid-unicode-with.patch27
-rw-r--r--development/cgit/patches/0005-ui-patch-fix-crash-when-using-path-limit.patch43
-rw-r--r--development/cgit/patches/0006-ui-repolist-properly-sort-by-age.patch78
-rw-r--r--development/cgit/patches/0007-Remove-unused-variable-from-sort_section.patch25
-rw-r--r--development/cgit/patches/0011-ui-atom-properly-escape-delimiter-in-page-link.patch31
-rw-r--r--development/cgit/patches/0012-ui-shared-don-t-print-path-crumbs-without-a-repo.patch37
-rw-r--r--development/cgit/patches/0013-parsing-clear-query-path-before-starting.patch44
-rw-r--r--development/cgit/patches/0014-cgit-don-t-set-vpath-unless-repo-is-set.patch47
-rw-r--r--development/cgit/patches/0015-ui-plain-print-symlink-content.patch30
10 files changed, 374 insertions, 1 deletions
diff --git a/development/cgit/cgit.SlackBuild b/development/cgit/cgit.SlackBuild
index 49bca2536b..b55f3a5739 100644
--- a/development/cgit/cgit.SlackBuild
+++ b/development/cgit/cgit.SlackBuild
@@ -23,7 +23,7 @@
PRGNAM=cgit
VERSION=${VERSION:-1.1}
-BUILD=${BUILD:-2}
+BUILD=${BUILD:-3}
TAG=${TAG:-_SBo}
DOCROOT=${DOCROOT:-/var/www}
@@ -78,6 +78,17 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
+# apply some upstream patches
+patch -p1 < $CWD/patches/0004-syntax-highlighting-replace-invalid-unicode-with.patch
+patch -p1 < $CWD/patches/0005-ui-patch-fix-crash-when-using-path-limit.patch
+patch -p1 < $CWD/patches/0006-ui-repolist-properly-sort-by-age.patch
+patch -p1 < $CWD/patches/0007-Remove-unused-variable-from-sort_section.patch
+patch -p1 < $CWD/patches/0011-ui-atom-properly-escape-delimiter-in-page-link.patch
+patch -p1 < $CWD/patches/0012-ui-shared-don-t-print-path-crumbs-without-a-repo.patch
+patch -p1 < $CWD/patches/0013-parsing-clear-query-path-before-starting.patch
+patch -p1 < $CWD/patches/0014-cgit-don-t-set-vpath-unless-repo-is-set.patch
+patch -p1 < $CWD/patches/0015-ui-plain-print-symlink-content.patch
+
# prepare sources
sed -i Makefile \
-e "s|-g -Wall -Igit|-Wall ${SLKCFLAGS} -Igit|" \
diff --git a/development/cgit/patches/0004-syntax-highlighting-replace-invalid-unicode-with.patch b/development/cgit/patches/0004-syntax-highlighting-replace-invalid-unicode-with.patch
new file mode 100644
index 0000000000..47483837f4
--- /dev/null
+++ b/development/cgit/patches/0004-syntax-highlighting-replace-invalid-unicode-with.patch
@@ -0,0 +1,27 @@
+From 5564a5d06678b3f9b0725bc4b2383ea1b7eb5515 Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Sun, 22 Jan 2017 12:44:44 +0100
+Subject: [PATCH 04/15] syntax-highlighting: replace invalid unicode with ?
+
+---
+ filters/syntax-highlighting.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py
+index 1ca4108..5888b50 100755
+--- a/filters/syntax-highlighting.py
++++ b/filters/syntax-highlighting.py
+@@ -30,8 +30,8 @@ from pygments.lexers import guess_lexer_for_filename
+ from pygments.formatters import HtmlFormatter
+
+
+-sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
+-sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
++sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace')
++sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
+ data = sys.stdin.read()
+ filename = sys.argv[1]
+ formatter = HtmlFormatter(style='pastie')
+--
+2.14.1
+
diff --git a/development/cgit/patches/0005-ui-patch-fix-crash-when-using-path-limit.patch b/development/cgit/patches/0005-ui-patch-fix-crash-when-using-path-limit.patch
new file mode 100644
index 0000000000..2339129069
--- /dev/null
+++ b/development/cgit/patches/0005-ui-patch-fix-crash-when-using-path-limit.patch
@@ -0,0 +1,43 @@
+From be39d22328f841536b8e44e8aaeed80a74ebb353 Mon Sep 17 00:00:00 2001
+From: Lukas Fleischer <lfleischer@lfos.de>
+Date: Thu, 24 Nov 2016 20:14:54 +0100
+Subject: [PATCH 05/15] ui-patch: fix crash when using path limit
+
+The array passed to setup_revisions() must be NULL-terminated. Fixes a
+regression introduced in 455b598 (ui-patch.c: Use log_tree_commit() to
+generate diffs, 2013-08-20).
+
+Reported-by: Florian Pritz <bluewind@xinu.at>
+Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
+---
+ ui-patch.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/ui-patch.c b/ui-patch.c
+index ec7f352..047e2f9 100644
+--- a/ui-patch.c
++++ b/ui-patch.c
+@@ -18,8 +18,8 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
+ struct commit *commit;
+ struct object_id new_rev_oid, old_rev_oid;
+ char rev_range[2 * 40 + 3];
+- const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix };
+- int rev_argc = ARRAY_SIZE(rev_argv);
++ const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL };
++ int rev_argc = ARRAY_SIZE(rev_argv) - 1;
+ char *patchname;
+
+ if (!prefix)
+@@ -85,8 +85,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
+ DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY;
+ if (prefix)
+ rev.diffopt.stat_sep = fmt("(limited to '%s')\n\n", prefix);
+- setup_revisions(ARRAY_SIZE(rev_argv), rev_argv, &rev,
+- NULL);
++ setup_revisions(rev_argc, rev_argv, &rev, NULL);
+ prepare_revision_walk(&rev);
+
+ while ((commit = get_revision(&rev)) != NULL) {
+--
+2.14.1
+
diff --git a/development/cgit/patches/0006-ui-repolist-properly-sort-by-age.patch b/development/cgit/patches/0006-ui-repolist-properly-sort-by-age.patch
new file mode 100644
index 0000000000..e48d97f2db
--- /dev/null
+++ b/development/cgit/patches/0006-ui-repolist-properly-sort-by-age.patch
@@ -0,0 +1,78 @@
+From 87c47488d02fcace4da0d468cd9ddd1651b7949e Mon Sep 17 00:00:00 2001
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
+Date: Thu, 30 Mar 2017 13:19:50 +0200
+Subject: [PATCH 06/15] ui-repolist: properly sort by age
+
+When empty repos exist, comparing them against an existing repo with a
+good mtime might, with particular qsort implementations, not sort
+correctly, because of this brokenness:
+
+ if (get_repo_modtime(r1, &t) && get_repo_modtime(r2, &t))
+
+However, sorting by the age column works as expected, so anyway, to tidy
+things up, we simply reuse that function.
+
+Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
+---
+ ui-repolist.c | 38 +++++++++++++++++---------------------
+ 1 file changed, 17 insertions(+), 21 deletions(-)
+
+diff --git a/ui-repolist.c b/ui-repolist.c
+index b57ea60..20a4f56 100644
+--- a/ui-repolist.c
++++ b/ui-repolist.c
+@@ -184,27 +184,6 @@ static int cmp(const char *s1, const char *s2)
+ return 0;
+ }
+
+-static int sort_section(const void *a, const void *b)
+-{
+- const struct cgit_repo *r1 = a;
+- const struct cgit_repo *r2 = b;
+- int result;
+- time_t t;
+-
+- result = cmp(r1->section, r2->section);
+- if (!result) {
+- if (!strcmp(ctx.cfg.repository_sort, "age")) {
+- // get_repo_modtime caches the value in r->mtime, so we don't
+- // have to worry about inefficiencies here.
+- if (get_repo_modtime(r1, &t) && get_repo_modtime(r2, &t))
+- result = r2->mtime - r1->mtime;
+- }
+- if (!result)
+- result = cmp(r1->name, r2->name);
+- }
+- return result;
+-}
+-
+ static int sort_name(const void *a, const void *b)
+ {
+ const struct cgit_repo *r1 = a;
+@@ -241,6 +220,23 @@ static int sort_idle(const void *a, const void *b)
+ return t2 - t1;
+ }
+
++static int sort_section(const void *a, const void *b)
++{
++ const struct cgit_repo *r1 = a;
++ const struct cgit_repo *r2 = b;
++ int result;
++ time_t t;
++
++ result = cmp(r1->section, r2->section);
++ if (!result) {
++ if (!strcmp(ctx.cfg.repository_sort, "age"))
++ result = sort_idle(r1, r2);
++ if (!result)
++ result = cmp(r1->name, r2->name);
++ }
++ return result;
++}
++
+ struct sortcolumn {
+ const char *name;
+ int (*fn)(const void *a, const void *b);
+--
+2.14.1
+
diff --git a/development/cgit/patches/0007-Remove-unused-variable-from-sort_section.patch b/development/cgit/patches/0007-Remove-unused-variable-from-sort_section.patch
new file mode 100644
index 0000000000..13e7118e50
--- /dev/null
+++ b/development/cgit/patches/0007-Remove-unused-variable-from-sort_section.patch
@@ -0,0 +1,25 @@
+From 7ebdb30fdf91d1f63b4fb07e54b089136de5507b Mon Sep 17 00:00:00 2001
+From: Lukas Fleischer <lfleischer@lfos.de>
+Date: Wed, 5 Apr 2017 06:38:27 +0200
+Subject: [PATCH 07/15] Remove unused variable from sort_section()
+
+Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
+---
+ ui-repolist.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/ui-repolist.c b/ui-repolist.c
+index 20a4f56..7272e87 100644
+--- a/ui-repolist.c
++++ b/ui-repolist.c
+@@ -225,7 +225,6 @@ static int sort_section(const void *a, const void *b)
+ const struct cgit_repo *r1 = a;
+ const struct cgit_repo *r2 = b;
+ int result;
+- time_t t;
+
+ result = cmp(r1->section, r2->section);
+ if (!result) {
+--
+2.14.1
+
diff --git a/development/cgit/patches/0011-ui-atom-properly-escape-delimiter-in-page-link.patch b/development/cgit/patches/0011-ui-atom-properly-escape-delimiter-in-page-link.patch
new file mode 100644
index 0000000000..2dbf661fc9
--- /dev/null
+++ b/development/cgit/patches/0011-ui-atom-properly-escape-delimiter-in-page-link.patch
@@ -0,0 +1,31 @@
+From 6d3c8bc37f6124c2193d66587079975d381aa435 Mon Sep 17 00:00:00 2001
+From: John Keeping <john@keeping.me.uk>
+Date: Sun, 15 Jan 2017 12:29:38 +0000
+Subject: [PATCH 11/15] ui-atom: properly escape delimiter in page link
+
+If the delimiter here is '&' then it needs to be escaped for inclusion
+in an attribute. Use html_attrf() to ensure that this happens (we know
+that hex won't need escaping, but this makes it clearer what's
+happening.
+
+Signed-off-by: John Keeping <john@keeping.me.uk>
+---
+ ui-atom.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ui-atom.c b/ui-atom.c
+index 41838d3..3866823 100644
+--- a/ui-atom.c
++++ b/ui-atom.c
+@@ -63,7 +63,7 @@ static void add_entry(struct commit *commit, const char *host)
+ html_attr(pageurl);
+ if (ctx.cfg.virtual_root)
+ delim = '?';
+- htmlf("%cid=%s", delim, hex);
++ html_attrf("%cid=%s", delim, hex);
+ html("'/>\n");
+ free(pageurl);
+ }
+--
+2.14.1
+
diff --git a/development/cgit/patches/0012-ui-shared-don-t-print-path-crumbs-without-a-repo.patch b/development/cgit/patches/0012-ui-shared-don-t-print-path-crumbs-without-a-repo.patch
new file mode 100644
index 0000000000..99af79c4ba
--- /dev/null
+++ b/development/cgit/patches/0012-ui-shared-don-t-print-path-crumbs-without-a-repo.patch
@@ -0,0 +1,37 @@
+From 1b4ef6783a71962f8b5da3a23f2830f0f0f55ea0 Mon Sep 17 00:00:00 2001
+From: John Keeping <john@keeping.me.uk>
+Date: Sun, 19 Feb 2017 12:27:48 +0000
+Subject: [PATCH 12/15] ui-shared: don't print path crumbs without a repo
+
+cgit_print_path_crumbs() can call repolink() which assumes that ctx.repo
+is non-null. Currently we don't have any commands that set want_vpath
+without also setting want_repo so it shouldn't be possible to fail this
+test, but the check in cgit.c is in the wrong order so it is possible to
+specify a query string like "?p=log&path=foo/bar" to end up here without
+a valid repository.
+
+This was found by American fuzzy lop [0].
+
+[0] http://lcamtuf.coredump.cx/afl/
+
+Signed-off-by: John Keeping <john@keeping.me.uk>
+---
+ ui-shared.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ui-shared.c b/ui-shared.c
+index 2e4fcd9..e5c9a02 100644
+--- a/ui-shared.c
++++ b/ui-shared.c
+@@ -1039,7 +1039,7 @@ void cgit_print_pageheader(void)
+ free(currenturl);
+ }
+ html("</td></tr></table>\n");
+- if (ctx.env.authenticated && ctx.qry.vpath) {
++ if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) {
+ html("<div class='path'>");
+ html("path: ");
+ cgit_print_path_crumbs(ctx.qry.vpath);
+--
+2.14.1
+
diff --git a/development/cgit/patches/0013-parsing-clear-query-path-before-starting.patch b/development/cgit/patches/0013-parsing-clear-query-path-before-starting.patch
new file mode 100644
index 0000000000..ca20044d93
--- /dev/null
+++ b/development/cgit/patches/0013-parsing-clear-query-path-before-starting.patch
@@ -0,0 +1,44 @@
+From c699866699411346c5dba406457581013f85a873 Mon Sep 17 00:00:00 2001
+From: John Keeping <john@keeping.me.uk>
+Date: Sun, 19 Feb 2017 12:17:05 +0000
+Subject: [PATCH 13/15] parsing: clear query path before starting
+
+By specifying the "url" query parameter multiple times it is possible to
+end up with ctx.qry.vpath set while ctx.repo is null, which triggers an
+invalid code path from cgit_print_pageheader() while printing path
+crumbs, resulting in a null dereference.
+
+The previous patch fixed this segfault, but it makes no sense for us to
+clear ctx.repo while leaving ctx.qry.path set to the previous value, so
+let's just clear it here so that the last "url" parameter given takes
+full effect rather than partially overriding the effect of the previous
+value.
+
+Signed-off-by: John Keeping <john@keeping.me.uk>
+---
+ parsing.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parsing.c b/parsing.c
+index 9dacb16..b8d7f10 100644
+--- a/parsing.c
++++ b/parsing.c
+@@ -21,6 +21,7 @@ void cgit_parse_url(const char *url)
+ struct cgit_repo *repo;
+
+ ctx.repo = NULL;
++ ctx.qry.page = NULL;
+ if (!url || url[0] == '\0')
+ return;
+
+@@ -53,7 +54,6 @@ void cgit_parse_url(const char *url)
+ }
+ if (cmd[1])
+ ctx.qry.page = xstrdup(cmd + 1);
+- return;
+ }
+ }
+
+--
+2.14.1
+
diff --git a/development/cgit/patches/0014-cgit-don-t-set-vpath-unless-repo-is-set.patch b/development/cgit/patches/0014-cgit-don-t-set-vpath-unless-repo-is-set.patch
new file mode 100644
index 0000000000..1038a44b8f
--- /dev/null
+++ b/development/cgit/patches/0014-cgit-don-t-set-vpath-unless-repo-is-set.patch
@@ -0,0 +1,47 @@
+From 113f4b85886bc5eb6b319fd048623b8d43b7bce0 Mon Sep 17 00:00:00 2001
+From: John Keeping <john@keeping.me.uk>
+Date: Sun, 19 Feb 2017 12:02:37 +0000
+Subject: [PATCH 14/15] cgit: don't set vpath unless repo is set
+
+After the previous two patches, this can be classified as a tidy up
+rather than a bug fix, but I think it makes sense to group all of the
+tests together before setting up the environment for the command to
+execute.
+
+Signed-off-by: John Keeping <john@keeping.me.uk>
+---
+ cgit.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/cgit.c b/cgit.c
+index 1075753..1dae4b8 100644
+--- a/cgit.c
++++ b/cgit.c
+@@ -726,18 +726,18 @@ static void process_request(void)
+ return;
+ }
+
+- /* If cmd->want_vpath is set, assume ctx.qry.path contains a "virtual"
+- * in-project path limit to be made available at ctx.qry.vpath.
+- * Otherwise, no path limit is in effect (ctx.qry.vpath = NULL).
+- */
+- ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL;
+-
+ if (cmd->want_repo && !ctx.repo) {
+ cgit_print_error_page(400, "Bad request",
+ "No repository selected");
+ return;
+ }
+
++ /* If cmd->want_vpath is set, assume ctx.qry.path contains a "virtual"
++ * in-project path limit to be made available at ctx.qry.vpath.
++ * Otherwise, no path limit is in effect (ctx.qry.vpath = NULL).
++ */
++ ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL;
++
+ if (ctx.repo && prepare_repo_cmd())
+ return;
+
+--
+2.14.1
+
diff --git a/development/cgit/patches/0015-ui-plain-print-symlink-content.patch b/development/cgit/patches/0015-ui-plain-print-symlink-content.patch
new file mode 100644
index 0000000000..736158bc3b
--- /dev/null
+++ b/development/cgit/patches/0015-ui-plain-print-symlink-content.patch
@@ -0,0 +1,30 @@
+From 51cc456b773a3bb7253fad2146c1a0d2b0fa98cb Mon Sep 17 00:00:00 2001
+From: John Keeping <john@keeping.me.uk>
+Date: Mon, 6 Mar 2017 23:27:23 +0000
+Subject: [PATCH 15/15] ui-plain: print symlink content
+
+We currently ignore symlinks in ui-plain, leading to a 404. In ui-tree
+we print the content of the blob (that is, the path to the target of the
+link), so it makes sense to do the same here.
+
+Signed-off-by: John Keeping <john@keeping.me.uk>
+---
+ ui-plain.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ui-plain.c b/ui-plain.c
+index e45d553..cfdbf73 100644
+--- a/ui-plain.c
++++ b/ui-plain.c
+@@ -135,7 +135,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+ struct walk_tree_context *walk_tree_ctx = cbdata;
+
+ if (base->len == walk_tree_ctx->match_baselen) {
+- if (S_ISREG(mode)) {
++ if (S_ISREG(mode) || S_ISLNK(mode)) {
+ if (print_object(sha1, pathname))
+ walk_tree_ctx->match = 1;
+ } else if (S_ISDIR(mode)) {
+--
+2.14.1
+