Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.Git.checkout()


      String originalBranch = repo.getFullBranch();
      boolean empty = repo.resolve(Constants.HEAD) == null;
      if (!empty) {
        if (repo.getRef(branch) == null)
          git.branchCreate().setName(branch).call();
        git.checkout().setName(branch).call();
      }

      writeTrashFile(filename, contents);
      git.add().addFilepattern(filename).call();
      RevCommit commit = git.commit()
View Full Code Here


      git.add().addFilepattern(filename).call();
      RevCommit commit = git.commit()
          .setMessage(branch + ": " + filename).call();

      if (originalBranch != null)
        git.checkout().setName(originalBranch).call();
      else if (empty)
        git.branchCreate().setName(branch).setStartPoint(commit).call();

      return commit;
    } catch (IOException e) {
View Full Code Here

    commitBuilder.setParentId(firstCommitId);
    ObjectId commitId = newObjectInserter.insert(commitBuilder);

    RevWalk revWalk = new RevWalk(git.getRepository());
    if (!secondCheckout)
      git.checkout().setStartPoint(revWalk.parseCommit(firstCommitId))
          .setName("refs/heads/master").setCreateBranch(true).call();
    try {
      if (secondCheckout) {
        git.checkout().setStartPoint(revWalk.parseCommit(commitId))
            .setName("refs/heads/master").setCreateBranch(true)
View Full Code Here

    if (!secondCheckout)
      git.checkout().setStartPoint(revWalk.parseCommit(firstCommitId))
          .setName("refs/heads/master").setCreateBranch(true).call();
    try {
      if (secondCheckout) {
        git.checkout().setStartPoint(revWalk.parseCommit(commitId))
            .setName("refs/heads/master").setCreateBranch(true)
            .call();
      } else {
        git.branchCreate().setName("refs/heads/next")
            .setStartPoint(commitId.name()).call();
View Full Code Here

            .setName("refs/heads/master").setCreateBranch(true)
            .call();
      } else {
        git.branchCreate().setName("refs/heads/next")
            .setStartPoint(commitId.name()).call();
        git.checkout().setName("refs/heads/next")
            .call();
      }
      if (!good)
        fail("Checkout of Tree " + Arrays.asList(path) + " should fail");
    } catch (InvalidPathException e) {
View Full Code Here

      try {
        Repository subRepo = add.call();
        if (revision != null) {
          Git sub = new Git(subRepo);
          sub.checkout().setName(findRef(revision, subRepo)).call();
          git.add().addFilepattern(name).call();
        }
        for (CopyFile copyfile : copyfiles) {
          copyfile.copy();
          git.add().addFilepattern(copyfile.dest).call();
View Full Code Here

    RevCommit c1 = git.commit().setMessage("create file").call();
    writeTrashFile("file.txt", "content2");
    git.add().addFilepattern("file.txt").call();
    RevCommit c2 = git.commit().setMessage("edit file").call();

    git.checkout().setCreateBranch(true).setName("newbranch")
        .setStartPoint(c1).call();

    git.checkout().setName(c1.getName()).call();

    git.checkout().setName("master").call();
View Full Code Here

    RevCommit c2 = git.commit().setMessage("edit file").call();

    git.checkout().setCreateBranch(true).setName("newbranch")
        .setStartPoint(c1).call();

    git.checkout().setName(c1.getName()).call();

    git.checkout().setName("master").call();

    assertEquals(c1.getName(), db.simplify("@{-1}"));
    assertEquals("newbranch", db.simplify("@{-2}"));
View Full Code Here

    git.checkout().setCreateBranch(true).setName("newbranch")
        .setStartPoint(c1).call();

    git.checkout().setName(c1.getName()).call();

    git.checkout().setName("master").call();

    assertEquals(c1.getName(), db.simplify("@{-1}"));
    assertEquals("newbranch", db.simplify("@{-2}"));
    assertEquals("master", db.simplify("@{-3}"));
View Full Code Here

    writeTrashFile(".gitignore", fname);
    git.add().addFilepattern(".gitignore").call();
    git.commit().setMessage("delete and ignore file").call();

    writeTrashFile(fname, "Something different");
    git.checkout().setName("master").call();
    assertWorkDir(mkmap(fname, "b"));
    assertTrue(git.status().call().isClean());
  }

  @Test
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.