#!/bin/sh
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

base_dir=$(dirname "$0")
url="http://src.chromium.org/git/git-cl.git"
cur_url=$(git config -f "$base_dir/git-cl-repo/.git/config" remote.origin.url)

if [ "$cur_url" != "$url" ]; then
  cat <<EOF
$base_dir/git-cl-repo
is tracking a non-default remote repository:

  default: $url
  yours:   $cur_url

This is intended to be an automatically-updating, read-only repository.
Please create a separate repository for making changes to git-cl, move your
modifications there, and then run:
  rm -rf $base_dir/git-cl-repo
EOF
  exit 1
fi

if [ ! -f "$base_dir/git-cl-repo/git-cl" ]; then
  git clone $url $base_dir/git-cl-repo -q
fi

$base_dir/git-cl-repo/git-cl "$@"
