您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ unpack_trees函数代码示例

51自学网 2021-06-03 09:11:22
  C++
这篇教程C++ unpack_trees函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中unpack_trees函数的典型用法代码示例。如果您正苦于以下问题:C++ unpack_trees函数的具体用法?C++ unpack_trees怎么用?C++ unpack_trees使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了unpack_trees函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: read_tree_trivial

static int read_tree_trivial(unsigned char *common, unsigned char *head,			     unsigned char *one){	int i, nr_trees = 0;	struct tree *trees[MAX_UNPACK_TREES];	struct tree_desc t[MAX_UNPACK_TREES];	struct unpack_trees_options opts;	memset(&opts, 0, sizeof(opts));	opts.head_idx = 2;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.update = 1;	opts.verbose_update = 1;	opts.trivial_merges_only = 1;	opts.merge = 1;	trees[nr_trees] = parse_tree_indirect(common);	if (!trees[nr_trees++])		return -1;	trees[nr_trees] = parse_tree_indirect(head);	if (!trees[nr_trees++])		return -1;	trees[nr_trees] = parse_tree_indirect(one);	if (!trees[nr_trees++])		return -1;	opts.fn = threeway_merge;	cache_tree_free(&active_cache_tree);	for (i = 0; i < nr_trees; i++) {		parse_tree(trees[i]);		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);	}	if (unpack_trees(nr_trees, t, &opts))		return -1;	return 0;}
开发者ID:carey94tt,项目名称:git,代码行数:35,


示例2: git_merge_trees

static int git_merge_trees(int index_only,			   struct tree *common,			   struct tree *head,			   struct tree *merge){	int rc;	struct tree_desc t[3];	struct unpack_trees_options opts;	memset(&opts, 0, sizeof(opts));	if (index_only)		opts.index_only = 1;	else		opts.update = 1;	opts.merge = 1;	opts.head_idx = 2;	opts.fn = threeway_merge;	opts.src_index = &the_index;	opts.dst_index = &the_index;	init_tree_desc_from_tree(t+0, common);	init_tree_desc_from_tree(t+1, head);	init_tree_desc_from_tree(t+2, merge);	rc = unpack_trees(3, t, &opts);	cache_tree_free(&active_cache_tree);	return rc;}
开发者ID:emk,项目名称:git,代码行数:28,


示例3: checkout

static int checkout(void){	unsigned char sha1[20];	char *head;	struct lock_file *lock_file;	struct unpack_trees_options opts;	struct tree *tree;	struct tree_desc t;	int err = 0, fd;	if (option_no_checkout)		return 0;	head = resolve_refdup("HEAD", sha1, 1, NULL);	if (!head) {		warning(_("remote HEAD refers to nonexistent ref, "			  "unable to checkout./n"));		return 0;	}	if (!strcmp(head, "HEAD")) {		if (advice_detached_head)			detach_advice(sha1_to_hex(sha1));	} else {		if (prefixcmp(head, "refs/heads/"))			die(_("HEAD not found below refs/heads!"));	}	free(head);	/* We need to be in the new work tree for the checkout */	setup_work_tree();	lock_file = xcalloc(1, sizeof(struct lock_file));	fd = hold_locked_index(lock_file, 1);	memset(&opts, 0, sizeof opts);	opts.update = 1;	opts.merge = 1;	opts.fn = oneway_merge;	opts.verbose_update = (option_verbosity >= 0);	opts.src_index = &the_index;	opts.dst_index = &the_index;	tree = parse_tree_indirect(sha1);	parse_tree(tree);	init_tree_desc(&t, tree->buffer, tree->size);	if (unpack_trees(1, &t, &opts) < 0)		die(_("unable to checkout working tree"));	if (write_cache(fd, active_cache, active_nr) ||	    commit_locked_index(lock_file))		die(_("unable to write new index file"));	err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),			sha1_to_hex(sha1), "1", NULL);	if (!err && option_recursive)		err = run_command_v_opt(argv_submodule, RUN_GIT_CMD);	return err;}
开发者ID:pniebla,项目名称:test-repo-console,代码行数:60,


示例4: reset_tree

static int reset_tree(struct tree *tree, const struct checkout_opts *o,		      int worktree, int *writeout_error){	struct unpack_trees_options opts;	struct tree_desc tree_desc;	memset(&opts, 0, sizeof(opts));	opts.head_idx = -1;	opts.update = worktree;	opts.skip_unmerged = !worktree;	opts.reset = 1;	opts.merge = 1;	opts.fn = oneway_merge;	opts.verbose_update = o->show_progress;	opts.src_index = &the_index;	opts.dst_index = &the_index;	parse_tree(tree);	init_tree_desc(&tree_desc, tree->buffer, tree->size);	switch (unpack_trees(1, &tree_desc, &opts)) {	case -2:		*writeout_error = 1;		/*		 * We return 0 nevertheless, as the index is all right		 * and more importantly we have made best efforts to		 * update paths in the work tree, and we cannot revert		 * them.		 */		/* fallthrough */	case 0:		return 0;	default:		return 128;	}}
开发者ID:Noffica,项目名称:git,代码行数:34,


示例5: diff_cache

