Re: cgit-lua: to jit or not to jit

2014-01-14 Thread Justin Cormack
On 14 Jan 2014 03:52, Andrew Starks andrew.sta...@trms.com wrote:



 On Monday, January 13, 2014, Jason A. Donenfeld wrote:

 On Tue, Jan 14, 2014 at 3:37 AM, Andrew Starks andrew.sta...@trms.com
wrote:
 
  I don't have LuaJit installed and would not install it (and migrate
  everything I do over to it) just to use a library. By way of example,
your
  library may as well have been written for Python, for as much good as
it
  would be to me.
 
  By contrast, if you stick to the subset of 5.2 that 5.1 supports, and
/ or
  use a bit of the luacomp library, then anyone with lua 5.1, luajit or
Lua
  5.2 can use it.
 
  The question, from a user's perspective is: what benefit are you
giving me,
  in exchange for locking me into luajit, as a dependency?
 
  Even if I am using Luajit, that doesn't mean that I don't need to
support
  the current, mainline distribution and straight 5.1. So, I can't use
your
  library as a dependency, if this were the case.
 
  It's easier for you if you like what the FFI gives you. Supporting the
  common subset and using luacompat, as necessary, is the simplest, for
the
  user.
 
  IMHO, of course

 That's a fairly compelling opinion. The only thing against it is the
 temptation of using FFI in the default scripts that we ship with cgit.
 But I suppose for the sake of giving users choice later on, it might
 be best, as you've said, to continue to support both, and let the user
 choose.


 Jason,

 I also just remembered this:

 https://github.com/jmckaskill/luaffi

 Which is a luajit compatible FFI extension for Lua 5.1 and Lua 5.2, but
5.2 is listed as beta. It might be worth a shot, if it lets you gain some
of those conveniences and keep a broad support base.


Lua 5.2 support is fine for luaffi, but both are beta, and you have to fix
the bugs yourself as it is only intermittently being developed (by me).

The most important platform that LuaJIT is not available for is probably
softfloat MIPS (eg openwrt).

Justin
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: lua vs luajit vs both

2014-01-14 Thread John Keeping
On Tue, Jan 14, 2014 at 02:02:40AM +0100, Jason A. Donenfeld wrote:
 I've gone ahead and merged the lua work to master, for testing and
 subsequent cleanup before release.
 
 Regarding to jit or not to jit, I currently have this fancy autodetection
 logic:
 http://git.zx2c4.com/cgit/commit/?id=3488d124052f5c3ddef303ed5306ad6a458794c1
 
 John -- I'm waiting for your input on the parent email, as you seem to be
 the originator of the opinion that both are good.

It was more of a there doesn't seem much overhead to supporting both,
since the API is the same.  I think the Makefile should take an
approach more like this though:

ifdef NO_LUA
CGIT_CFLAGS += -DNO_LUA
else if defined(USE_LUAJIT)
# LuaJIT code goes here
else
# Lua code goes here
endif

Basically, use vanilla Lua by default by provide an easy way for users
to switch to LuaJIT if they want.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 1/1] fix UTF-8 with email-gravatar.py

2014-01-14 Thread Christian Hesse
---
 filters/email-gravatar.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/filters/email-gravatar.py b/filters/email-gravatar.py
index f90b87d..5d08ea8 100755
--- a/filters/email-gravatar.py
+++ b/filters/email-gravatar.py
@@ -20,6 +20,7 @@
 
 import sys
 import hashlib
+import codecs
 
 email = sys.argv[1].lower().strip()
 if email[0] == '':
@@ -29,6 +30,9 @@ if email[-1] == '':
 
 page = sys.argv[2]
 
+sys.stdin = codecs.getreader(utf-8)(sys.stdin.detach())
+sys.stdout = codecs.getwriter(utf-8)(sys.stdout.detach())
+
 md5 = hashlib.md5(email.encode()).hexdigest()
 text = sys.stdin.read().strip()
 
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH v3 2/2] filters: Choose 'trac' theme in pygments

2014-01-14 Thread Stefan Tatschner
Am 14.01.2014 02:33, schrieb Jason A. Donenfeld:
 Personally, I think the trac colors are a bit ugly. I like pastie
 best. But this is just preference.

I personally also like the 'default' theme it is pretty much the same as
'pastie' but it does not add a background color to strings. This
background color looks really strange with multiline strings. It might
be another solution. If we use 'default' I think we will have to
overwrite the background color of div class=highlight to white.



signature.asc
Description: OpenPGP digital signature
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Idle time in project overview

2014-01-14 Thread Stefan Tatschner
I don't know if it is a bug or a feature but I think on this nice
mailing list I could ask without being shot or mutilated. :)

If I have a git repository with multiple branches and I push to another
branch as 'master' the idle time on the project overview is not updated.
I think this behaviour is not correct. When I push to another branch as
master the project is absolutely not in an idle state. I think the idle
time should be updated when I push to any branch.

Stefan



signature.asc
Description: OpenPGP digital signature
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH/RFC] tests/: Add t0111-filter.sh

2014-01-14 Thread Lukas Fleischer
This adds basic tests for all types of exec filters.

