Set the reference list ID during creation

Because the reference list could not be found again, this caused the
branches and tags in the list to disappear in the main view when the
references were reloaded, such as after an external command.

Fixes GH-148.
Improve invalidation during reload of references

Add valid field and only clear the reference ID after the reload so that
decoration of replaced commits will work correctly.