public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES
@ 2019-12-30 13:30 Michał Górny
  2019-12-30 14:03 ` Michael 'veremitz' Everitt
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2019-12-30 13:30 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Match recursive submodules using their full paths rather than path
relatively to the parent submodule.

Closes: https://bugs.gentoo.org/694494
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/git-r3.eclass | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
index 144236c6ac38..663fd939b295 100644
--- a/eclass/git-r3.eclass
+++ b/eclass/git-r3.eclass
@@ -401,16 +401,22 @@ _git-r3_set_gitdir() {
 }
 
 # @FUNCTION: _git-r3_set_submodules
-# @USAGE: <file-contents>
+# @USAGE: <parent-path> <file-contents>
 # @INTERNAL
 # @DESCRIPTION:
 # Parse .gitmodules contents passed as <file-contents>
 # as in "$(cat .gitmodules)"). Composes a 'submodules' array that
 # contains in order (name, URL, path) for each submodule.
+#
+# <parent-path> specifies path to current submodule (empty if top repo),
+# and is used to support recursively specifying submodules.  The path
+# must include a trailing slash if it's not empty.
 _git-r3_set_submodules() {
 	debug-print-function ${FUNCNAME} "$@"
 
-	local data=${1}
+	local parent_path=${1}
+	local data=${2}
+	[[ -z ${parent_path} || ${parent_path} == */ ]] || die
 
 	# ( name url path ... )
 	submodules=()
@@ -435,12 +441,14 @@ _git-r3_set_submodules() {
 					l_res=1
 				fi
 
-				[[ ${subname} == ${p} ]] && res=${l_res}
+				[[ ${parent_path}${subname} == ${p} ]] && res=${l_res}
 			done
 
 			if [[ ! ${res} ]]; then
-				einfo "Skipping submodule ${subname}"
+				einfo "Skipping submodule ${parent_path}${subname}"
 				continue
+			else
+				einfo "Using submodule ${parent_path}${subname}"
 			fi
 		fi
 
@@ -546,7 +554,7 @@ _git-r3_is_local_repo() {
 # This default should be fine unless you are fetching multiple trees
 # from the same repository in the same ebuild.
 #
-# <commit-id> requests attempting to use repository state as of specific
+# <commit-date> requests attempting to use repository state as of specific
 # date. For more details, see EGIT_COMMIT_DATE.
 #
 # The fetch operation will affect the EGIT_STORE only. It will not touch
@@ -817,7 +825,7 @@ git-r3_fetch() {
 	# recursively fetch submodules
 	if git cat-file -e "${local_ref}":.gitmodules &>/dev/null; then
 		local submodules
-		_git-r3_set_submodules \
+		_git-r3_set_submodules "${_GIT_SUBMODULE_PATH}" \
 			"$(git cat-file -p "${local_ref}":.gitmodules || die)"
 
 		while [[ ${submodules[@]} ]]; do
@@ -839,7 +847,9 @@ git-r3_fetch() {
 				local subrepos
 				_git-r3_set_subrepos "${url}" "${repos[@]}"
 
-				git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}"
+				_GIT_SUBMODULE_PATH=${_GIT_SUBMODULE_PATH}${path}/ \
+				git-r3_fetch "${subrepos[*]}" "${commit}" \
+					"${local_id}/${subname}" ""
 			fi
 
 			submodules=( "${submodules[@]:3}" ) # shift
@@ -975,7 +985,7 @@ git-r3_checkout() {
 	# recursively checkout submodules
 	if [[ -f ${out_dir}/.gitmodules && ! ${checkout_paths} ]]; then
 		local submodules
-		_git-r3_set_submodules \
+		_git-r3_set_submodules "${_GIT_SUBMODULE_PATH}" \
 			"$(<"${out_dir}"/.gitmodules)"
 
 		while [[ ${submodules[@]} ]]; do
@@ -989,6 +999,7 @@ git-r3_checkout() {
 				local subrepos
 				_git-r3_set_subrepos "${url}" "${repos[@]}"
 
+				_GIT_SUBMODULE_PATH=${_GIT_SUBMODULE_PATH}${path}/ \
 				git-r3_checkout "${subrepos[*]}" "${out_dir}/${path}" \
 					"${local_id}/${subname}"
 			fi
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES
  2019-12-30 13:30 [gentoo-dev] [PATCH] git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES Michał Górny
@ 2019-12-30 14:03 ` Michael 'veremitz' Everitt
  2019-12-30 14:11   ` Michał Górny
  0 siblings, 1 reply; 4+ messages in thread
From: Michael 'veremitz' Everitt @ 2019-12-30 14:03 UTC (permalink / raw
  To: gentoo-dev


[-- Attachment #1.1: Type: text/plain, Size: 788 bytes --]

On 30/12/19 13:30, Michał Górny wrote:
> Match recursive submodules using their full paths rather than path
> relatively to the parent submodule.
>
> Closes: https://bugs.gentoo.org/694494
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> ---
>  eclass/git-r3.eclass | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> index 144236c6ac38..663fd939b295 100644
> --- a/eclass/git-r3.eclass
> +++ b/eclass/git-r3.eclass
> @@ -401,16 +401,22 @@ _git-r3_set_gitdir() {
>  }
>  
>  # @FUNCTION: _git-r3_set_submodules
> -# @USAGE: <file-contents>
> +# @USAGE: <parent-path> <file-contents>
>  # @INTERNAL
>  # @DESCRIPTION:
<snip>

How is this backward compatible?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES
  2019-12-30 14:03 ` Michael 'veremitz' Everitt
