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

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

51自学网 2021-06-01 20:21:54
  C++
这篇教程C++ DIFF_OPT_TST函数代码示例写得很实用,希望能帮到您。

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

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

示例1: show_entry

/* A file entry went away or appeared */static void show_entry(struct diff_options *opt, const char *prefix,		       struct tree_desc *desc, struct strbuf *base){	unsigned mode;	const char *path;	const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);	int pathlen = tree_entry_len(path, sha1);	int old_baselen = base->len;	strbuf_add(base, path, pathlen);	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {		enum object_type type;		struct tree_desc inner;		void *tree;		unsigned long size;		tree = read_sha1_file(sha1, &type, &size);		if (!tree || type != OBJ_TREE)			die("corrupt tree sha %s", sha1_to_hex(sha1));		if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))			opt->add_remove(opt, *prefix, mode, sha1, base->buf, 0);		strbuf_addch(base, '/');		init_tree_desc(&inner, tree, size);		show_tree(opt, prefix, &inner, base);		free(tree);	} else		opt->add_remove(opt, prefix[0], mode, sha1, base->buf, 0);	strbuf_setlen(base, old_baselen);}
开发者ID:julesbowden,项目名称:git,代码行数:34,


示例2: compare_tree_entry

static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const char *base, int baselen, struct diff_options *opt){	unsigned mode1, mode2;	const char *path1, *path2;	const unsigned char *sha1, *sha2;	int cmp, pathlen1, pathlen2;	char *fullname;	sha1 = tree_entry_extract(t1, &path1, &mode1);	sha2 = tree_entry_extract(t2, &path2, &mode2);	pathlen1 = tree_entry_len(path1, sha1);	pathlen2 = tree_entry_len(path2, sha2);	cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);	if (cmp < 0) {		show_entry(opt, "-", t1, base, baselen);		return -1;	}	if (cmp > 0) {		show_entry(opt, "+", t2, base, baselen);		return 1;	}	if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)		return 0;	/*	 * If the filemode has changed to/from a directory from/to a regular	 * file, we need to consider it a remove and an add.	 */	if (S_ISDIR(mode1) != S_ISDIR(mode2)) {		show_entry(opt, "-", t1, base, baselen);		show_entry(opt, "+", t2, base, baselen);		return 0;	}	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {		int retval;		char *newbase = malloc_base(base, baselen, path1, pathlen1);		if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {			newbase[baselen + pathlen1] = 0;			opt->change(opt, mode1, mode2,				    sha1, sha2, newbase);			newbase[baselen + pathlen1] = '/';		}		retval = diff_tree_sha1(sha1, sha2, newbase, opt);		free(newbase);		return retval;	}	fullname = malloc_fullname(base, baselen, path1, pathlen1);	opt->change(opt, mode1, mode2, sha1, sha2, fullname);	free(fullname);	return 0;}
开发者ID:Inkdit,项目名称:git,代码行数:54,


示例3: match_stat_with_submodule

/* * Has a file changed or has a submodule new commits or a dirty work tree? * * Return 1 when changes are detected, 0 otherwise. If the DIRTY_SUBMODULES * option is set, the caller does not only want to know if a submodule is * modified at all but wants to know all the conditions that are met (new * commits, untracked content and/or modified content). */static int match_stat_with_submodule(struct diff_options *diffopt,				      struct cache_entry *ce, struct stat *st,				      unsigned ce_option, unsigned *dirty_submodule){	int changed = ce_match_stat(ce, st, ce_option);	if (S_ISGITLINK(ce->ce_mode)	    && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)	    && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {		*dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));	}	return changed;}
开发者ID:Provab-Solutions,项目名称:git,代码行数:20,


示例4: compare_tree_entry

static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,			      struct strbuf *base, struct diff_options *opt){	unsigned mode1, mode2;	const char *path1, *path2;	const unsigned char *sha1, *sha2;	int cmp, pathlen1, pathlen2;	int old_baselen = base->len;	sha1 = tree_entry_extract(t1, &path1, &mode1);	sha2 = tree_entry_extract(t2, &path2, &mode2);	pathlen1 = tree_entry_len(path1, sha1);	pathlen2 = tree_entry_len(path2, sha2);	cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);	if (cmp < 0) {		show_entry(opt, "-", t1, base);		return -1;	}	if (cmp > 0) {		show_entry(opt, "+", t2, base);		return 1;	}	if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)		return 0;	/*	 * If the filemode has changed to/from a directory from/to a regular	 * file, we need to consider it a remove and an add.	 */	if (S_ISDIR(mode1) != S_ISDIR(mode2)) {		show_entry(opt, "-", t1, base);		show_entry(opt, "+", t2, base);		return 0;	}	strbuf_add(base, path1, pathlen1);	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {		if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {			opt->change(opt, mode1, mode2,				    sha1, sha2, base->buf, 0, 0);		}		strbuf_addch(base, '/');		diff_tree_sha1(sha1, sha2, base->buf, opt);	} else {		opt->change(opt, mode1, mode2, sha1, sha2, base->buf, 0, 0);	}	strbuf_setlen(base, old_baselen);	return 0;}
开发者ID:julesbowden,项目名称:git,代码行数:50,


