diff mbox series

fetch2/git: ignore comments in .gitattributes when detecting LFS

Message ID 20250728143543.2896652-1-skandigraun@gmail.com
State New
Headers show
Series fetch2/git: ignore comments in .gitattributes when detecting LFS | expand

Commit Message

Gyorgy Sarvari July 28, 2025, 2:35 p.m. UTC
Fixes [YOCTO 15917]

When fetching a git repository the .gitattributes file is scanned, checking if LFS
support is required for the repository. This scan checks if the word "lfs" is present
in the file, however the used regex doesn't account for comments, which makes some
repositories[1] be to misidentified as requiring LFS support (which fails fetching, in case
lfs support isn't installed on the build host).

To avoid it, change the used regex to ignore lines starting with "#".

[1]: e.g. https://github.com/MicrochipTech/cryptoauthlib

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 bitbake/lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 14ec45a3f6..ecaf0a49af 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -829,7 +829,7 @@  class Git(FetchMethod):
         """
         Check if the repository has 'lfs' (large file) content
         """
-        cmd = "%s grep lfs %s:.gitattributes | wc -l" % (
+        cmd = "%s grep '^[^#].*lfs' %s:.gitattributes | wc -l" % (
             ud.basecmd, ud.revision)
 
         try: