问题
I'm trying to query for commits:
repo.Commits.QueryBy(new LibGit2Sharp.Filter { Since = repo.Refs }).Take(100)
This is otherwise ok, but it also returns stashes. How can I exclude stashes? I know that when I'm looping through the results I could just ignore them I guess, but then I wouldn't have 100 of them as I wanted.
回答1:
The Since
and Until
properties of the Filter
type are quite tolerant regarding what they can be valued with.
According to the documentation they
Can either be a string containing the sha or reference canonical name to use, a Branch, a Reference, a Commit, a Tag, a TagAnnotation, an ObjectId or even a mixed collection of all of the above.
Basically, Since = repo.Refs
means "I want to revwalk from every reference of the repository when enumerating the pointed at commits".
Similarly to git log --all
this will indeed consider the branches, the tags, the stash, the notes, ...
If you're willing to reduce the scope of the references, you'll have to select what Since
will be valued with.
Since = repo.Branches.Where(b => !b.IsRemote)
Since = new object[] { repo.Branches["br2"], "refs/heads/master", new ObjectId("e90810b") }
For instance, in order to only consider branches and tags, you'd use
Since = new object[]{ repo.Branches, repo.Tags }
来源:https://stackoverflow.com/questions/10837862/how-to-exclude-stashes-while-querying-refs