Given a specific reference (a tag in this case) how can you list the branches that contain that commit in git2go? Similar to git branch --contains <commit>
.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The question here, graph-wise is "how do I know if A is an ancestor of B?" (repeated a few times for each branch which you want to be B). The only way to answer that is to walk down the history graph starting at B and check if you find A.
You can do this in a few ways, but the most efficient is generally going to be to reduce the question to the equivalent "is A a merge-base of A and B?". You can ask this question in git2go via Repository.MergeBase()
. This will return the best merge-base between the two commits you give it. In the case where you want one of the commits to be the merge base, this should always provide the right answer, even though it cuts the answer down to a single merge base.