Refactor common git ref lookup into utility
test: ensure HEAD is not modified unexpectedly
Silence 'git merge-base'

The invocation and results aren't interesting to end user