summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-07-04 17:19:27 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-07-04 17:19:27 +0200
commit5b857b1009d0fdf5186d96840d5e6b04ff4411b9 (patch)
treebfaf108e928ed4b9630975798ccfcc404f717087
parentb28dab49bd8df92aecf3eb458a94f8e8989b18e0 (diff)
downloadbin-5b857b1009d0fdf5186d96840d5e6b04ff4411b9.zip
bin-5b857b1009d0fdf5186d96840d5e6b04ff4411b9.tar.gz
git-synk: use git stash when needed
-rwxr-xr-xgit-synk7
1 files changed, 6 insertions, 1 deletions
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}"