static int diff_cache(struct rev_info *revs,		      const struct object_id *tree_oid,		      const char *tree_name,		      int cached){	struct tree *tree;	struct tree_desc t;	struct unpack_trees_options opts;	tree = parse_tree_indirect(tree_oid);	if (!tree)		return error("bad tree object %s",			     tree_name ? tree_name : oid_to_hex(tree_oid));	memset(&opts, 0, sizeof(opts));	opts.head_idx = 1;	opts.index_only = cached;	opts.diff_index_cached = (cached &&				  !revs->diffopt.flags.find_copies_harder);	opts.merge = 1;	opts.fn = oneway_diff;	opts.unpack_data = revs;	opts.src_index = revs->diffopt.repo->index;	opts.dst_index = NULL;	opts.pathspec = &revs->diffopt.pathspec;	opts.pathspec->recursive = 1;	init_tree_desc(&t, tree->buffer, tree->size);	return unpack_trees(1, &t, &opts);}
开发者ID:MichaelBlume,项目名称:git,代码行数:29,


示例6: create_base_index

static void create_base_index(const struct commit *current_head){	struct tree *tree;	struct unpack_trees_options opts;	struct tree_desc t;	if (!current_head) {		discard_cache();		return;	}	memset(&opts, 0, sizeof(opts));	opts.head_idx = 1;	opts.index_only = 1;	opts.merge = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.fn = oneway_merge;	tree = parse_tree_indirect(current_head->object.sha1);	if (!tree)		die(_("failed to unpack HEAD tree object"));	parse_tree(tree);	init_tree_desc(&t, tree->buffer, tree->size);	if (unpack_trees(1, &t, &opts))		exit(128); /* We've already reported the error, finish dying */}
开发者ID:AresDice,项目名称:git,代码行数:27,


示例7: diff_merge

intdiff_merge (SeafCommit *merge, GList **results){    SeafCommit *parent1, *parent2;    struct tree_desc t[3];    struct unpack_trees_options opts;    struct index_state istate;    g_assert (*results == NULL);    g_assert (merge->parent_id != NULL && merge->second_parent_id != NULL);    parent1 = seaf_commit_manager_get_commit (seaf->commit_mgr,                                              merge->parent_id);    if (!parent1) {        seaf_warning ("failed to find commit %s./n", merge->parent_id);        return -1;    }    parent2 = seaf_commit_manager_get_commit (seaf->commit_mgr,                                              merge->second_parent_id);    if (!parent2) {        seaf_warning ("failed to find commit %s./n", merge->second_parent_id);        seaf_commit_unref (parent1);        return -1;    }    fill_tree_descriptor(&t[0], merge->root_id);    fill_tree_descriptor(&t[1], parent1->root_id);    fill_tree_descriptor(&t[2], parent2->root_id);    seaf_commit_unref (parent1);    seaf_commit_unref (parent2);    /* Empty index */    memset(&istate, 0, sizeof(istate));    memset(&opts, 0, sizeof(opts));    opts.head_idx = -1;    opts.index_only = 1;    opts.merge = 1;    opts.fn = threeway_diff;    opts.unpack_data = results;    opts.src_index = &istate;    opts.dst_index = NULL;    if (unpack_trees(3, t, &opts) < 0) {        seaf_warning ("failed to unpack trees./n");        return -1;    }    if (*results != NULL)        diff_resolve_renames (results);    tree_desc_free (&t[0]);    tree_desc_free (&t[1]);    tree_desc_free (&t[2]);    return 0;}
开发者ID:AzinmarErus,项目名称:seafile,代码行数:59,


示例8: write_archive_entries

int write_archive_entries(struct archiver_args *args,		write_archive_entry_fn_t write_entry){	struct archiver_context context;	struct unpack_trees_options opts;	struct tree_desc t;	int err;	if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {		size_t len = args->baselen;		while (len > 1 && args->base[len - 2] == '/')			len--;		if (args->verbose)			fprintf(stderr, "%.*s/n", (int)len, args->base);		err = write_entry(args, args->tree->object.sha1, args->base,				  len, 040777);		if (err)			return err;	}	memset(&context, 0, sizeof(context));	context.args = args;	context.write_entry = write_entry;	/*	 * Setup index and instruct attr to read index only	 */	if (!args->worktree_attributes) {		memset(&opts, 0, sizeof(opts));		opts.index_only = 1;		opts.head_idx = -1;		opts.src_index = &the_index;		opts.dst_index = &the_index;		opts.fn = oneway_merge;		init_tree_desc(&t, args->tree->buffer, args->tree->size);		if (unpack_trees(1, &t, &opts))			return -1;		git_attr_set_direction(GIT_ATTR_INDEX, &the_index);	}	err = read_tree_recursive(args->tree, "", 0, 0, &args->pathspec,				  args->pathspec.has_wildcard ?				  queue_or_write_archive_entry :				  write_archive_entry_buf,				  &context);	if (err == READ_TREE_RECURSIVE)		err = 0;	while (context.bottom) {		struct directory *next = context.bottom->up;		free(context.bottom);		context.bottom = next;	}	return err;}
开发者ID:AbelTian,项目名称:git,代码行数:55,


示例9: diff_commits

