]> git.phdru.name Git - git-scripts.git/blobdiff - update-remotes
Rename update -> update-remotes
[git-scripts.git] / update-remotes
diff --git a/update-remotes b/update-remotes
new file mode 100755 (executable)
index 0000000..b164567
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+current="`git config --get --path remote.current.url`"
+origin="`git config --get --path remote.origin.url`"
+
+if [ -n "$origin" ]; then
+   if [ -n "$current" ]; then
+      echo "Config error (both origin and current)" >&2
+      exit 1
+   else
+      cd "$origin" &&
+      exec ./update-remotes
+   fi
+elif [ -z "$current" ]; then
+   echo "Wrong directory error (neither origin nor current)" >&2
+   exit 1
+fi
+
+git pull --ff-only current master &&
+
+web="`git config --get --path remote.web.url`" &&
+if [ -n "$web" ]; then
+   git push web
+fi &&
+
+cd "$current" && exec git pull origin