Skip to contentSkip to conversation

gitsm: Control submodule recursion

RFC PATCH In review Andrew Jeffery 3 participants 7 messages Aug 27, 2019 – Aug 30, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 gitsm: Control submodule recursion

There exist some use-cases where repositories related by submodules do not require submodules be recursively initialised despite needing the first layer of submodules to be fetched. Enable this usecase in gitsm by implementing a recurse=X SRC_URI parameter. The current implementation of the recurse parameter defaults to enabling exhaustive recursion to match the current behaviour of gitsm, with the one alternative being no recursion. Enough rope is provided to allow specific recursion depths to be implemented if necessary via the same interface. Values currently unsupported for the recurse parameter raise a ValueError to ensure forward compatibility.

---
 lib/bb/fetch2/gitsm.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
lib/bb/fetch2/gitsm.py +28 -6
index c622771d21aa..5a8426b486e3 100644
@@ -6,7 +6,15 @@ after cloning.
 
 SRC_URI = "gitsm://<see Git fetcher for syntax>"
 
-See the Git fetcher, git://, for usage documentation.
+Supported SRC_URI options are:
+
+- recurse
+    Control recursive nature of submodule initialisation.
+
+    The default value is -1, which will recursively initialise all submodules.
+    Set to 0 to disable recursiion.
+
+See the Git fetcher, git://, for further usage documentation.
 
 NOTE: Switching a SRC_URI from "git://" to "gitsm://" requires a clean of your recipe.
 
@@ -26,6 +34,15 @@ from   bb.fetch2 import logger
 from   bb.fetch2 import Fetch
 from   bb.fetch2 import BBFetchException
 
+def should_recurse(ud):
+    recurse = ud.parm.get("recurse", "-1")
+
+    # Change this condition if we end up supporting specific maximum depths
+    if recurse in ( "-1", "0" ):
+        return recurse == "-1"
+
+    raise ValueError("Recursion control value not supported: %s" % (recurse))
+
 class GitSM(Git):
     def supports(self, ud, d):
         """
@@ -95,25 +112,28 @@ class GitSM(Git):
         for module in submodules:
             # Translate the module url into a SRC_URI
 
+            recurse = should_recurse(ud)
             if "://" in uris[module]:
                 # Properly formated URL already
                 proto = uris[module].split(':', 1)[0]
-                url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+                desired = "gitsm:" if recurse else "git:"
+                url = uris[module].replace('%s:' % proto, desired, 1)
             else:
+                scheme = "gitsm://" if recurse else "git://"
                 if ":" in uris[module]:
                     # Most likely an SSH style reference
                     proto = "ssh"
                     if ":/" in uris[module]:
                         # Absolute reference, easy to convert..
-                        url = "gitsm://" + uris[module].replace(':/', '/', 1)
+                        url = scheme + uris[module].replace(':/', '/', 1)
                     else:
                         # Relative reference, no way to know if this is right!
                         logger.warning("Submodule included by %s refers to relative ssh reference %s.  References may fail if not absolute." % (ud.url, uris[module]))
-                        url = "gitsm://" + uris[module].replace(':', '/', 1)
+                        url = scheme + uris[module].replace(':', '/', 1)
                 else:
                     # This has to be a file reference
                     proto = "file"
-                    url = "gitsm://" + uris[module]
+                    url = scheme + uris[module]
 
             url += ';protocol=%s' % proto
             url += ";name=%s" % module
@@ -209,7 +229,9 @@ class GitSM(Git):
         ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d)
 
         if not ud.bareclone and ret:
+            recurse = should_recurse(ud)
             # All submodules should already be downloaded and configured in the tree.  This simply sets
             # up the configuration and checks out the files.  The main project config should remain
             # unmodified, and no download from the internet should occur.
-            runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir)
+            runfetchcmd("%s submodule update %s --no-fetch" % (ud.basecmd, "--recursive" if recurse else ""),
+                        d, quiet=True, workdir=ud.destdir)
Signature · 1 line
2.20.1
#1 lore raw
Quoted 10 lines · Andrew Jeffery

There exist some use-cases where repositories related by submodules do not require submodules be recursively initialised despite needing the first layer of submodules to be fetched. Enable this usecase in gitsm by implementing a recurse=X SRC_URI parameter. The current implementation of the recurse parameter defaults to enabling exhaustive recursion to match the current behaviour of gitsm, with the one alternative being no recursion. Enough rope is provided to allow specific recursion depths to be implemented if necessary via the same interface. Values currently unsupported for the recurse parameter raise a ValueError to ensure forward compatibility.

I was thinking about this patch and I'm not sure it's needed. There are ways to do this without using gitsm.

If you don't want recursion, then why are you specifying 'gitsm' at all? The 'git' fetcher won't recurse and can be used to pull down a subset of what would have been a recursive fetch. The 'subpath' parameter can even be used to combine the items in the same way as the gitsm fetcher if really needed.

(A few more comments below, as more of a technical review)

Quoted 43 lines
---
 lib/bb/fetch2/gitsm.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
lib/bb/fetch2/gitsm.py +18 -1
index c622771d21aa..5a8426b486e3 100644
@@ -6,7 +6,15 @@ after cloning.
 
 SRC_URI = "gitsm://<see Git fetcher for syntax>"
 
-See the Git fetcher, git://, for usage documentation.
+Supported SRC_URI options are:
+
+- recurse
+    Control recursive nature of submodule initialisation.
+
+    The default value is -1, which will recursively initialise all submodules.
+    Set to 0 to disable recursiion.
+
+See the Git fetcher, git://, for further usage documentation.
 
 NOTE: Switching a SRC_URI from "git://" to "gitsm://" requires a clean of your recipe.
 
@@ -26,6 +34,15 @@ from   bb.fetch2 import logger
 from   bb.fetch2 import Fetch
 from   bb.fetch2 import BBFetchException
 
+def should_recurse(ud):
+    recurse = ud.parm.get("recurse", "-1")
+
+    # Change this condition if we end up supporting specific maximum depths
+    if recurse in ( "-1", "0" ):
+        return recurse == "-1"
+
+    raise ValueError("Recursion control value not supported: %s" % (recurse))
+
 class GitSM(Git):
     def supports(self, ud, d):
         """

