Question

I've been tinkering around, and reading through what little Wiki information that I could find, and looked through tests that I thought may be relevant, however I'm having problems coming up with a working solution for a few things.

Mostly, I'm looking for a way to list commits that have been pushed to the server ahead of your working repository / local commits. I've tried using Fetch, and FetchHeads, but looking through all of the documentation for the Network class doesn't seem to yield anything that I can understand, I guess. Ideally, I'd be interested in seeing something like:

    IQueriableCommitLog Repository.Network.GetCommitsAhead

OR

    IQueriableCommitLog Repository.Remote.GetCommitsAhead

Then, just use the results like you would in:

    IQueriableCommitLog Repository.Commits

Also, perhaps a method like Commit.UpdateTo() for the remote commit.

Am I too far off base for what I'm looking for? Is it possible at this time to perform actions such as this? Is it supported by libgit2?

Was it helpful?

Solution

Mostly, I'm looking for a way to list commits that have been pushed to the server ahead of your working repository / local commits.

A Branch is either local or remote. Local Branches which are tracking other ones expose a TrackedBranch property.

Considering a local branch with a not null TrackedBranch property

  • Commits that have been performed on this local branch and aren't known from the tracked one.

repo.Commits.QueryBy(new Filter { Since = branch.Tip, Until = branch.TrackedBranch });

  • Commits that exist in the tracked branch and aren't known from the local one

repo.Commits.QueryBy(new Filter { Since = TrackedBranch, Until = Tip })

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top