diff --git a/dup b/dup index 2c6afcd..abc47c0 100755 --- a/dup +++ b/dup @@ -20,6 +20,16 @@ function do_get() { fi } +function do_pull() { + if [ "$stashAndSync" = true ] + then + git stash + git pull --rebase + git push + git stash pop || true + fi +} + function run_script() { script="$1"; shift targets="$@" @@ -45,6 +55,7 @@ function maybe_stow() { stow=true bootstrap=false +stashAndSync=false while [ "$#" -gt 0 ] do case $1 in @@ -56,6 +67,10 @@ do bootstrap=true shift ;; + -s | --stash-and-sync) + stashAndSync=true + shift + ;; --) shift break @@ -90,13 +105,13 @@ then elif [ "$bootstrap" != true ] then echo "Updating .dotfiles" - git pull + do_pull for dir in */ do echo "Updating $dir" cd "$dir" - git pull + do_pull cd .. done