From 49698d7bd28468368450201566c29bde67979814 Mon Sep 17 00:00:00 2001 From: "Ryan S. Arnold" Date: Fri, 14 Aug 2015 09:26:01 -0500 Subject: lib/checkout.sh: Deliberately checkout HEAD if ${branch} is empty. [https://bugs.linaro.org/show_bug.cgi?id=1751] This patch deliberately checks ${branch} and sets it to HEAD if it is empty (only for checkout()) so that we deliberately checkout HEAD, rather than by happenstance. Otherwise we get git 'fatal' warnings from a malformed checkout which pollute the log and confuse users. Change-Id: Ic21f5c7d61d37b9d5be3ae887c98029ed76378de --- lib/checkout.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/checkout.sh b/lib/checkout.sh index 08a170a7..fc897535 100644 --- a/lib/checkout.sh +++ b/lib/checkout.sh @@ -350,9 +350,9 @@ checkout() dryrun "(cd ${srcdir} && git_robust checkout -B local_${revision})" else # Make sure we are on the correct branch. - # This is a no-op if $branch is empty and it - # just gets master. - dryrun "(cd ${srcdir} && git_robust checkout -B ${branch} origin/${branch})" + # If ${branch} is empty we set it to HEAD and checkout HEAD. + : ${branch:=HEAD} + dryrun "(cd ${srcdir} && git_robust checkout -B local_${branch} origin/${branch})" dryrun "(cd ${srcdir} && git_robust pull)" fi fi -- cgit v1.2.3