lib/bb/fetch2/gitsm.py class GitSM(Git): · line 120

Quoted 10 lines
lib/bb/fetch2/gitsm.py +3 -1
@@ -95,25 +112,28 @@ class GitSM(Git):
         for module in submodules:
             # Translate the module url into a SRC_URI
 
+            recurse = should_recurse(ud)
             if "://" in uris[module]:
                 # Properly formated URL already
                 proto = uris[module].split(':', 1)[0]
-                url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+                desired = "gitsm:" if recurse else "git:"
+                url = uris[module].replace('%s:' % proto, desired, 1)

Above 'desired' is used, below 'scheme' is used. You should use the same variable for both, and set it before the first 'if'. To me 'scheme' is a better variable.

Quoted 34 lines
lib/bb/fetch2/gitsm.py +7 -4
             else:
+                scheme = "gitsm://" if recurse else "git://"
                 if ":" in uris[module]:
                     # Most likely an SSH style reference
                     proto = "ssh"
                     if ":/" in uris[module]:
                         # Absolute reference, easy to convert..
-                        url = "gitsm://" + uris[module].replace(':/', '/', 1)
+                        url = scheme + uris[module].replace(':/', '/', 1)
                     else:
                         # Relative reference, no way to know if this is right!
                         logger.warning("Submodule included by %s refers to relative ssh reference %s.  References may fail if not absolute." % (ud.url, uris[module]))
-                        url = "gitsm://" + uris[module].replace(':', '/', 1)
+                        url = scheme + uris[module].replace(':', '/', 1)
                 else:
                     # This has to be a file reference
                     proto = "file"
-                    url = "gitsm://" + uris[module]
+                    url = scheme + uris[module]
 
             url += ';protocol=%s' % proto
             url += ";name=%s" % module
@@ -209,7 +229,9 @@ class GitSM(Git):
         ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d)
 
         if not ud.bareclone and ret:
+            recurse = should_recurse(ud)
             # All submodules should already be downloaded and configured in the tree.  This simply sets
             # up the configuration and checks out the files.  The main project config should remain
             # unmodified, and no download from the internet should occur.
