Skip to content

externalsrc: Detect code changes in submodules

Douglas openembedded-core 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Revert "externalsrc: Detect code changes in submodules"meta/classes/externalsrc.bbclass+7 -91 reply
2/2externalsrc: Detect code changes in submodulesmeta/classes/externalsrc.bbclass+6 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] externalsrc: Detect code changes in submodules

Further to 50ff9afb39, only detect code changes in submodules that are subdirectories of the EXTERNALSRC directory.

The (undocumented) git submodule--helper returns a path for each submodule relative to the top of the repo. Don't add submodules that are not within our EXTERNALSRC subtree.

If we unpack one git repo inside another, like this:

    SRC_URI = "git://${GIT_SERVER}/repo1;name=repo1;destsuffix=repo1 \
               git://${GIT_SERVER}/repo2;name=repo2;destsuffix=repo1/repo2 \
               "

Git status reports, for repo1:

Untracked files:
(use "git add <file>..." to include in what will be committed)
repo2/

If we run devtool modify on this recipe, do_patch runs with:

PATCHTOOL = "git"
PATCH_COMMIT_FUNCTIONS = "1"

The patch_task_postfunc (patch.bbclass, line 82) runs a git add . on the top-level repo1, leaving the checkout in an invalid state. The following git warning does not appear in the log:

    $ git add .
    warning: adding embedded git repository: repo2
    hint: You've added another git repository inside your current repository.
    hint: Clones of the outer repository will not contain the contents of
    hint: the embedded repository and will not know how to obtain it.
    hint: If you meant to add a submodule, use:
    hint:
    hint: 	git submodule add <url> repo2
    hint:
    hint: If you added this path by mistake, you can remove it from the
    hint: index with:
    hint:
    hint: 	git rm --cached repo2
    hint:
    hint: See "git help submodule" for more information.
    $ git submodule status
    fatal: no submodule mapping found in .gitmodules for path 'repo2'

No further git submodule commands can be run on the checkout.

We could enhance the patch_task_postfunc to look for any embedded git checkouts and add them as submodules, but this seems unnecessary complexity for an obscure edge-case. Although the git repo is left in an invalid state with respect to the submodules, it still serves the purpose required by devtool:
To take further commits, and generate patch files from them.

We are still able to run these commands to examine any submodules, where git submodule--helper reports paths relative to the top of the checkout:

    $ git ls-files --stage | grep ^160000
    160000 5feee12d6e974dd8c0614cf5b593380b046439a5 0   repo2
    $ git submodule--helper list
    160000 5feee12d6e974dd8c0614cf5b593380b046439a5 0   repo2

When a recipe sets EXTERNALSRC to a subdirectory of the git checkout, we test for the existence of the reported submodule paths within the EXTERNALSRC directory.

The latest versions of git submodule--helper accept a path to a subdirectory and correctly report no submodules within that subdirectory. Regrettably, we still support git versions that don't accept a path to a subdirectory.

[YOCTO #14333]

Douglas Royds (2):
Revert "externalsrc: Detect code changes in submodules"
externalsrc: Detect code changes in submodules

 meta/classes/externalsrc.bbclass | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1