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 55 56 57 58 59 60 61 62 63 64 65
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/commit.R
\name{is_merge}
\alias{is_merge}
\title{Is merge}
\usage{
is_merge(commit = NULL)
}
\arguments{
\item{commit}{a git_commit object.}
}
\value{
TRUE if commit has more than one parent, else FALSE
}
\description{
Determine if a commit is a merge commit, i.e. has more than one
parent.
}
\examples{
\dontrun{
## Initialize a temporary repository
path <- tempfile(pattern="git2r-")
dir.create(path)
repo <- init(path)
## Create a user and commit a file
config(repo, user.name = "Alice", user.email = "alice@example.org")
writeLines(c("First line in file 1.", "Second line in file 1."),
file.path(path, "example-1.txt"))
add(repo, "example-1.txt")
commit(repo, "First commit message")
## Create and add one more file
writeLines(c("First line in file 2.", "Second line in file 2."),
file.path(path, "example-2.txt"))
add(repo, "example-2.txt")
commit(repo, "Second commit message")
## Create a new branch 'fix'
checkout(repo, "fix", create = TRUE)
## Update 'example-1.txt' (swap words in first line) and commit
writeLines(c("line First in file 1.", "Second line in file 1."),
file.path(path, "example-1.txt"))
add(repo, "example-1.txt")
commit(repo, "Third commit message")
checkout(repo, "master")
## Update 'example-2.txt' (swap words in second line) and commit
writeLines(c("First line in file 2.", "line Second in file 2."),
file.path(path, "example-2.txt"))
add(repo, "example-2.txt")
commit(repo, "Fourth commit message")
## Merge 'fix'
merge(repo, "fix")
## Display parents of last commit
parents(lookup(repo, branch_target(repository_head(repo))))
## Check that last commit is a merge
is_merge(lookup(repo, branch_target(repository_head(repo))))
}
}
|