]> git.phdru.name Git - git-scripts.git/blob - update-remotes
Feat(submodules/remove): Add option `-c`
[git-scripts.git] / update-remotes
1 #! /bin/sh
2
3 current="`git config --get --path remote.current.url`"
4 origin="`git config --get --path remote.origin.url`"
5 branches="master ${1:+$@}"
6
7 if [ -n "$origin" ]; then
8    if [ -n "$current" ]; then
9       echo "Config error (both origin and current)" >&2
10       exit 1
11    else
12       cd "$origin" &&
13       exec ./update-remotes
14    fi
15 elif [ -z "$current" ]; then
16    echo "Wrong directory error (neither origin nor current)" >&2
17    exit 1
18 fi
19
20 git fetch current &&
21 { git pull --ff-only current master || git reset --hard current/master ; } &&
22 git set-date &&
23
24 web="`git config --get --path remote.web.url`" &&
25 if [ -n "$web" ]; then
26    git push --force web $branches
27 fi &&
28
29 cd "$current" &&
30 git pull origin &&
31 exec git set-date