#!/bin/bash
# 
# Acts like git checkout, but performs the action on the super-repo
# and each submodule, recursively.
# NCS, Nov 2017

# Verify that we are in the super-repo
[ -d CanAM ] ||  { echo "ERROR: You MUST be in the CanESM super-repo" ; exit 1 ; } 

[ -z "$1" ] && { echo "ERROR: You MUST specify a ref to checkout as the first arguement" ; exit 1 ; }

git checkout $@
git submodule update --recursive --checkout # At least start in a consistent place with the super repo
git submodule foreach --recursive "git checkout $@ || :" 

