fetch2/git: fix HEAD and branch ref when subpath is used
PATCH 1/1 fetch2/git: fix HEAD and branch ref when subpath is used
From: Mark-Pk Tsai <[email protected]>
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.
--- lib/bb/fetch2/git.py | 6 ++++++ 1 file changed, 6 insertions(+)
lib/bb/fetch2/git.py +6 -0
@@ -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, \
Signature · 1 line
2.43.0
Hi,
Quoted 8 lines · Mark-PK Tsai via lists.openembedded.org
From: Mark-Pk Tsai <[email protected]>
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?
Thanks,
Antonin
Quoted 12 lines · Antonin Godard
Hi,
Quoted 8 lines · Mark-PK Tsai via lists.openembedded.org
From: Mark-Pk Tsai <[email protected]>
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.
Quoted 9 lines
Quoted 3 lines
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?
Thank you for pointing that out. I have removed the warning note in v2. Could you please take a look?
Quoted 2 lines
Thanks,
Antonin