diff options
-rwxr-xr-x | git-synk | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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} ... " && \ |