From f3c03913bb8023a8bd706b913e89dee38e8f1432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 5 Jul 2011 21:15:36 +0200 Subject: git-synk: add USE_STASH flag --- git-synk | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/git-synk b/git-synk index 17a9997..602ea37 100755 --- a/git-synk +++ b/git-synk @@ -2,10 +2,12 @@ if [ $# -gt 0 ]; then GIT_REMOTE=$1; shift; fi if [ $# -gt 0 ]; then GIT_BRANCH=$1; shift; fi +if [ $# -gt 0 ]; then USE_STASH=1; shift; fi GIT_BASE=${GIT_BASE:-$HOME/usr/git} GIT_REMOTE=${GIT_REMOTE:-origin} GIT_BRANCH=${GIT_BRANCH:-master} +USE_STASH=${USE_STASH:-0} RESET="\033[0m" RED="\033[0;31m" @@ -15,6 +17,7 @@ PURPLE="\033[0;35m" CYAN="\033[0;36m" YELLOW="\033[1;33m" +echo -e "remote: ${RED}$GIT_REMOTE${RESET}:${CYAN}$GIT_BRANCH${RESET}" for gitdir in ${GIT_BASE}; do echo -e "enter ${BROWN}${gitdir}${RESET}" && cd ${gitdir} || return 1 for dir in $(ls -1); do @@ -29,8 +32,12 @@ for gitdir in ${GIT_BASE}; do # GC + CLEAN echo -ne " ${CYAN}clean$RESET ... " && git gc 2>/dev/null && git diff --quiet && echo -e "${GREEN}OK${RESET}" if [ $? -ne 0 ]; then - STASH=1 - echo -e "${RED}head is not clean, ${CYAN}git stash save${RESET}" && git stash save -q + if [ $USE_STASH -eq 1 ]; then + STASH=1 + echo -e "${RED}head is not clean, ${CYAN}git stash save${RESET}" && git stash save -q + else + echo -e "${RED}head is not clean, USE_STASH=0 ... ${CYAN}leave${RESET}" && cd .. && continue + fi fi # PULL echo -ne " ${CYAN}pull${RESET}: ${YELLOW}${GIT_REMOTE}${RESET}:${PURPLE}${GIT_BRANCH}${RESET} ... " && \ -- cgit v1.1-2-g2b99