1 |
commit: 23717189bcef73c1b4604282de58daaf14a17b43 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Nov 13 14:06:35 2019 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 10 18:27:18 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=23717189 |
7 |
|
8 |
git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES |
9 |
|
10 |
Match recursive submodules using their full paths rather than path |
11 |
relatively to the parent submodule. |
12 |
|
13 |
Closes: https://bugs.gentoo.org/694494 |
14 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
15 |
|
16 |
eclass/git-r3.eclass | 27 +++++++++++++++++++-------- |
17 |
1 file changed, 19 insertions(+), 8 deletions(-) |
18 |
|
19 |
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass |
20 |
index 144236c6ac3..663fd939b29 100644 |
21 |
--- a/eclass/git-r3.eclass |
22 |
+++ b/eclass/git-r3.eclass |
23 |
@@ -401,16 +401,22 @@ _git-r3_set_gitdir() { |
24 |
} |
25 |
|
26 |
# @FUNCTION: _git-r3_set_submodules |
27 |
-# @USAGE: <file-contents> |
28 |
+# @USAGE: <parent-path> <file-contents> |
29 |
# @INTERNAL |
30 |
# @DESCRIPTION: |
31 |
# Parse .gitmodules contents passed as <file-contents> |
32 |
# as in "$(cat .gitmodules)"). Composes a 'submodules' array that |
33 |
# contains in order (name, URL, path) for each submodule. |
34 |
+# |
35 |
+# <parent-path> specifies path to current submodule (empty if top repo), |
36 |
+# and is used to support recursively specifying submodules. The path |
37 |
+# must include a trailing slash if it's not empty. |
38 |
_git-r3_set_submodules() { |
39 |
debug-print-function ${FUNCNAME} "$@" |
40 |
|
41 |
- local data=${1} |
42 |
+ local parent_path=${1} |
43 |
+ local data=${2} |
44 |
+ [[ -z ${parent_path} || ${parent_path} == */ ]] || die |
45 |
|
46 |
# ( name url path ... ) |
47 |
submodules=() |
48 |
@@ -435,12 +441,14 @@ _git-r3_set_submodules() { |
49 |
l_res=1 |
50 |
fi |
51 |
|
52 |
- [[ ${subname} == ${p} ]] && res=${l_res} |
53 |
+ [[ ${parent_path}${subname} == ${p} ]] && res=${l_res} |
54 |
done |
55 |
|
56 |
if [[ ! ${res} ]]; then |
57 |
- einfo "Skipping submodule ${subname}" |
58 |
+ einfo "Skipping submodule ${parent_path}${subname}" |
59 |
continue |
60 |
+ else |
61 |
+ einfo "Using submodule ${parent_path}${subname}" |
62 |
fi |
63 |
fi |
64 |
|
65 |
@@ -546,7 +554,7 @@ _git-r3_is_local_repo() { |
66 |
# This default should be fine unless you are fetching multiple trees |
67 |
# from the same repository in the same ebuild. |
68 |
# |
69 |
-# <commit-id> requests attempting to use repository state as of specific |
70 |
+# <commit-date> requests attempting to use repository state as of specific |
71 |
# date. For more details, see EGIT_COMMIT_DATE. |
72 |
# |
73 |
# The fetch operation will affect the EGIT_STORE only. It will not touch |
74 |
@@ -817,7 +825,7 @@ git-r3_fetch() { |
75 |
# recursively fetch submodules |
76 |
if git cat-file -e "${local_ref}":.gitmodules &>/dev/null; then |
77 |
local submodules |
78 |
- _git-r3_set_submodules \ |
79 |
+ _git-r3_set_submodules "${_GIT_SUBMODULE_PATH}" \ |
80 |
"$(git cat-file -p "${local_ref}":.gitmodules || die)" |
81 |
|
82 |
while [[ ${submodules[@]} ]]; do |
83 |
@@ -839,7 +847,9 @@ git-r3_fetch() { |
84 |
local subrepos |
85 |
_git-r3_set_subrepos "${url}" "${repos[@]}" |
86 |
|
87 |
- git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}" |
88 |
+ _GIT_SUBMODULE_PATH=${_GIT_SUBMODULE_PATH}${path}/ \ |
89 |
+ git-r3_fetch "${subrepos[*]}" "${commit}" \ |
90 |
+ "${local_id}/${subname}" "" |
91 |
fi |
92 |
|
93 |
submodules=( "${submodules[@]:3}" ) # shift |
94 |
@@ -975,7 +985,7 @@ git-r3_checkout() { |
95 |
# recursively checkout submodules |
96 |
if [[ -f ${out_dir}/.gitmodules && ! ${checkout_paths} ]]; then |
97 |
local submodules |
98 |
- _git-r3_set_submodules \ |
99 |
+ _git-r3_set_submodules "${_GIT_SUBMODULE_PATH}" \ |
100 |
"$(<"${out_dir}"/.gitmodules)" |
101 |
|
102 |
while [[ ${submodules[@]} ]]; do |
103 |
@@ -989,6 +999,7 @@ git-r3_checkout() { |
104 |
local subrepos |
105 |
_git-r3_set_subrepos "${url}" "${repos[@]}" |
106 |
|
107 |
+ _GIT_SUBMODULE_PATH=${_GIT_SUBMODULE_PATH}${path}/ \ |
108 |
git-r3_checkout "${subrepos[*]}" "${out_dir}/${path}" \ |
109 |
"${local_id}/${subname}" |
110 |
fi |