Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add branch querying/filtering feature #147

Open
nulltoken opened this Issue May 13, 2012 · 9 comments

Comments

Projects
None yet
4 participants
Member

nulltoken commented May 13, 2012

The git-branch doc states

With --contains, shows only the branches that contain the named commit (in other
words, the branches whose tip commits are descendants of the named commit).

With --merged, only branches merged into the named commit (i.e. the branches whose
tip commits are reachable from the named commit) will be listed.

With --no-merged only branches not merged into the named commit will be listed.

If the <commit> argument is missing it defaults to HEAD (i.e. the tip of the
current branch).

A potential API design might rely on the following

  • Add a QueryBy() method to the BranchCollection in a similar way to the CommitCollection.QueryBy() method.
  • Rename the current Filter type to CommitFilter, in order to allow the creation of a BranchFIlter

Binding the following method might also be helpful. Related libgit2 tests can be found here.

/**
 * Find a merge base between two commits
 *
 * @param out the OID of a merge base between 'one' and 'two'
 * @param repo the repository where the commits exist
 * @param one one of the commits
 * @param two the other commit
 */
GIT_EXTERN(int) git_merge_base(
     git_oid *out,
     git_repository *repo,
     git_oid *one,
     git_oid *two);
Contributor

aroben commented May 13, 2012

It would be neat to implement this (and CommitCollection.QueryBy) as an IQueryable LINQ provider.

Member

nulltoken commented May 13, 2012

It would be neat to implement this (and CommitCollection.QueryBy) as an IQueryable LINQ provider.

Agreed. Where's your patch? ;p

nufyoot commented May 13, 2012

I agree to the IQueryable LINQ provider.

I written a few linq providers, I might be able to help 😉

nufyoot commented May 13, 2012

I've written a few as well and would also be willing to help with this 😄

Member

nulltoken commented May 14, 2012

@nufyoot, @davidfowl As CommitCollection is already implemented and more or less covered by tests, I've created a dedicated issue (#148) for the implementation of IQueryable<Commit>.

Let's keep this (#147) issue dedicated to implementing the branch filtering feature as an IEnumerable<Branch> and the related tests. Once #147 and #148 are tackled, it should be easier to spawn a IQueryale<Branch>.

What do you think about that?

nufyoot commented May 14, 2012

That sounds reasonable. A QueryBy method makes sense to implement first and then do the IQueryable<Branch> and IQueryable<Commit> later.

Member

nulltoken commented May 23, 2012

@redoz implemented a nice repo.Commit.FindCommonAncestor() method that would come handy with this issue.

Member

nulltoken commented Aug 17, 2013

--contains feature can be fulfilled through the repo.Refs.ReachableFrom method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment