mgorny 14/06/01 22:07:59 Modified: ChangeLog git-r3.eclass Log: Properly canonicalize relative submodule URIs, bug #501250.
Revision Changes Path 1.1279 eclass/ChangeLog file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1279&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1279&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1278&r2=1.1279 Index: ChangeLog =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v retrieving revision 1.1278 retrieving revision 1.1279 diff -u -r1.1278 -r1.1279 --- ChangeLog 31 May 2014 10:23:36 -0000 1.1278 +++ ChangeLog 1 Jun 2014 22:07:59 -0000 1.1279 @@ -1,6 +1,10 @@ # ChangeLog for eclass directory # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1278 2014/05/31 10:23:36 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1279 2014/06/01 22:07:59 mgorny Exp $ + + 01 Jun 2014; Michał Górny <[email protected]> git-r3.eclass, + +tests/git-r3:subrepos.sh: + Properly canonicalize relative submodule URIs, bug #501250. 31 May 2014; Michał Górny <[email protected]> systemd.eclass: Add systemd_{do,new}userunit. 1.43 eclass/git-r3.eclass file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.43&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.43&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?r1=1.42&r2=1.43 Index: git-r3.eclass =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- git-r3.eclass 23 May 2014 07:09:07 -0000 1.42 +++ git-r3.eclass 1 Jun 2014 22:07:59 -0000 1.43 @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.42 2014/05/23 07:09:07 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.43 2014/06/01 22:07:59 mgorny Exp $ # @ECLASS: git-r3.eclass # @MAINTAINER: @@ -352,6 +352,49 @@ done < <(echo "${data}" | git config -f /dev/fd/0 -l || die) } +# @FUNCTION: _git-r3_set_subrepos +# @USAGE: <submodule-uri> <parent-repo-uri>... +# @INTERNAL +# @DESCRIPTION: +# Create 'subrepos' array containing absolute (canonical) submodule URIs +# for the given <submodule-uri>. If the URI is relative, URIs will be +# constructed using all <parent-repo-uri>s. Otherwise, this single URI +# will be placed in the array. +_git-r3_set_subrepos() { + debug-print-function ${FUNCNAME} "$@" + + local suburl=${1} + subrepos=( "${@:2}" ) + + if [[ ${suburl} == ./* || ${suburl} == ../* ]]; then + # drop all possible trailing slashes for consistency + subrepos=( "${subrepos[@]%%/}" ) + + while true; do + if [[ ${suburl} == ./* ]]; then + suburl=${suburl:2} + elif [[ ${suburl} == ../* ]]; then + suburl=${suburl:3} + + # XXX: correctness checking + + # drop the last path component + subrepos=( "${subrepos[@]%/*}" ) + # and then the trailing slashes, again + subrepos=( "${subrepos[@]%%/}" ) + else + break + fi + done + + # append the preprocessed path to the preprocessed URIs + subrepos=( "${subrepos[@]/%//${suburl}}") + else + subrepos=( "${suburl}" ) + fi +} + + # @FUNCTION: _git-r3_is_local_repo # @USAGE: <repo-uri> # @INTERNAL @@ -645,11 +688,9 @@ if [[ ! ${commit} ]]; then die "Unable to get commit id for submodule ${subname}" fi - if [[ ${url} == ./* || ${url} == ../* ]]; then - local subrepos=( "${repos[@]/%//${url}}" ) - else - local subrepos=( "${url}" ) - fi + + local subrepos + _git-r3_set_subrepos "${url}" "${repos[@]}" git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}" @@ -781,10 +822,8 @@ local subname=${submodules[0]} local url=${submodules[1]} local path=${submodules[2]} - - if [[ ${url} == ./* || ${url} == ../* ]]; then - url=${repos[0]%%/}/${url} - fi + local subrepos + _git-r3_set_subrepos "${url}" "${repos[@]}" git-r3_checkout "${url}" "${out_dir}/${path}" \ "${local_id}/${subname}"
