Method: Rugged::Index#write_tree

Defined in:
ext/rugged/rugged_index.c

#write_tree([repo]) ⇒ Object

Write the index to a tree, either in the index’s repository, or in the given repo.

If the index contains any files in conflict, writing the tree will fail.

Returns the OID string of the written tree object.

[View source]

624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
# File 'ext/rugged/rugged_index.c', line 624

static VALUE rb_git_index_writetree(int argc, VALUE *argv, VALUE self)
{
	git_index *index;
	git_oid tree_oid;
	int error;
	VALUE rb_repo;

	Data_Get_Struct(self, git_index, index);

	if (rb_scan_args(argc, argv, "01", &rb_repo) == 1) {
		git_repository *repo = NULL;
		rugged_check_repo(rb_repo);
		Data_Get_Struct(rb_repo, git_repository, repo);
		error = git_index_write_tree_to(&tree_oid, index, repo);
	}
	else {
		error = git_index_write_tree(&tree_oid, index);
	}

	rugged_exception_check(error);
	return rugged_create_oid(&tree_oid);
}