From 7c2dea03674b54aa43d17a93e6e550f03759c95f Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <info@cryptocrack.de>
Date: Wed, 19 Jan 2011 14:05:48 +0100
Subject: Makefile: Make `make get-git` work under OpenBSD.

OpenBSD tar(1) defaults to read from "/dev/rst0" when not specifying an
filename and thus fails to extract the Git sourcecode when not passing
stdin as input file descriptor explicitly.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

diff --git a/Makefile b/Makefile
index 2dae3ac..3bdc218 100644
--- a/Makefile
+++ b/Makefile
@@ -168,4 +168,4 @@ clean-doc:
 	rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
 
 get-git:
-	curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git
+	curl $(GIT_URL) | tar -xjf - && rm -rf git && mv git-$(GIT_VER) git
-- 
cgit v0.10.1


From 6bf2658f04089179aa373e47bd1d0718e808a59b Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Thu, 23 Dec 2010 12:47:53 +0100
Subject: ui-shared: silence warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

warning: format ‘%ld’ expects type ‘long int’, but argument 2 has type
‘size_t’

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>

diff --git a/ui-shared.c b/ui-shared.c
index 8a7cc32..d1b020b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -466,7 +466,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
 	else if (ctx->page.mimetype)
 		htmlf("Content-Type: %s\n", ctx->page.mimetype);
 	if (ctx->page.size)
-		htmlf("Content-Length: %ld\n", ctx->page.size);
+		htmlf("Content-Length: %zd\n", ctx->page.size);
 	if (ctx->page.filename)
 		htmlf("Content-Disposition: inline; filename=\"%s\"\n",
 		      ctx->page.filename);
-- 
cgit v0.10.1


From fc384b16fb9787380746000d3cea2d53fccc548e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 28 Feb 2011 12:18:57 +0100
Subject: do not infloop on a query ending in %XY, for invalid hex X or Y

When a query ends in say %gg, (or any invalid hex) e.g.,
http://git.gnome.org/browse/gdlmm/commit/?id=%gg
convert_query_hexchar calls memmove(txt, txt+3, 0), and then returns
txt-1, so the loop in http_parse_querystring never terminates.  The
solution is to make the memmove also copy the trailing NUL.
* html.c (convert_query_hexchar): Fix off-by-one error.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

diff --git a/html.c b/html.c
index d86b2c1..5336596 100644
--- a/html.c
+++ b/html.c
@@ -249,7 +249,7 @@ char *convert_query_hexchar(char *txt)
 	d1 = hextoint(*(txt+1));
 	d2 = hextoint(*(txt+2));
 	if (d1<0 || d2<0) {
-		memmove(txt, txt+3, n-3);
+		memmove(txt, txt+3, n-2);
 		return txt-1;
 	} else {
 		*txt = d1 * 16 + d2;
-- 
cgit v0.10.1


From d0cb8413ffd5319c623d832802abe6a6d5795679 Mon Sep 17 00:00:00 2001
From: Lars Hjemli <hjemli@gmail.com>
Date: Sat, 5 Mar 2011 13:47:04 +0100
Subject: Avoid trailing slash in virtual-root

When setting virtual-root from cgitrc, care is taken to avoid trailing
slashes. But when no virtual-root setting is specified, SCRIPT_FILE
from the web server is used without similar checks. This patch fixes the
inconsistency, which could lead to double-slashes in generated links.

Noticed-by: Wouter Van Hemel <wouter@duodecim.org>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>

diff --git a/cgit.c b/cgit.c
index ad62d10..af9832f 100644
--- a/cgit.c
+++ b/cgit.c
@@ -679,10 +679,11 @@ int main(int argc, const char **argv)
 	http_parse_querystring(ctx.qry.raw, querystring_cb);
 
 	/* If virtual-root isn't specified in cgitrc, lets pretend
-	 * that virtual-root equals SCRIPT_NAME.
+	 * that virtual-root equals SCRIPT_NAME, minus any possibly
+	 * trailing slashes.
 	 */
 	if (!ctx.cfg.virtual_root)
-		ctx.cfg.virtual_root = ctx.cfg.script_name;
+		ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/');
 
 	/* If no url parameter is specified on the querystring, lets
 	 * use PATH_INFO as url. This allows cgit to work with virtual
-- 
cgit v0.10.1


From 9e849950dc7c1f2fb6ffa62ab65bd30f35717d13 Mon Sep 17 00:00:00 2001
From: Lars Hjemli <hjemli@gmail.com>
Date: Sat, 5 Mar 2011 13:52:39 +0100
Subject: CGIT 0.8.3.5

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

diff --git a/Makefile b/Makefile
index 3bdc218..304521e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CGIT_VERSION = v0.8.3.4
+CGIT_VERSION = v0.8.3.5
 CGIT_SCRIPT_NAME = cgit.cgi
 CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
 CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
-- 
cgit v0.10.1