Signed-off-by: Lukas Fleischer c...@cryptocrack.de
---
This only includes tests for exec filters so far. I will send another
patch for Lua filters once this one is merged.

 tests/filters/capitalize-argv1.sh |  3 +++
 tests/filters/capitalize-stdin.sh |  3 +++
 tests/setup.sh| 13 +
 tests/t0111-filter.sh | 38 ++
 4 files changed, 57 insertions(+)
 create mode 100755 tests/filters/capitalize-argv1.sh
 create mode 100755 tests/filters/capitalize-stdin.sh
 create mode 100755 tests/t0111-filter.sh

diff --git a/tests/filters/capitalize-argv1.sh 
b/tests/filters/capitalize-argv1.sh
new file mode 100755
index 000..2ea0098
--- /dev/null
+++ b/tests/filters/capitalize-argv1.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo $1 | tr '[:lower:]' '[:upper:]'
diff --git a/tests/filters/capitalize-stdin.sh 
b/tests/filters/capitalize-stdin.sh
new file mode 100755
index 000..c9f4719
--- /dev/null
+++ b/tests/filters/capitalize-stdin.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+tr '[:lower:]' '[:upper:]'
diff --git a/tests/setup.sh b/tests/setup.sh
index 5476ced..861f48a 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -58,6 +58,8 @@ else
PATH=$(pwd)/../..:$PATH
 fi
 
+FILTER_DIRECTORY=$(cd ../filters  pwd)
+
 mkrepo() {
name=$1
count=$2
@@ -90,6 +92,7 @@ setup_repos()
mkrepo repos/bar 50 /dev/null
mkrepo repos/foo+bar 10 testplus /dev/null
mkrepo repos/with space 2 /dev/null
+   mkrepo repos/filter 5 testplus /dev/null
cat cgitrc EOF
 virtual-root=/
 cache-root=$PWD/cache
@@ -102,6 +105,7 @@ summary-log=5
 summary-branches=5
 summary-tags=5
 clone-url=git://example.org/\$CGIT_REPO_URL.git
+enable-filter-overrides=1
 
 repo.url=foo
 repo.path=$PWD/repos/foo/.git
@@ -120,6 +124,15 @@ repo.desc=the foo+bar repo
 repo.url=with space
 repo.path=$PWD/repos/with space/.git
 repo.desc=spaced repo
+
+repo.url=filter
+repo.path=$PWD/repos/filter/.git
+repo.desc=filtered repo
+repo.about-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
+repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
+repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-argv1.sh
+repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
+repo.readme=master:a+b
 EOF
 }
 
diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh
new file mode 100755
index 000..2f99880
--- /dev/null
+++ b/tests/t0111-filter.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='Check filtered content'
+. ./setup.sh
+
+test_expect_success 'generate filter/tree/a%2bb' '
+   cgit_url filter/tree/a%2bb tmp
+'
+
+test_expect_success 'check whether the source filter works' '
+   grep codeHELLO$ tmp
+'
+
+test_expect_success 'generate filter/about/' '
+   cgit_url filter/about/ tmp
+'
+
+test_expect_success 'check whether the about filter works' '
+   grep div id='''summary'''HELLO$ tmp
+'
+
+test_expect_success 'generate filter/commit/' '
+   cgit_url filter/commit/ tmp
+'
+
+test_expect_success 'check whether the commit filter works' '
+   grep div class='''commit-subject'''ADD A+B tmp
+'
+
+test_expect_success 'check whether the email filter works for authors' '
+   grep aut...@example.com tmp
+'
+
+test_expect_success 'check whether the email filter works for committers' '
+   grep commit...@example.com tmp
+'
+
+test_done
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 1/1] fix html syntax in email-gravatar.*

2014-01-14 Thread Christian Hesse
* make ampersand a html entity
* add required alt attribute
* add required img end tag
---
 filters/email-gravatar.lua | 2 +-
 filters/email-gravatar.py  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/filters/email-gravatar.lua b/filters/email-gravatar.lua
index 9feb611..22f0641 100644
--- a/filters/email-gravatar.lua
+++ b/filters/email-gravatar.lua
@@ -15,7 +15,7 @@ function filter_open(email, page)
 end
 
 function filter_close()
-   html(img src='//www.gravatar.com/avatar/ .. md5 .. ?s=13d=retro' 
style='height:10pt;width:10pt'  .. buffer)
+   html(img src='//www.gravatar.com/avatar/ .. md5 .. 
?s=13amp;d=retro' style='height:10pt;width:10pt' alt='Gravatar' /  .. 
buffer)
 end
 
 function filter_write(str)
diff --git a/filters/email-gravatar.py b/filters/email-gravatar.py
index 5d08ea8..97f21cf 100755
--- a/filters/email-gravatar.py
+++ b/filters/email-gravatar.py
@@ -36,4 +36,4 @@ sys.stdout = codecs.getwriter(utf-8)(sys.stdout.detach())
 md5 = hashlib.md5(email.encode()).hexdigest()
 text = sys.stdin.read().strip()
 
-print(img src='//www.gravatar.com/avatar/ + md5 + ?s=13d=retro' 
style='height:10pt;width:10pt'  + text)
+print(img src='//www.gravatar.com/avatar/ + md5 + ?s=13amp;d=retro' 
style='height:10pt;width:10pt' alt='Gravatar' /  + text)
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: Idle time in project overview

