Skip to content

Optionally read .gitattributes from HEAD#5189

Merged
ethomson merged 15 commits intomasterfrom
ethomson/attrs_from_head
Aug 27, 2019
Merged

Optionally read .gitattributes from HEAD#5189
ethomson merged 15 commits intomasterfrom
ethomson/attrs_from_head

Conversation

@ethomson
Copy link
Copy Markdown
Member

Currently, we honor .gitattributes, behaving like git - reading from the working directory and / or the index. We do not read any attributes out of HEAD.

However, some consumers may want to examine a bare repository, and read the file contents as if the filters were being applied. Provide an update to git_blob_filter that take a new option to indicate that filters should be read from HEAD.

Deprecate git_blob_filtered_content in favor of git_blob_filter.

Add a LF->CRLF conversion test to the blob filter.
Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pleasant read, thanks a lot! :) Some comments, but overall this looks really good to me

Provide a function to filter blobs that allows for more functionality
than the existing `git_blob_filtered_content` function.
Move users of `git_blob_filtered_content` to `git_blob_filter`.
Users should now use `git_blob_filter`.
By default, `/etc/gitattributes` (or the system equivalent) is read to
provide attributes.  Ensure that, by default, this is read when
filtering blobs.
Test that we can optionally ignore system attributes when filtering a
blob.
Allow system-wide attributes (the ones specified in
`/etc/gitattributes`) to be ignored if the flag
`GIT_FILTER_NO_SYSTEM_ATTRIBUTES` is specified.
Introduce `GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES`, which tells
`git_blob_filter` to ignore the system-wide attributes file, usually
`/etc/gitattributes`.

This simply passes the appropriate flag to the attribute loading code.
When `GIT_ATTR_CHECK_INCLUDE_HEAD` is specified, read `gitattribute`
files that are checked into the repository at the HEAD revision.
When `GIT_FILTER_ATTRIBUTES_FROM_HEAD` is specified, configure the
filter to read filter attributes from `gitattributes` files that are
checked in to the repository at the HEAD revision.  This passes the flag
`GIT_ATTR_CHECK_INCLUDE_HEAD` to the attribute reading functions.
When `GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD` is passed to
`git_blob_filter`, read attributes from `gitattributes` files that
are checked in to the repository at the HEAD revision.  This passes
the flag `GIT_FILTER_ATTRIBUTES_FROM_HEAD` to the filter functions.
@ethomson ethomson force-pushed the ethomson/attrs_from_head branch from 871a8ed to 21c196e Compare August 11, 2019 19:49
Add a subdirectory in the crlf.git bare repository that has a
second-level .gitattribute file.
Ensure that a `.gitattributes` file that is deeper in the tree is
honored, not just an attributes file at the root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants