gitver: fix non-symbolic HEAD ref
authorChris Larson <chris_larson@mentor.com>
Wed, 27 Oct 2010 21:54:20 +0000 (14:54 -0700)
committerChris Larson <chris_larson@mentor.com>
Wed, 27 Oct 2010 22:06:23 +0000 (15:06 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
classes/gitver.bbclass

index de182a0..28256c6 100644 (file)
@@ -32,17 +32,16 @@ def get_git_pv(path, d, tagadjust=None):
     # if the active branch is switched, or if the branch changes.
     mark_dependency(d, os.path.join(gitdir, "HEAD"))
 
-    ref = git(["symbolic-ref", "HEAD"])
-    if ref:
-        reffile = os.path.join(gitdir, ref)
-        if os.path.exists(reffile):
-            mark_dependency(d, reffile)
-        else:
-            mark_dependency(d, os.path.join(gitdir, "index"))
+    # Force a reparse if anything in the index changes.
+    mark_dependency(d, os.path.join(gitdir, "index"))
+
+    try:
+        ref = oe_run(d, ["git", "symbolic-ref", "-q", "HEAD"], cwd=gitdir).rstrip()
+    except oe.process.CmdError:
+        pass
     else:
-        # The ref might be hidden in packed-refs. Force a reparse if anything
-        # in the working copy changes.
-        mark_dependency(d, os.path.join(gitdir, "index"))
+        if ref:
+            mark_dependency(d, os.path.join(gitdir, ref))
 
     # Catch new tags.
     tagdir = os.path.join(gitdir, "refs", "tags")