* [PATCH 11/11] Support bundles in builtin-clone
@ 2008-03-08 23:04 Johannes Schindelin
2008-03-08 23:28 ` Johannes Schindelin
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2008-03-08 23:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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 '.*[/:]'. */
+ * strip trailing '[:/]*.{git,bundle}', strip leading '.*[/:]'. */
after_slash_or_colon = 1;
limit = repo + strlen(repo);
start = repo;
end = limit;
for (p = repo; p < limit; p++) {
- if (!prefixcmp(p, ".git")) {
+ const char *prefix = is_bundle ? ".bundle" : ".git";
+ if (!prefixcmp(p, prefix)) {
if (!after_slash_or_colon)
end = p;
- p += 3;
+ p += strlen(prefix) - 1;
} else if (!prefixcmp(p, ".bundle")) {
if (!after_slash_or_colon)
end = p;
@@ -312,6 +322,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
{
int use_local_hardlinks = 1;
int use_separate_remote = 1;
+ int is_bundle = 0;
struct stat buf;
const char *repo_name, *repo, *work_tree, *git_dir;
char *path, *dir;
@@ -345,14 +356,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
repo_name = argv[0];
- if (argc == 2) {
- dir = xstrdup(argv[1]);
- } else {
- dir = guess_dir_name(repo_name);
- }
- fprintf(stderr, "dir is %s\n", dir);
-
- path = get_repo_path(repo_name);
+ path = get_repo_path(repo_name, &is_bundle);
if (path != NULL)
repo = xstrdup(make_absolute_path(path));
else if (!strchr(repo_name, ':'))
@@ -361,6 +365,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
repo = repo_name;
fprintf(stderr, "repo is %s\n", repo);
+ if (argc == 2) {
+ dir = xstrdup(argv[1]);
+ } else {
+ dir = guess_dir_name(repo_name, is_bundle);
+ }
+ fprintf(stderr, "dir is %s\n", dir);
+
if (!stat(dir, &buf))
die("destination directory '%s' already exists.", dir);
@@ -426,7 +437,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
refspec.src = "refs/heads/";
refspec.dst = branch_top;
- if (path != NULL)
+ if (path != NULL && !is_bundle)
refs = clone_local(path, git_dir);
else {
struct remote *remote = remote_get(argv[0]);
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 7cfe716..8dfaaa4 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -83,14 +83,14 @@ test_expect_success 'bundle clone without .bundle suffix' '
git fetch
'
-test_expect_failure 'bundle clone with .bundle suffix' '
+test_expect_success 'bundle clone with .bundle suffix' '
cd "$D" &&
git clone b1.bundle &&
cd b1 &&
git fetch
'
-test_expect_failure 'bundle clone from b4' '
+test_expect_success 'bundle clone from b4' '
cd "$D" &&
git clone b4 bdl &&
cd bdl &&
@@ -108,7 +108,7 @@ test_expect_success 'bundle clone from b4.bundle that does not exist' '
fi
'
-test_expect_failure 'bundle clone with nonexistent HEAD' '
+test_expect_success 'bundle clone with nonexistent HEAD' '
cd "$D" &&
git clone b2.bundle b2 &&
cd b2 &&
--
1.5.4.3.327.g614d7.dirty
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-08 23:04 [PATCH 11/11] Support bundles in builtin-clone Johannes Schindelin
@ 2008-03-08 23:28 ` Johannes Schindelin
2008-03-09 19:00 ` Daniel Barkalow
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2008-03-08 23:28 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Sat, 8 Mar 2008, Johannes Schindelin wrote:
> This forward-ports c6fef0bb(clone: support cloning full bundles) to the
> builtin clone.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
Wow... Is this a new send-email feature? I did not send this email...
Ciao,
Dscho
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-08 23:28 ` Johannes Schindelin
@ 2008-03-09 19:00 ` Daniel Barkalow
2008-03-09 20:56 ` Johannes Schindelin
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Barkalow @ 2008-03-09 19:00 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git
On Sun, 9 Mar 2008, Johannes Schindelin wrote:
> Hi,
>
> On Sat, 8 Mar 2008, Johannes Schindelin wrote:
>
> > This forward-ports c6fef0bb(clone: support cloning full bundles) to the
> > builtin clone.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
>
> Wow... Is this a new send-email feature? I did not send this email...
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*
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-09 19:00 ` Daniel Barkalow
@ 2008-03-09 20:56 ` Johannes Schindelin
2008-03-09 21:59 ` Daniel Barkalow
2008-03-10 5:55 ` Junio C Hamano
0 siblings, 2 replies; 8+ messages in thread
From: Johannes Schindelin @ 2008-03-09 20:56 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Junio C Hamano, git
Hi,
On Sun, 9 Mar 2008, Daniel Barkalow wrote:
> On Sun, 9 Mar 2008, Johannes Schindelin wrote:
>
> > On Sat, 8 Mar 2008, Johannes Schindelin wrote:
> >
> > > This forward-ports c6fef0bb(clone: support cloning full bundles) to
> > > the builtin clone.
> > >
> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > > ---
> >
> > Wow... Is this a new send-email feature? I did not send this email...
>
> 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:.
I think that makes sense.
> Of course, you did sort of send that email
> (http://permalink.gmane.org/gmane.comp.version-control.git/75743).
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-09 20:56 ` Johannes Schindelin
@ 2008-03-09 21:59 ` Daniel Barkalow
2008-03-10 5:55 ` Junio C Hamano
1 sibling, 0 replies; 8+ messages in thread
From: Daniel Barkalow @ 2008-03-09 21:59 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git
On Sun, 9 Mar 2008, Johannes Schindelin wrote:
> Hi,
>
> On Sun, 9 Mar 2008, Daniel Barkalow wrote:
>
> > On Sun, 9 Mar 2008, Johannes Schindelin wrote:
> >
> > > On Sat, 8 Mar 2008, Johannes Schindelin wrote:
> > >
> > > > This forward-ports c6fef0bb(clone: support cloning full bundles) to
> > > > the builtin clone.
> > > >
> > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > > > ---
> > >
> > > Wow... Is this a new send-email feature? I did not send this email...
> >
> > 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:.
>
> I think that makes sense.
>
> > Of course, you did sort of send that email
> > (http://permalink.gmane.org/gmane.comp.version-control.git/75743).
>
> 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).
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*
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-09 20:56 ` Johannes Schindelin
2008-03-09 21:59 ` Daniel Barkalow
@ 2008-03-10 5:55 ` Junio C Hamano
2008-03-10 6:32 ` Junio C Hamano
1 sibling, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2008-03-10 5:55 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Daniel Barkalow, git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 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).
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).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-10 5:55 ` Junio C Hamano
@ 2008-03-10 6:32 ` Junio C Hamano
2008-03-10 10:56 ` Johannes Schindelin
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2008-03-10 6:32 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Daniel Barkalow, git
Junio C Hamano <gitster@pobox.com> writes:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> 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).
>
> 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).
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 11/11] Support bundles in builtin-clone
2008-03-10 6:32 ` Junio C Hamano
@ 2008-03-10 10:56 ` Johannes Schindelin
0 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2008-03-10 10:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Daniel Barkalow, git
Hi,
On Sun, 9 Mar 2008, Junio C Hamano wrote:
> 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.
Thanks for clarifying,
Dscho
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-03-10 10:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-08 23:04 [PATCH 11/11] Support bundles in builtin-clone Johannes Schindelin
2008-03-08 23:28 ` Johannes Schindelin
2008-03-09 19:00 ` Daniel Barkalow
2008-03-09 20:56 ` Johannes Schindelin
2008-03-09 21:59 ` Daniel Barkalow
2008-03-10 5:55 ` Junio C Hamano
2008-03-10 6:32 ` Junio C Hamano
2008-03-10 10:56 ` Johannes Schindelin
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).