From: Colin Watson Date: Fri, 8 Jul 2005 19:37:25 +0000 (+0000) Subject: New tool to get/update/switch (as appropriate) subdirectories in a tree X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=commitdiff_plain;h=66785e5dcef209c1b0890c169a11dc0a9e241728;hp=7f9c44bbc8ead909e8f14f0c3a7b8c4112c5dc15 New tool to get/update/switch (as appropriate) subdirectories in a tree built with an arch config. --- diff --git a/baz-update-config b/baz-update-config new file mode 100755 index 0000000..e992cf9 --- /dev/null +++ b/baz-update-config @@ -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