/** * Create a new update command by path name. * * @param entryPath * path of the file within the repository. */ public PathEdit(String entryPath) { path = Constants.encode(entryPath); }
/** * Create an empty entry at stage 0. * * @param newPath * name of the cache entry. * @throws java.lang.IllegalArgumentException * If the path starts or ends with "/", or contains "//" either * "\0". These sequences are not permitted in a git tree object * or DirCache file. */ public DirCacheEntry(String newPath) { this(Constants.encode(newPath), STAGE_0); }
private PathSuffixFilter(String s) { pathStr = s; pathRaw = Constants.encode(pathStr); }
private PathFilter(String s) { pathStr = s; pathRaw = Constants.encode(pathStr); }
/** * Create an empty entry at the specified stage. * * @param newPath * name of the cache entry. * @param stage * the stage index of the new entry. * @throws java.lang.IllegalArgumentException * If the path starts or ends with "/", or contains "//" either * "\0". These sequences are not permitted in a git tree object * or DirCache file. Or if {@code stage} is outside of the * range 0..3, inclusive. */ public DirCacheEntry(String newPath, int stage) { this(Constants.encode(newPath), stage); }
/** * Create a key for a specific footer line. * * @param keyName * name of the footer line. */ public FooterKey(String keyName) { name = keyName; raw = Constants.encode(keyName.toLowerCase(Locale.ROOT)); }
@Override void sendString(String s) throws IOException { msgOut.write(Constants.encode(s + "\n")); //$NON-NLS-1$ } });
private void send(StringBuilder s) { if (write) { try { out.write(Constants.encode(s.toString())); out.flush(); } catch (IOException err) { write = false; } } } }
/** * Write a UTF-8 encoded string as a single length-delimited packet. * * @param s * string to write. * @throws java.io.IOException * the packet could not be written, the stream is corrupted as * the packet may have been only partially written. */ public void writeString(String s) throws IOException { writePacket(Constants.encode(s)); }
/** * Seek the iterator on a file, if present. * * @param name * file name to find (will not find a directory). * @return true if the file exists in this tree; false otherwise. * @throws org.eclipse.jgit.errors.CorruptObjectException * tree is invalid. * @since 4.2 */ public boolean findFile(String name) throws CorruptObjectException { return findFile(Constants.encode(name)); }
/** * Insert a literal string of text, in UTF-8 encoding. * * @param text * the string to insert. * @return true if the insert fits within the limit; false if the insert * would cause the instruction stream to exceed the limit. * @throws java.io.IOException * the instruction buffer can't store the instructions. */ public boolean insert(String text) throws IOException { return insert(Constants.encode(text)); }
/** * Append any entry to the tree. * * @param name * name of the entry. * @param mode * mode describing the treatment of {@code id}. * @param id * the ObjectId to store in this entry. */ public void append(String name, FileMode mode, AnyObjectId id) { append(encode(name), mode, id); }
/** * Send a message to the client, if it supports receiving them. * <p> * If the client doesn't support receiving messages, the message will be * discarded, with no other indication to the caller or to the client. * * @param what * string describing the problem identified by the hook. The * string must not end with an LF, and must not contain an LF. */ public void sendMessage(String what) { msgOutWrapper.write(Constants.encode(what + "\n")); //$NON-NLS-1$ }
/** * Parse a name string (e.g. author, committer, tagger) into a PersonIdent. * <p> * Leading spaces won't be trimmed from the string, i.e. will show up in the * parsed name afterwards. * * @param in * the string to parse a name from. * @return the parsed identity or null in case the identity could not be * parsed. */ public static PersonIdent parsePersonIdent(String in) { return parsePersonIdent(Constants.encode(in), 0); }
/** * Locate the position a path's entry is at in the index. For details refer * to #findEntry(byte[], int). * * @param path * the path to search for. * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. */ public int findEntry(String path) { final byte[] p = Constants.encode(path); return findEntry(p, p.length); }
private byte[] encode(ObjectId oldId, ObjectId newId, PersonIdent ident, String message) { StringBuilder r = new StringBuilder(); r.append(ObjectId.toString(oldId)); r.append(' '); r.append(ObjectId.toString(newId)); r.append(' '); r.append(ident.toExternalString()); r.append('\t'); r.append( message.replace("\r\n", " ") //$NON-NLS-1$ //$NON-NLS-2$ .replace("\n", " ")); //$NON-NLS-1$ //$NON-NLS-2$ r.append('\n'); return Constants.encode(r.toString()); }
static ObjectId symref(String s) { @SuppressWarnings("resource") ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); return fmt.idFor(OBJ_BLOB, encode(s)); } }
private void fatalError(String msg) { if (errOut != null) { try { errOut.write(Constants.encode(msg)); errOut.flush(); } catch (IOException e) { // Ignore write failures } } else { sendError(msg); } }
private boolean reportInternalServerErrorOverSideband() { try { @SuppressWarnings("resource" /* java 7 */) SideBandOutputStream err = new SideBandOutputStream( SideBandOutputStream.CH_ERROR, SideBandOutputStream.SMALL_BUF, rawOut); err.write(Constants.encode(JGitText.get().internalServerError)); err.flush(); return true; } catch (Throwable cannotReport) { // Ignore the reason. This is a secondary failure. return false; } }
private static CanonicalTreeParser createParserAtPath(ObjectReader reader, AnyObjectId srcId, String prefix) throws IOException { ObjectId root = toTree(reader, srcId); if (prefix.isEmpty()) { return new CanonicalTreeParser(BINARY_R_REFS, reader, root); } String dir = RefTree.refPath(Paths.stripTrailingSeparator(prefix)); TreeWalk tw = TreeWalk.forPath(reader, dir, root); if (tw == null || !tw.isSubtree()) { return null; } ObjectId id = tw.getObjectId(0); return new CanonicalTreeParser(encode(prefix), reader, id); }