{"thread":{"id":"2214","subject":"[PATCH] Add a --prefix option to git-daemon","startedAt":"2005-10-25T07:08:51Z","lastAt":"2005-10-25T09:10:57Z","messageCount":3,"participants":["Brad Roberts","Junio C Hamano","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10560","messageId":"200510250708.j9P78pG3024087@gameboy2.puremagic.com","threadId":"2214","inReplyTo":null,"subject":"[PATCH] Add a --prefix option to git-daemon","fromName":"Brad Roberts","fromEmail":"braddr@gameboy2.puremagic.com","sentAt":"2005-10-25T07:08:51Z","receivedAt":"2005-10-25T07:08:51Z","isPatch":true,"sender":{"key":"braddr@gameboy2.puremagic.com","avatar":null},"body":"Add a --prefix option to git-daemon.  This path is prepended to the search\npath for repositories.  In other words, git://hostname/path/to/gitdir will\nresult in looking for /prefix/path/to/gitdir.\n\nSigned-off-by: Brad Roberts <braddr@puremagic.com>\n---\n\n daemon.c |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\napplies-to: ccef5ac580c68a9714f37dcd8ee433e9691b640a\n4ab5253ba31370d151843ca14a8cabcadc37c974\ndiff --git a/daemon.c b/daemon.c\nindex 0c6182f..566bec6 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -15,7 +15,7 @@ static int verbose;\n \n static const char daemon_usage[] =\n \"git-daemon [--verbose] [--syslog] [--inetd | --port=n] [--export-all]\\n\"\n-\"           [--timeout=n] [--init-timeout=n] [directory...]\";\n+\"           [--timeout=n] [--init-timeout=n] [--prefix=directory] [directory...]\";\n \n /* List of acceptable pathname prefixes */\n static char **ok_paths = NULL;\n@@ -27,6 +27,9 @@ static int export_all_trees = 0;\n static unsigned int timeout = 0;\n static unsigned int init_timeout = 0;\n \n+/* directory prefix for all repositories */\n+static const char *directory_prefix = \"\";\n+\n static void logreport(int priority, const char *err, va_list params)\n {\n \t/* We should do a single write so that it is atomic and output\n@@ -170,10 +173,10 @@ static int set_dir(const char *dir)\n static int upload(char *dir)\n {\n \t/* Try paths in this order */\n-\tstatic const char *paths[] = { \"%s\", \"%s/.git\", \"%s.git\", \"%s.git/.git\", NULL };\n+\tstatic const char *paths[] = { \"%s%s\", \"%s%s/.git\", \"%s%s.git\", \"%s%s.git/.git\", NULL };\n \tconst char **pp;\n \t/* Enough for the longest path above including final null */\n-\tint buflen = strlen(dir)+10;\n+\tint buflen = strlen(dir)+strlen(directory_prefix)+10;\n \tchar *dirbuf = xmalloc(buflen);\n \t/* Timeout as string */\n \tchar timeout_buf[64];\n@@ -181,7 +184,7 @@ static int upload(char *dir)\n \tloginfo(\"Request for '%s'\", dir);\n \n \tfor ( pp = paths ; *pp ; pp++ ) {\n-\t\tsnprintf(dirbuf, buflen, *pp, dir);\n+\t\tsnprintf(dirbuf, buflen, *pp, directory_prefix, dir);\n \t\tif ( !set_dir(dirbuf) )\n \t\t\tbreak;\n \t}\n@@ -615,6 +618,10 @@ int main(int argc, char **argv)\n \t\tif (!strncmp(arg, \"--init-timeout=\", 15)) {\n \t\t\tinit_timeout = atoi(arg+15);\n \t\t}\n+\t\tif (!strncmp(arg, \"--prefix=\", 9)) {\n+\t\t\tdirectory_prefix = arg+9;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--\")) {\n \t\t\tok_paths = &argv[i+1];\n \t\t\tbreak;\n---\n0.99.8.GIT\n"},{"id":"10561","messageId":"7virvmjb4s.fsf@assigned-by-dhcp.cox.net","threadId":"2214","inReplyTo":"200510250708.j9P78pG3024087@gameboy2.puremagic.com","subject":"Re: [PATCH] Add a --prefix option to git-daemon","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-25T07:42:27Z","receivedAt":"2005-10-25T07:42:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brad Roberts <braddr@gameboy2.puremagic.com> writes:\n\n> Add a --prefix option to git-daemon.\n\nWhat is your thought about my RFC last night [*1*], and how does\nthis patch address the concern raised in it, specifically what\nis the plan for this --prefix option to work together with\nupload-pack?\n\n[Reference]\n\n*1* http://marc.theaimsgroup.com/?l=git&m=113014402715697&w=2\n"},{"id":"10567","messageId":"20051025091057.GA30889@pasky.or.cz","threadId":"2214","inReplyTo":"200510250708.j9P78pG3024087@gameboy2.puremagic.com","subject":"Re: [PATCH] Add a --prefix option to git-daemon","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-10-25T09:10:57Z","receivedAt":"2005-10-25T09:10:57Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Oct 25, 2005 at 09:08:51AM CEST, I got a letter\nwhere Brad Roberts <braddr@gameboy2.puremagic.com> told me that...\n> Add a --prefix option to git-daemon.  This path is prepended to the search\n> path for repositories.  In other words, git://hostname/path/to/gitdir will\n> result in looking for /prefix/path/to/gitdir.\n> \n> Signed-off-by: Brad Roberts <braddr@puremagic.com>\n\nYou forgot to document the option. :-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nVI has two modes: the one in which it beeps and the one in which\nit doesn't.\n"}]}