test boolean first to avoid unnecessary IO checking git repository for modules
minor code simplification
[FIXED JENKINS-12188] close JGit repository