git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [COGITO PATCH] mirroring repositories
@ 2005-05-29 21:41 Michael Frank
  2005-06-02 21:24 ` Petr Baudis
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Frank @ 2005-05-29 21:41 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 492 bytes --]

The attached patch adds the two programs cg-mirror-add and
cg-mirror-sync.  Say you do all of your work on your laptop and you want
to make a mirror of your repository available to the public.  You
specify the location of the mirror with cg-mirror-add:

$ cg-mirror-add scp://my.server:/var/www/repos/project.git

which locally creates the file .git/mirrors.  Whenever you want to
upload your changes, you run cg-mirror-sync.

Michael

Signed-off-by: Michael Frank <msfrank@syntaxjockey.com>

[-- Attachment #2: mirror.patch --]
[-- Type: text/x-patch, Size: 2426 bytes --]

diff -pruN cogito.old/cg-mirror-add cogito.new/cg-mirror-add
--- cogito.old/cg-mirror-add	1969-12-31 16:00:00.000000000 -0800
+++ cogito.new/cg-mirror-add	2005-05-26 18:46:16.357489808 -0700
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+#
+# Add new mirror to the GIT repository.
+# Copyright (c) Michael Frank, 2005
+#
+# Takes the mirror location as parameter.  Location can be
+# an rsync URI, as in:
+#     $ cg-mirror add rsync://your.server:/path/to/project.git
+#
+# or an scp URI (rsync is still used to copy the files):
+#     $ cg-mirror add scp://user@your.server:/project/path.git
+#
+
+. ${COGITO_LIB}cg-Xlib
+
+location=$1
+
+([ "$location" ]) || die "usage: cg-mirror-add MIRROR_LOC"
+if [ -e $_git/mirrors ]; then
+    grep -xq $location $_git/mirrors && die "mirror already exists"
+fi
+echo "$location" >> $_git/mirrors
diff -pruN cogito.old/cg-mirror-sync cogito.new/cg-mirror-sync
--- cogito.old/cg-mirror-sync	1969-12-31 16:00:00.000000000 -0800
+++ cogito.new/cg-mirror-sync	2005-05-26 18:37:35.408686064 -0700
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+#
+# Pushes changes from the local GIT repository to mirrors.
+# Copyright (c) Michael Frank, 2005
+#
+
+. ${COGITO_LIB}cg-Xlib
+
+[ -r $_git/mirrors ] || die "No mirrors to sync!"
+
+uri=
+for mirror in `cat $_git/mirrors`; do
+    if echo $mirror | grep -q "^scp://"; then
+        uri=`echo $mirror | sed -e "s/^scp:\/\///"`
+        echo "syncing $mirror ..."
+        rsync -a -v -z --exclude=mirrors $_git/* $uri
+        echo ""
+    elif echo $mirror | grep -q "^rsync://"; then
+        echo "syncing $mirror ..."
+        rsync -a -v -z --exclude=mirrors $_git/* $mirror
+        echo ""
+    else
+        echo "skipping $mirror; mirror uses unknown transport"
+    fi
+done
diff -pruN cogito.old/Makefile cogito.new/Makefile
--- cogito.old/Makefile	2005-05-26 19:15:25.412593016 -0700
+++ cogito.new/Makefile	2005-05-26 17:44:43.348912448 -0700
@@ -55,7 +55,8 @@ PROG=   git-update-cache git-diff-files 
 SCRIPT=	commit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \
 	cg-branch-add cg-branch-ls cg-cancel cg-clone cg-commit cg-diff \
 	cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch cg-patch \
-	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update
+	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
+	cg-mirror-add cg-mirror-sync
 
 LIB_SCRIPT=cg-Xlib cg-Xdiffdo cg-Xmergefile
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [COGITO PATCH] mirroring repositories
  2005-05-29 21:41 [COGITO PATCH] mirroring repositories Michael Frank
@ 2005-06-02 21:24 ` Petr Baudis
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Baudis @ 2005-06-02 21:24 UTC (permalink / raw)
  To: Michael Frank; +Cc: git

Dear diary, on Sun, May 29, 2005 at 11:41:23PM CEST, I got a letter
where Michael Frank <msfrank@syntaxjockey.com> told me that...
> The attached patch adds the two programs cg-mirror-add and
> cg-mirror-sync.  Say you do all of your work on your laptop and you want
> to make a mirror of your repository available to the public.  You
> specify the location of the mirror with cg-mirror-add:
> 
> $ cg-mirror-add scp://my.server:/var/www/repos/project.git
> 
> which locally creates the file .git/mirrors.  Whenever you want to
> upload your changes, you run cg-mirror-sync.

FWIW, I think this is the wrong approach - full-blown pushing makes much
more sense since it's a full superset of mirroring and it's more
universal, and not *that* more complicated to do (basically just the
HEAD stuff - and I think the race conditions around that don't matter
that much in the real life if you take some basic crude protections).

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-02 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-29 21:41 [COGITO PATCH] mirroring repositories Michael Frank
2005-06-02 21:24 ` Petr Baudis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).