/** * Pass through to the original {@link StagingArea}. */ @Override public void updateStageHead(ObjectId newTree) { index.updateStageHead(newTree); }
/** * Pass through to the original {@link StagingArea}. */ @Override public void updateStageHead(ObjectId newTree) { index.updateStageHead(newTree); }
final boolean nothingElseStaged = headTree.isPresent() && headTree.get().equals(stageTree); if (nothingElseStaged) { stagingArea().updateStageHead(finalWorkTree.getId()); } else { stageDeletes(deleteTrees.values().iterator(), deleteFeatures.iterator());
final boolean nothingElseStaged = headTree.isPresent() && headTree.get().equals(stageTree); if (nothingElseStaged) { stagingArea().updateStageHead(finalWorkTree.getId()); } else { stageDeletes(deleteTrees.values().iterator(), deleteFeatures.iterator());
private Ref doFastForwardMerge(Ref headRef, ObjectId commitId, MergeStatusBuilder mergeStatusBuilder) { getProgressListener().setDescription(String.format("Fast forward merging %s onto %s", commitId.toString().substring(0, 8), headRef.getObjectId().toString().substring(0, 8))); if (headRef instanceof SymRef) { final String currentBranch = ((SymRef) headRef).getTarget(); command(UpdateRef.class).setName(currentBranch).setNewValue(commitId).call(); headRef = (SymRef) command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(currentBranch).call().get(); } else { headRef = command(UpdateRef.class).setName(headRef.getName()).setNewValue(commitId) .call().get(); } workingTree().updateWorkHead(commitId); stagingArea().updateStageHead(commitId); mergeStatusBuilder.setChanged(true); return headRef; }
/** * Updates the remote ref that matches the given refspec. * * @param refspec the ref to update * @param commitId the new value of the ref * @param delete if true, the remote ref will be deleted * @return the updated ref */ @Override protected Optional<Ref> updateRemoteRef(String refspec, ObjectId commitId, boolean delete) { Optional<Ref> updatedRef = remoteRepo.command(UpdateRef.class).setName(refspec) .setNewValue(commitId).setDelete(delete).call(); if (updatedRef.isPresent()) { final Ref remoteHead = headRef().orNull(); if (remoteHead instanceof SymRef) { if (((SymRef) remoteHead).getTarget().equals(updatedRef.get().getName())) { remoteRepo.command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(updatedRef.get().getName()).call(); RevCommit commit = remoteRepo.getCommit(commitId); remoteRepo.workingTree().updateWorkHead(commit.getTreeId()); remoteRepo.index().updateStageHead(commit.getTreeId()); } } } return updatedRef; }
/** * Updates the remote ref that matches the given refspec. * * @param refspec the ref to update * @param commitId the new value of the ref * @param delete if true, the remote ref will be deleted * @return the updated ref */ @Override protected Optional<Ref> updateRemoteRef(String refspec, ObjectId commitId, boolean delete) { Optional<Ref> updatedRef = remoteRepo.command(UpdateRef.class).setName(refspec) .setNewValue(commitId).setDelete(delete).call(); if (updatedRef.isPresent()) { final Ref remoteHead = headRef().orNull(); if (remoteHead instanceof SymRef) { if (((SymRef) remoteHead).getTarget().equals(updatedRef.get().getName())) { remoteRepo.command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(updatedRef.get().getName()).call(); RevCommit commit = remoteRepo.getCommit(commitId); remoteRepo.workingTree().updateWorkHead(commit.getTreeId()); remoteRepo.index().updateStageHead(commit.getTreeId()); } } } return updatedRef; }
stagingArea().updateStageHead(treeId); result.setNewTree(treeId); if (targetRef.isPresent()) {
stagingArea().updateStageHead(treeId); checkoutResult.setNewTree(treeId); if (targetRef.isPresent()) {
stagingArea().updateStageHead(newTreeId);
@Override public void pushNewData(final Repository local, final Ref ref, final String refspec, final ProgressListener progress) throws SynchronizationException { Optional<Ref> remoteRef = remoteRepository.command(RefParse.class).setName(refspec).call(); remoteRef = remoteRef.or( remoteRepository.command(RefParse.class).setName(Ref.TAGS_PREFIX + refspec).call()); checkPush(local, ref, remoteRef); CommitTraverser traverser = getPushTraverser(local, remoteRef); traverser.traverse(ref.getObjectId()); progress.setDescription("Uploading objects to " + refspec); progress.setProgress(0); while (!traverser.commits.isEmpty()) { ObjectId commitId = traverser.commits.pop(); walkHead(commitId, local, remoteRepository, progress); } String nameToSet = remoteRef.isPresent() ? remoteRef.get().getName() : Ref.HEADS_PREFIX + refspec; Ref updatedRef = remoteRepository.command(UpdateRef.class).setName(nameToSet) .setNewValue(ref.getObjectId()).call().get(); Ref remoteHead = headRef().orNull(); if (remoteHead instanceof SymRef) { if (((SymRef) remoteHead).getTarget().equals(updatedRef.getName())) { remoteRepository.command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(ref.getName()).call(); RevCommit commit = remoteRepository.getCommit(ref.getObjectId()); remoteRepository.workingTree().updateWorkHead(commit.getTreeId()); remoteRepository.index().updateStageHead(commit.getTreeId()); } } }
case HARD: stagingArea().updateStageHead(oldCommit.getTreeId()); workingTree().updateWorkHead(oldCommit.getTreeId()); break; case MIXED: stagingArea().updateStageHead(oldCommit.getTreeId()); break; default:
private Ref doFastForwardMerge(Ref headRef, ObjectId commitId, MergeStatusBuilder mergeStatusBuilder) { if (headRef instanceof SymRef) { final String currentBranch = ((SymRef) headRef).getTarget(); command(UpdateRef.class).setName(currentBranch).setNewValue(commitId).call(); headRef = (SymRef) command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(currentBranch).call().get(); } else { headRef = command(UpdateRef.class).setName(headRef.getName()).setNewValue(commitId) .call().get(); } workingTree().updateWorkHead(commitId); stagingArea().updateStageHead(commitId); mergeStatusBuilder.setChanged(true); return headRef; }
stagingArea().updateStageHead(newTreeId);
@Override public void pushNewData(final Repository local, final Ref ref, final String refspec, final ProgressListener progress) throws SynchronizationException { Optional<Ref> remoteRef = remoteRepository.command(RefParse.class).setName(refspec).call(); remoteRef = remoteRef.or( remoteRepository.command(RefParse.class).setName(Ref.TAGS_PREFIX + refspec).call()); checkPush(local, ref, remoteRef); CommitTraverser traverser = getPushTraverser(local, remoteRef); traverser.traverse(ref.getObjectId()); progress.setDescription("Uploading objects to " + refspec); progress.setProgress(0); while (!traverser.commits.isEmpty()) { ObjectId commitId = traverser.commits.pop(); walkHead(commitId, local, remoteRepository, progress); } String nameToSet = remoteRef.isPresent() ? remoteRef.get().getName() : Ref.HEADS_PREFIX + refspec; Ref updatedRef = remoteRepository.command(UpdateRef.class).setName(nameToSet) .setNewValue(ref.getObjectId()).call().get(); Ref remoteHead = headRef().orNull(); if (remoteHead instanceof SymRef) { if (((SymRef) remoteHead).getTarget().equals(updatedRef.getName())) { remoteRepository.command(UpdateSymRef.class).setName(Ref.HEAD) .setNewValue(ref.getName()).call(); RevCommit commit = remoteRepository.getCommit(ref.getObjectId()); remoteRepository.workingTree().updateWorkHead(commit.getTreeId()); remoteRepository.index().updateStageHead(commit.getTreeId()); } } }
repository.index().updateStageHead(newTreeId);
case HARD: stagingArea().updateStageHead(oldCommit.getTreeId()); workingTree().updateWorkHead(oldCommit.getTreeId()); break; case MIXED: stagingArea().updateStageHead(oldCommit.getTreeId()); break; default:
stagingArea().updateStageHead(newTreeId);
private void createCommit(RevCommit commit) { // write new tree ObjectId newTreeId = command(WriteTree2.class).call(); long timestamp = platform().currentTimeMillis(); String committerName = resolveCommitter(); String committerEmail = resolveCommitterEmail(); // Create new commit CommitBuilder builder = new CommitBuilder(); builder.setParentIds(Arrays.asList(revertHead)); builder.setTreeId(newTreeId); builder.setCommitterTimestamp(timestamp); builder.setMessage( "Revert '" + commit.getMessage() + "'\nThis reverts " + commit.getId().toString()); builder.setCommitter(committerName); builder.setCommitterEmail(committerEmail); builder.setAuthor(committerName); builder.setAuthorEmail(committerEmail); RevCommit newCommit = builder.build(); objectDatabase().put(newCommit); revertHead = newCommit.getId(); command(UpdateRef.class).setName(currentBranch).setNewValue(revertHead).call(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call(); workingTree().updateWorkHead(newTreeId); stagingArea().updateStageHead(newTreeId); }
private void createCommit(RevCommit commit) { // write new tree ObjectId newTreeId = command(WriteTree2.class).call(); long timestamp = platform().currentTimeMillis(); String committerName = resolveCommitter(); String committerEmail = resolveCommitterEmail(); // Create new commit RevCommitBuilder builder = RevCommit.builder(); builder.parentIds(Arrays.asList(revertHead)); builder.treeId(newTreeId); builder.committerTimestamp(timestamp); builder.message( "Revert '" + commit.getMessage() + "'\nThis reverts " + commit.getId().toString()); builder.committer(committerName); builder.committerEmail(committerEmail); builder.author(committerName); builder.authorEmail(committerEmail); RevCommit newCommit = builder.build(); objectDatabase().put(newCommit); revertHead = newCommit.getId(); command(UpdateRef.class).setName(currentBranch).setNewValue(revertHead).call(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call(); workingTree().updateWorkHead(newTreeId); stagingArea().updateStageHead(newTreeId); }