示例5: show_entry

/* A file entry went away or appeared */static void show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc,		       const char *base, int baselen){	unsigned mode;	const char *path;	const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);	int pathlen = tree_entry_len(path, sha1);	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {		enum object_type type;		char *newbase = malloc_base(base, baselen, path, pathlen);		struct tree_desc inner;		void *tree;		unsigned long size;		tree = read_sha1_file(sha1, &type, &size);		if (!tree || type != OBJ_TREE)			die("corrupt tree sha %s", sha1_to_hex(sha1));		init_tree_desc(&inner, tree, size);		show_tree(opt, prefix, &inner, newbase, baselen + 1 + pathlen);		free(tree);		free(newbase);	} else {		char *fullname = malloc_fullname(base, baselen, path, pathlen);		opt->add_remove(opt, prefix[0], mode, sha1, fullname);		free(fullname);	}}
开发者ID:Inkdit,项目名称:git,代码行数:31,


示例6: fill_origin_blob

/* * Given an origin, prepare mmfile_t structure to be used by the * diff machinery */static void fill_origin_blob(struct diff_options *opt,			     struct blame_origin *o, mmfile_t *file, int *num_read_blob){	if (!o->file.ptr) {		enum object_type type;		unsigned long file_size;		(*num_read_blob)++;		if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&		    textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))			;		else			file->ptr = read_sha1_file(o->blob_oid.hash, &type,						   &file_size);		file->size = file_size;		if (!file->ptr)			die("Cannot read blob %s for path %s",			    oid_to_hex(&o->blob_oid),			    o->path);		o->file = *file;	}	else		*file = o->file;}
开发者ID:basilgor,项目名称:git,代码行数:29,


示例7: cmd_log_init

static void cmd_log_init(int argc, const char **argv, const char *prefix,		      struct rev_info *rev){	int i;	int decorate = 0;	rev->abbrev = DEFAULT_ABBREV;	rev->commit_format = CMIT_FMT_DEFAULT;	if (fmt_pretty)		get_commit_format(fmt_pretty, rev);	rev->verbose_header = 1;	DIFF_OPT_SET(&rev->diffopt, RECURSIVE);	rev->show_root_diff = default_show_root;	rev->subject_prefix = fmt_patch_subject_prefix;	argc = setup_revisions(argc, argv, rev, "HEAD");	if (rev->diffopt.pickaxe || rev->diffopt.filter)		rev->always_show_header = 0;	if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {		rev->always_show_header = 0;		if (rev->diffopt.nr_paths != 1)			usage("git logs can only follow renames on one pathname at a time");	}	for (i = 1; i < argc; i++) {		const char *arg = argv[i];		if (!strcmp(arg, "--decorate")) {			if (!decorate)				for_each_ref(add_ref_decoration, NULL);			decorate = 1;		} else			die("unrecognized argument: %s", arg);	}}
开发者ID:dlowe,项目名称:nnet,代码行数:32,


示例8: stuff_change

static void stuff_change(struct diff_options *opt,			 unsigned old_mode, unsigned new_mode,			 const unsigned char *old_sha1,			 const unsigned char *new_sha1,			 const char *old_name,			 const char *new_name){	struct diff_filespec *one, *two;	if (!is_null_sha1(old_sha1) && !is_null_sha1(new_sha1) &&	    !hashcmp(old_sha1, new_sha1) && (old_mode == new_mode))		return;	if (DIFF_OPT_TST(opt, REVERSE_DIFF)) {		unsigned tmp;		const unsigned char *tmp_u;		const char *tmp_c;		tmp = old_mode; old_mode = new_mode; new_mode = tmp;		tmp_u = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_u;		tmp_c = old_name; old_name = new_name; new_name = tmp_c;	}	if (opt->prefix &&	    (strncmp(old_name, opt->prefix, opt->prefix_length) ||	     strncmp(new_name, opt->prefix, opt->prefix_length)))		return;	one = alloc_filespec(old_name);	two = alloc_filespec(new_name);	fill_filespec(one, old_sha1, old_mode);	fill_filespec(two, new_sha1, new_mode);	diff_queue(&diff_queued_diff, one, two);}
开发者ID:tnachen,项目名称:git,代码行数:34,


示例9: cmd_log_walk

static int cmd_log_walk(struct rev_info *rev){	struct commit *commit;	if (rev->early_output)		setup_early_output(rev);	if (prepare_revision_walk(rev))		die("revision walk setup failed");	if (rev->early_output)		finish_early_output(rev);	/*	 * For --check and --exit-code, the exit code is based on CHECK_FAILED	 * and HAS_CHANGES being accumulated in rev->diffopt, so be careful to	 * retain that state information if replacing rev->diffopt in this loop	 */	while ((commit = get_revision(rev)) != NULL) {		log_tree_commit(rev, commit);		if (!rev->reflog_info) {			/* we allow cycles in reflog ancestry */			free(commit->buffer);			commit->buffer = NULL;		}		free_commit_list(commit->parents);		commit->parents = NULL;	}	if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&	    DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {		return 02;	}	return diff_result_code(&rev->diffopt, 0);}
开发者ID:samv,项目名称:git,代码行数:34,


