jenkinsci/git-plugin — pull request #130 by MarkEWaite (2013-02-15 01:56:19+00:00)
Title: Simplify hasGitRepo using rev-parse rather than ls-files

The git ls-files call lists all the files in the repository. That is
significantly more work than is really needed to answer the question
which is being asked. The question asked by the API is "Is this a valid
git controlled working directory?"

The git rev-parse is-inside-work-tree command answers the same question
reliably and much faster than listing all the files in the repository.

This also adds three new unit tests to verify the behavior was preserved
from before the change to after the change.

The automated tests call hasGitRepo over 60 times, so it appears the
hasGitRepo() method is used more frequently than I initially expected.
Since it may be used frequently, it seems safer to use a lighter call to
decide if a repo is "real" rather than using the heavier call to ls-files.