GitHub does this, I believe, by running the git merge some_branch
command and checking the return status; for a conflicting merge, the git merge
command returns 1.
$ git merge test1
Auto-merging HELLO
CONFLICT (content): Merge conflict in HELLO
Automatic merge failed; fix conflicts and then commit the result.
$ echo $?
1
Do this in a throwaway branch, stemming off what will become the merge base.
Edit: The merge.verbosity
option, when set to "0", may also be of some use (not sure how you can apply this to pygit without shelling out):
Controls the amount of output shown by the recursive merge strategy.
Level 0 outputs nothing except a final error message if conflicts were
detected. Level 1 outputs only conflicts, 2 outputs conflicts and file
changes. Level 5 and above outputs debugging information. The default
is level 2. Can be overridden by the GIT_MERGE_VERBOSITY environment
variable.
See the "Configuration" section of the man page on git merge
at http://linux.die.net/man/1/git-merge.