Skip to contentSkip to conversation

metadata_scm.bbclass: get the metadata revision for current HEAD

PATCH In review Khem Raj 3 participants 8 messages Nov 3, 2010 – Nov 4, 2010

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 metadata_scm.bbclass: get the metadata revision for current HEAD

Currently we report wrong revision when we build from branches not based on master because we only fetch the HEAD value which is remote master This patch makes it to report the HEAD of whatever branch one has checked out.

---
 classes/metadata_scm.bbclass |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
classes/metadata_scm.bbclass +2 -1
index ffc6a8a..37024b7 100644
@@ -70,7 +70,8 @@ def base_get_metadata_git_branch(path, d):
 	return "<unknown>"
 
 def base_get_metadata_git_revision(path, d):
-	rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip()
+	branch = os.path.basename(base_get_metadata_git_branch(path, d))
+	rev = os.popen("cd %s; PATH=%s git show-ref HEAD %s 2>/dev/null" % (path, d.getVar("PATH", 1), branch)).read().split(" ")[0].rstrip()
 	if len(rev) != 0:
 		return rev
 	return "<unknown>"
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Khem Raj

Currently we report wrong revision when we build from branches not based on master because we only fetch the HEAD value which is remote master This patch makes it to report the HEAD of whatever branch one has checked out.

This doesn't make sense. The HEAD ref always points to the current checked out commit or branch, it is *not* specific to master.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
Acked-by
#2 lore raw
Quoted 10 lines · Chris Larson
Quoted 5 lines · Khem Raj

Currently we report wrong revision when we build from branches not based on master because we only fetch the HEAD value which is remote master This patch makes it to report the HEAD of whatever branch one has checked out.

This doesn't make sense. The HEAD ref always points to the current checked out commit or branch, it is *not* specific to master.

No it does make sense, because it fixes my <unknown> METADATA_REVISION :).

in my R/W checkout I have it right even before patch

bitbake@jama ~/oe $ git show-ref HEAD b3246d96069fd11caee42ec6ebcbf6dca2d62449 refs/remotes/origin/HEAD

OE om-gta02@shr ~/oe $ git remote -v
jama /OE/dev/ (fetch)
jama /OE/dev/ (push)
....
origin [email protected]:openembedded (fetch) origin [email protected]:openembedded (push)

but in my "work" checkout, where I have this R/W used as origin bitbake@jama ~/dev $ git show-ref HEAD -> nothing

OE om-gta02@shr ~/dev $ git remote -v
gitorious [email protected]:~jama/angstrom/jama-shr-experimental.git (fetch) gitorious [email protected]:~jama/angstrom/jama-shr-experimental.git (push)
....
origin /OE/oe/ (fetch)
origin /OE/oe/ (push)

Regards,

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#3 lore raw
Quoted 14 lines · Martin Jansa
Quoted 3 lines · Chris Larson
Quoted 1 line · Khem Raj

Currently we report wrong revision when we build from branches not

based

Quoted 6 lines
Quoted 4 lines

on master because we only fetch the HEAD value which is remote master This patch makes it to report the HEAD of whatever branch one has checked out.

This doesn't make sense. The HEAD ref always points to the current

checked

Quoted 1 line

out commit or branch, it is *not* specific to master.

Quoted 8 lines

No it does make sense, because it fixes my <unknown> METADATA_REVISION :).

in my R/W checkout I have it right even before patch

bitbake@jama ~/oe $ git show-ref HEAD b3246d96069fd11caee42ec6ebcbf6dca2d62449 refs/remotes/origin/HEAD

No, this is broken. It shouldn't be determining the METADATA_REVISION from a ref you don't even have checked out. Right now it's pulling the HEAD ref from upstream, it should be pulling the local HEAD ref. So NACK on this patch, the metadata revision code needs to be fixed to either not use show-ref or pass the necessary args to not operate based on a HEAD of a remote.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
author
#4 lore raw
Quoted 26 lines · Chris Larson
Quoted 14 lines · Martin Jansa
Quoted 3 lines · Chris Larson
Quoted 1 line · Khem Raj

Currently we report wrong revision when we build from branches not

based

Quoted 6 lines
Quoted 4 lines

