Properly verify SHA for branch command

Quite a significant bug, as this means that rewritten original commits
weren't recognized properly. Thanks to John Morris for spotting this.
Removed spurious debug log