List of usage examples for org.eclipse.jgit.lib Constants OBJ_BLOB
int OBJ_BLOB
To view the source code for org.eclipse.jgit.lib Constants OBJ_BLOB.
Click Source Link
From source file:gerrit.PRED_commit_edits_2.java
License:Apache License
private Text load(final ObjectId tree, final String path, final ObjectReader reader) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { if (path == null) { return Text.EMPTY; }/*from w ww. j a va 2s . co m*/ final TreeWalk tw = TreeWalk.forPath(reader, path, tree); if (tw == null) { return Text.EMPTY; } if (tw.getFileMode(0).getObjectType() != Constants.OBJ_BLOB) { return Text.EMPTY; } return new Text(reader.open(tw.getObjectId(0), Constants.OBJ_BLOB)); }
From source file:io.macgyver.plugin.git.GitResourceImpl.java
License:Apache License
@Override public InputStream openInputStream() throws IOException { GitResourceProvider p = getGitResourceProvider(); ObjectLoader loader = p.repo.open(id, Constants.OBJ_BLOB); return loader.openStream(); }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void process(final ObjectId id) throws TransportException { final RevObject obj; try {/*from w w w . j a va 2 s . c o m*/ if (id instanceof RevObject) { obj = (RevObject) id; if (obj.has(COMPLETE)) return; revWalk.parseHeaders(obj); } else { obj = revWalk.parseAny(id); if (obj.has(COMPLETE)) return; } } catch (IOException e) { throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e); } switch (obj.getType()) { case Constants.OBJ_BLOB: processBlob(obj); break; case Constants.OBJ_TREE: processTree(obj); break; case Constants.OBJ_COMMIT: processCommit(obj); break; case Constants.OBJ_TAG: processTag(obj); break; default: throw new TransportException(MessageFormat.format(JGitText.get().unknownObjectType, id.name())); } // If we had any prior errors fetching this object they are // now resolved, as the object was parsed successfully. // fetchErrors.remove(id); }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void processBlob(final RevObject obj) throws TransportException { try {/* w w w .ja v a2 s .c o m*/ if (reader.has(obj, Constants.OBJ_BLOB)) obj.add(COMPLETE); else throw new TransportException(MessageFormat.format(JGitText.get().cannotReadBlob, obj.name()), new MissingObjectException(obj, Constants.TYPE_BLOB)); } catch (IOException error) { throw new TransportException(MessageFormat.format(JGitText.get().cannotReadBlob, obj.name()), error); } }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void processTree(final RevObject obj) throws TransportException { try {/*from w w w. j a v a 2s . c o m*/ treeWalk.reset(obj); while (treeWalk.next()) { final FileMode mode = treeWalk.getFileMode(0); final int sType = mode.getObjectType(); switch (sType) { case Constants.OBJ_BLOB: case Constants.OBJ_TREE: treeWalk.getObjectId(idBuffer, 0); needs(revWalk.lookupAny(idBuffer, sType)); continue; default: if (FileMode.GITLINK.equals(mode)) continue; treeWalk.getObjectId(idBuffer, 0); throw new CorruptObjectException(MessageFormat.format(JGitText.get().invalidModeFor, mode, idBuffer.name(), treeWalk.getPathString(), obj.getId().name())); } } } catch (IOException ioe) { throw new TransportException(MessageFormat.format(JGitText.get().cannotReadTree, obj.name()), ioe); } obj.add(COMPLETE); }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void markLocalObjComplete(RevObject obj) throws IOException { while (obj.getType() == Constants.OBJ_TAG) { obj.add(COMPLETE);//from www. j ava 2s. com obj = ((RevTag) obj).getObject(); revWalk.parseHeaders(obj); } switch (obj.getType()) { case Constants.OBJ_BLOB: obj.add(COMPLETE); break; case Constants.OBJ_COMMIT: pushLocalCommit((RevCommit) obj); break; case Constants.OBJ_TREE: markTreeComplete((RevTree) obj); break; } }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void markTreeComplete(final RevTree tree) throws IOException { if (tree.has(COMPLETE)) return;/*from w w w .ja v a 2s .co m*/ tree.add(COMPLETE); treeWalk.reset(tree); while (treeWalk.next()) { final FileMode mode = treeWalk.getFileMode(0); final int sType = mode.getObjectType(); switch (sType) { case Constants.OBJ_BLOB: treeWalk.getObjectId(idBuffer, 0); revWalk.lookupAny(idBuffer, sType).add(COMPLETE); continue; case Constants.OBJ_TREE: { treeWalk.getObjectId(idBuffer, 0); final RevObject o = revWalk.lookupAny(idBuffer, sType); if (!o.has(COMPLETE)) { o.add(COMPLETE); treeWalk.enterSubtree(); } continue; } default: if (FileMode.GITLINK.equals(mode)) continue; treeWalk.getObjectId(idBuffer, 0); throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3, mode, idBuffer.name(), treeWalk.getPathString(), tree.name())); } } }
From source file:jbenchmarker.trace.git.GitExtraction.java
License:Open Source License
byte[] open(DiffEntry.Side side, DiffEntry entry) throws IOException { if (entry.getMode(side) == FileMode.MISSING) { return EMPTY; }//w w w. j a v a 2 s. c om if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB) { return EMPTY; } AbbreviatedObjectId id = entry.getId(side); if (!id.isComplete()) { Collection<ObjectId> ids = reader.resolve(id); if (ids.size() == 1) { // id = AbbreviatedObjectId.fromObjectId(ids.iterator().next()); // switch (side) { // case OLD: // entry.oldId = id; // break; // case NEW: // entry.newId = id; // break; // } } else if (ids.isEmpty()) { throw new MissingObjectException(id, Constants.OBJ_BLOB); } else { throw new AmbiguousObjectException(id, ids); } } ObjectLoader ldr = pairSource.open(side, entry); return getBytes(ldr, id.toObjectId()); }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
License:Apache License
public static String asObjectType(int objectType) { switch (objectType) { case Constants.OBJ_BAD: return "BAD"; case Constants.OBJ_BLOB: return "BLOB"; case Constants.OBJ_COMMIT: return "COMMIT"; case Constants.OBJ_EXT: return "EXT(future)"; case Constants.OBJ_OFS_DELTA: return "OFS_DELTA(offset_delta)"; case Constants.OBJ_REF_DELTA: return "REF_DELTA(reference_delta)"; case Constants.OBJ_TAG: return "TAG"; case Constants.OBJ_TREE: return "TREE"; case Constants.OBJ_TYPE_5: return "TYPE_S(future)"; default:/*from w ww.j a va 2 s . c o m*/ return "[" + objectType + "]"; } }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
License:Apache License
public static String getObjectName(Repository repo, ObjectId objectId) { try {/* w w w . j av a 2 s . co m*/ ObjectLoader loader = repo.open(objectId); StringBuilder ret = new StringBuilder(); if (loader.isLarge()) { ret.append("LARGE! "); } switch (loader.getType()) { case Constants.OBJ_BAD: ret.append("BAD "); break; case Constants.OBJ_BLOB: ret.append("BLOB "); break; case Constants.OBJ_COMMIT: ret.append("COMMIT "); break; case Constants.OBJ_EXT: ret.append("EXT "); break; case Constants.OBJ_OFS_DELTA: ret.append("OFS_DELTA "); break; case Constants.OBJ_REF_DELTA: ret.append("REF_DELTA "); break; case Constants.OBJ_TAG: ret.append("TAG "); break; case Constants.OBJ_TREE: ret.append("TREE "); break; case Constants.OBJ_TYPE_5: ret.append("TYPE_5 "); break; default: ret.append("UNKNOWN[").append(loader.getType()).append("] "); break; } ret.append(String.format("Size=%,d", loader.getSize())); return ret.toString(); } catch (MissingObjectException e) { LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e); return "<missing object>"; } catch (IOException e) { LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e); return "<unable to open object>"; } }