/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path from one entry to another, * supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. */ public void copyMetaData(DirCacheEntry src) { copyMetaData(src, false); }
@Override public void apply(DirCacheEntry ent) { ent.copyMetaData(entry); } });
/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path from one entry to another, * supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. */ public void copyMetaData(final DirCacheEntry src) { copyMetaData(src, false); }
/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path from one entry to another, * supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. */ public void copyMetaData(DirCacheEntry src) { copyMetaData(src, false); }
@Override public void apply(DirCacheEntry ent) { ent.copyMetaData(entry); } });
public void apply(DirCacheEntry ent) { ent.copyMetaData(entry); } });
/** * 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); } }
@Override public void apply(DirCacheEntry ent) { ObjectInserter inserter = repo.newObjectInserter(); if (oldEntry != null) ent.copyMetaData(oldEntry); else ent.setFileMode(FileMode.REGULAR_FILE); ent.setLength(newContent.length); ent.setLastModified(System.currentTimeMillis()); InputStream in = new ByteArrayInputStream(newContent); try { ent.setObjectId(inserter.insert(Constants.OBJ_BLOB, newContent.length, in)); inserter.flush(); } catch (IOException ex) { throw new RuntimeException(ex); } finally { try { in.close(); } catch (IOException e) { // ignore here } } } }
/** * 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); } }
/** * 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); } }