-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git extension improvements #3502
Merged
DefaultRyan
merged 8 commits into
feature/fileexplorer-sourcecontrol-integration
from
user/defaultryan/git-improvements
Jul 26, 2024
Merged
Git extension improvements #3502
DefaultRyan
merged 8 commits into
feature/fileexplorer-sourcecontrol-integration
from
user/defaultryan/git-improvements
Jul 26, 2024
Conversation
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
…eneck inside LibGit2Sharp
…ol-integration' into user/defaultryan/git-improvements
dhoehna
reviewed
Jul 26, 2024
...ions/GitExtension/FileExplorerGitIntegration.UnitTest/GitLocalRepositoryProviderUnitTests.cs
Show resolved
Hide resolved
dhoehna
reviewed
Jul 26, 2024
extensions/GitExtension/FileExplorerGitIntegration/Models/CommitLogCache.cs
Outdated
Show resolved
Hide resolved
dhoehna
reviewed
Jul 26, 2024
extensions/GitExtension/FileExplorerGitIntegration/Models/RepositoryWrapper.cs
Outdated
Show resolved
Hide resolved
dhoehna
approved these changes
Jul 26, 2024
DefaultRyan
merged commit Jul 26, 2024
a27d47a
into
feature/fileexplorer-sourcecontrol-integration
4 checks passed
ssparach
pushed a commit
that referenced
this pull request
Jul 31, 2024
* WARP SPEED COMMIT HISTORY. Rooted out and worked around a major bottleneck inside LibGit2Sharp * Better status * Introduce RepositoryWrapper to lock access to Repository * Update unit test to reflect new repo status * Check cache before calling Repository.IsValid
ssparach
pushed a commit
that referenced
this pull request
Jul 31, 2024
* WARP SPEED COMMIT HISTORY. Rooted out and worked around a major bottleneck inside LibGit2Sharp * Better status * Introduce RepositoryWrapper to lock access to Repository * Update unit test to reflect new repo status * Check cache before calling Repository.IsValid
ssparach
pushed a commit
that referenced
this pull request
Jul 31, 2024
* WARP SPEED COMMIT HISTORY. Rooted out and worked around a major bottleneck inside LibGit2Sharp * Better status * Introduce RepositoryWrapper to lock access to Repository * Update unit test to reflect new repo status * Check cache before calling Repository.IsValid
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the pull request
This brings several improvements to the Git extension:
Detailed description of the pull request / Additional comments
For the perf increase, I learned that
LibGit2Sharp.CommitEnumerator
is not reusable, even though the object it wraps, libgit2'sgit_revwalk
is documented that "for maximum performance, this revision walker should be reused for different walks". Measurements confirmed that most of the time was being spent in libgit2'sprepare_walk()
where it traverses, sorts, and caches the commit graph in thegit_revwalk
. After this step, walking the commits in the revwalk proceed quickly, which is used for finding a file's latest commit.To work around this, we grab the whole commit graph up front and cache the list of
LibGit2Sharp.Commit
objects to walk later. When it's time to fetch this cached list, we first check to see ifHEAD
has changed, and retrieve a new list of commits.For improved file status, instead of calling
ToString
on LibGit2Sharp's enum values, we now simplify and turn these strings into more intuitive values, like "Modified", "Staged", "Untracked".For improved repo status, we now obtain the whole-repo status and condense that into a compact string representation we see in other tools.
<branch name> <branch status> | <file counts>
Where:
<branch name>
is either"Branch: <name>"
or"Detached: <sha>"
<branch status>
if the branch is tracking a remote shows either↑ <ahead # commits>
↓ <behind # commits>
↓ <behind # commits> ↑ <ahead # commits>
≡
(when up-to-date)<file counts>
is"+<#added> ~<#numstaged> -<#removed> | <#untracked> ~<modified> -<missing>"
"!<#conflicted>"
To fix race conditions, I moved the
LibGit2Sharp.Repository
object into a newRepositoryWrapper
class that will manage access to the Repository objects to eliminate concurrent access.Validation steps performed
Built extension and browsed the PowerToys repo, refreshing the view while checking out branches back and forth to cause contention on fetching status and commits. Not only does this run much faster than before, but the infrequent instances where the extension would sometimes hang or crash have disappeared.
PR checklist