From c1e29395fce81f4a1385ed5a820a2c7773ff8a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 21 Feb 2014 00:11:04 +0100 Subject: [PATCH 2/3] Use dedicated refs rather than branches for eclass data. --- eclass/git-r3.eclass | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass index 487b77b..fb75cff 100644 --- a/eclass/git-r3.eclass +++ b/eclass/git-r3.eclass @@ -312,7 +312,7 @@ git-r3_fetch() { local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}} local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}} local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}} - local local_ref=refs/heads/${local_id}/__main__ + local local_ref=refs/git-r3/${local_id}/__main__ [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset" @@ -324,17 +324,6 @@ git-r3_fetch() { for r in "${repos[@]}"; do einfo "Fetching ${remote_ref} from ${r} ..." - local lookup_ref - if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]] - then - is_branch=1 - lookup_ref=${remote_ref} - else - # ls-remote by commit is going to fail anyway, - # so we may as well pass refs/tags/ABCDEF... - lookup_ref=refs/tags/${remote_ref} - fi - local fetch_command=( git fetch --prune "${r}" # mirror the remote branches as local branches @@ -346,11 +335,10 @@ git-r3_fetch() { set -- "${fetch_command[@]}" echo "${@}" >&2 if "${@}"; then - set -- git branch -f "${local_id}/__main__" \ - "${ref[0]:-${remote_ref}}" + set -- git update-ref "${local_ref}" "${remote_ref}" echo "${@}" >&2 if ! "${@}"; then - die "Creating branch for ${remote_ref} failed (wrong ref?)." + die "Referencing ${remote_ref} failed (wrong ref?)." fi success=1 @@ -429,7 +417,7 @@ git-r3_checkout() { einfo "Checking out ${repos[0]} to ${out_dir} ..." - if ! git cat-file -e refs/heads/"${local_id}"/__main__ + 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." @@ -448,7 +436,7 @@ git-r3_checkout() { done rm "${lockfile_l}" || die - set -- git checkout -f "${local_id}"/__main__ . + set -- git checkout -f refs/git-r3/"${local_id}"/__main__ . echo "${@}" >&2 "${@}" local ret=${?} @@ -456,12 +444,12 @@ git-r3_checkout() { # Remove the lock! rm "${lockfile}" || die - [[ ${ret} == 0 ]] || die "git checkout ${local_id}/__main__ failed" + [[ ${ret} == 0 ]] || die "git checkout refs/git-r3/${local_id}/__main__ failed" # diff against previous revision (if any) - local new_commit_id=$(git rev-parse --verify "${local_id}"/__main__) + local new_commit_id=$(git rev-parse --verify refs/git-r3/"${local_id}"/__main__) local old_commit_id=$( - git rev-parse --verify "${local_id}"/__old__ 2>/dev/null + git rev-parse --verify refs/git-r3/"${local_id}"/__old__ 2>/dev/null ) if [[ ! ${old_commit_id} ]]; then @@ -482,7 +470,7 @@ git-r3_checkout() { echo " at the commit: ${new_commit_id}" fi fi - git branch -f "${local_id}"/{__old__,__main__} || die + git update-ref refs/git-r3/"${local_id}"/{__old__,__main__} || die # recursively checkout submodules if [[ -f ${GIT_WORK_TREE}/.gitmodules ]]; then -- 1.9.0