MCPcopy Index your code
hub / github.com/git/git / run_diff

Function run_diff

diff.c:5024–5076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5022}
5023
5024static void run_diff(struct diff_filepair *p, struct diff_options *o)
5025{
5026 const struct external_diff *pgm = external_diff();
5027 struct strbuf msg;
5028 struct diff_filespec *one = p->one;
5029 struct diff_filespec *two = p->two;
5030 const char *name;
5031 const char *other;
5032 const char *attr_path;
5033
5034 name = one->path;
5035 other = (strcmp(name, two->path) ? two->path : NULL);
5036 attr_path = name;
5037 if (o->prefix_length)
5038 strip_prefix(o->prefix_length, &name, &other);
5039
5040 if (!o->flags.allow_external)
5041 pgm = NULL;
5042
5043 if (DIFF_PAIR_UNMERGED(p)) {
5044 run_diff_cmd(pgm, name, NULL, attr_path,
5045 NULL, NULL, NULL, o, p);
5046 return;
5047 }
5048
5049 diff_fill_oid_info(one, o->repo->index);
5050 diff_fill_oid_info(two, o->repo->index);
5051
5052 if (!pgm &&
5053 DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&
5054 (S_IFMT & one->mode) != (S_IFMT & two->mode)) {
5055 /*
5056 * a filepair that changes between file and symlink
5057 * needs to be split into deletion and creation.
5058 */
5059 struct diff_filespec *null = alloc_filespec(two->path);
5060 run_diff_cmd(NULL, name, other, attr_path,
5061 one, null, &msg,
5062 o, p);
5063 free(null);
5064 strbuf_release(&msg);
5065
5066 null = alloc_filespec(one->path);
5067 run_diff_cmd(NULL, name, other, attr_path,
5068 null, two, &msg, o, p);
5069 free(null);
5070 }
5071 else
5072 run_diff_cmd(pgm, name, other, attr_path,
5073 one, two, &msg, o, p);
5074
5075 strbuf_release(&msg);
5076}
5077
5078static void run_diffstat(struct diff_filepair *p, struct diff_options *o,
5079 struct diffstat_t *diffstat)

Callers 1

diff_flush_patchFunction · 0.70

Calls 6

strip_prefixFunction · 0.85
run_diff_cmdFunction · 0.85
diff_fill_oid_infoFunction · 0.85
alloc_filespecFunction · 0.85
strbuf_releaseFunction · 0.85
external_diffFunction · 0.70

Tested by

no test coverage detected