Lines 410-462
git-r3_checkout() {
Link Here
|
410 |
local out_dir=${2:-${EGIT_CHECKOUT_DIR:-${WORKDIR}/${P}}} |
410 |
local out_dir=${2:-${EGIT_CHECKOUT_DIR:-${WORKDIR}/${P}}} |
411 |
local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}} |
411 |
local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}} |
412 |
|
412 |
|
413 |
local -x GIT_DIR GIT_WORK_TREE |
413 |
local -x GIT_DIR |
414 |
_git-r3_set_gitdir "${repos[0]}" |
414 |
_git-r3_set_gitdir "${repos[0]}" |
415 |
GIT_WORK_TREE=${out_dir} |
|
|
416 |
mkdir -p "${GIT_WORK_TREE}" || die |
417 |
|
415 |
|
418 |
einfo "Checking out ${repos[0]} to ${out_dir} ..." |
416 |
einfo "Checking out ${repos[0]} to ${out_dir} ..." |
419 |
|
417 |
|
420 |
if ! git cat-file -e refs/git-r3/"${local_id}"/__main__ |
418 |
if ! git cat-file -e refs/git-r3/"${local_id}"/__main__; then |
421 |
then |
|
|
422 |
if [[ ${EVCS_OFFLINE} ]]; then |
419 |
if [[ ${EVCS_OFFLINE} ]]; then |
423 |
die "No local clone of ${repos[0]}. Unable to work with EVCS_OFFLINE." |
420 |
die "No local clone of ${repos[0]}. Unable to work with EVCS_OFFLINE." |
424 |
else |
421 |
else |
425 |
die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?" |
422 |
die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?" |
426 |
fi |
423 |
fi |
427 |
fi |
424 |
fi |
|
|
425 |
local new_commit_id=$( |
426 |
git rev-parse --verify refs/git-r3/"${local_id}"/__main__ |
427 |
) |
428 |
|
428 |
|
429 |
# Note: this is a hack to avoid parallel checkout issues. |
429 |
set -- git clone --shared --no-checkout "${GIT_DIR}" "${out_dir}"/ |
430 |
# I will try to handle it without locks when I have more time. |
|
|
431 |
local lockfile=${GIT_DIR}/.git-r3_checkout_lock |
432 |
local lockfile_l=${lockfile}.${BASHPID} |
433 |
touch "${lockfile_l}" || die |
434 |
until ln "${lockfile_l}" "${lockfile}" &>/dev/null; do |
435 |
sleep 1 |
436 |
done |
437 |
rm "${lockfile_l}" || die |
438 |
|
439 |
set -- git checkout -f refs/git-r3/"${local_id}"/__main__ . |
440 |
echo "${@}" >&2 |
430 |
echo "${@}" >&2 |
441 |
"${@}" |
431 |
"${@}" || die "git clone (for checkout) failed" |
442 |
local ret=${?} |
|
|
443 |
|
444 |
# Remove the lock! |
445 |
rm "${lockfile}" || die |
446 |
|
432 |
|
447 |
[[ ${ret} == 0 ]] || die "git checkout refs/git-r3/${local_id}/__main__ failed" |
433 |
git-r3_sub_checkout() { |
|
|
434 |
local -x GIT_DIR=${out_dir}/.git |
435 |
local -x GIT_WORK_TREE=${out_dir} |
448 |
|
436 |
|
449 |
# diff against previous revision (if any) |
437 |
set -- git checkout --quiet "${new_commit_id}" |
450 |
local new_commit_id=$(git rev-parse --verify refs/git-r3/"${local_id}"/__main__) |
438 |
echo "${@}" >&2 |
451 |
local old_commit_id=$( |
439 |
"${@}" || die "git checkout ${new_commit_id} failed" |
452 |
git rev-parse --verify refs/git-r3/"${local_id}"/__old__ 2>/dev/null |
440 |
} |
453 |
) |
441 |
git-r3_sub_checkout |
454 |
|
442 |
|
455 |
if [[ ! ${old_commit_id} ]]; then |
443 |
if ! git cat-file -e refs/git-r3/"${local_id}"/__old__; then |
456 |
echo "GIT NEW branch -->" |
444 |
echo "GIT NEW branch -->" |
457 |
echo " repository: ${repos[0]}" |
445 |
echo " repository: ${repos[0]}" |
458 |
echo " at the commit: ${new_commit_id}" |
446 |
echo " at the commit: ${new_commit_id}" |
459 |
else |
447 |
else |
|
|
448 |
# diff against previous revision |
449 |
local old_commit_id=$( |
450 |
git rev-parse --verify refs/git-r3/"${local_id}"/__old__ 2>/dev/null |
451 |
) |
452 |
|
460 |
echo "GIT update -->" |
453 |
echo "GIT update -->" |
461 |
echo " repository: ${repos[0]}" |
454 |
echo " repository: ${repos[0]}" |
462 |
# write out message based on the revisions |
455 |
# write out message based on the revisions |
Lines 473-482
git-r3_checkout() {
Link Here
|
473 |
git update-ref refs/git-r3/"${local_id}"/{__old__,__main__} || die |
466 |
git update-ref refs/git-r3/"${local_id}"/{__old__,__main__} || die |
474 |
|
467 |
|
475 |
# recursively checkout submodules |
468 |
# recursively checkout submodules |
476 |
if [[ -f ${GIT_WORK_TREE}/.gitmodules ]]; then |
469 |
if [[ -f ${out_dir}/.gitmodules ]]; then |
477 |
local submodules |
470 |
local submodules |
478 |
_git-r3_set_submodules \ |
471 |
_git-r3_set_submodules \ |
479 |
"$(<"${GIT_WORK_TREE}"/.gitmodules)" |
472 |
"$(<"${out_dir}"/.gitmodules)" |
480 |
|
473 |
|
481 |
while [[ ${submodules[@]} ]]; do |
474 |
while [[ ${submodules[@]} ]]; do |
482 |
local subname=${submodules[0]} |
475 |
local subname=${submodules[0]} |
Lines 487-493
git-r3_checkout() {
Link Here
|
487 |
url=${repos[0]%%/}/${url} |
480 |
url=${repos[0]%%/}/${url} |
488 |
fi |
481 |
fi |
489 |
|
482 |
|
490 |
git-r3_checkout "${url}" "${GIT_WORK_TREE}/${path}" \ |
483 |
git-r3_checkout "${url}" "${out_dir}/${path}" \ |
491 |
"${local_id}/${subname}" |
484 |
"${local_id}/${subname}" |
492 |
|
485 |
|
493 |
submodules=( "${submodules[@]:3}" ) # shift |
486 |
submodules=( "${submodules[@]:3}" ) # shift |
Lines 497-507
git-r3_checkout() {
Link Here
|
497 |
# keep this *after* submodules |
490 |
# keep this *after* submodules |
498 |
export EGIT_DIR=${GIT_DIR} |
491 |
export EGIT_DIR=${GIT_DIR} |
499 |
export EGIT_VERSION=${new_commit_id} |
492 |
export EGIT_VERSION=${new_commit_id} |
500 |
|
|
|
501 |
# create a fake '.git' directory to satisfy 'git rev-parse HEAD' |
502 |
GIT_DIR=${GIT_WORK_TREE}/.git |
503 |
git init || die |
504 |
echo "${EGIT_VERSION}" > "${GIT_WORK_TREE}"/.git/HEAD || die |
505 |
} |
493 |
} |
506 |
|
494 |
|
507 |
# @FUNCTION: git-r3_peek_remote_ref |
495 |
# @FUNCTION: git-r3_peek_remote_ref |
508 |
- |
|
|