{"thread":{"id":"12594","subject":"[PATCH 11/11] Support bundles in builtin-clone","startedAt":"2008-03-08T23:04:29Z","lastAt":"2008-03-10T10:56:44Z","messageCount":8,"participants":["Johannes Schindelin","Daniel Barkalow","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":11},"messages":[{"id":"71467","messageId":"alpine.LNX.1.00.0803081804280.19665@iabervon.org","threadId":"12594","inReplyTo":null,"subject":"[PATCH 11/11] Support bundles in builtin-clone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-08T23:04:29Z","receivedAt":"2008-03-08T23:04:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This forward-ports c6fef0bb(clone: support cloning full bundles) to the\nbuiltin clone.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin-clone.c        |   63 ++++++++++++++++++++++++++++-------------------\n t/t5701-clone-local.sh |    6 ++--\n 2 files changed, 40 insertions(+), 29 deletions(-)\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 1b83062..e4047ed 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -64,42 +64,52 @@ static struct option builtin_clone_options[] = {\n \tOPT_END()\n };\n \n-static char *get_repo_path(const char *repo)\n+static char *get_repo_path(const char *repo, int *is_bundle)\n {\n-\tconst char *path;\n-\tstruct stat buf;\n-\n-\tpath = mkpath(\"%s/.git\", repo);\n-\tif (!stat(path, &buf) && S_ISDIR(buf.st_mode))\n-\t\treturn xstrdup(make_absolute_path(path));\n-\n-\tpath = mkpath(\"%s.git\", repo);\n-\tif (!stat(path, &buf) && S_ISDIR(buf.st_mode))\n-\t\treturn xstrdup(make_absolute_path(path));\n+\tstatic char *suffix[] = { \"/.git\", \".git\", \"\" };\n+\tstatic char *bundle_suffix[] = { \".bundle\", \"\" };\n+\tstruct stat st;\n+\tint i;\n+\n+\tfor (i = 0; i < ARRAY_SIZE(suffix); i++) {\n+\t\tconst char *path;\n+\t\tpath = mkpath(\"%s%s\", repo, suffix[i]);\n+\t\tif (!stat(path, &st) && S_ISDIR(st.st_mode)) {\n+\t\t\t*is_bundle = 0;\n+\t\t\treturn xstrdup(make_absolute_path(path));\n+\t\t}\n+\t}\n \n-\tif (!stat(repo, &buf) && S_ISDIR(buf.st_mode))\n-\t\treturn xstrdup(make_absolute_path(repo));\n+\tfor (i = 0; i < ARRAY_SIZE(bundle_suffix); i++) {\n+\t\tconst char *path;\n+\t\tpath = mkpath(\"%s%s\", repo, bundle_suffix[i]);\n+\t\tif (!stat(path, &st) && S_ISREG(st.st_mode)) {\n+\t\t\t*is_bundle = 1;\n+\t\t\treturn xstrdup(make_absolute_path(path));\n+\t\t}\n+\t}\n \n \treturn NULL;\n }\n \n-static char *guess_dir_name(const char *repo)\n+static char *guess_dir_name(const char *repo, int is_bundle)\n {\n \tconst char *p, *start, *end, *limit;\n \tint after_slash_or_colon;\n \n \t/* Guess dir name from repository: strip trailing '/',\n-\t * strip trailing '[:/]*git', strip leading '.*[/:]'. */\n+\t * strip trailing '[:/]*.{git,bundle}', strip leading '.*[/:]'. */\n \n \tafter_slash_or_colon = 1;\n \tlimit = repo + strlen(repo);\n \tstart = repo;\n \tend = limit;\n \tfor (p = repo; p < limit; p++) {\n-\t\tif (!prefixcmp(p, \".git\")) {\n+\t\tconst char *prefix = is_bundle ? \".bundle\" : \".git\";\n+\t\tif (!prefixcmp(p, prefix)) {\n \t\t\tif (!after_slash_or_colon)\n \t\t\t\tend = p;\n-\t\t\tp += 3;\n+\t\t\tp += strlen(prefix) - 1;\n \t\t} else if (!prefixcmp(p, \".bundle\")) {\n \t\t\tif (!after_slash_or_colon)\n \t\t\t\tend = p;\n@@ -312,6 +322,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n {\n \tint use_local_hardlinks = 1;\n \tint use_separate_remote = 1;\n+\tint is_bundle = 0;\n \tstruct stat buf;\n \tconst char *repo_name, *repo, *work_tree, *git_dir;\n \tchar *path, *dir;\n@@ -345,14 +356,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \trepo_name = argv[0];\n \n-\tif (argc == 2) {\n-\t\tdir = xstrdup(argv[1]);\n-\t} else {\n-\t\tdir = guess_dir_name(repo_name);\n-\t}\n-\tfprintf(stderr, \"dir is %s\\n\", dir);\n-\n-\tpath = get_repo_path(repo_name);\n+\tpath = get_repo_path(repo_name, &is_bundle);\n \tif (path != NULL)\n \t\trepo = xstrdup(make_absolute_path(path));\n \telse if (!strchr(repo_name, ':'))\n@@ -361,6 +365,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\trepo = repo_name;\n \tfprintf(stderr, \"repo is %s\\n\", repo);\n \n+\tif (argc == 2) {\n+\t\tdir = xstrdup(argv[1]);\n+\t} else {\n+\t\tdir = guess_dir_name(repo_name, is_bundle);\n+\t}\n+\tfprintf(stderr, \"dir is %s\\n\", dir);\n+\n \tif (!stat(dir, &buf))\n \t\tdie(\"destination directory '%s' already exists.\", dir);\n \n@@ -426,7 +437,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \trefspec.src = \"refs/heads/\";\n \trefspec.dst = branch_top;\n \n-\tif (path != NULL)\n+\tif (path != NULL && !is_bundle)\n \t\trefs = clone_local(path, git_dir);\n \telse {\n \t\tstruct remote *remote = remote_get(argv[0]);\ndiff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh\nindex 7cfe716..8dfaaa4 100755\n--- a/t/t5701-clone-local.sh\n+++ b/t/t5701-clone-local.sh\n@@ -83,14 +83,14 @@ test_expect_success 'bundle clone without .bundle suffix' '\n \tgit fetch\n '\n \n-test_expect_failure 'bundle clone with .bundle suffix' '\n+test_expect_success 'bundle clone with .bundle suffix' '\n \tcd \"$D\" &&\n \tgit clone b1.bundle &&\n \tcd b1 &&\n \tgit fetch\n '\n \n-test_expect_failure 'bundle clone from b4' '\n+test_expect_success 'bundle clone from b4' '\n \tcd \"$D\" &&\n \tgit clone b4 bdl &&\n \tcd bdl &&\n@@ -108,7 +108,7 @@ test_expect_success 'bundle clone from b4.bundle that does not exist' '\n \tfi\n '\n \n-test_expect_failure 'bundle clone with nonexistent HEAD' '\n+test_expect_success 'bundle clone with nonexistent HEAD' '\n \tcd \"$D\" &&\n \tgit clone b2.bundle b2 &&\n \tcd b2 &&\n-- \n1.5.4.3.327.g614d7.dirty\n"},{"id":"71479","messageId":"alpine.LSU.1.00.0803090027570.3975@racer.site","threadId":"12594","inReplyTo":"alpine.LNX.1.00.0803081804280.19665@iabervon.org","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-08T23:28:30Z","receivedAt":"2008-03-08T23:28:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 8 Mar 2008, Johannes Schindelin wrote:\n\n> This forward-ports c6fef0bb(clone: support cloning full bundles) to the\n> builtin clone.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n\nWow... Is this a new send-email feature?  I did not send this email...\n\nCiao,\nDscho\n"},{"id":"71520","messageId":"alpine.LNX.1.00.0803091447230.19665@iabervon.org","threadId":"12594","inReplyTo":"alpine.LSU.1.00.0803090027570.3975@racer.site","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-03-09T19:00:58Z","receivedAt":"2008-03-09T19:00:58Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 9 Mar 2008, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Sat, 8 Mar 2008, Johannes Schindelin wrote:\n> \n> > This forward-ports c6fef0bb(clone: support cloning full bundles) to the\n> > builtin clone.\n> > \n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> \n> Wow... Is this a new send-email feature?  I did not send this email...\n\nNope, it's an old format-patch feature. format-patch generates the \nmessages with the From: being the commit author, and my MTA doesn't \ncomplain about the fact that I'm sending email with some entirely \ndifferent From:. It would probably be more clever to have format-patch use \nthe committer or the current user as the From:, and put an additional \nFrom: in the message body with the author if it's not the email From:.\n\nOf course, you did sort of send that email \n(http://permalink.gmane.org/gmane.comp.version-control.git/75743). I just \nbounced it to the list again with a different subject, some other headers, \nthe note removed, and the patch rebased. Or something like that. I \nactually didn't expect it to come out looking like you'd sent the email \nuntil it showed up (or, rather, until it didn't show up for a little while \nbecause vger thought it was odd).\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"71527","messageId":"alpine.LSU.1.00.0803092155450.3975@racer.site","threadId":"12594","inReplyTo":"alpine.LNX.1.00.0803091447230.19665@iabervon.org","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-09T20:56:54Z","receivedAt":"2008-03-09T20:56:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 9 Mar 2008, Daniel Barkalow wrote:\n\n> On Sun, 9 Mar 2008, Johannes Schindelin wrote:\n> \n> > On Sat, 8 Mar 2008, Johannes Schindelin wrote:\n> > \n> > > This forward-ports c6fef0bb(clone: support cloning full bundles) to \n> > > the builtin clone.\n> > > \n> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > > ---\n> > \n> > Wow... Is this a new send-email feature?  I did not send this email...\n> \n> Nope, it's an old format-patch feature. format-patch generates the \n> messages with the From: being the commit author, and my MTA doesn't \n> complain about the fact that I'm sending email with some entirely \n> different From:. It would probably be more clever to have format-patch \n> use the committer or the current user as the From:, and put an \n> additional From: in the message body with the author if it's not the \n> email From:.\n\nI think that makes sense.\n\n> Of course, you did sort of send that email \n> (http://permalink.gmane.org/gmane.comp.version-control.git/75743).\n\nSort of.\n\nOf course, I am okay with it, but I consider the From: issue a real bug in \nsend-email (or format-patch, if you want).\n\nCiao,\nDscho\n"},{"id":"71530","messageId":"alpine.LNX.1.00.0803091755530.19665@iabervon.org","threadId":"12594","inReplyTo":"alpine.LSU.1.00.0803092155450.3975@racer.site","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-03-09T21:59:56Z","receivedAt":"2008-03-09T21:59:56Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 9 Mar 2008, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Sun, 9 Mar 2008, Daniel Barkalow wrote:\n> \n> > On Sun, 9 Mar 2008, Johannes Schindelin wrote:\n> > \n> > > On Sat, 8 Mar 2008, Johannes Schindelin wrote:\n> > > \n> > > > This forward-ports c6fef0bb(clone: support cloning full bundles) to \n> > > > the builtin clone.\n> > > > \n> > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > > > ---\n> > > \n> > > Wow... Is this a new send-email feature?  I did not send this email...\n> > \n> > Nope, it's an old format-patch feature. format-patch generates the \n> > messages with the From: being the commit author, and my MTA doesn't \n> > complain about the fact that I'm sending email with some entirely \n> > different From:. It would probably be more clever to have format-patch \n> > use the committer or the current user as the From:, and put an \n> > additional From: in the message body with the author if it's not the \n> > email From:.\n> \n> I think that makes sense.\n> \n> > Of course, you did sort of send that email \n> > (http://permalink.gmane.org/gmane.comp.version-control.git/75743).\n> \n> Sort of.\n> \n> Of course, I am okay with it, but I consider the From: issue a real bug in \n> send-email (or format-patch, if you want).\n\nAgreed; (format-patch, I didn't use send-email). But I don't understand \nthe flow control in pretty.c nearly well enough to fix it right now. It \nlists the author in the headers, like all of the log output formats, and \ndoesn't then have the author available in the body, afaict.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"71553","messageId":"7v7igbm8cb.fsf@gitster.siamese.dyndns.org","threadId":"12594","inReplyTo":"alpine.LSU.1.00.0803092155450.3975@racer.site","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-10T05:55:16Z","receivedAt":"2008-03-10T05:55:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Of course, I am okay with it, but I consider the From: issue a real bug in \n> send-email (or format-patch, if you want).\n\nFormat-patch is about recording the author of the patch on From: line\n(think of it a tool to reproduce an e-mail that you would have received\nand applied to your tree).  It may probably make a lot of sense to teach\nsend-email not to forge From: (even though, RFC is Ok with it, as long as\nit also correctly adds Sender: pointing at the real sender).\n"},{"id":"71556","messageId":"7vtzjfks1l.fsf@gitster.siamese.dyndns.org","threadId":"12594","inReplyTo":"7v7igbm8cb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-10T06:32:38Z","receivedAt":"2008-03-10T06:32:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>\n>> Of course, I am okay with it, but I consider the From: issue a real bug in \n>> send-email (or format-patch, if you want).\n>\n> Format-patch is about recording the author of the patch on From: line\n> (think of it a tool to reproduce an e-mail that you would have received\n> and applied to your tree).  It may probably make a lot of sense to teach\n> send-email not to forge From: (even though, RFC is Ok with it, as long as\n> it also correctly adds Sender: pointing at the real sender).\n\nWell, as I re-read send-email, it does put you on the From: and adds the\npatch author From: at the beginning of the message.  So there is no bug\nhere.  Daniel did not use send-email, so of course even if there were a\nbug in send-email it would not have triggered ;-)\n\nSo there is no bug to hunt here.\n"},{"id":"71570","messageId":"alpine.LSU.1.00.0803101156310.3975@racer.site","threadId":"12594","inReplyTo":"7vtzjfks1l.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 11/11] Support bundles in builtin-clone","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-10T10:56:44Z","receivedAt":"2008-03-10T10:56:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 9 Mar 2008, Junio C Hamano wrote:\n\n> Well, as I re-read send-email, it does put you on the From: and adds the \n> patch author From: at the beginning of the message.  So there is no bug \n> here.  Daniel did not use send-email, so of course even if there were a \n> bug in send-email it would not have triggered ;-)\n> \n> So there is no bug to hunt here.\n\nThanks for clarifying,\nDscho\n"}]}