/[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.1 Revision 1.2
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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.1 2013/09/05 20:24:10 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.2 2013/09/05 22:40:12 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.
312 # split on whitespace 312 # split on whitespace
313 local ref=( 313 local ref=(
314 $(git ls-remote "${r}" "${lookup_ref}") 314 $(git ls-remote "${r}" "${lookup_ref}")
315 ) 315 )
316 316
317 local ref_param=()
318 if [[ ! ${ref[0]} ]]; then
319 local EGIT_NONSHALLOW=1
320 fi
321
322 # 1. if we need a non-shallow clone and we have a shallow one,
323 # we need to unshallow it explicitly.
324 # 2. if we want a shallow clone, we just pass '--depth 1'
325 # to the first fetch in the repo. passing '--depth'
326 # to further requests usually results in more data being
327 # downloaded than without it.
328 # 3. in any other case, we just do plain 'git fetch' and let
329 # git to do its best (on top of shallow or non-shallow repo).
330
331 if [[ ${EGIT_NONSHALLOW} ]]; then
332 if [[ -f ${GIT_DIR}/shallow ]]; then
333 ref_param+=( --unshallow )
334 fi
335 else
336 # 'git show-ref --heads' returns 1 when there are no branches
337 if ! git show-ref --heads -q; then
338 ref_param+=( --depth 1 )
339 fi
340 fi
341
317 # now, another important thing. we may only fetch a remote 342 # now, another important thing. we may only fetch a remote
318 # branch directly to a local branch. Otherwise, we need to fetch 343 # branch directly to a local branch. Otherwise, we need to fetch
319 # the commit and re-create the branch on top of it. 344 # the commit and re-create the branch on top of it.
320
321 local ref_param=()
322 if [[ ! ${ref[0]} ]]; then
323 local EGIT_NONSHALLOW=1
324 fi
325
326 if [[ ! -f ${GIT_DIR}/shallow ]]; then
327 # if it's a complete repo, fetch it as-is
328 :
329 elif [[ ${EGIT_NONSHALLOW} ]]; then
330 # if it's a shallow clone but we need complete,
331 # unshallow it
332 ref_param+=( --unshallow )
333 else
334 # otherwise, just fetch as shallow
335 ref_param+=( --depth 1 )
336 fi
337 345
338 if [[ ${ref[0]} ]]; then 346 if [[ ${ref[0]} ]]; then
339 if [[ ${is_branch} ]]; then 347 if [[ ${is_branch} ]]; then
340 ref_param+=( -f "${remote_ref}:${local_id}/__main__" ) 348 ref_param+=( -f "${remote_ref}:${local_id}/__main__" )
341 else 349 else

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20