{"thread":{"id":"761","subject":"[COGITO PATCH] mirroring repositories","startedAt":"2005-05-29T21:41:23Z","lastAt":"2005-06-02T21:24:36Z","messageCount":2,"participants":["Michael Frank","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4198","messageId":"1117402883.8536.5.camel@localhost.localdomain","threadId":"761","inReplyTo":null,"subject":"[COGITO PATCH] mirroring repositories","fromName":"Michael Frank","fromEmail":"msfrank@syntaxjockey.com","sentAt":"2005-05-29T21:41:23Z","receivedAt":"2005-05-29T21:41:23Z","isPatch":true,"sender":{"key":"msfrank@syntaxjockey.com","avatar":null},"body":"The attached patch adds the two programs cg-mirror-add and\ncg-mirror-sync.  Say you do all of your work on your laptop and you want\nto make a mirror of your repository available to the public.  You\nspecify the location of the mirror with cg-mirror-add:\n\n$ cg-mirror-add scp://my.server:/var/www/repos/project.git\n\nwhich locally creates the file .git/mirrors.  Whenever you want to\nupload your changes, you run cg-mirror-sync.\n\nMichael\n\nSigned-off-by: Michael Frank <msfrank@syntaxjockey.com>\n\n\ndiff -pruN cogito.old/cg-mirror-add cogito.new/cg-mirror-add\n--- cogito.old/cg-mirror-add\t1969-12-31 16:00:00.000000000 -0800\n+++ cogito.new/cg-mirror-add\t2005-05-26 18:46:16.357489808 -0700\n@@ -0,0 +1,22 @@\n+#!/usr/bin/env bash\n+#\n+# Add new mirror to the GIT repository.\n+# Copyright (c) Michael Frank, 2005\n+#\n+# Takes the mirror location as parameter.  Location can be\n+# an rsync URI, as in:\n+#     $ cg-mirror add rsync://your.server:/path/to/project.git\n+#\n+# or an scp URI (rsync is still used to copy the files):\n+#     $ cg-mirror add scp://user@your.server:/project/path.git\n+#\n+\n+. ${COGITO_LIB}cg-Xlib\n+\n+location=$1\n+\n+([ \"$location\" ]) || die \"usage: cg-mirror-add MIRROR_LOC\"\n+if [ -e $_git/mirrors ]; then\n+    grep -xq $location $_git/mirrors && die \"mirror already exists\"\n+fi\n+echo \"$location\" >> $_git/mirrors\ndiff -pruN cogito.old/cg-mirror-sync cogito.new/cg-mirror-sync\n--- cogito.old/cg-mirror-sync\t1969-12-31 16:00:00.000000000 -0800\n+++ cogito.new/cg-mirror-sync\t2005-05-26 18:37:35.408686064 -0700\n@@ -0,0 +1,25 @@\n+#!/usr/bin/env bash\n+#\n+# Pushes changes from the local GIT repository to mirrors.\n+# Copyright (c) Michael Frank, 2005\n+#\n+\n+. ${COGITO_LIB}cg-Xlib\n+\n+[ -r $_git/mirrors ] || die \"No mirrors to sync!\"\n+\n+uri=\n+for mirror in `cat $_git/mirrors`; do\n+    if echo $mirror | grep -q \"^scp://\"; then\n+        uri=`echo $mirror | sed -e \"s/^scp:\\/\\///\"`\n+        echo \"syncing $mirror ...\"\n+        rsync -a -v -z --exclude=mirrors $_git/* $uri\n+        echo \"\"\n+    elif echo $mirror | grep -q \"^rsync://\"; then\n+        echo \"syncing $mirror ...\"\n+        rsync -a -v -z --exclude=mirrors $_git/* $mirror\n+        echo \"\"\n+    else\n+        echo \"skipping $mirror; mirror uses unknown transport\"\n+    fi\n+done\ndiff -pruN cogito.old/Makefile cogito.new/Makefile\n--- cogito.old/Makefile\t2005-05-26 19:15:25.412593016 -0700\n+++ cogito.new/Makefile\t2005-05-26 17:44:43.348912448 -0700\n@@ -55,7 +55,8 @@ PROG=   git-update-cache git-diff-files \n SCRIPT=\tcommit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \\\n \tcg-branch-add cg-branch-ls cg-cancel cg-clone cg-commit cg-diff \\\n \tcg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch cg-patch \\\n-\tcg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update\n+\tcg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \\\n+\tcg-mirror-add cg-mirror-sync\n \n LIB_SCRIPT=cg-Xlib cg-Xdiffdo cg-Xmergefile\n \n"},{"id":"4453","messageId":"20050602212436.GI32189@pasky.ji.cz","threadId":"761","inReplyTo":"1117402883.8536.5.camel@localhost.localdomain","subject":"Re: [COGITO PATCH] mirroring repositories","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-06-02T21:24:36Z","receivedAt":"2005-06-02T21:24:36Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sun, May 29, 2005 at 11:41:23PM CEST, I got a letter\nwhere Michael Frank <msfrank@syntaxjockey.com> told me that...\n> The attached patch adds the two programs cg-mirror-add and\n> cg-mirror-sync.  Say you do all of your work on your laptop and you want\n> to make a mirror of your repository available to the public.  You\n> specify the location of the mirror with cg-mirror-add:\n> \n> $ cg-mirror-add scp://my.server:/var/www/repos/project.git\n> \n> which locally creates the file .git/mirrors.  Whenever you want to\n> upload your changes, you run cg-mirror-sync.\n\nFWIW, I think this is the wrong approach - full-blown pushing makes much\nmore sense since it's a full superset of mirroring and it's more\nuniversal, and not *that* more complicated to do (basically just the\nHEAD stuff - and I think the race conditions around that don't matter\nthat much in the real life if you take some basic crude protections).\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"}]}