intdiff_commits (SeafCommit *commit1, SeafCommit *commit2, GList **results){    struct tree_desc t[2];    struct unpack_trees_options opts;    struct index_state istate;    g_assert (*results == NULL);    if (strcmp (commit1->commit_id, commit2->commit_id) == 0)        return 0;    if (strcmp (commit1->root_id, EMPTY_SHA1) != 0) {        fill_tree_descriptor(&t[0], commit1->root_id);    } else {        fill_tree_descriptor(&t[0], NULL);    }    if (strcmp (commit2->root_id, EMPTY_SHA1) != 0) {        fill_tree_descriptor(&t[1], commit2->root_id);    } else {        fill_tree_descriptor(&t[1], NULL);    }    /* Empty index */    memset(&istate, 0, sizeof(istate));    memset(&opts, 0, sizeof(opts));    opts.head_idx = -1;    opts.index_only = 1;    opts.merge = 1;    opts.fn = twoway_diff;    opts.unpack_data = results;    opts.src_index = &istate;    opts.dst_index = NULL;    if (unpack_trees(2, t, &opts) < 0) {        seaf_warning ("failed to unpack trees./n");        return -1;    }    if (results != NULL)        diff_resolve_empty_dirs (results);    if (*results != NULL)        diff_resolve_renames (results);    tree_desc_free (&t[0]);    tree_desc_free (&t[1]);    return 0;}
开发者ID:2bj,项目名称:seafile,代码行数:52,


示例10: reset_index_file

static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet){	int nr = 1;	int newfd;	struct tree_desc desc[2];	struct unpack_trees_options opts;	struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));	memset(&opts, 0, sizeof(opts));	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.fn = oneway_merge;	opts.merge = 1;	if (!quiet)		opts.verbose_update = 1;	switch (reset_type) {	case KEEP:	case MERGE:		opts.update = 1;		break;	case HARD:		opts.update = 1;		/* fallthrough */	default:		opts.reset = 1;	}	newfd = hold_locked_index(lock, 1);	read_cache_unmerged();	if (reset_type == KEEP) {		unsigned char head_sha1[20];		if (get_sha1("HEAD", head_sha1))			return error(_("You do not have a valid HEAD."));		if (!fill_tree_descriptor(desc, head_sha1))			return error(_("Failed to find tree of HEAD."));		nr++;		opts.fn = twoway_merge;	}	if (!fill_tree_descriptor(desc + nr - 1, sha1))		return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));	if (unpack_trees(nr, desc, &opts))		return -1;	if (write_cache(newfd, active_cache, active_nr) ||	    commit_locked_index(lock))		return error(_("Could not write new index file."));	return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:52,


示例11: reset_index

static int reset_index(const unsigned char *sha1, int reset_type, int quiet){	int nr = 1;	struct tree_desc desc[2];	struct tree *tree;	struct unpack_trees_options opts;	memset(&opts, 0, sizeof(opts));	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.fn = oneway_merge;	opts.merge = 1;	if (!quiet)		opts.verbose_update = 1;	switch (reset_type) {	case KEEP:	case MERGE:		opts.update = 1;		break;	case HARD:		opts.update = 1;		/* fallthrough */	default:		opts.reset = 1;	}	read_cache_unmerged();	if (reset_type == KEEP) {		unsigned char head_sha1[20];		if (get_sha1("HEAD", head_sha1))			return error(_("You do not have a valid HEAD."));		if (!fill_tree_descriptor(desc, head_sha1))			return error(_("Failed to find tree of HEAD."));		nr++;		opts.fn = twoway_merge;	}	if (!fill_tree_descriptor(desc + nr - 1, sha1))		return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));	if (unpack_trees(nr, desc, &opts))		return -1;	if (reset_type == MIXED || reset_type == HARD) {		tree = parse_tree_indirect(sha1);		prime_cache_tree(&active_cache_tree, tree);	}	return 0;}
开发者ID:ElPincheTopo,项目名称:git,代码行数:51,


示例12: checkout_fast_forward

int checkout_fast_forward(const unsigned char *head,			  const unsigned char *remote,			  int overwrite_ignore){	struct tree *trees[MAX_UNPACK_TREES];	struct unpack_trees_options opts;	struct tree_desc t[MAX_UNPACK_TREES];	int i, nr_trees = 0;	struct dir_struct dir;	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));	refresh_cache(REFRESH_QUIET);	hold_locked_index(lock_file, 1);	memset(&trees, 0, sizeof(trees));	memset(&opts, 0, sizeof(opts));	memset(&t, 0, sizeof(t));	if (overwrite_ignore) {		memset(&dir, 0, sizeof(dir));		dir.flags |= DIR_SHOW_IGNORED;		setup_standard_excludes(&dir);		opts.dir = &dir;	}	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.update = 1;	opts.verbose_update = 1;	opts.merge = 1;	opts.fn = twoway_merge;	setup_unpack_trees_porcelain(&opts, "merge");	trees[nr_trees] = parse_tree_indirect(head);	if (!trees[nr_trees++])		return -1;	trees[nr_trees] = parse_tree_indirect(remote);	if (!trees[nr_trees++])		return -1;	for (i = 0; i < nr_trees; i++) {		parse_tree(trees[i]);		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);	}	if (unpack_trees(nr_trees, t, &opts))		return -1;	if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))		die(_("unable to write new index file"));	return 0;}
开发者ID:0369,项目名称:git,代码行数:50,


示例13: get_new_blocks_ff

