Method: Rugged::Repository.init_at

Defined in:
ext/rugged/rugged_repo.c

.init_at(path, is_bare = false, opts = {}) ⇒ Object

Initialize a Git repository in path. This implies creating all the necessary files on the FS, or re-initializing an already existing repository if the files have already been created.

The is_bare (optional, defaults to false) attribute specifies whether the Repository should be created on disk as bare or not. Bare repositories have no working directory and are created in the root of path. Non-bare repositories are created in a .git folder and use path as working directory.

The following options can be passed in the options Hash:

:backend

A Rugged::Backend instance

Rugged::Repository.init_at(‘repository’, :bare) #=> #<Rugged::Repository:0x108849488>


396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'ext/rugged/rugged_repo.c', line 396

static VALUE rb_git_repo_init_at(int argc, VALUE *argv, VALUE klass)
{
	git_repository *repo = NULL;
	VALUE rb_path, rb_is_bare, rb_options;
	int error;

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

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

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

	if(!repo) {
		error =	git_repository_init(&repo, StringValueCStr(rb_path), RTEST(rb_is_bare));
		rugged_exception_check(error);
	}

	return rugged_repo_new(klass, repo);
}