/[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.42 Revision 1.43
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.42 2014/05/23 07:09:07 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.43 2014/06/01 22:07:59 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.
350 submodule."${subname}".path || die)" 350 submodule."${subname}".path || die)"
351 ) 351 )
352 done < <(echo "${data}" | git config -f /dev/fd/0 -l || die) 352 done < <(echo "${data}" | git config -f /dev/fd/0 -l || die)
353} 353}
354 354
355# @FUNCTION: _git-r3_set_subrepos
356# @USAGE: <submodule-uri> <parent-repo-uri>...
357# @INTERNAL
358# @DESCRIPTION:
359# Create 'subrepos' array containing absolute (canonical) submodule URIs
360# for the given <submodule-uri>. If the URI is relative, URIs will be
361# constructed using all <parent-repo-uri>s. Otherwise, this single URI
362# will be placed in the array.
363_git-r3_set_subrepos() {
364 debug-print-function ${FUNCNAME} "$@"
365
366 local suburl=${1}
367 subrepos=( "${@:2}" )
368
369 if [[ ${suburl} == ./* || ${suburl} == ../* ]]; then
370 # drop all possible trailing slashes for consistency
371 subrepos=( "${subrepos[@]%%/}" )
372
373 while true; do
374 if [[ ${suburl} == ./* ]]; then
375 suburl=${suburl:2}
376 elif [[ ${suburl} == ../* ]]; then
377 suburl=${suburl:3}
378
379 # XXX: correctness checking
380
381 # drop the last path component
382 subrepos=( "${subrepos[@]%/*}" )
383 # and then the trailing slashes, again
384 subrepos=( "${subrepos[@]%%/}" )
385 else
386 break
387 fi
388 done
389
390 # append the preprocessed path to the preprocessed URIs
391 subrepos=( "${subrepos[@]/%//${suburl}}")
392 else
393 subrepos=( "${suburl}" )
394 fi
395}
396
397
355# @FUNCTION: _git-r3_is_local_repo 398# @FUNCTION: _git-r3_is_local_repo
356# @USAGE: <repo-uri> 399# @USAGE: <repo-uri>
357# @INTERNAL 400# @INTERNAL
358# @DESCRIPTION: 401# @DESCRIPTION:
359# Determine whether the given URI specifies a local (on-disk) 402# Determine whether the given URI specifies a local (on-disk)
643 local commit=$(git rev-parse "${local_ref}:${path}") 686 local commit=$(git rev-parse "${local_ref}:${path}")
644 687
645 if [[ ! ${commit} ]]; then 688 if [[ ! ${commit} ]]; then
646 die "Unable to get commit id for submodule ${subname}" 689 die "Unable to get commit id for submodule ${subname}"
647 fi 690 fi
648 if [[ ${url} == ./* || ${url} == ../* ]]; then 691
649 local subrepos=( "${repos[@]/%//${url}}" ) 692 local subrepos
650 else 693 _git-r3_set_subrepos "${url}" "${repos[@]}"
651 local subrepos=( "${url}" )
652 fi
653 694
654 git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}" 695 git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}"
655 696
656 submodules=( "${submodules[@]:3}" ) # shift 697 submodules=( "${submodules[@]:3}" ) # shift
657 done 698 done
779 820
780 while [[ ${submodules[@]} ]]; do 821 while [[ ${submodules[@]} ]]; do
781 local subname=${submodules[0]} 822 local subname=${submodules[0]}
782 local url=${submodules[1]} 823 local url=${submodules[1]}
783 local path=${submodules[2]} 824 local path=${submodules[2]}
784 825 local subrepos
785 if [[ ${url} == ./* || ${url} == ../* ]]; then 826 _git-r3_set_subrepos "${url}" "${repos[@]}"
786 url=${repos[0]%%/}/${url}
787 fi
788 827
789 git-r3_checkout "${url}" "${out_dir}/${path}" \ 828 git-r3_checkout "${url}" "${out_dir}/${path}" \
790 "${local_id}/${subname}" 829 "${local_id}/${subname}"
791 830
792 submodules=( "${submodules[@]:3}" ) # shift 831 submodules=( "${submodules[@]:3}" ) # shift

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20