Method: Rugged::Repository.discover
- Defined in:
- ext/rugged/rugged_repo.c
permalink .discover(path = nil, across_fs = true) ⇒ Object
Traverse path
upwards until a Git working directory with a .git
folder has been found, open it and return it as a Repository
object.
If path
is nil
, the current working directory will be used as a starting point.
If across_fs
is true
, the traversal won’t stop when reaching a different device than the one that contained path
(only applies to UNIX-based OSses).
1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 |
# File 'ext/rugged/rugged_repo.c', line 1623
static VALUE rb_git_repo_discover(int argc, VALUE *argv, VALUE klass)
{
git_repository *repo;
VALUE rb_path, rb_across_fs;
git_buf repository_path = { NULL };
int error, across_fs = 0;
rb_scan_args(argc, argv, "02", &rb_path, &rb_across_fs);
if (NIL_P(rb_path)) {
VALUE rb_dir = rb_const_get(rb_cObject, rb_intern("Dir"));
rb_path = rb_funcall(rb_dir, rb_intern("pwd"), 0);
}
if (!NIL_P(rb_across_fs)) {
across_fs = rugged_parse_bool(rb_across_fs);
}
FilePathValue(rb_path);
error = git_repository_discover(
&repository_path,
StringValueCStr(rb_path),
across_fs,
NULL
);
rugged_exception_check(error);
error = git_repository_open(&repo, repository_path.ptr);
git_buf_dispose(&repository_path);
rugged_exception_check(error);
return rugged_repo_new(klass, repo);
}
|