Fix merge base computation

I just looked at git's git-merge-octopus.sh script and took the same logic (see https://github.com/git/git/blob/master/git-merge-octopus.sh)