maruel@chromium.org | 565db0e | 2009-06-05 18:08:54 +0000 | [diff] [blame] | 1 | #!/bin/sh |
derat@chromium.org | b7ec6aa | 2010-02-16 17:04:39 +0000 | [diff] [blame] | 2 | # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
maruel@chromium.org | 565db0e | 2009-06-05 18:08:54 +0000 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | base_dir=$(dirname "$0") |
msb@chromium.org | b48f229 | 2010-10-06 19:48:39 +0000 | [diff] [blame] | 7 | repo="$base_dir/git_cl_repo" |
chase@chromium.org | 733bc0f | 2010-10-18 12:54:00 +0000 | [diff] [blame] | 8 | url="http://git.chromium.org/git/git-cl.git" |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 9 | cur_url=$(git config -f "$repo/.git/config" remote.origin.url) |
msb@chromium.org | dffe494 | 2009-11-18 02:25:16 +0000 | [diff] [blame] | 10 | |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 11 | if [ -e "$repo" -a "$cur_url" != "$url" ]; then |
derat@chromium.org | b7ec6aa | 2010-02-16 17:04:39 +0000 | [diff] [blame] | 12 | cat <<EOF |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 13 | $repo |
derat@chromium.org | b7ec6aa | 2010-02-16 17:04:39 +0000 | [diff] [blame] | 14 | is tracking a non-default remote repository: |
| 15 | |
| 16 | default: $url |
| 17 | yours: $cur_url |
| 18 | |
| 19 | This is intended to be an automatically-updating, read-only repository. |
| 20 | Please create a separate repository for making changes to git-cl, move your |
| 21 | modifications there, and then run: |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 22 | rm -rf $repo |
derat@chromium.org | b7ec6aa | 2010-02-16 17:04:39 +0000 | [diff] [blame] | 23 | EOF |
| 24 | exit 1 |
msb@chromium.org | dffe494 | 2009-11-18 02:25:16 +0000 | [diff] [blame] | 25 | fi |
maruel@chromium.org | 565db0e | 2009-06-05 18:08:54 +0000 | [diff] [blame] | 26 | |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 27 | if [ ! -f "$repo/git-cl" ]; then |
| 28 | git clone $url $repo -q |
msb@chromium.org | b48f229 | 2010-10-06 19:48:39 +0000 | [diff] [blame] | 29 | elif [ ! -e "$repo/.git" ]; then |
| 30 | echo "$0: $repo does not appear to be a git repo" |
msb@chromium.org | d065ecc | 2010-07-13 22:46:06 +0000 | [diff] [blame] | 31 | elif [ "X$DEPOT_TOOLS_UPDATE" != "X0" ]; then |
msb@chromium.org | b48f229 | 2010-10-06 19:48:39 +0000 | [diff] [blame] | 32 | (cd "$repo"; git pull -q) |
maruel@chromium.org | 565db0e | 2009-06-05 18:08:54 +0000 | [diff] [blame] | 33 | fi |
| 34 | |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 35 | $repo/git-cl "$@" |