/[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.35 Revision 1.39
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.35 2014/03/02 11:49:05 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.39 2014/03/03 21:45:06 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.
35# @ECLASS-VARIABLE: EGIT_CLONE_TYPE 35# @ECLASS-VARIABLE: EGIT_CLONE_TYPE
36# @DESCRIPTION: 36# @DESCRIPTION:
37# Type of clone that should be used against the remote repository. 37# Type of clone that should be used against the remote repository.
38# This can be either of: 'mirror', 'single', 'shallow'. 38# This can be either of: 'mirror', 'single', 'shallow'.
39# 39#
40# This is intended to be set by user in make.conf. Ebuilds are supposed
41# to set EGIT_MIN_CLONE_TYPE if necessary instead.
42#
40# The 'mirror' type clones all remote branches and tags with complete 43# The 'mirror' type clones all remote branches and tags with complete
41# history and all notes. EGIT_COMMIT can specify any commit hash. 44# history and all notes. EGIT_COMMIT can specify any commit hash.
42# Upstream-removed branches and tags are purged from the local clone 45# Upstream-removed branches and tags are purged from the local clone
43# while fetching. This mode is suitable for cloning the local copy 46# while fetching. This mode is suitable for cloning the local copy
44# for development or hosting a local git mirror. However, clones 47# for development or hosting a local git mirror. However, clones
62# @DESCRIPTION: 65# @DESCRIPTION:
63# 'Minimum' clone type supported by the ebuild. Takes same values 66# 'Minimum' clone type supported by the ebuild. Takes same values
64# as EGIT_CLONE_TYPE. When user sets a type that's 'lower' (that is, 67# as EGIT_CLONE_TYPE. When user sets a type that's 'lower' (that is,
65# later on the list) than EGIT_MIN_CLONE_TYPE, the eclass uses 68# later on the list) than EGIT_MIN_CLONE_TYPE, the eclass uses
66# EGIT_MIN_CLONE_TYPE instead. 69# EGIT_MIN_CLONE_TYPE instead.
70#
71# This variable is intended to be used by ebuilds only. Users are
72# supposed to set EGIT_CLONE_TYPE instead.
67# 73#
68# A common case is to use 'single' whenever the build system requires 74# A common case is to use 'single' whenever the build system requires
69# access to full branch history or the remote (Google Code) does not 75# access to full branch history or the remote (Google Code) does not
70# support shallow clones. Please use sparingly, and to fix fatal errors 76# support shallow clones. Please use sparingly, and to fix fatal errors
71# rather than 'non-pretty versions'. 77# rather than 'non-pretty versions'.
450 456
451 if [[ ${EGIT_CLONE_TYPE} == mirror ]]; then 457 if [[ ${EGIT_CLONE_TYPE} == mirror ]]; then
452 fetch_command+=( 458 fetch_command+=(
453 --prune 459 --prune
454 # mirror the remote branches as local branches 460 # mirror the remote branches as local branches
455 "refs/heads/*:refs/heads/*" 461 "+refs/heads/*:refs/heads/*"
456 # pull tags explicitly in order to prune them properly 462 # pull tags explicitly in order to prune them properly
457 "refs/tags/*:refs/tags/*" 463 "+refs/tags/*:refs/tags/*"
458 # notes in case something needs them 464 # notes in case something needs them
459 "refs/notes/*:refs/notes/*" 465 "+refs/notes/*:refs/notes/*"
460 # and HEAD in case we need the default branch 466 # and HEAD in case we need the default branch
461 # (we keep it in refs/git-r3 since otherwise --prune interferes) 467 # (we keep it in refs/git-r3 since otherwise --prune interferes)
462 HEAD:refs/git-r3/HEAD 468 "+HEAD:refs/git-r3/HEAD"
463 ) 469 )
464 else # single or shallow 470 else # single or shallow
465 local fetch_l fetch_r 471 local fetch_l fetch_r
466 472
467 if [[ ${remote_ref} == HEAD ]]; then 473 if [[ ${remote_ref} == HEAD ]]; then
500 else 506 else
501 fetch_r=${fetch_l} 507 fetch_r=${fetch_l}
502 fi 508 fi
503 509
504 fetch_command+=( 510 fetch_command+=(
505 "${fetch_l}:${fetch_r}" 511 "+${fetch_l}:${fetch_r}"
506 ) 512 )
507 fi 513 fi
508 514
509 if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then 515 if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then
510 # use '--depth 1' when fetching a new branch 516 if _git-r3_is_local_repo; then
517 # '--depth 1' causes sandbox violations with local repos
518 # bug #491260
519 local EGIT_CLONE_TYPE=single
511 if [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]] 520 elif [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]]
512 then 521 then
522 # use '--depth 1' when fetching a new branch
513 fetch_command+=( --depth 1 ) 523 fetch_command+=( --depth 1 )
514 fi 524 fi
515 else # non-shallow mode 525 else # non-shallow mode
516 if [[ -f ${GIT_DIR}/shallow ]]; then 526 if [[ -f ${GIT_DIR}/shallow ]]; then
517 fetch_command+=( --unshallow ) 527 fetch_command+=( --unshallow )
566 break 576 break
567 fi 577 fi
568 done 578 done
569 [[ ${success} ]] || die "Unable to fetch from any of EGIT_REPO_URI" 579 [[ ${success} ]] || die "Unable to fetch from any of EGIT_REPO_URI"
570 580
581 # submodules can reference commits in any branch
582 # always use the 'clone' mode to accomodate that, bug #503332
583 local EGIT_CLONE_TYPE=mirror
584
571 # recursively fetch submodules 585 # recursively fetch submodules
572 if git cat-file -e "${local_ref}":.gitmodules &>/dev/null; then 586 if git cat-file -e "${local_ref}":.gitmodules &>/dev/null; then
573 local submodules 587 local submodules
574 _git-r3_set_submodules \ 588 _git-r3_set_submodules \
575 "$(git cat-file -p "${local_ref}":.gitmodules || die)" 589 "$(git cat-file -p "${local_ref}":.gitmodules || die)"

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.39

  ViewVC Help
Powered by ViewVC 1.1.20