mc-git: use the while counter only when needed