.bashrc: Setup $GOPATH
[dotfiles.git] / bin / git-subup
index 04ea0b57f53ed3ec73190481ecb6609896729678..ceef5b6149ed69f712b692325db467977188d3ec 100755 (executable)
@@ -1,8 +1,15 @@
-#!/bin/sh
-# Checkout and update source for all registered submodules (.gitmodules)
+#!/bin/bash
+# Checkout and update source for all registered submodules (.gitmodules).
+# Optionally 'git pull' on each submodule to check for updates.
 
-cd $(git rev-parse --show-toplevel)
-git submodule update --init --quiet
-git submodule sync --quiet
-git submodule foreach --quiet git checkout --quiet master
-git submodule foreach git pull --prune
+# Ensure all submodules (and child submodules) are checked-out
+git submodule update --init --recursive
+
+# Update submodules' remotes based on .gitmodules
+git submodule sync
+
+if [ "$1" = "pull" ]; then
+    # Fetch & pull any new updates from submodule's origin
+    # [http://scribu.net/blog/git-alias-for-updating-submodules.html]
+    git submodule foreach 'git fetch origin --tags; git checkout master; git pull'
+fi