| Message ID | 20260415025829.2342719-1-mark-pk.tsai@mediatek.com |
|---|---|
| State | New |
| Headers | show |
| Series | fetch2/git: fix HEAD and branch ref when subpath is used | expand |
Hi, On Wed Apr 15, 2026 at 4:58 AM CEST, Mark-PK Tsai via lists.openembedded.org wrote: > From: Mark-Pk Tsai <mark-pk.tsai@mediatek.com> > > When subpath is set the checkout code uses read-tree + checkout-index, > but never updates HEAD. It stays on whatever branch the clone defaulted > to instead of pointing to the requested revision. > > Fix by pointing HEAD at the correct revision after checkout-index, and > creating the branch ref when branch= is specified. Can you remove this warning note with your patch? https://git.openembedded.org/bitbake/tree/doc/bitbake-user-manual/bitbake-user-manual-fetching.rst#n428 Thanks, Antonin
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index 6ed14005b..21f5f28a0 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -787,6 +787,12 @@ class Git(FetchMethod): runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revision, readpathspec), d, workdir=destdir) runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d, workdir=destdir) + runfetchcmd("%s update-ref --no-deref HEAD %s" % (ud.basecmd, ud.revision), + d, workdir=destdir) + if not ud.nobranch: + branchname = ud.branch + runfetchcmd("%s update-ref refs/heads/%s %s" % (ud.basecmd, branchname, + ud.revision), d, workdir=destdir) elif not ud.nobranch: branchname = ud.branch runfetchcmd("%s checkout -B %s %s" % (ud.basecmd, branchname, \