| 5022 | } |
| 5023 | |
| 5024 | static 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 | |
| 5078 | static void run_diffstat(struct diff_filepair *p, struct diff_options *o, |
| 5079 | struct diffstat_t *diffstat) |
no test coverage detected