chiark / gitweb /
New tool to get/update/switch (as appropriate) subdirectories in a tree
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Fri, 8 Jul 2005 19:37:25 +0000 (19:37 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Fri, 8 Jul 2005 19:37:25 +0000 (19:37 +0000)
built with an arch config.

baz-update-config [new file with mode: 0755]

diff --git a/baz-update-config b/baz-update-config
new file mode 100755 (executable)
index 0000000..e992cf9
--- /dev/null
@@ -0,0 +1,31 @@
+#! /bin/sh
+set -e
+
+CONFIG="$1"
+if [ -z "$CONFIG" ]; then
+       echo "Usage: $0 CONFIG" >&2
+       exit 1
+fi
+
+NEWLINE='
+'
+
+IFS_SAVE="$IFS"
+IFS="$NEWLINE"
+for line in $(baz cat-config "$1"); do
+       IFS="$IFS_SAVE"
+       set -- $line
+       DIR="$1"
+       VERSION="$2"
+
+       if [ -d "$DIR" ]; then
+               OLDVERSION="$(baz tree-version -d "$DIR")"
+               if [ "$VERSION" != "$OLDVERSION" ]; then
+                       baz switch -d "$DIR" "$VERSION"
+               else
+                       baz update -d "$DIR" "$VERSION"
+               fi
+       else
+               baz get "$VERSION" "$DIR"
+       fi
+done