示例10: reopen_stdout

static int reopen_stdout(struct commit *commit, struct rev_info *rev){	struct strbuf filename = STRBUF_INIT;	int suffix_len = strlen(fmt_patch_suffix) + 1;	if (output_directory) {		strbuf_addstr(&filename, output_directory);		if (filename.len >=		    PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len)			return error("name of output directory is too long");		if (filename.buf[filename.len - 1] != '/')			strbuf_addch(&filename, '/');	}	get_patch_filename(commit, rev->nr, fmt_patch_suffix, &filename);	if (!DIFF_OPT_TST(&rev->diffopt, QUIET))		fprintf(realstdout, "%s/n", filename.buf + outdir_offset);	if (freopen(filename.buf, "w", stdout) == NULL)		return error("Cannot open patch file %s", filename.buf);	strbuf_release(&filename);	return 0;}
开发者ID:samv,项目名称:git,代码行数:25,


示例11: diffcore_pickaxe_count

static void diffcore_pickaxe_count(struct diff_options *o){	const char *needle = o->pickaxe;	int opts = o->pickaxe_opts;	unsigned long len = strlen(needle);	regex_t regex, *regexp = NULL;	kwset_t kws = NULL;	if (opts & DIFF_PICKAXE_REGEX) {		int err;		err = regcomp(&regex, needle, REG_EXTENDED | REG_NEWLINE);		if (err) {			/* The POSIX.2 people are surely sick */			char errbuf[1024];			regerror(err, &regex, errbuf, 1024);			regfree(&regex);			die("invalid pickaxe regex: %s", errbuf);		}		regexp = &regex;	} else {		kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)			       ? tolower_trans_tbl : NULL);		kwsincr(kws, needle, len);		kwsprep(kws);	}	pickaxe(&diff_queued_diff, o, regexp, kws, has_changes);	if (opts & DIFF_PICKAXE_REGEX)		regfree(&regex);	else		kwsfree(kws);	return;}
开发者ID:4rch17,项目名称:git,代码行数:34,


示例12: stuff_change

static void stuff_change(struct diff_options *opt,			 unsigned old_mode, unsigned new_mode,			 const struct object_id *old_oid,			 const struct object_id *new_oid,			 int old_oid_valid,			 int new_oid_valid,			 const char *old_path,			 const char *new_path){	struct diff_filespec *one, *two;	if (!is_null_oid(old_oid) && !is_null_oid(new_oid) &&	    !oidcmp(old_oid, new_oid) && (old_mode == new_mode))		return;	if (DIFF_OPT_TST(opt, REVERSE_DIFF)) {		SWAP(old_mode, new_mode);		SWAP(old_oid, new_oid);		SWAP(old_path, new_path);	}	if (opt->prefix &&	    (strncmp(old_path, opt->prefix, opt->prefix_length) ||	     strncmp(new_path, opt->prefix, opt->prefix_length)))		return;	one = alloc_filespec(old_path);	two = alloc_filespec(new_path);	fill_filespec(one, old_oid, old_oid_valid, old_mode);	fill_filespec(two, new_oid, new_oid_valid, new_mode);	diff_queue(&diff_queued_diff, one, two);}
开发者ID:Litttle-butterfly,项目名称:git,代码行数:33,


示例13: log_tree_diff

/* * Show the diff of a commit. * * Return true if we printed any log info messages */static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log_info *log){	int showed_log;	struct commit_list *parents;	unsigned const char *sha1 = commit->object.sha1;	if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))		return 0;	/* Root commit? */	parents = commit->parents;	if (!parents) {		if (opt->show_root_diff) {			diff_root_tree_sha1(sha1, "", &opt->diffopt);			log_tree_diff_flush(opt);		}		return !opt->loginfo;	}	/* More than one parent? */	if (parents && parents->next) {		if (opt->ignore_merges)			return 0;		else if (opt->combine_merges)			return do_diff_combined(opt, commit);		else if (opt->first_parent_only) {			/*			 * Generate merge log entry only for the first			 * parent, showing summary diff of the others			 * we merged _in_.			 */			diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);			log_tree_diff_flush(opt);			return !opt->loginfo;		}		/* If we show individual diffs, show the parent info */		log->parent = parents->item;	}	showed_log = 0;	for (;;) {		struct commit *parent = parents->item;		diff_tree_sha1(parent->object.sha1, sha1, "", &opt->diffopt);		log_tree_diff_flush(opt);		showed_log |= !opt->loginfo;		/* Set up the log info for the next parent, if any.. */		parents = parents->next;		if (!parents)			break;		log->parent = parents->item;		opt->loginfo = log;	}	return showed_log;}
开发者ID:Advael,项目名称:git,代码行数:63,


