/[gentoo-x86]/eclass/git-r3.eclass
Gentoo

Diff of /eclass/git-r3.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.40 Revision 1.41
1# Copyright 1999-2014 Gentoo Foundation 1# Copyright 1999-2014 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.40 2014/03/24 21:32:31 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.41 2014/04/17 20:28:37 mgorny Exp $
4 4
5# @ECLASS: git-r3.eclass 5# @ECLASS: git-r3.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Michał Górny <mgorny@gentoo.org> 7# Michał Górny <mgorny@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 8# @BLURB: Eclass for fetching and unpacking git repositories.
466 local r success 466 local r success
467 for r in "${repos[@]}"; do 467 for r in "${repos[@]}"; do
468 einfo "Fetching ${r} ..." 468 einfo "Fetching ${r} ..."
469 469
470 local fetch_command=( git fetch "${r}" ) 470 local fetch_command=( git fetch "${r}" )
471 local clone_type=${EGIT_CLONE_TYPE}
471 472
472 if [[ ${EGIT_CLONE_TYPE} == mirror ]]; then 473 if [[ ${r} == https://code.google.com/* ]]; then
474 # Google Code has special magic on top of git that:
475 # 1) can't handle shallow clones at all,
476 # 2) fetches duplicately when tags are pulled in with branch
477 # so automatically switch to single+tags mode.
478 if [[ ${clone_type} == shallow ]]; then
479 einfo " Google Code does not support shallow clones"
480 einfo " using EGIT_CLONE_TYPE=single+tags"
481 clone_type=single+tags
482 elif [[ ${clone_type} == single ]]; then
483 einfo " git-r3: Google Code does not send tags properly in 'single' mode"
484 einfo " using EGIT_CLONE_TYPE=single+tags"
485 clone_type=single+tags
486 fi
487 fi
488
489 if [[ ${clone_type} == mirror ]]; then
473 fetch_command+=( 490 fetch_command+=(
474 --prune 491 --prune
475 # mirror the remote branches as local branches 492 # mirror the remote branches as local branches
476 "+refs/heads/*:refs/heads/*" 493 "+refs/heads/*:refs/heads/*"
477 # pull tags explicitly in order to prune them properly 494 # pull tags explicitly in order to prune them properly
508 else 525 else
509 fetch_l=HEAD 526 fetch_l=HEAD
510 fi 527 fi
511 528
512 # fetching by commit in shallow mode? can't do. 529 # fetching by commit in shallow mode? can't do.
513 if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then 530 if [[ ${clone_type} == shallow ]]; then
514 local EGIT_CLONE_TYPE=single 531 clone_type=single
515 fi 532 fi
516 fi 533 fi
517 fi 534 fi
518 535
519 if [[ ${fetch_l} == HEAD ]]; then 536 if [[ ${fetch_l} == HEAD ]]; then
524 541
525 fetch_command+=( 542 fetch_command+=(
526 "+${fetch_l}:${fetch_r}" 543 "+${fetch_l}:${fetch_r}"
527 ) 544 )
528 545
529 if [[ ${EGIT_CLONE_TYPE} == single+tags ]]; then 546 if [[ ${clone_type} == single+tags ]]; then
530 fetch_command+=( 547 fetch_command+=(
531 # pull tags explicitly as requested 548 # pull tags explicitly as requested
532 "+refs/tags/*:refs/tags/*" 549 "+refs/tags/*:refs/tags/*"
533 ) 550 )
534 fi 551 fi
535 fi 552 fi
536 553
537 if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then 554 if [[ ${clone_type} == shallow ]]; then
538 if _git-r3_is_local_repo; then 555 if _git-r3_is_local_repo; then
539 # '--depth 1' causes sandbox violations with local repos 556 # '--depth 1' causes sandbox violations with local repos
540 # bug #491260 557 # bug #491260
541 local EGIT_CLONE_TYPE=single 558 clone_type=single
542 elif [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]] 559 elif [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]]
543 then 560 then
544 # use '--depth 1' when fetching a new branch 561 # use '--depth 1' when fetching a new branch
545 fetch_command+=( --depth 1 ) 562 fetch_command+=( --depth 1 )
546 fi 563 fi
551 fi 568 fi
552 569
553 set -- "${fetch_command[@]}" 570 set -- "${fetch_command[@]}"
554 echo "${@}" >&2 571 echo "${@}" >&2
555 if "${@}"; then 572 if "${@}"; then
556 if [[ ${EGIT_CLONE_TYPE} == mirror ]]; then 573 if [[ ${clone_type} == mirror ]]; then
557 # find remote HEAD and update our HEAD properly 574 # find remote HEAD and update our HEAD properly
558 git symbolic-ref HEAD \ 575 git symbolic-ref HEAD \
559 "$(_git-r3_find_head refs/git-r3/HEAD \ 576 "$(_git-r3_find_head refs/git-r3/HEAD \
560 < <(git show-ref --heads || die))" \ 577 < <(git show-ref --heads || die))" \
561 || die "Unable to update HEAD" 578 || die "Unable to update HEAD"

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

  ViewVC Help
Powered by ViewVC 1.1.20