|
|
|
@ -165,6 +165,32 @@ fi
|
|
|
|
|
#
|
|
|
|
|
# EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
|
|
|
|
|
|
|
|
|
|
# @ECLASS-VARIABLE: EGIT_SUBMODULES
|
|
|
|
|
# @DEFAULT_UNSET
|
|
|
|
|
# @DESCRIPTION:
|
|
|
|
|
# An array of inclusive and exclusive wildcards on submodule names,
|
|
|
|
|
# stating which submodules are fetched and checked out. Exclusions
|
|
|
|
|
# start with '-', and exclude previously matched submodules.
|
|
|
|
|
#
|
|
|
|
|
# If unset, all submodules are enabled. Empty list disables all
|
|
|
|
|
# submodules. In order to use an exclude-only list, start the array
|
|
|
|
|
# with '*'.
|
|
|
|
|
#
|
|
|
|
|
# Remember that wildcards need to be quoted in order to prevent filename
|
|
|
|
|
# expansion.
|
|
|
|
|
#
|
|
|
|
|
# Examples:
|
|
|
|
|
# @CODE
|
|
|
|
|
# # Disable all submodules
|
|
|
|
|
# EGIT_SUBMODULES=()
|
|
|
|
|
#
|
|
|
|
|
# # Include only foo and bar
|
|
|
|
|
# EGIT_SUBMODULES=( foo bar )
|
|
|
|
|
#
|
|
|
|
|
# # Use all submodules except for test-* but include test-lib
|
|
|
|
|
# EGIT_SUBMODULES=( '*' '-test-*' test-lib )
|
|
|
|
|
# @CODE
|
|
|
|
|
|
|
|
|
|
# @FUNCTION: _git-r3_env_setup
|
|
|
|
|
# @INTERNAL
|
|
|
|
|
# @DESCRIPTION:
|
|
|
|
@ -205,21 +231,26 @@ _git-r3_env_setup() {
|
|
|
|
|
die "Invalid EGIT_MIN_CLONE_TYPE=${EGIT_MIN_CLONE_TYPE}"
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]]
|
|
|
|
|
then
|
|
|
|
|
die 'EGIT_SUBMODULES must be an array.'
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local esc_pn livevar
|
|
|
|
|
esc_pn=${PN//[-+]/_}
|
|
|
|
|
|
|
|
|
|
livevar=${esc_pn}_LIVE_REPO
|
|
|
|
|
EGIT_REPO_URI=${!livevar:-${EGIT_REPO_URI}}
|
|
|
|
|
EGIT_REPO_URI=${!livevar-${EGIT_REPO_URI}}
|
|
|
|
|
[[ ${!livevar} ]] \
|
|
|
|
|
&& ewarn "Using ${livevar}, no support will be provided"
|
|
|
|
|
|
|
|
|
|
livevar=${esc_pn}_LIVE_BRANCH
|
|
|
|
|
EGIT_BRANCH=${!livevar:-${EGIT_BRANCH}}
|
|
|
|
|
EGIT_BRANCH=${!livevar-${EGIT_BRANCH}}
|
|
|
|
|
[[ ${!livevar} ]] \
|
|
|
|
|
&& ewarn "Using ${livevar}, no support will be provided"
|
|
|
|
|
|
|
|
|
|
livevar=${esc_pn}_LIVE_COMMIT
|
|
|
|
|
EGIT_COMMIT=${!livevar:-${EGIT_COMMIT}}
|
|
|
|
|
EGIT_COMMIT=${!livevar-${EGIT_COMMIT}}
|
|
|
|
|
[[ ${!livevar} ]] \
|
|
|
|
|
&& ewarn "Using ${livevar}, no support will be provided"
|
|
|
|
|
|
|
|
|
@ -243,7 +274,8 @@ _git-r3_env_setup() {
|
|
|
|
|
if [[ ${EGIT_HAS_SUBMODULES} ]]; then
|
|
|
|
|
eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs"
|
|
|
|
|
eerror "to switch the clone type in order to support submodules and therefore"
|
|
|
|
|
eerror "submodules are detected and fetched automatically."
|
|
|
|
|
eerror "submodules are detected and fetched automatically. If you need to"
|
|
|
|
|
eerror "disable or filter submodules, see EGIT_SUBMODULES."
|
|
|
|
|
die "EGIT_HAS_SUBMODULES is no longer necessary."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -296,7 +328,7 @@ _git-r3_set_gitdir() {
|
|
|
|
|
git/*) repo_name=${repo_name#git/};;
|
|
|
|
|
# gentoo.org
|
|
|
|
|
gitroot/*) repo_name=${repo_name#gitroot/};;
|
|
|
|
|
# google code, sourceforge
|
|
|
|
|
# sourceforge
|
|
|
|
|
p/*) repo_name=${repo_name#p/};;
|
|
|
|
|
# kernel.org
|
|
|
|
|
pub/scm/*) repo_name=${repo_name#pub/scm/};;
|
|
|
|
@ -311,7 +343,7 @@ _git-r3_set_gitdir() {
|
|
|
|
|
|
|
|
|
|
GIT_DIR=${EGIT3_STORE_DIR}/${repo_name}
|
|
|
|
|
|
|
|
|
|
if [[ ! -d ${EGIT3_STORE_DIR} ]]; then
|
|
|
|
|
if [[ ! -d ${EGIT3_STORE_DIR} && ! ${EVCS_OFFLINE} ]]; then
|
|
|
|
|
(
|
|
|
|
|
addwrite /
|
|
|
|
|
mkdir -p "${EGIT3_STORE_DIR}"
|
|
|
|
@ -320,6 +352,14 @@ _git-r3_set_gitdir() {
|
|
|
|
|
|
|
|
|
|
addwrite "${EGIT3_STORE_DIR}"
|
|
|
|
|
if [[ ! -d ${GIT_DIR} ]]; then
|
|
|
|
|
if [[ ${EVCS_OFFLINE} ]]; then
|
|
|
|
|
eerror "A clone of the following repository is required to proceed:"
|
|
|
|
|
eerror " ${1}"
|
|
|
|
|
eerror "However, networking activity has been disabled using EVCS_OFFLINE and there"
|
|
|
|
|
eerror "is no local clone available."
|
|
|
|
|
die "No local clone of ${1}. Unable to proceed with EVCS_OFFLINE."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local saved_umask
|
|
|
|
|
if [[ ${EVCS_UMASK} ]]; then
|
|
|
|
|
saved_umask=$(umask)
|
|
|
|
@ -357,6 +397,26 @@ _git-r3_set_submodules() {
|
|
|
|
|
l=${l#submodule.}
|
|
|
|
|
local subname=${l%%.url=*}
|
|
|
|
|
|
|
|
|
|
# filter out on EGIT_SUBMODULES
|
|
|
|
|
if declare -p EGIT_SUBMODULES &>/dev/null; then
|
|
|
|
|
local p l_res res=
|
|
|
|
|
for p in "${EGIT_SUBMODULES[@]}"; do
|
|
|
|
|
if [[ ${p} == -* ]]; then
|
|
|
|
|
p=${p#-}
|
|
|
|
|
l_res=
|
|
|
|
|
else
|
|
|
|
|
l_res=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[[ ${subname} == ${p} ]] && res=${l_res}
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [[ ! ${res} ]]; then
|
|
|
|
|
einfo "Skipping submodule \e[1m${subname}\e[22m"
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# skip modules that have 'update = none', bug #487262.
|
|
|
|
|
local upd=$(echo "${data}" | git config -f /dev/fd/0 \
|
|
|
|
|
submodule."${subname}".update)
|
|
|
|
@ -434,42 +494,6 @@ _git-r3_is_local_repo() {
|
|
|
|
|
[[ ${uri} == file://* || ${uri} == /* ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# @FUNCTION: _git-r3_find_head
|
|
|
|
|
# @USAGE: <head-ref>
|
|
|
|
|
# @INTERNAL
|
|
|
|
|
# @DESCRIPTION:
|
|
|
|
|
# Given a ref to which remote HEAD was fetched, try to find
|
|
|
|
|
# a branch matching the commit. Expects 'git show-ref'
|
|
|
|
|
# or 'git ls-remote' output on stdin.
|
|
|
|
|
_git-r3_find_head() {
|
|
|
|
|
debug-print-function ${FUNCNAME} "$@"
|
|
|
|
|
|
|
|
|
|
local head_ref=${1}
|
|
|
|
|
local head_hash=$(git rev-parse --verify "${1}" || die)
|
|
|
|
|
local matching_ref
|
|
|
|
|
|
|
|
|
|
# TODO: some transports support peeking at symbolic remote refs
|
|
|
|
|
# find a way to use that rather than guessing
|
|
|
|
|
|
|
|
|
|
# (based on guess_remote_head() in git-1.9.0/remote.c)
|
|
|
|
|
local h ref
|
|
|
|
|
while read h ref; do
|
|
|
|
|
# look for matching head
|
|
|
|
|
if [[ ${h} == ${head_hash} ]]; then
|
|
|
|
|
# either take the first matching ref, or master if it is there
|
|
|
|
|
if [[ ! ${matching_ref} || ${ref} == refs/heads/master ]]; then
|
|
|
|
|
matching_ref=${ref}
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [[ ! ${matching_ref} ]]; then
|
|
|
|
|
die "Unable to find a matching branch for remote HEAD (${head_hash})"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "${matching_ref}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# @FUNCTION: git-r3_fetch
|
|
|
|
|
# @USAGE: [<repo-uri> [<remote-ref> [<local-id>]]]
|
|
|
|
|
# @DESCRIPTION:
|
|
|
|
@ -501,8 +525,6 @@ _git-r3_find_head() {
|
|
|
|
|
git-r3_fetch() {
|
|
|
|
|
debug-print-function ${FUNCNAME} "$@"
|
|
|
|
|
|
|
|
|
|
[[ ${EVCS_OFFLINE} ]] && return
|
|
|
|
|
|
|
|
|
|
local repos
|
|
|
|
|
if [[ ${1} ]]; then
|
|
|
|
|
repos=( ${1} )
|
|
|
|
@ -537,164 +559,143 @@ git-r3_fetch() {
|
|
|
|
|
umask "${EVCS_UMASK}" || die "Bad options to umask: ${EVCS_UMASK}"
|
|
|
|
|
fi
|
|
|
|
|
for r in "${repos[@]}"; do
|
|
|
|
|
einfo "Fetching \e[1m${r}\e[22m ..."
|
|
|
|
|
|
|
|
|
|
local fetch_command=( git fetch "${r}" )
|
|
|
|
|
local clone_type=${EGIT_CLONE_TYPE}
|
|
|
|
|
|
|
|
|
|
if [[ ${r} == https://* ]] && ! ROOT=/ has_version 'dev-vcs/git[curl]'; then
|
|
|
|
|
eerror "git-r3: fetching from https:// requested. In order to support https,"
|
|
|
|
|
eerror "dev-vcs/git needs to be built with USE=curl. Example solution:"
|
|
|
|
|
eerror
|
|
|
|
|
eerror " echo dev-vcs/git curl >> /etc/portage/package.use"
|
|
|
|
|
eerror " emerge -1v dev-vcs/git"
|
|
|
|
|
die "dev-vcs/git built with USE=curl required."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${r} == https://code.google.com/* ]]; then
|
|
|
|
|
# Google Code has special magic on top of git that:
|
|
|
|
|
# 1) can't handle shallow clones at all,
|
|
|
|
|
# 2) fetches duplicately when tags are pulled in with branch
|
|
|
|
|
# so automatically switch to single+tags mode.
|
|
|
|
|
if [[ ${clone_type} == shallow ]]; then
|
|
|
|
|
einfo " Google Code does not support shallow clones"
|
|
|
|
|
einfo " using \e[1mEGIT_CLONE_TYPE=single+tags\e[22m"
|
|
|
|
|
clone_type=single+tags
|
|
|
|
|
elif [[ ${clone_type} == single ]]; then
|
|
|
|
|
einfo " git-r3: Google Code does not send tags properly in 'single' mode"
|
|
|
|
|
einfo " using \e[1mEGIT_CLONE_TYPE=single+tags\e[22m"
|
|
|
|
|
clone_type=single+tags
|
|
|
|
|
if [[ ! ${EVCS_OFFLINE} ]]; then
|
|
|
|
|
einfo "Fetching \e[1m${r}\e[22m ..."
|
|
|
|
|
|
|
|
|
|
local fetch_command=( git fetch "${r}" )
|
|
|
|
|
local clone_type=${EGIT_CLONE_TYPE}
|
|
|
|
|
|
|
|
|
|
if [[ ${r} == https://* ]] && ! ROOT=/ has_version 'dev-vcs/git[curl]'; then
|
|
|
|
|
eerror "git-r3: fetching from https:// requested. In order to support https,"
|
|
|
|
|
eerror "dev-vcs/git needs to be built with USE=curl. Example solution:"
|
|
|
|
|
eerror
|
|
|
|
|
eerror " echo dev-vcs/git curl >> /etc/portage/package.use"
|
|
|
|
|
eerror " emerge -1v dev-vcs/git"
|
|
|
|
|
die "dev-vcs/git built with USE=curl required."
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${clone_type} == mirror ]]; then
|
|
|
|
|
fetch_command+=(
|
|
|
|
|
--prune
|
|
|
|
|
# mirror the remote branches as local branches
|
|
|
|
|
"+refs/heads/*:refs/heads/*"
|
|
|
|
|
# pull tags explicitly in order to prune them properly
|
|
|
|
|
"+refs/tags/*:refs/tags/*"
|
|
|
|
|
# notes in case something needs them
|
|
|
|
|
"+refs/notes/*:refs/notes/*"
|
|
|
|
|
# and HEAD in case we need the default branch
|
|
|
|
|
# (we keep it in refs/git-r3 since otherwise --prune interferes)
|
|
|
|
|
"+HEAD:refs/git-r3/HEAD"
|
|
|
|
|
)
|
|
|
|
|
else # single or shallow
|
|
|
|
|
local fetch_l fetch_r
|
|
|
|
|
|
|
|
|
|
if [[ ${remote_ref} == HEAD ]]; then
|
|
|
|
|
# HEAD
|
|
|
|
|
fetch_l=HEAD
|
|
|
|
|
elif [[ ${remote_ref} == refs/* ]]; then
|
|
|
|
|
# regular branch, tag or some other explicit ref
|
|
|
|
|
fetch_l=${remote_ref}
|
|
|
|
|
else
|
|
|
|
|
# tag or commit id...
|
|
|
|
|
# let ls-remote figure it out
|
|
|
|
|
local tagref=$(git ls-remote "${r}" "refs/tags/${remote_ref}")
|
|
|
|
|
|
|
|
|
|
# if it was a tag, ls-remote obtained a hash
|
|
|
|
|
if [[ ${tagref} ]]; then
|
|
|
|
|
# tag
|
|
|
|
|
fetch_l=refs/tags/${remote_ref}
|
|
|
|
|
if [[ ${clone_type} == mirror ]]; then
|
|
|
|
|
fetch_command+=(
|
|
|
|
|
--prune
|
|
|
|
|
# mirror the remote branches as local branches
|
|
|
|
|
"+refs/heads/*:refs/heads/*"
|
|
|
|
|
# pull tags explicitly in order to prune them properly
|
|
|
|
|
"+refs/tags/*:refs/tags/*"
|
|
|
|
|
# notes in case something needs them
|
|
|
|
|
"+refs/notes/*:refs/notes/*"
|
|
|
|
|
# and HEAD in case we need the default branch
|
|
|
|
|
# (we keep it in refs/git-r3 since otherwise --prune interferes)
|
|
|
|
|
"+HEAD:refs/git-r3/HEAD"
|
|
|
|
|
)
|
|
|
|
|
else # single or shallow
|
|
|
|
|
local fetch_l fetch_r
|
|
|
|
|
|
|
|
|
|
if [[ ${remote_ref} == HEAD ]]; then
|
|
|
|
|
# HEAD
|
|
|
|
|
fetch_l=HEAD
|
|
|
|
|
elif [[ ${remote_ref} == refs/* ]]; then
|
|
|
|
|
# regular branch, tag or some other explicit ref
|
|
|
|
|
fetch_l=${remote_ref}
|
|
|
|
|
else
|
|
|
|
|
# commit id
|
|
|
|
|
# so we need to fetch the whole branch
|
|
|
|
|
if [[ ${branch} ]]; then
|
|
|
|
|
fetch_l=${branch}
|
|
|
|
|
# tag or commit id...
|
|
|
|
|
# let ls-remote figure it out
|
|
|
|
|
local tagref=$(git ls-remote "${r}" "refs/tags/${remote_ref}")
|
|
|
|
|
|
|
|
|
|
# if it was a tag, ls-remote obtained a hash
|
|
|
|
|
if [[ ${tagref} ]]; then
|
|
|
|
|
# tag
|
|
|
|
|
fetch_l=refs/tags/${remote_ref}
|
|
|
|
|
else
|
|
|
|
|
fetch_l=HEAD
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# fetching by commit in shallow mode? can't do.
|
|
|
|
|
if [[ ${clone_type} == shallow ]]; then
|
|
|
|
|
clone_type=single
|
|
|
|
|
# commit id
|
|
|
|
|
# so we need to fetch the whole branch
|
|
|
|
|
if [[ ${branch} ]]; then
|
|
|
|
|
fetch_l=${branch}
|
|
|
|
|
else
|
|
|
|
|
fetch_l=HEAD
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# fetching by commit in shallow mode? can't do.
|
|
|
|
|
if [[ ${clone_type} == shallow ]]; then
|
|
|
|
|
clone_type=single
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${fetch_l} == HEAD ]]; then
|
|
|
|
|
fetch_r=refs/git-r3/HEAD
|
|
|
|
|
else
|
|
|
|
|
fetch_r=${fetch_l}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
fetch_command+=(
|
|
|
|
|
"+${fetch_l}:${fetch_r}"
|
|
|
|
|
)
|
|
|
|
|
if [[ ${fetch_l} == HEAD ]]; then
|
|
|
|
|
fetch_r=refs/git-r3/HEAD
|
|
|
|
|
else
|
|
|
|
|
fetch_r=${fetch_l}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${clone_type} == single+tags ]]; then
|
|
|
|
|
fetch_command+=(
|
|
|
|
|
# pull tags explicitly as requested
|
|
|
|
|
"+refs/tags/*:refs/tags/*"
|
|
|
|
|
"+${fetch_l}:${fetch_r}"
|
|
|
|
|
)
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${clone_type} == shallow ]]; then
|
|
|
|
|
if _git-r3_is_local_repo; then
|
|
|
|
|
# '--depth 1' causes sandbox violations with local repos
|
|
|
|
|
# bug #491260
|
|
|
|
|
clone_type=single
|
|
|
|
|
elif [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]]
|
|
|
|
|
then
|
|
|
|
|
# use '--depth 1' when fetching a new branch
|
|
|
|
|
fetch_command+=( --depth 1 )
|
|
|
|
|
fi
|
|
|
|
|
else # non-shallow mode
|
|
|
|
|
if [[ -f ${GIT_DIR}/shallow ]]; then
|
|
|
|
|
fetch_command+=( --unshallow )
|
|
|
|
|
if [[ ${clone_type} == single+tags ]]; then
|
|
|
|
|
fetch_command+=(
|
|
|
|
|
# pull tags explicitly as requested
|
|
|
|
|
"+refs/tags/*:refs/tags/*"
|
|
|
|
|
)
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
set -- "${fetch_command[@]}"
|
|
|
|
|
echo "${@}" >&2
|
|
|
|
|
if "${@}"; then
|
|
|
|
|
if [[ ${clone_type} == mirror ]]; then
|
|
|
|
|
# find remote HEAD and update our HEAD properly
|
|
|
|
|
git symbolic-ref HEAD \
|
|
|
|
|
"$(_git-r3_find_head refs/git-r3/HEAD \
|
|
|
|
|
< <(git show-ref --heads || die))" \
|
|
|
|
|
|| die "Unable to update HEAD"
|
|
|
|
|
else # single or shallow
|
|
|
|
|
if [[ ${fetch_l} == HEAD ]]; then
|
|
|
|
|
# find out what branch we fetched as HEAD
|
|
|
|
|
local head_branch=$(_git-r3_find_head \
|
|
|
|
|
refs/git-r3/HEAD \
|
|
|
|
|
< <(git ls-remote --heads "${r}" || die))
|
|
|
|
|
|
|
|
|
|
# and move it to its regular place
|
|
|
|
|
git update-ref --no-deref "${head_branch}" \
|
|
|
|
|
refs/git-r3/HEAD \
|
|
|
|
|
|| die "Unable to sync HEAD branch ${head_branch}"
|
|
|
|
|
git symbolic-ref HEAD "${head_branch}" \
|
|
|
|
|
|| die "Unable to update HEAD"
|
|
|
|
|
if [[ ${clone_type} == shallow ]]; then
|
|
|
|
|
if _git-r3_is_local_repo; then
|
|
|
|
|
# '--depth 1' causes sandbox violations with local repos
|
|
|
|
|
# bug #491260
|
|
|
|
|
clone_type=single
|
|
|
|
|
elif [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]]
|
|
|
|
|
then
|
|
|
|
|
# use '--depth 1' when fetching a new branch
|
|
|
|
|
fetch_command+=( --depth 1 )
|
|
|
|
|
fi
|
|
|
|
|
else # non-shallow mode
|
|
|
|
|
if [[ -f ${GIT_DIR}/shallow ]]; then
|
|
|
|
|
fetch_command+=( --unshallow )
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# now let's see what the user wants from us
|
|
|
|
|
local full_remote_ref=$(
|
|
|
|
|
git rev-parse --verify --symbolic-full-name "${remote_ref}"
|
|
|
|
|
)
|
|
|
|
|
set -- "${fetch_command[@]}"
|
|
|
|
|
echo "${@}" >&2
|
|
|
|
|
"${@}" || continue
|
|
|
|
|
|
|
|
|
|
if [[ ${full_remote_ref} ]]; then
|
|
|
|
|
# when we are given a ref, create a symbolic ref
|
|
|
|
|
# so that we preserve the actual argument
|
|
|
|
|
set -- git symbolic-ref "${local_ref}" "${full_remote_ref}"
|
|
|
|
|
else
|
|
|
|
|
# otherwise, we were likely given a commit id
|
|
|
|
|
set -- git update-ref --no-deref "${local_ref}" "${remote_ref}"
|
|
|
|
|
if [[ ${clone_type} == mirror || ${fetch_l} == HEAD ]]; then
|
|
|
|
|
# update our HEAD to match our remote HEAD ref
|
|
|
|
|
git symbolic-ref HEAD refs/git-r3/HEAD \
|
|
|
|
|
|| die "Unable to update HEAD"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "${@}" >&2
|
|
|
|
|
if ! "${@}"; then
|
|
|
|
|
# now let's see what the user wants from us
|
|
|
|
|
local full_remote_ref=$(
|
|
|
|
|
git rev-parse --verify --symbolic-full-name "${remote_ref}"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if [[ ${full_remote_ref} ]]; then
|
|
|
|
|
# when we are given a ref, create a symbolic ref
|
|
|
|
|
# so that we preserve the actual argument
|
|
|
|
|
set -- git symbolic-ref "${local_ref}" "${full_remote_ref}"
|
|
|
|
|
else
|
|
|
|
|
# otherwise, we were likely given a commit id
|
|
|
|
|
set -- git update-ref --no-deref "${local_ref}" "${remote_ref}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "${@}" >&2
|
|
|
|
|
if ! "${@}"; then
|
|
|
|
|
if [[ ${EVCS_OFFLINE} ]]; then
|
|
|
|
|
eerror "A clone of the following repository is required to proceed:"
|
|
|
|
|
eerror " ${r}"
|
|
|
|
|
eerror "However, networking activity has been disabled using EVCS_OFFLINE and the local"
|
|
|
|
|
eerror "clone does not have requested ref:"
|
|
|
|
|
eerror " ${remote_ref}"
|
|
|
|
|
die "Local clone of ${r} does not have requested ref: ${remote_ref}. Unable to proceed with EVCS_OFFLINE."
|
|
|
|
|
else
|
|
|
|
|
die "Referencing ${remote_ref} failed (wrong ref?)."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
success=1
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
success=1
|
|
|
|
|
break
|
|
|
|
|
done
|
|
|
|
|
if [[ ${saved_umask} ]]; then
|
|
|
|
|
umask "${saved_umask}" || die
|
|
|
|
@ -779,11 +780,7 @@ git-r3_checkout() {
|
|
|
|
|
einfo "Checking out \e[1m${repos[0]}\e[22m to \e[1m${out_dir}\e[22m ..."
|
|
|
|
|
|
|
|
|
|
if ! git cat-file -e refs/git-r3/"${local_id}"/__main__; then
|
|
|
|
|
if [[ ${EVCS_OFFLINE} ]]; then
|
|
|
|
|
die "No local clone of ${repos[0]}. Unable to work with EVCS_OFFLINE."
|
|
|
|
|
else
|
|
|
|
|
die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?"
|
|
|
|
|
fi
|
|
|
|
|
die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?"
|
|
|
|
|
fi
|
|
|
|
|
local remote_ref=$(
|
|
|
|
|
git symbolic-ref --quiet refs/git-r3/"${local_id}"/__main__
|
|
|
|
@ -806,9 +803,7 @@ git-r3_checkout() {
|
|
|
|
|
# setup 'alternates' to avoid copying objects
|
|
|
|
|
echo "${orig_repo}/objects" > "${GIT_DIR}"/objects/info/alternates || die
|
|
|
|
|
# now copy the refs
|
|
|
|
|
# [htn]* safely catches heads, tags, notes without complaining
|
|
|
|
|
# on non-existing ones, and omits internal 'git-r3' ref
|
|
|
|
|
cp -R "${orig_repo}"/refs/[htn]* "${GIT_DIR}"/refs/ || die
|
|
|
|
|
cp -R "${orig_repo}"/refs/* "${GIT_DIR}"/refs/ || die
|
|
|
|
|
|
|
|
|
|
# (no need to copy HEAD, we will set it via checkout)
|
|
|
|
|
|
|
|
|
|