Method: Rugged::Repository.new
- Defined in:
- ext/rugged/rugged_repo.c
.new(path, options = {}) ⇒ Object
Open a Git repository in the given path
and return a Repository
object representing it. An exception will be thrown if path
doesn’t point to a valid repository. If you need to create a repository from scratch, use Rugged::Repository.init_at instead.
The path
must point to either the actual folder (.git
) of a Git repository, or to the directorly that contains the .git
folder.
See also Rugged::Repository.discover and Rugged::Repository.bare.
The following options can be passed in the options
Hash:
- :alternates
-
A list of alternate object folders.
Examples:
Rugged::Repository.new('test/.git') #=> #<Rugged::Repository:0x108849488>
Rugged::Repository.new(path, :alternates => ['./other/repo/.git/objects'])
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'ext/rugged/rugged_repo.c', line 354
static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
{
git_repository *repo;
int error = 0;
VALUE rb_path, rb_options;
rb_scan_args(argc, argv, "10:", &rb_path, &rb_options);
FilePathValue(rb_path);
error = git_repository_open(&repo, StringValueCStr(rb_path));
rugged_exception_check(error);
if (!NIL_P(rb_options)) {
/* Check for `:alternates` */
load_alternates(repo, rb_hash_aref(rb_options, CSTR2SYM("alternates")));
}
return rugged_repo_new(klass, repo);
}
|