Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add RevWalker #2038

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

Open
jairbubbles wants to merge 33 commits into libgit2:master
base: master
Choose a base branch
Loading
from jairbubbles:add-revwalker
Open

Add RevWalker #2038

jairbubbles wants to merge 33 commits into libgit2:master from jairbubbles:add-revwalker

Conversation

@jairbubbles
Copy link
Contributor

@jairbubbles jairbubbles commented May 20, 2023

This allows more flexibility than CommitLog and allows to traverse the repository multiple times more efficiently.

using var repository = new Repository(@"<repo_path>");
using var revWalker = new RevWalker(repository);
// Store commits in a cache to speed up multiple walks on same repository
var commitsCache = new Dictionary<ObjectId, Commit>();
 
revWalker.Reset();
revWalker.Sorting(CommitSortStrategies.Topological);
revWalker.PushGlob("refs/tags/*");
var commits = GetCommits().ToArray();
// Subsequent walk will reuse commits cache and internal RevWalker cache
revWalker.Reset();
revWalker.PushRef("HEAD");
commits = GetCommits().ToArray();
 
IEnumerable<Commit> GetCommits()
{
 while (true)
 {
 var objectId = revWalker.Next();
 if (objectId == null)
 break;
 
 if (!commitsCache.TryGetValue(objectId, out var commit))
 {
 commit = repository.Lookup<Commit>(objectId);
 commitsCache[objectId] = commit;
 }
 yield return commit;
 }
}
 

olivier-spinelli, DefaultRyan, kornman00, and lofcz reacted with thumbs up emoji
James-LG and others added 28 commits May 17, 2024 12:19
Wires up CustomHeaders in PushOptions in the same vain as FetchOptions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /