private RefUpdate createRefUpdate(Ref stashRef) throws IOException { RefUpdate update = repo.updateRef(R_STASH); update.disableRefLog(); update.setExpectedOldObjectId(stashRef.getObjectId()); update.setForceUpdate(true); return update; }
private RefUpdate.Result updateRef(ObjectId newId) throws IOException { RefUpdate ru = db.updateRef(REF_NAME); ru.setExpectedOldObjectId(commit != null ? commit : ObjectId.zeroId()); ru.setNewObjectId(newId); ru.setRefLogIdent(pending.get(pending.size() - 1).ident); ru.setRefLogMessage(JGitText.get().storePushCertReflog, false); try (RevWalk rw = new RevWalk(reader)) { return ru.update(rw); } }
private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, String refLogMessage) throws IOException { Ref currentRef = repo.exactRef(Constants.R_STASH); RefUpdate refUpdate = repo.updateRef(Constants.R_STASH); refUpdate.setNewObjectId(commitId); refUpdate.setRefLogIdent(refLogIdent); refUpdate.setRefLogMessage(refLogMessage, false); refUpdate.setForceRefLog(true); if (currentRef != null) refUpdate.setExpectedOldObjectId(currentRef.getObjectId()); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.forceUpdate(); }
private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, String refLogMessage) throws IOException { if (ref == null) return; Ref currentRef = repo.findRef(ref); RefUpdate refUpdate = repo.updateRef(ref); refUpdate.setNewObjectId(commitId); refUpdate.setRefLogIdent(refLogIdent); refUpdate.setRefLogMessage(refLogMessage, false); refUpdate.setForceRefLog(true); if (currentRef != null) refUpdate.setExpectedOldObjectId(currentRef.getObjectId()); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.forceUpdate(); }
private void updateHead(StringBuilder refLogMessage, ObjectId newHeadId, ObjectId oldHeadID) throws IOException, ConcurrentRefUpdateException { RefUpdate refUpdate = repo.updateRef(Constants.HEAD); refUpdate.setNewObjectId(newHeadId); refUpdate.setRefLogMessage(refLogMessage.toString(), false); refUpdate.setExpectedOldObjectId(oldHeadID); Result rc = refUpdate.update(); switch (rc) { case NEW: case FAST_FORWARD: return; case REJECTED: case LOCK_FAILURE: throw new ConcurrentRefUpdateException( JGitText.get().couldNotLockHEAD, refUpdate.getRef(), rc); default: throw new JGitInternalException(MessageFormat.format( JGitText.get().updatingRefFailed, Constants.HEAD, newHeadId.toString(), rc)); } }
/** {@inheritDoc} */ @Override protected Result doRename() throws IOException { // TODO Correctly handle renaming foo/bar to foo. // TODO Batch these together into one log update. destination.setExpectedOldObjectId(ObjectId.zeroId()); destination.setNewObjectId(source.getRef().getObjectId()); switch (destination.update()) { case NEW: source.delete(); return Result.RENAMED; default: return destination.getResult(); } } }
static void commitNoteMap(Repository r, String ref, RevWalk walk, NoteMap map, RevCommit notesCommit, ObjectInserter inserter, String msg) throws IOException { // commit the note CommitBuilder builder = new CommitBuilder(); builder.setTreeId(map.writeTree(inserter)); builder.setAuthor(new PersonIdent(r)); builder.setCommitter(builder.getAuthor()); builder.setMessage(msg); if (notesCommit != null) builder.setParentIds(notesCommit); ObjectId commit = inserter.insert(builder); inserter.flush(); RefUpdate refUpdate = r.updateRef(ref); if (notesCommit != null) refUpdate.setExpectedOldObjectId(notesCommit); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.setNewObjectId(commit); refUpdate.update(walk); }
case DELETE: if (!ObjectId.zeroId().equals(cmd.getOldId())) ru.setExpectedOldObjectId(cmd.getOldId()); ru.setForceUpdate(true); return ru; default: ru.setForceUpdate(isAllowNonFastForwards()); ru.setExpectedOldObjectId(cmd.getOldId()); ru.setNewObjectId(cmd.getNewId()); return ru;
if (headName.startsWith(Constants.R_HEADS)) { RefUpdate rup = repo.updateRef(headName); rup.setExpectedOldObjectId(oldCommit); rup.setNewObjectId(newCommit); rup.setRefLogMessage("Fast-forward from " + oldCommit.name() //$NON-NLS-1$
ru.setExpectedOldObjectId(headId != null ? headId : ObjectId.zeroId()); Result rc = ru.update(rw);
refUpdate.setExpectedOldObjectId(head); refUpdate.setNewObjectId(commit); refUpdate.setRefLogMessage(
source.setExpectedOldObjectId(objId); source.setForceUpdate(true); source.disableRefLog(); source.setExpectedOldObjectId(ObjectId.zeroId()); source.setNewObjectId(objId); source.update(rw); dst.setExpectedOldObjectId(ObjectId.zeroId()); dst.setNewObjectId(objId); if (dst.update(rw) != Result.NEW) { source.setExpectedOldObjectId(ObjectId.zeroId()); source.setNewObjectId(objId); source.update(rw);
ru.setExpectedOldObjectId(headId); else ru.setExpectedOldObjectId(ObjectId.zeroId()); Result rc = ru.forceUpdate(); switch (rc) {
ru.setExpectedOldObjectId(getOldId()); case UPDATE_NONFASTFORWARD: ru.setForceUpdate(rp.isAllowNonFastForwards()); ru.setExpectedOldObjectId(getOldId()); ru.setRefLogMessage("push", true); //$NON-NLS-1$ if (getNewSymref() != null) {
.updateRef(head.getTarget().getName()); refUpdate.setNewObjectId(objectId); refUpdate.setExpectedOldObjectId(null); refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$ if (refUpdate.update() != Result.NEW)
private RefUpdate createRefUpdate(final Ref stashRef) throws IOException { RefUpdate update = repo.updateRef(R_STASH); update.disableRefLog(); update.setExpectedOldObjectId(stashRef.getObjectId()); update.setForceUpdate(true); return update; }
private RefUpdate.Result updateRef(ObjectId newId) throws IOException { RefUpdate ru = db.updateRef(REF_NAME); ru.setExpectedOldObjectId(commit != null ? commit : ObjectId.zeroId()); ru.setNewObjectId(newId); ru.setRefLogIdent(pending.get(pending.size() - 1).ident); ru.setRefLogMessage(JGitText.get().storePushCertReflog, false); try (RevWalk rw = new RevWalk(reader)) { return ru.update(rw); } }
private static void setBranchHead(String name, AnyObjectId commitId, Repository repo, @Nullable String refLogMessage, boolean forceUpdate) throws IOException { String refName = fullBranchName(name); AnyObjectId currentHead = repo.resolve(refName); if(currentHead == null) currentHead = zeroId(); RefUpdate update = repo.updateRef(refName); update.setRefLogMessage(refLogMessage, false); update.setForceUpdate(forceUpdate); update.setNewObjectId(commitId); update.setExpectedOldObjectId(currentHead); RefUpdateValidator.validate(update.update()); }
private static void setBranchHead(String name, AnyObjectId commitId, Repository repo, @Nullable String refLogMessage, boolean forceUpdate) throws IOException { String refName = fullBranchName(name); AnyObjectId currentHead = repo.resolve(refName); if(currentHead == null) currentHead = zeroId(); RefUpdate update = repo.updateRef(refName); update.setRefLogMessage(refLogMessage, false); update.setForceUpdate(forceUpdate); update.setNewObjectId(commitId); update.setExpectedOldObjectId(currentHead); RefUpdateValidator.validate(update.update()); }
public static void addToStash(RevCommit commit, Repository repo) throws IOException { RefUpdate update = repo.updateRef(R_STASH); update.setNewObjectId(commit); update.setRefLogIdent(commit.getCommitterIdent()); AnyObjectId prevStash = repo.resolve(R_STASH); update.setExpectedOldObjectId(prevStash != null ? prevStash : zeroId()); update.forceUpdate(); }