void createBranch(String branchName, RevCommit revCommit) throws GitAPIException { try { git.branchCreate().setName(branchName).setStartPoint(revCommit).call(); } catch (GitAPIException e) { LOGGER.error("[CONFIG_MERGE] Failed to create branch {} at revision {}", branchName, revCommit.getId(), e); throw e; } }
@Signature public Memory branchCreate(String name, ArrayMemory settings) throws GitAPIException { CreateBranchCommand command = getWrappedObject().branchCreate(); command.setName(name); if (settings != null && settings.isNotNull()) { Memory startPoint = settings.valueOfIndex("startPoint"); if (startPoint.isNotNull()) { command.setStartPoint(startPoint.toString()); } command.setForce(settings.valueOfIndex("force").toBoolean()); Memory upstreamMode = settings.valueOfIndex("upstreamMode"); if (upstreamMode.isNotNull()) { command.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.valueOf(upstreamMode.toString())); } } return GitUtils.valueOf(command.call()); }
git.branchCreate() .setName("master")
git.branchCreate() .setName("master")
Ref changes = git.branchCreate().setName("changes").call(); System.out.println("Result of creating the branch: " + changes);
Ref changes = git.branchCreate().setName("changes").call(); System.out.println("Result of creating the branch: " + changes);
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { if(repository.exactRef("refs/heads/testbranch") == null) { // first we need to ensure that the remote branch is visible locally Ref ref = git.branchCreate().setName("testbranch").setStartPoint("origin/testbranch").call(); System.out.println("Created local testbranch with ref: " + ref); } // the diff works on TreeIterators, we prepare two for the two branches AbstractTreeIterator oldTreeParser = prepareTreeParser(repository, "refs/heads/testbranch"); AbstractTreeIterator newTreeParser = prepareTreeParser(repository, "refs/heads/master"); // then the procelain diff-command returns a list of diff entries List<DiffEntry> diff = git.diff().setOldTree(oldTreeParser).setNewTree(newTreeParser).call(); for (DiffEntry entry : diff) { System.out.println("Entry: " + entry); } } } }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { if(repository.exactRef("refs/heads/testbranch") == null) { // first we need to ensure that the remote branch is visible locally Ref ref = git.branchCreate().setName("testbranch").setStartPoint("origin/testbranch").call(); System.out.println("Created local testbranch with ref: " + ref); } // the diff works on TreeIterators, we prepare two for the two branches AbstractTreeIterator oldTreeParser = prepareTreeParser(repository, "refs/heads/testbranch"); AbstractTreeIterator newTreeParser = prepareTreeParser(repository, "refs/heads/master"); // then the procelain diff-command returns a list of diff entries List<DiffEntry> diff = git.diff().setOldTree(oldTreeParser).setNewTree(newTreeParser).call(); for (DiffEntry entry : diff) { System.out.println("Entry: " + entry); } } } }
git.branchCreate() .setName("testbranch") .call();
git.branchCreate() .setName("testbranch") .call();
CreateBranchCommand command = git.branchCreate(); command.setName(name); if (startCommit != null)
@Override public Ref createBranch(Git git, String branchName) throws GitAPIException { Ref newBranch = git.branchCreate().setName(branchName).call(); if (newBranch == null) throw new RuntimeException("Couldn't create new branch " + branchName); return newBranch; }
public static void createBranch(final Git git, final String source, final String target) { try { git.branchCreate().setName(target).setStartPoint(source).call(); } catch (GitAPIException e) { throw new RuntimeException(e); } }
protected void doCreateBranch(Git git, String fromBranch, String newBranch) throws GitAPIException { checkoutBranch(git, fromBranch); git.branchCreate().setName(newBranch).call(); checkoutBranch(git, newBranch); }
public void branch(String name) throws GitException { verifyGitRepository(); try { jGitDelegate.branchCreate().setName(name).call(); } catch (GitAPIException e) { throw new GitException(Messages.GitAPI_Branch_CreateErrorMsg(name), e); } }
public Ref createBranch(Git git, String branchName) throws GitAPIException { return git.branchCreate() .setName(branchName) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + branchName) .setForce(true) .call(); }
public void createBranch(String branchName, String branchRevision) { try { CreateBranchCommand command = git().branchCreate(); command.setName(branchName); RevCommit commit = getRevCommit(branchRevision); command.setStartPoint(getRevCommit(branchRevision)); command.call(); cacheObjectId(GitUtils.branch2ref(branchName), commit); } catch (GitAPIException e) { throw new RuntimeException(e); } }
private void updateBranch(final String targetBranchName, final org.eclipse.jgit.api.Git git, final ObjectId commitId) throws Exception { git.branchCreate() .setName(targetBranchName) .setStartPoint(commitId.name()) .setForce(true) .call(); }
private Ref branch(Git origin, String source, String target) throws Exception { final Repository repo = origin.getRepository(); return org.eclipse.jgit.api.Git.wrap(repo) .branchCreate() .setName(target) .setStartPoint(source) .call(); }
public void checkoutFromRemote(String remoteBranchName, String branchName) throws GitAPIException, JGitInternalException, StopTaskException { mRepo.getGit().checkout().setCreateBranch(true).setName(branchName) .setStartPoint(remoteBranchName).call(); mRepo.getGit() .branchCreate() .setUpstreamMode( CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint(remoteBranchName).setName(branchName) .setForce(true).call(); } }