blob: 48cc4cdf2ddb8f035efbf01d82a5286616e4b317 [file] [log] [blame]
maruel@chromium.org565db0e2009-06-05 18:08:54 +00001#!/bin/sh
derat@chromium.orgb7ec6aa2010-02-16 17:04:39 +00002# Copyright (c) 2010 The Chromium Authors. All rights reserved.
maruel@chromium.org565db0e2009-06-05 18:08:54 +00003# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6base_dir=$(dirname "$0")
msb@chromium.orgb48f2292010-10-06 19:48:39 +00007repo="$base_dir/git_cl_repo"
chase@chromium.org733bc0f2010-10-18 12:54:00 +00008url="http://git.chromium.org/git/git-cl.git"
derat@chromium.orge08f4912010-02-17 22:11:37 +00009cur_url=$(git config -f "$repo/.git/config" remote.origin.url)
msb@chromium.orgdffe4942009-11-18 02:25:16 +000010
derat@chromium.orge08f4912010-02-17 22:11:37 +000011if [ -e "$repo" -a "$cur_url" != "$url" ]; then
maruel@chromium.org37801da2010-10-18 13:54:08 +000012 # Always override "origin"
13 (cd "$repo"; git remote set-url origin $url)
msb@chromium.orgdffe4942009-11-18 02:25:16 +000014fi
maruel@chromium.org565db0e2009-06-05 18:08:54 +000015
derat@chromium.orge08f4912010-02-17 22:11:37 +000016if [ ! -f "$repo/git-cl" ]; then
17 git clone $url $repo -q
msb@chromium.orgb48f2292010-10-06 19:48:39 +000018elif [ ! -e "$repo/.git" ]; then
19 echo "$0: $repo does not appear to be a git repo"
msb@chromium.orgd065ecc2010-07-13 22:46:06 +000020elif [ "X$DEPOT_TOOLS_UPDATE" != "X0" ]; then
msb@chromium.orgb48f2292010-10-06 19:48:39 +000021 (cd "$repo"; git pull -q)
maruel@chromium.org565db0e2009-06-05 18:08:54 +000022fi
23
derat@chromium.orge08f4912010-02-17 22:11:37 +000024$repo/git-cl "$@"