/** * Write an ObjectId and LF to the temporary file. * * @param id * the id to store in the file. The id will be written in hex, * followed by a sole LF. * @throws java.io.IOException * the temporary file could not be written. The lock is released * before throwing the underlying IO exception to the caller. * @throws java.lang.RuntimeException * the temporary file could not be written. The lock is released * before throwing the underlying exception to the caller. */ public void write(ObjectId id) throws IOException { byte[] buf = new byte[Constants.OBJECT_ID_STRING_LENGTH + 1]; id.copyTo(buf, 0); buf[Constants.OBJECT_ID_STRING_LENGTH] = '\n'; write(buf); }
/** * Overwrite (or create) a loose ref in the remote repository. * <p> * This method creates any missing parent directories, if necessary. * * @param name * name of the ref within the ref space, for example * <code>refs/heads/pu</code>. * @param value * new value to store in this ref. Must not be null. * @throws IOException * writing is not supported, or attempting to write the file * failed, possibly due to permissions or remote disk full, etc. */ void writeRef(String name, ObjectId value) throws IOException { final ByteArrayOutputStream b; b = new ByteArrayOutputStream(Constants.OBJECT_ID_STRING_LENGTH + 1); value.copyTo(b); b.write('\n'); writeFile(ROOT_DIR + name, b.toByteArray()); }
/** * Write the given heads to a file in the git directory. * * @param heads * a list of object ids to write or null if the file should be * deleted. * @param filename * @throws FileNotFoundException * @throws IOException */ private void writeHeadsFile(List<? extends ObjectId> heads, String filename) throws FileNotFoundException, IOException { File headsFile = new File(getDirectory(), filename); if (heads != null) { try (OutputStream bos = new BufferedOutputStream( new FileOutputStream(headsFile))) { for (ObjectId id : heads) { id.copyTo(bos); bos.write('\n'); } } } else { FileUtils.delete(headsFile, FileUtils.SKIP_MISSING); } }
UTF_8)) { w.write("object "); //$NON-NLS-1$ getObjectId().copyTo(w); w.write('\n');
e.getValue().copyTo(tmp, w); w.write(' '); w.write(e.getKey());
public byte[] asBytes() { byte[] r = new byte[KEYLEN]; format32(r, 0, repo); r[8] = '.'; chunk.copyTo(r, 9); return r; }
public byte[] asBytes() { byte[] r = new byte[KEYLEN]; format32(r, 0, repo); r[8] = '.'; chunk.copyTo(r, 9); return r; }
/** * Write an ObjectId and LF to the temporary file. * * @param id * the id to store in the file. The id will be written in hex, * followed by a sole LF. * @throws IOException * the temporary file could not be written. The lock is released * before throwing the underlying IO exception to the caller. * @throws RuntimeException * the temporary file could not be written. The lock is released * before throwing the underlying exception to the caller. */ public void write(final ObjectId id) throws IOException { byte[] buf = new byte[Constants.OBJECT_ID_STRING_LENGTH + 1]; id.copyTo(buf, 0); buf[Constants.OBJECT_ID_STRING_LENGTH] = '\n'; write(buf); }
/** * Write an ObjectId and LF to the temporary file. * * @param id * the id to store in the file. The id will be written in hex, * followed by a sole LF. * @throws java.io.IOException * the temporary file could not be written. The lock is released * before throwing the underlying IO exception to the caller. * @throws java.lang.RuntimeException * the temporary file could not be written. The lock is released * before throwing the underlying exception to the caller. */ public void write(ObjectId id) throws IOException { byte[] buf = new byte[Constants.OBJECT_ID_STRING_LENGTH + 1]; id.copyTo(buf, 0); buf[Constants.OBJECT_ID_STRING_LENGTH] = '\n'; write(buf); }
/** * Overwrite (or create) a loose ref in the remote repository. * <p> * This method creates any missing parent directories, if necessary. * * @param name * name of the ref within the ref space, for example * <code>refs/heads/pu</code>. * @param value * new value to store in this ref. Must not be null. * @throws IOException * writing is not supported, or attempting to write the file * failed, possibly due to permissions or remote disk full, etc. */ void writeRef(final String name, final ObjectId value) throws IOException { final ByteArrayOutputStream b; b = new ByteArrayOutputStream(Constants.OBJECT_ID_STRING_LENGTH + 1); value.copyTo(b); b.write('\n'); writeFile(ROOT_DIR + name, b.toByteArray()); }
/** * Overwrite (or create) a loose ref in the remote repository. * <p> * This method creates any missing parent directories, if necessary. * * @param name * name of the ref within the ref space, for example * <code>refs/heads/pu</code>. * @param value * new value to store in this ref. Must not be null. * @throws IOException * writing is not supported, or attempting to write the file * failed, possibly due to permissions or remote disk full, etc. */ void writeRef(String name, ObjectId value) throws IOException { final ByteArrayOutputStream b; b = new ByteArrayOutputStream(Constants.OBJECT_ID_STRING_LENGTH + 1); value.copyTo(b); b.write('\n'); writeFile(ROOT_DIR + name, b.toByteArray()); }
/** * Write the given heads to a file in the git directory. * * @param heads * a list of object ids to write or null if the file should be * deleted. * @param filename * @throws FileNotFoundException * @throws IOException */ private void writeHeadsFile(List<? extends ObjectId> heads, String filename) throws FileNotFoundException, IOException { File headsFile = new File(getDirectory(), filename); if (heads != null) { try (OutputStream bos = new BufferedOutputStream( new FileOutputStream(headsFile))) { for (ObjectId id : heads) { id.copyTo(bos); bos.write('\n'); } } } else { FileUtils.delete(headsFile, FileUtils.SKIP_MISSING); } }
@Override protected void show(final ObjectWalk ow, final RevObject obj) throws Exception { if (obj.has(RevFlag.UNINTERESTING)) outw.print('-'); obj.getId().copyTo(outbuffer, outw); final String path = ow.getPathString(); if (path != null) { outw.print(' '); outw.print(path); } else if (obj instanceof RevTree) outw.print(' '); outw.println(); } }
private void show(RevWalk rw, final RevCommit c) throws Exception { char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2]; outw.print(CLIText.get().commitLabel); outw.print(" "); //$NON-NLS-1$ c.getId().copyTo(outbuffer, outw); outw.println(); final PersonIdent author = c.getAuthorIdent(); outw.println(MessageFormat.format(CLIText.get().authorInfo, author.getName(), author.getEmailAddress())); final TimeZone authorTZ = author.getTimeZone(); fmt.setTimeZone(authorTZ != null ? authorTZ : myTZ); outw.println(MessageFormat.format(CLIText.get().dateInfo, fmt.format(author.getWhen()))); outw.println(); final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$ for (final String s : lines) { outw.print(" "); //$NON-NLS-1$ outw.print(s); outw.println(); } outw.println(); if (c.getParentCount() == 1) { rw.parseHeaders(c.getParent(0)); showDiff(c); } outw.flush(); }