本文整理汇总了C++中diff_setup_done函数的典型用法代码示例。如果您正苦于以下问题:C++ diff_setup_done函数的具体用法?C++ diff_setup_done怎么用?C++ diff_setup_done使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了diff_setup_done函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cgit_diff_tree
void cgit_diff_tree(const unsigned char *old_sha1,
const unsigned char *new_sha1,
filepair_fn fn, const char *prefix, int ignorews)
{
struct diff_options opt;
struct pathspec_item item;
diff_setup(&opt);
opt.output_format = DIFF_FORMAT_CALLBACK;
opt.detect_rename = 1;
opt.rename_limit = ctx.cfg.renamelimit;
DIFF_OPT_SET(&opt, RECURSIVE);
if (ignorews)
DIFF_XDL_SET(&opt, IGNORE_WHITESPACE);
opt.format_callback = cgit_diff_tree_cb;
opt.format_callback_data = fn;
if (prefix) {
item.match = prefix;
item.len = strlen(prefix);
opt.pathspec.nr = 1;
opt.pathspec.items = &item;
}
diff_setup_done(&opt);
if (old_sha1 && !is_null_sha1(old_sha1))
diff_tree_sha1(old_sha1, new_sha1, "", &opt);
else
diff_root_tree_sha1(new_sha1, "", &opt);
diffcore_std(&opt);
diff_flush(&opt);
}
示例2: check_for_new_submodule_commits
void check_for_new_submodule_commits(unsigned char new_sha1[20])
{
struct rev_info rev;
struct commit *commit;
const char *argv[] = {NULL, NULL, "--not", "--all", NULL};
int argc = ARRAY_SIZE(argv) - 1;
init_revisions(&rev, NULL);
argv[1] = xstrdup(sha1_to_hex(new_sha1));
setup_revisions(argc, argv, &rev, NULL);
if (prepare_revision_walk(&rev))
die("revision walk setup failed");
/*
* Collect all submodules (whether checked out or not) for which new
* commits have been recorded upstream in "changed_submodule_paths".
*/
while ((commit = get_revision(&rev))) {
struct commit_list *parent = commit->parents;
while (parent) {
struct diff_options diff_opts;
diff_setup(&diff_opts);
diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
diff_opts.format_callback = submodule_collect_changed_cb;
if (diff_setup_done(&diff_opts) < 0)
die("diff_setup_done failed");
diff_tree_sha1(parent->item->object.sha1, commit->object.sha1, "", &diff_opts);
diffcore_std(&diff_opts);
diff_flush(&diff_opts);
parent = parent->next;
}
}
free((char *)argv[1]);
}
示例3: check_changes_tracked_files
static int check_changes_tracked_files(struct pathspec ps)
{
int result;
struct rev_info rev;
struct object_id dummy;
/* No initial commit. */
if (get_oid("HEAD", &dummy))
return -1;
if (read_cache() < 0)
return -1;
init_revisions(&rev, NULL);
rev.prune_data = ps;
rev.diffopt.flags.quick = 1;
rev.diffopt.flags.ignore_submodules = 1;
rev.abbrev = 0;
add_head_to_pending(&rev);
diff_setup_done(&rev.diffopt);
result = run_diff_index(&rev, 1);
if (diff_result_code(&rev.diffopt, result))
return 1;
object_array_clear(&rev.pending);
result = run_diff_files(&rev, 0);
if (diff_result_code(&rev.diffopt, result))
return 1;
return 0;
}
示例4: cgit_diff_tree
void cgit_diff_tree(const unsigned char *old_sha1,
const unsigned char *new_sha1,
filepair_fn fn, const char *prefix)
{
struct diff_options opt;
int ret;
int prefixlen;
diff_setup(&opt);
opt.output_format = DIFF_FORMAT_CALLBACK;
opt.detect_rename = 1;
opt.rename_limit = ctx.cfg.renamelimit;
DIFF_OPT_SET(&opt, RECURSIVE);
opt.format_callback = cgit_diff_tree_cb;
opt.format_callback_data = fn;
if (prefix) {
opt.nr_paths = 1;
opt.paths = &prefix;
prefixlen = strlen(prefix);
opt.pathlens = &prefixlen;
}
diff_setup_done(&opt);
if (old_sha1 && !is_null_sha1(old_sha1))
ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt);
else
ret = diff_root_tree_sha1(new_sha1, "", &opt);
diffcore_std(&opt);
diff_flush(&opt);
}
示例5: diff_no_index
void diff_no_index(struct rev_info *revs,
int argc, const char **argv,
const char *prefix)
{
int i, prefixlen;
const char *paths[2];
diff_setup(&revs->diffopt);
for (i = 1; i < argc - 2; ) {
int j;
if (!strcmp(argv[i], "--no-index"))
i++;
else if (!strcmp(argv[i], "--"))
i++;
else {
j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
if (j <= 0)
die("invalid diff option/value: %s", argv[i]);
i += j;
}
}
prefixlen = prefix ? strlen(prefix) : 0;
for (i = 0; i < 2; i++) {
const char *p = argv[argc - 2 + i];
if (!strcmp(p, "-"))
/*
* stdin should be spelled as "-"; if you have
* path that is "-", spell it as "./-".
*/
p = file_from_standard_input;
else if (prefixlen)
p = xstrdup(prefix_filename(prefix, prefixlen, p));
paths[i] = p;
}
revs->diffopt.skip_stat_unmatch = 1;
if (!revs->diffopt.output_format)
revs->diffopt.output_format = DIFF_FORMAT_PATCH;
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
revs->max_count = -2;
diff_setup_done(&revs->diffopt);
setup_diff_pager(&revs->diffopt);
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
if (queue_diff(&revs->diffopt, paths[0], paths[1]))
exit(1);
diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
/*
* The return code for --no-index imitates diff(1):
* 0 = no changes, 1 = changes, else error
*/
exit(diff_result_code(&revs->diffopt, 0));
}
示例6: xcalloc
/*
* Get information of all renames which occurred between 'o_tree' and
* 'tree'. We need the three trees in the merge ('o_tree', 'a_tree' and
* 'b_tree') to be able to associate the correct cache entries with
* the rename information. 'tree' is always equal to either a_tree or b_tree.
*/
static struct string_list *get_renames(struct merge_options *o,
struct tree *tree,
struct tree *o_tree,
struct tree *a_tree,
struct tree *b_tree,
struct string_list *entries)
{
int i;
struct string_list *renames;
struct diff_options opts;
renames = xcalloc(1, sizeof(struct string_list));
diff_setup(&opts);
DIFF_OPT_SET(&opts, RECURSIVE);
opts.detect_rename = DIFF_DETECT_RENAME;
opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
500;
opts.warn_on_too_large_rename = 1;
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
if (diff_setup_done(&opts) < 0)
die("diff setup failed");
diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
diffcore_std(&opts);
for (i = 0; i < diff_queued_diff.nr; ++i) {
struct string_list_item *item;
struct rename *re;
struct diff_filepair *pair = diff_queued_diff.queue[i];
if (pair->status != 'R') {
diff_free_filepair(pair);
continue;
}
re = xmalloc(sizeof(*re));
re->processed = 0;
re->pair = pair;
item = string_list_lookup(re->pair->one->path, entries);
if (!item)
re->src_entry = insert_stage_data(re->pair->one->path,
o_tree, a_tree, b_tree, entries);
else
re->src_entry = item->util;
item = string_list_lookup(re->pair->two->path, entries);
if (!item)
re->dst_entry = insert_stage_data(re->pair->two->path,
o_tree, a_tree, b_tree, entries);
else
re->dst_entry = item->util;
item = string_list_insert(pair->one->path, renames);
item->util = re;
}
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
diff_queued_diff.nr = 0;
diff_flush(&opts);
return renames;
}
示例7: init_patch_ids
int init_patch_ids(struct patch_ids *ids)
{
memset(ids, 0, sizeof(*ids));
diff_setup(&ids->diffopts);
ids->diffopts.detect_rename = 0;
DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
diff_setup_done(&ids->diffopts);
hashmap_init(&ids->patches, (hashmap_cmp_fn)patch_id_cmp, 256);
return 0;
}
示例8: init_patch_ids
int init_patch_ids(struct patch_ids *ids)
{
memset(ids, 0, sizeof(*ids));
diff_setup(&ids->diffopts);
ids->diffopts.detect_rename = 0;
ids->diffopts.flags.recursive = 1;
diff_setup_done(&ids->diffopts);
hashmap_init(&ids->patches, patch_id_neq, &ids->diffopts, 256);
return 0;
}
示例9: has_unstaged_changes
/**
* Returns 1 if there are unstaged changes, 0 otherwise.
*/
static int has_unstaged_changes(const char *prefix)
{
struct rev_info rev_info;
int result;
init_revisions(&rev_info, prefix);
DIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES);
DIFF_OPT_SET(&rev_info.diffopt, QUICK);
diff_setup_done(&rev_info.diffopt);
result = run_diff_files(&rev_info, 0);
return diff_result_code(&rev_info.diffopt, result);
}
示例10: show_local_changes
static void show_local_changes(struct object *head,
const struct diff_options *opts)
{
struct rev_info rev;
/* I think we want full paths, even if we're in a subdirectory. */
repo_init_revisions(the_repository, &rev, NULL);
rev.diffopt.flags = opts->flags;
rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
diff_setup_done(&rev.diffopt);
add_pending_object(&rev, head, NULL);
run_diff_index(&rev, 0);
}
示例11: finish
static void finish(struct commit *head_commit,
struct commit_list *remoteheads,
const unsigned char *new_head, const char *msg)
{
struct strbuf reflog_message = STRBUF_INIT;
const unsigned char *head = head_commit->object.oid.hash;
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
if (verbosity >= 0)
printf("%s\n", msg);
strbuf_addf(&reflog_message, "%s: %s",
getenv("GIT_REFLOG_ACTION"), msg);
}
if (squash) {
squash_message(head_commit, remoteheads);
} else {
if (verbosity >= 0 && !merge_msg.len)
printf(_("No merge message -- not updating HEAD\n"));
else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
update_ref(reflog_message.buf, "HEAD",
new_head, head, 0,
UPDATE_REFS_DIE_ON_ERR);
/*
* We ignore errors in 'gc --auto', since the
* user should see them.
*/
close_all_packs();
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
}
}
if (new_head && show_diffstat) {
struct diff_options opts;
diff_setup(&opts);
opts.stat_width = -1; /* use full terminal width */
opts.stat_graph_width = -1; /* respect statGraphWidth config */
opts.output_format |=
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
diff_setup_done(&opts);
diff_tree_sha1(head, new_head, "", &opts);
diffcore_std(&opts);
diff_flush(&opts);
}
/* Run a post-merge hook */
run_hook_le(NULL, "post-merge", squash ? "1" : "0", NULL);
strbuf_release(&reflog_message);
}
示例12: finish
static void finish(const unsigned char *new_head, const char *msg)
{
struct strbuf reflog_message = STRBUF_INIT;
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
if (verbosity >= 0)
printf("%s\n", msg);
strbuf_addf(&reflog_message, "%s: %s",
getenv("GIT_REFLOG_ACTION"), msg);
}
if (squash) {
squash_message();
} else {
if (verbosity >= 0 && !merge_msg.len)
printf(_("No merge message -- not updating HEAD\n"));
else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
update_ref(reflog_message.buf, "HEAD",
new_head, head, 0,
DIE_ON_ERR);
/*
* We ignore errors in 'gc --auto', since the
* user should see them.
*/
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
}
}
if (new_head && show_diffstat) {
struct diff_options opts;
diff_setup(&opts);
opts.output_format |=
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
if (diff_use_color_default > 0)
DIFF_OPT_SET(&opts, COLOR_DIFF);
if (diff_setup_done(&opts) < 0)
die(_("diff_setup_done failed"));
diff_tree_sha1(head, new_head, "", &opts);
diffcore_std(&opts);
diff_flush(&opts);
}
/* Run a post-merge hook */
run_hook(NULL, "post-merge", squash ? "1" : "0", NULL);
strbuf_release(&reflog_message);
}
示例13: prepare_bases
static void prepare_bases(struct base_tree_info *bases,
struct commit *base,
struct commit **list,
int total)
{
struct commit *commit;
struct rev_info revs;
struct diff_options diffopt;
int i;
if (!base)
return;
diff_setup(&diffopt);
DIFF_OPT_SET(&diffopt, RECURSIVE);
diff_setup_done(&diffopt);
oidcpy(&bases->base_commit, &base->object.oid);
init_revisions(&revs, NULL);
revs.max_parents = 1;
revs.topo_order = 1;
for (i = 0; i < total; i++) {
list[i]->object.flags &= ~UNINTERESTING;
add_pending_object(&revs, &list[i]->object, "rev_list");
list[i]->util = (void *)1;
}
base->object.flags |= UNINTERESTING;
add_pending_object(&revs, &base->object, "base");
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
/*
* Traverse the commits list, get prerequisite patch ids
* and stuff them in bases structure.
*/
while ((commit = get_revision(&revs)) != NULL) {
unsigned char sha1[20];
struct object_id *patch_id;
if (commit->util)
continue;
if (commit_patch_id(commit, &diffopt, sha1))
die(_("cannot get patch id"));
ALLOC_GROW(bases->patch_id, bases->nr_patch_id + 1, bases->alloc_patch_id);
patch_id = bases->patch_id + bases->nr_patch_id;
hashcpy(patch_id->hash, sha1);
bases->nr_patch_id++;
}
}
示例14: main
int main(int ac, const char **av)
{
int stage1, stage2;
setup_git_directory();
git_config(git_diff_config);
read_cache();
diff_setup(&diff_options);
while (1 < ac && av[1][0] == '-') {
const char *arg = av[1];
if (!strcmp(arg, "-r"))
; /* as usual */
else {
int diff_opt_cnt;
diff_opt_cnt = diff_opt_parse(&diff_options,
av+1, ac-1);
if (diff_opt_cnt < 0)
usage(diff_stages_usage);
else if (diff_opt_cnt) {
av += diff_opt_cnt;
ac -= diff_opt_cnt;
continue;
}
else
usage(diff_stages_usage);
}
ac--; av++;
}
if (ac < 3 ||
sscanf(av[1], "%d", &stage1) != 1 ||
! (0 <= stage1 && stage1 <= 3) ||
sscanf(av[2], "%d", &stage2) != 1 ||
! (0 <= stage2 && stage2 <= 3))
usage(diff_stages_usage);
av += 3; /* The rest from av[0] are for paths restriction. */
diff_options.paths = av;
if (diff_setup_done(&diff_options) < 0)
usage(diff_stages_usage);
diff_stages(stage1, stage2);
diffcore_std(&diff_options);
diff_flush(&diff_options);
return 0;
}
示例15: has_uncommitted_changes
/**
* Returns 1 if there are uncommitted changes, 0 otherwise.
*/
static int has_uncommitted_changes(const char *prefix)
{
struct rev_info rev_info;
int result;
if (is_cache_unborn())
return 0;
init_revisions(&rev_info, prefix);
DIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES);
DIFF_OPT_SET(&rev_info.diffopt, QUICK);
add_head_to_pending(&rev_info);
diff_setup_done(&rev_info.diffopt);
result = run_diff_index(&rev_info, 1);
return diff_result_code(&rev_info.diffopt, result);
}