Subject: Re: [PATCH] Documentation/git-clone: describe --mirror more verbose

From: Michael J Gruber <[email-masked]>
Date: Mon, 04 Oct 2010 10:23:13 +0200

Uwe Kleine-König venit, vidit, dixit 04.10.2010 09:50:
> Hello Michael,
> 
> On Mon, Oct 04, 2010 at 09:25:17AM +0200, Michael J Gruber wrote:
>> Steven Rostedt venit, vidit, dixit 01.10.2010 23:16:
>>> On Fri, 2010-10-01 at 13:18 -0700, Darren Hart wrote:
>>>> 2010/10/1 Uwe Kleine-König <[email-masked]>:
>>>>> Some people in #linux-rt claimed that you cannot define "--mirror" with
>>>>> "mirror".
>>>>>
>>
>> I'd say "mirror" is a commonly known term for an exact copy. Moreover,
>> the text below doesn't explain what a mirror is either, only how
>> "update" behaves in it.
> hmm.  The --mirror option doesn't have any effect (apart from the
> changes in the config file) until you update.  So I think it's natural
> to talk about git update.  No?

"git clone" (with or without --mirror) does a couple of things, and it
does them differently when "--mirror" is used. It mirrors each branch
from the source repo in the target repo under the same name, including
for example any remote branches in the source repo. This is completely
different without "--mirror", where clone does not look at the source's
remote branches at all. Also, it sets up a mirroring refspec, i.e.
+refs/*:refs/*

Then, when you use the mirror clone, the refspec makes it behave
differently from a normal clone, which is what you notice with "update" etc.

>>>>> Signed-off-by: Uwe Kleine-König <[email-masked]>
>>>>
>>>> Acked-by: Darren 'Some People' Hart <[email-masked]>
>>>
>>>   Acked-by: Steven Rostedt <[email-masked]>
>>>
>>> -- Steve
>>>
>>>>
>>>>> ---
>>>>>  Documentation/git-clone.txt |   11 ++++++++++-
>>>>>  1 files changed, 10 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
>>>>> index dc7d3d1..5eedfbd 100644
>>>>> --- a/Documentation/git-clone.txt
>>>>> +++ b/Documentation/git-clone.txt
>>>>> @@ -128,7 +128,16 @@ objects from the source repository into a pack in the cloned repository.
>>>>>        configuration variables are created.
>>>>>
>>>>>  --mirror::
>>>>> -       Set up a mirror of the remote repository.  This implies `--bare`.
>>>>> +       Set up a mirror of the remote repository.
>>>>> +       Using
>>>>> +
>>>>> +               git remote update origin
>>>>> +
>>>>> +       (or `<name>` instead of `origin` if -o is given) in the resulting
>>
>> "remote" has no "-o" option. You probably mean the "clone" option, but
>> the way it's written it refers to the preceding command.
> So what do you think about:
> 
> 	... (or `<name>` instead of `origin` if -o is given to clone)

maybe "was given"

> 
>>
>>>>> +       repository overwrites the local branches without asking.
>>>>> +       This implies `--bare`.
>>
>> Again, "this" refers to the preceding sentence. But the update behavior
>> does not imply "--bare". Specifying "--mirror" for "clone" implies "--bare".
> OK.
>  
>>>>> +       Without --mirror (but with --bare) git remote update doesn't touch any
>>>>> +       branches at all.
>>
>> That's not true. It just doesn't touch any local branches; it updates
>> the remote branches, of course.
> Hmm, for me there are no remote branches when using --bare:

I'm sorry, I missed the parenthetical remark. You're completely right
for the case with "--bare" only.

> 
> 	ukleinek@cassiopeia:~/tmp$ git clone --bare ~/gsrc/topgit
> 	Cloning into bare repository topgit.git...
> 	done.
> 	ukleinek@cassiopeia:~/tmp$ cd topgit.git/
> 	ukleinek@cassiopeia:~/tmp/topgit.git$ git remote update
> 	Fetching origin
> 	From /home/ukleinek/gsrc/topgit
> 	 * branch            HEAD       -> FETCH_HEAD
> 
> This is also documented for --bare:
> 
> 	When this option is used, neither remote-tracking branches nor
> 	the related configuration variables are created.
> 
> Best regards
> Uwe
> 

This makes me think that --mirror should be explained on top of --bare.
For example:

In addition to the mapping of local branches to local branches which
--bare does, --mirror maps all refs which the source has under the same
name in the target (including remote branches, notes etc.) and sets up a
refspec configuration so that all these refs are updated by a `git
update` in the target repo.

Michael