Fix gitdir detection when in subdir of gitdir