initial import of git tools...
[divverent/div0-gittools.git] / git-pullall
1 #!/bin/sh
2
3 set -e
4 #set -x
5
6 cur=`git symbolic-ref HEAD`
7 case "$cur" in
8         refs/heads/*)
9                 cur=${cur#refs/heads/}
10                 ;;
11         *)
12                 echo >&2 "Not in a branch"
13                 exit 1
14                 ;;
15 esac
16 git update-index -q --refresh
17
18 if git diff-index --quiet --cached HEAD --ignore-submodules -- && git diff-files --quiet --ignore-submodules; then
19         stashed=false
20 else
21         git stash save
22         stashed=true
23 fi
24
25 eval `git for-each-ref --shell --format='
26         b=%(refname);
27         b=${b#refs/heads/};
28         if git config branch.$b.merge >/dev/null && git config branch.$b.remote >/dev/null; then
29                 git checkout "$b";
30                 git pull;
31         fi;
32 ' refs/heads/`
33 git checkout "$cur"
34 if $stashed; then
35         git stash pop --index
36 fi