Package org.eclipse.jgit.lib

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


    if (branch == null)
      throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote);
    if (!Constants.HEAD.equals(branch.getName())) {
      RefUpdate u = db.updateRef(Constants.HEAD);
      u.disableRefLog();
      u.link(branch.getName());
    }

    final RevCommit commit = parseCommit(branch);
    final RefUpdate u = db.updateRef(Constants.HEAD);
    u.setNewObjectId(commit);
View Full Code Here


    initialCommit = git.commit().setMessage("Initial commit").call();

    // create a master branch and switch to it
    git.branchCreate().setName("test").call();
    RefUpdate rup = db.updateRef(Constants.HEAD);
    rup.link("refs/heads/test");

    // commit something on the test branch
    writeTrashFile("Test.txt", "Some change");
    git.add().addFilepattern("Test.txt").call();
    secondCommit = git.commit().setMessage("Second commit").call();
View Full Code Here

  public void testPackRepoWithCorruptReflog() throws Exception {
    // create a reflog entry "0000... 0000... foobar" by doing an initial
    // refupdate for HEAD which points to a non-existing ref. The
    // All-Projects repo of gerrit instances had such entries
    RefUpdate ru = repo.updateRef(Constants.HEAD);
    ru.link("refs/to/garbage");
    tr.branch("refs/heads/master").commit().add("A", "A").add("B", "B")
        .create();
    // make sure HEAD exists
    Git.wrap(repo).checkout().setName("refs/heads/master").call();
    gc.gc();
View Full Code Here

  @Test
  public void testUpdateSmudgedEntries() throws Exception {
    git.branchCreate().setName("test2").call();
    RefUpdate rup = db.updateRef(Constants.HEAD);
    rup.link("refs/heads/test2");

    File file = new File(db.getWorkTree(), "Test.txt");
    long size = file.length();
    long mTime = file.lastModified() - 5000L;
    assertTrue(file.setLastModified(mTime));
View Full Code Here

      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
      refUpdate.setForceUpdate(force);
      refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false); //$NON-NLS-1$
      Result updateResult;
      if (ref != null)
        updateResult = refUpdate.link(ref.getName());
      else if (orphan) {
        updateResult = refUpdate.link(getBranchName());
        ref = repo.getRef(Constants.HEAD);
      } else {
        refUpdate.setNewObjectId(newCommit);
View Full Code Here

      refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false); //$NON-NLS-1$
      Result updateResult;
      if (ref != null)
        updateResult = refUpdate.link(ref.getName());
      else if (orphan) {
        updateResult = refUpdate.link(getBranchName());
        ref = repo.getRef(Constants.HEAD);
      } else {
        refUpdate.setNewObjectId(newCommit);
        updateResult = refUpdate.forceUpdate();
      }
View Full Code Here

        throw new JGitInternalException("Updating HEAD failed");
      }
      rup = repo.updateRef(Constants.HEAD);
      rup.setRefLogMessage("rebase finished: returning to " + headName, //$NON-NLS-1$
          false);
      res = rup.link(headName);
      switch (res) {
      case FAST_FORWARD:
      case FORCED:
      case NO_CHANGE:
        break;
View Full Code Here

      Result res = null;
      RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
      refUpdate.setRefLogMessage("rebase: aborting", false); //$NON-NLS-1$
      if (headName.startsWith(Constants.R_REFS)) {
        // update the HEAD
        res = refUpdate.link(headName);
      } else {
        refUpdate.setNewObjectId(repo.readOrigHead());
        res = refUpdate.forceUpdate();

      }
View Full Code Here

      }
    }

    // update the HEAD
    RefUpdate refUpdate = db.updateRef(Constants.HEAD);
    refUpdate.link(branchName);
  }

  private void addNewFileToIndex(String filename) throws IOException,
      CorruptObjectException {
    File writeTrashFile = writeTrashFile(filename, filename);
View Full Code Here

    if (branch == null)
      throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote);
    if (!Constants.HEAD.equals(branch.getName())) {
      RefUpdate u = db.updateRef(Constants.HEAD);
      u.disableRefLog();
      u.link(branch.getName());
    }

    final Commit commit = db.mapCommit(branch.getObjectId());
    final RefUpdate u = db.updateRef(Constants.HEAD);
    u.setNewObjectId(commit.getCommitId());
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.