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 |
maruel@chromium.org | 37801da | 2010-10-18 13:54:08 +0000 | [diff] [blame^] | 12 | # Always override "origin" |
| 13 | (cd "$repo"; git remote set-url origin $url) |
msb@chromium.org | dffe494 | 2009-11-18 02:25:16 +0000 | [diff] [blame] | 14 | fi |
maruel@chromium.org | 565db0e | 2009-06-05 18:08:54 +0000 | [diff] [blame] | 15 | |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 16 | if [ ! -f "$repo/git-cl" ]; then |
| 17 | git clone $url $repo -q |
msb@chromium.org | b48f229 | 2010-10-06 19:48:39 +0000 | [diff] [blame] | 18 | elif [ ! -e "$repo/.git" ]; then |
| 19 | echo "$0: $repo does not appear to be a git repo" |
msb@chromium.org | d065ecc | 2010-07-13 22:46:06 +0000 | [diff] [blame] | 20 | elif [ "X$DEPOT_TOOLS_UPDATE" != "X0" ]; then |
msb@chromium.org | b48f229 | 2010-10-06 19:48:39 +0000 | [diff] [blame] | 21 | (cd "$repo"; git pull -q) |
maruel@chromium.org | 565db0e | 2009-06-05 18:08:54 +0000 | [diff] [blame] | 22 | fi |
| 23 | |
derat@chromium.org | e08f491 | 2010-02-17 22:11:37 +0000 | [diff] [blame] | 24 | $repo/git-cl "$@" |