Re: [PATCH 11/11] Support bundles in builtin-clone

Previous thread: [PATCH 02/11] Add a test for another combination of --reference by Johan Herland on Saturday, March 8, 2008 - 4:03 pm. (1 message)

Next thread: [PATCH 01/11] Add test for cloning with "--reference" repo being a subset of source repo by Johan Herland on Saturday, March 8, 2008 - 4:03 pm. (1 message)
From: Johannes Schindelin
Date: Saturday, March 8, 2008 - 4:04 pm

This forward-ports c6fef0bb(clone: support cloning full bundles) to the
builtin clone.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin-clone.c        |   63 ++++++++++++++++++++++++++++-------------------
 t/t5701-clone-local.sh |    6 ++--
 2 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/builtin-clone.c b/builtin-clone.c
index 1b83062..e4047ed 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -64,42 +64,52 @@ static struct option builtin_clone_options[] = {
 	OPT_END()
 };
 
-static char *get_repo_path(const char *repo)
+static char *get_repo_path(const char *repo, int *is_bundle)
 {
-	const char *path;
-	struct stat buf;
-
-	path = mkpath("%s/.git", repo);
-	if (!stat(path, &buf) && S_ISDIR(buf.st_mode))
-		return xstrdup(make_absolute_path(path));
-
-	path = mkpath("%s.git", repo);
-	if (!stat(path, &buf) && S_ISDIR(buf.st_mode))
-		return xstrdup(make_absolute_path(path));
+	static char *suffix[] = { "/.git", ".git", "" };
+	static char *bundle_suffix[] = { ".bundle", "" };
+	struct stat st;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(suffix); i++) {
+		const char *path;
+		path = mkpath("%s%s", repo, suffix[i]);
+		if (!stat(path, &st) && S_ISDIR(st.st_mode)) {
+			*is_bundle = 0;
+			return xstrdup(make_absolute_path(path));
+		}
+	}
 
-	if (!stat(repo, &buf) && S_ISDIR(buf.st_mode))
-		return xstrdup(make_absolute_path(repo));
+	for (i = 0; i < ARRAY_SIZE(bundle_suffix); i++) {
+		const char *path;
+		path = mkpath("%s%s", repo, bundle_suffix[i]);
+		if (!stat(path, &st) && S_ISREG(st.st_mode)) {
+			*is_bundle = 1;
+			return xstrdup(make_absolute_path(path));
+		}
+	}
 
 	return NULL;
 }
 
-static char *guess_dir_name(const char *repo)
+static char *guess_dir_name(const char *repo, int is_bundle)
 {
 	const char *p, *start, *end, *limit;
 	int after_slash_or_colon;
 
 	/* Guess dir name from repository: strip trailing '/',
-	 * strip trailing '[:/]*git', strip leading '.*[/:]'. */
+	 * ...
From: Johannes Schindelin
Date: Saturday, March 8, 2008 - 4:28 pm

Hi,


Wow... Is this a new send-email feature?  I did not send this email...

Ciao,
Dscho
--

From: Daniel Barkalow
Date: Sunday, March 9, 2008 - 12:00 pm

Nope, it's an old format-patch feature. format-patch generates the 
messages with the From: being the commit author, and my MTA doesn't 
complain about the fact that I'm sending email with some entirely 
different From:. It would probably be more clever to have format-patch use 
the committer or the current user as the From:, and put an additional 
From: in the message body with the author if it's not the email From:.

Of course, you did sort of send that email 
(http://permalink.gmane.org/gmane.comp.version-control.git/75743). I just 
bounced it to the list again with a different subject, some other headers, 
the note removed, and the patch rebased. Or something like that. I 
actually didn't expect it to come out looking like you'd sent the email 
until it showed up (or, rather, until it didn't show up for a little while 
because vger thought it was odd).

	-Daniel
*This .sig left intentionally blank*
--

From: Johannes Schindelin
Date: Sunday, March 9, 2008 - 1:56 pm

Hi,



Sort of.

Of course, I am okay with it, but I consider the From: issue a real bug in 
send-email (or format-patch, if you want).

Ciao,
Dscho

--

From: Daniel Barkalow
Date: Sunday, March 9, 2008 - 2:59 pm

Agreed; (format-patch, I didn't use send-email). But I don't understand 
the flow control in pretty.c nearly well enough to fix it right now. It 
lists the author in the headers, like all of the log output formats, and 
doesn't then have the author available in the body, afaict.

	-Daniel
*This .sig left intentionally blank*
--

From: Junio C Hamano
Date: Sunday, March 9, 2008 - 10:55 pm

Format-patch is about recording the author of the patch on From: line
(think of it a tool to reproduce an e-mail that you would have received
and applied to your tree).  It may probably make a lot of sense to teach
send-email not to forge From: (even though, RFC is Ok with it, as long as
it also correctly adds Sender: pointing at the real sender).

--

From: Junio C Hamano
Date: Sunday, March 9, 2008 - 11:32 pm

Well, as I re-read send-email, it does put you on the From: and adds the
patch author From: at the beginning of the message.  So there is no bug
here.  Daniel did not use send-email, so of course even if there were a
bug in send-email it would not have triggered ;-)

So there is no bug to hunt here.


--

From: Johannes Schindelin
Date: Monday, March 10, 2008 - 3:56 am

Hi,


Thanks for clarifying,
Dscho

--

Previous thread: [PATCH 02/11] Add a test for another combination of --reference by Johan Herland on Saturday, March 8, 2008 - 4:03 pm. (1 message)

Next thread: [PATCH 01/11] Add test for cloning with "--reference" repo being a subset of source repo by Johan Herland on Saturday, March 8, 2008 - 4:03 pm. (1 message)