Log correct SHA when deploying non master branch.

Every call that depends on fetch_revision used wrong SHA, when non master/HEAD branch was deployed.

This patch changes it to ask for branch or HEAD if not supplied.

Also properly escapes path and branch name.