Lines 322-328
git-r3_fetch() {
Link Here
|
322 |
# try to fetch from the remote |
322 |
# try to fetch from the remote |
323 |
local r success |
323 |
local r success |
324 |
for r in "${repos[@]}"; do |
324 |
for r in "${repos[@]}"; do |
325 |
einfo "Fetching ${remote_ref} from ${r} ..." |
325 |
einfo "Fetching ${r} ..." |
326 |
|
326 |
|
327 |
local fetch_command=( |
327 |
local fetch_command=( |
328 |
git fetch --prune "${r}" |
328 |
git fetch --prune "${r}" |
Lines 335-341
git-r3_fetch() {
Link Here
|
335 |
set -- "${fetch_command[@]}" |
335 |
set -- "${fetch_command[@]}" |
336 |
echo "${@}" >&2 |
336 |
echo "${@}" >&2 |
337 |
if "${@}"; then |
337 |
if "${@}"; then |
338 |
set -- git update-ref "${local_ref}" "${remote_ref}" |
338 |
# now let's see what the user wants from us |
|
|
339 |
local full_remote_ref=$( |
340 |
git rev-parse --verify --symbolic-full-name "${remote_ref}" |
341 |
) |
342 |
|
343 |
if [[ ${full_remote_ref} ]]; then |
344 |
# when we are given a ref, create a symbolic ref |
345 |
# so that we preserve the actual argument |
346 |
set -- git symbolic-ref "${local_ref}" "${full_remote_ref}" |
347 |
else |
348 |
# otherwise, we were likely given a commit id |
349 |
set -- git update-ref --no-deref "${local_ref}" "${remote_ref}" |
350 |
fi |
351 |
|
339 |
echo "${@}" >&2 |
352 |
echo "${@}" >&2 |
340 |
if ! "${@}"; then |
353 |
if ! "${@}"; then |
341 |
die "Referencing ${remote_ref} failed (wrong ref?)." |
354 |
die "Referencing ${remote_ref} failed (wrong ref?)." |
Lines 422-427
git-r3_checkout() {
Link Here
|
422 |
die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?" |
435 |
die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?" |
423 |
fi |
436 |
fi |
424 |
fi |
437 |
fi |
|
|
438 |
local remote_ref=$( |
439 |
git symbolic-ref --quiet refs/git-r3/"${local_id}"/__main__ |
440 |
) |
425 |
local new_commit_id=$( |
441 |
local new_commit_id=$( |
426 |
git rev-parse --verify refs/git-r3/"${local_id}"/__main__ |
442 |
git rev-parse --verify refs/git-r3/"${local_id}"/__main__ |
427 |
) |
443 |
) |
Lines 434-442
git-r3_checkout() {
Link Here
|
434 |
local -x GIT_DIR=${out_dir}/.git |
450 |
local -x GIT_DIR=${out_dir}/.git |
435 |
local -x GIT_WORK_TREE=${out_dir} |
451 |
local -x GIT_WORK_TREE=${out_dir} |
436 |
|
452 |
|
437 |
set -- git checkout --quiet "${new_commit_id}" |
453 |
set -- git checkout --quiet |
|
|
454 |
if [[ ${remote_ref} ]]; then |
455 |
set -- "${@}" "${remote_ref#refs/heads/}" |
456 |
else |
457 |
set -- "${@}" "${new_commit_id}" |
458 |
fi |
438 |
echo "${@}" >&2 |
459 |
echo "${@}" >&2 |
439 |
"${@}" || die "git checkout ${new_commit_id} failed" |
460 |
"${@}" || die "git checkout ${remote_ref:-${new_commit_id}} failed" |
440 |
} |
461 |
} |
441 |
git-r3_sub_checkout |
462 |
git-r3_sub_checkout |
442 |
|
463 |
|
Lines 463-469
git-r3_checkout() {
Link Here
|
463 |
echo " at the commit: ${new_commit_id}" |
484 |
echo " at the commit: ${new_commit_id}" |
464 |
fi |
485 |
fi |
465 |
fi |
486 |
fi |
466 |
git update-ref refs/git-r3/"${local_id}"/{__old__,__main__} || die |
487 |
git update-ref --no-deref refs/git-r3/"${local_id}"/{__old__,__main__} || die |
467 |
|
488 |
|
468 |
# recursively checkout submodules |
489 |
# recursively checkout submodules |
469 |
if [[ -f ${out_dir}/.gitmodules ]]; then |
490 |
if [[ -f ${out_dir}/.gitmodules ]]; then |
470 |
- |
|
|