/* * Get the new blocks that need to be checked out if we ff to @remote. */static intget_new_blocks_ff (SeafRepo *repo,                    SeafCommit *head,                    SeafCommit *remote,                    BlockList **bl){    SeafRepoManager *mgr = repo->manager;    char index_path[SEAF_PATH_MAX];    struct tree_desc trees[2];    struct unpack_trees_options topts;    struct index_state istate;    int ret = 0;    memset (&istate, 0, sizeof(istate));    snprintf (index_path, SEAF_PATH_MAX, "%s/%s", mgr->index_dir, repo->id);    if (read_index_from (&istate, index_path) < 0) {        g_warning ("Failed to load index./n");        return -1;    }    fill_tree_descriptor (&trees[0], head->root_id);    fill_tree_descriptor (&trees[1], remote->root_id);    memset(&topts, 0, sizeof(topts));    topts.base = repo->worktree;    topts.head_idx = -1;    topts.src_index = &istate;    topts.update = 1;    topts.merge = 1;    topts.fn = twoway_merge;    /* unpack_trees() doesn't update index or worktree. */    if (unpack_trees (2, trees, &topts) < 0) {        g_warning ("Failed to ff to commit %s./n", remote->commit_id);        ret = -1;        goto out;    }    *bl = block_list_new ();    collect_new_blocks_from_index (&topts.result, *bl);out:    tree_desc_free (&trees[0]);    tree_desc_free (&trees[1]);    discard_index (&istate);    discard_index (&topts.result);    return ret;}
开发者ID:AzinmarErus,项目名称:seafile,代码行数:52,


示例14: checkout_fast_forward

static int checkout_fast_forward(unsigned char *head, unsigned char *remote){	struct tree *trees[MAX_UNPACK_TREES];	struct unpack_trees_options opts;	struct tree_desc t[MAX_UNPACK_TREES];	int i, fd, nr_trees = 0;	struct dir_struct dir;	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));	refresh_cache(REFRESH_QUIET);	fd = hold_locked_index(lock_file, 1);	memset(&trees, 0, sizeof(trees));	memset(&opts, 0, sizeof(opts));	memset(&t, 0, sizeof(t));	memset(&dir, 0, sizeof(dir));	dir.flags |= DIR_SHOW_IGNORED;	dir.exclude_per_dir = ".gitignore";	opts.dir = &dir;	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.update = 1;	opts.verbose_update = 1;	opts.merge = 1;	opts.fn = twoway_merge;	opts.msgs = get_porcelain_error_msgs();	trees[nr_trees] = parse_tree_indirect(head);	if (!trees[nr_trees++])		return -1;	trees[nr_trees] = parse_tree_indirect(remote);	if (!trees[nr_trees++])		return -1;	for (i = 0; i < nr_trees; i++) {		parse_tree(trees[i]);		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);	}	if (unpack_trees(nr_trees, t, &opts))		return -1;	if (write_cache(fd, active_cache, active_nr) ||		commit_locked_index(lock_file))		die("unable to write new index file");	return 0;}
开发者ID:samv,项目名称:git,代码行数:47,


示例15: checkout_fast_forward

static int checkout_fast_forward(unsigned char *head, unsigned char *remote){	struct tree *trees[MAX_UNPACK_TREES];	struct unpack_trees_options opts;	struct tree_desc t[MAX_UNPACK_TREES];	int i, fd, nr_trees = 0;	struct dir_struct dir;	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));	if (read_cache_unmerged())		die("you need to resolve your current index first");	fd = hold_locked_index(lock_file, 1);	memset(&trees, 0, sizeof(trees));	memset(&opts, 0, sizeof(opts));	memset(&t, 0, sizeof(t));	dir.show_ignored = 1;	dir.exclude_per_dir = ".gitignore";	opts.dir = &dir;	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.update = 1;	opts.verbose_update = 1;	opts.merge = 1;	opts.fn = twoway_merge;	trees[nr_trees] = parse_tree_indirect(head);	if (!trees[nr_trees++])		return -1;	trees[nr_trees] = parse_tree_indirect(remote);	if (!trees[nr_trees++])		return -1;	for (i = 0; i < nr_trees; i++) {		parse_tree(trees[i]);		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);	}	if (unpack_trees(nr_trees, t, &opts))		return -1;	if (write_cache(fd, active_cache, active_nr) ||		commit_locked_index(lock_file))		die("unable to write new index file");	return 0;}
开发者ID:Pistos,项目名称:git,代码行数:46,


示例16: seafile_merge_trees

static int seafile_merge_trees(struct merge_options *o,                               struct unpack_trees_options *opts,                               SeafDir *common,                               SeafDir *head,                               SeafDir *merge,                               char **error){    int rc;    struct tree_desc t[3];    memset(opts, 0, sizeof(*opts));    if (o->call_depth)        opts->index_only = 1;    else        opts->update = 1;    opts->merge = 1;    opts->head_idx = 2;    opts->base = o->worktree;    opts->fn = threeway_merge;    opts->src_index = o->index;    opts->dst_index = o->index;    if (o->crypt)        opts->crypt = o->crypt;    fill_tree_descriptor(t+0, common->dir_id);    fill_tree_descriptor(t+1, head->dir_id);    fill_tree_descriptor(t+2, merge->dir_id);    rc = unpack_trees(3, t, opts);    if (rc == 0) {        discard_index(o->index);        *(o->index) = opts->result;        if (o->collect_blocks_only)            collect_new_blocks_from_index (o->index, o->bl);    }    tree_desc_free (t);    tree_desc_free (t+1);    tree_desc_free (t+2);    return rc;}
开发者ID:asukaliy,项目名称:seafile,代码行数:44,


示例17: diff_index

int diff_index(struct index_state *istate, SeafDir *root, GList **results){    struct tree_desc t;    struct unpack_trees_options opts;    memset(&opts, 0, sizeof(opts));    opts.head_idx = 1;    opts.index_only = 1;    /* Unmerged entries are handled in diff worktree. */    opts.skip_unmerged = 1;    opts.merge = 1;    opts.fn = oneway_diff;    opts.unpack_data = results;    opts.src_index = istate;    opts.dst_index = NULL;    fill_tree_descriptor(&t, root->dir_id);    int ret = unpack_trees(1, &t, &opts);    tree_desc_free (&t);    return ret;}
开发者ID:2bj,项目名称:seafile,代码行数:22,


