如何在JGit中完成合并基础? [英] How is a merge-base done in JGit?

查看:84
本文介绍了如何在JGit中完成合并基础?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 JGit文档,当前版本为 3.5.1.201410131835-r ,而我找不到 git-merge-基本.

I'm looking at the JGit Documentation, currently at version 3.5.1.201410131835-r, and I cannot find the equivalent of git-merge-base.

我想确定分支是最新的,落后的,领先的还是分叉的,如 git中所示:检查是否需要拉动.

I would like to determine if a branch is up-to-date, behind, ahead, or diverged, as shown in git: check if pull needed.

JGit中最简洁的方法是找到尽可能好的共同祖先进行合并?

What is the most concise way in JGit to find as good common ancestors as possible for a merge?

推荐答案

您可以为此使用 RevFilter.MERGE_BASE :

RevWalk walk = new RevWalk(repository);
walk.setRevFilter(RevFilter.MERGE_BASE);
walk.markStart(commit1);
walk.markStart(commit2);
RevCommit mergeBase = walk.next();

还要注意,这里有

Also note that there is BranchTrackingStatus if all you are interested in is ahead/behind count of a branch compared to its remote-tracking branch.

这篇关于如何在JGit中完成合并基础?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