In detached HEAD state, `git rev-parse --abbrev-ref HEAD` returns `HEAD`. `git log -n 1 --pretty=%D HEAD` could be used to get all refs but which one do we choose? Maybe `branch` should just be `null` or an empty string in detached HEAD state?