static boolean sameType(FileMode a, FileMode b) { // Files have to be of the same type in order to rename them. // We would never want to rename a file to a gitlink, or a // symlink to a file. // int aType = a.getBits() & FileMode.TYPE_MASK; int bType = b.getBits() & FileMode.TYPE_MASK; return aType == bType; }
private static boolean isFile(FileMode mode) { return (mode.getBits() & FileMode.TYPE_MASK) == FileMode.TYPE_FILE; } }
/** * Try to merge filemodes. If only ours or theirs have changed the mode * (compared to base) we choose that one. If ours and theirs have equal * modes return that one. If also that is not the case the modes are not * mergeable. Return {@link FileMode#MISSING} int that case. * * @param modeB * filemode found in BASE * @param modeO * filemode found in OURS * @param modeT * filemode found in THEIRS * * @return the merged filemode or {@link FileMode#MISSING} in case of a * conflict */ private int mergeFileModes(int modeB, int modeO, int modeT) { if (modeO == modeT) return modeO; if (modeB == modeO) // Base equal to Ours -> chooses Theirs if that is not missing return (modeT == FileMode.MISSING.getBits()) ? modeO : modeT; if (modeB == modeT) // Base equal to Theirs -> chooses Ours if that is not missing return (modeO == FileMode.MISSING.getBits()) ? modeT : modeO; return FileMode.MISSING.getBits(); }
private boolean isEntryGitLink(AbstractTreeIterator ti) { return ((ti != null) && (ti.getEntryRawMode() == FileMode.GITLINK .getBits())); }
private void parseEntry() { final Entry e = entries[ptr]; mode = e.getMode().getBits(); final int nameLen = e.encodedNameLen; ensurePathCapacity(pathOffset + nameLen, pathOffset); System.arraycopy(e.encodedName, 0, path, pathOffset, nameLen); pathLen = pathOffset + nameLen; canonLen = -1; cleanFilterCommandHolder = null; eolStreamTypeHolder = null; }
/** * Set the file mode for this entry. * * @param mode * the new mode constant. * @throws java.lang.IllegalArgumentException * If {@code mode} is * {@link org.eclipse.jgit.lib.FileMode#MISSING}, * {@link org.eclipse.jgit.lib.FileMode#TREE}, or any other type * code not permitted in a tree object. */ public void setFileMode(FileMode mode) { switch (mode.getBits() & FileMode.TYPE_MASK) { case FileMode.TYPE_MISSING: case FileMode.TYPE_TREE: throw new IllegalArgumentException(MessageFormat.format( JGitText.get().invalidModeForPath, mode, getPathString())); } NB.encodeInt32(info, infoOffset + P_MODE, mode.getBits()); }
/** * Is the file mode of the current entry different than the given raw mode? * * @param rawMode * an int. * @return true if different, false otherwise */ public boolean isModeDifferent(int rawMode) { // Determine difference in mode-bits of file and index-entry. In the // bitwise presentation of modeDiff we'll have a '1' when the two modes // differ at this position. int modeDiff = getEntryRawMode() ^ rawMode; if (modeDiff == 0) return false; // Do not rely on filemode differences in case of symbolic links if (getOptions().getSymLinks() == SymLinks.FALSE) if (FileMode.SYMLINK.equals(rawMode)) return false; // Ignore the executable file bits if WorkingTreeOptions tell me to // do so. Ignoring is done by setting the bits representing a // EXECUTABLE_FILE to '0' in modeDiff if (!state.options.isFileMode()) modeDiff &= ~FileMode.EXECUTABLE_FILE.getBits(); return modeDiff != 0; }
DirCacheEntry ent = i.getDirCacheEntry(); if (ent != null && compareMetadata(ent) == MetadataDiff.EQUAL && ((ent.getFileMode().getBits() & FileMode.TYPE_MASK) != FileMode.TYPE_GITLINK)) { contentIdOffset = i.idOffset();
if (mode == FileMode.SYMLINK.getBits()) { return !new File(readSymlinkTarget(current())).equals( new File(readContentAsNormalizedString(entry, reader)));
mode = FileMode.TREE.getBits(); path = cep; pathLen = pathOffset + s.nameLength();
dce.setFileMode(newMode == FileMode.MISSING.getBits() ? FileMode.REGULAR_FILE : FileMode.fromBits(newMode)); if (mergedFile != null) {
if (newMode != FileMode.MISSING.getBits()) { if (newMode == modeO)
private void readEntry() { GfsTreeEntry entry = currentEntry(); mode = entry.getMode().getBits(); id = entry.getId(); byte[] name = encode(entry.getName()); ensurePathCapacity(pathOffset + name.length, pathOffset); arraycopy(name, 0, path, pathOffset, name.length); pathLen = pathOffset + name.length; }
@Override protected void onSelect(AjaxRequestTarget target, QueryHit hit) { BlobIdent blobIdent = new BlobIdent( getRevision(), hit.getBlobPath(), FileMode.REGULAR_FILE.getBits()); context.onSelect(target, blobIdent, hit.getTokenPos()); }
@Override protected void onSelect(AjaxRequestTarget target, QueryHit hit) { BlobIdent selected = new BlobIdent(state.blobIdent.revision, hit.getBlobPath(), FileMode.REGULAR_FILE.getBits()); ProjectBlobPage.this.onSelect(target, selected, hit.getTokenPos()); modal.close(); }