Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script refreshes the local repository with the contents of the |
| 4 | # upstream repository. The main usage of this is to pull the |
| 5 | # master branch, and sync git-svn if necessary. |
| 6 | # |
| 7 | # Syntax: git-refresh [all] |
| 8 | |
| 9 | . llvm-common |
| 10 | |
| 11 | # Update from origin to upstream |
Diana Picus | 72189fd | 2016-05-23 19:32:46 +0300 | [diff] [blame] | 12 | master_dir=`git rev-parse --git-common-dir` |
| 13 | |
| 14 | pushdq $master_dir/../ |
| 15 | trap popdq EXIT |
| 16 | |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 17 | safe_run git checkout master |
| 18 | echo " + Fetching origin..." |
| 19 | safe_run git fetch origin |
Renato Golin | 98312fe | 2017-04-13 17:05:31 +0100 | [diff] [blame] | 20 | safe_run git remote update -p |
| 21 | |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 22 | if is_git_svn; then |
| 23 | echo " + Rebasing SVN master..." |
| 24 | safe_run git svn rebase -l |
| 25 | else |
| 26 | echo " + Rebasing master..." |
| 27 | safe_run git pull |
| 28 | fi |
| 29 | |
| 30 | # Fetch all other remotes |
| 31 | if [[ $1 = 'all' ]]; then |
| 32 | for remote in `git remote`; do |
| 33 | if [ "$remote" != "origin" ]; then |
| 34 | echo " + Fetching remote $remote..." |
| 35 | safe_run git fetch $remote |
| 36 | fi |
| 37 | done |
| 38 | fi |