Commit 01e87675 by Yamashita Yuu

Fix `fetch_git` with `--keep`

Update existing git repo if exists, or clone if not exists.
The destination repo might exist if the `--keep` was supplied for `ruby-build`.
parent 9b7679ad
...@@ -357,9 +357,9 @@ fetch_git() { ...@@ -357,9 +357,9 @@ fetch_git() {
pushd "$RUBY_BUILD_CACHE_PATH" >&4 pushd "$RUBY_BUILD_CACHE_PATH" >&4
local clone_name="$(sanitize "$git_url")" local clone_name="$(sanitize "$git_url")"
if [ -e "${clone_name}" ]; then if [ -e "${clone_name}" ]; then
{ cd "${clone_name}" ( cd "${clone_name}"
git fetch --force "$git_url" "+${git_ref}:${git_ref}" git fetch --force "$git_url" "+${git_ref}:${git_ref}"
} >&4 2>&1 ) >&4 2>&1
else else
git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1 git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1
fi fi
...@@ -367,7 +367,13 @@ fetch_git() { ...@@ -367,7 +367,13 @@ fetch_git() {
popd >&4 popd >&4
fi fi
git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1 if [ -e "${package_name}" ]; then
( cd "${package_name}"
git fetch --force --update-head-ok "$git_url" "+${git_ref}:${git_ref}"
) >&4 2>&1
else
git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1
fi
else else
echo "error: please install \`git\` and try again" >&2 echo "error: please install \`git\` and try again" >&2
exit 1 exit 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment