diff options
author | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-03-17 10:59:16 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-09-01 14:34:25 +0100 |
commit | 05508339882c7cc1fe3f1f67f72314fdcab979b7 (patch) | |
tree | 2526fdff1f68e321980cc55cb4bc81a867b591d6 | |
parent | a57b24f848a7cb89cf57830e07682224f8bbc96f (diff) | |
download | openembedded-core-05508339882c7cc1fe3f1f67f72314fdcab979b7.tar.gz openembedded-core-05508339882c7cc1fe3f1f67f72314fdcab979b7.tar.bz2 openembedded-core-05508339882c7cc1fe3f1f67f72314fdcab979b7.zip |
kernel-yocto: remove redundant SRCREV check
do_validate_branches checks to ensure that a valid machine SRCREV was
set. A test against an empty SRCREV is done in two separate locations,
we only need one, since the first check immediately returns and the
second check never hits.
At the same time, we can stop referring to the same commit hash by
3 different names. Instead we assign to a local variable at the
top of the routine, and refer to it at all times.
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r-- | meta/classes/kernel-yocto.bbclass | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass index 6010dc94e0..6c92427704 100644 --- a/meta/classes/kernel-yocto.bbclass +++ b/meta/classes/kernel-yocto.bbclass @@ -296,12 +296,14 @@ do_validate_branches() { export KMETA=${KMETA} machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}" + machine_srcrev="${SRCREV_machine}" set +e # if SRCREV is AUTOREV it shows up as AUTOINC there's nothing to # check and we can exit early - if [ "${SRCREV_machine}" = "AUTOINC" ] || [ "${SRCREV_machine}" = "INVALID" ] || - [ "${SRCREV_machine}" = "" ]; then + if [ "${machine_srcrev}" = "AUTOINC" ] || [ "${machine_srcrev}" = "INVALID" ] || + [ "${machine_srcrev}" = "" ]; then + bbnote "INFO: SRCREV validation is not required for AUTOREV or empty/invalid settings, returning" return fi @@ -319,27 +321,16 @@ do_validate_branches() { fi fi - if [ -z "${SRCREV_machine}" ]; then - target_branch_head="${SRCREV}" - else - target_branch_head="${SRCREV_machine}" - fi - - # $SRCREV could have also been AUTOINC, so check again - if [ "${target_branch_head}" = "AUTOINC" ]; then - return - fi - - ref=`git show ${target_branch_head} 2>&1 | head -n1 || true` + ref=`git show ${machine_srcrev} 2>&1 | head -n1 || true` if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then - echo "ERROR ${target_branch_head} is not a valid commit ID." + echo "ERROR ${machine_srcrev} is not a valid commit ID." echo "The kernel source tree may be out of sync" exit 1 fi - containing_branches=`git branch --contains $target_branch_head | sed 's/^..//'` + containing_branches=`git branch --contains $machine_srcrev | sed 's/^..//'` if [ -z "$containing_branches" ]; then - echo "ERROR: SRCREV was set to \"$target_branch_head\", but no branches" + echo "ERROR: SRCREV was set to \"$machine_srcrev\", but no branches" echo " contain this commit" exit 1 fi @@ -349,13 +340,13 @@ do_validate_branches() { git checkout -q master for b in $containing_branches; do branch_head=`git show-ref -s --heads ${b}` - if [ "$branch_head" != "$target_branch_head" ]; then - echo "[INFO] Setting branch $b to ${target_branch_head}" + if [ "$branch_head" != "$machine_srcrev" ]; then + echo "[INFO] Setting branch $b to ${machine_srcrev}" if [ "$b" = "master" ]; then - git reset --hard $target_branch_head > /dev/null + git reset --hard $machine_srcrev > /dev/null else git branch -D $b > /dev/null - git branch $b $target_branch_head > /dev/null + git branch $b $machine_srcrev > /dev/null fi fi done |