Subject: Re: [RFC] Moving "git remote add --mirror blah" functionality to "git clone --bare --origin=blah"

From: Junio C Hamano <[email-masked]>
Date: Wed, 23 Apr 2008 09:07:28 -0700

Paolo Bonzini <[email-masked]> writes:

> In the thread "git remote update -> rejected" Junio and Johannes came
> to the conclusion that "--mirror means that you do not have local
> branches", because "you give control away to the other end on the ref
> namespace".  Furthermore, it was agreed that --mirror currently makes
> sense mostly (or only?) on a bare repository.
>
> From here I gather that if you have "git remote add --mirror", most
> likely the mirrored repository will be the only remote you have.
> There is in general no point in having other remotes in a bare
> repository. And so there is no loss of generality if this remote is
> the "origin" remote.
>
> Hence, my proposal is:
>
> 1) Add an option to "git clone", to be used with --bare, to create a
> mirror.  --bare already leaves the original refs in place, without
> moving them under refs/remotes/origin, so it makes sense to optionally
> create the remote.

I actually had a slightly different vision.  A mid-term goal should be to
reimplement "clone" that has a lot of code duplication with "fetch" and
"remote" in terms of "init + remote + fetch + checkout" [*1*].  For that
to happen, I suspect that "remote" needs to learn a few more tricks than
it currently knows (e.g. "figuring out the HEAD").

I would agree that it is useful for "clone" to create a bare repository in
a mode that can be used for further cloning by other repositories (perhaps
the former sits at the firewall boundary that it is cumbersome to cross by
the latter).  As you described above, we already have that (iow, "--bare").

And "remote add --mirror" would be an implementation detail to produce
such a clone.  It is mostly about fetching.

An option to add a back-up repository that you can maintain an exact
mirror of your working repository would be useful, but that is different
from what "remote add --mirror" is about.

[Footnote]

*1* In that sense, a more sensible order than rewriting "clone" in C in
its current form would be to make necessary enhancements to the components
in this sequence that need to implement clone, figure out how they should
fit together and first make "clone" a four-liner shell script. Then
rewriting the result in C may become more trivial.