Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mail.openembedded.org (Postfix) with ESMTP id E160D62132 for ; Wed, 18 May 2016 09:32:03 +0000 (UTC) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 18 May 2016 02:31:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,328,1459839600"; d="scan'208";a="957072406" Received: from marquiz.fi.intel.com ([10.237.72.155]) by orsmga001.jf.intel.com with ESMTP; 18 May 2016 02:31:42 -0700 From: Markus Lehtonen To: bitbake-devel@lists.openembedded.org Date: Wed, 18 May 2016 12:31:41 +0300 Message-Id: <1463563901-3979-1-git-send-email-markus.lehtonen@linux.intel.com> X-Mailer: git-send-email 2.6.6 Subject: [PATCH] fetch2/git: allow using 'HEAD' as a branch name X-BeenThere: bitbake-devel@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussion that advance bitbake development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2016 09:32:09 -0000 This change makes it possible to e.g. build a currently checked out revision of a local Git repository and use AUTOREV. It will be possible to build HEAD of remote repositories, too, of course, but this is probably not that practical. In order to use this one must also use the nobranch parameter, i.e. have 'branch=HEAD;nobranch=1' in the SRC_URI, because 'HEAD' is really not a Git branch as such. The wording in "branch=HEAD;nobranch=1" is probably a bit counter-intuitive and illogical but this seems to be the only easy way to make this work without complicating the fetcher even further. Another solution would be e.g. to introduce an alternative 'ref' parameter which could be used in place of 'branch' to give any ref. The effect would basically be the same (with better wording) with yet a bit more complex fetcher code. [YOCTO #9351] Signed-off-by: Markus Lehtonen --- lib/bb/fetch2/git.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index 526668b..99d7dc1 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -344,12 +344,15 @@ class Git(FetchMethod): output = self._lsremote(ud, d, "") # Tags of the form ^{} may not work, need to fallback to other form if ud.unresolvedrev[name][:5] == "refs/": - head = ud.unresolvedrev[name] - tag = ud.unresolvedrev[name] + search_list = [ud.unresolvedrev[name], + ud.unresolvedrev[name] + "^{}"] + elif ud.unresolvedrev[name] == 'HEAD': + search_list = ['HEAD'] else: head = "refs/heads/%s" % ud.unresolvedrev[name] tag = "refs/tags/%s" % ud.unresolvedrev[name] - for s in [head, tag + "^{}", tag]: + search_list = [head, tag + "^{}", tag] + for s in search_list: for l in output.split('\n'): if s in l: return l.split()[0] -- 2.6.6