Add a --prefix option to git-daemon. This path is prepended to the search path for repositories. In other words, git://hostname/path/to/gitdir will result in looking for /prefix/path/to/gitdir. Signed-off-by: Brad Roberts <braddr@puremagic.com> --- daemon.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) applies-to: ccef5ac580c68a9714f37dcd8ee433e9691b640a 4ab5253ba31370d151843ca14a8cabcadc37c974 diff --git a/daemon.c b/daemon.c index 0c6182f..566bec6 100644 --- a/daemon.c +++ b/daemon.c @@ -15,7 +15,7 @@ static int verbose; static const char daemon_usage[] = "git-daemon [--verbose] [--syslog] [--inetd | --port=n] [--export-all]\n" -" [--timeout=n] [--init-timeout=n] [directory...]"; +" [--timeout=n] [--init-timeout=n] [--prefix=directory] [directory...]"; /* List of acceptable pathname prefixes */ static char **ok_paths = NULL; @@ -27,6 +27,9 @@ static int export_all_trees = 0; static unsigned int timeout = 0; static unsigned int init_timeout = 0; +/* directory prefix for all repositories */ +static const char *directory_prefix = ""; + static void logreport(int priority, const char *err, va_list params) { /* We should do a single write so that it is atomic and output @@ -170,10 +173,10 @@ static int set_dir(const char *dir) static int upload(char *dir) { /* Try paths in this order */ - static const char *paths[] = { "%s", "%s/.git", "%s.git", "%s.git/.git", NULL }; + static const char *paths[] = { "%s%s", "%s%s/.git", "%s%s.git", "%s%s.git/.git", NULL }; const char **pp; /* Enough for the longest path above including final null */ - int buflen = strlen(dir)+10; + int buflen = strlen(dir)+strlen(directory_prefix)+10; char *dirbuf = xmalloc(buflen); /* Timeout as string */ char timeout_buf[64]; @@ -181,7 +184,7 @@ static int upload(char *dir) loginfo("Request for '%s'", dir); for ( pp = paths ; *pp ; pp++ ) { - snprintf(dirbuf, buflen, *pp, dir); + snprintf(dirbuf, buflen, *pp, directory_prefix, dir); if ( !set_dir(dirbuf) ) break; } @@ -615,6 +618,10 @@ int main(int argc, char **argv) if (!strncmp(arg, "--init-timeout=", 15)) { init_timeout = atoi(arg+15); } + if (!strncmp(arg, "--prefix=", 9)) { + directory_prefix = arg+9; + continue; + } if (!strcmp(arg, "--")) { ok_paths = &argv[i+1]; break; --- 0.99.8.GIT - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlReceived on Tue Oct 25 17:09:34 2005
This archive was generated by hypermail 2.1.8 : 2005-10-25 17:09:38 EST