on master because we only fetch the HEAD value which is remote master This patch makes it to report the HEAD of whatever branch one has checked out.

This doesn't make sense.  The HEAD ref always points to the current

checked

Quoted 1 line

out commit or branch, it is *not* specific to master.

Quoted 8 lines

No it does make sense, because it fixes my <unknown> METADATA_REVISION :).

in my R/W checkout I have it right even before patch

bitbake@jama ~/oe $ git show-ref HEAD b3246d96069fd11caee42ec6ebcbf6dca2d62449 refs/remotes/origin/HEAD

Quoted 6 lines

No, this is broken.  It shouldn't be determining the METADATA_REVISION from a ref you don't even have checked out.  Right now it's pulling the HEAD ref from upstream, it should be pulling the local HEAD ref.  So NACK on this patch, the metadata revision code needs to be fixed to either not use show-ref or pass the necessary args to not operate based on a HEAD of a remote.

whats wrong with this patch. or what is it that we need additionally.

Quoted 11 lines

--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#5 lore raw
Quoted 6 lines · Khem Raj
Quoted 5 lines
Quoted 2 lines

bitbake@jama ~/oe $ git show-ref HEAD b3246d96069fd11caee42ec6ebcbf6dca2d62449 refs/remotes/origin/HEAD

No, this is broken. It shouldn't be determining the METADATA_REVISION

from

Quoted 8 lines
Quoted 1 line

a ref you don't even have checked out. Right now it's pulling the HEAD

ref

Quoted 4 lines

from upstream, it should be pulling the local HEAD ref. So NACK on this patch, the metadata revision code needs to be fixed to either not use show-ref or pass the necessary args to not operate based on a HEAD of a remote.

whats wrong with this patch. or what is it that we need additionally.

The issue is, show-ref shows all refs which match the supplied search string. show-ref HEAD will show all the HEAD refs, both local and the ones in all your remotes, which isn't what we want for METADATA_REVISION. I'm testing a patch which changes it to use rev-parse to get the commit hash for HEAD rather than show-ref. Thanks for catching this, by the way, I don't want to sound unappreciative, its just that this patch is more of a workaround, rather than a fix for the root problem. :)

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
author
#6 lore raw
Quoted 15 lines · Chris Larson
Quoted 13 lines · Khem Raj
Quoted 5 lines
Quoted 2 lines

bitbake@jama ~/oe $ git show-ref HEAD b3246d96069fd11caee42ec6ebcbf6dca2d62449 refs/remotes/origin/HEAD

No, this is broken.  It shouldn't be determining the METADATA_REVISION

from

Quoted 1 line

a ref you don't even have checked out.  Right now it's pulling the HEAD

ref

Quoted 4 lines

from upstream, it should be pulling the local HEAD ref.  So NACK on this patch, the metadata revision code needs to be fixed to either not use show-ref or pass the necessary args to not operate based on a HEAD of a remote.

Quoted 8 lines
Quoted 1 line

whats wrong with this patch. or what is it that we need additionally.

The issue is, show-ref shows all refs which match the supplied search string.  show-ref HEAD will show all the HEAD refs, both local and the ones in all your remotes, which isn't what we want for METADATA_REVISION.  I'm testing a patch which changes it to use rev-parse to get the commit hash for HEAD rather than show-ref.

FWIW you could also use git show-ref --head <branch>

Thanks for catching this, by the way, I don't

Quoted 13 lines

want to sound unappreciative, its just that this patch is more of a workaround, rather than a fix for the root problem. :) --
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#7 lore raw
Quoted 9 lines · Khem Raj
Quoted 2 lines

The issue is, show-ref shows all refs which match the supplied search string. show-ref HEAD will show all the HEAD refs, both local and the

ones

Quoted 2 lines

in all your remotes, which isn't what we want for METADATA_REVISION. I'm testing a patch which changes it to use rev-parse to get the commit hash

for

Quoted 1 line

HEAD rather than show-ref.

FWIW you could also use git show-ref --head <branch>

Yeah, that will work if the <branch> is the full path including refs/heads/, but it's not using the right plumbing tool for the job. show-ref is designed to *list* refs in the repo, not resolve a single one.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics