2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 local help="Usage: gitget [--help] [REPO_URL] [REPO_DIR]
18 Idempotent git clone/pull
21 Without arguments, just git pull.
22 REPO_DIR is, or will become the root of the repo."
24 if [[ $1 == --help ]]; then
28 if (( $# >= 3 )); then
29 echo error
: expected
2 or
less arguments
, got
$#
33 if [[ $# == 0 ]]; then
41 if [[ $1 == *[^
/].git
]]; then
46 workingdir
="${workingdir%.git}"
48 elif (( $# == 2 )); then
49 echo error
: 2 arguments given but the first does not end
in .git
54 if [[ ! -d $workingdir/.git
]]; then
55 echo "error: expected $workingdir/.git to exist"
59 [[ -d $workingdir ]] || mkdir
-p "$workingdir"
61 if [[ -d .git
]]; then