示例18: reset_tree

static int reset_tree(struct object_id *i_tree, int update, int reset){	int nr_trees = 1;	struct unpack_trees_options opts;	struct tree_desc t[MAX_UNPACK_TREES];	struct tree *tree;	struct lock_file lock_file = LOCK_INIT;	read_cache_preload(NULL);	if (refresh_cache(REFRESH_QUIET))		return -1;	hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);	memset(&opts, 0, sizeof(opts));	tree = parse_tree_indirect(i_tree);	if (parse_tree(tree))		return -1;	init_tree_desc(t, tree->buffer, tree->size);	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.merge = 1;	opts.reset = reset;	opts.update = update;	opts.fn = oneway_merge;	if (unpack_trees(nr_trees, t, &opts))		return -1;	if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))		return error(_("unable to write new index file"));	return 0;}
开发者ID:PhilipOakley,项目名称:git,代码行数:38,


示例19: cmd_clone

//.........这里部分代码省略.........			transport->verbose = -1;		else if (option_verbose)			transport->progress = 1;		if (option_upload_pack)			transport_set_option(transport, TRANS_OPT_UPLOADPACK,					     option_upload_pack);		refs = transport_get_remote_refs(transport);		transport_fetch_refs(transport, refs);	}	clear_extra_refs();	mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);	head_points_at = locate_head(refs, mapped_refs, &remote_head);	if (head_points_at) {		/* Local default branch link */		create_symref("HEAD", head_points_at->name, NULL);		if (!option_bare) {			struct strbuf head_ref = STRBUF_INIT;			const char *head = head_points_at->name;			if (!prefixcmp(head, "refs/heads/"))				head += 11;			/* Set up the initial local branch */			/* Local branch initial value */			update_ref(reflog_msg.buf, "HEAD",				   head_points_at->old_sha1,				   NULL, 0, DIE_ON_ERR);			strbuf_addstr(&head_ref, branch_top);			strbuf_addstr(&head_ref, "HEAD");			/* Remote branch link */			create_symref(head_ref.buf,				      head_points_at->peer_ref->name,				      reflog_msg.buf);			snprintf(key, sizeof(key), "branch.%s.remote", head);			git_config_set(key, option_origin);			snprintf(key, sizeof(key), "branch.%s.merge", head);			git_config_set(key, head_points_at->name);		}	} else if (remote_head) {		/* Source had detached HEAD pointing somewhere. */		if (!option_bare)			update_ref(reflog_msg.buf, "HEAD",				   remote_head->old_sha1,				   NULL, REF_NODEREF, DIE_ON_ERR);	} else {		/* Nothing to checkout out */		if (!option_no_checkout)			warning("remote HEAD refers to nonexistent ref, "				"unable to checkout./n");		option_no_checkout = 1;	}	if (transport)		transport_unlock_pack(transport);	if (!option_no_checkout) {		struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));		struct unpack_trees_options opts;		struct tree *tree;		struct tree_desc t;		int fd;		/* We need to be in the new work tree for the checkout */		setup_work_tree();		fd = hold_locked_index(lock_file, 1);		memset(&opts, 0, sizeof opts);		opts.update = 1;		opts.merge = 1;		opts.fn = oneway_merge;		opts.verbose_update = !option_quiet;		opts.src_index = &the_index;		opts.dst_index = &the_index;		tree = parse_tree_indirect(remote_head->old_sha1);		parse_tree(tree);		init_tree_desc(&t, tree->buffer, tree->size);		unpack_trees(1, &t, &opts);		if (write_cache(fd, active_cache, active_nr) ||		    commit_locked_index(lock_file))			die("unable to write new index file");	}	strbuf_release(&reflog_msg);	junk_pid = 0;	return 0;}
开发者ID:Inkdit,项目名称:git,代码行数:101,


示例20: reset_index

static int reset_index(const struct object_id *oid, int reset_type, int quiet){	int i, nr = 0;	struct tree_desc desc[2];	struct tree *tree;	struct unpack_trees_options opts;	int ret = -1;	memset(&opts, 0, sizeof(opts));	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.fn = oneway_merge;	opts.merge = 1;	if (!quiet)		opts.verbose_update = 1;	switch (reset_type) {	case KEEP:	case MERGE:		opts.update = 1;		break;	case HARD:		opts.update = 1;		/* fallthrough */	default:		opts.reset = 1;	}	read_cache_unmerged();	if (reset_type == KEEP) {		struct object_id head_oid;		if (get_oid("HEAD", &head_oid))			return error(_("You do not have a valid HEAD."));		if (!fill_tree_descriptor(desc + nr, &head_oid))			return error(_("Failed to find tree of HEAD."));		nr++;		opts.fn = twoway_merge;	}	if (!fill_tree_descriptor(desc + nr, oid)) {		error(_("Failed to find tree of %s."), oid_to_hex(oid));		goto out;	}	nr++;	if (unpack_trees(nr, desc, &opts))		goto out;	if (reset_type == MIXED || reset_type == HARD) {		tree = parse_tree_indirect(oid);		prime_cache_tree(&the_index, tree);	}	ret = 0;out:	for (i = 0; i < nr; i++)		free((void *)desc[i].buffer);	return ret;}
开发者ID:guban,项目名称:git,代码行数:61,


示例21: checkout_fast_forward

