/** * {@inheritDoc} * <p> * Use for debugging only ! */ @SuppressWarnings("nls") @Override public String toString() { return getFileMode() + " " + getLength() + " " + getLastModified() + " " + getObjectId() + " " + getStage() + " " + getPathString() + "\n"; }
/** * adds a entry to the index builder which is a copy of the specified * DirCacheEntry * * @param e * the entry which should be copied * * @return the entry which was added to the index */ private DirCacheEntry keep(DirCacheEntry e) { DirCacheEntry newEntry = new DirCacheEntry(e.getRawPath(), e.getStage()); newEntry.setFileMode(e.getFileMode()); newEntry.setObjectId(e.getObjectId()); newEntry.setLastModified(e.getLastModified()); newEntry.setLength(e.getLength()); builder.add(newEntry); return newEntry; }
@Override public void apply(DirCacheEntry ent) { ent.setFileMode(FileMode.REGULAR_FILE); ent.setObjectId(certId); } });
/** * adds a new path with the specified stage to the index builder * * @param path * @param p * @param stage * @param lastMod * @param len * @return the entry which was added to the index */ private DirCacheEntry add(byte[] path, CanonicalTreeParser p, int stage, long lastMod, long len) { if (p != null && !p.getEntryFileMode().equals(FileMode.TREE)) { DirCacheEntry e = new DirCacheEntry(path, stage); e.setFileMode(p.getEntryFileMode()); e.setObjectId(p.getEntryObjectId()); e.setLastModified(lastMod); e.setLength(len); builder.add(e); return e; } return null; }
final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath()); entry.setFileMode(cIter.getEntryFileMode()); entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset()); if (dcIter != null && dcIter.idEqual(cIter)) { DirCacheEntry indexEntry = dcIter.getDirCacheEntry(); entry.setLastModified(indexEntry.getLastModified()); entry.setLength(indexEntry.getLength());
@Override public void apply(DirCacheEntry ent) { ent.setFileMode(oldEntry.getFileMode()); ent.setObjectId(oldEntry.getObjectId()); } });
private void update(String path, ObjectId mId, FileMode mode) throws IOException { if (!FileMode.TREE.equals(mode)) { updated.put(path, new CheckoutMetadata( walk.getEolStreamType(CHECKOUT_OP), walk.getFilterCommand(Constants.ATTR_FILTER_TYPE_SMUDGE))); DirCacheEntry entry = new DirCacheEntry(path, DirCacheEntry.STAGE_0); entry.setObjectId(mId); entry.setFileMode(mode); builder.add(entry); } }
if (entry != null && entry.getStage() > 0 && lastAdded != null && lastAdded.length == tw.getPathLength() && (!update || GITLINK == entry.getFileMode())) { builder.add(entry); if (entry != null && entry.isAssumeValid()) { if (entry == null || entry.getStage() > 0) { entry = new DirCacheEntry(path); entry.setFileMode(mode); entry.setLength(f.getEntryLength()); entry.setLastModified(f.getEntryLastModified()); long len = f.getEntryContentLength(); entry.setObjectId(id); entry.setLength(0); entry.setLastModified(0); entry.setObjectId(f.getEntryObjectId());
WorkingTreeIterator.class); if (indexIter != null && !indexIter.getDirCacheEntry().isMerged()) throw new UnmergedPathsException( new UnmergedPathException( continue; treeWalk.getObjectId(id, 0); final DirCacheEntry entry = new DirCacheEntry( treeWalk.getRawPath()); entry.setLength(wtIter.getEntryLength()); entry.setLastModified(wtIter.getEntryLastModified()); entry.setFileMode(wtIter.getEntryFileMode()); long contentLength = wtIter.getEntryContentLength(); try (InputStream in = wtIter.openEntryStream()) { entry.setObjectId(inserter.insert( Constants.OBJ_BLOB, contentLength, in)); String repoRelativePath = entry.getPathString(); File file = new File(repo.getWorkTree(), repoRelativePath);
/** * A conflict is detected - add the three different stages to the index * @param path the path of the conflicting entry * @param e the previous index entry * @param h the first tree you want to merge (the HEAD) * @param m the second tree you want to merge */ private void conflict(String path, DirCacheEntry e, AbstractTreeIterator h, AbstractTreeIterator m) { conflicts.add(path); DirCacheEntry entry; if (e != null) { entry = new DirCacheEntry(e.getPathString(), DirCacheEntry.STAGE_1); entry.copyMetaData(e, true); builder.add(entry); } if (h != null && !FileMode.TREE.equals(h.getEntryFileMode())) { entry = new DirCacheEntry(h.getEntryPathString(), DirCacheEntry.STAGE_2); entry.setFileMode(h.getEntryFileMode()); entry.setObjectId(h.getEntryObjectId()); builder.add(entry); } if (m != null && !FileMode.TREE.equals(m.getEntryFileMode())) { entry = new DirCacheEntry(m.getEntryPathString(), DirCacheEntry.STAGE_3); entry.setFileMode(m.getEntryFileMode()); entry.setObjectId(m.getEntryObjectId()); builder.add(entry); } }
if (checkoutMetadata == null) checkoutMetadata = CheckoutMetadata.EMPTY; ObjectLoader ol = or.open(entry.getObjectId()); File f = new File(repo.getWorkTree(), entry.getPathString()); File parentDir = f.getParentFile(); FileUtils.mkdirs(parentDir, true); FS fs = repo.getFS(); WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY); if (entry.getFileMode() == FileMode.SYMLINK && opt.getSymLinks() == SymLinks.TRUE) { byte[] bytes = ol.getBytes(); entry.setLength(bytes.length); entry.setLastModified(fs.lastModified(f)); return; entry.setLength(ol.getSize()); } else { entry.setLength(tmpFile.length()); if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) { if (!fs.canExecute(tmpFile)) fs.setExecute(tmpFile, true); entry.setLastModified(fs.lastModified(f));
for (int i = 0; i < cache.getEntryCount(); i++) { final DirCacheEntry ent = cache.getEntry(i); final FileMode mode = FileMode.fromBits(ent.getRawMode()); final int len = ent.getLength(); long lastModified = ent.getLastModified(); final Date mtime = new Date(lastModified); final int stage = ent.getStage(); outw.print(fmt.format(mtime)); outw.print(' '); outw.print(ent.getObjectId().name()); outw.print(' '); outw.print(stage); outw.print('\t'); outw.print(ent.getPathString()); outw.println();
if (entry.isAssumeValid()) return MetadataDiff.EQUAL; if (entry.isUpdateNeeded()) return MetadataDiff.DIFFER_BY_METADATA; if (isModeDifferent(entry.getRawMode())) return MetadataDiff.DIFFER_BY_METADATA; return MetadataDiff.EQUAL; if (!entry.isSmudged() && entry.getLength() != (int) getEntryLength()) return MetadataDiff.DIFFER_BY_METADATA; long cacheLastModified = entry.getLastModified(); long fileLastModified = getEntryLastModified(); long lastModifiedMillis = fileLastModified % 1000; else if (!entry.isSmudged())
final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath()); entry.setFileMode(cIter.getEntryFileMode()); entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset()); entry.getPathString()); actuallyModifiedPaths.add(entry.getPathString());
case DIFFER_BY_METADATA: if (mode == FileMode.TREE.getBits() && entry.getFileMode().equals(FileMode.GITLINK)) { byte[] idBuffer = idBuffer(); int idOffset = idOffset(); if (entry.getObjectId().compareTo(idBuffer, idOffset) == 0) { return true; } else if (ObjectId.zeroId().compareTo(idBuffer, idOffset) == 0) { return new File(repository.getWorkTree(), entry.getPathString()).list().length > 0;
for (int eIdx = 0; eIdx < end; eIdx++) { DirCacheEntry e = entries[eIdx]; if (e.getStage() != 0) { continue; if (n.getStage() != 0) { continue; int m = s < nPath.length ? TYPE_TREE : n.getRawMode(); int cmp = compareSameName( ePath, prefixLen, ePath.length, } else if (cmp == 0) { throw new DirCacheNameConflictException( e.getPathString(), n.getPathString());
walk.setOperationType(OperationType.CHECKIN_OP); for (int i = 0; i < entryCnt; i++) if (sortedEntries[i].isSmudged()) paths.add(sortedEntries[i].getPathString()); if (paths.isEmpty()) return; continue; DirCacheEntry entry = iIter.getDirCacheEntry(); if (entry.isSmudged() && iIter.idEqual(fIter)) { entry.setLength(fIter.getEntryLength()); entry.setLastModified(fIter.getEntryLastModified());
private static DirCacheEntry toEntry(int stage, CanonicalTreeParser i) { byte[] buf = i.getEntryPathBuffer(); int len = i.getEntryPathLength(); byte[] path = new byte[len]; System.arraycopy(buf, 0, path, 0, len); DirCacheEntry e = new DirCacheEntry(path, stage); e.setFileMode(i.getEntryRawMode()); e.setObjectIdFromRaw(i.idBuffer(), i.idOffset()); return e; }
@Override public void apply(DirCacheEntry ent) { ent.setFileMode(tw.getFileMode(0)); ent.setObjectId(tw.getObjectId(0)); // for index & working tree compare ent.setLastModified(0); } });
private static IllegalStateException bad(DirCacheEntry a, String msg) { return new IllegalStateException(String.format( "%s: %d %s", //$NON-NLS-1$ msg, Integer.valueOf(a.getStage()), a.getPathString())); } }