Properly detect that HEAD is detached