git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add a --prefix option to git-daemon

From
BRBrad Roberts <braddr@gameboy2.puremagic.com>
Date
Oct 25, 2005, 07:08 UTC
Message-ID
<200510250708.j9P78pG3024087@gameboy2.puremagic.com>

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
Next: Junio C Hamano
Message 1 of 3 in “Add a --prefix option to git-daemon”
  1. Add a --prefix option to git-daemonBrad Roberts, Oct 25, 2005
  2. Junio C HamanoOct 25, 2005
  3. Petr BaudisOct 25, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.