Gentoo Archives: gentoo-commits

From: "Michal Gorny (mgorny)" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog git-r3.eclass
Date: Sun, 01 Jun 2014 22:08:04
Message-Id: 20140601220759.833B82004E@flycatcher.gentoo.org
1 mgorny 14/06/01 22:07:59
2
3 Modified: ChangeLog git-r3.eclass
4 Log:
5 Properly canonicalize relative submodule URIs, bug #501250.
6
7 Revision Changes Path
8 1.1279 eclass/ChangeLog
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1279&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1279&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1278&r2=1.1279
13
14 Index: ChangeLog
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
17 retrieving revision 1.1278
18 retrieving revision 1.1279
19 diff -u -r1.1278 -r1.1279
20 --- ChangeLog 31 May 2014 10:23:36 -0000 1.1278
21 +++ ChangeLog 1 Jun 2014 22:07:59 -0000 1.1279
22 @@ -1,6 +1,10 @@
23 # ChangeLog for eclass directory
24 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1278 2014/05/31 10:23:36 mgorny Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1279 2014/06/01 22:07:59 mgorny Exp $
27 +
28 + 01 Jun 2014; Michał Górny <mgorny@g.o> git-r3.eclass,
29 + +tests/git-r3:subrepos.sh:
30 + Properly canonicalize relative submodule URIs, bug #501250.
31
32 31 May 2014; Michał Górny <mgorny@g.o> systemd.eclass:
33 Add systemd_{do,new}userunit.
34
35
36
37 1.43 eclass/git-r3.eclass
38
39 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.43&view=markup
40 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.43&content-type=text/plain
41 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?r1=1.42&r2=1.43
42
43 Index: git-r3.eclass
44 ===================================================================
45 RCS file: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v
46 retrieving revision 1.42
47 retrieving revision 1.43
48 diff -u -r1.42 -r1.43
49 --- git-r3.eclass 23 May 2014 07:09:07 -0000 1.42
50 +++ git-r3.eclass 1 Jun 2014 22:07:59 -0000 1.43
51 @@ -1,6 +1,6 @@
52 # Copyright 1999-2014 Gentoo Foundation
53 # Distributed under the terms of the GNU General Public License v2
54 -# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.42 2014/05/23 07:09:07 mgorny Exp $
55 +# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.43 2014/06/01 22:07:59 mgorny Exp $
56
57 # @ECLASS: git-r3.eclass
58 # @MAINTAINER:
59 @@ -352,6 +352,49 @@
60 done < <(echo "${data}" | git config -f /dev/fd/0 -l || die)
61 }
62
63 +# @FUNCTION: _git-r3_set_subrepos
64 +# @USAGE: <submodule-uri> <parent-repo-uri>...
65 +# @INTERNAL
66 +# @DESCRIPTION:
67 +# Create 'subrepos' array containing absolute (canonical) submodule URIs
68 +# for the given <submodule-uri>. If the URI is relative, URIs will be
69 +# constructed using all <parent-repo-uri>s. Otherwise, this single URI
70 +# will be placed in the array.
71 +_git-r3_set_subrepos() {
72 + debug-print-function ${FUNCNAME} "$@"
73 +
74 + local suburl=${1}
75 + subrepos=( "${@:2}" )
76 +
77 + if [[ ${suburl} == ./* || ${suburl} == ../* ]]; then
78 + # drop all possible trailing slashes for consistency
79 + subrepos=( "${subrepos[@]%%/}" )
80 +
81 + while true; do
82 + if [[ ${suburl} == ./* ]]; then
83 + suburl=${suburl:2}
84 + elif [[ ${suburl} == ../* ]]; then
85 + suburl=${suburl:3}
86 +
87 + # XXX: correctness checking
88 +
89 + # drop the last path component
90 + subrepos=( "${subrepos[@]%/*}" )
91 + # and then the trailing slashes, again
92 + subrepos=( "${subrepos[@]%%/}" )
93 + else
94 + break
95 + fi
96 + done
97 +
98 + # append the preprocessed path to the preprocessed URIs
99 + subrepos=( "${subrepos[@]/%//${suburl}}")
100 + else
101 + subrepos=( "${suburl}" )
102 + fi
103 +}
104 +
105 +
106 # @FUNCTION: _git-r3_is_local_repo
107 # @USAGE: <repo-uri>
108 # @INTERNAL
109 @@ -645,11 +688,9 @@
110 if [[ ! ${commit} ]]; then
111 die "Unable to get commit id for submodule ${subname}"
112 fi
113 - if [[ ${url} == ./* || ${url} == ../* ]]; then
114 - local subrepos=( "${repos[@]/%//${url}}" )
115 - else
116 - local subrepos=( "${url}" )
117 - fi
118 +
119 + local subrepos
120 + _git-r3_set_subrepos "${url}" "${repos[@]}"
121
122 git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}"
123
124 @@ -781,10 +822,8 @@
125 local subname=${submodules[0]}
126 local url=${submodules[1]}
127 local path=${submodules[2]}
128 -
129 - if [[ ${url} == ./* || ${url} == ../* ]]; then
130 - url=${repos[0]%%/}/${url}
131 - fi
132 + local subrepos
133 + _git-r3_set_subrepos "${url}" "${repos[@]}"
134
135 git-r3_checkout "${url}" "${out_dir}/${path}" \
136 "${local_id}/${subname}"