org.eclipse.jgit.lib.ObjectStream Java Examples
The following examples show how to use
org.eclipse.jgit.lib.ObjectStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LfsFilter.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
@NotNull @Override public String getMd5(@NotNull GitObject<? extends ObjectId> objectId) throws IOException { final ObjectLoader loader = objectId.openObject(); try (ObjectStream stream = loader.openStream()) { final Meta meta = parseMeta(stream); if (meta != null) { final String md5 = getReader(meta).getMd5(); if (md5 != null) return md5; } } return GitFilterHelper.getMd5(this, cacheMd5, null, objectId); }
Example #2
Source File: LfsFilter.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
@NotNull @Override public InputStream inputStream(@NotNull GitObject<? extends ObjectId> objectId) throws IOException { final ObjectLoader loader = objectId.openObject(); try (ObjectStream stream = loader.openStream()) { final byte[] header = new byte[Constants.POINTER_MAX_SIZE]; int length = IOUtils.read(stream, header, 0, header.length); if (length < header.length) { final Meta meta = parseMeta(header, length); if (meta != null) return getReader(meta).openStream(); } // We need to re-open stream return loader.openStream(); } }
Example #3
Source File: GitIndexHandlerV1.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private boolean handleGet(HttpServletRequest request, HttpServletResponse response, Repository db, String pattern) throws CoreException, IOException, ServletException { Index index = new Index(null /* not needed */, db, pattern); ObjectStream stream = index.toObjectStream(); if (stream == null) { String msg = NLS.bind("{0} not found in index", pattern); //$NON-NLS-1$ if ("true".equals(request.getHeader("read-if-exists"))) { return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.WARNING, 204, msg, null)); } return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.OK, HttpServletResponse.SC_NOT_FOUND, msg, null)); } response.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ IOUtilities.pipe(stream, response.getOutputStream(), true, false); return true; }
Example #4
Source File: Index.java From orion.server with Eclipse Public License 1.0 | 5 votes |
public ObjectStream toObjectStream() throws IOException { DirCache cache = db.readDirCache(); DirCacheEntry entry = cache.getEntry(pattern); if (entry == null) { return null; } try { ObjectId blobId = entry.getObjectId(); return db.open(blobId, Constants.OBJ_BLOB).openStream(); } catch (MissingObjectException e) { return null; } }
Example #5
Source File: Commit.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * Return body of the commit * * @return body of the commit as an Object Stream * @throws IOException * when reading the object failed */ public ObjectStream toObjectStream() throws IOException { final TreeWalk w = TreeWalk.forPath(db, pattern, revCommit.getTree()); if (w == null) { return null; } ObjectId blobId = w.getObjectId(0); return db.open(blobId, Constants.OBJ_BLOB).openStream(); }
Example #6
Source File: LfsFilter.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Override public long getSize(@NotNull GitObject<? extends ObjectId> objectId) throws IOException { final ObjectLoader loader = objectId.openObject(); try (ObjectStream stream = loader.openStream()) { final Meta meta = parseMeta(stream); if (meta != null) return meta.getSize(); } return loader.getSize(); }
Example #7
Source File: AutoCRLFObjectStream.java From git-code-format-maven-plugin with MIT License | 4 votes |
public AutoCRLFObjectStream(ObjectStream delegate, EolStreamType eolStreamType) { this.delegate = requireNonNull(delegate); this.autoCRLFInputStream = requireNonNull(EolStreamTypeUtil.wrapInputStream(delegate, eolStreamType)); }
Example #8
Source File: AutoCRLFObjectLoader.java From git-code-format-maven-plugin with MIT License | 4 votes |
@Override public ObjectStream openStream() throws MissingObjectException, IOException { return new AutoCRLFObjectStream(delegate.openStream(), eolStreamType); }