示例#1
0
int git_tree__writeback(git_tree *tree, git_odb_source *src)
{
	size_t i;
	char filemode[8];

	assert(tree && src);

	if (tree->entries.length == 0)
		return GIT_EMISSINGOBJDATA;

	git_vector_sort(&tree->entries);

	for (i = 0; i < tree->entries.length; ++i) {
		git_tree_entry *entry;

		entry = git_vector_get(&tree->entries, i);
	
		sprintf(filemode, "%06o ", entry->attr);

		git__source_write(src, filemode, strlen(filemode));
		git__source_write(src, entry->filename, strlen(entry->filename) + 1);
		git__source_write(src, entry->oid.id, GIT_OID_RAWSZ);
	} 

	return GIT_SUCCESS;
}
示例#2
0
文件: blob.c 项目: bnoordhuis/libgit2
int git_blob__writeback(git_blob *blob, git_odb_source *src)
{
	assert(blob->object.modified);

	if (blob->content.data == NULL)
		return GIT_EMISSINGOBJDATA;

	return git__source_write(src, blob->content.data, blob->content.len);
}