static void wt_status_print_verbose(struct wt_status *s) { struct rev_info rev; struct setup_revision_opt opt; init_revisions(&rev, NULL); DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV); memset(&opt, 0, sizeof(opt)); opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference; setup_revisions(0, NULL, &rev, &opt); rev.diffopt.output_format |= DIFF_FORMAT_PATCH; rev.diffopt.detect_rename = 1; rev.diffopt.file = s->fp; rev.diffopt.close_file = 0; /* * If we're not going to stdout, then we definitely don't * want color, since we are going to the commit message * file (and even the "auto" setting won't work, since it * will have checked isatty on stdout). */ if (s->fp != stdout) DIFF_OPT_CLR(&rev.diffopt, COLOR_DIFF); run_diff_index(&rev, 1); }
void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *arg) { DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES); DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES); DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES); if (!strcmp(arg, "all")) DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES); else if (!strcmp(arg, "untracked")) DIFF_OPT_SET(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES); else if (!strcmp(arg, "dirty")) DIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES); else if (strcmp(arg, "none")) die("bad --ignore-submodules argument: %s", arg); }
static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct commit *commit) { struct tree *t1 = parent->tree; struct tree *t2 = commit->tree; if (!t1) return REV_TREE_NEW; if (!t2) return REV_TREE_OLD; if (revs->simplify_by_decoration) { /* * If we are simplifying by decoration, then the commit * is worth showing if it has a tag pointing at it. */ if (lookup_decoration(&name_decoration, &commit->object)) return REV_TREE_DIFFERENT; /* * A commit that is not pointed by a tag is uninteresting * if we are not limited by path. This means that you will * see the usual "commits that touch the paths" plus any * tagged commit by specifying both --simplify-by-decoration * and pathspec. */ if (!revs->prune_data) return REV_TREE_SAME; } tree_difference = REV_TREE_SAME; DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES); if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "", &revs->pruning) < 0) return REV_TREE_DIFFERENT; return tree_difference; }
static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2) { if (!t1) return REV_TREE_NEW; if (!t2) return REV_TREE_DIFFERENT; tree_difference = REV_TREE_SAME; DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES); if (diff_tree_sha1(t1->object.sha1, t2->object.sha1, "", &revs->pruning) < 0) return REV_TREE_DIFFERENT; return tree_difference; }
static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1) { int retval; void *tree; unsigned long size; struct tree_desc empty, real; if (!t1) return 0; tree = read_object_with_reference(t1->object.sha1, tree_type, &size, NULL); if (!tree) return 0; init_tree_desc(&real, tree, size); init_tree_desc(&empty, "", 0); tree_difference = REV_TREE_SAME; DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES); retval = diff_tree(&empty, &real, "", &revs->pruning); free(tree); return retval >= 0 && (tree_difference == REV_TREE_SAME); }
void diff_tree_combined(const unsigned char *sha1, const unsigned char parent[][20], int num_parent, int dense, struct rev_info *rev) { struct diff_options *opt = &rev->diffopt; struct diff_options diffopts; struct combine_diff_path *p, *paths = NULL; int i, num_paths, needsep, show_log_first; diffopts = *opt; diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; DIFF_OPT_SET(&diffopts, RECURSIVE); DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL); show_log_first = !!rev->loginfo && !rev->no_commit_id; needsep = 0; /* find set of paths that everybody touches */ for (i = 0; i < num_parent; i++) { /* show stat against the first parent even * when doing combined diff. */ int stat_opt = (opt->output_format & (DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT)); if (i == 0 && stat_opt) diffopts.output_format = stat_opt; else diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; diff_tree_sha1(parent[i], sha1, "", &diffopts); diffcore_std(&diffopts); paths = intersect_paths(paths, i, num_parent); if (show_log_first && i == 0) { show_log(rev); if (rev->verbose_header && opt->output_format) putchar(opt->line_termination); } diff_flush(&diffopts); } /* find out surviving paths */ for (num_paths = 0, p = paths; p; p = p->next) { if (p->len) num_paths++; } if (num_paths) { if (opt->output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME | DIFF_FORMAT_NAME_STATUS)) { for (p = paths; p; p = p->next) { if (p->len) show_raw_diff(p, num_parent, rev); } needsep = 1; } else if (opt->output_format & (DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT)) needsep = 1; if (opt->output_format & DIFF_FORMAT_PATCH) { if (needsep) putchar(opt->line_termination); for (p = paths; p; p = p->next) { if (p->len) show_patch_diff(p, num_parent, dense, rev); } } } /* Clean things up */ while (paths) { struct combine_diff_path *tmp = paths; paths = paths->next; free(tmp); } }