Reputation: 15395
Say I have a repository repo
:
library(git2r)
repo <- repository(".")
In this repository is a subdirectory R
, with files a.txt
, b.txt
and other files that I'm not interested in. How can I use git2r
to work out if there are unstaged changes in these files? I've looked at summary(diff())
, but that works on the level of the whole repo.
Essentially, what I'm trying to do is replicate the effects of the git command:
! git diff-index --quiet HEAD -- file
Where if there are changes in the file, then return false. While I could use a system command, there's no guarantee the user has git
in their path and so the command would fail.
Is there a way to replicate the git functionality I'm looking for?
Upvotes: 0
Views: 262
Reputation: 15395
This issue is solved in the latest development release of git2r.
There is now an all_unstaged
option to status
:
> status(repo, all_untracked = TRUE)
Untracked files:
Untracked: untracked/a.txt
Untracked: untracked/b.txt
Upvotes: 1