sha1_name: interpret ~n as HEAD~n

HEAD~n is often used for rebase invocations etc. Make it use the same
default we use in other places, i.e. ~n == HEAD~n.