Skip to content

WIP: Repository#attributes_at can traverse nested .gitattributes files

James Edwards-Jones requested to merge jej/gitattributes-recursive-parse into master

What

Adds optional recursive: true param to Repository#attributes_at to allow .gitattributes files in subfolders to be checked.

Currenlty this is a WIP prototype using check-attr with read-tree and a temporary index. We might choose to do this with our existing ruby parser instead.

Why

This is needed so we can determine if files match the LFS filter in https://gitlab.com/gitlab-org/gitlab-ce/issues/29876 and in https://gitlab.com/gitlab-org/gitlab-ce/issues/39785

Git allows .gitattributes files in subfolders, and these are added by lfs track when ran from a subdirectory. Currently we do not properly check these files when processing attributes.

.gitattributes order

https://git-scm.com/docs/gitattributes#_description:

When deciding what attributes are assigned to a path, Git consults $GIT_DIR/info/attributes file (which has the highest precedence), .gitattributes file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree (the further the directory that contains .gitattributes is from the path in question, the lower its precedence). Finally global and system-wide files are considered (they have the lowest precedence).

Acceptance criteria

  • Changelog entry added, if necessary
  • Tests added for this feature/bug
  • Review
    • Has been reviewed by Backend

Related

Builds upon https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16418

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/41984

Merge request reports