示例14: cmd_log_init

static void cmd_log_init(int argc, const char **argv, const char *prefix,		      struct rev_info *rev){	int i;	int decoration_style = 0;	rev->abbrev = DEFAULT_ABBREV;	rev->commit_format = CMIT_FMT_DEFAULT;	if (fmt_pretty)		get_commit_format(fmt_pretty, rev);	rev->verbose_header = 1;	DIFF_OPT_SET(&rev->diffopt, RECURSIVE);	rev->show_root_diff = default_show_root;	rev->subject_prefix = fmt_patch_subject_prefix;	DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);	if (default_date_mode)		rev->date_mode = parse_date_format(default_date_mode);	/*	 * Check for -h before setup_revisions(), or "git log -h" will	 * fail when run without a git directory.	 */	if (argc == 2 && !strcmp(argv[1], "-h"))		usage(builtin_log_usage);	argc = setup_revisions(argc, argv, rev, "HEAD");	if (rev->diffopt.pickaxe || rev->diffopt.filter)		rev->always_show_header = 0;	if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {		rev->always_show_header = 0;		if (rev->diffopt.nr_paths != 1)			usage("git logs can only follow renames on one pathname at a time");	}	for (i = 1; i < argc; i++) {		const char *arg = argv[i];		if (!strcmp(arg, "--decorate")) {			decoration_style = DECORATE_SHORT_REFS;		} else if (!prefixcmp(arg, "--decorate=")) {			const char *v = skip_prefix(arg, "--decorate=");			if (!strcmp(v, "full"))				decoration_style = DECORATE_FULL_REFS;			else if (!strcmp(v, "short"))				decoration_style = DECORATE_SHORT_REFS;			else				die("invalid --decorate option: %s", arg);		} else if (!strcmp(arg, "--source")) {			rev->show_source = 1;		} else if (!strcmp(arg, "-h")) {			usage(builtin_log_usage);		} else			die("unrecognized argument: %s", arg);	}	if (decoration_style) {		rev->show_decorations = 1;		load_ref_decorations(decoration_style);	}}
开发者ID:samv,项目名称:git,代码行数:58,


示例15: match_stat_with_submodule

/* * Has a file changed or has a submodule new commits or a dirty work tree? * * Return 1 when changes are detected, 0 otherwise. If the DIRTY_SUBMODULES * option is set, the caller does not only want to know if a submodule is * modified at all but wants to know all the conditions that are met (new * commits, untracked content and/or modified content). */static int match_stat_with_submodule(struct diff_options *diffopt,                                     struct cache_entry *ce, struct stat *st,                                     unsigned ce_option, unsigned *dirty_submodule){    int changed = ce_match_stat(ce, st, ce_option);    if (S_ISGITLINK(ce->ce_mode)) {        unsigned orig_flags = diffopt->flags;        if (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))            set_diffopt_flags_from_submodule_config(diffopt, ce->name);        if (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))            changed = 0;        else if (!DIFF_OPT_TST(diffopt, IGNORE_DIRTY_SUBMODULES)                 && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES)))            *dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));        diffopt->flags = orig_flags;    }    return changed;}
开发者ID:jjuran,项目名称:git,代码行数:26,


示例16: index_is_dirty

static int index_is_dirty(void){	struct rev_info rev;	init_revisions(&rev, NULL);	setup_revisions(0, NULL, &rev, "HEAD");	DIFF_OPT_SET(&rev.diffopt, QUIET);	DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);	run_diff_index(&rev, 1);	return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);}
开发者ID:Jatinpurohit,项目名称:git,代码行数:10,


示例17: diff_tree

int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt){	int baselen = strlen(base);	for (;;) {		if (DIFF_OPT_TST(opt, QUICK) &&		    DIFF_OPT_TST(opt, HAS_CHANGES))			break;		if (opt->nr_paths) {			skip_uninteresting(t1, base, baselen, opt);			skip_uninteresting(t2, base, baselen, opt);		}		if (!t1->size) {			if (!t2->size)				break;			show_entry(opt, "+", t2, base, baselen);			update_tree_entry(t2);			continue;		}		if (!t2->size) {			show_entry(opt, "-", t1, base, baselen);			update_tree_entry(t1);			continue;		}		switch (compare_tree_entry(t1, t2, base, baselen, opt)) {		case -1:			update_tree_entry(t1);			continue;		case 0:			update_tree_entry(t1);			/* Fallthrough */		case 1:			update_tree_entry(t2);			continue;		}		die("git diff-tree: internal error");	}	return 0;}
开发者ID:Jinyan,项目名称:git,代码行数:39,


示例18: diff_tree

