Show conflicts when pulling using libgit2sharp

a 夏天 提交于 2019-12-13 00:25:17

问题


I'm using libgit2sharp to pull (Commands.Pull) from a remote repo using the default FetchOptions, MergeOptions and PullOptions. My working directory has an uncommitted change that will cause a conflict, and as expected I get a CheckOutConflictException with the message "1 conflict prevents checkout".

What I can't figure out is how to programmatically find out the file that is causing the conflict. repo.Index.Conflicts doesn't contain any conflicts, I haven't found any documentation for this case in the wiki, and I can't find any tests for this case in the codebase.

Can anyone show me what I'm missing?


回答1:


You want to add a CheckoutOptions.OnCheckoutNotify callback, which will notify you every time checkout encounters a path with a particular action.

In this case, you want to look for conflicts, so set your CheckoutOptions.CheckoutNotifyFlags to listen for CheckoutNotifyFlags.Conflict.

You will be called back for each file that has a checkout conflict and given the path.



来源:https://stackoverflow.com/questions/48406501/show-conflicts-when-pulling-using-libgit2sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!