as_git_repository: Open a Git repository, the git2r way

Description Usage Arguments Value Examples

Description

githug uses the git2r package, under the hood, to perform local Git operations. git2r handles Git repos as objects of class git_repository. Use this function to convert a path (or other way of referring to a Git repo) to the right sort of input. You might need this for more exotic Git operations, i.e. to call git2r functions that aren't exposed via githug.

Usage

1

Arguments

x

Git repository specified as a path. Or as an object of class rpath (S3 class used only internally in githug) or of class git_repository (from the git2r package).

Value

An S4 git_repository object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
repo <- git_init(tempfile("githug-to-git2r-example-"))
owd <- setwd(repo)
git_config(user.name = "jd", user.email = "jd@example.org")
writeLines(paste("Well, I've always believed that if done properly, armed",
                 "robbery doesn't have to be an unpleasant experience."),
           "jd.txt")
git_add("jd.txt")
git_commit("jd is a smooth talker")

## here's a rather exotic Git operation that githug is unlikely to expose:
## odb_blobs() lists "all blobs reachable from the commits in the object database"
## pre-process the repo with as_git_repository() to prepare for git2r
git2r::odb_blobs(as_git_repository())
setwd(owd)

jennybc/githug documentation built on May 19, 2019, 5:05 a.m.