int diff_tree(struct tree_desc *t1, struct tree_desc *t2,	      const char *base_str, struct diff_options *opt){	struct strbuf base;	int baselen = strlen(base_str);	enum interesting t1_match = entry_not_interesting;	enum interesting t2_match = entry_not_interesting;	/* Enable recursion indefinitely */	opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);	opt->pathspec.max_depth = -1;	strbuf_init(&base, PATH_MAX);	strbuf_add(&base, base_str, baselen);	for (;;) {		if (diff_can_quit_early(opt))			break;		if (opt->pathspec.nr) {			skip_uninteresting(t1, &base, opt, &t1_match);			skip_uninteresting(t2, &base, opt, &t2_match);		}		if (!t1->size) {			if (!t2->size)				break;			show_entry(opt, "+", t2, &base);			update_tree_entry(t2);			continue;		}		if (!t2->size) {			show_entry(opt, "-", t1, &base);			update_tree_entry(t1);			continue;		}		switch (compare_tree_entry(t1, t2, &base, opt)) {		case -1:			update_tree_entry(t1);			continue;		case 0:			update_tree_entry(t1);			/* Fallthrough */		case 1:			update_tree_entry(t2);			continue;		}		die("git diff-tree: internal error");	}	strbuf_release(&base);	return 0;}
开发者ID:mxz297,项目名称:Git-author,代码行数:51,


示例19: cmd_log_walk

static int cmd_log_walk(struct rev_info *rev){	struct commit *commit;	int saved_nrl = 0;	int saved_dcctc = 0;	if (rev->early_output)		setup_early_output(rev);	if (prepare_revision_walk(rev))		die(_("revision walk setup failed"));	if (rev->early_output)		finish_early_output(rev);	/*	 * For --check and --exit-code, the exit code is based on CHECK_FAILED	 * and HAS_CHANGES being accumulated in rev->diffopt, so be careful to	 * retain that state information if replacing rev->diffopt in this loop	 */	while ((commit = get_revision(rev)) != NULL) {		if (!log_tree_commit(rev, commit) &&		    rev->max_count >= 0)			/*			 * We decremented max_count in get_revision,			 * but we didn't actually show the commit.			 */			rev->max_count++;		if (!rev->reflog_info) {			/* we allow cycles in reflog ancestry */			free(commit->buffer);			commit->buffer = NULL;		}		free_commit_list(commit->parents);		commit->parents = NULL;		if (saved_nrl < rev->diffopt.needed_rename_limit)			saved_nrl = rev->diffopt.needed_rename_limit;		if (rev->diffopt.degraded_cc_to_c)			saved_dcctc = 1;	}	rev->diffopt.degraded_cc_to_c = saved_dcctc;	rev->diffopt.needed_rename_limit = saved_nrl;	if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&	    DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {		return 02;	}	return diff_result_code(&rev->diffopt, 0);}
开发者ID:DavidGould,项目名称:git,代码行数:49,


示例20: log_setup_revisions_tweak

static void log_setup_revisions_tweak(struct rev_info *rev,				      struct setup_revision_opt *opt){	if (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&	    rev->prune_data.nr == 1)		DIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);	/* Turn --cc/-c into -p --cc/-c when -p was not given */	if (!rev->diffopt.output_format && rev->combine_merges)		rev->diffopt.output_format = DIFF_FORMAT_PATCH;	/* Turn -m on when --cc/-c was given */	if (rev->combine_merges)		rev->ignore_merges = 0;}
开发者ID:BT-ojossen,项目名称:git,代码行数:15,


示例21: pickaxe_match

static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,			 regex_t *regexp, kwset_t kws, pickaxe_fn fn){	struct userdiff_driver *textconv_one = NULL;	struct userdiff_driver *textconv_two = NULL;	mmfile_t mf1, mf2;	int ret;	if (!o->pickaxe[0])		return 0;	/* ignore unmerged */	if (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))		return 0;	if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {		textconv_one = get_textconv(p->one);		textconv_two = get_textconv(p->two);	}	/*	 * If we have an unmodified pair, we know that the count will be the	 * same and don't even have to load the blobs. Unless textconv is in	 * play, _and_ we are using two different textconv filters (e.g.,	 * because a pair is an exact rename with different textconv attributes	 * for each side, which might generate different content).	 */	if (textconv_one == textconv_two && diff_unmodified_pair(p))		return 0;	mf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);	mf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);	ret = fn(DIFF_FILE_VALID(p->one) ? &mf1 : NULL,		 DIFF_FILE_VALID(p->two) ? &mf2 : NULL,		 o, regexp, kws);	if (textconv_one)		free(mf1.ptr);	if (textconv_two)		free(mf2.ptr);	diff_free_filespec_data(p->one);	diff_free_filespec_data(p->two);	return ret;}
开发者ID:4rch17,项目名称:git,代码行数:46,


示例22: diff_tree_oid

int diff_tree_oid(const struct object_id *old_oid,		  const struct object_id *new_oid,		  const char *base_str, struct diff_options *opt){	struct strbuf base;	int retval;	strbuf_init(&base, PATH_MAX);	strbuf_addstr(&base, base_str);	retval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);	if (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())		try_to_follow_renames(old_oid, new_oid, &base, opt);	strbuf_release(&base);	return retval;}
开发者ID:Litttle-butterfly,项目名称:git,代码行数:18,


