| 3838 | } |
| 3839 | |
| 3840 | static void builtin_diff(const char *name_a, |
| 3841 | const char *name_b, |
| 3842 | struct diff_filespec *one, |
| 3843 | struct diff_filespec *two, |
| 3844 | const char *xfrm_msg, |
| 3845 | int must_show_header, |
| 3846 | struct diff_options *o, |
| 3847 | int complete_rewrite, |
| 3848 | const struct range_set *line_ranges) |
| 3849 | { |
| 3850 | mmfile_t mf1, mf2; |
| 3851 | const char *lbl[2]; |
| 3852 | char *a_one, *b_two; |
| 3853 | const char *meta = diff_get_color_opt(o, DIFF_METAINFO); |
| 3854 | const char *reset = diff_get_color_opt(o, DIFF_RESET); |
| 3855 | const char *a_prefix, *b_prefix; |
| 3856 | struct userdiff_driver *textconv_one = NULL; |
| 3857 | struct userdiff_driver *textconv_two = NULL; |
| 3858 | struct strbuf header = STRBUF_INIT; |
| 3859 | const char *line_prefix = diff_line_prefix(o); |
| 3860 | |
| 3861 | diff_set_mnemonic_prefix(o, "a/", "b/"); |
| 3862 | if (o->flags.reverse_diff) { |
| 3863 | a_prefix = o->b_prefix; |
| 3864 | b_prefix = o->a_prefix; |
| 3865 | } else { |
| 3866 | a_prefix = o->a_prefix; |
| 3867 | b_prefix = o->b_prefix; |
| 3868 | } |
| 3869 | |
| 3870 | if (o->submodule_format == DIFF_SUBMODULE_LOG && |
| 3871 | (!one->mode || S_ISGITLINK(one->mode)) && |
| 3872 | (!two->mode || S_ISGITLINK(two->mode)) && |
| 3873 | (!diff_filepair_is_phoney(one, two))) { |
| 3874 | show_submodule_diff_summary(o, one->path ? one->path : two->path, |
| 3875 | &one->oid, &two->oid, |
| 3876 | two->dirty_submodule); |
| 3877 | o->found_changes = 1; |
| 3878 | return; |
| 3879 | } else if (o->submodule_format == DIFF_SUBMODULE_INLINE_DIFF && |
| 3880 | (!one->mode || S_ISGITLINK(one->mode)) && |
| 3881 | (!two->mode || S_ISGITLINK(two->mode)) && |
| 3882 | (!diff_filepair_is_phoney(one, two))) { |
| 3883 | show_submodule_inline_diff(o, one->path ? one->path : two->path, |
| 3884 | &one->oid, &two->oid, |
| 3885 | two->dirty_submodule); |
| 3886 | o->found_changes = 1; |
| 3887 | return; |
| 3888 | } |
| 3889 | |
| 3890 | if (o->flags.allow_textconv) { |
| 3891 | textconv_one = get_textconv(o->repo, one); |
| 3892 | textconv_two = get_textconv(o->repo, two); |
| 3893 | } |
| 3894 | |
| 3895 | /* Never use a non-valid filename anywhere if at all possible */ |
| 3896 | name_a = DIFF_FILE_VALID(one) ? name_a : name_b; |
| 3897 | name_b = DIFF_FILE_VALID(two) ? name_b : name_a; |
no test coverage detected