2014-10-30 55 views

回答

4

RevWalk::isMergedInto()可用於確定提交是否合併到另一個提交。即,如果第一個參數中給出的提交是第二個給定提交的祖先,則isMergedInto返回true。

try(RevWalk revWalk = new RevWalk(repository)) { 
    RevCommit masterHead = revWalk.parseCommit(repository.resolve("refs/heads/master"); 
    RevCommit otherHead = revWalk.parseCommit(repository.resolve("refs/heads/other-branch"); 
    if(revWalk.isMergedInto(otherHead, masterHead)) { 
    ... 
    } 
} 

要獲得使用ListBranchesCommand所有分支的列表:

List<Ref> branches = Git.wrap(repository).listBranches().setListMode(ListMode.ALL).call(); 
相關問題