From 5b857b1009d0fdf5186d96840d5e6b04ff4411b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Jul 2011 17:19:27 +0200 Subject: git-synk: use git stash when needed --- git-synk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-synk b/git-synk index 2a522c8..17a9997 100755 --- a/git-synk +++ b/git-synk @@ -18,6 +18,7 @@ YELLOW="\033[1;33m" for gitdir in ${GIT_BASE}; do echo -e "enter ${BROWN}${gitdir}${RESET}" && cd ${gitdir} || return 1 for dir in $(ls -1); do + STASH=0 [ -d ${dir} ] && [ -e ${dir}/.git/config ] || continue # SEARCH REMOTE echo -e " enter ${BROWN}${dir}${RESET}" && cd $dir || exit 1 @@ -28,7 +29,8 @@ 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 - echo -e "${RED}head is not clear${RESET}" && cd .. && continue + STASH=1 + echo -e "${RED}head is not clean, ${CYAN}git stash save${RESET}" && git stash save -q fi # PULL echo -ne " ${CYAN}pull${RESET}: ${YELLOW}${GIT_REMOTE}${RESET}:${PURPLE}${GIT_BRANCH}${RESET} ... " && \ @@ -42,6 +44,9 @@ for gitdir in ${GIT_BASE}; do if [ $? -ne 0 ]; then echo -e "${RED}KO${RESET}" && cd .. && continue fi + if [ $STASH -eq 1 ]; then + echo -e " ${RED}was not clean, ${CYAN}git stash pop${RESET}" && git stash pop -q + fi cd .. done echo -e "leave ${BROWN}${gitdir}${RESET}" -- cgit v1.1-2-g2b99