ropensci / git2r

R bindings to the libgit2 library
https://docs.ropensci.org/git2r
GNU General Public License v2.0
215 stars 58 forks source link

Implementing subtree commands #443

Open TransGirlCodes opened 1 year ago

TransGirlCodes commented 1 year ago

I was looking to write an RStudio extension to help my colleages with some more advanced git use - namely subtree add etc, my first thought was to use sys to do git commands but then my second was - use library bindings which brought me to git2r. But I then found git subtree isn't implemented in gits libraries but as a script. So I thought to use the git2r to recreate the functionality of the script, but some commands such as git check-ref-format or git read-tree don't appear to be possible. I've seen functions such as git_index_read_tree in LibGit2 which seem like they may be what I'm looking for, but I don't think they're exposed to R either. Can someone more knowledgeable weigh in on what would be required?

stewid commented 1 year ago

In order to expose new functionality from libgit2 into git2r, one must add a C function that can be called from R which then in turn calls the function in libgit2. The file src/git2r.c lists all the functions that can currently be called from R. See, for example, src/git2r_branch.c for functions that implements branch functionality from libgit2. Pull requests are welcome if you are interested in implementing new functionality.