That's because I was using .lfsconfig instead of .gitattributes in "contains_lfs" function. self-tests only use the latter.
I've send v2 patches.

Richard Purdie <richard.purdie@linuxfoundation.org> escreveu no dia sexta, 29/05/2020 à(s) 06:46:
On Thu, 2020-05-28 at 15:18 +0100, Mauro Queirós wrote:
> Git-LFS objects were being fetched even when lfs=0 was not set.
> This patch disables LFS smudging when lfs=0. That way, only the LFS
> pointers
> are downloaded during checkout.
>
> Signed-off-by: Mauro Queiros <maurofrqueiros@gmail.com>
> ---
>  lib/bb/fetch2/git.py | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index 5b3793a7..4c7d388e 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -475,6 +475,9 @@ class Git(FetchMethod):

>          need_lfs = ud.parm.get("lfs", "1") == "1"

> +        if not need_lfs:
> +            ud.basecmd = "GIT_LFS_SKIP_SMUDGE=1 " + ud.basecmd
> +
>          source_found = False
>          source_error = []

Thanks for the patches, the sound good. Unfortunately they cause
bitbake-selftest to fail:

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/991/steps/8/logs/step1d

Cheers,

Richard