refs: detach split repos' HEAD when the linked ref is updated/deleted

This is effective when a ref is updated from the super repository as
well as all linked repositories because "repos" directory is shared
between all repos.

We could even forbid a ref update if it's some repo's HEAD. But I'd
rather see a generic, permanent ref locking mechanism in place first
and make use of it.
refs.c: refactor do_head_ref(... to do_one_head_ref("HEAD", ...
rev-list: include repos/xx/HEAD in --all

This makes sure repack won't drop detached HEADs from $GIT_DIR/repos/