Show conflicts when pulling using libgit2sharp

2019-08-01 06:13发布

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条回答
Lonely孤独者°
2楼-- · 2019-08-01 07:05

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.

查看更多
登录 后发表回答