Package org.eclipse.jgit.api

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


    assertTrue(status.getModified().isEmpty());
    assertTrue(status.getChanged().isEmpty());
    assertTrue(db.getFS().canExecute(file));

    // Switch branches
    git.checkout().setName("b1").call();

    // Verify not executable and working directory is clean
    status = git.status().call();
    assertTrue(status.getModified().isEmpty());
    assertTrue(status.getChanged().isEmpty());
View Full Code Here


    assertTrue(db.getFS().canExecute(file));

    writeTrashFile("file.txt", "b");

    // Switch branches
    CheckoutCommand checkout = git.checkout().setName("b1");
    try {
      checkout.call();
      fail("Checkout exception not thrown");
    } catch (org.eclipse.jgit.api.errors.CheckoutConflictException e) {
      CheckoutResult result = checkout.getResult();
View Full Code Here

        indexState(CONTENT));
    assertWorkDir(mkmap("file.txt", "b", "file2.txt", ""));

    // Switch branches and check that the dirty file survived in worktree
    // and index
    git.checkout().setName("b1").call();
    assertEquals("[file.txt, mode:100755, content:a]", indexState(CONTENT));
    assertWorkDir(mkmap("file.txt", "b"));
  }

  @Test
View Full Code Here

    assertEquals("[file.txt, mode:100644, content:a]", indexState(CONTENT));
    assertWorkDir(mkmap("file.txt", "c"));

    // Switch branches and check that the dirty file survived in worktree
    // and index
    git.checkout().setName("b1").call();
    assertEquals("[file.txt, mode:100644, content:a]", indexState(CONTENT));
    assertWorkDir(mkmap("file.txt", "c"));
  }

  @Test
View Full Code Here

    git.add().addFilepattern("file2.txt").call();
    git.commit().setMessage("commit2").call();
    assertFalse(db.getFS().canExecute(file2));

    // Create branch from first commit
    assertNotNull(git.checkout().setCreateBranch(true).setName("b1")
        .setStartPoint(Constants.HEAD + "~1").call());

    // Change content and file mode in working directory and index
    file1 = writeTrashFile("file1.txt", "c");
    db.getFS().setExecute(file1, true);
View Full Code Here

    file1 = writeTrashFile("file1.txt", "c");
    db.getFS().setExecute(file1, true);
    git.add().addFilepattern("file1.txt").call();

    // Switch back to 'master'
    assertNotNull(git.checkout().setName(Constants.MASTER).call());
  }

  public void assertWorkDir(HashMap<String, String> i) throws CorruptObjectException,
      IOException {
    TreeWalk walk = new TreeWalk(db);
View Full Code Here

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

    assertEquals(c2, db.resolve("master@{0}"));
    assertEquals(c1, db.resolve("master@{1}"));

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

    // same as current branch, e.g. master
    assertEquals(c1, db.resolve("@{0}"));
    try {
View Full Code Here

    } catch (RevisionSyntaxException e) {
      assertNotNull(e);
    }

    // detached head, read HEAD reflog
    git.checkout().setName(c2.getName()).call();
    assertEquals(c2, db.resolve("@{0}"));
    assertEquals(c1, db.resolve("@{1}"));
    assertEquals(c2, db.resolve("@{2}"));
  }
View Full Code Here

    assertSame(repo.getRef("HEAD").getStorage(), Storage.LOOSE);
    assertEquals(repo.getRef("HEAD").getTarget().getName(),
        "refs/heads/master");
    assertNull(repo.getRef("HEAD").getTarget().getObjectId());

    git.checkout().setName("refs/heads/side").call();
    gc.packRefs();
    assertSame(repo.getRef("HEAD").getStorage(), Storage.LOOSE);

    // check for detached HEAD
    git.checkout().setName(first.getName()).call();
View Full Code Here

    git.checkout().setName("refs/heads/side").call();
    gc.packRefs();
    assertSame(repo.getRef("HEAD").getStorage(), Storage.LOOSE);

    // check for detached HEAD
    git.checkout().setName(first.getName()).call();
    gc.packRefs();
    assertSame(repo.getRef("HEAD").getStorage(), Storage.LOOSE);
  }

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