blob: 5730c3ab8a2524c25cd5635b515adcdfeaa5a4b4 [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
msb@chromium.org2a949042010-10-18 18:04:01 +000011"$base_dir"/update_depot_tools
12
derat@chromium.orge08f4912010-02-17 22:11:37 +000013if [ -e "$repo" -a "$cur_url" != "$url" ]; then
maruel@chromium.org37801da2010-10-18 13:54:08 +000014 # Always override "origin"
15 (cd "$repo"; git remote set-url origin $url)
msb@chromium.orgdffe4942009-11-18 02:25:16 +000016fi
maruel@chromium.org565db0e2009-06-05 18:08:54 +000017
derat@chromium.orge08f4912010-02-17 22:11:37 +000018if [ ! -f "$repo/git-cl" ]; then
19 git clone $url $repo -q
msb@chromium.orgb48f2292010-10-06 19:48:39 +000020elif [ ! -e "$repo/.git" ]; then
21 echo "$0: $repo does not appear to be a git repo"
msb@chromium.orgd065ecc2010-07-13 22:46:06 +000022elif [ "X$DEPOT_TOOLS_UPDATE" != "X0" ]; then
msb@chromium.orgb48f2292010-10-06 19:48:39 +000023 (cd "$repo"; git pull -q)
maruel@chromium.org565db0e2009-06-05 18:08:54 +000024fi
25
derat@chromium.orge08f4912010-02-17 22:11:37 +000026$repo/git-cl "$@"