-            runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir)
+            runfetchcmd("%s submodule update %s --no-fetch" % (ud.basecmd, "--recursive" if recurse else ""),
+                        d, quiet=True, workdir=ud.destdir)
#2 lore raw

Hi Mark,

Quoted 12 lines · Mark Hatle
Quoted 10 lines · Andrew Jeffery

There exist some use-cases where repositories related by submodules do not require submodules be recursively initialised despite needing the first layer of submodules to be fetched. Enable this usecase in gitsm by implementing a recurse=X SRC_URI parameter. The current implementation of the recurse parameter defaults to enabling exhaustive recursion to match the current behaviour of gitsm, with the one alternative being no recursion. Enough rope is provided to allow specific recursion depths to be implemented if necessary via the same interface. Values currently unsupported for the recurse parameter raise a ValueError to ensure forward compatibility.

Quoted 4 lines

I was thinking about this patch and I'm not sure it's needed. There are ways to do this without using gitsm.

If you don't want recursion, then why are you specifying 'gitsm' at all?

As far as I'm aware the git fetcher doesn't handle submodules at all. If I have a misunderstanding there and this patch is unnecessary then that's excellent, because I hate it :D

Quoted 4 lines

The
'git' fetcher won't recurse and can be used to pull down a subset of what would have been a recursive fetch. The 'subpath' parameter can even be used to combine the items in the same way as the gitsm fetcher if really needed.

Can you expand a bit more on how I'd do this (examples?), or point me in the right direction with documentation? There don't appear to be any pointers in the git:// fetcher section of the mega manual.

Just for clarity, the repository structure this patch is trying to cater for looks like:

      +---->C
      |
      +---->D
      +
A+--->B+--->E
      +
      +---->F
      |
      +---->G

We have a recipe for A, whose repository has a submodule B, and B has several submodules C, D, E, F, G. Repositories C-G are large and actually irrelevant for the purpose of what we're doing in A, but the content of B is required for A to build.

I hate the patch because the scenario seems like such a corner-case, but here we are with a real-world use-case.

Quoted 49 lines

(A few more comments below, as more of a technical review)

Quoted 46 lines
---
 lib/bb/fetch2/gitsm.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
lib/bb/fetch2/gitsm.py +18 -1
index c622771d21aa..5a8426b486e3 100644
@@ -6,7 +6,15 @@ after cloning.
 
 SRC_URI = "gitsm://<see Git fetcher for syntax>"
 
-See the Git fetcher, git://, for usage documentation.
+Supported SRC_URI options are:
+
+- recurse
+    Control recursive nature of submodule initialisation.
+
+    The default value is -1, which will recursively initialise all submodules.
+    Set to 0 to disable recursiion.
+
+See the Git fetcher, git://, for further usage documentation.
 
 NOTE: Switching a SRC_URI from "git://" to "gitsm://" requires a clean of your recipe.
 
@@ -26,6 +34,15 @@ from   bb.fetch2 import logger
 from   bb.fetch2 import Fetch
 from   bb.fetch2 import BBFetchException
 
