git2r icon indicating copy to clipboard operation
git2r copied to clipboard

Get ahead/behind for a remote

Open alexwhan opened this issue 5 years ago • 1 comments

I would like to be able to see the state of my local repo compared to the remote (the same way that git status shows eg: Your branch is ahead of 'origin/master' by 1 commit.

I can see git2r::ahead_behind but I don't think there's a way to use a remote commit object.

Is it a matter of exposing libgit2 functionality in git2r::status?

alexwhan avatar Aug 09 '19 02:08 alexwhan

I think it would be legit to use git rev-parse in such cases. For example;

library(git2r)
repo <- repository("/path/to/file")
local_head <- revparse_single(repo, "HEAD")
upstream_head <- revparse_single(repo, "origin/HEAD")
ahead_behind(local_head, upstream_head)

strboul avatar Nov 02 '19 20:11 strboul