2014-01-14 Thread John Keeping
On Tue, Jan 14, 2014 at 11:50:23AM +0100, Stefan Tatschner wrote:
 I don't know if it is a bug or a feature but I think on this nice
 mailing list I could ask without being shot or mutilated. :)
 
 If I have a git repository with multiple branches and I push to another
 branch as 'master' the idle time on the project overview is not updated.
 I think this behaviour is not correct. When I push to another branch as
 master the project is absolutely not in an idle state. I think the idle
 time should be updated when I push to any branch.

This question comes up periodically.  The answer is to use a hook to
update an agefile on push.  The best reference is this message:

http://article.gmane.org/gmane.comp.version-control.cgit/1059

It would be nice to have that example hook in the repository somewhere
(contrib/hooks/ ?) if someone feels like working up a patch...
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH 1/1] fix email-gravatar.lua for lua 5.2

2014-01-14 Thread Jason A. Donenfeld
Merged, thanks.

What exactly is the reason for this change in Lua 5.2?
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH 1/1] fix UTF-8 with email-gravatar.py

2014-01-14 Thread Jason A. Donenfeld
Ahhh Python... *sigh*

Merged. Thanks for this.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH 1/1] fix html syntax in email-gravatar.*

2014-01-14 Thread Jason A. Donenfeld
Good catch with amp;. Merged.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH/RFC] tests/: Add t0111-filter.sh

2014-01-14 Thread Jason A. Donenfeld
Terrific! I was hoping something like this would come about. Looking
forward to seeing the lua side of things.

There's another change I'm going to be pushing later today that
involves being able to do meaningful things with the
cgit_filter_close() exit code. I'll then be using this to /maybe/
implement a basic authentication infrastructure. Stand by! Exciting
things are happening.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH] filter: refactor cgit_new_filter()

2014-01-14 Thread Jason A. Donenfeld
From: Lukas Fleischer c...@cryptocrack.de

Use prefixcmp() as a preparation for using strip_prefix() later. Also,
interpret the command as a file name if it contains a colon but none of
the filter prefixes matches instead of bailing out and adding a special
check for Windows.

Signed-off-by: Lukas Fleischer c...@cryptocrack.de
---
John -- this is your code so I'm awaiting your input on this.
Personally, I like receiving an error message that says invalid filter
type, and this patch kills that. But I'll go with whatever you prefer.

 filter.c | 30 +++---
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/filter.c b/filter.c
index 4d4acaf..1997881 100644
--- a/filter.c
+++ b/filter.c
@@ -379,31 +379,19 @@ static const struct {
const char *prefix;
struct cgit_filter *(*ctor)(const char *cmd, int argument_count);
 } filter_specs[] = {
-   { exec, new_exec_filter },
+   { exec:, new_exec_filter },
 #ifndef NO_LUA
-   { lua, new_lua_filter },
+   { lua:, new_lua_filter },
 #endif
 };
 
 struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype)
 {
-   char *colon;
-   int i;
-   size_t len;
-   int argument_count;
+   int argument_count, i;
 
if (!cmd || !cmd[0])
return NULL;
 
-   colon = strchr(cmd, ':');
-   len = colon - cmd;
-   /*
-* In case we're running on Windows, don't allow a single letter before
-* the colon.
-*/
-   if (len == 1)
-   colon = NULL;
-
switch (filtertype) {
case EMAIL:
argument_count = 2;
@@ -420,15 +408,11 @@ struct cgit_filter *cgit_new_filter(const char *cmd, 
filter_type filtertype)
break;
}
 
-   /* If no prefix is given, exec filter is the default. */
-   if (!colon)
-   return new_exec_filter(cmd, argument_count);
-
for (i = 0; i  ARRAY_SIZE(filter_specs); i++) {
-   if (len == strlen(filter_specs[i].prefix) 
-   !strncmp(filter_specs[i].prefix, cmd, len))
-   return filter_specs[i].ctor(colon + 1, argument_count);
+   if (!prefixcmp(cmd, filter_specs[i].prefix))
+   return filter_specs[i].ctor(strchr(cmd, ':') + 1, 
argument_count);
}
 
-   die(Invalid filter type: %.*s, (int) len, cmd);
+   /* If no valid prefix is given, exec filter is the default. */
+   return new_exec_filter(cmd, argument_count);
 }
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: cgit-lua: to jit or not to jit

2014-01-14 Thread Jason A. Donenfeld
On Tue, Jan 14, 2014 at 4:51 AM, Andrew Starks andrew.sta...@trms.com wrote:

 I also just remembered this:

 https://github.com/jmckaskill/luaffi

 Which is a luajit compatible FFI extension for Lua 5.1 and Lua 5.2, but 5.2
 is listed as beta. It might be worth a shot, if it lets you gain some of
 those conveniences and keep a broad support base.

Excellent! Thanks Andrew.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 1/1] filter: fix lua function name

2014-01-14 Thread Christian Hesse
---
 filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/filter.c b/filter.c
index 44af434..0cce7bb 100644
--- a/filter.c
+++ b/filter.c
@@ -319,7 +319,7 @@ static int close_lua_filter(struct cgit_filter *base)
error_lua_filter(filter);
ret = -1;
} else {
-   ret = lua_to_number(filter-lua_state, -1);
+   ret = lua_tonumber(filter-lua_state, -1);
lua_pop(filter-lua_state, 1);
}
 
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH 1/1] fix email-gravatar.lua for lua 5.2

2014-01-14 Thread Christian Hesse
Jason A. Donenfeld ja...@zx2c4.com on Tue, 2014/01/14 13:48:
 Merged, thanks.
 
 What exactly is the reason for this change in Lua 5.2?

No idea. Just noticed it is broken and fixed it. ;)
-- 
Schoene Gruesse
Chris
 O ascii ribbon campaign
   stop html mail - www.asciiribbon.org


signature.asc
Description: PGP signature
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH 1/1] filter: fix lua function name

2014-01-14 Thread Jason A. Donenfeld
Wow you're quick. I pushed and then [improperly] rebased within a
matter of 15 seconds. But I guess you caught this anyway.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [RESEND PATCH 1/1] enable cgit to show gravatar for author, committer and tagger

2014-01-14 Thread Jason A. Donenfeld
On Tue, Jan 14, 2014 at 6:22 PM, Christian Hesse l...@eworm.de wrote:
 Looks better, though not perfect.
 At least firefox still scales the image a bit.

Can you investigate the whole px to pt situation, line-height, and
the best way to manage this?
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [RESEND PATCH 1/1] enable cgit to show gravatar for author, committer and tagger

2014-01-14 Thread Christian Hesse
Jason A. Donenfeld ja...@zx2c4.com on Tue, 2014/01/14 18:23:
 On Tue, Jan 14, 2014 at 6:22 PM, Christian Hesse l...@eworm.de wrote:
  Looks better, though not perfect.
  At least firefox still scales the image a bit.
 
 Can you investigate the whole px to pt situation, line-height, and
 the best way to manage this?

pixels = points * 96 / 72

So for 10pt:

10 * 96 / 72 = 13.334

The browser scales the image, then keeps the full pixels.

Probably the only way to not have this is to use pixel only for images.
Want a patch?
-- 
main(a){char*c=/*Schoene Gruesse */B?IJj;MEH
CX:;,b;for(a/*Chris   get my mail address:*/=0;b=c[a++];)
putchar(b-1/(/*   gcc -o sig sig.c  ./sig*/b/42*2-3)*42);}


signature.asc
Description: PGP signature
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [RESEND PATCH 1/1] enable cgit to show gravatar for author, committer and tagger

2014-01-14 Thread René Neumann
Am 14.01.2014 18:35, schrieb Christian Hesse:
 Jason A. Donenfeld ja...@zx2c4.com on Tue, 2014/01/14 18:23:
 On Tue, Jan 14, 2014 at 6:22 PM, Christian Hesse l...@eworm.de wrote:
 Looks better, though not perfect.
 At least firefox still scales the image a bit.

 Can you investigate the whole px to pt situation, line-height, and
 the best way to manage this?
 
 pixels = points * 96 / 72

96 only iff DPI=96, isn't it?




signature.asc
Description: OpenPGP digital signature
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [RESEND PATCH 1/1] enable cgit to show gravatar for author, committer and tagger

2014-01-14 Thread Jason A. Donenfeld
On Tue, Jan 14, 2014 at 6:35 PM, Christian Hesse l...@eworm.de wrote:
 Probably the only way to not have this is to use pixel only for images.
 Want a patch?

I think I have it handled. Would you look at git.zx2c4.com/cgit/log/
and tell me if that looks better to you?
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [RESEND PATCH 1/1] enable cgit to show gravatar for author, committer and tagger

2014-01-14 Thread Christian Hesse
Jason A. Donenfeld ja...@zx2c4.com on Tue, 2014/01/14 18:51:
 On Tue, Jan 14, 2014 at 6:35 PM, Christian Hesse l...@eworm.de wrote:
  Probably the only way to not have this is to use pixel only for images.
  Want a patch?
 
 I think I have it handled. Would you look at git.zx2c4.com/cgit/log/
 and tell me if that looks better to you?

Looks good to me.

Though this may result in images that do not fit font size if dpi is a lot
more or less than 96 as René pointed.
-- 
main(a){char*c=/*Schoene Gruesse */B?IJj;MEH
CX:;,b;for(a/*Chris   get my mail address:*/=0;b=c[a++];)
putchar(b-1/(/*   gcc -o sig sig.c  ./sig*/b/42*2-3)*42);}


signature.asc
Description: PGP signature
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [RESEND PATCH 1/1] enable cgit to show gravatar for author, committer and tagger

2014-01-14 Thread Jason A. Donenfeld
On Tue, Jan 14, 2014 at 6:58 PM, Christian Hesse l...@eworm.de wrote:
 Looks good to me.

 Though this may result in images that do not fit font size if dpi is a lot
 more or less than 96 as René pointed.

Anybody want to try with a fancy retina iPad or the like?
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: lua vs luajit vs both

2014-01-14 Thread Jason A. Donenfeld


