aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2017-02-15 22:20:25 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2017-02-16 13:14:26 +0000
commit94d268b8c92edc9860e6aad3f8d96ca44d3c91a6 (patch)
treed6e58a59cb595c706e4f2b64f08fb86218d1e160
parentee36efafa133ee0c8313485a392e29258107a4e5 (diff)
lib/component.sh: Support new git-branch output format.
After checking out a revision, 'git branch' version 1.9.1 from trusty used to report: * (detached from 833c70b) As of version 2.7.4 (trusty), the same command generates: * (HEAD detached at 833c70b) Since we used to check the presence of detached in the 2nd field, we get '(HEAD' instead of the expected '(detached' which confuses collect_data/component_init. This patch fixes this by adding '^(HEAD' in the expected strings. Otherwise, this causes parser errors when $branch='(HEAD' and at some point the script evaluates something like abe[BRANCH]=(HEAD (at line 59). Change-Id: I856f200ebee72fca38b0074bb49549c291b6140d
-rw-r--r--lib/component.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/component.sh b/lib/component.sh
index 0581c7dc..9e5a0104 100644
--- a/lib/component.sh
+++ b/lib/component.sh
@@ -526,7 +526,7 @@ collect_data ()
local revision="$(git log --format=format:%H -n 1)"
local abbrev="$(git log --format=format:%h -n 1)"
local branch="$(git branch | grep "^\*" | cut -d ' ' -f 2)"
- if test "$(echo ${branch} | egrep -c "detached|^\(no")" -gt -0; then
+ if test "$(echo ${branch} | egrep -c "detached|^\(no|^\(HEAD")" -gt -0; then
local branch=
fi
local url="$(git config --get remote.origin.url)"