forked from jenkinsci/git-client-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use --no-walk when merely checking if a revision exists
When implementing isCommitInRepo() for the CLI git implementation we use git rev-list, assuming that if this command fails then the commit doesn't exist in the repository. This is technically correct. However, git rev-list actually performs a complete revision walk, which for large repositories can take a long time. For example, on the Linux repository, git rev-list HEAD took around 30 seconds. This is entirely due to the command producing an entire list of all revisions leading back to the beginning of history. But isCommitInRepo() doesn't even care about that! We can significantly reduce the cost of this function in a number of ways. One, we could re-implement this using various other git commands, such as git cat-file. Or, we could ask rev-list not to actually walk the revisions. This was added in git 1.5.3 (~2007). Local testing found there to be minimal difference in "git cat-file -t <id>" vs "git rev-list --no-walk <id>". Since the latter is mostly already implemented, add support for "--no-walk" to the RevListCommand. This allows us to modify isCommitInRepo() to use the RevList_() directly, and pass .nowalk(true) in order to avoid the unnecessary revision walk. For completeness, also implement the equivalent support in JGit. To do so, simply use parseCommit() of the refspec provided to the command. If all was set to true, we'll search all refs and include those as well. Ultimately, this enables the command line implementation of the gitClient to have a significantly faster test for whether a commit is in a repository. Signed-off-by: Jacob Keller <[email protected]>
- Loading branch information
1 parent
40e9281
commit d19a04c
Showing
4 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters