[oe-commits] Patrick Ohly : combo-layer: fix action_pull for unknown branch

git at git.openembedded.org git at git.openembedded.org
Fri Aug 7 03:50:29 UTC 2015


Module: openembedded-core.git
Branch: master-next
Commit: 39edf84315e75225bf79f7ea55514e4c49d2fd6d
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=39edf84315e75225bf79f7ea55514e4c49d2fd6d

Author: Patrick Ohly <patrick.ohly at intel.com>
Date:   Tue Aug  4 18:24:00 2015 +0200

combo-layer: fix action_pull for unknown branch

When reconfiguring the branch to something not already fetched,
action_pull fails with
   error: pathspec '<new branch name>' did not match any file(s) known to git.

It is the "git checkout" which fails like that. To solve this,
try the faster "git checkout + git pull" first and only if that fails,
fall back to the slow "git fetch + git checkout".

In the conf.hard_reset case, do the checkout always after the git fetch.

Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 scripts/combo-layer | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/scripts/combo-layer b/scripts/combo-layer
index 7380f5b..7435a17 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -586,13 +586,25 @@ def action_pull(conf, args):
         ldir = repo['local_repo_dir']
         branch = repo.get('branch', "master")
         logger.info("update branch %s of component repo %s in %s ..." % (branch, name, ldir))
-        runcmd("git checkout %s" % branch, ldir)
         if not conf.hard_reset:
-            output=runcmd("git pull --ff-only", ldir)
-            logger.info(output)
+            # Try to pull only the configured branch. Beware that this may fail
+            # when the branch is currently unknown (for example, after reconfiguring
+            # combo-layer). In that case we need to fetch everything and try the check out
+            # and pull again.
+            try:
+                runcmd("git checkout %s" % branch, ldir, printerr=False)
+            except subprocess.CalledProcessError:
+                output=runcmd("git fetch", ldir)
+                logger.info(output)
+                runcmd("git checkout %s" % branch, ldir)
+                runcmd("git pull --ff-only", ldir)
+            else:
+                output=runcmd("git pull --ff-only", ldir)
+                logger.info(output)
         else:
             output=runcmd("git fetch", ldir)
             logger.info(output)
+            runcmd("git checkout %s" % branch, ldir)
             runcmd("git reset --hard FETCH_HEAD", ldir)
 
 def action_update(conf, args):



More information about the Openembedded-commits mailing list