On Tue, Jan 14, 2014 at 10:08 AM, John Keeping j...@keeping.me.uk wrote:
 It was more of a there doesn't seem much overhead to supporting both,
 since the API is the same.  I think the Makefile should take an
 approach more like this though:

 ifdef NO_LUA
 CGIT_CFLAGS += -DNO_LUA
 else if defined(USE_LUAJIT)
 # LuaJIT code goes here
 else
 # Lua code goes here
 endif

Okay we've got this fancy autodetection logic now. From the README:

 If you'd like to compile without Lua support, you may use:
$ make NO_LUA=1
 And if you'd like to specify a Lua implementation, you may use:
$ make LUA_IMPLEMENTATION=JIT
 for using the LuaJIT project. Or:

$ make LUA_IMPLEMENTATION=VANILLA
 for the mainline Lua project. If you specify neither implementation, it will
 be auto-detected, preferring LuaJIT if both are present.

From cgit.mk:

 ifdef NO_LUA
 LUA_MESSAGE := linking without specified Lua support
 CGIT_CFLAGS += -DNO_LUA
 else
 LUAJIT_CFLAGS := $(shell pkg-config --cflags luajit 2/dev/null)
 LUAJIT_LIBS := $(shell pkg-config --libs luajit 2/dev/null)
 LUA_LIBS := $(shell pkg-config --libs lua 2/dev/null)
 LUA_CFLAGS := $(shell pkg-config --cflags lua 2/dev/null)
 ifeq (JIT,$(LUA_IMPLEMENTATION))
 ifeq ($(strip $(LUAJIT_LIBS)),)
  $(error LuaJIT specified via LUA_IMPLEMENTATION=JIT, but library 
 could not be found.)
 endif
 LUA_MESSAGE := linking with selected LuaJIT
 CGIT_LIBS += $(LUAJIT_LIBS)
 CGIT_CFLAGS += $(LUAJIT_CFLAGS)
 else ifeq (VANILLA,$(LUA_IMPLEMENTATION))
 ifeq ($(strip $(LUA_LIBS)),)
  $(error Lua specified via LUA_IMPLEMENTATION=VANILLA, but library 
 could not be found.)
 endif
 LUA_MESSAGE := linking with selected Lua
 CGIT_LIBS += $(LUA_LIBS)
 CGIT_LIBS += $(LUA_CFLAGS)
 else ifneq ($(strip $(LUAJIT_LIBS)),)
 LUA_MESSAGE := linking with autodetected LuaJIT
 CGIT_LIBS += $(LUAJIT_LIBS)
 CGIT_CFLAGS += $(LUAJIT_CFLAGS)
 else ifneq ($(strip $(LUA_LIBS)),)
 LUA_MESSAGE := linking with autodetected Lua
 CGIT_LIBS += $(LUA_LIBS)
 CGIT_CFLAGS += $(LUA_CFLAGS)
 else
 LUA_MESSAGE := linking without autodetected Lua support
 NO_LUA := YesPlease
 CGIT_CFLAGS += -DNO_LUA
 endif

 endif

 # Add -ldl to linker flags on non-BSD systems.
 ifeq ($(findstring BSD,$(uname_S)),)
 CGIT_LIBS += -ldl
 endif

How's this look to you? The correct way to be doing things?
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: cgit-lua: to jit or not to jit

2014-01-14 Thread Florian Weimer
* Jason A. Donenfeld:

 On Tue, Jan 14, 2014 at 3:10 AM, demetri demetri.spa...@gmail.com wrote:
 1) PUC Lua works on more machines/architectures (though Mike has
 substantially closed the gap for most architectures people care about in a
 non-embedded non-mobile environment)

 Do you know what the gap is?

 LuaJIT supports x86, x86_x64, arm, ppc, e500, and mips. I guess that
 leaves, what? Sparc, AVR, ia64, ... other obscure ones? Hmm..

ppc64 and s390x.  Neither one is particularly obscure.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 1/2] t0111: Prepare for other filter prefixes

2014-01-14 Thread Lukas Fleischer
Rename the filter repository to filter-exec. The Git repository itself
is not renamed since it can be shared amongst all filter types.

Signed-off-by: Lukas Fleischer c...@cryptocrack.de
---
 tests/setup.sh|  2 +-
 tests/t0111-filter.sh | 22 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/setup.sh b/tests/setup.sh
index 861f48a..6499836 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -125,7 +125,7 @@ repo.url=with space
 repo.path=$PWD/repos/with space/.git
 repo.desc=spaced repo
 
-repo.url=filter
+repo.url=filter-exec
 repo.path=$PWD/repos/filter/.git
 repo.desc=filtered repo
 repo.about-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh
index 2f99880..c7e9d05 100755
--- a/tests/t0111-filter.sh
+++ b/tests/t0111-filter.sh
@@ -3,35 +3,35 @@
 test_description='Check filtered content'
 . ./setup.sh
 
-test_expect_success 'generate filter/tree/a%2bb' '
-   cgit_url filter/tree/a%2bb tmp
+test_expect_success 'generate filter-exec/tree/a%2bb' '
+   cgit_url filter-exec/tree/a%2bb tmp
 '
 
-test_expect_success 'check whether the source filter works' '
+test_expect_success 'check whether the exec source filter works' '
grep codeHELLO$ tmp
 '
 
