Repository.xs: merge_base() should fail if sv_isobject is false
Use a different counter for counting and iterating

Some values may be undefined, resulting in an infinite loop.
Repository.xs: Added is_head_detached()
Changes: update