示例23: get_stat_data

static int get_stat_data(struct cache_entry *ce,                         const unsigned char **sha1p,                         unsigned int *modep,                         int cached, int match_missing,                         unsigned *dirty_submodule, struct diff_options *diffopt){    const unsigned char *sha1 = ce->sha1;    unsigned int mode = ce->ce_mode;    if (!cached && !ce_uptodate(ce)) {        int changed;        struct stat st;        changed = check_removed(ce, &st);        if (changed < 0)            return -1;        else if (changed) {            if (match_missing) {                *sha1p = sha1;                *modep = mode;                return 0;            }            return -1;        }        changed = ce_match_stat(ce, &st, 0);        if (S_ISGITLINK(ce->ce_mode)                && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)                && (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH))                && is_submodule_modified(ce->name)) {            changed = 1;            *dirty_submodule = 1;        }        if (changed) {            mode = ce_mode_from_stat(ce, st.st_mode);            sha1 = null_sha1;        }    }    *sha1p = sha1;    *modep = mode;    return 0;}
开发者ID:bartman,项目名称:git,代码行数:41,


示例24: diffcore_pickaxe_grep

static void diffcore_pickaxe_grep(struct diff_options *o){	int err;	regex_t regex;	int cflags = REG_EXTENDED | REG_NEWLINE;	if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE))		cflags |= REG_ICASE;	err = regcomp(&regex, o->pickaxe, cflags);	if (err) {		char errbuf[1024];		regerror(err, &regex, errbuf, 1024);		regfree(&regex);		die("invalid log-grep regex: %s", errbuf);	}	pickaxe(&diff_queued_diff, o, &regex, NULL, diff_grep);	regfree(&regex);	return;}
开发者ID:4rch17,项目名称:git,代码行数:22,


示例25: show_blob_object

static int show_blob_object(const unsigned char *sha1, struct rev_info *rev, const char *obj_name){	unsigned char sha1c[20];	struct object_context obj_context;	char *buf;	unsigned long size;	fflush(stdout);	if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||	    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))		return stream_blob_to_fd(1, sha1, NULL, 0);	if (get_sha1_with_context(obj_name, 0, sha1c, &obj_context))		die(_("Not a valid object name %s"), obj_name);	if (!obj_context.path[0] ||	    !textconv_object(obj_context.path, obj_context.mode, sha1c, 1, &buf, &size))		return stream_blob_to_fd(1, sha1, NULL, 0);	if (!buf)		die(_("git show %s: bad file"), obj_name);	write_or_die(1, buf, size);	return 0;}
开发者ID:AbelTian,项目名称:git,代码行数:24,


示例26: cmd_log_init_finish

static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,			 struct rev_info *rev, struct setup_revision_opt *opt){	struct userformat_want w;	int quiet = 0, source = 0;	const struct option builtin_log_options[] = {		OPT_BOOLEAN(0, "quiet", &quiet, N_("suppress diff output")),		OPT_BOOLEAN(0, "source", &source, N_("show source")),		{ OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),		  PARSE_OPT_OPTARG, decorate_callback},		OPT_END()	};	argc = parse_options(argc, argv, prefix,			     builtin_log_options, builtin_log_usage,			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |			     PARSE_OPT_KEEP_DASHDASH);	argc = setup_revisions(argc, argv, rev, opt);	if (quiet)		rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;	/* Any arguments at this point are not recognized */	if (argc > 1)		die("unrecognized argument: %s", argv[1]);	memset(&w, 0, sizeof(w));	userformat_find_requirements(NULL, &w);	if (!rev->show_notes_given && (!rev->pretty_given || w.notes))		rev->show_notes = 1;	if (rev->show_notes)		init_display_notes(&rev->notes_opt);	if (rev->diffopt.pickaxe || rev->diffopt.filter)		rev->always_show_header = 0;	if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {		rev->always_show_header = 0;		if (rev->diffopt.pathspec.nr != 1)			usage("git logs can only follow renames on one pathname at a time");	}	if (source)		rev->show_source = 1;	if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {		/*		 * "log --pretty=raw" is special; ignore UI oriented		 * configuration variables such as decoration.		 */		if (!decoration_given)			decoration_style = 0;		if (!rev->abbrev_commit_given)			rev->abbrev_commit = 0;	}	if (decoration_style) {		rev->show_decorations = 1;		load_ref_decorations(decoration_style);	}	setup_pager();}
开发者ID:DavidGould,项目名称:git,代码行数:63,


示例27: cmd_format_patch

