gitattributes not applying in subdirectories

Summary

Files in subdirectories do not seem to be tagged correctly with the gitlab-language attribute, but those same files are tagged correctly in the repository root.

They should be treated the same because git shows the same attributes on both when checked with git check-attr.

Steps to reproduce

  1. Create a file with an unknown extension in the repository root; e.g., Dockerfile.local
  2. Create a file with the same unknown extension in a subdirectory; e.g., docker/Dockerfile.local
  3. Add a rule to .gitattributes to give those files the gitlab-language attribute, e.g., Dockerfile.* gitlab-language=dockerfile
  4. Observe that the file in the repository root is correctly highlighted, but the one in the subdirectory is not
  5. Observe that both files have the same attributes when queried with git check-attr -a

Example Project

https://gitlab.com/iamthad/gitattributes-bug-repro

What is the current bug behavior?

The file in the subdirectory is not highlighted as specified by the gitlab-language attribute, unlike the file in the repository root.

What is the expected correct behavior?

The file in the subdirectory should be highlighted as specified by the gitlab-language attribute, just like the file in the repository root is.

Relevant logs and/or screenshots

Screenshot_2025-01-16_140431 Screenshot_2025-01-16_140509

Output of checks

This bug happens on GitLab.com