Avoid NPE when the default branch cannot be identified

This is a normal condition that complicates debugging, i.e.
when catching all NPE's.
Don't crash with an NPE when the cache contains removed repositoried