Skip to contentSkip to conversation

fetch2/git: fix HEAD and branch ref when subpath is used

PATCH Superseded Mark-PK Tsai 2 participants 3 messages Apr 15 – Apr 16

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 6ed14005b..21f5f28a0 100644
@@ -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
#1 lore raw

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?

https://git.openembedded.org/bitbake/tree/doc/bitbake-user-manual/bitbake-user-manual-fetching.rst#n428

Thanks,
Antonin

#2 lore raw
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?

https://urldefense.com/v3/__https://git.openembedded.org/bitbake/tree/doc/bitbake-user-manual/bitbake-user-manual-fetching.rst*n428__;Iw!!CTRNKA9wMg0ARbw!glJbRSkEd8P_hdbEWwJEMDsYXGJhez1iBKQZhnqx8swFNF98NnhluX8KkTZVt3uVyZJcJDtnDPjqLqL03s0hxLGICalfTwQ$

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