-test_expect_success 'generate filter/about/' '
-   cgit_url filter/about/ tmp
+test_expect_success 'generate filter-exec/about/' '
+   cgit_url filter-exec/about/ tmp
 '
 
-test_expect_success 'check whether the about filter works' '
+test_expect_success 'check whether the exec about filter works' '
grep div id='''summary'''HELLO$ tmp
 '
 
-test_expect_success 'generate filter/commit/' '
-   cgit_url filter/commit/ tmp
+test_expect_success 'generate filter-exec/commit/' '
+   cgit_url filter-exec/commit/ tmp
 '
 
-test_expect_success 'check whether the commit filter works' '
+test_expect_success 'check whether the exec commit filter works' '
grep div class='''commit-subject'''ADD A+B tmp
 '
 
-test_expect_success 'check whether the email filter works for authors' '
+test_expect_success 'check whether the exec email filter works for authors' '
grep aut...@example.com tmp
 '
 
-test_expect_success 'check whether the email filter works for committers' '
+test_expect_success 'check whether the exec email filter works for committers' 
'
grep commit...@example.com tmp
 '
 
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 2/2] t0111: Add basic tests for Lua filters

2014-01-14 Thread Lukas Fleischer
Signed-off-by: Lukas Fleischer c...@cryptocrack.de
---
 tests/filters/capitalize-buffer.lua | 14 ++
 tests/setup.sh  |  9 +
 tests/t0111-filter.sh   | 32 
 3 files changed, 55 insertions(+)
 create mode 100644 tests/filters/capitalize-buffer.lua

diff --git a/tests/filters/capitalize-buffer.lua 
b/tests/filters/capitalize-buffer.lua
new file mode 100644
index 000..7ca4ec6
--- /dev/null
+++ b/tests/filters/capitalize-buffer.lua
@@ -0,0 +1,14 @@
+function filter_open(...)
+   buffer = 
+end
+
+function filter_close()
+   html(buffer)
+   return 0
+end
+
+function filter_write(str)
+   buffer = buffer .. string.upper(str)
+end
+
+
diff --git a/tests/setup.sh b/tests/setup.sh
index 6499836..529f410 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -133,6 +133,15 @@ 
repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
 repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-argv1.sh
 repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
 repo.readme=master:a+b
+
+repo.url=filter-lua
+repo.path=$PWD/repos/filter/.git
+repo.desc=filtered repo
+repo.about-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua
+repo.commit-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua
+repo.email-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua
+repo.source-filter=lua:$FILTER_DIRECTORY/capitalize-buffer.lua
+repo.readme=master:a+b
 EOF
 }
 
diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh
index c7e9d05..3833de4 100755
--- a/tests/t0111-filter.sh
+++ b/tests/t0111-filter.sh
@@ -35,4 +35,36 @@ test_expect_success 'check whether the exec email filter 
works for committers' '
grep commit...@example.com tmp
 '
 
+test_expect_success 'generate filter-lua/tree/a%2bb' '
+   cgit_url filter-lua/tree/a%2bb tmp
+'
+
+test_expect_success 'check whether the Lua source filter works' '
+   grep codeHELLO$ tmp
+'
+
+test_expect_success 'generate filter-lua/about/' '
+   cgit_url filter-lua/about/ tmp
+'
+
+test_expect_success 'check whether the Lua about filter works' '
+   grep div id='''summary'''HELLO$ tmp
+'
+
+test_expect_success 'generate filter-lua/commit/' '
+   cgit_url filter-lua/commit/ tmp
+'
+
+test_expect_success 'check whether the Lua commit filter works' '
+   grep div class='''commit-subject'''ADD A+B tmp
+'
+
+test_expect_success 'check whether the Lua email filter works for authors' '
+   grep A U THOR LT;aut...@example.comGT; tmp
+'
+
+test_expect_success 'check whether the Lua email filter works for committers' '
+   grep C O MITTER LT;commit...@example.comGT; tmp
+'
+
 test_done
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH] filter: refactor cgit_new_filter()

2014-01-14 Thread John Keeping
On Tue, Jan 14, 2014 at 02:00:48PM +0100, Jason A. Donenfeld wrote:
 From: Lukas Fleischer c...@cryptocrack.de
 
 Use prefixcmp() as a preparation for using strip_prefix() later. Also,
 interpret the command as a file name if it contains a colon but none of
 the filter prefixes matches instead of bailing out and adding a special
 check for Windows.
 
 Signed-off-by: Lukas Fleischer c...@cryptocrack.de
 ---
 John -- this is your code so I'm awaiting your input on this.
 Personally, I like receiving an error message that says invalid filter
 type, and this patch kills that. But I'll go with whatever you prefer.

Yeah, it would be nice to keep the unrecognised prefix warning.

I like the simplification, but I'm not sure the result is better.  Even
without the rest we should replace the strncmp with prefixcmp though.