@ 2019-12-30 14:11   ` Michał Górny
  2019-12-30 14:20     ` Michael 'veremitz' Everitt
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2019-12-30 14:11 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

On Mon, 2019-12-30 at 14:03 +0000, Michael 'veremitz' Everitt wrote:
> On 30/12/19 13:30, Michał Górny wrote:
> > Match recursive submodules using their full paths rather than path
> > relatively to the parent submodule.
> > 
> > Closes: https://bugs.gentoo.org/694494
> > Signed-off-by: Michał Górny <mgorny@gentoo.org>
> > ---
> >  eclass/git-r3.eclass | 27 +++++++++++++++++++--------
> >  1 file changed, 19 insertions(+), 8 deletions(-)
> > 
> > diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> > index 144236c6ac38..663fd939b295 100644
> > --- a/eclass/git-r3.eclass
> > +++ b/eclass/git-r3.eclass
> > @@ -401,16 +401,22 @@ _git-r3_set_gitdir() {
> >  }
> >  
> >  # @FUNCTION: _git-r3_set_submodules
> > -# @USAGE: <file-contents>
> > +# @USAGE: <parent-path> <file-contents>
> >  # @INTERNAL
> >  # @DESCRIPTION:
> <snip>
> 
> How is this backward compatible?
> 

This is an internal function.

-- 
Best regards,
Michał Górny


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES
  2019-12-30 14:11   ` Michał Górny
@ 2019-12-30 14:20     ` Michael 'veremitz' Everitt
  0 siblings, 0 replies; 4+ messages in thread
From: Michael 'veremitz' Everitt @ 2019-12-30 14:20 UTC (permalink / raw
  To: gentoo-dev


[-- Attachment #1.1: Type: text/plain, Size: 1030 bytes --]

On 30/12/19 14:11, Michał Górny wrote:
> On Mon, 2019-12-30 at 14:03 +0000, Michael 'veremitz' Everitt wrote:
>> On 30/12/19 13:30, Michał Górny wrote:
>>> Match recursive submodules using their full paths rather than path
>>> relatively to the parent submodule.
>>>
>>> Closes: https://bugs.gentoo.org/694494
>>> Signed-off-by: Michał Górny <mgorny@gentoo.org>
>>> ---
>>>  eclass/git-r3.eclass | 27 +++++++++++++++++++--------
>>>  1 file changed, 19 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
>>> index 144236c6ac38..663fd939b295 100644
>>> --- a/eclass/git-r3.eclass
>>> +++ b/eclass/git-r3.eclass
>>> @@ -401,16 +401,22 @@ _git-r3_set_gitdir() {
>>>  }
>>>  
>>>  # @FUNCTION: _git-r3_set_submodules
>>> -# @USAGE: <file-contents>
>>> +# @USAGE: <parent-path> <file-contents>
>>>  # @INTERNAL
>>>  # @DESCRIPTION:
>> <snip>
>>
>> How is this backward compatible?
>>
> This is an internal function.
>
Ah thanks. id10t check passed! :]


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-30 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-30 13:30 [gentoo-dev] [PATCH] git-r3.eclass: Handle recursive submodules in EGIT_SUBMODULES Michał Górny
2019-12-30 14:03 ` Michael 'veremitz' Everitt
2019-12-30 14:11   ` Michał Górny
2019-12-30 14:20     ` Michael 'veremitz' Everitt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox