libgit2 / libgit2/libgit2sharp

Add branch querying/filtering feature

Open
#147 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

FeatReq
Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

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 guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with BranchCollection and compare its proposed QueryBy() API with CommitCollection.QueryBy(). Review the current Filter type before considering the proposed rename, then inspect libgit2's revwalk/mergebase.c tests and the git_merge_base binding. Done means the branch contains/merged/not-merged queries and related merge-base API are defined with matching tests and a settled API design.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.