int checkout_fast_forward(const struct object_id *head,			  const struct object_id *remote,			  int overwrite_ignore){	struct tree *trees[MAX_UNPACK_TREES];	struct unpack_trees_options opts;	struct tree_desc t[MAX_UNPACK_TREES];	int i, nr_trees = 0;	struct dir_struct dir;	struct lock_file lock_file = LOCK_INIT;	refresh_cache(REFRESH_QUIET);	if (hold_locked_index(&lock_file, LOCK_REPORT_ON_ERROR) < 0)		return -1;	memset(&trees, 0, sizeof(trees));	memset(&t, 0, sizeof(t));	trees[nr_trees] = parse_tree_indirect(head);	if (!trees[nr_trees++]) {		rollback_lock_file(&lock_file);		return -1;	}	trees[nr_trees] = parse_tree_indirect(remote);	if (!trees[nr_trees++]) {		rollback_lock_file(&lock_file);		return -1;	}	for (i = 0; i < nr_trees; i++) {		parse_tree(trees[i]);		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);	}	memset(&opts, 0, sizeof(opts));	if (overwrite_ignore) {		memset(&dir, 0, sizeof(dir));		dir.flags |= DIR_SHOW_IGNORED;		setup_standard_excludes(&dir);		opts.dir = &dir;	}	opts.head_idx = 1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	opts.update = 1;	opts.verbose_update = 1;	opts.merge = 1;	opts.fn = twoway_merge;	setup_unpack_trees_porcelain(&opts, "merge");	if (unpack_trees(nr_trees, t, &opts)) {		rollback_lock_file(&lock_file);		clear_unpack_trees_porcelain(&opts);		return -1;	}	clear_unpack_trees_porcelain(&opts);	if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))		return error(_("unable to write new index file"));	return 0;}
开发者ID:Nowher2,项目名称:git,代码行数:62,


示例22: cmd_read_tree

int cmd_read_tree(int argc, const char **argv, const char *unused_prefix){	int i, newfd, stage = 0;	unsigned char sha1[20];	struct tree_desc t[MAX_UNPACK_TREES];	struct unpack_trees_options opts;	int prefix_set = 0;	const struct option read_tree_options[] = {		{ OPTION_CALLBACK, 0, "index-output", NULL, N_("file"),		  N_("write resulting index to <file>"),		  PARSE_OPT_NONEG, index_output_cb },		OPT_SET_INT(0, "empty", &read_empty,			    N_("only empty the index"), 1),		OPT__VERBOSE(&opts.verbose_update, N_("be verbose")),		OPT_GROUP(N_("Merging")),		OPT_SET_INT('m', NULL, &opts.merge,			    N_("perform a merge in addition to a read"), 1),		OPT_SET_INT(0, "trivial", &opts.trivial_merges_only,			    N_("3-way merge if no file level merging required"), 1),		OPT_SET_INT(0, "aggressive", &opts.aggressive,			    N_("3-way merge in presence of adds and removes"), 1),		OPT_SET_INT(0, "reset", &opts.reset,			    N_("same as -m, but discard unmerged entries"), 1),		{ OPTION_STRING, 0, "prefix", &opts.prefix, N_("<subdirectory>/"),		  N_("read the tree into the index under <subdirectory>/"),		  PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP },		OPT_SET_INT('u', NULL, &opts.update,			    N_("update working tree with merge result"), 1),		{ OPTION_CALLBACK, 0, "exclude-per-directory", &opts,		  N_("gitignore"),		  N_("allow explicitly ignored files to be overwritten"),		  PARSE_OPT_NONEG, exclude_per_directory_cb },		OPT_SET_INT('i', NULL, &opts.index_only,			    N_("don't check the working tree after merging"), 1),		OPT__DRY_RUN(&opts.dry_run, N_("don't update the index or the work tree")),		OPT_SET_INT(0, "no-sparse-checkout", &opts.skip_sparse_checkout,			    N_("skip applying sparse checkout filter"), 1),		OPT_SET_INT(0, "debug-unpack", &opts.debug_unpack,			    N_("debug unpack-trees"), 1),		OPT_END()	};	memset(&opts, 0, sizeof(opts));	opts.head_idx = -1;	opts.src_index = &the_index;	opts.dst_index = &the_index;	git_config(git_default_config, NULL);	argc = parse_options(argc, argv, unused_prefix, read_tree_options,			     read_tree_usage, 0);	newfd = hold_locked_index(&lock_file, 1);	prefix_set = opts.prefix ? 1 : 0;	if (1 < opts.merge + opts.reset + prefix_set)		die("Which one? -m, --reset, or --prefix?");	if (opts.reset || opts.merge || opts.prefix) {		if (read_cache_unmerged() && (opts.prefix || opts.merge))			die("You need to resolve your current index first");		stage = opts.merge = 1;	}	resolve_undo_clear();	for (i = 0; i < argc; i++) {		const char *arg = argv[i];		if (get_sha1(arg, sha1))			die("Not a valid object name %s", arg);		if (list_tree(sha1) < 0)			die("failed to unpack tree object %s", arg);		stage++;	}	if (nr_trees == 0 && !read_empty)		warning("read-tree: emptying the index with no arguments is deprecated; use --empty");	else if (nr_trees > 0 && read_empty)		die("passing trees as arguments contradicts --empty");	if (1 < opts.index_only + opts.update)		die("-u and -i at the same time makes no sense");	if ((opts.update||opts.index_only) && !opts.merge)		die("%s is meaningless without -m, --reset, or --prefix",		    opts.update ? "-u" : "-i");	if ((opts.dir && !opts.update))		die("--exclude-per-directory is meaningless unless -u");	if (opts.merge && !opts.index_only)		setup_work_tree();	if (opts.merge) {		if (stage < 2)			die("just how do you expect me to merge %d trees?", stage-1);		switch (stage - 1) {		case 1:			opts.fn = opts.prefix ? bind_merge : oneway_merge;			break;		case 2:			opts.fn = twoway_merge;			opts.initial_checkout = is_cache_unborn();			break;//.........这里部分代码省略.........
开发者ID:4rch17,项目名称:git,代码行数:101,


示例23: fast_forward_checkout

static intfast_forward_checkout (SeafRepo *repo, SeafCommit *head, CloneTask *task){    SeafRepoManager *mgr = repo->manager;    char index_path[SEAF_PATH_MAX];    struct tree_desc trees[2];    struct unpack_trees_options topts;    struct index_state istate;    int ret = 0;    if (strcmp (head->root_id, task->root_id) == 0)        return 0;    memset (&istate, 0, sizeof(istate));    snprintf (index_path, SEAF_PATH_MAX, "%s/%s", mgr->index_dir, repo->id);    if (read_index_from (&istate, index_path) < 0) {        seaf_warning ("Failed to load index./n");        return -1;    }    repo->index_corrupted = FALSE;    fill_tree_descriptor (&trees[0], task->root_id);    fill_tree_descriptor (&trees[1], head->root_id);    memset(&topts, 0, sizeof(topts));    topts.base = task->worktree;    topts.head_idx = -1;    topts.src_index = &istate;    topts.update = 1;    topts.merge = 1;    topts.fn = twoway_merge;    if (repo->encrypted) {        topts.crypt = seafile_crypt_new (repo->enc_version,                                          repo->enc_key,                                          repo->enc_iv);    }    if (unpack_trees (2, trees, &topts) < 0) {        seaf_warning ("Failed to merge commit %s with work tree./n", head->commit_id);        ret = -1;        goto out;    }    if (update_worktree (&topts, FALSE,                         head->commit_id,                         head->creator_name,                         NULL) < 0) {        seaf_warning ("Failed to update worktree./n");        ret = -1;        goto out;    }    discard_index (&istate);    istate = topts.result;    if (update_index (&istate, index_path) < 0) {        seaf_warning ("Failed to update index./n");    }out:    tree_desc_free (&trees[0]);    tree_desc_free (&trees[1]);    g_free (topts.crypt);    discard_index (&istate);    return ret;}
开发者ID:break123,项目名称:seafile,代码行数:69,


示例24: checkout

static int checkout(int submodule_progress){	unsigned char sha1[20];	char *head;	struct lock_file *lock_file;	struct unpack_trees_options opts;	struct tree *tree;	struct tree_desc t;	int err = 0;	if (option_no_checkout)		return 0;	head = resolve_refdup("HEAD", RESOLVE_REF_READING, sha1, NULL);	if (!head) {		warning(_("remote HEAD refers to nonexistent ref, "			  "unable to checkout./n"));		return 0;	}	if (!strcmp(head, "HEAD")) {		if (advice_detached_head)			detach_advice(sha1_to_hex(sha1));	} else {		if (!starts_with(head, "refs/heads/"))			die(_("HEAD not found below refs/heads!"));	}	free(head);	/* We need to be in the new work tree for the checkout */	setup_work_tree();	lock_file = xcalloc(1, sizeof(struct lock_file));	hold_locked_index(lock_file, LOCK_DIE_ON_ERROR);	memset(&opts, 0, sizeof opts);	opts.update = 1;	opts.merge = 1;	opts.fn = oneway_merge;	opts.verbose_update = (option_verbosity >= 0);	opts.src_index = &the_index;	opts.dst_index = &the_index;	tree = parse_tree_indirect(sha1);	parse_tree(tree);	init_tree_desc(&t, tree->buffer, tree->size);	if (unpack_trees(1, &t, &opts) < 0)		die(_("unable to checkout working tree"));	if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))		die(_("unable to write new index file"));	err |= run_hook_le(NULL, "post-checkout", sha1_to_hex(null_sha1),			   sha1_to_hex(sha1), "1", NULL);	if (!err && option_recursive) {		struct argv_array args = ARGV_ARRAY_INIT;		argv_array_pushl(&args, "submodule", "update", "--init", "--recursive", NULL);		if (option_shallow_submodules == 1)			argv_array_push(&args, "--depth=1");		if (max_jobs != -1)			argv_array_pushf(&args, "--jobs=%d", max_jobs);		if (submodule_progress)			argv_array_push(&args, "--progress");		err = run_command_v_opt(args.argv, RUN_GIT_CMD);		argv_array_clear(&args);	}	return err;}
开发者ID:dindinw,项目名称:git,代码行数:73,


示例25: cmd_clone

//.........这里部分代码省略.........		else			our_head_points_at = remote_head_points_at;	}	else {		warning("You appear to have cloned an empty repository.");		our_head_points_at = NULL;		remote_head_points_at = NULL;		remote_head = NULL;		option_no_checkout = 1;		if (!option_bare)			install_branch_config(0, "master", option_origin,					      "refs/heads/master");	}	if (remote_head_points_at && !option_bare) {		struct strbuf head_ref = STRBUF_INIT;		strbuf_addstr(&head_ref, branch_top.buf);		strbuf_addstr(&head_ref, "HEAD");		create_symref(head_ref.buf,			      remote_head_points_at->peer_ref->name,			      reflog_msg.buf);	}	if (our_head_points_at) {		/* Local default branch link */		create_symref("HEAD", our_head_points_at->name, NULL);		if (!option_bare) {			const char *head = skip_prefix(our_head_points_at->name,						       "refs/heads/");			update_ref(reflog_msg.buf, "HEAD",				   our_head_points_at->old_sha1,				   NULL, 0, DIE_ON_ERR);			install_branch_config(0, head, option_origin,					      our_head_points_at->name);		}	} else if (remote_head) {		/* Source had detached HEAD pointing somewhere. */		if (!option_bare) {			update_ref(reflog_msg.buf, "HEAD",				   remote_head->old_sha1,				   NULL, REF_NODEREF, DIE_ON_ERR);			our_head_points_at = remote_head;		}	} else {		/* Nothing to checkout out */		if (!option_no_checkout)			warning("remote HEAD refers to nonexistent ref, "				"unable to checkout./n");		option_no_checkout = 1;	}	if (transport) {		transport_unlock_pack(transport);		transport_disconnect(transport);	}	if (!option_no_checkout) {		struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));		struct unpack_trees_options opts;		struct tree *tree;		struct tree_desc t;		int fd;		/* We need to be in the new work tree for the checkout */		setup_work_tree();		fd = hold_locked_index(lock_file, 1);		memset(&opts, 0, sizeof opts);		opts.update = 1;		opts.merge = 1;		opts.fn = oneway_merge;		opts.verbose_update = !option_quiet;		opts.src_index = &the_index;		opts.dst_index = &the_index;		tree = parse_tree_indirect(our_head_points_at->old_sha1);		parse_tree(tree);		init_tree_desc(&t, tree->buffer, tree->size);		unpack_trees(1, &t, &opts);		if (write_cache(fd, active_cache, active_nr) ||		    commit_locked_index(lock_file))			die("unable to write new index file");		err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),				sha1_to_hex(our_head_points_at->old_sha1), "1",				NULL);		if (!err && option_recursive)			err = run_command_v_opt(argv_submodule, RUN_GIT_CMD);	}	strbuf_release(&reflog_msg);	strbuf_release(&branch_top);	strbuf_release(&key);	strbuf_release(&value);	junk_pid = 0;	return err;}
开发者ID:astubbs,项目名称:git,代码行数:101,


示例26: merge_working_tree

static int merge_working_tree(const struct checkout_opts *opts,			      struct branch_info *old_branch_info,			      struct branch_info *new_branch_info,			      int *writeout_error){	int ret;	struct lock_file lock_file = LOCK_INIT;	hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);	if (read_cache_preload(NULL) < 0)		return error(_("index file corrupt"));	resolve_undo_clear();	if (opts->force) {		ret = reset_tree(get_commit_tree(new_branch_info->commit),				 opts, 1, writeout_error);		if (ret)			return ret;	} else {		struct tree_desc trees[2];		struct tree *tree;		struct unpack_trees_options topts;		memset(&topts, 0, sizeof(topts));		topts.head_idx = -1;		topts.src_index = &the_index;		topts.dst_index = &the_index;		setup_unpack_trees_porcelain(&topts, "checkout");		refresh_cache(REFRESH_QUIET);		if (unmerged_cache()) {			error(_("you need to resolve your current index first"));			return 1;		}		/* 2-way merge to the new branch */		topts.initial_checkout = is_cache_unborn();		topts.update = 1;		topts.merge = 1;		topts.gently = opts->merge && old_branch_info->commit;		topts.verbose_update = opts->show_progress;		topts.fn = twoway_merge;		if (opts->overwrite_ignore) {			topts.dir = xcalloc(1, sizeof(*topts.dir));			topts.dir->flags |= DIR_SHOW_IGNORED;			setup_standard_excludes(topts.dir);		}		tree = parse_tree_indirect(old_branch_info->commit ?					   &old_branch_info->commit->object.oid :					   the_hash_algo->empty_tree);		init_tree_desc(&trees[0], tree->buffer, tree->size);		tree = parse_tree_indirect(&new_branch_info->commit->object.oid);		init_tree_desc(&trees[1], tree->buffer, tree->size);		ret = unpack_trees(2, trees, &topts);		clear_unpack_trees_porcelain(&topts);		if (ret == -1) {			/*			 * Unpack couldn't do a trivial merge; either			 * give up or do a real merge, depending on			 * whether the merge flag was used.			 */			struct tree *result;			struct tree *work;			struct merge_options o;			if (!opts->merge)				return 1;			/*			 * Without old_branch_info->commit, the below is the same as			 * the two-tree unpack we already tried and failed.			 */			if (!old_branch_info->commit)				return 1;			/* Do more real merge */			/*			 * We update the index fully, then write the			 * tree from the index, then merge the new			 * branch with the current tree, with the old			 * branch as the base. Then we reset the index			 * (but not the working tree) to the new			 * branch, leaving the working tree as the			 * merged version, but skipping unmerged			 * entries in the index.			 */			add_files_to_cache(NULL, NULL, 0);			/*			 * NEEDSWORK: carrying over local changes			 * when branches have different end-of-line			 * normalization (or clean+smudge rules) is			 * a pain; plumb in an option to set			 * o.renormalize?			 */			init_merge_options(&o, the_repository);			o.verbosity = 0;//.........这里部分代码省略.........
开发者ID:Noffica,项目名称:git,代码行数:101,



注:本文中的unpack_trees函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ unpause函数代码示例
C++ unpack函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。