devtool: get hooks directory path from git rev-parse
PATCH v2 1/2 devtool: get hooks directory path from git rev-parse
Ask git rev-parse to provide the path to the repo's hooks directory.
This allows devtool to support git submodules, where only the superproject contains a .git directory.
git submodules contain .git files pointing to their parent repo, which confuses devtool when it tries to modify the commit hooks by a manually constructed path.
--- meta/lib/oe/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/patch.py +1 -1
@@ -510,7 +510,7 @@ class GitApplyTree(PatchTree): reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip() if not reporoot: raise Exception("Cannot get repository root for directory %s" % self.dir) - hooks_dir = os.path.join(reporoot, '.git', 'hooks') + hooks_dir = runcmd("git rev-parse --git-path hooks".split(), self.dir) hooks_dir_backup = hooks_dir + '.devtool-orig' if os.path.lexists(hooks_dir_backup): raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup)
Signature · 1 line
2.25.1
PATCH v2 2/2 devtool: don't exec patch commit task funcs for git submodules
When applying a patch directly to a submodule, devtool doesn't need to generate commits for updated submodule revisions, which may differ each time a patch is applied to a devtool workspace. (submodule revision commits would be effectively useless unless the patch is pushed to a remote repo from devtool, at which time a commit should be generated by the user anyway.)
Additionally, attempting to commit new submodule revisions in the parent repo may error with "no changes added to commit" if the patched module is nested within multiple submodules below the parent repo. (Devtool doesn't and shouldn't recusively create commits on each submodule.)
--- scripts/lib/devtool/standard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/lib/devtool/standard.py +2 -1
@@ -569,7 +569,8 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works f.write('DEVTOOL_DEVBRANCH = "%s"\n' % devbranch) if not is_kernel_yocto: f.write('PATCHTOOL = "git"\n') - f.write('PATCH_COMMIT_FUNCTIONS = "1"\n') + if not 'gitsm' in d.getVar('SRC_URI'): + f.write('PATCH_COMMIT_FUNCTIONS = "1"\n') if extra_overrides: f.write('DEVTOOL_EXTRA_OVERRIDES = "%s"\n' % ':'.join(extra_overrides)) f.write('inherit devtool-source\n')
Signature · 1 line
2.25.1