java.lang.Object
org.eclipse.jgit.attributes.AttributesHandler
The attributes handler knows how to retrieve, parse and merge attributes from
the various gitattributes files. Furthermore it collects and expands macro
expressions. The method
getAttributes()
yields the ready processed
attributes for the current path represented by the
TreeWalk
The implementation is based on the specifications in http://git-scm.com/docs/gitattributes
- Since:
- 4.3
-
Constructor Summary
ConstructorsConstructorDescriptionAttributesHandler
(TreeWalk treeWalk) Deprecated.AttributesHandler
(TreeWalk treeWalk, Supplier<CanonicalTreeParser> attributesTree) Create anAttributesHandler
with default rules as well as merged rules from global, info and worktree root attributes -
Method Summary
Modifier and TypeMethodDescriptionprotected void
expandMacro
(Attribute attr, Attributes result) Expand a macroprotected void
mergeAttributes
(AttributesNode node, String entryPath, boolean isDirectory, Attributes result) Merges the matching node attributes for an entry path.
-
Constructor Details
-
AttributesHandler
Deprecated.since 6.1, useAttributesHandler(TreeWalk, Supplier)
insteadCreate anAttributesHandler
with default rules as well as merged rules from global, info and worktree root attributes- Parameters:
treeWalk
- aTreeWalk
- Throws:
IOException
- if an IO error occurred
-
AttributesHandler
public AttributesHandler(TreeWalk treeWalk, Supplier<CanonicalTreeParser> attributesTree) throws IOException Create anAttributesHandler
with default rules as well as merged rules from global, info and worktree root attributes- Parameters:
treeWalk
- aTreeWalk
attributesTree
- the tree to read .gitattributes from- Throws:
IOException
- if an IO error occurred- Since:
- 6.1
-
-
Method Details
-
getAttributes
- Returns:
- the
Attributes
for the current path represented by theTreeWalk
- Throws:
IOException
- if an IO error occurred
-
mergeAttributes
protected void mergeAttributes(@Nullable AttributesNode node, String entryPath, boolean isDirectory, Attributes result) Merges the matching node attributes for an entry path.- Parameters:
node
- the node to scan for matches to entryPathentryPath
- the path to test. The path must be relative to this attribute node's own repository path, and in repository path format (uses '/' and not '\').isDirectory
- true if the target item is a directory.result
- that will hold the attributes matching this entry path. This method will NOT override any existing entry in attributes.
-
expandMacro
Expand a macro- Parameters:
attr
- aAttribute
result
- contains the (recursive) expanded and merged macro attributes including the attribute iself
-
AttributesHandler(TreeWalk, Supplier)
instead