/** * Whether the attribute with the given key is unspecified * * @param key * a {@link java.lang.String} object. * @return true if the key is * {@link org.eclipse.jgit.attributes.Attribute.State#UNSPECIFIED}, * false in all other cases */ public boolean isUnspecified(String key) { return (getState(key) == State.UNSPECIFIED); }
private static EolStreamType checkInStreamType(WorkingTreeOptions options, Attributes attrs) { if (attrs.isUnset("text")) {//$NON-NLS-1$ if (attrs.isSet("crlf")) {//$NON-NLS-1$ return EolStreamType.TEXT_LF; // Same as isSet("text") } else if (attrs.isUnset("crlf")) {//$NON-NLS-1$ return EolStreamType.DIRECT; // Same as isUnset("text") } else if ("input".equals(attrs.getValue("crlf"))) {//$NON-NLS-1$ //$NON-NLS-2$ return EolStreamType.TEXT_LF; // Same as eol=lf String eol = attrs.getValue("eol"); //$NON-NLS-1$ if (eol != null) if (attrs.isSet("text")) { //$NON-NLS-1$ return EolStreamType.TEXT_LF; if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$ return EolStreamType.AUTO_LF;
/** * Creates a new instance * * @param attributes * a {@link org.eclipse.jgit.attributes.Attribute} */ public Attributes(Attribute... attributes) { if (attributes != null) { for (Attribute a : attributes) { put(a); } } }
/** * Test if the given attributes implies to handle the related entry as a * binary file (i.e. if the entry has an -merge or a merge=binary attribute) * or if it can be content merged. * * @return <code>true</code> if the entry can be content merged, * <code>false</code> otherwise * @since 4.9 */ public boolean canBeContentMerged() { if (isUnset(Constants.ATTR_MERGE)) { return false; } else if (isCustom(Constants.ATTR_MERGE) && getValue(Constants.ATTR_MERGE) .equals(Constants.ATTR_BUILTIN_BINARY_MERGER)) { return false; } return true; }
String entryPath = treeWalk.getPathString(); boolean isDirectory = (treeWalk.getFileMode() == FileMode.TREE); Attributes attributes = new Attributes(); for (Attribute a : attributes.getAll()) { if (a.getState() == State.UNSPECIFIED) attributes.remove(a.getKey());
if (result.containsKey(attr.getKey())) return; result.put(attr);
Attributes attributes = getAttributes(); Attribute f = attributes.get(Constants.ATTR_FILTER); if (f == null) { return null;
String entryPath = treeWalk.getPathString(); boolean isDirectory = (treeWalk.getFileMode() == FileMode.TREE); Attributes attributes = new Attributes(); for (Attribute a : attributes.getAll()) { if (a.getState() == State.UNSPECIFIED) attributes.remove(a.getKey());
/** * Test if the given attributes implies to handle the related entry as a * binary file (i.e. if the entry has an -merge or a merge=binary attribute) * or if it can be content merged. * * @return <code>true</code> if the entry can be content merged, * <code>false</code> otherwise * @since 4.9 */ public boolean canBeContentMerged() { if (isUnset(Constants.ATTR_MERGE)) { return false; } else if (isCustom(Constants.ATTR_MERGE) && getValue(Constants.ATTR_MERGE) .equals(Constants.ATTR_BUILTIN_BINARY_MERGER)) { return false; } return true; }
if (result.containsKey(attr.getKey())) return; result.put(attr);
void loadText(ObjectReader reader) throws IOException { ObjectLoader ldr = LfsFactory.getInstance().applySmudgeFilter(sourceRepository, reader.open(sourceBlob, Constants.OBJ_BLOB), LfsFactory.getAttributesForPath(sourceRepository, sourcePath.getPath(), sourceCommit) .get(Constants.ATTR_DIFF)); sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE)); }
private static EolStreamType checkOutStreamType(WorkingTreeOptions options, Attributes attrs) { if (attrs.isUnset("text")) {//$NON-NLS-1$ if (attrs.isSet("crlf")) {//$NON-NLS-1$ return getOutputFormat(options); // Same as isSet("text") } else if (attrs.isUnset("crlf")) {//$NON-NLS-1$ return EolStreamType.DIRECT; // Same as isUnset("text") } else if ("input".equals(attrs.getValue("crlf"))) {//$NON-NLS-1$ //$NON-NLS-2$ return EolStreamType.DIRECT; // Same as eol=lf String eol = attrs.getValue("eol"); //$NON-NLS-1$ if (eol != null) { if ("crlf".equals(eol)) {//$NON-NLS-1$ if (attrs.isSet("text")) { //$NON-NLS-1$ return getOutputFormat(options); if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$ EolStreamType basic = getOutputFormat(options); switch (basic) {
/** * see {@link TreeWalk#getAttributes()} * * @return the {@link Attributes} for the current path represented by the * {@link TreeWalk} * @throws IOException */ public Attributes getAttributes() throws IOException { String entryPath = treeWalk.getPathString(); boolean isDirectory = (treeWalk.getFileMode() == FileMode.TREE); Attributes attributes = new Attributes(); // Gets the info attributes mergeInfoAttributes(entryPath, isDirectory, attributes); // Gets the attributes located on the current entry path mergePerDirectoryEntryAttributes(entryPath, isDirectory, treeWalk.getTree(WorkingTreeIterator.class), treeWalk.getTree(DirCacheIterator.class), treeWalk.getTree(CanonicalTreeParser.class), attributes); // Gets the attributes located in the global attribute file mergeGlobalAttributes(entryPath, isDirectory, attributes); // now after all attributes are collected - in the correct hierarchy // order - remove all unspecified entries (the ! marker) for (Attribute a : attributes.getAll()) { if (a.getState() == State.UNSPECIFIED) attributes.remove(a.getKey()); } return attributes; }
/** * Whether the attribute is set * * @param key * a {@link java.lang.String} object. * @return true if the key is * {@link org.eclipse.jgit.attributes.Attribute.State#SET}, false in * all other cases */ public boolean isSet(String key) { return (getState(key) == State.SET); }
if (result.containsKey(attr.getKey())) return; result.put(attr);
private ObjectId insertMergeResult(TemporaryBuffer buf, Attributes attributes) throws IOException { InputStream in = buf.openInputStream(); try (LfsInputStream is = LfsFactory.getInstance().applyCleanFilter( getRepository(), in, buf.length(), attributes.get(Constants.ATTR_MERGE))) { return getObjectInserter().insert(OBJ_BLOB, is.getLength(), is); } }
/** * Creates a new instance * * @param attributes */ public Attributes(Attribute... attributes) { if (attributes != null) { for (Attribute a : attributes) { put(a); } } }
private static EolStreamType checkInStreamType(WorkingTreeOptions options, Attributes attrs) { if (attrs.isSet("crlf")) {//$NON-NLS-1$ return EolStreamType.TEXT_LF; } else if (attrs.isUnset("crlf")) {//$NON-NLS-1$ return EolStreamType.DIRECT; } else if ("input".equals(attrs.getValue("crlf"))) {//$NON-NLS-1$ //$NON-NLS-2$ return EolStreamType.TEXT_LF; if (attrs.isUnset("text")) {//$NON-NLS-1$ return EolStreamType.DIRECT; String eol = attrs.getValue("eol"); //$NON-NLS-1$ if (eol != null) if (attrs.isSet("text")) { //$NON-NLS-1$ return EolStreamType.TEXT_LF; if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$ return EolStreamType.AUTO_LF;
/** * Is this a custom attribute * * @param key * a {@link java.lang.String} object. * @return true if the key is * {@link org.eclipse.jgit.attributes.Attribute.State#CUSTOM}, false * in all other cases see {@link #getValue(String)} for the value of * the key */ public boolean isCustom(String key) { return (getState(key) == State.CUSTOM); }
private RawText getRawText(ObjectId id, Attributes attributes) throws IOException, BinaryBlobException { if (id.equals(ObjectId.zeroId())) return new RawText(new byte[] {}); ObjectLoader loader = LfsFactory.getInstance().applySmudgeFilter( getRepository(), reader.open(id, OBJ_BLOB), attributes.get(Constants.ATTR_MERGE)); int threshold = PackConfig.DEFAULT_BIG_FILE_THRESHOLD; return RawText.load(loader, threshold); }