There's actually no reason we couldn't mutate cmd here, which would
simplify it a lot, but I'm not sure we want to remove the const
modifiers all the way through.  Then we can just do *colon = '\0' and
use strcmp.

  filter.c | 30 +++---
  1 file changed, 7 insertions(+), 23 deletions(-)
 
 diff --git a/filter.c b/filter.c
 index 4d4acaf..1997881 100644
 --- a/filter.c
 +++ b/filter.c
 @@ -379,31 +379,19 @@ static const struct {
   const char *prefix;
   struct cgit_filter *(*ctor)(const char *cmd, int argument_count);
  } filter_specs[] = {
 - { exec, new_exec_filter },
 + { exec:, new_exec_filter },
  #ifndef NO_LUA
 - { lua, new_lua_filter },
 + { lua:, new_lua_filter },
  #endif
  };
  
  struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype)
  {
 - char *colon;
 - int i;
 - size_t len;
 - int argument_count;
 + int argument_count, i;
  
   if (!cmd || !cmd[0])
   return NULL;
  
 - colon = strchr(cmd, ':');
 - len = colon - cmd;
 - /*
 -  * In case we're running on Windows, don't allow a single letter before
 -  * the colon.
 -  */
 - if (len == 1)
 - colon = NULL;
 -
   switch (filtertype) {
   case EMAIL:
   argument_count = 2;
 @@ -420,15 +408,11 @@ struct cgit_filter *cgit_new_filter(const char *cmd, 
 filter_type filtertype)
   break;
   }
  
 - /* If no prefix is given, exec filter is the default. */
 - if (!colon)
 - return new_exec_filter(cmd, argument_count);
 -
   for (i = 0; i  ARRAY_SIZE(filter_specs); i++) {
 - if (len == strlen(filter_specs[i].prefix) 
 - !strncmp(filter_specs[i].prefix, cmd, len))
 - return filter_specs[i].ctor(colon + 1, argument_count);
 + if (!prefixcmp(cmd, filter_specs[i].prefix))
 + return filter_specs[i].ctor(strchr(cmd, ':') + 1, 
 argument_count);

Using strchr here feels wrong, why not:

cmd + strlen(filter_specs[i].prefix)

?

   }
  
 - die(Invalid filter type: %.*s, (int) len, cmd);
 + /* If no valid prefix is given, exec filter is the default. */
 + return new_exec_filter(cmd, argument_count);
  }
 -- 
 1.8.5.2
 
 ___
 CGit mailing list
 CGit@lists.zx2c4.com
 http://lists.zx2c4.com/mailman/listinfo/cgit
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: cgit-lua: to jit or not to jit

2014-01-14 Thread Eric Wing
 But perhaps there
 are some obvious downsides to this approach that I also am missing.

Here are a few more potential downsides not mentioned so far.

One is that iOS and Windows Store policies disallow JIT. While you can
disable this part in LuaJIT, most of the performance advantages
disappear when you do this.

Additionally, if you want/need to modify Lua, it is much easier to
modify canonical Lua as opposed to LuaJIT. It is also easy to find Lua
patches (power patches).

On a similar vein, I would imagine auditing code for things like
security or high availability would be easier with canonical Lua.
(Look to Wikimedia Commons and Verisign talks about what they needed
to accomplish.) If you or you have users that worry about this kind of
thing, they may be more reassured if you retain compatibility with
both.

Thanks,
Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: cgit-lua: to jit or not to jit

2014-01-14 Thread Coda Highland
On Tue, Jan 14, 2014 at 12:50 PM, Coda Highland chighl...@gmail.com wrote:
 On Tue, Jan 14, 2014 at 12:41 PM, Eric Wing ewmail...@gmail.com wrote:
 But perhaps there
 are some obvious downsides to this approach that I also am missing.

 Here are a few more potential downsides not mentioned so far.

 One is that iOS and Windows Store policies disallow JIT. While you can
 disable this part in LuaJIT, most of the performance advantages
 disappear when you do this.

 However, even with the JIT disabled, LuaJIT does tend to outperform
 Lua for a lot of use cases (Lua wins in a few cases) just by virtue of
 having an interpreter written in hand-tuned assembly.

 /s/ Adam

Addendum: FFI still works on iOS at least, and probably WinRT.

/s/ Adam
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


ssh clone config

2014-01-14 Thread Doug Carter

Hi All,

Sorry if this is already an answered question, but I've been through
the docs and the mailing list archives but couldn't find anything.

I have a local, in house gitolite repo with the latest cgit up and
running. Since it's private and open to all engineers, I'd like to create
a some ssl clone text that can be copy/pasted like github does it:

  g...@git.foo.com:repo.git

Is there a way to do this and not include any URLs?

TIA

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH v2 1/3] t0111: Prepare for other filter prefixes

2014-01-14 Thread Lukas Fleischer
* Validate the email filter by manipulating stdin. Additional checks for
  all the arguments can be added in a later patch.

* Add the exec prefix to all informational messages.

* Rename the filter repository to filter-exec. The Git repository itself
  is not renamed since it can be shared amongst all filter types.

Signed-off-by: Lukas Fleischer c...@cryptocrack.de
---
 tests/filters/capitalize-argv1.sh |  3 ---
 tests/setup.sh|  4 ++--
 tests/t0111-filter.sh | 26 +-
 3 files changed, 15 insertions(+), 18 deletions(-)
 delete mode 100755 tests/filters/capitalize-argv1.sh

