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