File: revparse.R

package info (click to toggle)
r-cran-git2r 0.26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 6,884 kB
  • sloc: ansic: 101,730; sh: 3,364; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 2,062 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## git2r, R bindings to the libgit2 library.
## Copyright (C) 2013-2018 The git2r contributors
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License, version 2,
## as published by the Free Software Foundation.
##
## git2r is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

##' Revparse
##'
##' Find object specified by revision.
##' @template repo-param
##' @param revision The revision string, see
##' http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
##' @return a \code{git_commit} or \code{git_tag} or \code{git_tree}
##' object
##' @export
##' @examples
##' \dontrun{
##' ## Create a directory in tempdir
##' path <- tempfile(pattern="git2r-")
##' dir.create(path)
##'
##' ## Initialize a repository
##' repo <- init(path)
##' config(repo, user.name="Alice", user.email="alice@@example.org")
##'
##' ## Create a file, add and commit
##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
##'            con = file.path(path, "test.txt"))
##' add(repo, "test.txt")
##' commit(repo, "First commit message")
##'
##' # Change file and commit
##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
##'              "eiusmod tempor incididunt ut labore et dolore magna aliqua."),
##'              con = file.path(path, "test.txt"))
##' add(repo, "test.txt")
##' commit(repo, "Second commit message")
##'
##' revparse_single(repo, "HEAD^")
##' revparse_single(repo, "HEAD:test.txt")
##' }
revparse_single <- function(repo = ".", revision = NULL) {
    .Call(git2r_revparse_single, lookup_repository(repo), revision)
}