+def should_recurse(ud):
+    recurse = ud.parm.get("recurse", "-1")
+
+    # Change this condition if we end up supporting specific maximum depths
+    if recurse in ( "-1", "0" ):
+        return recurse == "-1"
+
+    raise ValueError("Recursion control value not supported: %s" % (recurse))
+
 class GitSM(Git):
     def supports(self, ud, d):
         """
@@ -95,25 +112,28 @@ class GitSM(Git):
         for module in submodules:
             # Translate the module url into a SRC_URI
 
Quoted 11 lines

lib/bb/fetch2/gitsm.py class GitSM(Git): · line 120

Quoted 7 lines
lib/bb/fetch2/gitsm.py +3 -1
+            recurse = should_recurse(ud)
             if "://" in uris[module]:
                 # Properly formated URL already
                 proto = uris[module].split(':', 1)[0]
-                url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+                desired = "gitsm:" if recurse else "git:"
+                url = uris[module].replace('%s:' % proto, desired, 1)

Above 'desired' is used, below 'scheme' is used. You should use the same variable for both, and set it before the first 'if'. To me 'scheme' is a better variable.

Yep, will address this if we go forward with the approach.

Thanks for the feedback!

Andrew

#3 lore raw
Quoted 4 lines · Andrew Jeffery

Can you expand a bit more on how I'd do this (examples?), or point me in the right direction with documentation? There don't appear to be any pointers in the git:// fetcher section of the mega manual.

I believe you simply need to specify several git:// entries for the submodules you want like for example vulkan-demos does:

SRCREV_glm = "01f9ab5b6d21e5062ac0f6e0f205c7fa2ca9d769" SRCREV_gli = "8e43030b3e12bb58a4663d85adc5c752f89099c0" SRCREV = "ae0b59c6e2e8630a2ae26f4a0b7a72cbe7547948"

SRC_URI = "git://github.com/SaschaWillems/Vulkan.git \
git://github.com/g-truc/glm;destsuffix=git/external/glm;name=glm
\
git://github.com/g-truc/gli;destsuffix=git/external/gli;name=gli
\

file://0001-Don-t-build-demos-with-questionably-licensed-data.patch \
"

In our internal project we ended up converting all gitsm:// recipes to plain 'unfolded' git:// as gitsm:// has a number of issues in the thud release that we tripped over
(I made sure warrior/master does address them).

Alex

#4 lore raw
Quoted 12 lines · Alexander Kanavin
Quoted 3 lines · Andrew Jeffery

Can you expand a bit more on how I'd do this (examples?), or point me in
the right direction with documentation? There don't appear to be any pointers in the git:// fetcher section of the mega manual.

I believe you simply need to specify several git:// entries for the submodules you want like for example vulkan-demos does:

SRCREV_glm = "01f9ab5b6d21e5062ac0f6e0f205c7fa2ca9d769" SRCREV_gli = "8e43030b3e12bb58a4663d85adc5c752f89099c0" SRCREV = "ae0b59c6e2e8630a2ae26f4a0b7a72cbe7547948"

Quoted 5 lines

SRC_URI = "git://github.com/SaschaWillems/Vulkan.git \
git://github.com/g-truc/glm;destsuffix=git/external/glm;name=glm \
git://github.com/g-truc/gli;destsuffix=git/external/gli;name=gli \
file://0001-Don-t-build-demos-with-questionably-licensed-data.patch \
"

Great, this is exactly what I was after.

Thanks!

Andrew

#5 lore raw
In reply to Andrew Jeffery
Quoted 15 lines · Andrew Jeffery

Hi Mark,

Quoted 12 lines · Mark Hatle
Quoted 10 lines · Andrew Jeffery

There exist some use-cases where repositories related by submodules do not require submodules be recursively initialised despite needing the first layer of submodules to be fetched. Enable this usecase in gitsm by implementing a recurse=X SRC_URI parameter. The current implementation of the recurse parameter defaults to enabling exhaustive recursion to match the current behaviour of gitsm, with the one alternative being no recursion. Enough rope is provided to allow specific recursion depths to be implemented if necessary via the same interface. Values currently unsupported for the recurse parameter raise a ValueError to ensure forward compatibility.

Quoted 8 lines
Quoted 4 lines

I was thinking about this patch and I'm not sure it's needed. There are ways to do this without using gitsm.

If you don't want recursion, then why are you specifying 'gitsm' at all?

As far as I'm aware the git fetcher doesn't handle submodules at all. If I have a misunderstanding there and this patch is unnecessary then that's excellent, because I hate it :D

Yes, that is the point. Since it doesn't handle submodules, there it won't recurse and you are fine.

For example:

SRC_URI = "gitsm://github.com/bus1/dbus-broker;protocol=git;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2"

This will result in the following submodules:

Quoted 5 lines

Submodule 'edgelet/hsm-sys/azure-iot-hsm-c/deps/azure-c-shared-utility' (https://github.com/Azure/azure-c-shared-utility.git) registered for path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared' Submodule 'edgelet/hsm-sys/azure-iot-hsm-c/deps/azure-utpm-c' (https://github.com/Azure/azure-utpm-c.git) registered for path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm' Submodule 'testtools/ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'testtools/ctest'
Submodule 'testtools/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'testtools/testrunner'
Submodule 'testtools/umock-c' (https://github.com/Azure/umock-c.git) registered for path 'testtools/umock-c'

Quoted 8 lines

Submodule 'deps/azure-ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'deps/ctest' Submodule 'deps/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'deps/testrunner' Submodule 'deps/c-utility' (https://github.com/Azure/azure-c-shared-utility.git) registered for path 'deps/c-utility' Submodule 'testtools/ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'testtools/ctest' Submodule 'testtools/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'testtools/testrunner' Submodule 'testtools/umock-c' (https://github.com/Azure/umock-c.git) registered for path 'testtools/umock-c' Submodule 'deps/azure-ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'deps/ctest' Submodule 'deps/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'deps/testrunner'

With the following commits:

Quoted 5 lines

Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared': checked out '4deb950a4154e9baa39c87d75dd323dd58e239b7' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c': checked out 'c2c0f18d785ba85fef213302266f520c64201bb1' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/deps/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a'

Quoted 8 lines

Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/deps/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm': checked out 'a82e758bfcea806167e19d9dd94c2e1cc223aaee'
Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility': checked out '4deb950a4154e9baa39c87d75dd323dd58e239b7' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c': checked out 'c2c0f18d785ba85fef213302266f520c64201bb1' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b'

If we clone this WITHOUT gitsm, it would be done as, and only want a subset, we could do:

Quoted 103 lines
SRC_URI = "git://github.com/bus1/dbus-broker;protocol=git;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2 \
           git://github.com/Azure/azure-c-shared-utility.git;protocol=git;subpath=edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared;rev=4deb950a4154e9baa39c87d75dd323dd58e239b7 \
           "
Quoted 4 lines

The
'git' fetcher won't recurse and can be used to pull down a subset of what would have been a recursive fetch. The 'subpath' parameter can even be used to combine the items in the same way as the gitsm fetcher if really needed.

Can you expand a bit more on how I'd do this (examples?), or point me in the right direction with documentation? There don't appear to be any pointers in the git:// fetcher section of the mega manual.

Just for clarity, the repository structure this patch is trying to cater for looks like:

      +---->C
      |
      +---->D
      +
A+--->B+--->E
      +
      +---->F
      |
      +---->G

We have a recipe for A, whose repository has a submodule B, and B has several submodules C, D, E, F, G. Repositories C-G are large and actually irrelevant for the purpose of what we're doing in A, but the content of B is required for A to build.

I hate the patch because the scenario seems like such a corner-case, but here we are with a real-world use-case.

Quoted 49 lines

(A few more comments below, as more of a technical review)

Quoted 46 lines
---
 lib/bb/fetch2/gitsm.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
lib/bb/fetch2/gitsm.py +18 -1
index c622771d21aa..5a8426b486e3 100644
@@ -6,7 +6,15 @@ after cloning.
 
 SRC_URI = "gitsm://<see Git fetcher for syntax>"
 
-See the Git fetcher, git://, for usage documentation.
+Supported SRC_URI options are:
+
+- recurse
+    Control recursive nature of submodule initialisation.
+
+    The default value is -1, which will recursively initialise all submodules.
+    Set to 0 to disable recursiion.
+
+See the Git fetcher, git://, for further usage documentation.
 
 NOTE: Switching a SRC_URI from "git://" to "gitsm://" requires a clean of your recipe.
 
@@ -26,6 +34,15 @@ from   bb.fetch2 import logger
 from   bb.fetch2 import Fetch
 from   bb.fetch2 import BBFetchException
 
+def should_recurse(ud):
+    recurse = ud.parm.get("recurse", "-1")
+
+    # Change this condition if we end up supporting specific maximum depths
+    if recurse in ( "-1", "0" ):
+        return recurse == "-1"
+
+    raise ValueError("Recursion control value not supported: %s" % (recurse))
+
 class GitSM(Git):
     def supports(self, ud, d):
         """
