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

Function emit_rewrite_diff

diff.c:1874–1958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1872}
1873
1874static void emit_rewrite_diff(const char *name_a,
1875 const char *name_b,
1876 struct diff_filespec *one,
1877 struct diff_filespec *two,
1878 struct userdiff_driver *textconv_one,
1879 struct userdiff_driver *textconv_two,
1880 struct diff_options *o)
1881{
1882 int lc_a, lc_b;
1883 static struct strbuf a_name = STRBUF_INIT, b_name = STRBUF_INIT;
1884 const char *a_prefix, *b_prefix;
1885 char *data_one, *data_two;
1886 size_t size_one, size_two;
1887 unsigned ws_rule;
1888 struct emit_callback ecbdata;
1889 struct strbuf out = STRBUF_INIT;
1890
1891 if (diff_mnemonic_prefix && o->flags.reverse_diff) {
1892 a_prefix = o->b_prefix;
1893 b_prefix = o->a_prefix;
1894 } else {
1895 a_prefix = o->a_prefix;
1896 b_prefix = o->b_prefix;
1897 }
1898
1899 name_a += (*name_a == '/');
1900 name_b += (*name_b == '/');
1901
1902 strbuf_reset(&a_name);
1903 strbuf_reset(&b_name);
1904 quote_two_c_style(&a_name, a_prefix, name_a, 0);
1905 quote_two_c_style(&b_name, b_prefix, name_b, 0);
1906
1907 size_one = fill_textconv(o->repo, textconv_one, one, &data_one);
1908 size_two = fill_textconv(o->repo, textconv_two, two, &data_two);
1909
1910 ws_rule = whitespace_rule(o->repo->index, name_b);
1911
1912 /* symlink being an incomplete line is not a news */
1913 if (DIFF_FILE_VALID(two) && S_ISLNK(two->mode))
1914 ws_rule &= ~WS_INCOMPLETE_LINE;
1915
1916 memset(&ecbdata, 0, sizeof(ecbdata));
1917 ecbdata.color_diff = o->use_color;
1918 ecbdata.ws_rule = ws_rule;
1919 ecbdata.opt = o;
1920 if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
1921 mmfile_t mf1, mf2;
1922 mf1.ptr = (char *)data_one;
1923 mf2.ptr = (char *)data_two;
1924 mf1.size = size_one;
1925 mf2.size = size_two;
1926 check_blank_at_eof(&mf1, &mf2, &ecbdata);
1927 }
1928 ecbdata.lno_in_preimage = 1;
1929 ecbdata.lno_in_postimage = 1;
1930
1931 lc_a = count_lines(data_one, size_one);

Callers 1

builtin_diffFunction · 0.85

Calls 10

quote_two_c_styleFunction · 0.85
fill_textconvFunction · 0.85
check_blank_at_eofFunction · 0.85
count_linesFunction · 0.85
emit_diff_symbolFunction · 0.85
strbuf_addstrFunction · 0.85
add_line_countFunction · 0.85
strbuf_releaseFunction · 0.85
emit_rewrite_linesFunction · 0.85
whitespace_ruleFunction · 0.70

Tested by

no test coverage detected