[RFC] Moving "git remote add --mirror blah" functionality to "git clone --bare --origin=blah"
- From
Paolo Bonzini <bonzini@gnu.org>
- Date
- Apr 23, 2008, 08:28 UTC
- Message-ID
- <480EF334.1090907@gnu.org>
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.
Actually you don't need to add a new option. Right now, specifying -o/--origin together with --bare would give an error; in my proposal, if you had "--bare --origin=source" a remote would be created in the config file like this:
[remote "source"] url = ... fetch = +refs/*:refs/*
2) Modify the --mirror option to "git remote add", so that it creates a remote *acting as a mirror of this one*. The config would look like this:
[remote "mirror"]
url = ...
fetch = +refs/heads/*:refs/remotes/mirror/*
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
mirrorNow, I know that this is not what was proposed in the original --mirror thread, and it is backwards-incompatible. On the other hand, I think it has several advantages:
1) it does not add special cases such as "--mirror is only to be used in a --bare repository". It moves the functionality to a combination of options that used to give an error.
2) it provides an easy-to-use UI to create a mirror of this repository somewhere. With a patch I already posted, "git push" would automatically update this mirror.
3) overall, I think it makes a lot of sense: "git remote add" is about adding one remote of many, and "git clone" is about setting up a single special remote. Now, you can have many remotes that are mirrored-from-here, while you can only have one remote that is mirrored-to-here. So, I believe that "git remote add" should add mirrored-from-here remotes, while "git clone" should be used to create a mirrored-to-here remote.
Opinions?
Paolo