//.........这里部分代码省略.........	/*	 * If numbered is set solely due to format.numbered in config,	 * and it would conflict with --keep-subject (-k) from the	 * command line, reset "numbered".	 */	if (numbered && keep_subject && !numbered_cmdline_opt)		numbered = 0;	if (numbered && keep_subject)		die ("-n and -k are mutually exclusive.");	if (keep_subject && subject_prefix)		die ("--subject-prefix and -k are mutually exclusive.");	argc = setup_revisions(argc, argv, &rev, "HEAD");	if (argc > 1)		die ("unrecognized argument: %s", argv[1]);	if (rev.diffopt.output_format & DIFF_FORMAT_NAME)		die("--name-only does not make sense");	if (rev.diffopt.output_format & DIFF_FORMAT_NAME_STATUS)		die("--name-status does not make sense");	if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)		die("--check does not make sense");	if (!use_patch_format &&		(!rev.diffopt.output_format ||		 rev.diffopt.output_format == DIFF_FORMAT_PATCH))		rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY;	/* Always generate a patch */	rev.diffopt.output_format |= DIFF_FORMAT_PATCH;	if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)		DIFF_OPT_SET(&rev.diffopt, BINARY);	if (!use_stdout)		output_directory = set_outdir(prefix, output_directory);	if (output_directory) {		if (use_stdout)			die("standard output, or directory, which one?");		if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)			die_errno("Could not create directory '%s'",				  output_directory);	}	if (rev.pending.nr == 1) {		if (rev.max_count < 0 && !rev.show_root_diff) {			/*			 * This is traditional behaviour of "git format-patch			 * origin" that prepares what the origin side still			 * does not have.			 */			rev.pending.objects[0].item->flags |= UNINTERESTING;			add_head_to_pending(&rev);		}		/*		 * Otherwise, it is "format-patch -22 HEAD", and/or		 * "format-patch --root HEAD".  The user wants		 * get_revision() to do the usual traversal.		 */	}	/*	 * We cannot move this anywhere earlier because we do want to
开发者ID:samv,项目名称:git,代码行数:67,


示例28: cmd_log_init_finish

static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,			 struct rev_info *rev, struct setup_revision_opt *opt){	struct userformat_want w;	int quiet = 0, source = 0, mailmap = 0;	static struct line_opt_callback_data line_cb = {NULL, NULL, STRING_LIST_INIT_DUP};	const struct option builtin_log_options[] = {		OPT__QUIET(&quiet, N_("suppress diff output")),		OPT_BOOL(0, "source", &source, N_("show source")),		OPT_BOOL(0, "use-mailmap", &mailmap, N_("Use mail map file")),		{ OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),		  PARSE_OPT_OPTARG, decorate_callback},		OPT_CALLBACK('L', NULL, &line_cb, "n,m:file",			     N_("Process line range n,m in file, counting from 1"),			     log_line_range_callback),		OPT_END()	};	line_cb.rev = rev;	line_cb.prefix = prefix;	mailmap = use_mailmap_config;	argc = parse_options(argc, argv, prefix,			     builtin_log_options, builtin_log_usage,			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |			     PARSE_OPT_KEEP_DASHDASH);	if (quiet)		rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;	argc = setup_revisions(argc, argv, rev, opt);	/* Any arguments at this point are not recognized */	if (argc > 1)		die(_("unrecognized argument: %s"), argv[1]);	memset(&w, 0, sizeof(w));	userformat_find_requirements(NULL, &w);	if (!rev->show_notes_given && (!rev->pretty_given || w.notes))		rev->show_notes = 1;	if (rev->show_notes)		init_display_notes(&rev->notes_opt);	if (rev->diffopt.pickaxe || rev->diffopt.filter ||	    DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES))		rev->always_show_header = 0;	if (source)		rev->show_source = 1;	if (mailmap) {		rev->mailmap = xcalloc(1, sizeof(struct string_list));		read_mailmap(rev->mailmap, NULL);	}	if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {		/*		 * "log --pretty=raw" is special; ignore UI oriented		 * configuration variables such as decoration.		 */		if (!decoration_given)			decoration_style = 0;		if (!rev->abbrev_commit_given)			rev->abbrev_commit = 0;	}	if (decoration_style) {		rev->show_decorations = 1;		load_ref_decorations(decoration_style);	}	if (rev->line_level_traverse)		line_log_init(rev, line_cb.prefix, &line_cb.args);	setup_pager();}
开发者ID:AbelTian,项目名称:git,代码行数:77,


示例29: cmd_diff

