String parentRel = getParentPath(pathRel); if (isDirectoryIgnored(parentRel)) { return true; IgnoreNode rules = getIgnoreNode(); final Boolean ignored = rules != null ? rules.checkIgnored(pathRel, FileMode.TREE.equals(fileMode)) && ((WorkingTreeIterator) parent).isEntryIgnored(pLen, fileMode);
ObjectReader reader) throws IOException { if (entry == null) return !FileMode.MISSING.equals(getEntryFileMode()); MetadataDiff diff = compareMetadata(entry); switch (diff) { case DIFFER_BY_TIMESTAMP: return contentCheck(entry, reader); else return contentCheck(entry, reader); case EQUAL: if (mode == FileMode.SYMLINK.getBits()) { return contentCheck(entry, reader); if (mode == FileMode.TREE.getBits() && entry.getFileMode().equals(FileMode.GITLINK)) { byte[] idBuffer = idBuffer(); int idOffset = idOffset(); if (entry.getObjectId().compareTo(idBuffer, idOffset) == 0) { return true; return contentCheck(entry, reader); return true; default:
if (getEntryObjectId().equals(entry.getObjectId())) { entry.setLength((int) getEntryLength()); return !new File(readSymlinkTarget(current())).equals( new File(readContentAsNormalizedString(entry, reader))); return true; switch (getEolStreamType()) { case DIRECT: return true; loader.openStream(), true, true /* abort if binary */)) { dcInLen = computeLength(dcIn); } catch (AutoLFInputStream.IsBinaryException e) { return true; byte[] autoCrLfHash = computeHash(dcIn, dcInLen); boolean changed = getEntryObjectId() .compareTo(autoCrLfHash, 0) != 0; return changed;
/** {@inheritDoc} */ @Override public void reset() { if (!first()) { ptr = 0; if (!eof()) parseEntry(); } }
/** {@inheritDoc} */ @Override public void next(int delta) throws CorruptObjectException { ptr += delta; if (!eof()) { parseEntry(); } }
private ByteBuffer filterClean(byte[] src, int n, OperationType opType) throws IOException { InputStream in = new ByteArrayInputStream(src); try { return IO.readWholeStream(filterClean(in, opType), n); } finally { safeClose(in); } }
if (workingTreeIterator == null) workingTreeIterator = new FileTreeIterator(repo); workingTreeIterator.setDirCacheIterator(tw, 0); tw.addTree(workingTreeIterator); if (!addAll) DirCacheIterator c = tw.getTree(0, DirCacheIterator.class); WorkingTreeIterator f = tw.getTree(1, WorkingTreeIterator.class); if (c == null && f != null && f.isEntryIgnored()) { if ((f.getEntryRawMode() == TYPE_TREE && f.getIndexFileMode(c) != FileMode.GITLINK) || (f.getEntryRawMode() == TYPE_GITLINK && f.getIndexFileMode(c) == FileMode.TREE)) { FileMode mode = f.getIndexFileMode(c); entry.setFileMode(mode); entry.setLength(f.getEntryLength()); entry.setLastModified(f.getEntryLastModified()); long len = f.getEntryContentLength(); try (InputStream in = f.openEntryStream()) { ObjectId id = inserter.insert(OBJ_BLOB, len, in); entry.setObjectId(id); entry.setLength(0); entry.setLastModified(0); entry.setObjectId(f.getEntryObjectId());
private InputStream possiblyFilteredInputStream(final Entry e, final InputStream is, final long len, OperationType opType) throws IOException { if (getCleanFilterCommand() == null && getEolStreamType(opType) == EolStreamType.DIRECT) { canonLen = len; return is; } if (len <= MAXIMUM_FILE_SIZE_TO_READ_FULLY) { ByteBuffer rawbuf = IO.readWholeStream(is, (int) len); rawbuf = filterClean(rawbuf.array(), rawbuf.limit(), opType); canonLen = rawbuf.limit(); return new ByteArrayInputStream(rawbuf.array(), 0, (int) canonLen); } if (getCleanFilterCommand() == null && isBinary(e)) { canonLen = len; return is; } final InputStream lenIs = filterClean(e.openInputStream(), opType); try { canonLen = computeLength(lenIs); } finally { safeClose(lenIs); } return filterClean(is, opType); }
if (f != null && !FileMode.TREE.equals(f.getEntryFileMode()) && !f.isEntryIgnored()) { if (failOnConflict) { } else if (i.getDirCacheEntry() != null) { if (f.isModified(i.getDirCacheEntry(), true, this.walk.getObjectReader()) || i.getDirCacheEntry().getStage() != 0) entry.setLastModified(f.getEntryLastModified()); keep(entry);
if (equalIdAndMode(hId, hMode, iId, iMode)) if (f != null && f.isModified(dce, true, this.walk.getObjectReader())) if (f == null || FileMode.TREE.equals(f.getEntryFileMode())) { if ((ffMask == 0x00F) && f != null && FileMode.TREE.equals(f.getEntryFileMode())) { if (f != null && !f.isEntryIgnored()) { f.getEntryObjectId(), f.getEntryFileMode())) { conflict(name, null, h, m); return; && (f == null || f.isModified(dce, true, this.walk.getObjectReader()))) && f.isModified(dce, true, this.walk.getObjectReader())) { if (!FileMode.TREE.equals(f.getEntryFileMode()) && FileMode.TREE.equals(iMode)) && (f != null && f.isModified(dce, true, this.walk.getObjectReader()))) {
/** * Get the filtered input length of this entry * * @return size of the content, in bytes * @throws java.io.IOException */ public long getEntryContentLength() throws IOException { if (canonLen == -1) { long rawLen = getEntryLength(); if (rawLen == 0) canonLen = 0; InputStream is = current().openInputStream(); try { // canonLen gets updated here possiblyFilteredInputStream(current(), is, current() .getLength()); } finally { safeClose(is); } } return canonLen; }
/** * Obtain an input stream to read the file content. * <p> * Efficient implementations are not required. The caller will usually * obtain the stream only once per entry, if at all. * <p> * The input stream should not use buffering if the implementation can avoid * it. The caller will buffer as necessary to perform efficient block IO * operations. * <p> * The caller will close the stream once complete. * * @return a stream to read from the file. * @throws java.io.IOException * the file could not be opened for reading. */ public InputStream openEntryStream() throws IOException { InputStream rawis = current().openInputStream(); if (getCleanFilterCommand() == null && getEolStreamType() == EolStreamType.DIRECT) return rawis; else return filterClean(rawis); }
&& !(honorIgnores && wi.isEntryIgnored())) { if (honorIgnores && wi.isEntryIgnored()) { ignoredPaths.add(wi.getEntryPathString()); int i = 0; for (; i < cnt; i++) { return wi.isModified(di == null ? null : di.getDirCacheEntry(), true, tw.getObjectReader());
treeWalk.addTree(new DirCacheIterator(dirCache)); treeWalk.addTree(initialWorkingTreeIterator); initialWorkingTreeIterator.setDirCacheIterator(treeWalk, 1); Collection<TreeFilter> filters = new ArrayList<>(4); && !workingTreeIterator.isEntryIgnored()) { untracked.add(treeWalk.getPathString()); missing.add(treeWalk.getPathString()); } else { if (workingTreeIterator.isModified( dirCacheIterator.getDirCacheEntry(), true, treeWalk.getObjectReader())) {
private byte[] idBufferBlob(Entry e) { try { final InputStream is = e.openInputStream(); if (is == null) return zeroid; try { state.initializeReadBuffer(); final long len = e.getLength(); InputStream filteredIs = possiblyFilteredInputStream(e, is, len, OperationType.CHECKIN_OP); return computeHash(filteredIs, canonLen); } finally { safeClose(is); } } catch (IOException err) { // Can't read the file? Don't report the failure either. return zeroid; } }
if (i != null) { DirCacheEntry ent = i.getDirCacheEntry(); if (ent != null && compareMetadata(ent) == MetadataDiff.EQUAL && ((ent.getFileMode().getBits() & FileMode.TYPE_MASK) != FileMode.TYPE_GITLINK)) { case FileMode.TYPE_FILE: contentIdFromPtr = ptr; return contentId = idBufferBlob(entries[ptr]); case FileMode.TYPE_GITLINK: contentIdFromPtr = ptr; return contentId = idSubmodule(entries[ptr]);
ObjectReader reader) throws IOException { if (entry == null) return !FileMode.MISSING.equals(getEntryFileMode()); MetadataDiff diff = compareMetadata(entry); switch (diff) { case DIFFER_BY_TIMESTAMP: return contentCheck(entry, reader); else return contentCheck(entry, reader); case EQUAL: if (mode == FileMode.SYMLINK.getBits()) { return contentCheck(entry, reader); return contentCheck(entry, reader); return true; default:
/** * Determine if the current entry path is ignored by an ignore rule. * * @return true if the entry was ignored by an ignore rule file. * @throws java.io.IOException * a relevant ignore rule file exists but cannot be read. */ public boolean isEntryIgnored() throws IOException { return isEntryIgnored(pathLen); }
boolean negatePrevious) throws IOException { IgnoreNode rules = getIgnoreNode(); if (rules != null) { return ((WorkingTreeIterator) parent).isEntryIgnored(pLen, fileMode, negatePrevious); return false;
/** * Get the raw byte length of this entry. * * @return size of this file, in bytes. */ public long getEntryLength() { return current().getLength(); }