Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefUpdate.forceUpdate()


            branchName = "refs/heads/" + branchName;
          }
          RefUpdate ru = repository.updateRef(branchName);
          ru.setNewObjectId(commitId);
          ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
          Result rc = ru.forceUpdate();
          switch (rc) {
          case NEW:
          case FORCED:
          case FAST_FORWARD:
            success = true;
View Full Code Here


          RevCommit revCommit = revWalk.parseCommit(commitId);
          RefUpdate ru = repository.updateRef(GB_REFLOG);
          ru.setNewObjectId(commitId);
          ru.setExpectedOldObjectId(headId);
          ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
          Result rc = ru.forceUpdate();
          switch (rc) {
          case NEW:
          case FORCED:
          case FAST_FORWARD:
            success = true;
View Full Code Here

        RevCommit revCommit = revWalk.parseCommit(commitId);
        RefUpdate ru = db.updateRef(BRANCH);
        ru.setNewObjectId(commitId);
        ru.setExpectedOldObjectId(headId);
        ru.setRefLogMessage("commit: " + revCommit.getShortMessage(), false);
        Result rc = ru.forceUpdate();
        switch (rc) {
        case NEW:
        case FORCED:
        case FAST_FORWARD:
          success = true;
View Full Code Here

    RevCommit commit2 = add(repo2, "test2.txt", "content2.txt");
    Repository repo = new FileRepository(testRepo);
    RefUpdate originMaster = repo.updateRef(Constants.R_REMOTES
        + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER);
    originMaster.setNewObjectId(commit1);
    originMaster.forceUpdate();
    RemoteConfig config = new RemoteConfig(repo.getConfig(),
        Constants.DEFAULT_REMOTE_NAME);
    config.addURI(new URIish(repo2.toURI().toString()));
    config.update(repo.getConfig());
    Collection<RefDiff> diffs = RepositoryUtils.diffOriginRefs(repo);
View Full Code Here

    // update the HEAD
    RefUpdate refUpdate = db.updateRef(Constants.HEAD, true);
    refUpdate.setNewObjectId(commit);
    refUpdate.setRefLogMessage("checkout: moving to " + head.getName(),
        false);
    refUpdate.forceUpdate();
  }

  @Test
  public void testFastForwardWithNewFile() throws Exception {
    // create file1 on master
View Full Code Here

    remoteGit.add().addFilepattern("Test.txt").call();
    secondCommit = remoteGit.commit().setMessage("Second commit").call();
    // create a master branch
    RefUpdate rup = remoteRepository.updateRef("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.forceUpdate();

    Repository localRepository = createWorkRepository();
    Git localGit = new Git(localRepository);
    StoredConfig config = localRepository.getConfig();
    RemoteConfig rc = new RemoteConfig(config, "origin");
View Full Code Here

    config.save();
    FetchResult res = localGit.fetch().setRemote("origin").call();
    assertFalse(res.getTrackingRefUpdates().isEmpty());
    rup = localRepository.updateRef("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.forceUpdate();
    rup = localRepository.updateRef(Constants.HEAD);
    rup.link("refs/heads/master");
    rup.setNewObjectId(initialCommit.getId());
    rup.update();
    return localGit;
View Full Code Here

      // expected
    }
    // rename without old name and detached head not allowed
    RefUpdate rup = git.getRepository().updateRef(Constants.HEAD, true);
    rup.setNewObjectId(initialCommit);
    rup.forceUpdate();
    try {
      git.branchRename().setNewName("detached").call();
    } catch (DetachedHeadException e) {
      // expected
    }
View Full Code Here

    refUpdate.setRefLogMessage(refLogMessage, false);
    if (currentRef != null)
      refUpdate.setExpectedOldObjectId(currentRef.getObjectId());
    else
      refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
    refUpdate.forceUpdate();
  }

  private Ref getHead() throws GitAPIException {
    try {
      Ref head = repo.getRef(Constants.HEAD);
View Full Code Here

    final RevCommit commit = parseCommit(clonedRepo, head);

    boolean detached = !head.getName().startsWith(Constants.R_HEADS);
    RefUpdate u = clonedRepo.updateRef(Constants.HEAD, detached);
    u.setNewObjectId(commit.getId());
    u.forceUpdate();

    if (!bare) {
      DirCache dc = clonedRepo.lockDirCache();
      DirCacheCheckout co = new DirCacheCheckout(clonedRepo, dc,
          commit.getTree());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.