aboutsummaryrefslogtreecommitdiff
path: root/helpers/git-refresh
blob: d42381287cbe1f02d1a429c5509df7a2cadbebce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash

# This script refreshes the local repository with the contents of the
# upstream repository. The main usage of this is to pull the
# master branch, and sync git-svn if necessary.
#
# Syntax: git-refresh [all]

. llvm-common

# Update from origin to upstream
master_dir=`git rev-parse --git-common-dir`

pushdq $master_dir/../
trap popdq EXIT

safe_run git checkout master
echo " + Fetching origin..."
safe_run git fetch origin
safe_run git remote update -p

if is_git_svn; then
  echo " + Rebasing SVN master..."
  safe_run git svn rebase -l
else
  echo " + Rebasing master..."
  safe_run git pull
fi

# Fetch all other remotes
if [[ $1 = 'all' ]]; then
  for remote in `git remote`; do
    if [ "$remote" != "origin" ]; then
      echo " + Fetching remote $remote..."
      safe_run git fetch $remote
    fi
  done
fi