git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add a --prefix option to git-daemon
@ 2005-10-25  7:08 Brad Roberts
  2005-10-25  7:42 ` Junio C Hamano
  2005-10-25  9:10 ` Petr Baudis
  0 siblings, 2 replies; 3+ messages in thread
From: Brad Roberts @ 2005-10-25  7:08 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add a --prefix option to git-daemon
  2005-10-25  7:08 [PATCH] Add a --prefix option to git-daemon Brad Roberts
@ 2005-10-25  7:42 ` Junio C Hamano
  2005-10-25  9:10 ` Petr Baudis
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2005-10-25  7:42 UTC (permalink / raw)
  To: Brad Roberts; +Cc: git

Brad Roberts <braddr@gameboy2.puremagic.com> writes:

> Add a --prefix option to git-daemon.

What is your thought about my RFC last night [*1*], and how does
this patch address the concern raised in it, specifically what
is the plan for this --prefix option to work together with
upload-pack?

[Reference]

*1* http://marc.theaimsgroup.com/?l=git&m=113014402715697&w=2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add a --prefix option to git-daemon
  2005-10-25  7:08 [PATCH] Add a --prefix option to git-daemon Brad Roberts
  2005-10-25  7:42 ` Junio C Hamano
@ 2005-10-25  9:10 ` Petr Baudis
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Baudis @ 2005-10-25  9:10 UTC (permalink / raw)
  To: Brad Roberts; +Cc: git

Dear diary, on Tue, Oct 25, 2005 at 09:08:51AM CEST, I got a letter
where Brad Roberts <braddr@gameboy2.puremagic.com> told me that...
> 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>

You forgot to document the option. :-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-25  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-25  7:08 [PATCH] Add a --prefix option to git-daemon Brad Roberts
2005-10-25  7:42 ` Junio C Hamano
2005-10-25  9:10 ` Petr Baudis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).