Makefile: use `git rev-parse HEAD` instead of crazy `git show` commands

Signed-off-by: Jean Privat <jean@pryen.org>
doc: add a unit test for has_prefix

Jean Privat <jean@pryen.org>