diff --git a/tests/filters/capitalize-argv1.sh 
b/tests/filters/capitalize-argv1.sh
deleted file mode 100755
index 2ea0098..000
--- a/tests/filters/capitalize-argv1.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo $1 | tr '[:lower:]' '[:upper:]'
diff --git a/tests/setup.sh b/tests/setup.sh
index 861f48a..a0a9be2 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -125,12 +125,12 @@ repo.url=with space
 repo.path=$PWD/repos/with space/.git
 repo.desc=spaced repo
 
-repo.url=filter
+repo.url=filter-exec
 repo.path=$PWD/repos/filter/.git
 repo.desc=filtered repo
 repo.about-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
 repo.commit-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
-repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-argv1.sh
+repo.email-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
 repo.source-filter=exec:$FILTER_DIRECTORY/capitalize-stdin.sh
 repo.readme=master:a+b
 EOF
diff --git a/tests/t0111-filter.sh b/tests/t0111-filter.sh
index 2f99880..c235652 100755
--- a/tests/t0111-filter.sh
+++ b/tests/t0111-filter.sh
@@ -3,36 +3,36 @@
 test_description='Check filtered content'
 . ./setup.sh
 
-test_expect_success 'generate filter/tree/a%2bb' '
-   cgit_url filter/tree/a%2bb tmp
+test_expect_success 'generate filter-exec/tree/a%2bb' '
+   cgit_url filter-exec/tree/a%2bb tmp
 '
 
-test_expect_success 'check whether the source filter works' '
+test_expect_success 'check whether the exec source filter works' '
grep codeHELLO$ tmp
 '
 
-test_expect_success 'generate filter/about/' '
-   cgit_url filter/about/ tmp
+test_expect_success 'generate filter-exec/about/' '
+   cgit_url filter-exec/about/ tmp
 '
 
-test_expect_success 'check whether the about filter works' '
+test_expect_success 'check whether the exec about filter works' '
grep div id='''summary'''HELLO$ tmp
 '
 
-test_expect_success 'generate filter/commit/' '
-   cgit_url filter/commit/ tmp
+test_expect_success 'generate filter-exec/commit/' '
+   cgit_url filter-exec/commit/ tmp
 '
 
-test_expect_success 'check whether the commit filter works' '
+test_expect_success 'check whether the exec commit filter works' '
grep div class='''commit-subject'''ADD A+B tmp
 '
 
-test_expect_success 'check whether the email filter works for authors' '
-   grep aut...@example.com tmp
+test_expect_success 'check whether the exec email filter works for authors' '
+   grep A U THOR LT;aut...@example.comGT; tmp
 '
 
-test_expect_success 'check whether the email filter works for committers' '
-   grep commit...@example.com tmp
+test_expect_success 'check whether the exec email filter works for committers' 
'
+   grep C O MITTER LT;commit...@example.comGT; tmp
 '
 
 test_done
-- 
1.8.5.2

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: [PATCH] filter: refactor cgit_new_filter()

2014-01-14 Thread John Keeping
On Tue, Jan 14, 2014 at 09:54:21PM +0100, Jason A. Donenfeld wrote:
 On Tue, Jan 14, 2014 at 9:39 PM, John Keeping j...@keeping.me.uk wrote:
  I like the simplification, but I'm not sure the result is better.  Even
  without the rest we should replace the strncmp with prefixcmp though.
 
 Agreed.
 
  There's actually no reason we couldn't mutate cmd here, which would
  simplify it a lot, but I'm not sure we want to remove the const
  modifiers all the way through.  Then we can just do *colon = '\0' and
  use strcmp.
 
 IMHO, it's better to keep lookup tables like these in the read-only
 section. Let's keep the constness.

I meant for the input, which is read from the config file.  Just
terminate the user-specified command string at the colon and treat it as
two genuinely separate strings.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: cgit-lua: to jit or not to jit

2014-01-14 Thread malkia
One more thing for luajit vs. lua - If you ship a plugin (.so, .dll,
.dylib) using luajit, then the host application might not always work
with it. If I'm not mistaken the lower 2GB (or 4GB?) must be allocated
to luajit, (so even in 64-bit app, it needs the lower 32-bit address
space - for lua allocated objects).


On Tue, Jan 14, 2014 at 12:50 PM, Coda Highland chighl...@gmail.com wrote:
 On Tue, Jan 14, 2014 at 12:50 PM, Coda Highland chighl...@gmail.com wrote:
 On Tue, Jan 14, 2014 at 12:41 PM, Eric Wing ewmail...@gmail.com wrote:
 But perhaps there
 are some obvious downsides to this approach that I also am missing.

 Here are a few more potential downsides not mentioned so far.

 One is that iOS and Windows Store policies disallow JIT. While you can
 disable this part in LuaJIT, most of the performance advantages
 disappear when you do this.

 However, even with the JIT disabled, LuaJIT does tend to outperform
 Lua for a lot of use cases (Lua wins in a few cases) just by virtue of
 having an interpreter written in hand-tuned assembly.

 /s/ Adam

 Addendum: FFI still works on iOS at least, and probably WinRT.

 /s/ Adam




-- 
Dimiter malkia Stanev,
ICQ: 21875894
mal...@mac.com
mal...@gmail.com
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit