Dilluti0n의 블로그

지난번에 apache2 를 통해 /Users/git/Sites 내의 Symlink 를 통해 http 접속을 구현하는 것을 알아봤는데, 이 기능은 단순히 http 프로토콜을 통해 클라이언트가 리포지토리를 fetch 할 수 있도록 한다.

~git 에 브라우저로 접속한다면 리포지토리의 내용을 볼 수 없기 때문에, 이를 가능하게 하는 서버인 cgit 을 설치할 것이다.

sudo port install lua51 py-docutils py-markdown py-pygments zlib

으로 빌드 의존성을 설치하고,

git clone https://git.zx2c4.com/cgit

cd cgit

git submodule init
git submodule update

CGIT_SCRIPT_PATH = /usr/local/var/www/html/cgit/cgi
CGIT_CONFIG = /usr/local/var/www/html/cgit/cgitrc
CACHE_ROOT = /usr/local/var/www/html/cgit/cache
prefix = /usr/local/var/www/html/cgit
libdir = $(prefix)
filterdir = $(libdir)/filters

[hskimse@beta cgit]$ git add -f cgit.conf
[hskimse@beta cgit]$ git commit -m "installation path change"

컴파일 시

../ui-shared.c:1254:50: error: implicit declaration of function 'memrchr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        for (last_slash = path + strlen(path); (slash = memrchr(path, '/', last_slash - path)) != NULL; last_slash = slash) {
                                                        ^

에러가 발생한다. memrchr 가 Darwin 의 libc 에 없는 듯 하다.

diff --git a/ui-shared.c b/ui-shared.c
index 6fae72d..5772087 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -14,6 +15,18 @@
 #include "html.h"
 #include "version.h"

+#include <stddef.h>
+
+void *memrchr(const void *s, int c, size_t n) {
+       const unsigned char *p = (const unsigned char *)s + n;
+
+       while (n--) {
+               if (*--p == (unsigned char)c)
+                       return (void *)p;
+       }
+       return NULL;
+}
+
 static const char cgit_doctype[] =
 "<!DOCTYPE html>\n";

이 패치를 통해 해결했다.