@@ -95,25 +112,28 @@ class GitSM(Git):
         for module in submodules:
             # Translate the module url into a SRC_URI
 
Quoted 11 lines

lib/bb/fetch2/gitsm.py class GitSM(Git): · line 120

Quoted 7 lines
lib/bb/fetch2/gitsm.py +3 -1
+            recurse = should_recurse(ud)
             if "://" in uris[module]:
                 # Properly formated URL already
                 proto = uris[module].split(':', 1)[0]
-                url = uris[module].replace('%s:' % proto, 'gitsm:', 1)
+                desired = "gitsm:" if recurse else "git:"
+                url = uris[module].replace('%s:' % proto, desired, 1)

Above 'desired' is used, below 'scheme' is used. You should use the same variable for both, and set it before the first 'if'. To me 'scheme' is a better variable.

Yep, will address this if we go forward with the approach.

Thanks for the feedback!

Andrew

#6 lore raw
Quoted 65 lines · Mark Hatle
Quoted 15 lines · Andrew Jeffery

Hi Mark,

Quoted 12 lines · Mark Hatle
Quoted 10 lines · Andrew Jeffery

There exist some use-cases where repositories related by submodules do not require submodules be recursively initialised despite needing the first layer of submodules to be fetched. Enable this usecase in gitsm by implementing a recurse=X SRC_URI parameter. The current implementation of the recurse parameter defaults to enabling exhaustive recursion to match the current behaviour of gitsm, with the one alternative being no recursion. Enough rope is provided to allow specific recursion depths to be implemented if necessary via the same interface. Values currently unsupported for the recurse parameter raise a ValueError to ensure forward compatibility.

