git-mirror - exactly mirror another repository
Subsystems (2)
PATCH 1/1 git-mirror - exactly mirror another repository
Sometimes its handy to be able to efficiently backup or mirror one Git repository to another Git repository by employing the native Git object transfer protocol. But when mirroring or backing up a repository you really want:
1) Every object in the source to go to the mirror.
2) Every ref in the source to go to the mirror.
3) Any ref removed from the source to be removed from the mirror.
and since git-fetch doesn't do 2 and 3, here's a tool that does.
This is based on Shawn Pearce's patch from 25 Sep 2006, updated to take Junio's and Sergey's review into account, to use few newer pieces of Git infrastructure and with few trivial tweaks. The repacking part was dropped since git-fetch does that on its own now.
I actually still would kind of prefer this to be a git-fetch's feature but the general mood seems to be to have this as a separate command and I can't say I care at all.
---
.gitignore | 1 Documentation/config.txt | 6 ++ Documentation/git-mirror.txt | 54 +++++++++++++++++++++ Makefile | 2 - git-mirror.perl | 110 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 172 insertions(+), 1 deletions(-)
.gitignore +1 -0
@@ -80,6 +80,7 @@ git-merge-resolve git-merge-stupid git-merge-subtree git-mergetool +git-mirror git-mktag git-mktree git-name-rev
Documentation/config.txt +6 -0
@@ -513,6 +513,12 @@ log.showroot:: Tools like gitlink:git-log[1] or gitlink:git-whatchanged[1], which normally hide the root commit will now show it. True by default. +mirror.allowed:: + If true, gitlink:git-mirror[1] will be allowed to run on the + repository. Please see its documentation for all the implications. + +mirror. + merge.summary:: Whether to include summaries of merged commits in newly created merge commit messages. False by default.
Documentation/git-mirror.txt new file +54 -0
54 lines not on this page · raw message
Makefile +1 -1
@@ -208,7 +208,7 @@ SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ git-cvsserver.perl git-remote.perl \ git-svnimport.perl git-cvsexportcommit.perl \ - git-send-email.perl git-svn.perl + git-send-email.perl git-svn.perl git-mirror.perl SCRIPT_PYTHON = \ git-p4import.py
git-mirror.perl new file +110 -0
110 lines not on this page · raw message
Sorry for the dupe mail, accidentally slipped out. Full patch series
show arrive when vger's greylisting permits.
Petr "Pasky" Baudis
Quoted 11 lines · Petr Baudis
Sometimes its handy to be able to efficiently backup or mirror one Git repository to another Git repository by employing the native Git object transfer protocol. But when mirroring or backing up a repository you really want:
1) Every object in the source to go to the mirror.
2) Every ref in the source to go to the mirror.
3) Any ref removed from the source to be removed from the mirror.and since git-fetch doesn't do 2 and 3, here's a tool that does.
Quoted 9 lines
This is based on Shawn Pearce's patch from 25 Sep 2006, updated to take Junio's and Sergey's review into account, to use few newer pieces of Git infrastructure and with few trivial tweaks. The repacking part was dropped since git-fetch does that on its own now.
I actually still would kind of prefer this to be a git-fetch's feature but the general mood seems to be to have this as a separate command and I can't say I care at all.
It would be nice if this had an option to not mirror HEAD and another option to map the refs from (/ref/[^/])/(.*) to /ref/\1/${repo_path}/\2.
Quoted 2 lines · A Large Angry SCM
It would be nice if this had an option to not mirror HEAD and another option to map the refs from (/ref/[^/])/(.*) to /ref/\1/${repo_path}/\2.
When I try to guess why you want this, I think this is just saying "it would be nice if this was part of git-fetch and if git-fetch actually did this automagically by default". Because when you clone a given repository with all its branches, you are naturally interested not only in the snapshot of the branch set at the point of the clone but more likely just want "anytime whatever branches are over there". So when fetching a * refspec it's natural to look for new branches and fetch them too; and if you do that, it should be pretty easy to also (probably optionally) remove stale branches.
But heck, maybe with all the nifty fetch--tools git-fetch is already doing it. But there seems to be basically zero documentation, the code is not that easy to follow and it's too late for me to be decyphering it now...
Signature · 4 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ Ever try. Ever fail. No matter. // Try again. Fail again. Fail better. -- Samuel Beckett
Quoted 4 lines · Petr Baudis
But heck, maybe with all the nifty fetch--tools git-fetch is already doing it. But there seems to be basically zero documentation, the code is not that easy to follow and it's too late for me to be decyphering it now...
Ok, so it seems that git-fetch already can do almost all of this; at least it seems that I'm far from being alone in not realizing it. :-)
With the refspec +refs/heads/*:refs/heads/* and git remote prune (thanks, Shawn!), it seems that git-fetch can already do everything git-mirror tries to do, except updating the HEAD, but especially with the symref embedding in git-ls-remote that Junio proposed, even that should be fixable easily, right?
Signature · 4 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ Ever try. Ever fail. No matter. // Try again. Fail again. Fail better. -- Samuel Beckett
Quoted 47 lines · Petr Baudis
Sometimes its handy to be able to efficiently backup or mirror one Git repository to another Git repository by employing the native Git object transfer protocol. But when mirroring or backing up a repository you really want:
1) Every object in the source to go to the mirror.
2) Every ref in the source to go to the mirror.
3) Any ref removed from the source to be removed from the mirror.and since git-fetch doesn't do 2 and 3, here's a tool that does.
This is based on Shawn Pearce's patch from 25 Sep 2006, updated to take Junio's and Sergey's review into account, to use few newer pieces of Git infrastructure and with few trivial tweaks. The repacking part was dropped since git-fetch does that on its own now.
I actually still would kind of prefer this to be a git-fetch's feature but the general mood seems to be to have this as a separate command and I can't say I care at all.
Signed-off-by Petr Baudis <[email protected]>---
.gitignore | 1 Documentation/config.txt | 6 ++ Documentation/git-mirror.txt | 54 +++++++++++++++++++++ Makefile | 2 - git-mirror.perl | 110 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 172 insertions(+), 1 deletions(-).gitignore +1
-0@@ -80,6 +80,7 @@ git-merge-resolve git-merge-stupid git-merge-subtree git-mergetool +git-mirror git-mktag git-mktree git-name-revDocumentation/config.txt +0
-0
Documentation/config.txt log.showroot:: · line 521
Quoted 9 lines
Documentation/config.txt +6
-0@@ -513,6 +513,12 @@ log.showroot:: Tools like gitlink:git-log[1] or gitlink:git-whatchanged[1], which normally hide the root commit will now show it. True by default. +mirror.allowed:: + If true, gitlink:git-mirror[1] will be allowed to run on the + repository. Please see its documentation for all the implications. + +mirror. +
Ok, I can see why you'd want to protect a user from going git-mirror <foo> and losing their local changes. But you've only protected them from mirroring at all. If they want to use this repo as a mirror of somewhere X you have not stopped them from git-mirror Y'ing themselves.
Now yes if you know its a mirror then I guess you can recover with a
git-mirror X but ...
It seems to me if you are having a config option that perhaps it should be the URL from whence the mirror comes, and the command should just be 'git mirror'.
[mirror]
url='somewhere'
-apw
Hi,
Quoted 3 lines · Petr Baudis
I actually still would kind of prefer this to be a git-fetch's feature but the general mood seems to be to have this as a separate command and I can't say I care at all.
I have to admit that I share your preference. And I really would like to be able to say "git fetch --all <remote>", because I use Git for backup operations, too.
Ciao,
Dscho