[OE-core] [PATCH] devtool: improve git repo checks before check_commits logic

Dan Dedrick dan.dedrick at gmail.com
Mon Jan 21 20:15:27 UTC 2019


The check_commits logic assumes that both devtool-base and args.branch
exist in the git repo that it is operating on. In order to prevent
errors at that point it's best to first ensure that both of these refs
actually exist. If they don't both exist then the check_commits logic
should just be skipped, as it would be if the repo wasn't originally
checked out by devtool.

Previously if a user removed the args.branch branch from their devtool
cloned repo this code would crash on adding the repo with -n. The crash
would look like this:

Traceback (most recent call last):
  File "/home/ddedrick/src/poky/scripts/devtool", line 344, in <module>
    ret = main()
  File "/home/ddedrick/src/poky/scripts/devtool", line 331, in main
    ret = args.func(args, config, basepath, workspace)
  File "/home/ddedrick/src/poky/scripts/lib/devtool/standard.py", line 812, in modify
    (stdout, _) = bb.process.run('git log devtool-base..%s' % branch, cwd=srctree)
  File "/home/ddedrick/src/poky/bitbake/lib/bb/process.py", line 178, in run
    raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
bb.process.ExecutionError: Execution of 'git log devtool-base..devtool' failed with exit code 128:
fatal: ambiguous argument 'devtool-base..devtool': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
---
 scripts/lib/devtool/standard.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index d14b7a6543..328b5cf02e 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -769,9 +769,13 @@ def modify(args, config, basepath, workspace):
             check_commits = True
         else:
             if os.path.exists(os.path.join(srctree, '.git')):
-                # Check if it's a tree previously extracted by us
+                # Check if it's a tree previously extracted by us. This is done
+                # by ensuring that devtool-base and args.branch (devtool) exist.
+                # The check_commits logic will cause an exception if either one
+                # of these doesn't exist
                 try:
                     (stdout, _) = bb.process.run('git branch --contains devtool-base', cwd=srctree)
+                    bb.process.run('git rev-parse %s' % args.branch, cwd=srctree)
                 except bb.process.ExecutionError:
                     stdout = ''
                 if stdout:
-- 
2.20.1



More information about the Openembedded-core mailing list