From: Bruce Ashfield <bruce.ashfield@windriver.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: "Hart, Darren" <darren.hart@intel.com>,
bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: Re: [PATCH] fetch2/git: Add workaround for clone using alternates problem
Date: Tue, 31 Jan 2012 09:29:14 -0500 [thread overview]
Message-ID: <4F27FABA.9070304@windriver.com> (raw)
In-Reply-To: <1328019536.13744.28.camel@ted>
On 12-01-31 09:18 AM, Richard Purdie wrote:
> To quote my report of this to the git mailing list:
> """
>
> I have a problem with git clone commands using alternates failing by
> mixing up different repositories. I have a situation where I could end
> up with both:
>
> /srv/mirrors/repo
> /srv/mirrors/repo.git
>
> as bare clones.
>
> I then try cloning "repo" with alternates with the command:
>
> $ git clone -s -n /srv/mirrors/repo /tmp/foo
> Cloning into /tmp/foo...
> done.
>
> $ cat /tmp/foo/.git/objects/info/alternates
> /srv/mirrors/repo.git/objects
>
> Note how I'm now referencing repo.git, not repo. This doesn't work as
> expected giving some very bizarre results when actually using the
> repository.
>
> I appreciate this is a rather bizarre corner case but its one that is
> breaking the build system I work with. Ideally people would use a
> consistent URL for the same repository but we have an example where they
> haven't and this really shouldn't break like this.
>
> Looking at the code, the cause seems to be
>
> clone.c:get_repo_path():
> static char *suffix[] = { "/.git", ".git", "" };
>
> since its looking in order for:
> repo/.git (fails)
> repo.git (suceeds, incorrect)
> repo (never looked at)
>
> I'm not sure what would break if that order were to change, swapping the
> last two options.
>
> I can "force" the issue by running:
>
> git clone -s -n /srv/mirrors/repo/ /tmp/foo
>
> but this results in the slightly odd looking:
>
> $ cat /tmp/foo/.git/objects/info/alternates
>
> /srv/mirrors/repo//objects
>
> which does at least work.
> """
>
> This patch adds the trailing slash to ensure the correct repository is
> referenced at the expense of some ugliness in the alternates file.
For what it's worth, I've run into very similar issues in the past, and
the solution was the same .. Ensure that the trailing / was present, it
is meaningful to git in a few cases (in mine it was relative references
to alternate repositories).
In the relative reference case, we eventually did propose and got a variant
of our change to support it incorporated into git. But the work around
was still needed for a while, since waiting for it to propagate to
supported hosts and versions of git was a bit messy.
I couldn't find a good explanation of the ordering either, but I do know
that there are existing scripts and infrastructure that do depend on
having <foo>.git found before <foo>, so changing any ordering could
have some subtle impacts.
The summary of my rambling is that I couldn't come up with anything
better in my poking around before I've had much coffee today :)
Cheers,
Bruce
>
> Signed-off-by: Richard Purdie<richard.purdie@linuxfoundation.org>
>
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index d833714..fb0260a 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -220,7 +220,7 @@ class Git(FetchMethod):
> if os.path.exists(destdir):
> bb.utils.prunedir(destdir)
>
> - runfetchcmd("git clone -s -n %s %s" % (ud.clonedir, destdir), d)
> + runfetchcmd("git clone -s -n %s/ %s" % (ud.clonedir, destdir), d)
> if not ud.nocheckout:
> os.chdir(destdir)
> if subdir != "":
>
prev parent reply other threads:[~2012-01-31 16:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 14:18 [PATCH] fetch2/git: Add workaround for clone using alternates problem Richard Purdie
2012-01-31 14:29 ` Bruce Ashfield [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F27FABA.9070304@windriver.com \
--to=bruce.ashfield@windriver.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=darren.hart@intel.com \
--cc=richard.purdie@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.