summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2017-08-11 21:16:54 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2017-08-11 21:59:49 +0200
commit4bc539a8141e8099587536620bdc555c2c4cb01e (patch)
tree6cf4fda594209cf3e35d3a1e569a80ec086a0816 /org.eclipse.jgit/src
parent22201e8cca3b2b1f6df71fb1053c7358a9a2d72f (diff)
downloadjgit-4bc539a8141e8099587536620bdc555c2c4cb01e.tar.gz
jgit-4bc539a8141e8099587536620bdc555c2c4cb01e.zip
Use relative paths for attribute rule matching
Attribute rules must match against the entry path relative to the attribute node containing the rule. The global entry path is to be used only for the init and the global node (and of course the root node). Bug: 520677 Change-Id: I80389a2dc272a72312729ccd5358d7c75e1ea20a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesHandler.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesHandler.java b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesHandler.java
index 3bf4179e7d..8d928e3749 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesHandler.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesHandler.java
@@ -144,7 +144,8 @@ public class AttributesHandler {
mergeInfoAttributes(entryPath, isDirectory, attributes);
// Gets the attributes located on the current entry path
- mergePerDirectoryEntryAttributes(entryPath, isDirectory,
+ mergePerDirectoryEntryAttributes(entryPath, entryPath.lastIndexOf('/'),
+ isDirectory,
treeWalk.getTree(WorkingTreeIterator.class),
treeWalk.getTree(DirCacheIterator.class),
treeWalk.getTree(CanonicalTreeParser.class),
@@ -206,6 +207,8 @@ public class AttributesHandler {
* 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 '\').
+ * @param nameRoot
+ * index of the '/' preceeding the current level, or -1 if none
* @param isDirectory
* true if the target item is a directory.
* @param workingTreeIterator
@@ -217,7 +220,7 @@ public class AttributesHandler {
* @throws IOException
*/
private void mergePerDirectoryEntryAttributes(String entryPath,
- boolean isDirectory,
+ int nameRoot, boolean isDirectory,
@Nullable WorkingTreeIterator workingTreeIterator,
@Nullable DirCacheIterator dirCacheIterator,
@Nullable CanonicalTreeParser otherTree, Attributes result)
@@ -228,9 +231,12 @@ public class AttributesHandler {
AttributesNode attributesNode = attributesNode(
treeWalk, workingTreeIterator, dirCacheIterator, otherTree);
if (attributesNode != null) {
- mergeAttributes(attributesNode, entryPath, isDirectory, result);
+ mergeAttributes(attributesNode,
+ entryPath.substring(nameRoot + 1), isDirectory,
+ result);
}
- mergePerDirectoryEntryAttributes(entryPath, isDirectory,
+ mergePerDirectoryEntryAttributes(entryPath,
+ entryPath.lastIndexOf('/', nameRoot - 1), isDirectory,
parentOf(workingTreeIterator), parentOf(dirCacheIterator),
parentOf(otherTree), result);
}