Merge pull request #3177 from ethomson/binary_diff Binary diffs: store deltas in the diff structure, include binary data in diff callbacks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1fff2d4..a8e3e18 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -65,6 +65,10 @@ support for HTTPS connections insead of OpenSSL.
configuration. This allows modifying URL prefixes to a custom
value via gitconfig.
+* `git_diff_foreach`, `git_diff_blobs`, `git_diff_blob_to_buffer`,
+ and `git_diff_buffers` now accept a new binary callback of type
+ `git_diff_binary_cb` that includes the binary diff information.
+
### API additions
* The `git_merge_options` gained a `file_flags` member.
diff --git a/include/git2/diff.h b/include/git2/diff.h
index c0d42e3..0ecdc1b 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -426,6 +426,53 @@ typedef int (*git_diff_file_cb)(
void *payload);
/**
+ * When producing a binary diff, the binary data returned will be
+ * either the deflated full ("literal") contents of the file, or
+ * the deflated binary delta between the two sides (whichever is
+ * smaller).
+ */
+typedef enum {
+ /** There is no binary delta. */
+ GIT_DIFF_BINARY_NONE,
+
+ /** The binary data is the literal contents of the file. */
+ GIT_DIFF_BINARY_LITERAL,
+
+ /** The binary data is the delta from one side to the other. */
+ GIT_DIFF_BINARY_DELTA,
+} git_diff_binary_t;
+
+/** The contents of one of the files in a binary diff. */
+typedef struct {
+ /** The type of binary data for this file. */
+ git_diff_binary_t type;
+
+ /** The binary data, deflated. */
+ const char *data;
+
+ /** The length of the binary data. */
+ size_t datalen;
+
+ /** The length of the binary data after inflation. */
+ size_t inflatedlen;
+} git_diff_binary_file;
+
+/** Structure describing the binary contents of a diff. */
+typedef struct {
+ git_diff_binary_file old_file; /**< The contents of the old file. */
+ git_diff_binary_file new_file; /**< The contents of the new file. */
+} git_diff_binary;
+
+/**
+* When iterating over a diff, callback that will be made for
+* binary content within the diff.
+*/
+typedef int(*git_diff_binary_cb)(
+ const git_diff_delta *delta,
+ const git_diff_binary *binary,
+ void *payload);
+
+/**
* Structure describing a hunk of a diff.
*/
typedef struct {
@@ -897,6 +944,7 @@ GIT_EXTERN(int) git_diff_is_sorted_icase(const git_diff *diff);
*
* @param diff A git_diff generated by one of the above functions.
* @param file_cb Callback function to make per file in the diff.
+ * @param binary_cb Optional callback to make for binary files.
* @param hunk_cb Optional callback to make per hunk of text diff. This
* callback is called to describe a range of lines in the
* diff. It will not be issued for binary files.
@@ -909,6 +957,7 @@ GIT_EXTERN(int) git_diff_is_sorted_icase(const git_diff *diff);
GIT_EXTERN(int) git_diff_foreach(
git_diff *diff,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *payload);
@@ -984,6 +1033,7 @@ GIT_EXTERN(int) git_diff_print(
* @param new_as_path Treat new blob as if it had this filename; can be NULL
* @param options Options for diff, or NULL for default options
* @param file_cb Callback for "file"; made once if there is a diff; can be NULL
+ * @param binary_cb Callback for binary files; can be NULL
* @param hunk_cb Callback for each hunk in diff; can be NULL
* @param line_cb Callback for each line in diff; can be NULL
* @param payload Payload passed to each callback function
@@ -996,6 +1046,7 @@ GIT_EXTERN(int) git_diff_blobs(
const char *new_as_path,
const git_diff_options *options,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *payload);
@@ -1019,6 +1070,7 @@ GIT_EXTERN(int) git_diff_blobs(
* @param buffer_as_path Treat buffer as if it had this filename; can be NULL
* @param options Options for diff, or NULL for default options
* @param file_cb Callback for "file"; made once if there is a diff; can be NULL
+ * @param binary_cb Callback for binary files; can be NULL
* @param hunk_cb Callback for each hunk in diff; can be NULL
* @param line_cb Callback for each line in diff; can be NULL
* @param payload Payload passed to each callback function
@@ -1032,6 +1084,7 @@ GIT_EXTERN(int) git_diff_blob_to_buffer(
const char *buffer_as_path,
const git_diff_options *options,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *payload);
@@ -1051,6 +1104,7 @@ GIT_EXTERN(int) git_diff_blob_to_buffer(
* @param new_as_path Treat buffer as if it had this filename; can be NULL
* @param options Options for diff, or NULL for default options
* @param file_cb Callback for "file"; made once if there is a diff; can be NULL
+ * @param binary_cb Callback for binary files; can be NULL
* @param hunk_cb Callback for each hunk in diff; can be NULL
* @param line_cb Callback for each line in diff; can be NULL
* @param payload Payload passed to each callback function
@@ -1065,6 +1119,7 @@ GIT_EXTERN(int) git_diff_buffers(
const char *new_as_path,
const git_diff_options *options,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *payload);
diff --git a/src/blame.c b/src/blame.c
index 4a12cb8..a52f940 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -496,8 +496,8 @@ int git_blame_buffer(
/* Diff to the reference blob */
git_diff_blob_to_buffer(reference->final_blob, blame->path,
- buffer, buffer_len, blame->path,
- &diffopts, NULL, buffer_hunk_cb, buffer_line_cb, blame);
+ buffer, buffer_len, blame->path, &diffopts,
+ NULL, NULL, buffer_hunk_cb, buffer_line_cb, blame);
*out = blame;
return 0;
diff --git a/src/diff_file.c b/src/diff_file.c
index f7061ae..cef4bc1 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -89,10 +89,9 @@ static int diff_file_content_init_common(
int git_diff_file_content__init_from_diff(
git_diff_file_content *fc,
git_diff *diff,
- size_t delta_index,
+ git_diff_delta *delta,
bool use_old)
{
- git_diff_delta *delta = git_vector_get(&diff->deltas, delta_index);
bool has_data = true;
memset(fc, 0, sizeof(*fc));
@@ -218,7 +217,9 @@ static int diff_file_content_commit_to_str(
return 0;
}
-static int diff_file_content_load_blob(git_diff_file_content *fc)
+static int diff_file_content_load_blob(
+ git_diff_file_content *fc,
+ git_diff_options *opts)
{
int error = 0;
git_odb_object *odb_obj = NULL;
@@ -236,7 +237,8 @@ static int diff_file_content_load_blob(git_diff_file_content *fc)
return error;
}
- if (diff_file_content_binary_by_size(fc))
+ if ((opts->flags & GIT_DIFF_SHOW_BINARY) == 0 &&
+ diff_file_content_binary_by_size(fc))
return 0;
if (odb_obj != NULL) {
@@ -283,7 +285,9 @@ static int diff_file_content_load_workdir_symlink(
}
static int diff_file_content_load_workdir_file(
- git_diff_file_content *fc, git_buf *path)
+ git_diff_file_content *fc,
+ git_buf *path,
+ git_diff_options *diff_opts)
{
int error = 0;
git_filter_list *fl = NULL;
@@ -297,7 +301,8 @@ static int diff_file_content_load_workdir_file(
!(fc->file->size = git_futils_filesize(fd)))
goto cleanup;
- if (diff_file_content_binary_by_size(fc))
+ if ((diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0 &&
+ diff_file_content_binary_by_size(fc))
goto cleanup;
if ((error = git_filter_list_load(
@@ -339,7 +344,9 @@ cleanup:
return error;
}
-static int diff_file_content_load_workdir(git_diff_file_content *fc)
+static int diff_file_content_load_workdir(
+ git_diff_file_content *fc,
+ git_diff_options *diff_opts)
{
int error = 0;
git_buf path = GIT_BUF_INIT;
@@ -357,7 +364,7 @@ static int diff_file_content_load_workdir(git_diff_file_content *fc)
if (S_ISLNK(fc->file->mode))
error = diff_file_content_load_workdir_symlink(fc, &path);
else
- error = diff_file_content_load_workdir_file(fc, &path);
+ error = diff_file_content_load_workdir_file(fc, &path, diff_opts);
/* once data is loaded, update OID if we didn't have it previously */
if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) {
@@ -370,20 +377,23 @@ static int diff_file_content_load_workdir(git_diff_file_content *fc)
return error;
}
-int git_diff_file_content__load(git_diff_file_content *fc)
+int git_diff_file_content__load(
+ git_diff_file_content *fc,
+ git_diff_options *diff_opts)
{
int error = 0;
if ((fc->flags & GIT_DIFF_FLAG__LOADED) != 0)
return 0;
- if ((fc->file->flags & GIT_DIFF_FLAG_BINARY) != 0)
+ if ((fc->file->flags & GIT_DIFF_FLAG_BINARY) != 0 &&
+ (diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0)
return 0;
if (fc->src == GIT_ITERATOR_TYPE_WORKDIR)
- error = diff_file_content_load_workdir(fc);
+ error = diff_file_content_load_workdir(fc, diff_opts);
else
- error = diff_file_content_load_blob(fc);
+ error = diff_file_content_load_blob(fc, diff_opts);
if (error)
return error;
diff --git a/src/diff_file.h b/src/diff_file.h
index 4d290ad..0d54b6d 100644
--- a/src/diff_file.h
+++ b/src/diff_file.h
@@ -28,7 +28,7 @@ typedef struct {
extern int git_diff_file_content__init_from_diff(
git_diff_file_content *fc,
git_diff *diff,
- size_t delta_index,
+ git_diff_delta *delta,
bool use_old);
typedef struct {
@@ -49,7 +49,9 @@ extern int git_diff_file_content__init_from_src(
git_diff_file *as_file);
/* this loads the blob/file-on-disk as needed */
-extern int git_diff_file_content__load(git_diff_file_content *fc);
+extern int git_diff_file_content__load(
+ git_diff_file_content *fc,
+ git_diff_options *diff_opts);
/* this releases the blob/file-in-memory */
extern void git_diff_file_content__unload(git_diff_file_content *fc);
diff --git a/src/diff_patch.c b/src/diff_patch.c
index 1c4c0e8..63253c2 100644
--- a/src/diff_patch.c
+++ b/src/diff_patch.c
@@ -11,41 +11,13 @@
#include "diff_driver.h"
#include "diff_patch.h"
#include "diff_xdiff.h"
+#include "delta.h"
+#include "zstream.h"
#include "fileops.h"
-/* cached information about a hunk in a diff */
-typedef struct diff_patch_hunk {
- git_diff_hunk hunk;
- size_t line_start;
- size_t line_count;
-} diff_patch_hunk;
-
-struct git_patch {
- git_refcount rc;
- git_diff *diff; /* for refcount purposes, maybe NULL for blob diffs */
- git_diff_delta *delta;
- size_t delta_index;
- git_diff_file_content ofile;
- git_diff_file_content nfile;
- uint32_t flags;
- git_array_t(diff_patch_hunk) hunks;
- git_array_t(git_diff_line) lines;
- size_t content_size, context_size, header_size;
- git_pool flattened;
-};
-
-enum {
- GIT_DIFF_PATCH_ALLOCATED = (1 << 0),
- GIT_DIFF_PATCH_INITIALIZED = (1 << 1),
- GIT_DIFF_PATCH_LOADED = (1 << 2),
- GIT_DIFF_PATCH_DIFFABLE = (1 << 3),
- GIT_DIFF_PATCH_DIFFED = (1 << 4),
- GIT_DIFF_PATCH_FLATTENED = (1 << 5),
-};
-
static void diff_output_init(
- git_diff_output*, const git_diff_options*,
- git_diff_file_cb, git_diff_hunk_cb, git_diff_line_cb, void*);
+ git_diff_output*, const git_diff_options*, git_diff_file_cb,
+ git_diff_binary_cb, git_diff_hunk_cb, git_diff_line_cb, void*);
static void diff_output_to_patch(git_diff_output *, git_patch *);
@@ -67,15 +39,38 @@ static void diff_patch_init_common(git_patch *patch)
{
diff_patch_update_binary(patch);
- if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0)
- patch->flags |= GIT_DIFF_PATCH_LOADED; /* LOADED but not DIFFABLE */
-
patch->flags |= GIT_DIFF_PATCH_INITIALIZED;
if (patch->diff)
git_diff_addref(patch->diff);
}
+static int diff_patch_normalize_options(
+ git_diff_options *out,
+ const git_diff_options *opts)
+{
+ if (opts) {
+ GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options");
+ memcpy(out, opts, sizeof(git_diff_options));
+ } else {
+ git_diff_options default_opts = GIT_DIFF_OPTIONS_INIT;
+ memcpy(out, &default_opts, sizeof(git_diff_options));
+ }
+
+ out->old_prefix = opts && opts->old_prefix ?
+ git__strdup(opts->old_prefix) :
+ git__strdup(DIFF_OLD_PREFIX_DEFAULT);
+
+ out->new_prefix = opts && opts->new_prefix ?
+ git__strdup(opts->new_prefix) :
+ git__strdup(DIFF_NEW_PREFIX_DEFAULT);
+
+ GITERR_CHECK_ALLOC(out->old_prefix);
+ GITERR_CHECK_ALLOC(out->new_prefix);
+
+ return 0;
+}
+
static int diff_patch_init_from_diff(
git_patch *patch, git_diff *diff, size_t delta_index)
{
@@ -86,10 +81,12 @@ static int diff_patch_init_from_diff(
patch->delta = git_vector_get(&diff->deltas, delta_index);
patch->delta_index = delta_index;
- if ((error = git_diff_file_content__init_from_diff(
- &patch->ofile, diff, delta_index, true)) < 0 ||
+ if ((error = diff_patch_normalize_options(
+ &patch->diff_opts, &diff->opts)) < 0 ||
(error = git_diff_file_content__init_from_diff(
- &patch->nfile, diff, delta_index, false)) < 0)
+ &patch->ofile, diff, patch->delta, true)) < 0 ||
+ (error = git_diff_file_content__init_from_diff(
+ &patch->nfile, diff, patch->delta, false)) < 0)
return error;
diff_patch_init_common(patch);
@@ -116,6 +113,14 @@ static int diff_patch_alloc_from_diff(
return error;
}
+GIT_INLINE(bool) should_skip_binary(git_patch *patch, git_diff_file *file)
+{
+ if ((patch->diff_opts.flags & GIT_DIFF_SHOW_BINARY) != 0)
+ return false;
+
+ return (file->flags & GIT_DIFF_FLAG_BINARY) != 0;
+}
+
static int diff_patch_load(git_patch *patch, git_diff_output *output)
{
int error = 0;
@@ -128,7 +133,7 @@ static int diff_patch_load(git_patch *patch, git_diff_output *output)
* binary, then there is no need to actually load the data
*/
if ((patch->ofile.opts_flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0 &&
- output && !output->hunk_cb && !output->data_cb)
+ output && !output->binary_cb && !output->hunk_cb && !output->data_cb)
return 0;
incomplete_data =
@@ -141,25 +146,29 @@ static int diff_patch_load(git_patch *patch, git_diff_output *output)
* need 2x data size and this minimizes peak memory footprint
*/
if (patch->ofile.src == GIT_ITERATOR_TYPE_WORKDIR) {
- if ((error = git_diff_file_content__load(&patch->ofile)) < 0 ||
- (patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0)
+ if ((error = git_diff_file_content__load(
+ &patch->ofile, &patch->diff_opts)) < 0 ||
+ should_skip_binary(patch, patch->ofile.file))
goto cleanup;
}
if (patch->nfile.src == GIT_ITERATOR_TYPE_WORKDIR) {
- if ((error = git_diff_file_content__load(&patch->nfile)) < 0 ||
- (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0)
+ if ((error = git_diff_file_content__load(
+ &patch->nfile, &patch->diff_opts)) < 0 ||
+ should_skip_binary(patch, patch->nfile.file))
goto cleanup;
}
/* once workdir has been tried, load other data as needed */
if (patch->ofile.src != GIT_ITERATOR_TYPE_WORKDIR) {
- if ((error = git_diff_file_content__load(&patch->ofile)) < 0 ||
- (patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0)
+ if ((error = git_diff_file_content__load(
+ &patch->ofile, &patch->diff_opts)) < 0 ||
+ should_skip_binary(patch, patch->ofile.file))
goto cleanup;
}
if (patch->nfile.src != GIT_ITERATOR_TYPE_WORKDIR) {
- if ((error = git_diff_file_content__load(&patch->nfile)) < 0 ||
- (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0)
+ if ((error = git_diff_file_content__load(
+ &patch->nfile, &patch->diff_opts)) < 0 ||
+ should_skip_binary(patch, patch->nfile.file))
goto cleanup;
}
@@ -177,10 +186,14 @@ cleanup:
diff_patch_update_binary(patch);
if (!error) {
+ bool skip_binary =
+ (patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0 &&
+ (patch->diff_opts.flags & GIT_DIFF_SHOW_BINARY) == 0;
+
/* patch is diffable only for non-binary, modified files where
- * at least one side has data and the data actually changed
- */
- if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) == 0 &&
+ * at least one side has data and the data actually changed
+ */
+ if (!skip_binary &&
patch->delta->status != GIT_DELTA_UNMODIFIED &&
(patch->ofile.map.len || patch->nfile.map.len) &&
(patch->ofile.map.len != patch->nfile.map.len ||
@@ -207,6 +220,98 @@ static int diff_patch_invoke_file_callback(
"git_patch");
}
+static int create_binary(
+ git_diff_binary_t *out_type,
+ char **out_data,
+ size_t *out_datalen,
+ size_t *out_inflatedlen,
+ const char *a_data,
+ size_t a_datalen,
+ const char *b_data,
+ size_t b_datalen)
+{
+ git_buf deflate = GIT_BUF_INIT, delta = GIT_BUF_INIT;
+ unsigned long delta_data_len;
+ int error;
+
+ /* The git_delta function accepts unsigned long only */
+ if (!git__is_ulong(a_datalen) || !git__is_ulong(b_datalen))
+ return GIT_EBUFS;
+
+ if ((error = git_zstream_deflatebuf(&deflate, b_data, b_datalen)) < 0)
+ goto done;
+
+ /* The git_delta function accepts unsigned long only */
+ if (!git__is_ulong(deflate.size)) {
+ error = GIT_EBUFS;
+ goto done;
+ }
+
+ if (a_datalen && b_datalen) {
+ void *delta_data = git_delta(
+ a_data, (unsigned long)a_datalen,
+ b_data, (unsigned long)b_datalen,
+ &delta_data_len, (unsigned long)deflate.size);
+
+ if (delta_data) {
+ error = git_zstream_deflatebuf(
+ &delta, delta_data, (size_t)delta_data_len);
+
+ git__free(delta_data);
+
+ if (error < 0)
+ goto done;
+ }
+ }
+
+ if (delta.size && delta.size < deflate.size) {
+ *out_type = GIT_DIFF_BINARY_DELTA;
+ *out_datalen = delta.size;
+ *out_data = git_buf_detach(&delta);
+ *out_inflatedlen = delta_data_len;
+ } else {
+ *out_type = GIT_DIFF_BINARY_LITERAL;
+ *out_datalen = deflate.size;
+ *out_data = git_buf_detach(&deflate);
+ *out_inflatedlen = b_datalen;
+ }
+
+done:
+ git_buf_free(&deflate);
+ git_buf_free(&delta);
+
+ return error;
+}
+
+static int diff_binary(git_diff_output *output, git_patch *patch)
+{
+ git_diff_binary binary = { 0 };
+ const char *old_data = patch->ofile.map.data;
+ const char *new_data = patch->nfile.map.data;
+ size_t old_len = patch->ofile.map.len,
+ new_len = patch->nfile.map.len;
+ int error;
+
+ /* Create the old->new delta (as the "new" side of the patch),
+ * and the new->old delta (as the "old" side)
+ */
+ if ((error = create_binary(&binary.old_file.type,
+ (char **)&binary.old_file.data,
+ &binary.old_file.datalen,
+ &binary.old_file.inflatedlen,
+ new_data, new_len, old_data, old_len)) < 0 ||
+ (error = create_binary(&binary.new_file.type,
+ (char **)&binary.new_file.data,
+ &binary.new_file.datalen,
+ &binary.new_file.inflatedlen,
+ old_data, old_len, new_data, new_len)) < 0)
+ return error;
+
+ return giterr_set_after_callback_function(
+ output->binary_cb(patch->delta, &binary, output->payload),
+ "git_patch");
+}
+
static int diff_patch_generate(git_patch *patch, git_diff_output *output)
{
int error = 0;
@@ -214,8 +319,8 @@ static int diff_patch_generate(git_patch *patch, git_diff_output *output)
if ((patch->flags & GIT_DIFF_PATCH_DIFFED) != 0)
return 0;
- /* if we are not looking at the hunks and lines, don't do the diff */
- if (!output->hunk_cb && !output->data_cb)
+ /* if we are not looking at the binary or text data, don't do the diff */
+ if (!output->binary_cb && !output->hunk_cb && !output->data_cb)
return 0;
if ((patch->flags & GIT_DIFF_PATCH_LOADED) == 0 &&
@@ -225,10 +330,16 @@ static int diff_patch_generate(git_patch *patch, git_diff_output *output)
if ((patch->flags & GIT_DIFF_PATCH_DIFFABLE) == 0)
return 0;
- if (output->diff_cb != NULL &&
- (error = output->diff_cb(output, patch)) < 0)
- patch->flags |= GIT_DIFF_PATCH_DIFFED;
+ if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0) {
+ if (output->binary_cb)
+ error = diff_binary(output, patch);
+ }
+ else {
+ if (output->diff_cb)
+ error = output->diff_cb(output, patch);
+ }
+ patch->flags |= GIT_DIFF_PATCH_DIFFED;
return error;
}
@@ -245,6 +356,9 @@ static void diff_patch_free(git_patch *patch)
git_pool_clear(&patch->flattened);
+ git__free((char *)patch->diff_opts.old_prefix);
+ git__free((char *)patch->diff_opts.new_prefix);
+
if (patch->flags & GIT_DIFF_PATCH_ALLOCATED)
git__free(patch);
}
@@ -260,6 +374,7 @@ static int diff_required(git_diff *diff, const char *action)
int git_diff_foreach(
git_diff *diff,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb data_cb,
void *payload)
@@ -275,7 +390,7 @@ int git_diff_foreach(
memset(&xo, 0, sizeof(xo));
memset(&patch, 0, sizeof(patch));
diff_output_init(
- &xo.output, &diff->opts, file_cb, hunk_cb, data_cb, payload);
+ &xo.output, &diff->opts, file_cb, binary_cb, hunk_cb, data_cb, payload);
git_xdiff_init(&xo, &diff->opts);
git_vector_foreach(&diff->deltas, idx, patch.delta) {
@@ -284,11 +399,15 @@ int git_diff_foreach(
if (git_diff_delta__should_skip(&diff->opts, patch.delta))
continue;
+ if (binary_cb || hunk_cb || data_cb) {
+ if ((error = diff_patch_init_from_diff(&patch, diff, idx)) != 0 ||
+ (error = diff_patch_load(&patch, &xo.output)) != 0)
+ return error;
+ }
+
if ((error = diff_patch_invoke_file_callback(&patch, &xo.output)) == 0) {
- if (hunk_cb || data_cb) {
- if ((error = diff_patch_init_from_diff(&patch, diff, idx)) == 0)
+ if (binary_cb || hunk_cb || data_cb)
error = diff_patch_generate(&patch, &xo.output);
- }
}
git_patch_free(&patch);
@@ -350,7 +469,8 @@ static int diff_patch_from_sources(
git_diff_file *lfile = &pd->delta.old_file, *rfile = &pd->delta.new_file;
git_diff_file_content *ldata = &pd->patch.ofile, *rdata = &pd->patch.nfile;
- GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options");
+ if ((error = diff_patch_normalize_options(&pd->patch.diff_opts, opts)) < 0)
+ return error;
if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) {
void *tmp = lfile; lfile = rfile; rfile = tmp;
@@ -419,6 +539,7 @@ static int diff_from_sources(
git_diff_file_content_src *newsrc,
const git_diff_options *opts,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb data_cb,
void *payload)
@@ -429,7 +550,7 @@ static int diff_from_sources(
memset(&xo, 0, sizeof(xo));
diff_output_init(
- &xo.output, opts, file_cb, hunk_cb, data_cb, payload);
+ &xo.output, opts, file_cb, binary_cb, hunk_cb, data_cb, payload);
git_xdiff_init(&xo, opts);
memset(&pd, 0, sizeof(pd));
@@ -477,6 +598,7 @@ int git_diff_blobs(
const char *new_path,
const git_diff_options *opts,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb data_cb,
void *payload)
@@ -486,7 +608,7 @@ int git_diff_blobs(
git_diff_file_content_src nsrc =
GIT_DIFF_FILE_CONTENT_SRC__BLOB(new_blob, new_path);
return diff_from_sources(
- &osrc, &nsrc, opts, file_cb, hunk_cb, data_cb, payload);
+ &osrc, &nsrc, opts, file_cb, binary_cb, hunk_cb, data_cb, payload);
}
int git_patch_from_blobs(
@@ -512,6 +634,7 @@ int git_diff_blob_to_buffer(
const char *buf_path,
const git_diff_options *opts,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb data_cb,
void *payload)
@@ -521,7 +644,7 @@ int git_diff_blob_to_buffer(
git_diff_file_content_src nsrc =
GIT_DIFF_FILE_CONTENT_SRC__BUF(buf, buflen, buf_path);
return diff_from_sources(
- &osrc, &nsrc, opts, file_cb, hunk_cb, data_cb, payload);
+ &osrc, &nsrc, opts, file_cb, binary_cb, hunk_cb, data_cb, payload);
}
int git_patch_from_blob_and_buffer(
@@ -549,6 +672,7 @@ int git_diff_buffers(
const char *new_path,
const git_diff_options *opts,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb data_cb,
void *payload)
@@ -558,7 +682,7 @@ int git_diff_buffers(
git_diff_file_content_src nsrc =
GIT_DIFF_FILE_CONTENT_SRC__BUF(new_buf, new_len, new_path);
return diff_from_sources(
- &osrc, &nsrc, opts, file_cb, hunk_cb, data_cb, payload);
+ &osrc, &nsrc, opts, file_cb, binary_cb, hunk_cb, data_cb, payload);
}
int git_patch_from_buffers(
@@ -812,6 +936,7 @@ void git_patch__new_data(
int git_patch__invoke_callbacks(
git_patch *patch,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *payload)
@@ -822,6 +947,13 @@ int git_patch__invoke_callbacks(
if (file_cb)
error = file_cb(patch->delta, 0, payload);
+ if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0) {
+ if (binary_cb)
+ error = binary_cb(patch->delta, &patch->binary, payload);
+
+ return error;
+ }
+
if (!hunk_cb && !line_cb)
return error;
@@ -855,6 +987,36 @@ static int diff_patch_file_cb(
return 0;
}
+static int diff_patch_binary_cb(
+ const git_diff_delta *delta,
+ const git_diff_binary *binary,
+ void *payload)
+{
+ git_patch *patch = payload;
+
+ GIT_UNUSED(delta);
+
+ memcpy(&patch->binary, binary, sizeof(git_diff_binary));
+
+ if (binary->old_file.data) {
+ patch->binary.old_file.data = git__malloc(binary->old_file.datalen);
+ GITERR_CHECK_ALLOC(patch->binary.old_file.data);
+
+ memcpy((char *)patch->binary.old_file.data,
+ binary->old_file.data, binary->old_file.datalen);
+ }
+
+ if (binary->new_file.data) {
+ patch->binary.new_file.data = git__malloc(binary->new_file.datalen);
+ GITERR_CHECK_ALLOC(patch->binary.new_file.data);
+
+ memcpy((char *)patch->binary.new_file.data,
+ binary->new_file.data, binary->new_file.datalen);
+ }
+
+ return 0;
+}
+
static int diff_patch_hunk_cb(
const git_diff_delta *delta,
const git_diff_hunk *hunk_,
@@ -921,6 +1083,7 @@ static void diff_output_init(
git_diff_output *out,
const git_diff_options *opts,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb data_cb,
void *payload)
@@ -930,6 +1093,7 @@ static void diff_output_init(
memset(out, 0, sizeof(*out));
out->file_cb = file_cb;
+ out->binary_cb = binary_cb;
out->hunk_cb = hunk_cb;
out->data_cb = data_cb;
out->payload = payload;
@@ -938,6 +1102,11 @@ static void diff_output_init(
static void diff_output_to_patch(git_diff_output *out, git_patch *patch)
{
diff_output_init(
- out, NULL,
- diff_patch_file_cb, diff_patch_hunk_cb, diff_patch_line_cb, patch);
+ out,
+ NULL,
+ diff_patch_file_cb,
+ diff_patch_binary_cb,
+ diff_patch_hunk_cb,
+ diff_patch_line_cb,
+ patch);
}
diff --git a/src/diff_patch.h b/src/diff_patch.h
index df2ba4c..f6ce57d 100644
--- a/src/diff_patch.h
+++ b/src/diff_patch.h
@@ -13,6 +13,38 @@
#include "array.h"
#include "git2/patch.h"
+ /* cached information about a hunk in a diff */
+typedef struct diff_patch_hunk {
+ git_diff_hunk hunk;
+ size_t line_start;
+ size_t line_count;
+} diff_patch_hunk;
+
+enum {
+ GIT_DIFF_PATCH_ALLOCATED = (1 << 0),
+ GIT_DIFF_PATCH_INITIALIZED = (1 << 1),
+ GIT_DIFF_PATCH_LOADED = (1 << 2),
+ GIT_DIFF_PATCH_DIFFABLE = (1 << 3),
+ GIT_DIFF_PATCH_DIFFED = (1 << 4),
+ GIT_DIFF_PATCH_FLATTENED = (1 << 5),
+};
+
+struct git_patch {
+ git_refcount rc;
+ git_diff *diff; /* for refcount purposes, maybe NULL for blob diffs */
+ git_diff_options diff_opts;
+ git_diff_delta *delta;
+ size_t delta_index;
+ git_diff_file_content ofile;
+ git_diff_file_content nfile;
+ uint32_t flags;
+ git_diff_binary binary;
+ git_array_t(diff_patch_hunk) hunks;
+ git_array_t(git_diff_line) lines;
+ size_t content_size, context_size, header_size;
+ git_pool flattened;
+};
+
extern git_diff *git_patch__diff(git_patch *);
extern git_diff_driver *git_patch__driver(git_patch *);
@@ -23,6 +55,7 @@ extern void git_patch__new_data(char **, size_t *, git_patch *);
extern int git_patch__invoke_callbacks(
git_patch *patch,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *payload);
@@ -31,6 +64,7 @@ typedef struct git_diff_output git_diff_output;
struct git_diff_output {
/* these callbacks are issued with the diff data */
git_diff_file_cb file_cb;
+ git_diff_binary_cb binary_cb;
git_diff_hunk_cb hunk_cb;
git_diff_line_cb data_cb;
void *payload;
diff --git a/src/diff_print.c b/src/diff_print.c
index 43a90b3..ebae4ea 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -22,50 +22,92 @@ typedef struct {
uint32_t flags;
int oid_strlen;
git_diff_line line;
+ unsigned int
+ content_loaded : 1,
+ content_allocated : 1;
+ git_diff_file_content *ofile;
+ git_diff_file_content *nfile;
} diff_print_info;
-static int diff_print_info_init(
+static int diff_print_info_init__common(
diff_print_info *pi,
git_buf *out,
- git_diff *diff,
+ git_repository *repo,
git_diff_format_t format,
git_diff_line_cb cb,
void *payload)
{
- pi->diff = diff;
- pi->format = format;
+ pi->format = format;
pi->print_cb = cb;
- pi->payload = payload;
- pi->buf = out;
-
- if (diff)
- pi->flags = diff->opts.flags;
- else
- pi->flags = 0;
-
- if (diff && diff->opts.id_abbrev != 0)
- pi->oid_strlen = diff->opts.id_abbrev;
- else if (!diff || !diff->repo)
- pi->oid_strlen = GIT_ABBREV_DEFAULT;
- else if (git_repository__cvar(
- &pi->oid_strlen, diff->repo, GIT_CVAR_ABBREV) < 0)
- return -1;
+ pi->payload = payload;
+ pi->buf = out;
+
+ if (!pi->oid_strlen) {
+ if (!repo)
+ pi->oid_strlen = GIT_ABBREV_DEFAULT;
+ else if (git_repository__cvar(&pi->oid_strlen, repo, GIT_CVAR_ABBREV) < 0)
+ return -1;
+ }
pi->oid_strlen += 1; /* for NUL byte */
- if (pi->oid_strlen < 2)
- pi->oid_strlen = 2;
- else if (pi->oid_strlen > GIT_OID_HEXSZ + 1)
+ if (pi->oid_strlen > GIT_OID_HEXSZ + 1)
pi->oid_strlen = GIT_OID_HEXSZ + 1;
memset(&pi->line, 0, sizeof(pi->line));
pi->line.old_lineno = -1;
pi->line.new_lineno = -1;
- pi->line.num_lines = 1;
+ pi->line.num_lines = 1;
return 0;
}
+static int diff_print_info_init_fromdiff(
+ diff_print_info *pi,
+ git_buf *out,
+ git_diff *diff,
+ git_diff_format_t format,
+ git_diff_line_cb cb,
+ void *payload)
+{
+ git_repository *repo = diff ? diff->repo : NULL;
+
+ memset(pi, 0, sizeof(diff_print_info));
+
+ pi->diff = diff;
+
+ if (diff) {
+ pi->flags = diff->opts.flags;
+ pi->oid_strlen = diff->opts.id_abbrev;
+ }
+
+ return diff_print_info_init__common(pi, out, repo, format, cb, payload);
+}
+
+static int diff_print_info_init_frompatch(
+ diff_print_info *pi,
+ git_buf *out,
+ git_patch *patch,
+ git_diff_format_t format,
+ git_diff_line_cb cb,
+ void *payload)
+{
+ git_repository *repo = patch && patch->diff ? patch->diff->repo : NULL;
+
+ memset(pi, 0, sizeof(diff_print_info));
+
+ pi->diff = patch->diff;
+
+ pi->flags = patch->diff_opts.flags;
+ pi->oid_strlen = patch->diff_opts.id_abbrev;
+
+ pi->content_loaded = 1;
+ pi->ofile = &patch->ofile;
+ pi->nfile = &patch->nfile;
+
+ return diff_print_info_init__common(pi, out, repo, format, cb, payload);
+}
+
static char diff_pick_suffix(int mode)
{
if (S_ISDIR(mode))
@@ -283,66 +325,22 @@ int git_diff_delta__format_file_header(
return git_buf_oom(out) ? -1 : 0;
}
-static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
+static int format_binary(
+ diff_print_info *pi,
+ git_diff_binary_t type,
+ const char *data,
+ size_t datalen,
+ size_t inflatedlen)
{
- git_buf deflate = GIT_BUF_INIT, delta = GIT_BUF_INIT, *out = NULL;
- const void *old_data, *new_data;
- git_off_t old_data_len, new_data_len;
- unsigned long delta_data_len, inflated_len;
- const char *out_type = "literal";
- char *scan, *end;
- int error;
-
- old_data = old ? git_blob_rawcontent(old) : NULL;
- new_data = new ? git_blob_rawcontent(new) : NULL;
-
- old_data_len = old ? git_blob_rawsize(old) : 0;
- new_data_len = new ? git_blob_rawsize(new) : 0;
-
- /* The git_delta function accepts unsigned long only */
- if (!git__is_ulong(old_data_len) || !git__is_ulong(new_data_len))
- return GIT_EBUFS;
-
- out = &deflate;
- inflated_len = (unsigned long)new_data_len;
-
- if ((error = git_zstream_deflatebuf(
- out, new_data, (size_t)new_data_len)) < 0)
- goto done;
-
- /* The git_delta function accepts unsigned long only */
- if (!git__is_ulong((git_off_t)deflate.size)) {
- error = GIT_EBUFS;
- goto done;
- }
+ const char *typename = type == GIT_DIFF_BINARY_DELTA ?
+ "delta" : "literal";
+ const char *scan, *end;
+ int error = 0;
- if (old && new) {
- void *delta_data = git_delta(
- old_data, (unsigned long)old_data_len,
- new_data, (unsigned long)new_data_len,
- &delta_data_len, (unsigned long)deflate.size);
-
- if (delta_data) {
- error = git_zstream_deflatebuf(
- &delta, delta_data, (size_t)delta_data_len);
-
- git__free(delta_data);
-
- if (error < 0)
- goto done;
-
- if (delta.size < deflate.size) {
- out = δ
- out_type = "delta";
- inflated_len = delta_data_len;
- }
- }
- }
-
- git_buf_printf(pi->buf, "%s %lu\n", out_type, inflated_len);
+ git_buf_printf(pi->buf, "%s %lu\n", typename, inflatedlen);
pi->line.num_lines++;
- for (scan = out->ptr, end = out->ptr + out->size; scan < end; ) {
+ for (scan = data, end = data + datalen; scan < end; ) {
size_t chunk_len = end - scan;
if (chunk_len > 52)
chunk_len = 52;
@@ -355,51 +353,74 @@ static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
git_buf_encode_base85(pi->buf, scan, chunk_len);
git_buf_putc(pi->buf, '\n');
- if (git_buf_oom(pi->buf)) {
- error = -1;
- goto done;
- }
+ if (git_buf_oom(pi->buf))
+ return -1;
scan += chunk_len;
pi->line.num_lines++;
}
-done:
- git_buf_free(&deflate);
- git_buf_free(&delta);
+ return 0;
+}
- return error;
+static int diff_print_load_content(
+ diff_print_info *pi,
+ git_diff_delta *delta)
+{
+ git_diff_file_content *ofile, *nfile;
+ int error;
+
+ assert(pi->diff);
+
+ ofile = git__calloc(1, sizeof(git_diff_file_content));
+ nfile = git__calloc(1, sizeof(git_diff_file_content));
+
+ GITERR_CHECK_ALLOC(ofile);
+ GITERR_CHECK_ALLOC(nfile);
+
+ if ((error = git_diff_file_content__init_from_diff(
+ ofile, pi->diff, delta, true)) < 0 ||
+ (error = git_diff_file_content__init_from_diff(
+ nfile, pi->diff, delta, true)) < 0) {
+
+ git__free(ofile);
+ git__free(nfile);
+ return error;
+ }
+
+ pi->content_loaded = 1;
+ pi->content_allocated = 1;
+ pi->ofile = ofile;
+ pi->nfile = nfile;
+
+ return 0;
}
-/* git diff --binary 8d7523f~2 8d7523f~1 */
static int diff_print_patch_file_binary(
- diff_print_info *pi, const git_diff_delta *delta,
- const char *oldpfx, const char *newpfx)
+ diff_print_info *pi, git_diff_delta *delta,
+ const char *old_pfx, const char *new_pfx,
+ const git_diff_binary *binary)
{
- git_blob *old = NULL, *new = NULL;
- const git_oid *old_id, *new_id;
- int error;
size_t pre_binary_size;
+ int error;
if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0)
goto noshow;
+ if (!pi->content_loaded &&
+ (error = diff_print_load_content(pi, delta)) < 0)
+ return error;
+
pre_binary_size = pi->buf->size;
git_buf_printf(pi->buf, "GIT binary patch\n");
pi->line.num_lines++;
- old_id = (delta->status != GIT_DELTA_ADDED) ? &delta->old_file.id : NULL;
- new_id = (delta->status != GIT_DELTA_DELETED) ? &delta->new_file.id : NULL;
-
- if (old_id && (error = git_blob_lookup(&old, pi->diff->repo, old_id)) < 0)
- goto done;
- if (new_id && (error = git_blob_lookup(&new, pi->diff->repo,new_id)) < 0)
- goto done;
-
- if ((error = print_binary_hunk(pi, old, new)) < 0 ||
+ if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data,
+ binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
(error = git_buf_putc(pi->buf, '\n')) < 0 ||
- (error = print_binary_hunk(pi, new, old)) < 0)
- {
+ (error = format_binary(pi, binary->old_file.type, binary->old_file.data,
+ binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
+
if (error == GIT_EBUFS) {
giterr_clear();
git_buf_truncate(pi->buf, pre_binary_size);
@@ -408,17 +429,12 @@ static int diff_print_patch_file_binary(
}
pi->line.num_lines++;
-
-done:
- git_blob_free(old);
- git_blob_free(new);
-
return error;
noshow:
pi->line.num_lines = 1;
return diff_delta_format_with_paths(
- pi->buf, delta, oldpfx, newpfx,
+ pi->buf, delta, old_pfx, new_pfx,
"Binary files %s%s and %s%s differ\n");
}
@@ -432,7 +448,8 @@ static int diff_print_patch_file(
const char *newpfx =
pi->diff ? pi->diff->opts.new_prefix : DIFF_NEW_PREFIX_DEFAULT;
- bool binary = !!(delta->flags & GIT_DIFF_FLAG_BINARY);
+ bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
+ (pi->flags & GIT_DIFF_FORCE_BINARY);
bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY);
int oid_strlen = binary && show_binary ?
GIT_OID_HEXSZ + 1 : pi->oid_strlen;
@@ -455,19 +472,29 @@ static int diff_print_patch_file(
pi->line.content = git_buf_cstr(pi->buf);
pi->line.content_len = git_buf_len(pi->buf);
- if ((error = pi->print_cb(delta, NULL, &pi->line, pi->payload)) != 0)
- return error;
+ return pi->print_cb(delta, NULL, &pi->line, pi->payload);
+}
- if (!binary)
- return 0;
+static int diff_print_patch_binary(
+ const git_diff_delta *delta,
+ const git_diff_binary *binary,
+ void *data)
+{
+ diff_print_info *pi = data;
+ const char *old_pfx =
+ pi->diff ? pi->diff->opts.old_prefix : DIFF_OLD_PREFIX_DEFAULT;
+ const char *new_pfx =
+ pi->diff ? pi->diff->opts.new_prefix : DIFF_NEW_PREFIX_DEFAULT;
+ int error;
git_buf_clear(pi->buf);
- if ((error = diff_print_patch_file_binary(pi, delta, oldpfx, newpfx)) < 0)
+ if ((error = diff_print_patch_file_binary(
+ pi, (git_diff_delta *)delta, old_pfx, new_pfx, binary)) < 0)
return error;
- pi->line.origin = GIT_DIFF_LINE_BINARY;
- pi->line.content = git_buf_cstr(pi->buf);
+ pi->line.origin = GIT_DIFF_LINE_BINARY;
+ pi->line.content = git_buf_cstr(pi->buf);
pi->line.content_len = git_buf_len(pi->buf);
return pi->print_cb(delta, NULL, &pi->line, pi->payload);
@@ -515,12 +542,14 @@ int git_diff_print(
git_buf buf = GIT_BUF_INIT;
diff_print_info pi;
git_diff_file_cb print_file = NULL;
+ git_diff_binary_cb print_binary = NULL;
git_diff_hunk_cb print_hunk = NULL;
git_diff_line_cb print_line = NULL;
switch (format) {
case GIT_DIFF_FORMAT_PATCH:
print_file = diff_print_patch_file;
+ print_binary = diff_print_patch_binary;
print_hunk = diff_print_patch_hunk;
print_line = diff_print_patch_line;
break;
@@ -541,11 +570,10 @@ int git_diff_print(
return -1;
}
- if (!(error = diff_print_info_init(
- &pi, &buf, diff, format, print_cb, payload)))
- {
+ if (!(error = diff_print_info_init_fromdiff(
+ &pi, &buf, diff, format, print_cb, payload))) {
error = git_diff_foreach(
- diff, print_file, print_hunk, print_line, &pi);
+ diff, print_file, print_binary, print_hunk, print_line, &pi);
if (error) /* make sure error message is set */
giterr_set_after_callback_function(error, "git_diff_print");
@@ -568,13 +596,13 @@ int git_patch_print(
assert(patch && print_cb);
- if (!(error = diff_print_info_init(
- &pi, &temp, git_patch__diff(patch),
+ if (!(error = diff_print_info_init_frompatch(
+ &pi, &temp, patch,
GIT_DIFF_FORMAT_PATCH, print_cb, payload)))
{
error = git_patch__invoke_callbacks(
- patch, diff_print_patch_file, diff_print_patch_hunk,
- diff_print_patch_line, &pi);
+ patch, diff_print_patch_file, diff_print_patch_binary,
+ diff_print_patch_hunk, diff_print_patch_line, &pi);
if (error) /* make sure error message is set */
giterr_set_after_callback_function(error, "git_patch_print");
diff --git a/src/index.c b/src/index.c
index 0422ff1..14d8d36 100644
--- a/src/index.c
+++ b/src/index.c
@@ -2727,7 +2727,7 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
goto cleanup;
data.pathspec = &ps;
- error = git_diff_foreach(diff, apply_each_file, NULL, NULL, &data);
+ error = git_diff_foreach(diff, apply_each_file, NULL, NULL, NULL, &data);
git_diff_free(diff);
if (error) /* make sure error is set if callback stopped iteration */
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index cb574a5..7fac1c5 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -261,3 +261,232 @@ void test_diff_binary__delta_append(void)
git_index_free(index);
}
+
+void test_diff_binary__index_to_workdir(void)
+{
+ git_index *index;
+ git_diff *diff;
+ git_patch *patch;
+ git_buf actual = GIT_BUF_INIT;
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ const char *expected =
+ "diff --git a/untimely.txt b/untimely.txt\n" \
+ "index 9a69d960ae94b060f56c2a8702545e2bb1abb935..1111d4f11f4b35bf6759e0fb714fe09731ef0840 100644\n" \
+ "GIT binary patch\n" \
+ "delta 32\n" \
+ "nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
+ "\n" \
+ "delta 7\n" \
+ "Oc%18D`@*{63ljhg(E~C7\n";
+
+ opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
+ opts.id_abbrev = GIT_OID_HEXSZ;
+
+ repo = cl_git_sandbox_init("renames");
+ cl_git_pass(git_repository_index(&index, repo));
+
+ cl_git_append2file("renames/untimely.txt", "Oh that crazy Kipling!\r\n");
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, index, &opts));
+
+ cl_git_pass(git_patch_from_diff(&patch, diff, 0));
+ cl_git_pass(git_patch_to_buf(&actual, patch));
+
+ cl_assert_equal_s(expected, actual.ptr);
+
+ cl_git_pass(git_index_add_bypath(index, "untimely.txt"));
+ cl_git_pass(git_index_write(index));
+
+ test_patch(
+ "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13",
+ NULL,
+ &opts,
+ expected);
+
+ git_buf_free(&actual);
+ git_patch_free(patch);
+ git_diff_free(diff);
+ git_index_free(index);
+}
+
+static int print_cb(
+ const git_diff_delta *delta,
+ const git_diff_hunk *hunk,
+ const git_diff_line *line,
+ void *payload)
+{
+ git_buf *buf = (git_buf *)payload;
+
+ if (hunk)
+ git_buf_put(buf, hunk->header, hunk->header_len);
+
+ if (line)
+ git_buf_put(buf, line->content, line->content_len);
+
+ return git_buf_oom(buf) ? -1 : 0;
+}
+
+void test_diff_binary__print_patch_from_diff(void)
+{
+ git_index *index;
+ git_diff *diff;
+ git_buf actual = GIT_BUF_INIT;
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ const char *expected =
+ "diff --git a/untimely.txt b/untimely.txt\n" \
+ "index 9a69d960ae94b060f56c2a8702545e2bb1abb935..1111d4f11f4b35bf6759e0fb714fe09731ef0840 100644\n" \
+ "GIT binary patch\n" \
+ "delta 32\n" \
+ "nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
+ "\n" \
+ "delta 7\n" \
+ "Oc%18D`@*{63ljhg(E~C7\n";
+
+ opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
+ opts.id_abbrev = GIT_OID_HEXSZ;
+
+ repo = cl_git_sandbox_init("renames");
+ cl_git_pass(git_repository_index(&index, repo));
+
+ cl_git_append2file("renames/untimely.txt", "Oh that crazy Kipling!\r\n");
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, index, &opts));
+
+ cl_git_pass(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, print_cb, &actual));
+
+ cl_assert_equal_s(expected, actual.ptr);
+
+ git_buf_free(&actual);
+ git_diff_free(diff);
+ git_index_free(index);
+}
+
+struct diff_data {
+ char *old_path;
+ git_oid old_id;
+ git_buf old_binary_base85;
+ size_t old_binary_inflatedlen;
+ git_diff_binary_t old_binary_type;
+
+ char *new_path;
+ git_oid new_id;
+ git_buf new_binary_base85;
+ size_t new_binary_inflatedlen;
+ git_diff_binary_t new_binary_type;
+};
+
+static int file_cb(
+ const git_diff_delta *delta,
+ float progress,
+ void *payload)
+{
+ struct diff_data *diff_data = payload;
+
+ if (delta->old_file.path)
+ diff_data->old_path = git__strdup(delta->old_file.path);
+
+ if (delta->new_file.path)
+ diff_data->new_path = git__strdup(delta->new_file.path);
+
+ git_oid_cpy(&diff_data->old_id, &delta->old_file.id);
+ git_oid_cpy(&diff_data->new_id, &delta->new_file.id);
+
+ return 0;
+}
+
+static int binary_cb(
+ const git_diff_delta *delta,
+ const git_diff_binary *binary,
+ void *payload)
+{
+ struct diff_data *diff_data = payload;
+
+ git_buf_encode_base85(&diff_data->old_binary_base85,
+ binary->old_file.data, binary->old_file.datalen);
+ diff_data->old_binary_inflatedlen = binary->old_file.inflatedlen;
+ diff_data->old_binary_type = binary->old_file.type;
+
+ git_buf_encode_base85(&diff_data->new_binary_base85,
+ binary->new_file.data, binary->new_file.datalen);
+ diff_data->new_binary_inflatedlen = binary->new_file.inflatedlen;
+ diff_data->new_binary_type = binary->new_file.type;
+
+ return 0;
+}
+
+static int hunk_cb(
+ const git_diff_delta *delta,
+ const git_diff_hunk *hunk,
+ void *payload)
+{
+ cl_fail("did not expect hunk callback");
+ return 0;
+}
+
+static int line_cb(
+ const git_diff_delta *delta,
+ const git_diff_hunk *hunk,
+ const git_diff_line *line,
+ void *payload)
+{
+ cl_fail("did not expect line callback");
+ return 0;
+}
+
+void test_diff_binary__blob_to_blob(void)
+{
+ git_index *index;
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_blob *old_blob, *new_blob;
+ git_oid old_id, new_id;
+ struct diff_data diff_data = {0};
+ const char *expected =
+ "diff --git a/untimely.txt b/untimely.txt\n" \
+ "index 9a69d960ae94b060f56c2a8702545e2bb1abb935..1111d4f11f4b35bf6759e0fb714fe09731ef0840 100644\n" \
+ "GIT binary patch\n" \
+ "delta 32\n" \
+ "nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
+ "\n" \
+ "delta 7\n" \
+ "Oc%18D`@*{63ljhg(E~C7\n";
+
+ opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
+ opts.id_abbrev = GIT_OID_HEXSZ;
+
+ repo = cl_git_sandbox_init("renames");
+ cl_git_pass(git_repository_index(&index, repo));
+
+ cl_git_append2file("renames/untimely.txt", "Oh that crazy Kipling!\r\n");
+ cl_git_pass(git_index_add_bypath(index, "untimely.txt"));
+ cl_git_pass(git_index_write(index));
+
+ git_oid_fromstr(&old_id, "9a69d960ae94b060f56c2a8702545e2bb1abb935");
+ git_oid_fromstr(&new_id, "1111d4f11f4b35bf6759e0fb714fe09731ef0840");
+
+ cl_git_pass(git_blob_lookup(&old_blob, repo, &old_id));
+ cl_git_pass(git_blob_lookup(&new_blob, repo, &new_id));
+
+ cl_git_pass(git_diff_blobs(old_blob,
+ "untimely.txt", new_blob, "untimely.txt", &opts,
+ file_cb, binary_cb, hunk_cb, line_cb, &diff_data));
+
+ cl_assert_equal_s("untimely.txt", diff_data.old_path);
+ cl_assert_equal_oid(&old_id, &diff_data.old_id);
+ cl_assert_equal_i(GIT_DIFF_BINARY_DELTA, diff_data.old_binary_type);
+ cl_assert_equal_i(7, diff_data.old_binary_inflatedlen);
+ cl_assert_equal_s("c%18D`@*{63ljhg(E~C7",
+ diff_data.old_binary_base85.ptr);
+
+ cl_assert_equal_s("untimely.txt", diff_data.new_path);
+ cl_assert_equal_oid(&new_id, &diff_data.new_id);
+ cl_assert_equal_i(GIT_DIFF_BINARY_DELTA, diff_data.new_binary_type);
+ cl_assert_equal_i(32, diff_data.new_binary_inflatedlen);
+ cl_assert_equal_s("c%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW",
+ diff_data.new_binary_base85.ptr);
+
+ git_blob_free(old_blob);
+ git_blob_free(new_blob);
+
+ git__free(diff_data.old_path);
+ git__free(diff_data.new_path);
+}
diff --git a/tests/diff/blob.c b/tests/diff/blob.c
index 51bdbab..b0253f6 100644
--- a/tests/diff/blob.c
+++ b/tests/diff/blob.c
@@ -17,7 +17,7 @@ static void quick_diff_blob_to_str(
cl_git_pass(git_diff_blob_to_buffer(
blob, blob_path, str, len, str_path,
- &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ &opts, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
}
void test_diff_blob__initialize(void)
@@ -88,7 +88,7 @@ void test_diff_blob__can_compare_text_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
a, NULL, b, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(1, 6, 1, 5, 0, &expected);
/* same diff but use direct buffers */
@@ -96,27 +96,27 @@ void test_diff_blob__can_compare_text_blobs(void)
cl_git_pass(git_diff_buffers(
git_blob_rawcontent(a), (size_t)git_blob_rawsize(a), NULL,
git_blob_rawcontent(b), (size_t)git_blob_rawsize(b), NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(1, 6, 1, 5, 0, &expected);
/* diff on tests/resources/attr/root_test2 */
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
b, NULL, c, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(1, 15, 3, 9, 3, &expected);
/* diff on tests/resources/attr/root_test3 */
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
a, NULL, c, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(1, 13, 0, 12, 1, &expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
c, NULL, d, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(2, 14, 4, 6, 4, &expected);
git_blob_free(a);
@@ -206,7 +206,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
cl_git_pass(git_diff_blobs(
d, NULL, e, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_DELETED]);
@@ -222,7 +222,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
cl_git_pass(git_diff_blobs(
d, NULL, e, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_ADDED]);
@@ -238,7 +238,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
cl_git_pass(git_diff_blobs(
alien, NULL, NULL, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.files_binary);
@@ -250,7 +250,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
cl_git_pass(git_diff_blobs(
NULL, NULL, alien, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.files_binary);
@@ -358,7 +358,7 @@ void test_diff_blob__can_compare_identical_blobs(void)
cl_git_pass(git_diff_blobs(
d, NULL, d, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_identical_blobs_comparison(&expected);
cl_assert_equal_i(0, expected.files_binary);
@@ -366,7 +366,7 @@ void test_diff_blob__can_compare_identical_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
NULL, NULL, NULL, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_identical_blobs_comparison(&expected);
cl_assert_equal_i(0, expected.files_binary);
@@ -374,7 +374,7 @@ void test_diff_blob__can_compare_identical_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
alien, NULL, alien, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_identical_blobs_comparison(&expected);
cl_assert(expected.files_binary > 0);
@@ -441,7 +441,7 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
cl_git_pass(git_diff_blobs(
alien, NULL, heart, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
@@ -449,7 +449,7 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
cl_git_pass(git_diff_blobs(
heart, NULL, alien, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
@@ -460,7 +460,7 @@ void test_diff_blob__can_compare_a_binary_blob_and_a_text_blob(void)
{
cl_git_pass(git_diff_blobs(
alien, NULL, d, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
@@ -468,7 +468,7 @@ void test_diff_blob__can_compare_a_binary_blob_and_a_text_blob(void)
cl_git_pass(git_diff_blobs(
d, NULL, alien, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
}
@@ -510,7 +510,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
/* Test with default inter-hunk-context (not set) => default is 0 */
cl_git_pass(git_diff_blobs(
old_d, NULL, d, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(2, expected.hunks);
@@ -519,7 +519,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
old_d, NULL, d, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(2, expected.hunks);
@@ -528,7 +528,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
old_d, NULL, d, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.hunks);
@@ -542,7 +542,7 @@ void test_diff_blob__checks_options_version_too_low(void)
opts.version = 0;
cl_git_fail(git_diff_blobs(
d, NULL, alien, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
}
@@ -554,7 +554,7 @@ void test_diff_blob__checks_options_version_too_high(void)
opts.version = 1024;
cl_git_fail(git_diff_blobs(
d, NULL, alien, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
}
@@ -752,7 +752,7 @@ void test_diff_blob__binary_data_comparisons(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
bin, NULL, nonbin, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
/*
@@ -773,7 +773,7 @@ void test_diff_blob__binary_data_comparisons(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
bin, NULL, nonbin, NULL, &opts,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified_with_lines(&expected, 4);
/* cleanup */
@@ -993,8 +993,8 @@ void test_diff_blob__can_compare_buffer_to_buffer(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_buffers(
- a, strlen(a), NULL, b, strlen(b), NULL,
- &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ a, strlen(a), NULL, b, strlen(b), NULL, &opts,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(4, 9, 0, 4, 5, &expected);
opts.flags ^= GIT_DIFF_REVERSE;
@@ -1002,7 +1002,7 @@ void test_diff_blob__can_compare_buffer_to_buffer(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_buffers(
- a, strlen(a), NULL, b, strlen(b), NULL,
- &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
+ a, strlen(a), NULL, b, strlen(b), NULL, &opts,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_one_modified(4, 9, 0, 5, 4, &expected);
}
diff --git a/tests/diff/diff_helpers.c b/tests/diff/diff_helpers.c
index 03862d6..c735257 100644
--- a/tests/diff/diff_helpers.c
+++ b/tests/diff/diff_helpers.c
@@ -91,6 +91,18 @@ int diff_print_file_cb(
return diff_file_cb(delta, progress, payload);
}
+int diff_binary_cb(
+ const git_diff_delta *delta,
+ const git_diff_binary *binary,
+ void *payload)
+{
+ GIT_UNUSED(delta);
+ GIT_UNUSED(binary);
+ GIT_UNUSED(payload);
+
+ return 0;
+}
+
int diff_hunk_cb(
const git_diff_delta *delta,
const git_diff_hunk *hunk,
@@ -145,6 +157,7 @@ int diff_line_cb(
int diff_foreach_via_iterator(
git_diff *diff,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *data)
diff --git a/tests/diff/diff_helpers.h b/tests/diff/diff_helpers.h
index 6bcd1e6..4d3cd34 100644
--- a/tests/diff/diff_helpers.h
+++ b/tests/diff/diff_helpers.h
@@ -42,6 +42,11 @@ extern int diff_print_file_cb(
float progress,
void *cb_data);
+extern int diff_binary_cb(
+ const git_diff_delta *delta,
+ const git_diff_binary *binary,
+ void *cb_data);
+
extern int diff_hunk_cb(
const git_diff_delta *delta,
const git_diff_hunk *hunk,
@@ -56,6 +61,7 @@ extern int diff_line_cb(
extern int diff_foreach_via_iterator(
git_diff *diff,
git_diff_file_cb file_cb,
+ git_diff_binary_cb binary_cb,
git_diff_hunk_cb hunk_cb,
git_diff_line_cb line_cb,
void *data);
diff --git a/tests/diff/index.c b/tests/diff/index.c
index cf883f1..242fb00 100644
--- a/tests/diff/index.c
+++ b/tests/diff/index.c
@@ -35,7 +35,7 @@ void test_diff_index__0(void)
cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
@@ -63,7 +63,7 @@ void test_diff_index__0(void)
cl_git_pass(git_diff_tree_to_index(&diff, g_repo, b, NULL, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
@@ -127,8 +127,8 @@ void test_diff_index__1(void)
cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
- cl_assert_equal_i(
- 1, git_diff_foreach(diff, diff_stop_after_2_files, NULL, NULL, &exp) );
+ cl_assert_equal_i(1, git_diff_foreach(
+ diff, diff_stop_after_2_files, NULL, NULL, NULL, &exp) );
cl_assert_equal_i(2, exp.files);
@@ -193,7 +193,7 @@ static void do_conflicted_diff(diff_expects *exp, unsigned long flags)
cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, index, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, exp));
git_diff_free(diff);
git_tree_free(a);
diff --git a/tests/diff/notify.c b/tests/diff/notify.c
index da7390d..6ef4af5 100644
--- a/tests/diff/notify.c
+++ b/tests/diff/notify.c
@@ -59,7 +59,7 @@ static void test_notify(
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(expected_diffed_files_count, exp.files);
@@ -222,7 +222,7 @@ void test_diff_notify__notify_cb_can_be_used_as_filtering_function(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(0, exp.files);
diff --git a/tests/diff/rename.c b/tests/diff/rename.c
index 8a327f0..5cfd8e2 100644
--- a/tests/diff/rename.c
+++ b/tests/diff/rename.c
@@ -65,7 +65,7 @@ void test_diff_rename__match_oid(void)
*/
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -81,7 +81,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -102,7 +102,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -124,7 +124,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -204,7 +204,7 @@ void test_diff_rename__not_exact_match(void)
*/
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -222,7 +222,7 @@ void test_diff_rename__not_exact_match(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -243,7 +243,7 @@ void test_diff_rename__not_exact_match(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -266,7 +266,7 @@ void test_diff_rename__not_exact_match(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -297,7 +297,7 @@ void test_diff_rename__not_exact_match(void)
*/
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -317,7 +317,7 @@ void test_diff_rename__not_exact_match(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -344,7 +344,7 @@ void test_diff_rename__not_exact_match(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -369,7 +369,7 @@ void test_diff_rename__not_exact_match(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -469,7 +469,7 @@ void test_diff_rename__working_directory_changes(void)
/* git diff --no-renames 2bc7f351d20b53f1c72c16c4b036e491c478c49a */
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -482,7 +482,7 @@ void test_diff_rename__working_directory_changes(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_RENAMED]);
@@ -508,7 +508,7 @@ void test_diff_rename__working_directory_changes(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_RENAMED]);
@@ -527,7 +527,7 @@ void test_diff_rename__working_directory_changes(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
@@ -545,7 +545,7 @@ void test_diff_rename__working_directory_changes(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -575,7 +575,7 @@ void test_diff_rename__working_directory_changes(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -673,7 +673,7 @@ void test_diff_rename__file_exchange(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -682,7 +682,7 @@ void test_diff_rename__file_exchange(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_RENAMED]);
@@ -725,7 +725,7 @@ void test_diff_rename__file_exchange_three(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(3, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -734,7 +734,7 @@ void test_diff_rename__file_exchange_three(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(3, exp.file_status[GIT_DELTA_RENAMED]);
@@ -776,7 +776,7 @@ void test_diff_rename__file_partial_exchange(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -785,7 +785,7 @@ void test_diff_rename__file_partial_exchange(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_ADDED]);
@@ -833,7 +833,7 @@ void test_diff_rename__rename_and_copy_from_same_source(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -843,7 +843,7 @@ void test_diff_rename__rename_and_copy_from_same_source(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_COPIED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -885,7 +885,7 @@ void test_diff_rename__from_deleted_to_split(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -896,7 +896,7 @@ void test_diff_rename__from_deleted_to_split(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
@@ -998,8 +998,8 @@ void test_diff_rename__rejected_match_can_match_others(void)
cl_git_pass(git_diff_find_similar(diff, &findopts));
- cl_git_pass(
- git_diff_foreach(diff, test_names_expected, NULL, NULL, &expect));
+ cl_git_pass(git_diff_foreach(
+ diff, test_names_expected, NULL, NULL, NULL, &expect));
git_diff_free(diff);
git_tree_free(tree);
@@ -1072,8 +1072,8 @@ void test_diff_rename__rejected_match_can_match_others_two(void)
cl_git_pass(git_diff_find_similar(diff, &findopts));
- cl_git_pass(
- git_diff_foreach(diff, test_names_expected, NULL, NULL, &expect));
+ cl_git_pass(git_diff_foreach(
+ diff, test_names_expected, NULL, NULL, NULL, &expect));
cl_assert(expect.idx > 0);
git_diff_free(diff);
@@ -1128,8 +1128,8 @@ void test_diff_rename__rejected_match_can_match_others_three(void)
cl_git_pass(git_diff_find_similar(diff, &findopts));
- cl_git_pass(
- git_diff_foreach(diff, test_names_expected, NULL, NULL, &expect));
+ cl_git_pass(git_diff_foreach(
+ diff, test_names_expected, NULL, NULL, NULL, &expect));
cl_assert(expect.idx == expect.len);
@@ -1177,8 +1177,8 @@ void test_diff_rename__can_rename_from_rewrite(void)
cl_git_pass(git_diff_find_similar(diff, &findopts));
- cl_git_pass(
- git_diff_foreach(diff, test_names_expected, NULL, NULL, &expect));
+ cl_git_pass(git_diff_foreach(
+ diff, test_names_expected, NULL, NULL, NULL, &expect));
cl_assert(expect.idx == expect.len);
@@ -1210,7 +1210,7 @@ void test_diff_rename__case_changes_are_split(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_ADDED]);
@@ -1220,7 +1220,7 @@ void test_diff_rename__case_changes_are_split(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
@@ -1252,7 +1252,7 @@ void test_diff_rename__unmodified_can_be_renamed(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_ADDED]);
@@ -1262,13 +1262,13 @@ void test_diff_rename__unmodified_can_be_renamed(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
@@ -1317,7 +1317,7 @@ void test_diff_rename__rewrite_on_single_file(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
@@ -1352,7 +1352,7 @@ void test_diff_rename__can_find_copy_to_split(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(3, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -1362,7 +1362,7 @@ void test_diff_rename__can_find_copy_to_split(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_COPIED]);
@@ -1401,7 +1401,7 @@ void test_diff_rename__can_delete_unmodified_deltas(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(3, exp.file_status[GIT_DELTA_UNMODIFIED]);
@@ -1411,7 +1411,7 @@ void test_diff_rename__can_delete_unmodified_deltas(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_COPIED]);
@@ -1451,7 +1451,7 @@ void test_diff_rename__matches_config_behavior(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, &opts));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
@@ -1465,7 +1465,7 @@ void test_diff_rename__matches_config_behavior(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, &opts));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_ADDED]);
@@ -1479,7 +1479,7 @@ void test_diff_rename__matches_config_behavior(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, &opts));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -1492,7 +1492,7 @@ void test_diff_rename__matches_config_behavior(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, NULL));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -1535,7 +1535,7 @@ void test_diff_rename__can_override_thresholds_when_obeying_config(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, &opts));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -1549,7 +1549,7 @@ void test_diff_rename__can_override_thresholds_when_obeying_config(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, &opts));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -1590,7 +1590,7 @@ void test_diff_rename__by_config_doesnt_mess_with_whitespace_settings(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_find_similar(diff, &opts));
cl_git_pass(git_diff_foreach(diff,
- diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
@@ -1631,7 +1631,7 @@ static void expect_files_renamed(const char *one, const char *two, uint32_t whit
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
@@ -1686,7 +1686,7 @@ static void expect_files_not_renamed(const char *one, const char *two, uint32_t
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
diff --git a/tests/diff/submodules.c b/tests/diff/submodules.c
index 02870ac..e216958 100644
--- a/tests/diff/submodules.c
+++ b/tests/diff/submodules.c
@@ -465,7 +465,7 @@ void test_diff_submodules__skips_empty_includes_used(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
git_diff_free(diff);
@@ -478,7 +478,7 @@ void test_diff_submodules__skips_empty_includes_used(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
git_diff_free(diff);
@@ -488,7 +488,7 @@ void test_diff_submodules__skips_empty_includes_used(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
git_diff_free(diff);
diff --git a/tests/diff/tree.c b/tests/diff/tree.c
index 6ab49fd..6dd1720 100644
--- a/tests/diff/tree.c
+++ b/tests/diff/tree.c
@@ -49,7 +49,7 @@ void test_diff_tree__0(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(5, expect.files);
cl_assert_equal_i(2, expect.file_status[GIT_DELTA_ADDED]);
@@ -71,7 +71,7 @@ void test_diff_tree__0(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, b, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(2, expect.files);
cl_assert_equal_i(0, expect.file_status[GIT_DELTA_ADDED]);
@@ -158,7 +158,7 @@ void test_diff_tree__options(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, d, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &actual));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &actual));
expected = &test_expects[i];
cl_assert_equal_i(actual.files, expected->files);
@@ -194,7 +194,7 @@ void test_diff_tree__bare(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(3, expect.files);
cl_assert_equal_i(2, expect.file_status[GIT_DELTA_ADDED]);
@@ -235,7 +235,7 @@ void test_diff_tree__merge(void)
git_diff_free(diff2);
cl_git_pass(git_diff_foreach(
- diff1, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ diff1, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(6, expect.files);
cl_assert_equal_i(2, expect.file_status[GIT_DELTA_ADDED]);
@@ -332,7 +332,7 @@ void process_tree_to_tree_diffing(
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &expect));
+ diff, diff_file_cb, NULL, NULL, NULL, &expect));
}
void test_diff_tree__symlink_blob_mode_changed_to_regular_file(void)
@@ -441,8 +441,8 @@ void test_diff_tree__issue_1397(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ cl_git_pass(git_diff_foreach(diff,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(1, expect.files);
cl_assert_equal_i(0, expect.file_status[GIT_DELTA_DELETED]);
@@ -472,8 +472,8 @@ void test_diff_tree__diff_configs(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ cl_git_pass(git_diff_foreach(diff,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(2, expect.files);
cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
@@ -492,8 +492,8 @@ void test_diff_tree__diff_configs(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ cl_git_pass(git_diff_foreach(diff,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(2, expect.files);
cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
@@ -513,8 +513,8 @@ void test_diff_tree__diff_configs(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+ cl_git_pass(git_diff_foreach(diff,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
cl_assert_equal_i(2, expect.files);
cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 65005f9..5d6ebed 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -30,10 +30,10 @@ void test_diff_workdir__to_index(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
@@ -94,7 +94,7 @@ void test_diff_workdir__to_index_with_conflicts(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, &opts));
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(9, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -129,7 +129,7 @@ void test_diff_workdir__to_index_with_assume_unchanged(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(8, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]);
@@ -158,7 +158,7 @@ void test_diff_workdir__to_index_with_assume_unchanged(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(3, exp.file_status[GIT_DELTA_DELETED]);
@@ -205,10 +205,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(14, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -241,10 +241,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(15, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
@@ -278,10 +278,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(16, exp.files);
cl_assert_equal_i(5, exp.file_status[GIT_DELTA_ADDED]);
@@ -312,7 +312,7 @@ void test_diff_workdir__to_tree(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(16, exp.files);
cl_assert_equal_i(5, exp.file_status[GIT_DELTA_DELETED]);
@@ -359,9 +359,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(13, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -382,9 +382,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -405,9 +405,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -428,9 +428,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -465,10 +465,10 @@ void test_diff_workdir__filemode_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -488,10 +488,10 @@ void test_diff_workdir__filemode_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -521,7 +521,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -536,8 +536,8 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL));
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ cl_git_pass(git_diff_foreach(diff,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -580,10 +580,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -601,10 +601,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_w2i, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_w2i, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -624,10 +624,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -666,10 +666,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -693,10 +693,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -720,10 +720,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -913,7 +913,7 @@ void test_diff_workdir__submodules(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
/* so "git diff 873585" returns:
* M .gitmodules
@@ -991,7 +991,7 @@ void test_diff_workdir__to_null_tree(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(exp.files, exp.file_status[GIT_DELTA_UNTRACKED]);
@@ -1080,7 +1080,7 @@ void test_diff_workdir__to_index_issue_1397(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.hunks);
@@ -1096,7 +1096,7 @@ void test_diff_workdir__to_index_issue_1397(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
@@ -1133,7 +1133,7 @@ void test_diff_workdir__to_tree_issue_1397(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.hunks);
@@ -1149,7 +1149,7 @@ void test_diff_workdir__to_tree_issue_1397(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.hunks);
@@ -1203,7 +1203,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1223,7 +1223,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1243,7 +1243,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1267,7 +1267,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1290,7 +1290,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1310,7 +1310,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1333,7 +1333,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1354,7 +1354,7 @@ void test_diff_workdir__untracked_directory_scenarios(void)
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
- cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1505,7 +1505,7 @@ void test_diff_workdir__with_stale_index(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(17, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -1527,7 +1527,7 @@ void test_diff_workdir__with_stale_index(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
git_diff_free(diff);
@@ -1568,7 +1568,7 @@ static void basic_diff_status(git_diff **out, const git_diff_options *opts)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- *out, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+ *out, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(13, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
diff --git a/tests/stress/diff.c b/tests/stress/diff.c
index 0dda44d..a3ba4fa 100644
--- a/tests/stress/diff.c
+++ b/tests/stress/diff.c
@@ -37,7 +37,7 @@ static void test_with_many(int expected_new)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(expected_new + 1, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(expected_new + 2, exp.files);
@@ -47,7 +47,7 @@ static void test_with_many(int expected_new)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
cl_assert_equal_i(expected_new, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(expected_new + 1, exp.files);
@@ -63,7 +63,7 @@ static void test_with_many(int expected_new)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
cl_assert_equal_i(expected_new + 1, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(expected_new + 2, exp.files);
@@ -73,7 +73,7 @@ static void test_with_many(int expected_new)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
cl_assert_equal_i(expected_new, exp.file_status[GIT_DELTA_ADDED]);
cl_assert_equal_i(expected_new + 1, exp.files);