Quoted 8 lines
Quoted 4 lines

I was thinking about this patch and I'm not sure it's needed. There are ways to do this without using gitsm.

If you don't want recursion, then why are you specifying 'gitsm' at all?

As far as I'm aware the git fetcher doesn't handle submodules at all. If I have a misunderstanding there and this patch is unnecessary then that's excellent, because I hate it :D

Yes, that is the point. Since it doesn't handle submodules, there it won't recurse and you are fine.

For example:

SRC_URI = "gitsm://github.com/bus1/dbus-broker;protocol=git;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2"

This will result in the following submodules:

Quoted 5 lines

Submodule 'edgelet/hsm-sys/azure-iot-hsm-c/deps/azure-c-shared-utility' (https://github.com/Azure/azure-c-shared-utility.git) registered for path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared' Submodule 'edgelet/hsm-sys/azure-iot-hsm-c/deps/azure-utpm-c' (https://github.com/Azure/azure-utpm-c.git) registered for path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm' Submodule 'testtools/ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'testtools/ctest'
Submodule 'testtools/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'testtools/testrunner'
Submodule 'testtools/umock-c' (https://github.com/Azure/umock-c.git) registered for path 'testtools/umock-c'

Quoted 8 lines

Submodule 'deps/azure-ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'deps/ctest' Submodule 'deps/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'deps/testrunner' Submodule 'deps/c-utility' (https://github.com/Azure/azure-c-shared-utility.git) registered for path 'deps/c-utility' Submodule 'testtools/ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'testtools/ctest' Submodule 'testtools/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'testtools/testrunner' Submodule 'testtools/umock-c' (https://github.com/Azure/umock-c.git) registered for path 'testtools/umock-c' Submodule 'deps/azure-ctest' (https://github.com/Azure/azure-ctest.git) registered for path 'deps/ctest' Submodule 'deps/testrunner' (https://github.com/Azure/azure-c-testrunnerswitcher.git) registered for path 'deps/testrunner'

With the following commits:

Quoted 5 lines

Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared': checked out '4deb950a4154e9baa39c87d75dd323dd58e239b7' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c': checked out 'c2c0f18d785ba85fef213302266f520c64201bb1' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/deps/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a'

Quoted 8 lines

Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/deps/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm': checked out 'a82e758bfcea806167e19d9dd94c2e1cc223aaee'
Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility': checked out '4deb950a4154e9baa39c87d75dd323dd58e239b7' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c': checked out 'c2c0f18d785ba85fef213302266f520c64201bb1' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/ctest': checked out 'b1d09aff8212f1fb62ca9d6014cb3509d8b5559a' Submodule path 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/testrunner': checked out '721daafd8c34616f77a7697210470c0227dca20b'

Quoted 8 lines

If we clone this WITHOUT gitsm, it would be done as, and only want a subset, we could do:

Quoted 4 lines
SRC_URI = "git://github.com/bus1/dbus-broker;protocol=git;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2 \
           git://github.com/Azure/azure-c-shared-utility.git;protocol=git;subpath=edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared;rev=4deb950a4154e9baa39c87d75dd323dd58e239b7 \
           "

Makes sense, and I'm pleased we don't need my patch in the end.

Thanks for your help,

Andrew