Make sure the index is in a sensible state on changing or creating HEAD
Make sure the index is in a sensible state on changing or creating HEAD

There were a number of confusing problems due to switching branches
by updating the HEAD sym-ref but having the old index still there.
Similar problems arose when creating a new branch on gibak.py init
where we should have an empty index.

mhl/gib,mhl/gib