git2r
git2r copied to clipboard
Get ahead/behind for a remote
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
?
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)