Method: Rugged::Repository.bare

Defined in:
ext/rugged/rugged_repo.c

.bare(path[, alternates]) ⇒ Object .bare(path[, options]) ⇒ Object

Open a bare Git repository at path and return a Repository object representing it.

This is faster than Rugged::Repository.new, as it won’t attempt to perform any .git directory discovery, won’t try to load the config options to determine whether the repository is bare and won’t try to load the workdir.

Optionally, you can pass a list of alternate object folders or an options Hash.

Rugged::Repository.bare(path, ['./other/repo/.git/objects'])
Rugged::Repository.bare(path, opts)

The following options can be passed in the options Hash:

:backend

A Rugged::Backend instance

:alternates

A list of alternate object folders. Rugged::Repository.bare(path, :alternates => [‘./other/repo/.git/objects’])

[View source]

293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'ext/rugged/rugged_repo.c', line 293

static VALUE rb_git_repo_open_bare(int argc, VALUE *argv, VALUE klass)
{
	git_repository *repo = NULL;
	int error = 0;
	VALUE rb_path, rb_options, rb_alternates = 0;

	rb_scan_args(argc, argv, "11", &rb_path, &rb_options);

	if (!NIL_P(rb_options) && TYPE(rb_options) == T_ARRAY)
		rb_alternates = rb_options;

	if (!NIL_P(rb_options) && TYPE(rb_options) == T_HASH) {
		/* Check for `:backend` */
		VALUE rb_backend = rb_hash_aref(rb_options, CSTR2SYM("backend"));

		if (!NIL_P(rb_backend)) {
			rugged_repo_new_with_backend(&repo, rb_path, rb_backend);
		}

		/* Check for `:alternates` */
		rb_alternates = rb_hash_aref(rb_options, CSTR2SYM("alternates"));
	}

	if (!repo) {
		FilePathValue(rb_path);

		error = git_repository_open_bare(&repo, StringValueCStr(rb_path));
		rugged_exception_check(error);
	}

	if (rb_alternates) {
		load_alternates(repo, rb_alternates);
	}

	return rugged_repo_new(klass, repo);
}