Package org.eclipse.jgit.attributes
Class AttributesHandler
- java.lang.Object
-
- org.eclipse.jgit.attributes.AttributesHandler
-
public class AttributesHandler extends Object
The attributes handler knows how to retrieve, parse and merge attributes from the various gitattributes files. Furthermore it collects and expands macro expressions. The methodgetAttributes()
yields the ready processed attributes for the current path represented by theTreeWalk
The implementation is based on the specifications in http://git-scm.com/docs/gitattributes
- Since:
- 4.3
-
-
Constructor Summary
Constructors Constructor Description AttributesHandler(TreeWalk treeWalk)
Deprecated.since 6.1, useAttributesHandler(TreeWalk, Supplier)
insteadAttributesHandler(TreeWalk treeWalk, Supplier<CanonicalTreeParser> attributesTree)
Create anAttributesHandler
with default rules as well as merged rules from global, info and worktree root attributes
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
expandMacro(Attribute attr, Attributes result)
Expand a macroAttributes
getAttributes()
protected void
mergeAttributes(AttributesNode node, String entryPath, boolean isDirectory, Attributes result)
Merges the matching node attributes for an entry path.
-
-
-
Constructor Detail
-
AttributesHandler
@Deprecated public AttributesHandler(TreeWalk treeWalk) throws IOException
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
-
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
- Since:
- 6.1
-
-
Method Detail
-
getAttributes
public Attributes getAttributes() throws IOException
- Returns:
- the
Attributes
for the current path represented by theTreeWalk
- Throws:
IOException
-
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
protected void expandMacro(Attribute attr, Attributes result)
Expand a macro- Parameters:
attr
- aAttribute
result
- contains the (recursive) expanded and merged macro attributes including the attribute iself
-
-