public class AttributesHandler
extends java.lang.Object
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
| Modifier and Type | Field and Description |
|---|---|
private static java.util.List<Attribute> |
BINARY_RULE_ATTRIBUTES
This is the default binary rule that is present in any git folder
[attr]binary -diff -merge -text |
private static java.lang.String |
BINARY_RULE_KEY |
private java.util.Map<java.lang.String,java.util.List<Attribute>> |
expansions |
private AttributesNode |
globalNode |
private AttributesNode |
infoNode |
private static java.lang.String |
MACRO_PREFIX |
private TreeWalk |
treeWalk |
| Constructor and Description |
|---|
AttributesHandler(TreeWalk treeWalk)
Create an
AttributesHandler with
default rules as well as merged rules from global, info and worktree root
attributes |
| Modifier and Type | Method and Description |
|---|---|
private static AttributesNode |
attributesNode(TreeWalk treeWalk,
WorkingTreeIterator workingTreeIterator,
DirCacheIterator dirCacheIterator,
CanonicalTreeParser otherTree)
Get the
AttributesNode for the current entry. |
protected void |
expandMacro(Attribute attr,
Attributes result)
Expand a macro
|
Attributes |
getAttributes()
|
protected void |
mergeAttributes(AttributesNode node,
java.lang.String entryPath,
boolean isDirectory,
Attributes result)
Merges the matching node attributes for an entry path.
|
private void |
mergeGlobalAttributes(java.lang.String entryPath,
boolean isDirectory,
Attributes result)
Merges the matching GLOBAL attributes for an entry path.
|
private void |
mergeInfoAttributes(java.lang.String entryPath,
boolean isDirectory,
Attributes result)
Merges the matching INFO attributes for an entry path.
|
private void |
mergePerDirectoryEntryAttributes(java.lang.String entryPath,
int nameRoot,
boolean isDirectory,
WorkingTreeIterator workingTreeIterator,
DirCacheIterator dirCacheIterator,
CanonicalTreeParser otherTree,
Attributes result)
Merges the matching working directory attributes for an entry path.
|
private static <T extends AbstractTreeIterator> |
parentOf(T node) |
private static <T extends AbstractTreeIterator> |
rootOf(T node) |
private static final java.lang.String MACRO_PREFIX
private static final java.lang.String BINARY_RULE_KEY
private static final java.util.List<Attribute> BINARY_RULE_ATTRIBUTES
[attr]binary -diff -merge -textprivate final TreeWalk treeWalk
private final AttributesNode globalNode
private final AttributesNode infoNode
private final java.util.Map<java.lang.String,java.util.List<Attribute>> expansions
public AttributesHandler(TreeWalk treeWalk) throws java.io.IOException
AttributesHandler with
default rules as well as merged rules from global, info and worktree root
attributestreeWalk - a TreeWalkjava.io.IOExceptionpublic Attributes getAttributes() throws java.io.IOException
Attributes for the
current path represented by the
TreeWalkjava.io.IOExceptionprivate void mergeGlobalAttributes(java.lang.String entryPath,
boolean isDirectory,
Attributes result)
entryPath - 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.private void mergeInfoAttributes(java.lang.String entryPath,
boolean isDirectory,
Attributes result)
entryPath - 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.private void mergePerDirectoryEntryAttributes(java.lang.String entryPath,
int nameRoot,
boolean isDirectory,
@Nullable
WorkingTreeIterator workingTreeIterator,
@Nullable
DirCacheIterator dirCacheIterator,
@Nullable
CanonicalTreeParser otherTree,
Attributes result)
throws java.io.IOException
entryPath - 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 '\').nameRoot - index of the '/' preceeding the current level, or -1 if noneisDirectory - true if the target item is a directory.workingTreeIterator - dirCacheIterator - otherTree - result - that will hold the attributes matching this entry path. This
method will NOT override any existing entry in attributes.java.io.IOExceptionprotected void mergeAttributes(@Nullable AttributesNode node, java.lang.String entryPath, boolean isDirectory, Attributes result)
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.protected void expandMacro(Attribute attr, Attributes result)
attr - a Attributeresult - contains the (recursive) expanded and merged macro attributes
including the attribute iselfprivate static AttributesNode attributesNode(TreeWalk treeWalk, @Nullable WorkingTreeIterator workingTreeIterator, @Nullable DirCacheIterator dirCacheIterator, @Nullable CanonicalTreeParser otherTree) throws java.io.IOException
AttributesNode for the current entry.
This method implements the fallback mechanism between the index and the working tree depending on the operation type
treeWalk - workingTreeIterator - dirCacheIterator - otherTree - AttributesNode of the current entry,
NullPointerException otherwise.java.io.IOException - It raises an IOException if a problem appears while
parsing one on the attributes file.private static <T extends AbstractTreeIterator> T parentOf(@Nullable T node)
private static <T extends AbstractTreeIterator> T rootOf(@Nullable T node)