int cmd_diff(int argc, const char **argv, const char *prefix){	int i;	struct rev_info rev;	struct object_array_entry ent[100];	int ents = 0, blobs = 0, paths = 0;	const char *path = NULL;	struct blobinfo blob[2];	int nongit;	int result = 0;	/*	 * We could get N tree-ish in the rev.pending_objects list.	 * Also there could be M blobs there, and P pathspecs.	 *	 * N=0, M=0:	 *	cache vs files (diff-files)	 * N=0, M=2:	 *      compare two random blobs.  P must be zero.	 * N=0, M=1, P=1:	 *	compare a blob with a working tree file.	 *	 * N=1, M=0:	 *      tree vs cache (diff-index --cached)	 *	 * N=2, M=0:	 *      tree vs tree (diff-tree)	 *	 * N=0, M=0, P=2:	 *      compare two filesystem entities (aka --no-index).	 *	 * Other cases are errors.	 */	prefix = setup_git_directory_gently(&nongit);	gitmodules_config();	git_config(git_diff_ui_config, NULL);	if (diff_use_color_default == -1)		diff_use_color_default = git_use_color_default;	init_revisions(&rev, prefix);	/* If this is a no-index diff, just run it and exit there. */	diff_no_index(&rev, argc, argv, nongit, prefix);	/* Otherwise, we are doing the usual "git" diff */	rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;	/* Default to let external and textconv be used */	DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);	DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);	if (nongit)		die("Not a git repository");	argc = setup_revisions(argc, argv, &rev, NULL);	if (!rev.diffopt.output_format) {		rev.diffopt.output_format = DIFF_FORMAT_PATCH;		if (diff_setup_done(&rev.diffopt) < 0)			die("diff_setup_done failed");	}	DIFF_OPT_SET(&rev.diffopt, RECURSIVE);	/*	 * If the user asked for our exit code then don't start a	 * pager or we would end up reporting its exit code instead.	 */	if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS) &&	    check_pager_config("diff") != 0)		setup_pager();	/*	 * Do we have --cached and not have a pending object, then	 * default to HEAD by hand.  Eek.	 */	if (!rev.pending.nr) {		int i;		for (i = 1; i < argc; i++) {			const char *arg = argv[i];			if (!strcmp(arg, "--"))				break;			else if (!strcmp(arg, "--cached") ||				 !strcmp(arg, "--staged")) {				add_head_to_pending(&rev);				if (!rev.pending.nr) {					struct tree *tree;					tree = lookup_tree((const unsigned char*)EMPTY_TREE_SHA1_BIN);					add_pending_object(&rev, &tree->object, "HEAD");				}				break;			}		}	}	for (i = 0; i < rev.pending.nr; i++) {		struct object_array_entry *list = rev.pending.objects+i;		struct object *obj = list->item;		const char *name = list->name;		int flags = (obj->flags & UNINTERESTING);//.........这里部分代码省略.........
开发者ID:tnachen,项目名称:git,代码行数:101,


示例30: cmd_rev_list

int cmd_rev_list(int argc, const char **argv, const char *prefix){	struct rev_info revs;	struct rev_list_info info;	int i;	int bisect_list = 0;	int bisect_show_vars = 0;	int bisect_find_all = 0;	int use_bitmap_index = 0;	const char *show_progress = NULL;	if (argc == 2 && !strcmp(argv[1], "-h"))		usage(rev_list_usage);	git_config(git_default_config, NULL);	init_revisions(&revs, prefix);	revs.abbrev = DEFAULT_ABBREV;	revs.commit_format = CMIT_FMT_UNSPECIFIED;	argc = setup_revisions(argc, argv, &revs, NULL);	memset(&info, 0, sizeof(info));	info.revs = &revs;	if (revs.bisect)		bisect_list = 1;	if (DIFF_OPT_TST(&revs.diffopt, QUICK))		info.flags |= REV_LIST_QUIET;	for (i = 1 ; i < argc; i++) {		const char *arg = argv[i];		if (!strcmp(arg, "--header")) {			revs.verbose_header = 1;			continue;		}		if (!strcmp(arg, "--timestamp")) {			info.show_timestamp = 1;			continue;		}		if (!strcmp(arg, "--bisect")) {			bisect_list = 1;			continue;		}		if (!strcmp(arg, "--bisect-all")) {			bisect_list = 1;			bisect_find_all = 1;			info.flags |= BISECT_SHOW_ALL;			revs.show_decorations = 1;			continue;		}		if (!strcmp(arg, "--bisect-vars")) {			bisect_list = 1;			bisect_show_vars = 1;			continue;		}		if (!strcmp(arg, "--use-bitmap-index")) {			use_bitmap_index = 1;			continue;		}		if (!strcmp(arg, "--test-bitmap")) {			test_bitmap_walk(&revs);			return 0;		}		if (skip_prefix(arg, "--progress=", &arg)) {			show_progress = arg;			continue;		}		usage(rev_list_usage);	}	if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {		/* The command line has a --pretty  */		info.hdr_termination = '/n';		if (revs.commit_format == CMIT_FMT_ONELINE)			info.header_prefix = "";		else			info.header_prefix = "commit ";	}	else if (revs.verbose_header)		/* Only --header was specified */		revs.commit_format = CMIT_FMT_RAW;	if ((!revs.commits && reflog_walk_empty(revs.reflog_info) &&	     (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&	      !revs.pending.nr) &&	     !revs.rev_input_given) ||	    revs.diff)		usage(rev_list_usage);	if (revs.show_notes)		die(_("rev-list does not support display of notes"));	save_commit_buffer = (revs.verbose_header ||			      revs.grep_filter.pattern_list ||			      revs.grep_filter.header_list);	if (bisect_list)		revs.limited = 1;	if (show_progress)		progress = start_delayed_progress(show_progress, 0);//.........这里部分代码省略.........
开发者ID:ardumont,项目名称:git,代码行数:101,



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


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