Merge pull request #1087 from libgit2/great-renaming The Great Renaming of 2012
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 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17e4ff2..fc53077 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -204,7 +204,7 @@ IF (BUILD_CLAR)
ADD_CUSTOM_COMMAND(
OUTPUT ${CLAR_PATH}/clar_main.c ${CLAR_PATH}/clar.h
- COMMAND ${PYTHON_EXECUTABLE} clar -vtap .
+ COMMAND ${PYTHON_EXECUTABLE} clar .
DEPENDS ${CLAR_PATH}/clar ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH}
)
diff --git a/examples/diff.c b/examples/diff.c
index 38231d2..a465182 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -30,7 +30,7 @@ static int resolve_to_tree(
git_reference_resolve(&resolved, ref);
git_reference_free(ref);
if (resolved) {
- git_object_lookup(&obj, repo, git_reference_oid(resolved), GIT_OBJ_ANY);
+ git_object_lookup(&obj, repo, git_reference_target(resolved), GIT_OBJ_ANY);
git_reference_free(resolved);
}
}
@@ -63,12 +63,12 @@ char *colors[] = {
};
static int printer(
- void *data,
const git_diff_delta *delta,
const git_diff_range *range,
char usage,
const char *line,
- size_t line_len)
+ size_t line_len,
+ void *data)
{
int *last_color = data, color = 0;
@@ -225,9 +225,9 @@ int main(int argc, char *argv[])
fputs(colors[0], stdout);
if (compact)
- check(git_diff_print_compact(diff, &color, printer), "Displaying diff");
+ check(git_diff_print_compact(diff, printer, &color), "Displaying diff");
else
- check(git_diff_print_patch(diff, &color, printer), "Displaying diff");
+ check(git_diff_print_patch(diff, printer, &color), "Displaying diff");
if (color >= 0)
fputs(colors[0], stdout);
diff --git a/examples/general.c b/examples/general.c
index 9ccb4c5..9ea264e 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -261,8 +261,8 @@ int main (int argc, char** argv)
git_tree_lookup(&tree, repo, &oid);
// Getting the count of entries in the tree so you can iterate over them if you want to.
- int cnt = git_tree_entrycount(tree); // 3
- printf("tree entries: %d\n", cnt);
+ size_t cnt = git_tree_entrycount(tree); // 3
+ printf("tree entries: %d\n", (int)cnt);
entry = git_tree_entry_byindex(tree, 0);
printf("Entry name: %s\n", git_tree_entry_name(entry)); // "hello.c"
@@ -298,7 +298,7 @@ int main (int argc, char** argv)
// Note that this buffer may not be contain ASCII data for certain blobs (e.g. binary files):
// do not consider the buffer a NULL-terminated string, and use the `git_blob_rawsize` attribute to
// find out its exact size in bytes
- printf("Blob Size: %ld\n", git_blob_rawsize(blob)); // 8
+ printf("Blob Size: %ld\n", (long)git_blob_rawsize(blob)); // 8
git_blob_rawcontent(blob); // "content"
// ### Revwalking
@@ -371,7 +371,7 @@ int main (int argc, char** argv)
// All these properties are exported publicly in the `git_index_entry` struct
ecount = git_index_entrycount(index);
for (i = 0; i < ecount; ++i) {
- git_index_entry *e = git_index_get_byindex(index, i);
+ const git_index_entry *e = git_index_get_byindex(index, i);
printf("path: %s\n", e->path);
printf("mtime: %d\n", (int)e->mtime.seconds);
@@ -405,12 +405,12 @@ int main (int argc, char** argv)
switch (git_reference_type(ref)) {
case GIT_REF_OID:
- git_oid_fmt(out, git_reference_oid(ref));
+ git_oid_fmt(out, git_reference_target(ref));
printf("%s [%s]\n", refname, out);
break;
case GIT_REF_SYMBOLIC:
- printf("%s => %s\n", refname, git_reference_target(ref));
+ printf("%s => %s\n", refname, git_reference_symbolic_target(ref));
break;
default:
fprintf(stderr, "Unexpected reference type\n");
diff --git a/examples/network/clone.c b/examples/network/clone.c
index 30a4944..a718f30 100644
--- a/examples/network/clone.c
+++ b/examples/network/clone.c
@@ -72,7 +72,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
checkout_opts.progress_payload = &pd;
// Do the clone
- error = git_clone(&cloned_repo, url, path, &fetch_progress, &pd, &checkout_opts);
+ error = git_clone(&cloned_repo, url, path, &checkout_opts, &fetch_progress, &pd);
printf("\n");
if (error != 0) {
const git_error *err = giterr_last();
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 9d1404a..e341d2d 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -25,7 +25,7 @@ static void *download(void *ptr)
// Connect to the remote end specifying that we want to fetch
// information from it.
- if (git_remote_connect(data->remote, GIT_DIR_FETCH) < 0) {
+ if (git_remote_connect(data->remote, GIT_DIRECTION_FETCH) < 0) {
data->ret = -1;
goto exit;
}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 822d6f6..62131d4 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -27,7 +27,7 @@ static int use_unnamed(git_repository *repo, const char *url)
// When connecting, the underlying code needs to know wether we
// want to push or fetch
- error = git_remote_connect(remote, GIT_DIR_FETCH);
+ error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
if (error < 0)
goto cleanup;
@@ -49,7 +49,7 @@ static int use_remote(git_repository *repo, char *name)
if (error < 0)
goto cleanup;
- error = git_remote_connect(remote, GIT_DIR_FETCH);
+ error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
if (error < 0)
goto cleanup;
diff --git a/include/git2/attr.h b/include/git2/attr.h
index 2de9f4b..b1a7e0e 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -183,6 +183,8 @@ GIT_EXTERN(int) git_attr_get_many(
size_t num_attr,
const char **names);
+typedef int (*git_attr_foreach_cb)(const char *name, const char *value, void *payload);
+
/**
* Loop over all the git attributes for a path.
*
@@ -204,7 +206,7 @@ GIT_EXTERN(int) git_attr_foreach(
git_repository *repo,
uint32_t flags,
const char *path,
- int (*callback)(const char *name, const char *value, void *payload),
+ git_attr_foreach_cb callback,
void *payload);
/**
diff --git a/include/git2/blob.h b/include/git2/blob.h
index f0719f1..a68c78b 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -68,6 +68,17 @@ GIT_INLINE(void) git_blob_free(git_blob *blob)
git_object_free((git_object *) blob);
}
+/**
+ * Get the id of a blob.
+ *
+ * @param blob a previously loaded blob.
+ * @return SHA1 hash for this blob.
+ */
+GIT_INLINE(const git_oid *) git_blob_id(const git_blob *blob)
+{
+ return git_object_id((const git_object *)blob);
+}
+
/**
* Get a read-only buffer with the raw content of a blob.
@@ -88,32 +99,35 @@ GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob);
* @param blob pointer to the blob
* @return size on bytes
*/
-GIT_EXTERN(size_t) git_blob_rawsize(git_blob *blob);
+GIT_EXTERN(git_off_t) git_blob_rawsize(git_blob *blob);
/**
* Read a file from the working folder of a repository
* and write it to the Object Database as a loose blob
*
- * @param oid return the id of the written blob
+ * @param id return the id of the written blob
* @param repo repository where the blob will be written.
* this repository cannot be bare
- * @param path file from which the blob will be created,
+ * @param relative_path file from which the blob will be created,
* relative to the repository's working dir
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path);
+GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
/**
* Read a file from the filesystem and write its content
* to the Object Database as a loose blob
*
- * @param oid return the id of the written blob
+ * @param id return the id of the written blob
* @param repo repository where the blob will be written.
* this repository can be bare or not
* @param path file from which the blob will be created
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, const char *path);
+GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
+
+
+typedef int (*git_blob_chunk_cb)(char *content, size_t max_length, void *payload);
/**
* Write a loose blob to the Object Database from a
@@ -141,7 +155,7 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con
* - When an error occurs, the callback should return -1.
*
*
- * @param oid Return the id of the written blob
+ * @param id Return the id of the written blob
*
* @param repo repository where the blob will be written.
* This repository can be bare or not.
@@ -152,10 +166,10 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_blob_create_fromchunks(
- git_oid *oid,
+ git_oid *id,
git_repository *repo,
const char *hintpath,
- int (*source_cb)(char *content, size_t max_length, void *payload),
+ git_blob_chunk_cb callback,
void *payload);
/**
diff --git a/include/git2/branch.h b/include/git2/branch.h
index f06609a..c9ae9cc 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -29,7 +29,7 @@ GIT_BEGIN_DECL
*
* The returned reference must be freed by the user.
*
- * @param branch_out Pointer where to store the underlying reference.
+ * @param out Pointer where to store the underlying reference.
*
* @param branch_name Name for the branch; this name is
* validated for consistency. It should also not conflict with
@@ -47,10 +47,10 @@ GIT_BEGIN_DECL
* pointing to the provided target commit.
*/
GIT_EXTERN(int) git_branch_create(
- git_reference **branch_out,
+ git_reference **out,
git_repository *repo,
const char *branch_name,
- const git_object *target,
+ const git_commit *target,
int force);
/**
@@ -113,7 +113,7 @@ GIT_EXTERN(int) git_branch_move(
*
* The generated reference must be freed by the user.
*
- * @param branch_out pointer to the looked-up branch reference
+ * @param out pointer to the looked-up branch reference
*
* @param repo the repository to look up the branch
*
@@ -127,7 +127,7 @@ GIT_EXTERN(int) git_branch_move(
* exists, otherwise an error code.
*/
GIT_EXTERN(int) git_branch_lookup(
- git_reference **branch_out,
+ git_reference **out,
git_repository *repo,
const char *branch_name,
git_branch_t branch_type);
@@ -136,7 +136,7 @@ GIT_EXTERN(int) git_branch_lookup(
* Return the reference supporting the remote tracking branch,
* given a local branch reference.
*
- * @param tracking_out Pointer where to store the retrieved
+ * @param out Pointer where to store the retrieved
* reference.
*
* @param branch Current underlying reference of the branch.
@@ -145,7 +145,7 @@ GIT_EXTERN(int) git_branch_lookup(
* reference exists, otherwise an error code.
*/
GIT_EXTERN(int) git_branch_tracking(
- git_reference **tracking_out,
+ git_reference **out,
git_reference *branch);
/**
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index 27ecc71..bd988db 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -146,8 +146,12 @@ typedef enum {
* Checkout options structure
*
* Use zeros to indicate default settings.
+ * This needs to be initialized with the `GIT_CHECKOUT_OPTS_INIT` macro:
+ *
+ * git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
*/
typedef struct git_checkout_opts {
+ unsigned int version;
unsigned int checkout_strategy; /** default will be a dry run */
int disable_filters; /** don't apply filters like CRLF conversion */
@@ -182,6 +186,8 @@ typedef struct git_checkout_opts {
git_strarray paths;
} git_checkout_opts;
+#define GIT_CHECKOUT_OPTS_INIT {1, 0}
+
/**
* Updates files in the index and the working tree to match the content of the
* commit pointed at by HEAD.
@@ -223,7 +229,7 @@ GIT_EXTERN(int) git_checkout_index(
*/
GIT_EXTERN(int) git_checkout_tree(
git_repository *repo,
- git_object *treeish,
+ const git_object *treeish,
git_checkout_opts *opts);
/** @} */
diff --git a/include/git2/clone.h b/include/git2/clone.h
index 7d8d321..2a02723 100644
--- a/include/git2/clone.h
+++ b/include/git2/clone.h
@@ -42,9 +42,9 @@ GIT_EXTERN(int) git_clone(
git_repository **out,
const char *origin_url,
const char *workdir_path,
+ git_checkout_opts *checkout_opts,
git_transfer_progress_callback fetch_progress_cb,
- void *fetch_progress_payload,
- git_checkout_opts *checkout_opts);
+ void *fetch_progress_payload);
/**
* Create a bare clone of a remote repository.
diff --git a/include/git2/commit.h b/include/git2/commit.h
index a159b79..872f691 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -76,7 +76,10 @@ GIT_INLINE(void) git_commit_free(git_commit *commit)
* @param commit a previously loaded commit.
* @return object identity for the commit.
*/
-GIT_EXTERN(const git_oid *) git_commit_id(git_commit *commit);
+GIT_INLINE(const git_oid *) git_commit_id(const git_commit *commit)
+{
+ return git_object_id((const git_object *)commit);
+}
/**
* Get the encoding for the message of a commit,
@@ -88,7 +91,7 @@ GIT_EXTERN(const git_oid *) git_commit_id(git_commit *commit);
* @param commit a previously loaded commit.
* @return NULL, or the encoding
*/
-GIT_EXTERN(const char *) git_commit_message_encoding(git_commit *commit);
+GIT_EXTERN(const char *) git_commit_message_encoding(const git_commit *commit);
/**
* Get the full message of a commit.
@@ -96,7 +99,7 @@ GIT_EXTERN(const char *) git_commit_message_encoding(git_commit *commit);
* @param commit a previously loaded commit.
* @return the message of a commit
*/
-GIT_EXTERN(const char *) git_commit_message(git_commit *commit);
+GIT_EXTERN(const char *) git_commit_message(const git_commit *commit);
/**
* Get the commit time (i.e. committer time) of a commit.
@@ -104,7 +107,7 @@ GIT_EXTERN(const char *) git_commit_message(git_commit *commit);
* @param commit a previously loaded commit.
* @return the time of a commit
*/
-GIT_EXTERN(git_time_t) git_commit_time(git_commit *commit);
+GIT_EXTERN(git_time_t) git_commit_time(const git_commit *commit);
/**
* Get the commit timezone offset (i.e. committer's preferred timezone) of a commit.
@@ -112,7 +115,7 @@ GIT_EXTERN(git_time_t) git_commit_time(git_commit *commit);
* @param commit a previously loaded commit.
* @return positive or negative timezone offset, in minutes from UTC
*/
-GIT_EXTERN(int) git_commit_time_offset(git_commit *commit);
+GIT_EXTERN(int) git_commit_time_offset(const git_commit *commit);
/**
* Get the committer of a commit.
@@ -120,7 +123,7 @@ GIT_EXTERN(int) git_commit_time_offset(git_commit *commit);
* @param commit a previously loaded commit.
* @return the committer of a commit
*/
-GIT_EXTERN(const git_signature *) git_commit_committer(git_commit *commit);
+GIT_EXTERN(const git_signature *) git_commit_committer(const git_commit *commit);
/**
* Get the author of a commit.
@@ -128,7 +131,7 @@ GIT_EXTERN(const git_signature *) git_commit_committer(git_commit *commit);
* @param commit a previously loaded commit.
* @return the author of a commit
*/
-GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
+GIT_EXTERN(const git_signature *) git_commit_author(const git_commit *commit);
/**
* Get the tree pointed to by a commit.
@@ -137,7 +140,7 @@ GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
* @param commit a previously loaded commit.
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
+GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, const git_commit *commit);
/**
* Get the id of the tree pointed to by a commit. This differs from
@@ -147,7 +150,7 @@ GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
* @param commit a previously loaded commit.
* @return the id of tree pointed to by commit.
*/
-GIT_EXTERN(const git_oid *) git_commit_tree_oid(git_commit *commit);
+GIT_EXTERN(const git_oid *) git_commit_tree_id(const git_commit *commit);
/**
* Get the number of parents of this commit
@@ -155,17 +158,17 @@ GIT_EXTERN(const git_oid *) git_commit_tree_oid(git_commit *commit);
* @param commit a previously loaded commit.
* @return integer of count of parents
*/
-GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
+GIT_EXTERN(unsigned int) git_commit_parentcount(const git_commit *commit);
/**
* Get the specified parent of the commit.
*
- * @param parent Pointer where to store the parent commit
+ * @param out Pointer where to store the parent commit
* @param commit a previously loaded commit.
* @param n the position of the parent (from 0 to `parentcount`)
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n);
+GIT_EXTERN(int) git_commit_parent(git_commit **out, git_commit *commit, unsigned int n);
/**
* Get the oid of a specified parent for a commit. This is different from
@@ -176,7 +179,7 @@ GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsig
* @param n the position of the parent (from 0 to `parentcount`)
* @return the id of the parent, NULL on error.
*/
-GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n);
+GIT_EXTERN(const git_oid *) git_commit_parent_id(git_commit *commit, unsigned int n);
/**
* Get the commit object that is the <n>th generation ancestor
@@ -204,7 +207,7 @@ GIT_EXTERN(int) git_commit_nth_gen_ancestor(
* The message will not be cleaned up. This can be achieved
* through `git_message_prettify()`.
*
- * @param oid Pointer where to store the OID of the
+ * @param id Pointer where to store the OID of the
* newly created commit
*
* @param repo Repository where to store the commit
@@ -245,7 +248,7 @@ GIT_EXTERN(int) git_commit_nth_gen_ancestor(
* the given reference will be updated to point to it
*/
GIT_EXTERN(int) git_commit_create(
- git_oid *oid,
+ git_oid *id,
git_repository *repo,
const char *update_ref,
const git_signature *author,
@@ -273,7 +276,7 @@ GIT_EXTERN(int) git_commit_create(
* @see git_commit_create
*/
GIT_EXTERN(int) git_commit_create_v(
- git_oid *oid,
+ git_oid *id,
git_repository *repo,
const char *update_ref,
const git_signature *author,
diff --git a/include/git2/config.h b/include/git2/config.h
index 8ec78e3..af4d540 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -41,23 +41,26 @@ typedef struct {
unsigned int level;
} git_config_entry;
+typedef int (*git_config_foreach_cb)(const git_config_entry *, void *);
+
+
/**
* Generic backend that implements the interface to
* access a configuration file
*/
-struct git_config_file {
+struct git_config_backend {
struct git_config *cfg;
/* Open means open the file/database and parse if necessary */
- int (*open)(struct git_config_file *, unsigned int level);
- int (*get)(struct git_config_file *, const char *key, const git_config_entry **entry);
- int (*get_multivar)(struct git_config_file *, const char *key, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
- int (*set)(struct git_config_file *, const char *key, const char *value);
- int (*set_multivar)(git_config_file *cfg, const char *name, const char *regexp, const char *value);
- int (*del)(struct git_config_file *, const char *key);
- int (*foreach)(struct git_config_file *, const char *, int (*fn)(const git_config_entry *, void *), void *data);
- int (*refresh)(struct git_config_file *);
- void (*free)(struct git_config_file *);
+ int (*open)(struct git_config_backend *, unsigned int level);
+ int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
+ int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
+ int (*set)(struct git_config_backend *, const char *key, const char *value);
+ int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
+ int (*del)(struct git_config_backend *, const char *key);
+ int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
+ int (*refresh)(struct git_config_backend *);
+ void (*free)(struct git_config_backend *);
};
typedef enum {
@@ -87,11 +90,11 @@ typedef struct {
* This method will not guess the path to the xdg compatible
* config file (.config/git/config).
*
- * @param global_config_path Buffer of GIT_PATH_MAX length to store the path
- * @return 0 if a global configuration file has been
- * found. Its path will be stored in `buffer`.
+ * @param out Buffer to store the path in
+ * @param length size of the buffer in bytes
+ * @return 0 if a global configuration file has been found. Its path will be stored in `buffer`.
*/
-GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
+GIT_EXTERN(int) git_config_find_global(char *out, size_t length);
/**
* Locate the path to the global xdg compatible configuration file
@@ -104,11 +107,12 @@ GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
* may be used on any `git_config` call to load the
* xdg compatible configuration file.
*
- * @param xdg_config_path Buffer of GIT_PATH_MAX length to store the path
+ * @param out Buffer to store the path in
+ * @param length size of the buffer in bytes
* @return 0 if a xdg compatible configuration file has been
* found. Its path will be stored in `buffer`.
*/
-GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
+GIT_EXTERN(int) git_config_find_xdg(char *out, size_t length);
/**
* Locate the path to the system configuration file
@@ -116,11 +120,12 @@ GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
* If /etc/gitconfig doesn't exist, it will look for
* %PROGRAMFILES%\Git\etc\gitconfig.
- * @param system_config_path Buffer of GIT_PATH_MAX length to store the path
+ * @param global_config_path Buffer to store the path in
+ * @param length size of the buffer in bytes
* @return 0 if a system configuration file has been
* found. Its path will be stored in `buffer`.
*/
-GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
+GIT_EXTERN(int) git_config_find_system(char *out, size_t length);
/**
* Open the global, XDG and system configuration files
@@ -163,9 +168,9 @@ GIT_EXTERN(int) git_config_new(git_config **out);
* @return 0 on success, GIT_EEXISTS when adding more than one file
* for a given priority level (and force_replace set to 0), or error code
*/
-GIT_EXTERN(int) git_config_add_file(
+GIT_EXTERN(int) git_config_add_backend(
git_config *cfg,
- git_config_file *file,
+ git_config_backend *file,
unsigned int level,
int force);
@@ -223,12 +228,15 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
* will return different config instances, but containing the same config_file
* instance.
*
+ * @param out The configuration instance to create
+ * @param parent Multi-level config to search for the given level
+ * @param level Configuration level to search for
* @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
* multi-level parent config, or an error code
*/
GIT_EXTERN(int) git_config_open_level(
- git_config **cfg_out,
- git_config *cfg_parent,
+ git_config **out,
+ const git_config *parent,
unsigned int level);
/**
@@ -262,7 +270,10 @@ GIT_EXTERN(void) git_config_free(git_config *cfg);
* @param name the variable's name
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_entry(
+ const git_config_entry **out,
+ const git_config *cfg,
+ const char *name);
/**
* Get the value of an integer config variable.
@@ -276,7 +287,7 @@ GIT_EXTERN(int) git_config_get_entry(const git_config_entry **out, git_config *c
* @param name the variable's name
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name);
/**
* Get the value of a long integer config variable.
@@ -290,7 +301,7 @@ GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *
* @param name the variable's name
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name);
/**
* Get the value of a boolean config variable.
@@ -307,7 +318,7 @@ GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *
* @param name the variable's name
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name);
/**
* Get the value of a string config variable.
@@ -324,7 +335,7 @@ GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name)
* @param name the variable's name
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name);
/**
* Get each value of a multivar.
@@ -338,7 +349,7 @@ GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const c
* @param fn the function to be called on each value of the variable
* @param data opaque pointer to pass to the callback
*/
-GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
+GIT_EXTERN(int) git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
/**
* Set the value of an integer config variable in the config file
@@ -404,7 +415,7 @@ GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const
* @param cfg the configuration
* @param name the variable to delete
*/
-GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name);
/**
* Perform an operation on each config variable.
@@ -420,8 +431,8 @@ GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
GIT_EXTERN(int) git_config_foreach(
- git_config *cfg,
- int (*callback)(const git_config_entry *, void *payload),
+ const git_config *cfg,
+ git_config_foreach_cb callback,
void *payload);
/**
@@ -438,9 +449,9 @@ GIT_EXTERN(int) git_config_foreach(
* @return 0 or the return value of the callback which didn't return 0
*/
GIT_EXTERN(int) git_config_foreach_match(
- git_config *cfg,
+ const git_config *cfg,
const char *regexp,
- int (*callback)(const git_config_entry *entry, void *payload),
+ git_config_foreach_cb callback,
void *payload);
/**
@@ -477,7 +488,12 @@ GIT_EXTERN(int) git_config_foreach_match(
* @param map_n number of mapping objects in `maps`
* @return 0 on success, error code otherwise
*/
-GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n);
+GIT_EXTERN(int) git_config_get_mapped(
+ int *out,
+ const git_config *cfg,
+ const char *name,
+ const git_cvar_map *maps,
+ size_t map_n);
/**
* Maps a string value to an integer constant
@@ -489,7 +505,7 @@ GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *nam
*/
GIT_EXTERN(int) git_config_lookup_map_value(
int *out,
- git_cvar_map *maps,
+ const git_cvar_map *maps,
size_t map_n,
const char *value);
@@ -506,7 +522,7 @@ GIT_EXTERN(int) git_config_lookup_map_value(
GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
/**
- * Parse a string value as an int64.
+ * Parse a string value as an int32.
*
* An optional value suffix of 'k', 'm', or 'g' will
* cause the value to be multiplied by 1024, 1048576,
@@ -515,10 +531,10 @@ GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
* @param out place to store the result of the parsing
* @param value value to parse
*/
-GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
+GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
/**
- * Parse a string value as an int32.
+ * Parse a string value as an int64.
*
* An optional value suffix of 'k', 'm', or 'g' will
* cause the value to be multiplied by 1024, 1048576,
@@ -527,7 +543,7 @@ GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
* @param out place to store the result of the parsing
* @param value value to parse
*/
-GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
+GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
/** @} */
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 47bfa5f..fd00378 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -106,6 +106,7 @@ typedef enum {
* - max_size: maximum blob size to diff, above this treated as binary
*/
typedef struct {
+ unsigned int version; /**< version for the struct */
uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */
uint16_t context_lines; /**< defaults to 3 */
uint16_t interhunk_lines; /**< defaults to 0 */
@@ -186,10 +187,10 @@ typedef struct {
/**
* When iterating over a diff, callback that will be made per file.
*/
-typedef int (*git_diff_file_fn)(
- void *cb_data,
+typedef int (*git_diff_file_cb)(
const git_diff_delta *delta,
- float progress);
+ float progress,
+ void *payload);
/**
* Structure describing a hunk of a diff.
@@ -204,31 +205,31 @@ typedef struct {
/**
* When iterating over a diff, callback that will be made per hunk.
*/
-typedef int (*git_diff_hunk_fn)(
- void *cb_data,
+typedef int (*git_diff_hunk_cb)(
const git_diff_delta *delta,
const git_diff_range *range,
const char *header,
- size_t header_len);
+ size_t header_len,
+ void *payload);
/**
* Line origin constants.
*
* These values describe where a line came from and will be passed to
- * the git_diff_data_fn when iterating over a diff. There are some
+ * the git_diff_data_cb when iterating over a diff. There are some
* special origin constants at the end that are used for the text
* output callbacks to demarcate lines that are actually part of
* the file or hunk headers.
*/
typedef enum {
- /* These values will be sent to `git_diff_data_fn` along with the line */
+ /* These values will be sent to `git_diff_data_cb` along with the line */
GIT_DIFF_LINE_CONTEXT = ' ',
GIT_DIFF_LINE_ADDITION = '+',
GIT_DIFF_LINE_DELETION = '-',
GIT_DIFF_LINE_ADD_EOFNL = '\n', /**< Removed line w/o LF & added one with */
GIT_DIFF_LINE_DEL_EOFNL = '\0', /**< LF was removed at end of file */
- /* The following values will only be sent to a `git_diff_data_fn` when
+ /* The following values will only be sent to a `git_diff_data_cb` when
* the content of a diff is being formatted (eg. through
* git_diff_print_patch() or git_diff_print_compact(), for instance).
*/
@@ -245,13 +246,13 @@ typedef enum {
* of text. This uses some extra GIT_DIFF_LINE_... constants for output
* of lines of file and hunk headers.
*/
-typedef int (*git_diff_data_fn)(
- void *cb_data,
+typedef int (*git_diff_data_cb)(
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin, /**< GIT_DIFF_LINE_... value from above */
const char *content,
- size_t content_len);
+ size_t content_len,
+ void *payload);
/**
* The diff patch is used to store all the text diffs for a delta.
@@ -283,6 +284,8 @@ typedef enum {
* Control behavior of rename and copy detection
*/
typedef struct {
+ unsigned int version;
+
/** Combination of git_diff_find_t values (default FIND_RENAMES) */
unsigned int flags;
@@ -461,7 +464,6 @@ GIT_EXTERN(int) git_diff_find_similar(
* the iteration and cause this return `GIT_EUSER`.
*
* @param diff A git_diff_list generated by one of the above functions.
- * @param cb_data Reference pointer that will be passed to your callbacks.
* @param file_cb Callback function to make per file in the diff.
* @param hunk_cb Optional callback to make per hunk of text diff. This
* callback is called to describe a range of lines in the
@@ -469,14 +471,15 @@ GIT_EXTERN(int) git_diff_find_similar(
* @param line_cb Optional callback to make per line of diff text. This
* same callback will be made for context lines, added, and
* removed lines, and even for a deleted trailing newline.
+ * @param payload Reference pointer that will be passed to your callbacks.
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
GIT_EXTERN(int) git_diff_foreach(
git_diff_list *diff,
- void *cb_data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn line_cb);
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb line_cb,
+ void *payload);
/**
* Iterate over a diff generating text output like "git diff --name-status".
@@ -485,14 +488,14 @@ GIT_EXTERN(int) git_diff_foreach(
* iteration and cause this return `GIT_EUSER`.
*
* @param diff A git_diff_list generated by one of the above functions.
- * @param cb_data Reference pointer that will be passed to your callback.
* @param print_cb Callback to make per line of diff text.
+ * @param payload Reference pointer that will be passed to your callback.
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
GIT_EXTERN(int) git_diff_print_compact(
git_diff_list *diff,
- void *cb_data,
- git_diff_data_fn print_cb);
+ git_diff_data_cb print_cb,
+ void *payload);
/**
* Look up the single character abbreviation for a delta status code.
@@ -517,7 +520,7 @@ GIT_EXTERN(char) git_diff_status_char(git_delta_t status);
* iteration and cause this return `GIT_EUSER`.
*
* @param diff A git_diff_list generated by one of the above functions.
- * @param cb_data Reference pointer that will be passed to your callbacks.
+ * @param payload Reference pointer that will be passed to your callbacks.
* @param print_cb Callback function to output lines of the diff. This
* same function will be called for file headers, hunk
* headers, and diff lines. Fortunately, you can probably
@@ -527,8 +530,8 @@ GIT_EXTERN(char) git_diff_status_char(git_delta_t status);
*/
GIT_EXTERN(int) git_diff_print_patch(
git_diff_list *diff,
- void *cb_data,
- git_diff_data_fn print_cb);
+ git_diff_data_cb print_cb,
+ void *payload);
/**
* Query how many diff records are there in a diff list.
@@ -572,15 +575,15 @@ GIT_EXTERN(size_t) git_diff_num_deltas_of_type(
* It is okay to pass NULL for either of the output parameters; if you pass
* NULL for the `git_diff_patch`, then the text diff will not be calculated.
*
- * @param patch Output parameter for the delta patch object
- * @param delta Output parameter for the delta object
+ * @param patch_out Output parameter for the delta patch object
+ * @param delta_out Output parameter for the delta object
* @param diff Diff list object
* @param idx Index into diff list
* @return 0 on success, other value < 0 on error
*/
GIT_EXTERN(int) git_diff_get_patch(
- git_diff_patch **patch,
- const git_diff_delta **delta,
+ git_diff_patch **patch_out,
+ const git_diff_delta **delta_out,
git_diff_list *diff,
size_t idx);
@@ -672,15 +675,15 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
* and cause this return `GIT_EUSER`.
*
* @param patch A git_diff_patch representing changes to one file
- * @param cb_data Reference pointer that will be passed to your callbacks.
* @param print_cb Callback function to output lines of the patch. Will be
* called for file headers, hunk headers, and diff lines.
+ * @param payload Reference pointer that will be passed to your callbacks.
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
GIT_EXTERN(int) git_diff_patch_print(
git_diff_patch *patch,
- void *cb_data,
- git_diff_data_fn print_cb);
+ git_diff_data_cb print_cb,
+ void *payload);
/**
* Get the content of a patch as a single diff text.
@@ -718,10 +721,10 @@ GIT_EXTERN(int) git_diff_blobs(
git_blob *old_blob,
git_blob *new_blob,
const git_diff_options *options,
- void *cb_data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn line_cb);
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb line_cb,
+ void *payload);
GIT_END_DECL
diff --git a/include/git2/index.h b/include/git2/index.h
index 8e1a7e5..fa9a197 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -21,10 +21,10 @@
*/
GIT_BEGIN_DECL
-#define GIT_IDXENTRY_NAMEMASK (0x0fff)
+#define GIT_IDXENTRY_NAMEMASK (0x0fff)
#define GIT_IDXENTRY_STAGEMASK (0x3000)
-#define GIT_IDXENTRY_EXTENDED (0x4000)
-#define GIT_IDXENTRY_VALID (0x8000)
+#define GIT_IDXENTRY_EXTENDED (0x4000)
+#define GIT_IDXENTRY_VALID (0x8000)
#define GIT_IDXENTRY_STAGESHIFT 12
/*
@@ -34,26 +34,26 @@ GIT_BEGIN_DECL
*
* In-memory only flags:
*/
-#define GIT_IDXENTRY_UPDATE (1 << 0)
-#define GIT_IDXENTRY_REMOVE (1 << 1)
-#define GIT_IDXENTRY_UPTODATE (1 << 2)
-#define GIT_IDXENTRY_ADDED (1 << 3)
+#define GIT_IDXENTRY_UPDATE (1 << 0)
+#define GIT_IDXENTRY_REMOVE (1 << 1)
+#define GIT_IDXENTRY_UPTODATE (1 << 2)
+#define GIT_IDXENTRY_ADDED (1 << 3)
-#define GIT_IDXENTRY_HASHED (1 << 4)
-#define GIT_IDXENTRY_UNHASHED (1 << 5)
-#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
-#define GIT_IDXENTRY_CONFLICTED (1 << 7)
+#define GIT_IDXENTRY_HASHED (1 << 4)
+#define GIT_IDXENTRY_UNHASHED (1 << 5)
+#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
+#define GIT_IDXENTRY_CONFLICTED (1 << 7)
-#define GIT_IDXENTRY_UNPACKED (1 << 8)
+#define GIT_IDXENTRY_UNPACKED (1 << 8)
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
/*
* Extended on-disk flags:
*/
-#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
-#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
+#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
+#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
/* GIT_IDXENTRY_EXTENDED2 is for future extension */
-#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
+#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
@@ -119,11 +119,11 @@ enum {
*
* The index must be freed once it's no longer in use.
*
- * @param index the pointer for the new index
+ * @param out the pointer for the new index
* @param index_path the path to the index file in disk
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_index_open(git_index **index, const char *index_path);
+GIT_EXTERN(int) git_index_open(git_index **out, const char *index_path);
/**
* Create an in-memory index object.
@@ -133,10 +133,10 @@ GIT_EXTERN(int) git_index_open(git_index **index, const char *index_path);
*
* The index must be freed once it's no longer in use.
*
- * @param index the pointer for the new index
+ * @param out the pointer for the new index
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_index_new(git_index **index);
+GIT_EXTERN(int) git_index_new(git_index **out);
/**
* Free an existing index object.
@@ -201,7 +201,7 @@ GIT_EXTERN(int) git_index_write(git_index *index);
* @param tree tree to read
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
+GIT_EXTERN(int) git_index_read_tree(git_index *index, const git_tree *tree);
/**
* Write the index as a tree
@@ -217,12 +217,12 @@ GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
*
* The index must not contain any file in conflict.
*
- * @param oid Pointer where to store the OID of the written tree
+ * @param out Pointer where to store the OID of the written tree
* @param index Index to write
* @return 0 on success, GIT_EUNMERGED when the index is not clean
* or an error code
*/
-GIT_EXTERN(int) git_index_write_tree(git_oid *oid, git_index *index);
+GIT_EXTERN(int) git_index_write_tree(git_oid *out, git_index *index);
/**
* Write the index as a tree to the given repository
@@ -233,13 +233,13 @@ GIT_EXTERN(int) git_index_write_tree(git_oid *oid, git_index *index);
*
* The index must not contain any file in conflict.
*
- * @param oid Pointer where to store OID of the the written tree
+ * @param out Pointer where to store OID of the the written tree
* @param index Index to write
* @param repo Repository where to write the tree
* @return 0 on success, GIT_EUNMERGED when the index is not clean
* or an error code
*/
-GIT_EXTERN(int) git_index_write_tree_to(git_oid *oid, git_index *index, git_repository *repo);
+GIT_EXTERN(int) git_index_write_tree_to(git_oid *out, git_index *index, git_repository *repo);
/**@}*/
@@ -258,7 +258,7 @@ GIT_EXTERN(int) git_index_write_tree_to(git_oid *oid, git_index *index, git_repo
* @param index an existing index object
* @return integer of count of current entries
*/
-GIT_EXTERN(unsigned int) git_index_entrycount(git_index *index);
+GIT_EXTERN(size_t) git_index_entrycount(const git_index *index);
/**
* Clear the contents (all the entries) of an index object.
@@ -282,7 +282,8 @@ GIT_EXTERN(void) git_index_clear(git_index *index);
* @param n the position of the entry
* @return a pointer to the entry; NULL if out of bounds
*/
-GIT_EXTERN(git_index_entry *) git_index_get_byindex(git_index *index, size_t n);
+GIT_EXTERN(const git_index_entry *) git_index_get_byindex(
+ git_index *index, size_t n);
/**
* Get a pointer to one of the entries in the index
@@ -298,7 +299,8 @@ GIT_EXTERN(git_index_entry *) git_index_get_byindex(git_index *index, size_t n);
* @param stage stage to search
* @return a pointer to the entry; NULL if it was not found
*/
-GIT_EXTERN(git_index_entry *) git_index_get_bypath(git_index *index, const char *path, int stage);
+GIT_EXTERN(const git_index_entry *) git_index_get_bypath(
+ git_index *index, const char *path, int stage);
/**
* Remove an entry from the index
@@ -402,7 +404,8 @@ GIT_EXTERN(int) git_index_find(git_index *index, const char *path);
* @param their_entry the entry data for their side of the merge conflict
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_index_conflict_add(git_index *index,
+GIT_EXTERN(int) git_index_conflict_add(
+ git_index *index,
const git_index_entry *ancestor_entry,
const git_index_entry *our_entry,
const git_index_entry *their_entry);
@@ -442,7 +445,7 @@ GIT_EXTERN(void) git_index_conflict_cleanup(git_index *index);
*
* @return 1 if at least one conflict is found, 0 otherwise.
*/
-GIT_EXTERN(int) git_index_has_conflicts(git_index *index);
+GIT_EXTERN(int) git_index_has_conflicts(const git_index *index);
/**@}*/
@@ -475,7 +478,7 @@ GIT_EXTERN(int) git_index_reuc_find(git_index *index, const char *path);
* Get a resolve undo entry from the index.
*
* The returned entry is read-only and should not be modified
- * of freed by the caller.
+ * or freed by the caller.
*
* @param index an existing index object
* @param path path to search
@@ -487,7 +490,7 @@ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *in
* Get a resolve undo entry from the index.
*
* The returned entry is read-only and should not be modified
- * of freed by the caller.
+ * or freed by the caller.
*
* @param index an existing index object
* @param n the position of the entry
@@ -496,7 +499,7 @@ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *in
GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
/**
- * Adds an resolve undo entry for a file based on the given parameters.
+ * Adds a resolve undo entry for a file based on the given parameters.
*
* The resolve undo entry contains the OIDs of files that were involved
* in a merge conflict after the conflict has been resolved. This allows
@@ -510,26 +513,26 @@ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *i
* @param index an existing index object
* @param path filename to add
* @param ancestor_mode mode of the ancestor file
- * @param ancestor_oid oid of the ancestor file
+ * @param ancestor_id oid of the ancestor file
* @param our_mode mode of our file
- * @param our_oid oid of our file
+ * @param our_id oid of our file
* @param their_mode mode of their file
- * @param their_oid oid of their file
+ * @param their_id oid of their file
* @return 0 or an error code
*/
GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
- int ancestor_mode, git_oid *ancestor_oid,
- int our_mode, git_oid *our_oid,
- int their_mode, git_oid *their_oid);
+ int ancestor_mode, git_oid *ancestor_id,
+ int our_mode, git_oid *our_id,
+ int their_mode, git_oid *their_id);
/**
* Remove an resolve undo entry from the index
*
* @param index an existing index object
- * @param position position of the resolve undo entry to remove
+ * @param n position of the resolve undo entry to remove
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_index_reuc_remove(git_index *index, int position);
+GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
/**@}*/
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index a2a1554..41a1503 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -44,14 +44,14 @@ GIT_EXTERN(int) git_indexer_stream_new(
git_indexer_stream **out,
const char *path,
git_transfer_progress_callback progress_cb,
- void *progress_callback_payload);
+ void *progress_cb_payload);
/**
* Add data to the indexer
*
* @param idx the indexer
* @param data the data to add
- * @param size the size of the data
+ * @param size the size of the data in bytes
* @param stats stat storage
*/
GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_transfer_progress *stats);
@@ -73,7 +73,7 @@ GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_transfe
*
* @param idx the indexer instance
*/
-GIT_EXTERN(const git_oid *) git_indexer_stream_hash(git_indexer_stream *idx);
+GIT_EXTERN(const git_oid *) git_indexer_stream_hash(const git_indexer_stream *idx);
/**
* Free the indexer and its resources
@@ -120,7 +120,7 @@ GIT_EXTERN(int) git_indexer_write(git_indexer *idx);
*
* @param idx the indexer instance
*/
-GIT_EXTERN(const git_oid *) git_indexer_hash(git_indexer *idx);
+GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx);
/**
* Free the indexer and its resources
diff --git a/include/git2/merge.h b/include/git2/merge.h
index 37b1c78..5949396 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -27,8 +27,13 @@ GIT_BEGIN_DECL
* @param repo the repository where the commits exist
* @param one one of the commits
* @param two the other commit
+ * @return Zero on success; GIT_ENOTFOUND or -1 on failure.
*/
-GIT_EXTERN(int) git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two);
+GIT_EXTERN(int) git_merge_base(
+ git_oid *out,
+ git_repository *repo,
+ const git_oid *one,
+ const git_oid *two);
/**
* Find a merge base given a list of commits
@@ -37,8 +42,13 @@ GIT_EXTERN(int) git_merge_base(git_oid *out, git_repository *repo, const git_oid
* @param repo the repository where the commits exist
* @param input_array oids of the commits
* @param length The number of commits in the provided `input_array`
+ * @return Zero on success; GIT_ENOTFOUND or -1 on failure.
*/
-GIT_EXTERN(int) git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_array[], size_t length);
+GIT_EXTERN(int) git_merge_base_many(
+ git_oid *out,
+ git_repository *repo,
+ const git_oid input_array[],
+ size_t length);
/** @} */
GIT_END_DECL
diff --git a/include/git2/message.h b/include/git2/message.h
index b42cb76..e89d022 100644
--- a/include/git2/message.h
+++ b/include/git2/message.h
@@ -23,21 +23,27 @@ GIT_BEGIN_DECL
*
* Optionally, can remove lines starting with a "#".
*
- * @param message_out The user allocated buffer which will be filled with
- * the cleaned up message. Pass NULL if you just want to get the size of the
- * prettified message as the output value.
+ * @param out The user-allocated buffer which will be filled with the
+ * cleaned up message. Pass NULL if you just want to get the needed
+ * size of the prettified message as the output value.
*
- * @param size The size of the allocated buffer message_out.
+ * @param out_size Size of the `out` buffer in bytes.
*
* @param message The message to be prettified.
*
- * @param strip_comments 1 to remove lines starting with a "#", 0 otherwise.
+ * @param strip_comments Non-zero to remove lines starting with "#", 0 to
+ * leave them in.
*
* @return -1 on error, else number of characters in prettified message
- * including the trailing NUL byte
+ * including the trailing NUL byte
*/
-GIT_EXTERN(int) git_message_prettify(char *message_out, size_t buffer_size, const char *message, int strip_comments);
+GIT_EXTERN(int) git_message_prettify(
+ char *out,
+ size_t out_size,
+ const char *message,
+ int strip_comments);
/** @} */
GIT_END_DECL
+
#endif /* INCLUDE_git_message_h__ */
diff --git a/include/git2/net.h b/include/git2/net.h
index c2301b6..2543ff8 100644
--- a/include/git2/net.h
+++ b/include/git2/net.h
@@ -4,8 +4,8 @@
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
-#ifndef INCLUDE_net_h__
-#define INCLUDE_net_h__
+#ifndef INCLUDE_git_net_h__
+#define INCLUDE_git_net_h__
#include "common.h"
#include "oid.h"
@@ -27,8 +27,10 @@ GIT_BEGIN_DECL
* gets called.
*/
-#define GIT_DIR_FETCH 0
-#define GIT_DIR_PUSH 1
+typedef enum {
+ GIT_DIRECTION_FETCH = 0,
+ GIT_DIRECTION_PUSH = 1
+} git_direction;
/**
@@ -44,7 +46,7 @@ struct git_remote_head {
/**
* Callback for listing the remote heads
*/
-typedef int (*git_headlist_cb)(git_remote_head *, void *);
+typedef int (*git_headlist_cb)(git_remote_head *rhead, void *payload);
/** @} */
GIT_END_DECL
diff --git a/include/git2/notes.h b/include/git2/notes.h
index af480a4..ae66975 100644
--- a/include/git2/notes.h
+++ b/include/git2/notes.h
@@ -19,20 +19,34 @@
GIT_BEGIN_DECL
/**
+ * Callback for git_note_foreach.
+ *
+ * Receives:
+ * - blob_id: Oid of the blob containing the message
+ * - annotated_object_id: Oid of the git object being annotated
+ * - payload: Payload data passed to `git_note_foreach`
+ */
+typedef int (*git_note_foreach_cb)(
+ const git_oid *blob_id, const git_oid *annotated_object_id, void *payload);
+
+/**
* Read the note for an object
*
* The note must be freed manually by the user.
*
- * @param note pointer to the read note; NULL in case of error
+ * @param out pointer to the read note; NULL in case of error
* @param repo repository where to look up the note
- * @param notes_ref canonical name of the reference to use (optional);
- * defaults to "refs/notes/commits"
+ * @param notes_ref canonical name of the reference to use (optional); defaults to
+ * "refs/notes/commits"
* @param oid OID of the git object to read the note from
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_note_read(git_note **note, git_repository *repo,
- const char *notes_ref, const git_oid *oid);
+GIT_EXTERN(int) git_note_read(
+ git_note **out,
+ git_repository *repo,
+ const char *notes_ref,
+ const git_oid *oid);
/**
* Get the note message
@@ -40,7 +54,7 @@ GIT_EXTERN(int) git_note_read(git_note **note, git_repository *repo,
* @param note
* @return the note message
*/
-GIT_EXTERN(const char *) git_note_message(git_note *note);
+GIT_EXTERN(const char *) git_note_message(const git_note *note);
/**
@@ -49,7 +63,7 @@ GIT_EXTERN(const char *) git_note_message(git_note *note);
* @param note
* @return the note object OID
*/
-GIT_EXTERN(const git_oid *) git_note_oid(git_note *note);
+GIT_EXTERN(const git_oid *) git_note_oid(const git_note *note);
/**
* Add a note for an object
@@ -65,10 +79,14 @@ GIT_EXTERN(const git_oid *) git_note_oid(git_note *note);
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
- git_signature *author, git_signature *committer,
- const char *notes_ref, const git_oid *oid,
- const char *note);
+GIT_EXTERN(int) git_note_create(
+ git_oid *out,
+ git_repository *repo,
+ const git_signature *author,
+ const git_signature *committer,
+ const char *notes_ref,
+ const git_oid *oid,
+ const char *note);
/**
@@ -83,9 +101,12 @@ GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_note_remove(git_repository *repo, const char *notes_ref,
- git_signature *author, git_signature *committer,
- const git_oid *oid);
+GIT_EXTERN(int) git_note_remove(
+ git_repository *repo,
+ const char *notes_ref,
+ const git_signature *author,
+ const git_signature *committer,
+ const git_oid *oid);
/**
* Free a git_note object
@@ -105,17 +126,6 @@ GIT_EXTERN(void) git_note_free(git_note *note);
GIT_EXTERN(int) git_note_default_ref(const char **out, git_repository *repo);
/**
- * Basic components of a note
- *
- * - Oid of the blob containing the message
- * - Oid of the git object being annotated
- */
-typedef struct {
- git_oid blob_oid;
- git_oid annotated_object_oid;
-} git_note_data;
-
-/**
* Loop over all the notes within a specified namespace
* and issue a callback for each one.
*
@@ -134,9 +144,8 @@ typedef struct {
GIT_EXTERN(int) git_note_foreach(
git_repository *repo,
const char *notes_ref,
- int (*note_cb)(git_note_data *note_data, void *payload),
- void *payload
-);
+ git_note_foreach_cb note_cb,
+ void *payload);
/** @} */
GIT_END_DECL
diff --git a/include/git2/object.h b/include/git2/object.h
index fd6ae95..fcc56cb 100644
--- a/include/git2/object.h
+++ b/include/git2/object.h
@@ -183,9 +183,9 @@ GIT_EXTERN(size_t) git_object__size(git_otype type);
* @return 0 or an error code
*/
GIT_EXTERN(int) git_object_peel(
- git_object **peeled,
- git_object *object,
- git_otype target_type);
+ git_object **peeled,
+ const git_object *object,
+ git_otype target_type);
/** @} */
GIT_END_DECL
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 4afa3b7..f2633d1 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -136,9 +136,10 @@ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *i
* @param db database to search for the object in.
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
- * @return 0 if the object was read;
- * GIT_ENOTFOUND if the object is not in the database.
- * GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
+ * @return
+ * - 0 if the object was read;
+ * - GIT_ENOTFOUND if the object is not in the database.
+ * - GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
*/
GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len);
@@ -152,15 +153,15 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
* of an object, so the whole object will be read and then the
* header will be returned.
*
- * @param len_p pointer where to store the length
- * @param type_p pointer where to store the type
+ * @param len_out pointer where to store the length
+ * @param type_out pointer where to store the type
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
* - 0 if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
-GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id);
+GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id);
/**
* Determine if the given object can be found in the object database.
@@ -183,10 +184,10 @@ GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
*
* @param db database to use
* @param cb the callback to call for each object
- * @param data data to pass to the callback
+ * @param payload data to pass to the callback
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
-GIT_EXTERN(int) git_odb_foreach(git_odb *db, int (*cb)(git_oid *oid, void *data), void *data);
+GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload);
/**
* Write an object directly into the ODB
@@ -199,14 +200,14 @@ GIT_EXTERN(int) git_odb_foreach(git_odb *db, int (*cb)(git_oid *oid, void *data)
* This method is provided for compatibility with custom backends
* which are not able to support streaming writes
*
- * @param oid pointer to store the OID result of the write
+ * @param out pointer to store the OID result of the write
* @param odb object database where to store the object
* @param data buffer with the data to store
* @param len size of the buffer
* @param type type of the data to store
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_odb_write(git_oid *oid, git_odb *odb, const void *data, size_t len, git_otype type);
+GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_otype type);
/**
* Open a stream to write an object into the ODB
@@ -229,13 +230,13 @@ GIT_EXTERN(int) git_odb_write(git_oid *oid, git_odb *odb, const void *data, size
*
* @see git_odb_stream
*
- * @param stream pointer where to store the stream
+ * @param out pointer where to store the stream
* @param db object database where the stream will write
* @param size final size of the object that will be written
* @param type type of the object that will be written
* @return 0 if the stream was created; error code otherwise
*/
-GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_t size, git_otype type);
+GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, size_t size, git_otype type);
/**
* Open a stream to read an object from the ODB
@@ -256,12 +257,12 @@ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_
*
* @see git_odb_stream
*
- * @param stream pointer where to store the stream
+ * @param out pointer where to store the stream
* @param db object database where the stream will read from
* @param oid oid of the object the stream will read from
* @return 0 if the stream was created; error code otherwise
*/
-GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid);
+GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **out, git_odb *db, const git_oid *oid);
/**
* Open a stream for writing a pack file to the ODB.
@@ -274,14 +275,18 @@ GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const
*
* @see git_odb_writepack
*
- * @param writepack pointer to the writepack functions
+ * @param out pointer to the writepack functions
* @param db object database where the stream will read from
* @param progress_cb function to call with progress information.
* Be aware that this is called inline with network and indexing operations,
* so performance may be affected.
* @param progress_payload payload for the progress callback
*/
-GIT_EXTERN(int) git_odb_write_pack(git_odb_writepack **writepack, git_odb *db, git_transfer_progress_callback progress_cb, void *progress_payload);
+GIT_EXTERN(int) git_odb_write_pack(
+ git_odb_writepack **out,
+ git_odb *db,
+ git_transfer_progress_callback progress_cb,
+ void *progress_payload);
/**
* Determine the object-ID (sha1 hash) of a data buffer
@@ -289,13 +294,13 @@ GIT_EXTERN(int) git_odb_write_pack(git_odb_writepack **writepack, git_odb *db, g
* The resulting SHA-1 OID will be the identifier for the data
* buffer as if the data buffer it were to written to the ODB.
*
- * @param id the resulting object-ID.
+ * @param out the resulting object-ID.
* @param data data to hash
* @param len size of the data
* @param type of the data to hash
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type);
+GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type);
/**
* Read a file from disk and fill a git_oid with the object id
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index 4df48d7..04658f9 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -24,7 +24,14 @@ GIT_BEGIN_DECL
struct git_odb_stream;
struct git_odb_writepack;
-/** An instance for a custom backend */
+/**
+ * Function type for callbacks from git_odb_foreach.
+ */
+typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
+
+/**
+ * An instance for a custom backend
+ */
struct git_odb_backend {
git_odb *odb;
@@ -79,8 +86,8 @@ struct git_odb_backend {
int (* foreach)(
struct git_odb_backend *,
- int (*cb)(git_oid *oid, void *data),
- void *data);
+ git_odb_foreach_cb cb,
+ void *payload);
int (* writepack)(
struct git_odb_writepack **,
@@ -101,7 +108,7 @@ enum {
/** A stream to read/write from a backend */
struct git_odb_stream {
struct git_odb_backend *backend;
- int mode;
+ unsigned int mode;
int (*read)(struct git_odb_stream *stream, char *buffer, size_t len);
int (*write)(struct git_odb_stream *stream, const char *buffer, size_t len);
@@ -118,12 +125,15 @@ struct git_odb_writepack {
void (*free)(struct git_odb_writepack *writepack);
};
-GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir);
-GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir, int compression_level, int do_fsync);
-GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **backend_out, const char *index_file);
-
GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
+/**
+ * Constructors for in-box ODB backends.
+ */
+GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir);
+GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **out, const char *objects_dir, int compression_level, int do_fsync);
+GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file);
+
GIT_END_DECL
#endif
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 9e54a9f..43717ad 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -30,11 +30,10 @@ GIT_BEGIN_DECL
#define GIT_OID_MINPREFIXLEN 4
/** Unique identity of any object (commit, tree, blob, tag). */
-typedef struct _git_oid git_oid;
-struct _git_oid {
+typedef struct git_oid {
/** raw binary formatted id */
unsigned char id[GIT_OID_RAWSZ];
-};
+} git_oid;
/**
* Parse a hex formatted object id into a git_oid.
@@ -71,14 +70,14 @@ GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw);
/**
* Format a git_oid into a hex string.
*
- * @param str output hex string; must be pointing at the start of
+ * @param out output hex string; must be pointing at the start of
* the hex sequence and have at least the number of bytes
* needed for an oid encoded in hex (40 bytes). Only the
* oid digits are written; a '\\0' terminator must be added
* by the caller if it is required.
* @param oid oid structure to format.
*/
-GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid);
+GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id);
/**
* Format a git_oid into a loose-object path string.
@@ -86,14 +85,14 @@ GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid);
* The resulting string is "aa/...", where "aa" is the first two
* hex digits of the oid and "..." is the remaining 38 digits.
*
- * @param str output hex string; must be pointing at the start of
+ * @param out output hex string; must be pointing at the start of
* the hex sequence and have at least the number of bytes
* needed for an oid encoded in hex (41 bytes). Only the
* oid digits are written; a '\\0' terminator must be added
* by the caller if it is required.
- * @param oid oid structure to format.
+ * @param id oid structure to format.
*/
-GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid);
+GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id);
/**
* Format a git_oid into a newly allocated c-string.
@@ -102,7 +101,7 @@ GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid);
* @return the c-string; NULL if memory is exhausted. Caller must
* deallocate the string with git__free().
*/
-GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
+GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *id);
/**
* Format a git_oid into a buffer as a hex format c-string.
@@ -115,11 +114,11 @@ GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
*
* @param out the buffer into which the oid string is output.
* @param n the size of the out buffer.
- * @param oid the oid structure to format.
+ * @param id the oid structure to format.
* @return the out buffer pointer, assuming no input parameter
* errors, otherwise a pointer to an empty string.
*/
-GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *oid);
+GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id);
/**
* Copy an oid from one structure to another.
@@ -176,19 +175,19 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len);
/**
* Check if an oid equals an hex formatted object id.
*
- * @param a oid structure.
+ * @param id oid structure.
* @param str input hex string of an object id.
* @return GIT_ENOTOID if str is not a valid hex string,
* 0 in case of a match, GIT_ERROR otherwise.
*/
-GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str);
+GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str);
/**
* Check is an oid is all zeros.
*
* @return 1 if all zeros, 0 otherwise.
*/
-GIT_EXTERN(int) git_oid_iszero(const git_oid *a);
+GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
/**
* OID Shortener object
@@ -230,12 +229,12 @@ GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length);
* GIT_ENOMEM error
*
* @param os a `git_oid_shorten` instance
- * @param text_oid an OID in text form
+ * @param text_id an OID in text form
* @return the minimal length to uniquely identify all OIDs
* added so far to the set; or an error code (<0) if an
* error occurs.
*/
-GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_oid);
+GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_id);
/**
* Free an OID shortener instance
diff --git a/include/git2/pack.h b/include/git2/pack.h
index 94d5fc6..585cffe 100644
--- a/include/git2/pack.h
+++ b/include/git2/pack.h
@@ -38,8 +38,9 @@ GIT_EXTERN(int) git_packbuilder_new(git_packbuilder **out, git_repository *repo)
*
* @param pb The packbuilder
* @param n Number of threads to spawn
+ * @return number of actual threads to be used
*/
-GIT_EXTERN(void) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n);
+GIT_EXTERN(unsigned int) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n);
/**
* Insert a single object
@@ -48,12 +49,12 @@ GIT_EXTERN(void) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n
* commits followed by trees and blobs.
*
* @param pb The packbuilder
- * @param oid The oid of the commit
- * @param oid The name; might be NULL
+ * @param id The oid of the commit
+ * @param name The name; might be NULL
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, const char *name);
+GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *id, const char *name);
/**
* Insert a root tree object
@@ -61,11 +62,11 @@ GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
* This will add the tree as well as all referenced trees and blobs.
*
* @param pb The packbuilder
- * @param oid The oid of the root tree
+ * @param id The oid of the root tree
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid);
+GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *id);
/**
* Write the new pack and the corresponding index to path
@@ -82,15 +83,17 @@ GIT_EXTERN(int) git_packbuilder_write(git_packbuilder *pb, const char *file);
*
* @param pb the packbuilder
* @param cb the callback to call with each packed object's buffer
- * @param data the callback's data
+ * @param payload the callback's data
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t size, void *data), void *data);
+typedef int (*git_packbuilder_foreach_cb)(void *buf, size_t size, void *payload);
+GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_foreach_cb cb, void *payload);
/**
* Get the total number of objects the packbuilder will write out
*
* @param pb the packbuilder
+ * @return
*/
GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
@@ -98,6 +101,7 @@ GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
* Get the number of objects the packbuilder has already written out
*
* @param pb the packbuilder
+ * @return
*/
GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb);
diff --git a/include/git2/reflog.h b/include/git2/reflog.h
index 72e1f17..45dff21 100644
--- a/include/git2/reflog.h
+++ b/include/git2/reflog.h
@@ -30,11 +30,11 @@ GIT_BEGIN_DECL
* The reflog must be freed manually by using
* git_reflog_free().
*
- * @param reflog pointer to reflog
+ * @param out pointer to reflog
* @param ref reference to read the reflog for
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_reflog_read(git_reflog **reflog, git_reference *ref);
+GIT_EXTERN(int) git_reflog_read(git_reflog **out, const git_reference *ref);
/**
* Write an existing in-memory reflog object back to disk
@@ -51,12 +51,12 @@ GIT_EXTERN(int) git_reflog_write(git_reflog *reflog);
* `msg` is optional and can be NULL.
*
* @param reflog an existing reflog object
- * @param new_oid the OID the reference is now pointing to
+ * @param id the OID the reference is now pointing to
* @param committer the signature of the committer
* @param msg the reflog message
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_signature *committer, const char *msg);
+GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *id, const git_signature *committer, const char *msg);
/**
* Rename the reflog for the given reference
@@ -64,10 +64,10 @@ GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *new_oid, co
* The reflog to be renamed is expected to already exist
*
* @param ref the reference
- * @param new_name the new name of the reference
+ * @param name the new name of the reference
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *new_name);
+GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *name);
/**
* Delete the reflog for the given reference
@@ -83,7 +83,7 @@ GIT_EXTERN(int) git_reflog_delete(git_reference *ref);
* @param reflog the previously loaded reflog
* @return the number of log entries
*/
-GIT_EXTERN(unsigned int) git_reflog_entrycount(git_reflog *reflog);
+GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog *reflog);
/**
* Lookup an entry by its index
@@ -126,7 +126,7 @@ GIT_EXTERN(int) git_reflog_drop(
* @param entry a reflog entry
* @return the old oid
*/
-GIT_EXTERN(const git_oid *) git_reflog_entry_oidold(const git_reflog_entry *entry);
+GIT_EXTERN(const git_oid *) git_reflog_entry_id_old(const git_reflog_entry *entry);
/**
* Get the new oid
@@ -134,7 +134,7 @@ GIT_EXTERN(const git_oid *) git_reflog_entry_oidold(const git_reflog_entry *entr
* @param entry a reflog entry
* @return the new oid at this time
*/
-GIT_EXTERN(const git_oid *) git_reflog_entry_oidnew(const git_reflog_entry *entry);
+GIT_EXTERN(const git_oid *) git_reflog_entry_id_new(const git_reflog_entry *entry);
/**
* Get the committer of this entry
@@ -142,15 +142,15 @@ GIT_EXTERN(const git_oid *) git_reflog_entry_oidnew(const git_reflog_entry *entr
* @param entry a reflog entry
* @return the committer
*/
-GIT_EXTERN(git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry);
+GIT_EXTERN(const git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry);
/**
- * Get the log msg
+ * Get the log message
*
* @param entry a reflog entry
* @return the log msg
*/
-GIT_EXTERN(char *) git_reflog_entry_msg(const git_reflog_entry *entry);
+GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry *entry);
/**
* Free the reflog
diff --git a/include/git2/refs.h b/include/git2/refs.h
index bc3f444..c926461 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -29,12 +29,12 @@ GIT_BEGIN_DECL
* See `git_reference_create_symbolic()` for documentation about valid
* reference names.
*
- * @param reference_out pointer to the looked-up reference
+ * @param out pointer to the looked-up reference
* @param repo the repository to look up the reference
* @param name the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
- * @return 0 or an error code
+ * @return 0 or an error code (ENOTFOUND, EINVALIDSPEC)
*/
-GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_repository *repo, const char *name);
+GIT_EXTERN(int) git_reference_lookup(git_reference **out, git_repository *repo, const char *name);
/**
* Lookup a reference by name and resolve immediately to OID.
@@ -43,12 +43,13 @@ GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_reposito
* through to the object id that it refers to. This avoids having to
* allocate or free any `git_reference` objects for simple situations.
*
- * @param oid Pointer to oid to be filled in
+ * @param out Pointer to oid to be filled in
* @param repo The repository in which to look up the reference
* @param name The long name for the reference
- * @return 0 on success, -1 if name could not be resolved
+ * @return 0 on success, -1 if name could not be resolved (EINVALIDSPEC,
+ * ENOTFOUND, etc)
*/
-GIT_EXTERN(int) git_reference_name_to_oid(
+GIT_EXTERN(int) git_reference_name_to_id(
git_oid *out, git_repository *repo, const char *name);
/**
@@ -73,14 +74,14 @@ GIT_EXTERN(int) git_reference_name_to_oid(
* This function will return an error if a reference already exists with the
* given name unless `force` is true, in which case it will be overwritten.
*
- * @param ref_out Pointer to the newly created reference
+ * @param out Pointer to the newly created reference
* @param repo Repository where that reference will live
* @param name The name of the reference
* @param target The target of the reference
* @param force Overwrite existing references
- * @return 0 or an error code
+ * @return 0 or an error code (EEXISTS, EINVALIDSPEC)
*/
-GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force);
+GIT_EXTERN(int) git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force);
/**
* Create a new direct reference.
@@ -105,14 +106,14 @@ GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repos
* This function will return an error if a reference already exists with the
* given name unless `force` is true, in which case it will be overwritten.
*
- * @param ref_out Pointer to the newly created reference
+ * @param out Pointer to the newly created reference
* @param repo Repository where that reference will live
* @param name The name of the reference
* @param id The object id pointed to by the reference.
* @param force Overwrite existing references
- * @return 0 or an error code
+ * @return 0 or an error code (EINVALIDSPEC, EEXISTS)
*/
-GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force);
+GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force);
/**
* Get the OID pointed to by a direct reference.
@@ -127,7 +128,7 @@ GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository
* @param ref The reference
* @return a pointer to the oid if available, NULL otherwise
*/
-GIT_EXTERN(const git_oid *) git_reference_oid(git_reference *ref);
+GIT_EXTERN(const git_oid *) git_reference_target(const git_reference *ref);
/**
* Get full name to the reference pointed to by a symbolic reference.
@@ -137,7 +138,7 @@ GIT_EXTERN(const git_oid *) git_reference_oid(git_reference *ref);
* @param ref The reference
* @return a pointer to the name if available, NULL otherwise
*/
-GIT_EXTERN(const char *) git_reference_target(git_reference *ref);
+GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference *ref);
/**
* Get the type of a reference.
@@ -147,7 +148,7 @@ GIT_EXTERN(const char *) git_reference_target(git_reference *ref);
* @param ref The reference
* @return the type
*/
-GIT_EXTERN(git_ref_t) git_reference_type(git_reference *ref);
+GIT_EXTERN(git_ref_t) git_reference_type(const git_reference *ref);
/**
* Get the full name of a reference.
@@ -157,7 +158,7 @@ GIT_EXTERN(git_ref_t) git_reference_type(git_reference *ref);
* @param ref The reference
* @return the full name for the ref
*/
-GIT_EXTERN(const char *) git_reference_name(git_reference *ref);
+GIT_EXTERN(const char *) git_reference_name(const git_reference *ref);
/**
* Resolve a symbolic reference to a direct reference.
@@ -175,7 +176,7 @@ GIT_EXTERN(const char *) git_reference_name(git_reference *ref);
* @param ref The reference
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_reference_resolve(git_reference **resolved_ref, git_reference *ref);
+GIT_EXTERN(int) git_reference_resolve(git_reference **out, const git_reference *ref);
/**
* Get the repository where a reference resides.
@@ -183,7 +184,7 @@ GIT_EXTERN(int) git_reference_resolve(git_reference **resolved_ref, git_referenc
* @param ref The reference
* @return a pointer to the repo
*/
-GIT_EXTERN(git_repository *) git_reference_owner(git_reference *ref);
+GIT_EXTERN(git_repository *) git_reference_owner(const git_reference *ref);
/**
* Set the symbolic target of a reference.
@@ -194,9 +195,9 @@ GIT_EXTERN(git_repository *) git_reference_owner(git_reference *ref);
*
* @param ref The reference
* @param target The new target for the reference
- * @return 0 or an error code
+ * @return 0 or an error code (EINVALIDSPEC)
*/
-GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const char *target);
+GIT_EXTERN(int) git_reference_symbolic_set_target(git_reference *ref, const char *target);
/**
* Set the OID target of a reference.
@@ -209,7 +210,7 @@ GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const char *target)
* @param id The new target OID for the reference
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
+GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const git_oid *id);
/**
* Rename an existing reference.
@@ -231,12 +232,12 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
* the reflog if it exists.
*
* @param ref The reference to rename
- * @param new_name The new name for the reference
+ * @param name The new name for the reference
* @param force Overwrite an existing reference
- * @return 0 or an error code
+ * @return 0 or an error code (EINVALIDSPEC, EEXISTS)
*
*/
-GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name, int force);
+GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *name, int force);
/**
* Delete an existing reference.
@@ -287,6 +288,8 @@ GIT_EXTERN(int) git_reference_packall(git_repository *repo);
*/
GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo, unsigned int list_flags);
+typedef int (*git_reference_foreach_cb)(const char *refname, void *payload);
+
/**
* Perform a callback on each reference in the repository.
*
@@ -307,7 +310,11 @@ GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo, un
* @param payload Additional data to pass to the callback
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
-GIT_EXTERN(int) git_reference_foreach(git_repository *repo, unsigned int list_flags, int (*callback)(const char *, void *), void *payload);
+GIT_EXTERN(int) git_reference_foreach(
+ git_repository *repo,
+ unsigned int list_flags,
+ git_reference_foreach_cb callback,
+ void *payload);
/**
* Check if a reference has been loaded from a packfile.
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 44390e7..6c70d7f 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -24,6 +24,7 @@
*/
GIT_BEGIN_DECL
+typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
/*
* TODO: This functions still need to be implemented:
* - _listcb/_foreach
@@ -71,7 +72,7 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
* @param remote the remote
* @return a pointer to the name
*/
-GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
+GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
/**
* Get the remote's url
@@ -79,7 +80,7 @@ GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
* @param remote the remote
* @return a pointer to the url
*/
-GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
+GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
/**
* Get the remote's url for pushing
@@ -87,7 +88,7 @@ GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
* @param remote the remote
* @return a pointer to the url or NULL if no special url for pushing is set
*/
-GIT_EXTERN(const char *) git_remote_pushurl(git_remote *remote);
+GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
/**
* Set the remote's url
@@ -126,7 +127,7 @@ GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
* @param remote the remote
* @return a pointer to the fetch refspec or NULL if it doesn't exist
*/
-GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_fetchspec(const git_remote *remote);
/**
* Set the remote's push refspec
@@ -144,7 +145,7 @@ GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
* @return a pointer to the push refspec or NULL if it doesn't exist
*/
-GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
/**
* Open a connection to a remote
@@ -157,7 +158,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
* @param direction whether you want to receive or send data
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
+GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
/**
* Get a list of refs at the remote
@@ -194,7 +195,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
GIT_EXTERN(int) git_remote_download(
git_remote *remote,
git_transfer_progress_callback progress_cb,
- void *progress_payload);
+ void *payload);
/**
* Check whether the remote is connected
@@ -266,11 +267,11 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
*
* The string array must be freed by the user.
*
- * @param remotes_list a string array with the names of the remotes
+ * @param out a string array which receives the names of the remotes
* @param repo the repository to query
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
+GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
/**
* Add a remote with the default fetch refspec to the repository's configuration
@@ -340,7 +341,7 @@ struct git_remote_callbacks {
void (*progress)(const char *str, int len, void *data);
int (*completion)(git_remote_completion_type type, void *data);
int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
- void *data;
+ void *payload;
};
/**
@@ -359,12 +360,12 @@ GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbac
*/
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
-enum {
+typedef enum {
GIT_REMOTE_DOWNLOAD_TAGS_UNSET,
GIT_REMOTE_DOWNLOAD_TAGS_NONE,
GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
GIT_REMOTE_DOWNLOAD_TAGS_ALL
-};
+} git_remote_autotag_option_t;
/**
* Retrieve the tag auto-follow setting
@@ -372,7 +373,7 @@ enum {
* @param remote the remote to query
* @return the auto-follow setting
*/
-GIT_EXTERN(int) git_remote_autotag(git_remote *remote);
+GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(git_remote *remote);
/**
* Set the tag auto-follow setting
@@ -380,7 +381,9 @@ GIT_EXTERN(int) git_remote_autotag(git_remote *remote);
* @param remote the remote to configure
* @param value a GIT_REMOTE_DOWNLOAD_TAGS value
*/
-GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
+GIT_EXTERN(void) git_remote_set_autotag(
+ git_remote *remote,
+ git_remote_autotag_option_t value);
/**
* Give the remote a new name
@@ -398,7 +401,7 @@ GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
GIT_EXTERN(int) git_remote_rename(
git_remote *remote,
const char *new_name,
- int (*callback)(const char *problematic_refspec, void *payload),
+ git_remote_rename_problem_cb callback,
void *payload);
/**
diff --git a/include/git2/repository.h b/include/git2/repository.h
index f891e91..e91108a 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -29,11 +29,11 @@ GIT_BEGIN_DECL
* The method will automatically detect if 'path' is a normal
* or bare repository or fail is 'path' is neither.
*
- * @param repository pointer to the repo which will be opened
+ * @param out pointer to the repo which will be opened
* @param path the path to the repository
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
+GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path);
/**
* Create a "fake" repository to wrap an object database
@@ -42,11 +42,11 @@ GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *pat
* with the API when all you have is an object database. This doesn't
* have any paths associated with it, so use with care.
*
- * @param repository pointer to the repo
+ * @param out pointer to the repo
* @param odb the object database to wrap
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *odb);
+GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb);
/**
* Look for a git repository and copy its path in the given buffer.
@@ -58,10 +58,10 @@ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *od
* The method will automatically detect if the repository is bare
* (if there is a repository).
*
- * @param repository_path The user allocated buffer which will
+ * @param path_out The user allocated buffer which will
* contain the found path.
*
- * @param size repository_path size
+ * @param path_size repository_path size
*
* @param start_path The base path where the lookup starts.
*
@@ -77,8 +77,8 @@ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *od
* @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_discover(
- char *repository_path,
- size_t size,
+ char *path_out,
+ size_t path_size,
const char *start_path,
int across_fs,
const char *ceiling_dirs);
@@ -95,18 +95,18 @@ GIT_EXTERN(int) git_repository_discover(
* directory "/home/user/source/" will not return "/.git/" as the found
* repo if "/" is a different filesystem than "/home".)
*/
-enum {
+typedef enum {
GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
-};
+} git_repository_open_flag_t;
/**
* Find and open a repository with extended controls.
*
- * @param repo_out Pointer to the repo which will be opened. This can
+ * @param out Pointer to the repo which will be opened. This can
* actually be NULL if you only want to use the error code to
* see if a repo at this path could be opened.
- * @param start_path Path to open as git repository. If the flags
+ * @param path Path to open as git repository. If the flags
* permit "searching", then this can be a path to a subdirectory
* inside the working directory of the repository.
* @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
@@ -118,9 +118,9 @@ enum {
* (such as repo corruption or system errors).
*/
GIT_EXTERN(int) git_repository_open_ext(
- git_repository **repo,
- const char *start_path,
- uint32_t flags,
+ git_repository **out,
+ const char *path,
+ unsigned int flags,
const char *ceiling_dirs);
/**
@@ -142,7 +142,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
* TODO:
* - Reinit the repository
*
- * @param repo_out pointer to the repo which will be created or reinitialized
+ * @param out pointer to the repo which will be created or reinitialized
* @param path the path to the repository
* @param is_bare if true, a Git repository without a working directory is
* created at the pointed path. If false, provided path will be
@@ -152,7 +152,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
* @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_init(
- git_repository **repo_out,
+ git_repository **out,
const char *path,
unsigned is_bare);
@@ -182,14 +182,14 @@ GIT_EXTERN(int) git_repository_init(
* `init.templatedir` global config if not, or falling back on
* "/usr/share/git-core/templates" if it exists.
*/
-enum {
+typedef enum {
GIT_REPOSITORY_INIT_BARE = (1u << 0),
GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1),
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2),
GIT_REPOSITORY_INIT_MKDIR = (1u << 3),
GIT_REPOSITORY_INIT_MKPATH = (1u << 4),
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
-};
+} git_repository_init_flag_t;
/**
* Mode options for `git_repository_init_ext`.
@@ -204,11 +204,11 @@ enum {
* * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
* * Anything else - Set to custom value.
*/
-enum {
+typedef enum {
GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
GIT_REPOSITORY_INIT_SHARED_ALL = 0002777,
-};
+} git_repository_init_mode_t;
/**
* Extended options structure for `git_repository_init_ext`.
@@ -256,26 +256,30 @@ typedef struct {
* auto-detect the case sensitivity of the file system and if the
* file system supports file mode bits correctly.
*
- * @param repo_out Pointer to the repo which will be created or reinitialized.
+ * @param out Pointer to the repo which will be created or reinitialized.
* @param repo_path The path to the repository.
* @param opts Pointer to git_repository_init_options struct.
* @return 0 or an error code on failure.
*/
GIT_EXTERN(int) git_repository_init_ext(
- git_repository **repo_out,
+ git_repository **out,
const char *repo_path,
git_repository_init_options *opts);
/**
* Retrieve and resolve the reference pointed at by HEAD.
*
- * @param head_out pointer to the reference which will be retrieved
+ * The returned `git_reference` will be owned by caller and
+ * `git_reference_free()` must be called when done with it to release the
+ * allocated memory and prevent a leak.
+ *
+ * @param out pointer to the reference which will be retrieved
* @param repo a repository object
*
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
* branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
*/
-GIT_EXTERN(int) git_repository_head(git_reference **head_out, git_repository *repo);
+GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
/**
* Check if a repository's HEAD is detached
@@ -468,12 +472,12 @@ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index
* Use this function to get the contents of this file. Don't forget to
* remove the file after you create the commit.
*
- * @param buffer Buffer to write data into or NULL to just read required size
+ * @param out Buffer to write data into or NULL to just read required size
* @param len Length of buffer in bytes
* @param repo Repository to read prepared message from
* @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
*/
-GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository *repo);
+GIT_EXTERN(int) git_repository_message(char *out, size_t len, git_repository *repo);
/**
* Remove git's prepared message.
diff --git a/include/git2/reset.h b/include/git2/reset.h
index cdcfb76..b5fc4a6 100644
--- a/include/git2/reset.h
+++ b/include/git2/reset.h
@@ -16,16 +16,26 @@
GIT_BEGIN_DECL
/**
+ * Kinds of reset operation
+ */
+typedef enum {
+ GIT_RESET_SOFT = 1, /** Move the head to the given commit */
+ GIT_RESET_MIXED = 2, /** SOFT plus reset index to the commit */
+ GIT_RESET_HARD = 3, /** MIXED plus changes in working tree discarded */
+} git_reset_t;
+
+/**
* Sets the current head to the specified commit oid and optionally
* resets the index and working tree to match.
*
- * When specifying a Soft kind of reset, the head will be moved to the commit.
+ * SOFT reset means the head will be moved to the commit.
*
- * Specifying a Mixed kind of reset will trigger a Soft reset and the index will
- * be replaced with the content of the commit tree.
+ * MIXED reset will trigger a SOFT reset, plus the index will be replaced
+ * with the content of the commit tree.
*
- * Specifying a Hard kind of reset will trigger a Mixed reset and the working
- * directory will be replaced with the content of the index.
+ * HARD reset will trigger a MIXED reset and the working directory will be
+ * replaced with the content of the index. (Untracked and ignored files
+ * will be left alone, however.)
*
* TODO: Implement remaining kinds of resets.
*
@@ -38,9 +48,10 @@ GIT_BEGIN_DECL
*
* @param reset_type Kind of reset operation to perform.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 on success or an error code < 0
*/
-GIT_EXTERN(int) git_reset(git_repository *repo, git_object *target, git_reset_type reset_type);
+GIT_EXTERN(int) git_reset(
+ git_repository *repo, git_object *target, git_reset_t reset_type);
/** @} */
GIT_END_DECL
diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h
index 0a85a4c..893ad2c 100644
--- a/include/git2/revwalk.h
+++ b/include/git2/revwalk.h
@@ -63,11 +63,11 @@ GIT_BEGIN_DECL
* it is possible to have several revision walkers in
* several different threads walking the same repository.
*
- * @param walker pointer to the new revision walker
+ * @param out pointer to the new revision walker
* @param repo the repo to walk through
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_revwalk_new(git_revwalk **walker, git_repository *repo);
+GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo);
/**
* Reset the revision walker for reuse.
@@ -96,10 +96,10 @@ GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
* be started.
*
* @param walk the walker being used for the traversal.
- * @param oid the oid of the commit to start from.
+ * @param id the oid of the commit to start from.
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *oid);
+GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *id);
/**
* Push matching references
@@ -134,10 +134,10 @@ GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk);
* output on the revision walk.
*
* @param walk the walker being used for the traversal.
- * @param oid the oid of commit that will be ignored during the traversal
+ * @param commit_id the oid of commit that will be ignored during the traversal
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *oid);
+GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *commit_id);
/**
* Hide matching references.
@@ -198,12 +198,12 @@ GIT_EXTERN(int) git_revwalk_hide_ref(git_revwalk *walk, const char *refname);
*
* The revision walker is reset when the walk is over.
*
- * @param oid Pointer where to store the oid of the next commit
+ * @param out Pointer where to store the oid of the next commit
* @param walk the walker to pop the commit from.
* @return 0 if the next commit was found;
* GIT_ITEROVER if there are no commits left to iterate
*/
-GIT_EXTERN(int) git_revwalk_next(git_oid *oid, git_revwalk *walk);
+GIT_EXTERN(int) git_revwalk_next(git_oid *out, git_revwalk *walk);
/**
* Change the sorting mode when iterating through the
diff --git a/include/git2/signature.h b/include/git2/signature.h
index cdbe678..7a265bd 100644
--- a/include/git2/signature.h
+++ b/include/git2/signature.h
@@ -20,44 +20,52 @@
GIT_BEGIN_DECL
/**
- * Create a new action signature. The signature must be freed
- * manually or using git_signature_free
+ * Create a new action signature.
+ *
+ * Call `git_signature_free()` to free the data.
*
* Note: angle brackets ('<' and '>') characters are not allowed
* to be used in either the `name` or the `email` parameter.
*
- * @param sig_out new signature, in case of error NULL
+ * @param out new signature, in case of error NULL
* @param name name of the person
* @param email email of the person
* @param time time when the action happened
* @param offset timezone offset in minutes for the time
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset);
+GIT_EXTERN(int) git_signature_new(git_signature **out, const char *name, const char *email, git_time_t time, int offset);
/**
- * Create a new action signature with a timestamp of 'now'. The
- * signature must be freed manually or using git_signature_free
+ * Create a new action signature with a timestamp of 'now'.
+ *
+ * Call `git_signature_free()` to free the data.
*
- * @param sig_out new signature, in case of error NULL
+ * @param out new signature, in case of error NULL
* @param name name of the person
* @param email email of the person
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_signature_now(git_signature **sig_out, const char *name, const char *email);
+GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const char *email);
/**
- * Create a copy of an existing signature.
+ * Create a copy of an existing signature. All internal strings are also
+ * duplicated.
+ *
+ * Call `git_signature_free()` to free the data.
*
- * All internal strings are also duplicated.
* @param sig signature to duplicated
* @return a copy of sig, NULL on out of memory
*/
GIT_EXTERN(git_signature *) git_signature_dup(const git_signature *sig);
/**
- * Free an existing signature
+ * Free an existing signature.
+ *
+ * Because the signature is not an opaque structure, it is legal to free it
+ * manually, but be sure to free the "name" and "email" strings in addition
+ * to the structure itself.
*
* @param sig signature to free
*/
diff --git a/include/git2/stash.h b/include/git2/stash.h
index 3ecd9e8..b57d47b 100644
--- a/include/git2/stash.h
+++ b/include/git2/stash.h
@@ -18,7 +18,7 @@
*/
GIT_BEGIN_DECL
-enum {
+typedef enum {
GIT_STASH_DEFAULT = 0,
/* All changes already added to the index
@@ -35,7 +35,7 @@ enum {
* cleaned up from the working directory
*/
GIT_STASH_INCLUDE_IGNORED = (1 << 2),
-};
+} git_stash_flags;
/**
* Save the local modifications to a new stash.
@@ -49,18 +49,17 @@ enum {
*
* @param message Optional description along with the stashed state.
*
- * @param flags Flags to control the stashing process.
+ * @param flags Flags to control the stashing process. (see GIT_STASH_* above)
*
* @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
* or error code.
*/
-
GIT_EXTERN(int) git_stash_save(
git_oid *out,
git_repository *repo,
git_signature *stasher,
const char *message,
- uint32_t flags);
+ unsigned int flags);
/**
* When iterating over all the stashed states, callback that will be
@@ -71,16 +70,16 @@ GIT_EXTERN(int) git_stash_save(
*
* @param message The stash message.
*
- * @param stash_oid The commit oid of the stashed state.
+ * @param stash_id The commit oid of the stashed state.
*
* @param payload Extra parameter to callback function.
*
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
-typedef int (*stash_cb)(
+typedef int (*git_stash_cb)(
size_t index,
const char* message,
- const git_oid *stash_oid,
+ const git_oid *stash_id,
void *payload);
/**
@@ -99,7 +98,7 @@ typedef int (*stash_cb)(
*/
GIT_EXTERN(int) git_stash_foreach(
git_repository *repo,
- stash_cb callback,
+ git_stash_cb callback,
void *payload);
/**
diff --git a/include/git2/status.h b/include/git2/status.h
index 8c59d76..c6926f3 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -47,6 +47,18 @@ typedef enum {
} git_status_t;
/**
+ * Function pointer to receive status on individual files
+ *
+ * `path` is the relative path to the file from the root of the repository.
+ *
+ * `status_flags` is a combination of `git_status_t` values that apply.
+ *
+ * `payload` is the value you passed to the foreach function as payload.
+ */
+typedef int (*git_status_cb)(
+ const char *path, unsigned int status_flags, void *payload);
+
+/**
* Gather file statuses and run a callback for each one.
*
* The callback is passed the path of the file, the status (a combination of
@@ -63,7 +75,7 @@ typedef enum {
*/
GIT_EXTERN(int) git_status_foreach(
git_repository *repo,
- int (*callback)(const char *, unsigned int, void *),
+ git_status_cb callback,
void *payload);
/**
@@ -146,9 +158,10 @@ typedef enum {
* `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
*/
typedef struct {
+ unsigned int version;
git_status_show_t show;
- unsigned int flags;
- git_strarray pathspec;
+ unsigned int flags;
+ git_strarray pathspec;
} git_status_options;
/**
@@ -168,7 +181,7 @@ typedef struct {
GIT_EXTERN(int) git_status_foreach_ext(
git_repository *repo,
const git_status_options *opts,
- int (*callback)(const char *, unsigned int, void *),
+ git_status_cb callback,
void *payload);
/**
diff --git a/include/git2/strarray.h b/include/git2/strarray.h
index f6092fa..0305679 100644
--- a/include/git2/strarray.h
+++ b/include/git2/strarray.h
@@ -28,21 +28,28 @@ struct _git_strarray {
/**
* Close a string array object
*
- * This method must always be called once a git_strarray is no
- * longer needed, otherwise memory will leak.
+ * This method should be called on `git_strarray` objects where the strings
+ * array is allocated and contains allocated strings, such as what you
+ * would get from `git_strarray_copy()`. Not doing so, will result in a
+ * memory leak.
*
- * @param array array to close
+ * This does not free the `git_strarray` itself, since the library will
+ * never allocate that object directly itself (it is more commonly embedded
+ * inside another struct or created on the stack).
+ *
+ * @param array git_strarray from which to free string data
*/
GIT_EXTERN(void) git_strarray_free(git_strarray *array);
/**
* Copy a string array object from source to target.
- *
- * Note: target is overwritten and hence should be empty,
+ *
+ * Note: target is overwritten and hence should be empty,
* otherwise its contents are leaked.
*
* @param tgt target
* @param src source
+ * @return 0 on success, < 0 on allocation failure
*/
GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
@@ -51,4 +58,4 @@ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
GIT_END_DECL
#endif
-
+
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index b00fad2..90e45ce 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -318,7 +318,7 @@ GIT_EXTERN(int) git_submodule_set_url(git_submodule *submodule, const char *url)
* @param submodule Pointer to submodule object
* @return Pointer to git_oid or NULL if submodule is not in index.
*/
-GIT_EXTERN(const git_oid *) git_submodule_index_oid(git_submodule *submodule);
+GIT_EXTERN(const git_oid *) git_submodule_index_id(git_submodule *submodule);
/**
* Get the OID for the submodule in the current HEAD tree.
@@ -326,7 +326,7 @@ GIT_EXTERN(const git_oid *) git_submodule_index_oid(git_submodule *submodule);
* @param submodule Pointer to submodule object
* @return Pointer to git_oid or NULL if submodule is not in the HEAD.
*/
-GIT_EXTERN(const git_oid *) git_submodule_head_oid(git_submodule *submodule);
+GIT_EXTERN(const git_oid *) git_submodule_head_id(git_submodule *submodule);
/**
* Get the OID for the submodule in the current working directory.
@@ -339,7 +339,7 @@ GIT_EXTERN(const git_oid *) git_submodule_head_oid(git_submodule *submodule);
* @param submodule Pointer to submodule object
* @return Pointer to git_oid or NULL if submodule is not checked out.
*/
-GIT_EXTERN(const git_oid *) git_submodule_wd_oid(git_submodule *submodule);
+GIT_EXTERN(const git_oid *) git_submodule_wd_id(git_submodule *submodule);
/**
* Get the ignore rule for the submodule.
diff --git a/include/git2/tag.h b/include/git2/tag.h
index a1b685f..f82a6c9 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -25,14 +25,16 @@ GIT_BEGIN_DECL
/**
* Lookup a tag object from the repository.
*
- * @param tag pointer to the looked up tag
+ * @param out pointer to the looked up tag
* @param repo the repo to use when locating the tag.
* @param id identity of the tag to locate.
* @return 0 or an error code
*/
-GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oid *id)
+GIT_INLINE(int) git_tag_lookup(
+ git_tag **out, git_repository *repo, const git_oid *id)
{
- return git_object_lookup((git_object **)tag, repo, id, (git_otype)GIT_OBJ_TAG);
+ return git_object_lookup(
+ (git_object **)out, repo, id, (git_otype)GIT_OBJ_TAG);
}
/**
@@ -41,32 +43,33 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi
*
* @see git_object_lookup_prefix
*
- * @param tag pointer to the looked up tag
+ * @param out pointer to the looked up tag
* @param repo the repo to use when locating the tag.
* @param id identity of the tag to locate.
* @param len the length of the short identifier
* @return 0 or an error code
*/
-GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const git_oid *id, size_t len)
+GIT_INLINE(int) git_tag_lookup_prefix(
+ git_tag **out, git_repository *repo, const git_oid *id, size_t len)
{
- return git_object_lookup_prefix((git_object **)tag, repo, id, len, (git_otype)GIT_OBJ_TAG);
+ return git_object_lookup_prefix(
+ (git_object **)out, repo, id, len, (git_otype)GIT_OBJ_TAG);
}
/**
* Close an open tag
*
- * This is a wrapper around git_object_free()
+ * You can no longer use the git_tag pointer after this call.
*
- * IMPORTANT:
- * It *is* necessary to call this method when you stop
- * using a tag. Failure to do so will cause a memory leak.
+ * IMPORTANT: You MUST call this method when you are through with a tag to
+ * release memory. Failure to do so will cause a memory leak.
*
* @param tag the tag to close
*/
GIT_INLINE(void) git_tag_free(git_tag *tag)
{
- git_object_free((git_object *) tag);
+ git_object_free((git_object *)tag);
}
@@ -76,7 +79,7 @@ GIT_INLINE(void) git_tag_free(git_tag *tag)
* @param tag a previously loaded tag.
* @return object identity for the tag.
*/
-GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
+GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag);
/**
* Get the tagged object of a tag
@@ -84,11 +87,11 @@ GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
* This method performs a repository lookup for the
* given object and returns it
*
- * @param target pointer where to store the target
+ * @param target_out pointer where to store the target
* @param tag a previously loaded tag.
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_tag_target(git_object **target, git_tag *tag);
+GIT_EXTERN(int) git_tag_target(git_object **target_out, const git_tag *tag);
/**
* Get the OID of the tagged object of a tag
@@ -96,7 +99,7 @@ GIT_EXTERN(int) git_tag_target(git_object **target, git_tag *tag);
* @param tag a previously loaded tag.
* @return pointer to the OID
*/
-GIT_EXTERN(const git_oid *) git_tag_target_oid(git_tag *tag);
+GIT_EXTERN(const git_oid *) git_tag_target_id(const git_tag *tag);
/**
* Get the type of a tag's tagged object
@@ -104,7 +107,7 @@ GIT_EXTERN(const git_oid *) git_tag_target_oid(git_tag *tag);
* @param tag a previously loaded tag.
* @return type of the tagged object
*/
-GIT_EXTERN(git_otype) git_tag_target_type(git_tag *tag);
+GIT_EXTERN(git_otype) git_tag_target_type(const git_tag *tag);
/**
* Get the name of a tag
@@ -112,7 +115,7 @@ GIT_EXTERN(git_otype) git_tag_target_type(git_tag *tag);
* @param tag a previously loaded tag.
* @return name of the tag
*/
-GIT_EXTERN(const char *) git_tag_name(git_tag *tag);
+GIT_EXTERN(const char *) git_tag_name(const git_tag *tag);
/**
* Get the tagger (author) of a tag
@@ -120,7 +123,7 @@ GIT_EXTERN(const char *) git_tag_name(git_tag *tag);
* @param tag a previously loaded tag.
* @return reference to the tag's author
*/
-GIT_EXTERN(const git_signature *) git_tag_tagger(git_tag *tag);
+GIT_EXTERN(const git_signature *) git_tag_tagger(const git_tag *tag);
/**
* Get the message of a tag
@@ -128,7 +131,7 @@ GIT_EXTERN(const git_signature *) git_tag_tagger(git_tag *tag);
* @param tag a previously loaded tag.
* @return message of the tag
*/
-GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
+GIT_EXTERN(const char *) git_tag_message(const git_tag *tag);
/**
@@ -167,13 +170,13 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* is written in the /refs/tags folder, pointing to it
*/
GIT_EXTERN(int) git_tag_create(
- git_oid *oid,
- git_repository *repo,
- const char *tag_name,
- const git_object *target,
- const git_signature *tagger,
- const char *message,
- int force);
+ git_oid *oid,
+ git_repository *repo,
+ const char *tag_name,
+ const git_object *target,
+ const git_signature *tagger,
+ const char *message,
+ int force);
/**
* Create a new tag in the repository from a buffer
@@ -185,10 +188,10 @@ GIT_EXTERN(int) git_tag_create(
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(int) git_tag_create_frombuffer(
- git_oid *oid,
- git_repository *repo,
- const char *buffer,
- int force);
+ git_oid *oid,
+ git_repository *repo,
+ const char *buffer,
+ int force);
/**
* Create a new lightweight tag pointing at a target object
@@ -218,11 +221,11 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
* pointing to the provided target object
*/
GIT_EXTERN(int) git_tag_create_lightweight(
- git_oid *oid,
- git_repository *repo,
- const char *tag_name,
- const git_object *target,
- int force);
+ git_oid *oid,
+ git_repository *repo,
+ const char *tag_name,
+ const git_object *target,
+ int force);
/**
* Delete an existing tag reference.
@@ -235,8 +238,8 @@ GIT_EXTERN(int) git_tag_create_lightweight(
* @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_delete(
- git_repository *repo,
- const char *tag_name);
+ git_repository *repo,
+ const char *tag_name);
/**
* Fill a list with all the tags in the Repository
@@ -252,8 +255,8 @@ GIT_EXTERN(int) git_tag_delete(
* @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_list(
- git_strarray *tag_names,
- git_repository *repo);
+ git_strarray *tag_names,
+ git_repository *repo);
/**
* Fill a list with all the tags in the Repository
@@ -274,39 +277,39 @@ GIT_EXTERN(int) git_tag_list(
* @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_list_match(
- git_strarray *tag_names,
- const char *pattern,
- git_repository *repo);
+ git_strarray *tag_names,
+ const char *pattern,
+ git_repository *repo);
-typedef int (*git_tag_foreach_cb)(const char *name, git_oid *oid, void *data);
+typedef int (*git_tag_foreach_cb)(const char *name, git_oid *oid, void *payload);
+
/**
* Call callback `cb' for each tag in the repository
*
* @param repo Repository
- * @param cb Callback function
- * @param cb_data Pointer to callback data (optional)
+ * @param callback Callback function
+ * @param payload Pointer to callback data (optional)
*/
GIT_EXTERN(int) git_tag_foreach(
- git_repository *repo,
- git_tag_foreach_cb cb,
- void *cb_data);
+ git_repository *repo,
+ git_tag_foreach_cb callback,
+ void *payload);
/**
- * Recursively peel a tag until a non tag git_object
- * is met
+ * Recursively peel a tag until a non tag git_object is found
*
* The retrieved `tag_target` object is owned by the repository
* and should be closed with the `git_object_free` method.
*
- * @param tag_target Pointer to the peeled git_object
+ * @param tag_target_out Pointer to the peeled git_object
* @param tag The tag to be processed
* @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_peel(
- git_object **tag_target,
- git_tag *tag);
+ git_object **tag_target_out,
+ const git_tag *tag);
/** @} */
GIT_END_DECL
diff --git a/include/git2/transport.h b/include/git2/transport.h
index b2bdaae..5a27d7f 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -45,12 +45,12 @@ typedef struct git_cred_userpass_plaintext {
/**
* Creates a new plain-text username and password credential object.
*
- * @param cred The newly created credential object.
+ * @param out The newly created credential object.
* @param username The username of the credential.
* @param password The password of the credential.
*/
GIT_EXTERN(int) git_cred_userpass_plaintext_new(
- git_cred **cred,
+ git_cred **out,
const char *username,
const char *password);
@@ -64,7 +64,7 @@ GIT_EXTERN(int) git_cred_userpass_plaintext_new(
typedef int (*git_cred_acquire_cb)(
git_cred **cred,
const char *url,
- int allowed_types);
+ unsigned int allowed_types);
/*
*** End interface for credentials acquisition ***
@@ -144,11 +144,11 @@ typedef struct git_transport {
* is scanned to find a transport that implements the scheme of the URI (i.e.
* git:// or http://) and a transport object is returned to the caller.
*
- * @param transport The newly created transport (out)
+ * @param out The newly created transport (out)
* @param url The URL to connect to
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_transport_new(git_transport **transport, const char *url);
+GIT_EXTERN(int) git_transport_new(git_transport **out, const char *url);
/**
* Function which checks to see if a transport could be created for the
@@ -161,7 +161,7 @@ GIT_EXTERN(int) git_transport_new(git_transport **transport, const char *url);
GIT_EXTERN(int) git_transport_valid_url(const char *url);
/* Signature of a function which creates a transport */
-typedef int (*git_transport_cb)(git_transport **transport, void *param);
+typedef int (*git_transport_cb)(git_transport **out, void *payload);
/* Transports which come with libgit2 (match git_transport_cb). The expected
* value for "param" is listed in-line below. */
@@ -170,34 +170,34 @@ typedef int (*git_transport_cb)(git_transport **transport, void *param);
* Create an instance of the dummy transport.
*
* @param transport The newly created transport (out)
- * @param param You must pass NULL for this parameter.
+ * @param payload You must pass NULL for this parameter.
* @return 0 or an error code
*/
GIT_EXTERN(int) git_transport_dummy(
git_transport **transport,
- /* NULL */ void *param);
+ /* NULL */ void *payload);
/**
* Create an instance of the local transport.
*
* @param transport The newly created transport (out)
- * @param param You must pass NULL for this parameter.
+ * @param payload You must pass NULL for this parameter.
* @return 0 or an error code
*/
GIT_EXTERN(int) git_transport_local(
git_transport **transport,
- /* NULL */ void *param);
+ /* NULL */ void *payload);
/**
* Create an instance of the smart transport.
*
* @param transport The newly created transport (out)
- * @param param A pointer to a git_smart_subtransport_definition
+ * @param payload A pointer to a git_smart_subtransport_definition
* @return 0 or an error code
*/
GIT_EXTERN(int) git_transport_smart(
git_transport **transport,
- /* (git_smart_subtransport_definition *) */ void *param);
+ /* (git_smart_subtransport_definition *) */ void *payload);
/*
*** End of base transport interface ***
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 527f818..2d3534f 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -24,14 +24,15 @@ GIT_BEGIN_DECL
/**
* Lookup a tree object from the repository.
*
- * @param tree pointer to the looked up tree
- * @param repo the repo to use when locating the tree.
- * @param id identity of the tree to locate.
+ * @param out Pointer to the looked up tree
+ * @param repo The repo to use when locating the tree.
+ * @param id Identity of the tree to locate.
* @return 0 or an error code
*/
-GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git_oid *id)
+GIT_INLINE(int) git_tree_lookup(
+ git_tree **out, git_repository *repo, const git_oid *id)
{
- return git_object_lookup((git_object **)tree, repo, id, GIT_OBJ_TREE);
+ return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TREE);
}
/**
@@ -47,54 +48,31 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git
* @return 0 or an error code
*/
GIT_INLINE(int) git_tree_lookup_prefix(
- git_tree **tree,
+ git_tree **out,
git_repository *repo,
const git_oid *id,
size_t len)
{
- return git_object_lookup_prefix((git_object **)tree, repo, id, len, GIT_OBJ_TREE);
+ return git_object_lookup_prefix(
+ (git_object **)out, repo, id, len, GIT_OBJ_TREE);
}
/**
* Close an open tree
*
- * This is a wrapper around git_object_free()
+ * You can no longer use the git_tree pointer after this call.
*
- * IMPORTANT:
- * It *is* necessary to call this method when you stop
- * using a tree. Failure to do so will cause a memory leak.
+ * IMPORTANT: You MUST call this method when you stop using a tree to
+ * release memory. Failure to do so will cause a memory leak.
*
- * @param tree the tree to close
+ * @param tree The tree to close
*/
GIT_INLINE(void) git_tree_free(git_tree *tree)
{
- git_object_free((git_object *) tree);
+ git_object_free((git_object *)tree);
}
/**
- * Free a tree entry
- *
- * IMPORTANT: This function is only needed for tree
- * entries owned by the user, such as the ones returned
- * by `git_tree_entry_dup`.
- *
- * @param entry The entry to free
- */
-GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry);
-
-/**
- * Duplicate a tree entry
- *
- * Create a copy of a tree entry. The returned copy is owned
- * by the user, and must be freed manually with
- * `git_tree_entry_free`.
- *
- * @param entry A tree entry to duplicate
- * @return a copy of the original entry
- */
-GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry);
-
-/**
* Get the id of a tree.
*
* @param tree a previously loaded tree.
@@ -108,44 +86,87 @@ GIT_EXTERN(const git_oid *) git_tree_id(const git_tree *tree);
* @param tree a previously loaded tree.
* @return the number of entries in the tree
*/
-GIT_EXTERN(unsigned int) git_tree_entrycount(const git_tree *tree);
+GIT_EXTERN(size_t) git_tree_entrycount(const git_tree *tree);
/**
* Lookup a tree entry by its filename
*
+ * This returns a git_tree_entry that is owned by the git_tree. You don't
+ * have to free it, but you must not use it after the git_tree is released.
+ *
* @param tree a previously loaded tree.
* @param filename the filename of the desired entry
* @return the tree entry; NULL if not found
*/
-GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(git_tree *tree, const char *filename);
+GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(
+ git_tree *tree, const char *filename);
/**
* Lookup a tree entry by its position in the tree
*
+ * This returns a git_tree_entry that is owned by the git_tree. You don't
+ * have to free it, but you must not use it after the git_tree is released.
+ *
* @param tree a previously loaded tree.
* @param idx the position in the entry list
* @return the tree entry; NULL if not found
*/
-GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex(git_tree *tree, size_t idx);
+GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex(
+ git_tree *tree, size_t idx);
/**
* Lookup a tree entry by SHA value.
*
+ * This returns a git_tree_entry that is owned by the git_tree. You don't
+ * have to free it, but you must not use it after the git_tree is released.
+ *
* Warning: this must examine every entry in the tree, so it is not fast.
*
* @param tree a previously loaded tree.
* @param oid the sha being looked for
* @return the tree entry; NULL if not found
*/
-GIT_EXTERN(const git_tree_entry *) git_tree_entry_byoid(git_tree *tree, const git_oid *oid);
+GIT_EXTERN(const git_tree_entry *) git_tree_entry_byoid(
+ const git_tree *tree, const git_oid *oid);
/**
- * Get the UNIX file attributes of a tree entry
+ * Retrieve a tree entry contained in a tree or in any of its subtrees,
+ * given its relative path.
*
- * @param entry a tree entry
- * @return filemode as an integer
+ * Unlike the other lookup functions, the returned tree entry is owned by
+ * the user and must be freed explicitly with `git_tree_entry_free()`.
+ *
+ * @param out Pointer where to store the tree entry
+ * @param root Previously loaded tree which is the root of the relative path
+ * @param subtree_path Path to the contained entry
+ * @return 0 on success; GIT_ENOTFOUND if the path does not exist
*/
-GIT_EXTERN(git_filemode_t) git_tree_entry_filemode(const git_tree_entry *entry);
+GIT_EXTERN(int) git_tree_entry_bypath(
+ git_tree_entry **out,
+ git_tree *root,
+ const char *path);
+
+/**
+ * Duplicate a tree entry
+ *
+ * Create a copy of a tree entry. The returned copy is owned by the user,
+ * and must be freed explicitly with `git_tree_entry_free()`.
+ *
+ * @param entry A tree entry to duplicate
+ * @return a copy of the original entry or NULL on error (alloc failure)
+ */
+GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry);
+
+/**
+ * Free a user-owned tree entry
+ *
+ * IMPORTANT: This function is only needed for tree entries owned by the
+ * user, such as the ones returned by `git_tree_entry_dup()` or
+ * `git_tree_entry_bypath()`.
+ *
+ * @param entry The entry to free
+ */
+GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry);
/**
* Get the filename of a tree entry
@@ -172,8 +193,18 @@ GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry);
GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
/**
+ * Get the UNIX file attributes of a tree entry
+ *
+ * @param entry a tree entry
+ * @return filemode as an integer
+ */
+GIT_EXTERN(git_filemode_t) git_tree_entry_filemode(const git_tree_entry *entry);
+
+/**
* Convert a tree entry to the git_object it points too.
*
+ * You must call `git_object_free()` on the object when you are done with it.
+ *
* @param object pointer to the converted object
* @param repo repository where to lookup the pointed object
* @param entry a tree entry
@@ -187,21 +218,21 @@ GIT_EXTERN(int) git_tree_entry_to_object(
/**
* Create a new tree builder.
*
- * The tree builder can be used to create or modify
- * trees in memory and write them as tree objects to the
- * database.
+ * The tree builder can be used to create or modify trees in memory and
+ * write them as tree objects to the database.
*
- * If the `source` parameter is not NULL, the tree builder
- * will be initialized with the entries of the given tree.
+ * If the `source` parameter is not NULL, the tree builder will be
+ * initialized with the entries of the given tree.
*
- * If the `source` parameter is NULL, the tree builder will
- * have no entries and will have to be filled manually.
+ * If the `source` parameter is NULL, the tree builder will start with no
+ * entries and will have to be filled manually.
*
- * @param builder_p Pointer where to store the tree builder
+ * @param out Pointer where to store the tree builder
* @param source Source tree to initialize the builder (optional)
* @return 0 on success; error code otherwise
*/
-GIT_EXTERN(int) git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source);
+GIT_EXTERN(int) git_treebuilder_create(
+ git_treebuilder **out, const git_tree *source);
/**
* Clear all the entires in the builder
@@ -231,7 +262,8 @@ GIT_EXTERN(void) git_treebuilder_free(git_treebuilder *bld);
* @param filename Name of the entry
* @return pointer to the entry; NULL if not found
*/
-GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, const char *filename);
+GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(
+ git_treebuilder *bld, const char *filename);
/**
* Add or update an entry to the builder
@@ -239,17 +271,17 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
* Insert a new entry for `filename` in the builder with the
* given attributes.
*
- * if an entry named `filename` already exists, its attributes
+ * If an entry named `filename` already exists, its attributes
* will be updated with the given ones.
*
- * The optional pointer `entry_out` can be used to retrieve a
- * pointer to the newly created/updated entry.
+ * The optional pointer `out` can be used to retrieve a pointer to
+ * the newly created/updated entry. Pass NULL if you do not need it.
*
* No attempt is being made to ensure that the provided oid points
* to an existing git object in the object database, nor that the
* attributes make sense regarding the type of the pointed at object.
*
- * @param entry_out Pointer to store the entry (optional)
+ * @param out Pointer to store the entry (optional)
* @param bld Tree builder
* @param filename Filename of the entry
* @param id SHA1 oid of the entry
@@ -259,7 +291,7 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
* @return 0 or an error code
*/
GIT_EXTERN(int) git_treebuilder_insert(
- const git_tree_entry **entry_out,
+ const git_tree_entry **out,
git_treebuilder *bld,
const char *filename,
const git_oid *id,
@@ -271,85 +303,75 @@ GIT_EXTERN(int) git_treebuilder_insert(
* @param bld Tree builder
* @param filename Filename of the entry to remove
*/
-GIT_EXTERN(int) git_treebuilder_remove(git_treebuilder *bld, const char *filename);
+GIT_EXTERN(int) git_treebuilder_remove(
+ git_treebuilder *bld, const char *filename);
+
+typedef int (*git_treebuilder_filter_cb)(
+ const git_tree_entry *entry, void *payload);
/**
* Filter the entries in the tree
*
- * The `filter` callback will be called for each entry
- * in the tree with a pointer to the entry and the
- * provided `payload`: if the callback returns 1, the
- * entry will be filtered (removed from the builder).
+ * The `filter` callback will be called for each entry in the tree with a
+ * pointer to the entry and the provided `payload`; if the callback returns
+ * non-zero, the entry will be filtered (removed from the builder).
*
* @param bld Tree builder
* @param filter Callback to filter entries
+ * @param payload Extra data to pass to filter
*/
GIT_EXTERN(void) git_treebuilder_filter(
git_treebuilder *bld,
- int (*filter)(const git_tree_entry *, void *),
+ git_treebuilder_filter_cb filter,
void *payload);
/**
* Write the contents of the tree builder as a tree object
*
- * The tree builder will be written to the given `repo`, and
- * it's identifying SHA1 hash will be stored in the `oid`
- * pointer.
+ * The tree builder will be written to the given `repo`, and its
+ * identifying SHA1 hash will be stored in the `id` pointer.
*
- * @param oid Pointer where to store the written OID
- * @param repo Repository where to store the object
+ * @param id Pointer to store the OID of the newly written tree
+ * @param repo Repository in which to store the object
* @param bld Tree builder to write
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld);
+GIT_EXTERN(int) git_treebuilder_write(
+ git_oid *id, git_repository *repo, git_treebuilder *bld);
-/**
- * Retrieve a tree entry contained in a tree or in any
- * of its subtrees, given its relative path.
- *
- * The returned tree entry is owned by the user and must
- * be freed manually with `git_tree_entry_free`.
- *
- * @param entry Pointer where to store the tree entry
- * @param root A previously loaded tree which will be the root of the relative path
- * @param subtree_path Path to the contained entry
- * @return 0 on success; GIT_ENOTFOUND if the path does not exist
- */
-GIT_EXTERN(int) git_tree_entry_bypath(
- git_tree_entry **entry,
- git_tree *root,
- const char *path);
/** Callback for the tree traversal method */
-typedef int (*git_treewalk_cb)(const char *root, const git_tree_entry *entry, void *payload);
+typedef int (*git_treewalk_cb)(
+ const char *root, const git_tree_entry *entry, void *payload);
/** Tree traversal modes */
-enum git_treewalk_mode {
+typedef enum {
GIT_TREEWALK_PRE = 0, /* Pre-order */
GIT_TREEWALK_POST = 1, /* Post-order */
-};
+} git_treewalk_mode;
/**
- * Traverse the entries in a tree and its subtrees in
- * post or pre order
+ * Traverse the entries in a tree and its subtrees in post or pre order.
*
- * The entries will be traversed in the specified order,
- * children subtrees will be automatically loaded as required,
- * and the `callback` will be called once per entry with
- * the current (relative) root for the entry and the entry
- * data itself.
+ * The entries will be traversed in the specified order, children subtrees
+ * will be automatically loaded as required, and the `callback` will be
+ * called once per entry with the current (relative) root for the entry and
+ * the entry data itself.
*
* If the callback returns a positive value, the passed entry will be
- * skipped on the traversal (in pre mode). A negative value stops the
- * walk.
+ * skipped on the traversal (in pre mode). A negative value stops the walk.
*
* @param tree The tree to walk
- * @param callback Function to call on each tree entry
* @param mode Traversal mode (pre or post-order)
+ * @param callback Function to call on each tree entry
* @param payload Opaque pointer to be passed on each callback
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);
+GIT_EXTERN(int) git_tree_walk(
+ const git_tree *tree,
+ git_treewalk_mode mode,
+ git_treewalk_cb callback,
+ void *payload);
/** @} */
diff --git a/include/git2/types.h b/include/git2/types.h
index 58cbaec..11bcf27 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -129,7 +129,7 @@ typedef struct git_index git_index;
typedef struct git_config git_config;
/** Interface to access a configuration file */
-typedef struct git_config_file git_config_file;
+typedef struct git_config_backend git_config_backend;
/** Representation of a reference log entry */
typedef struct git_reflog_entry git_reflog_entry;
@@ -175,13 +175,6 @@ typedef enum {
GIT_BRANCH_REMOTE = 2,
} git_branch_t;
-/** Kinds of reset operation. */
-typedef enum {
- GIT_RESET_SOFT = 1,
- GIT_RESET_MIXED = 2,
- GIT_RESET_HARD = 3,
-} git_reset_type;
-
/** Valid modes for index and tree entries. */
typedef enum {
GIT_FILEMODE_NEW = 0000000,
diff --git a/src/attr.c b/src/attr.c
index b575744..95d63be 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -295,7 +295,7 @@ static int load_attr_blob_from_index(
{
int error;
git_index *index;
- git_index_entry *entry;
+ const git_index_entry *entry;
if ((error = git_repository_index__weakptr(&index, repo)) < 0 ||
(error = git_index_find(index, relfile)) < 0)
diff --git a/src/blob.c b/src/blob.c
index 76d265f..b168df1 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -19,10 +19,10 @@ const void *git_blob_rawcontent(git_blob *blob)
return blob->odb_object->raw.data;
}
-size_t git_blob_rawsize(git_blob *blob)
+git_off_t git_blob_rawsize(git_blob *blob)
{
assert(blob);
- return blob->odb_object->raw.len;
+ return (git_off_t)blob->odb_object->raw.len;
}
int git_blob__getbuf(git_buf *buffer, git_blob *blob)
@@ -205,7 +205,7 @@ static int blob_create_internal(git_oid *oid, git_repository *repo, const char *
return error;
}
-int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path)
+int git_blob_create_fromworkdir(git_oid *oid, git_repository *repo, const char *path)
{
git_buf full_path = GIT_BUF_INIT;
const char *workdir;
diff --git a/src/branch.c b/src/branch.c
index c6173ca..5d7d443 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -44,12 +44,6 @@ cleanup:
return error;
}
-static int create_error_invalid(const char *msg)
-{
- giterr_set(GITERR_INVALID, "Cannot create branch - %s", msg);
- return -1;
-}
-
static int not_a_local_branch(git_reference *ref)
{
giterr_set(GITERR_INVALID, "Reference '%s' is not a local branch.", git_reference_name(ref));
@@ -60,31 +54,26 @@ int git_branch_create(
git_reference **ref_out,
git_repository *repository,
const char *branch_name,
- const git_object *target,
+ const git_commit *commit,
int force)
{
- git_object *commit = NULL;
git_reference *branch = NULL;
git_buf canonical_branch_name = GIT_BUF_INIT;
int error = -1;
- assert(branch_name && target && ref_out);
- assert(git_object_owner(target) == repository);
-
- if (git_object_peel(&commit, (git_object *)target, GIT_OBJ_COMMIT) < 0)
- return create_error_invalid("The given target does not resolve to a commit");
+ assert(branch_name && commit && ref_out);
+ assert(git_object_owner((const git_object *)commit) == repository);
if (git_buf_joinpath(&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name) < 0)
goto cleanup;
- error = git_reference_create_oid(&branch, repository,
- git_buf_cstr(&canonical_branch_name), git_object_id(commit), force);
+ error = git_reference_create(&branch, repository,
+ git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force);
if (!error)
*ref_out = branch;
cleanup:
- git_object_free(commit);
git_buf_free(&canonical_branch_name);
return error;
}
diff --git a/src/checkout.c b/src/checkout.c
index c4e4f99..a3166bf 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -693,7 +693,7 @@ cleanup:
int git_checkout_tree(
git_repository *repo,
- git_object *treeish,
+ const git_object *treeish,
git_checkout_opts *opts)
{
int error = 0;
diff --git a/src/clone.c b/src/clone.c
index 9ef6f81..7d49b39 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -28,18 +28,18 @@ static int create_branch(
const git_oid *target,
const char *name)
{
- git_object *head_obj = NULL;
+ git_commit *head_obj = NULL;
git_reference *branch_ref;
int error;
/* Find the target commit */
- if ((error = git_object_lookup(&head_obj, repo, target, GIT_OBJ_ANY)) < 0)
+ if ((error = git_commit_lookup(&head_obj, repo, target)) < 0)
return error;
/* Create the new branch */
error = git_branch_create(&branch_ref, repo, name, head_obj, 0);
- git_object_free(head_obj);
+ git_commit_free(head_obj);
if (!error)
*branch = branch_ref;
@@ -122,7 +122,7 @@ static int reference_matches_remote_head(
if (git_buf_len(&head_info->branchname) > 0)
return 0;
- if (git_reference_name_to_oid(
+ if (git_reference_name_to_id(
&oid,
head_info->repo,
reference_name) < 0) {
@@ -278,7 +278,7 @@ static int setup_remotes_and_fetch(
git_remote_set_update_fetchhead(origin, 0);
/* Connect and download everything */
- if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
+ if (!git_remote_connect(origin, GIT_DIRECTION_FETCH)) {
if (!git_remote_download(origin, progress_cb, progress_payload)) {
/* Create "origin/foo" branches for all remote branches */
if (!git_remote_update_tips(origin)) {
@@ -381,9 +381,9 @@ int git_clone(
git_repository **out,
const char *origin_url,
const char *workdir_path,
+ git_checkout_opts *checkout_opts,
git_transfer_progress_callback fetch_progress_cb,
- void *fetch_progress_payload,
- git_checkout_opts *checkout_opts)
+ void *fetch_progress_payload)
{
assert(out && origin_url && workdir_path);
diff --git a/src/commit.c b/src/commit.c
index b66978a..4072518 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -22,18 +22,18 @@ static void clear_parents(git_commit *commit)
{
unsigned int i;
- for (i = 0; i < commit->parent_oids.length; ++i) {
- git_oid *parent = git_vector_get(&commit->parent_oids, i);
+ for (i = 0; i < commit->parent_ids.length; ++i) {
+ git_oid *parent = git_vector_get(&commit->parent_ids, i);
git__free(parent);
}
- git_vector_clear(&commit->parent_oids);
+ git_vector_clear(&commit->parent_ids);
}
void git_commit__free(git_commit *commit)
{
clear_parents(commit);
- git_vector_free(&commit->parent_oids);
+ git_vector_free(&commit->parent_ids);
git_signature_free(commit->author);
git_signature_free(commit->committer);
@@ -43,11 +43,6 @@ void git_commit__free(git_commit *commit)
git__free(commit);
}
-const git_oid *git_commit_id(git_commit *c)
-{
- return git_object_id((git_object *)c);
-}
-
int git_commit_create_v(
git_oid *oid,
git_repository *repo,
@@ -141,26 +136,26 @@ int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len)
const char *buffer = data;
const char *buffer_end = (const char *)data + len;
- git_oid parent_oid;
+ git_oid parent_id;
- git_vector_init(&commit->parent_oids, 4, NULL);
+ git_vector_init(&commit->parent_ids, 4, NULL);
- if (git_oid__parse(&commit->tree_oid, &buffer, buffer_end, "tree ") < 0)
+ if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0)
goto bad_buffer;
/*
* TODO: commit grafts!
*/
- while (git_oid__parse(&parent_oid, &buffer, buffer_end, "parent ") == 0) {
- git_oid *new_oid;
+ while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) {
+ git_oid *new_id;
- new_oid = git__malloc(sizeof(git_oid));
- GITERR_CHECK_ALLOC(new_oid);
+ new_id = git__malloc(sizeof(git_oid));
+ GITERR_CHECK_ALLOC(new_id);
- git_oid_cpy(new_oid, &parent_oid);
+ git_oid_cpy(new_id, &parent_id);
- if (git_vector_insert(&commit->parent_oids, new_oid) < 0)
+ if (git_vector_insert(&commit->parent_ids, new_id) < 0)
return -1;
}
@@ -214,7 +209,7 @@ int git_commit__parse(git_commit *commit, git_odb_object *obj)
}
#define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
- _rvalue git_commit_##_name(git_commit *commit) \
+ _rvalue git_commit_##_name(const git_commit *commit) \
{\
assert(commit); \
return _return; \
@@ -226,34 +221,34 @@ GIT_COMMIT_GETTER(const char *, message, commit->message)
GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding)
GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time)
GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset)
-GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)commit->parent_oids.length)
-GIT_COMMIT_GETTER(const git_oid *, tree_oid, &commit->tree_oid);
+GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)commit->parent_ids.length)
+GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id);
-int git_commit_tree(git_tree **tree_out, git_commit *commit)
+int git_commit_tree(git_tree **tree_out, const git_commit *commit)
{
assert(commit);
- return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_oid);
+ return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_id);
}
-const git_oid *git_commit_parent_oid(git_commit *commit, unsigned int n)
+const git_oid *git_commit_parent_id(git_commit *commit, unsigned int n)
{
assert(commit);
- return git_vector_get(&commit->parent_oids, n);
+ return git_vector_get(&commit->parent_ids, n);
}
int git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n)
{
- const git_oid *parent_oid;
+ const git_oid *parent_id;
assert(commit);
- parent_oid = git_commit_parent_oid(commit, n);
- if (parent_oid == NULL) {
+ parent_id = git_commit_parent_id(commit, n);
+ if (parent_id == NULL) {
giterr_set(GITERR_INVALID, "Parent %u does not exist", n);
return GIT_ENOTFOUND;
}
- return git_commit_lookup(parent, commit->object.repo, parent_oid);
+ return git_commit_lookup(parent, commit->object.repo, parent_id);
}
int git_commit_nth_gen_ancestor(
diff --git a/src/commit.h b/src/commit.h
index d9f4928..1d1dc0d 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -17,8 +17,8 @@
struct git_commit {
git_object object;
- git_vector parent_oids;
- git_oid tree_oid;
+ git_vector parent_ids;
+ git_oid tree_id;
git_signature *author;
git_signature *committer;
diff --git a/src/commit_list.c b/src/commit_list.c
new file mode 100644
index 0000000..c1a7b22
--- /dev/null
+++ b/src/commit_list.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2009-2012 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "commit_list.h"
+#include "common.h"
+#include "revwalk.h"
+#include "pool.h"
+#include "odb.h"
+
+int git_commit_list_time_cmp(void *a, void *b)
+{
+ git_commit_list_node *commit_a = (git_commit_list_node *)a;
+ git_commit_list_node *commit_b = (git_commit_list_node *)b;
+
+ return (commit_a->time < commit_b->time);
+}
+
+git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p)
+{
+ git_commit_list *new_list = git__malloc(sizeof(git_commit_list));
+ if (new_list != NULL) {
+ new_list->item = item;
+ new_list->next = *list_p;
+ }
+ *list_p = new_list;
+ return new_list;
+}
+
+git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p)
+{
+ git_commit_list **pp = list_p;
+ git_commit_list *p;
+
+ while ((p = *pp) != NULL) {
+ if (git_commit_list_time_cmp(p->item, item) < 0)
+ break;
+
+ pp = &p->next;
+ }
+
+ return git_commit_list_insert(item, pp);
+}
+
+git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk)
+{
+ return (git_commit_list_node *)git_pool_malloc(&walk->commit_pool, COMMIT_ALLOC);
+}
+
+static int commit_error(git_commit_list_node *commit, const char *msg)
+{
+ char commit_oid[GIT_OID_HEXSZ + 1];
+ git_oid_fmt(commit_oid, &commit->oid);
+ commit_oid[GIT_OID_HEXSZ] = '\0';
+
+ giterr_set(GITERR_ODB, "Failed to parse commit %s - %s", commit_oid, msg);
+
+ return -1;
+}
+
+static git_commit_list_node **alloc_parents(
+ git_revwalk *walk, git_commit_list_node *commit, size_t n_parents)
+{
+ if (n_parents <= PARENTS_PER_COMMIT)
+ return (git_commit_list_node **)((char *)commit + sizeof(git_commit_list_node));
+
+ return (git_commit_list_node **)git_pool_malloc(
+ &walk->commit_pool, (uint32_t)(n_parents * sizeof(git_commit_list_node *)));
+}
+
+
+void git_commit_list_free(git_commit_list **list_p)
+{
+ git_commit_list *list = *list_p;
+
+ if (list == NULL)
+ return;
+
+ while (list) {
+ git_commit_list *temp = list;
+ list = temp->next;
+ git__free(temp);
+ }
+
+ *list_p = NULL;
+}
+
+git_commit_list_node *git_commit_list_pop(git_commit_list **stack)
+{
+ git_commit_list *top = *stack;
+ git_commit_list_node *item = top ? top->item : NULL;
+
+ if (top) {
+ *stack = top->next;
+ git__free(top);
+ }
+ return item;
+}
+
+static int commit_quick_parse(git_revwalk *walk, git_commit_list_node *commit, git_rawobj *raw)
+{
+ const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1;
+ unsigned char *buffer = raw->data;
+ unsigned char *buffer_end = buffer + raw->len;
+ unsigned char *parents_start, *committer_start;
+ int i, parents = 0;
+ int commit_time;
+
+ buffer += strlen("tree ") + GIT_OID_HEXSZ + 1;
+
+ parents_start = buffer;
+ while (buffer + parent_len < buffer_end && memcmp(buffer, "parent ", strlen("parent ")) == 0) {
+ parents++;
+ buffer += parent_len;
+ }
+
+ commit->parents = alloc_parents(walk, commit, parents);
+ GITERR_CHECK_ALLOC(commit->parents);
+
+ buffer = parents_start;
+ for (i = 0; i < parents; ++i) {
+ git_oid oid;
+
+ if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) < 0)
+ return -1;
+
+ commit->parents[i] = commit_lookup(walk, &oid);
+ if (commit->parents[i] == NULL)
+ return -1;
+
+ buffer += parent_len;
+ }
+
+ commit->out_degree = (unsigned short)parents;
+
+ if ((committer_start = buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
+ return commit_error(commit, "object is corrupted");
+
+ buffer++;
+
+ if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
+ return commit_error(commit, "object is corrupted");
+
+ /* Skip trailing spaces */
+ while (buffer > committer_start && git__isspace(*buffer))
+ buffer--;
+
+ /* Seek for the begining of the pack of digits */
+ while (buffer > committer_start && git__isdigit(*buffer))
+ buffer--;
+
+ /* Skip potential timezone offset */
+ if ((buffer > committer_start) && (*buffer == '+' || *buffer == '-')) {
+ buffer--;
+
+ while (buffer > committer_start && git__isspace(*buffer))
+ buffer--;
+
+ while (buffer > committer_start && git__isdigit(*buffer))
+ buffer--;
+ }
+
+ if ((buffer == committer_start) || (git__strtol32(&commit_time, (char *)(buffer + 1), NULL, 10) < 0))
+ return commit_error(commit, "cannot parse commit time");
+
+ commit->time = (time_t)commit_time;
+ commit->parsed = 1;
+ return 0;
+}
+
+int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
+{
+ git_odb_object *obj;
+ int error;
+
+ if (commit->parsed)
+ return 0;
+
+ if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
+ return error;
+ assert(obj->raw.type == GIT_OBJ_COMMIT);
+
+ error = commit_quick_parse(walk, commit, &obj->raw);
+ git_odb_object_free(obj);
+ return error;
+}
+
diff --git a/src/commit_list.h b/src/commit_list.h
new file mode 100644
index 0000000..ba809c9
--- /dev/null
+++ b/src/commit_list.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009-2012 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_commit_list_h__
+#define INCLUDE_commit_list_h__
+
+#include "git2/oid.h"
+
+#define PARENT1 (1 << 0)
+#define PARENT2 (1 << 1)
+#define RESULT (1 << 2)
+#define STALE (1 << 3)
+
+#define PARENTS_PER_COMMIT 2
+#define COMMIT_ALLOC \
+ (sizeof(git_commit_list_node) + PARENTS_PER_COMMIT * sizeof(git_commit_list_node *))
+
+typedef struct git_commit_list_node {
+ git_oid oid;
+ uint32_t time;
+ unsigned int seen:1,
+ uninteresting:1,
+ topo_delay:1,
+ parsed:1,
+ flags : 4;
+
+ unsigned short in_degree;
+ unsigned short out_degree;
+
+ struct git_commit_list_node **parents;
+} git_commit_list_node;
+
+typedef struct git_commit_list {
+ git_commit_list_node *item;
+ struct git_commit_list *next;
+} git_commit_list;
+
+git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk);
+int git_commit_list_time_cmp(void *a, void *b);
+void git_commit_list_free(git_commit_list **list_p);
+git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p);
+git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p);
+int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit);
+git_commit_list_node *git_commit_list_pop(git_commit_list **stack);
+
+#endif
diff --git a/src/config.c b/src/config.c
index fc9ea65..5ee0d39 100644
--- a/src/config.c
+++ b/src/config.c
@@ -19,13 +19,13 @@
typedef struct {
git_refcount rc;
- git_config_file *file;
+ git_config_backend *file;
unsigned int level;
} file_internal;
static void file_internal_free(file_internal *internal)
{
- git_config_file *file;
+ git_config_backend *file;
file = internal->file;
file->free(file);
@@ -87,7 +87,7 @@ int git_config_add_file_ondisk(
unsigned int level,
int force)
{
- git_config_file *file = NULL;
+ git_config_backend *file = NULL;
int res;
assert(cfg && path);
@@ -100,7 +100,7 @@ int git_config_add_file_ondisk(
if (git_config_file__ondisk(&file, path) < 0)
return -1;
- if ((res = git_config_add_file(cfg, file, level, force)) < 0) {
+ if ((res = git_config_add_backend(cfg, file, level, force)) < 0) {
/*
* free manually; the file is not owned by the config
* instance yet and will not be freed on cleanup
@@ -132,7 +132,7 @@ int git_config_open_ondisk(git_config **out, const char *path)
static int find_internal_file_by_level(
file_internal **internal_out,
- git_config *cfg,
+ const git_config *cfg,
int level)
{
int pos = -1;
@@ -224,7 +224,7 @@ static int git_config__add_internal(
int git_config_open_level(
git_config **cfg_out,
- git_config *cfg_parent,
+ const git_config *cfg_parent,
unsigned int level)
{
git_config *cfg;
@@ -247,9 +247,9 @@ int git_config_open_level(
return 0;
}
-int git_config_add_file(
+int git_config_add_backend(
git_config *cfg,
- git_config_file *file,
+ git_config_backend *file,
unsigned int level,
int force)
{
@@ -284,7 +284,7 @@ int git_config_refresh(git_config *cfg)
for (i = 0; i < cfg->files.length && !error; ++i) {
file_internal *internal = git_vector_get(&cfg->files, i);
- git_config_file *file = internal->file;
+ git_config_backend *file = internal->file;
error = file->refresh(file);
}
@@ -296,34 +296,34 @@ int git_config_refresh(git_config *cfg)
*/
int git_config_foreach(
- git_config *cfg, int (*fn)(const git_config_entry *, void *), void *data)
+ const git_config *cfg, git_config_foreach_cb cb, void *payload)
{
- return git_config_foreach_match(cfg, NULL, fn, data);
+ return git_config_foreach_match(cfg, NULL, cb, payload);
}
int git_config_foreach_match(
- git_config *cfg,
+ const git_config *cfg,
const char *regexp,
- int (*fn)(const git_config_entry *, void *),
- void *data)
+ git_config_foreach_cb cb,
+ void *payload)
{
int ret = 0;
unsigned int i;
file_internal *internal;
- git_config_file *file;
+ git_config_backend *file;
for (i = 0; i < cfg->files.length && ret == 0; ++i) {
internal = git_vector_get(&cfg->files, i);
file = internal->file;
- ret = file->foreach(file, regexp, fn, data);
+ ret = file->foreach(file, regexp, cb, payload);
}
return ret;
}
-int git_config_delete(git_config *cfg, const char *name)
+int git_config_delete_entry(git_config *cfg, const char *name)
{
- git_config_file *file;
+ git_config_backend *file;
file_internal *internal;
internal = git_vector_get(&cfg->files, 0);
@@ -355,7 +355,7 @@ int git_config_set_bool(git_config *cfg, const char *name, int value)
int git_config_set_string(git_config *cfg, const char *name, const char *value)
{
- git_config_file *file;
+ git_config_backend *file;
file_internal *internal;
internal = git_vector_get(&cfg->files, 0);
@@ -369,9 +369,9 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
***********/
int git_config_get_mapped(
int *out,
- git_config *cfg,
+ const git_config *cfg,
const char *name,
- git_cvar_map *maps,
+ const git_cvar_map *maps,
size_t map_n)
{
const char *value;
@@ -383,7 +383,7 @@ int git_config_get_mapped(
return git_config_lookup_map_value(out, maps, map_n, value);
}
-int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
+int git_config_get_int64(int64_t *out, const git_config *cfg, const char *name)
{
const char *value;
int ret;
@@ -394,7 +394,7 @@ int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
return git_config_parse_int64(out, value);
}
-int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
+int git_config_get_int32(int32_t *out, const git_config *cfg, const char *name)
{
const char *value;
int ret;
@@ -405,7 +405,7 @@ int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
return git_config_parse_int32(out, value);
}
-static int get_string_at_file(const char **out, git_config_file *file, const char *name)
+static int get_string_at_file(const char **out, const git_config_backend *file, const char *name)
{
const git_config_entry *entry;
int res;
@@ -417,7 +417,7 @@ static int get_string_at_file(const char **out, git_config_file *file, const cha
return res;
}
-static int get_string(const char **out, git_config *cfg, const char *name)
+static int get_string(const char **out, const git_config *cfg, const char *name)
{
file_internal *internal;
unsigned int i;
@@ -434,7 +434,7 @@ static int get_string(const char **out, git_config *cfg, const char *name)
return GIT_ENOTFOUND;
}
-int git_config_get_bool(int *out, git_config *cfg, const char *name)
+int git_config_get_bool(int *out, const git_config *cfg, const char *name)
{
const char *value = NULL;
int ret;
@@ -445,7 +445,7 @@ int git_config_get_bool(int *out, git_config *cfg, const char *name)
return git_config_parse_bool(out, value);
}
-int git_config_get_string(const char **out, git_config *cfg, const char *name)
+int git_config_get_string(const char **out, const git_config *cfg, const char *name)
{
int ret;
const char *str = NULL;
@@ -457,7 +457,7 @@ int git_config_get_string(const char **out, git_config *cfg, const char *name)
return 0;
}
-int git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name)
+int git_config_get_entry(const git_config_entry **out, const git_config *cfg, const char *name)
{
file_internal *internal;
unsigned int i;
@@ -467,7 +467,7 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch
*out = NULL;
git_vector_foreach(&cfg->files, i, internal) {
- git_config_file *file = internal->file;
+ git_config_backend *file = internal->file;
int ret = file->get(file, name, out);
if (ret != GIT_ENOTFOUND)
return ret;
@@ -476,11 +476,11 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch
return GIT_ENOTFOUND;
}
-int git_config_get_multivar(git_config *cfg, const char *name, const char *regexp,
- int (*fn)(const git_config_entry *entry, void *data), void *data)
+int git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp,
+ git_config_foreach_cb cb, void *payload)
{
file_internal *internal;
- git_config_file *file;
+ git_config_backend *file;
int ret = GIT_ENOTFOUND;
size_t i;
@@ -493,7 +493,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
for (i = cfg->files.length; i > 0; --i) {
internal = git_vector_get(&cfg->files, i - 1);
file = internal->file;
- ret = file->get_multivar(file, name, regexp, fn, data);
+ ret = file->get_multivar(file, name, regexp, cb, payload);
if (ret < 0 && ret != GIT_ENOTFOUND)
return ret;
}
@@ -503,7 +503,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
{
- git_config_file *file;
+ git_config_backend *file;
file_internal *internal;
internal = git_vector_get(&cfg->files, 0);
@@ -634,7 +634,7 @@ int git_config_open_default(git_config **out)
***********/
int git_config_lookup_map_value(
int *out,
- git_cvar_map *maps,
+ const git_cvar_map *maps,
size_t map_n,
const char *value)
{
@@ -644,7 +644,7 @@ int git_config_lookup_map_value(
goto fail_parse;
for (i = 0; i < map_n; ++i) {
- git_cvar_map *m = maps + i;
+ const git_cvar_map *m = maps + i;
switch (m->cvar_type) {
case GIT_CVAR_FALSE:
@@ -790,7 +790,7 @@ static int rename_config_entries_cb(
return error;
}
- return git_config_delete(data->config, entry->name);
+ return git_config_delete_entry(data->config, entry->name);
}
int git_config_rename_section(
diff --git a/src/config.h b/src/config.h
index c7595ee..ac8da6f 100644
--- a/src/config.h
+++ b/src/config.h
@@ -43,6 +43,6 @@ extern int git_config_rename_section(
* @param out the new backend
* @param path where the config file is located
*/
-extern int git_config_file__ondisk(struct git_config_file **out, const char *path);
+extern int git_config_file__ondisk(struct git_config_backend **out, const char *path);
#endif
diff --git a/src/config_file.c b/src/config_file.c
index 1209c53..7cc812a 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -64,7 +64,7 @@ typedef struct cvar_t {
(iter) = (tmp))
typedef struct {
- git_config_file parent;
+ git_config_backend parent;
git_strmap *values;
@@ -149,7 +149,7 @@ static void free_vars(git_strmap *values)
git_strmap_free(values);
}
-static int config_open(git_config_file *cfg, unsigned int level)
+static int config_open(git_config_backend *cfg, unsigned int level)
{
int res;
diskfile_backend *b = (diskfile_backend *)cfg;
@@ -176,7 +176,7 @@ static int config_open(git_config_file *cfg, unsigned int level)
return res;
}
-static int config_refresh(git_config_file *cfg)
+static int config_refresh(git_config_backend *cfg)
{
int res, updated = 0;
diskfile_backend *b = (diskfile_backend *)cfg;
@@ -203,7 +203,7 @@ static int config_refresh(git_config_file *cfg)
return res;
}
-static void backend_free(git_config_file *_backend)
+static void backend_free(git_config_backend *_backend)
{
diskfile_backend *backend = (diskfile_backend *)_backend;
@@ -216,7 +216,7 @@ static void backend_free(git_config_file *_backend)
}
static int file_foreach(
- git_config_file *backend,
+ git_config_backend *backend,
const char *regexp,
int (*fn)(const git_config_entry *, void *),
void *data)
@@ -262,7 +262,7 @@ cleanup:
return result;
}
-static int config_set(git_config_file *cfg, const char *name, const char *value)
+static int config_set(git_config_backend *cfg, const char *name, const char *value)
{
cvar_t *var = NULL, *old_var;
diskfile_backend *b = (diskfile_backend *)cfg;
@@ -346,7 +346,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
/*
* Internal function that actually gets the value in string form
*/
-static int config_get(git_config_file *cfg, const char *name, const git_config_entry **out)
+static int config_get(const git_config_backend *cfg, const char *name, const git_config_entry **out)
{
diskfile_backend *b = (diskfile_backend *)cfg;
char *key;
@@ -368,7 +368,7 @@ static int config_get(git_config_file *cfg, const char *name, const git_config_e
}
static int config_get_multivar(
- git_config_file *cfg,
+ git_config_backend *cfg,
const char *name,
const char *regex_str,
int (*fn)(const git_config_entry *, void *),
@@ -431,7 +431,7 @@ static int config_get_multivar(
}
static int config_set_multivar(
- git_config_file *cfg, const char *name, const char *regexp, const char *value)
+ git_config_backend *cfg, const char *name, const char *regexp, const char *value)
{
int replaced = 0;
cvar_t *var, *newvar;
@@ -506,7 +506,7 @@ static int config_set_multivar(
return result;
}
-static int config_delete(git_config_file *cfg, const char *name)
+static int config_delete(git_config_backend *cfg, const char *name)
{
cvar_t *var;
diskfile_backend *b = (diskfile_backend *)cfg;
@@ -540,7 +540,7 @@ static int config_delete(git_config_file *cfg, const char *name)
return result;
}
-int git_config_file__ondisk(git_config_file **out, const char *path)
+int git_config_file__ondisk(git_config_backend **out, const char *path)
{
diskfile_backend *backend;
@@ -562,7 +562,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path)
backend->parent.refresh = config_refresh;
backend->parent.free = backend_free;
- *out = (git_config_file *)backend;
+ *out = (git_config_backend *)backend;
return 0;
}
diff --git a/src/config_file.h b/src/config_file.h
index b500dd6..a9671b6 100644
--- a/src/config_file.h
+++ b/src/config_file.h
@@ -9,36 +9,36 @@
#include "git2/config.h"
-GIT_INLINE(int) git_config_file_open(git_config_file *cfg, unsigned int level)
+GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level)
{
return cfg->open(cfg, level);
}
-GIT_INLINE(void) git_config_file_free(git_config_file *cfg)
+GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
{
cfg->free(cfg);
}
GIT_INLINE(int) git_config_file_get_string(
- const git_config_entry **out, git_config_file *cfg, const char *name)
+ const git_config_entry **out, git_config_backend *cfg, const char *name)
{
return cfg->get(cfg, name, out);
}
GIT_INLINE(int) git_config_file_set_string(
- git_config_file *cfg, const char *name, const char *value)
+ git_config_backend *cfg, const char *name, const char *value)
{
return cfg->set(cfg, name, value);
}
GIT_INLINE(int) git_config_file_delete(
- git_config_file *cfg, const char *name)
+ git_config_backend *cfg, const char *name)
{
return cfg->del(cfg, name);
}
GIT_INLINE(int) git_config_file_foreach(
- git_config_file *cfg,
+ git_config_backend *cfg,
int (*fn)(const git_config_entry *entry, void *data),
void *data)
{
@@ -46,7 +46,7 @@ GIT_INLINE(int) git_config_file_foreach(
}
GIT_INLINE(int) git_config_file_foreach_match(
- git_config_file *cfg,
+ git_config_backend *cfg,
const char *regexp,
int (*fn)(const git_config_entry *entry, void *data),
void *data)
diff --git a/src/delta.c b/src/delta.c
index 49f7df0..2514dcc 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -148,7 +148,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
/* Determine index hash size. Note that indexing skips the
first byte to allow for optimizing the Rabin's polynomial
initialization in create_delta(). */
- entries = (bufsize - 1) / RABIN_WINDOW;
+ entries = (unsigned int)(bufsize - 1) / RABIN_WINDOW;
if (bufsize >= 0xffffffffUL) {
/*
* Current delta format can't encode offsets into
@@ -317,9 +317,12 @@ unsigned long git_delta_sizeof_index(struct git_delta_index *index)
#define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7)
void *
-git_delta_create(const struct git_delta_index *index,
- const void *trg_buf, unsigned long trg_size,
- unsigned long *delta_size, unsigned long max_size)
+git_delta_create(
+ const struct git_delta_index *index,
+ const void *trg_buf,
+ unsigned long trg_size,
+ unsigned long *delta_size,
+ unsigned long max_size)
{
unsigned int i, outpos, outsize, moff, msize, val;
int inscnt;
@@ -332,7 +335,7 @@ git_delta_create(const struct git_delta_index *index,
outpos = 0;
outsize = 8192;
if (max_size && outsize >= max_size)
- outsize = max_size + MAX_OP_SIZE + 1;
+ outsize = (unsigned int)(max_size + MAX_OP_SIZE + 1);
out = git__malloc(outsize);
if (!out)
return NULL;
@@ -377,19 +380,19 @@ git_delta_create(const struct git_delta_index *index,
for (entry = index->hash[i]; entry < index->hash[i+1]; entry++) {
const unsigned char *ref = entry->ptr;
const unsigned char *src = data;
- unsigned int ref_size = ref_top - ref;
+ unsigned int ref_size = (unsigned int)(ref_top - ref);
if (entry->val != val)
continue;
if (ref_size > (unsigned int)(top - src))
- ref_size = top - src;
+ ref_size = (unsigned int)(top - src);
if (ref_size <= msize)
break;
while (ref_size-- && *src++ == *ref)
ref++;
if (msize < (unsigned int)(ref - entry->ptr)) {
/* this is our best match so far */
- msize = ref - entry->ptr;
- moff = entry->ptr - ref_data;
+ msize = (unsigned int)(ref - entry->ptr);
+ moff = (unsigned int)(entry->ptr - ref_data);
if (msize >= 4096) /* good enough */
break;
}
diff --git a/src/delta.h b/src/delta.h
index b0b8e41..4ca3279 100644
--- a/src/delta.h
+++ b/src/delta.h
@@ -46,11 +46,12 @@ extern unsigned long git_delta_sizeof_index(struct git_delta_index *index);
* returned and *delta_size is updated with its size. The returned buffer
* must be freed by the caller.
*/
-extern void *
-git_delta_create(const struct git_delta_index *index,
- const void *buf, unsigned long bufsize,
- unsigned long *delta_size,
- unsigned long max_delta_size);
+extern void *git_delta_create(
+ const struct git_delta_index *index,
+ const void *buf,
+ unsigned long bufsize,
+ unsigned long *delta_size,
+ unsigned long max_delta_size);
/*
* diff_delta: create a delta from source buffer to target buffer
@@ -60,15 +61,16 @@ git_delta_create(const struct git_delta_index *index,
* pointer to the buffer with the delta data is returned and *delta_size is
* updated with its size. The returned buffer must be freed by the caller.
*/
-GIT_INLINE(void *)
-git_delta(const void *src_buf, unsigned long src_bufsize,
- const void *trg_buf, unsigned long trg_bufsize,
- unsigned long *delta_size, unsigned long max_delta_size)
+GIT_INLINE(void *) git_delta(
+ const void *src_buf, unsigned long src_bufsize,
+ const void *trg_buf, unsigned long trg_bufsize,
+ unsigned long *delta_size,
+ unsigned long max_delta_size)
{
struct git_delta_index *index = git_delta_create_index(src_buf, src_bufsize);
if (index) {
- void *delta = git_delta_create(index, trg_buf, trg_bufsize,
- delta_size, max_delta_size);
+ void *delta = git_delta_create(
+ index, trg_buf, trg_bufsize, delta_size, max_delta_size);
git_delta_free_index(index);
return delta;
}
@@ -82,9 +84,10 @@ git_delta(const void *src_buf, unsigned long src_bufsize,
* *trg_bufsize is updated with its size. On failure a NULL pointer is
* returned. The returned buffer must be freed by the caller.
*/
-extern void *git_delta_patch(const void *src_buf, unsigned long src_size,
- const void *delta_buf, unsigned long delta_size,
- unsigned long *dst_size);
+extern void *git_delta_patch(
+ const void *src_buf, unsigned long src_size,
+ const void *delta_buf, unsigned long delta_size,
+ unsigned long *dst_size);
/* the smallest possible delta size is 4 bytes */
#define GIT_DELTA_SIZE_MIN 4
@@ -93,9 +96,8 @@ extern void *git_delta_patch(const void *src_buf, unsigned long src_size,
* This must be called twice on the delta data buffer, first to get the
* expected source buffer size, and again to get the target buffer size.
*/
-GIT_INLINE(unsigned long)
-git_delta_get_hdr_size(const unsigned char **datap,
- const unsigned char *top)
+GIT_INLINE(unsigned long) git_delta_get_hdr_size(
+ const unsigned char **datap, const unsigned char *top)
{
const unsigned char *data = *datap;
unsigned long cmd, size = 0;
diff --git a/src/diff.c b/src/diff.c
index d6f5bd4..86f76f9 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -363,7 +363,7 @@ int git_diff__oid_for_file(
const git_oid *sm_oid;
if (!git_submodule_lookup(&sm, repo, path) &&
- (sm_oid = git_submodule_wd_oid(sm)) != NULL)
+ (sm_oid = git_submodule_wd_id(sm)) != NULL)
git_oid_cpy(oid, sm_oid);
else {
/* if submodule lookup failed probably just in an intermediate
@@ -496,7 +496,7 @@ static int maybe_modified(
/* grab OID while we are here */
if (git_oid_iszero(&nitem->oid)) {
- const git_oid *sm_oid = git_submodule_wd_oid(sub);
+ const git_oid *sm_oid = git_submodule_wd_id(sub);
if (sm_oid != NULL) {
git_oid_cpy(&noid, sm_oid);
use_noid = &noid;
diff --git a/src/diff_output.c b/src/diff_output.c
index 46a9e02..3d5e03a 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -262,7 +262,7 @@ static int get_blob_content(
return error;
map->data = (void *)git_blob_rawcontent(*blob);
- map->len = git_blob_rawsize(*blob);
+ map->len = (size_t)git_blob_rawsize(*blob);
return diff_delta_is_binary_by_content(ctxt, delta, file, map);
}
@@ -287,8 +287,8 @@ static int get_workdir_sm_content(
if ((file->flags & GIT_DIFF_FILE_VALID_OID) == 0) {
const git_oid* sm_head;
- if ((sm_head = git_submodule_wd_oid(sm)) != NULL ||
- (sm_head = git_submodule_head_oid(sm)) != NULL)
+ if ((sm_head = git_submodule_wd_id(sm)) != NULL ||
+ (sm_head = git_submodule_head_id(sm)) != NULL)
{
git_oid_cpy(&file->oid, sm_head);
file->flags |= GIT_DIFF_FILE_VALID_OID;
@@ -440,10 +440,10 @@ static void diff_context_init(
git_diff_list *diff,
git_repository *repo,
const git_diff_options *opts,
- void *data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn data_cb)
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb data_cb,
+ void *payload)
{
memset(ctxt, 0, sizeof(diff_context));
@@ -453,8 +453,8 @@ static void diff_context_init(
ctxt->file_cb = file_cb;
ctxt->hunk_cb = hunk_cb;
ctxt->data_cb = data_cb;
- ctxt->cb_data = data;
- ctxt->cb_error = 0;
+ ctxt->payload = payload;
+ ctxt->error = 0;
setup_xdiff_options(ctxt->opts, &ctxt->xdiff_config, &ctxt->xdiff_params);
}
@@ -469,10 +469,10 @@ static int diff_delta_file_callback(
progress = ctxt->diff ? ((float)idx / ctxt->diff->deltas.length) : 1.0f;
- if (ctxt->file_cb(ctxt->cb_data, delta, progress) != 0)
- ctxt->cb_error = GIT_EUSER;
+ if (ctxt->file_cb(delta, progress, ctxt->payload) != 0)
+ ctxt->error = GIT_EUSER;
- return ctxt->cb_error;
+ return ctxt->error;
}
static void diff_patch_init(
@@ -643,14 +643,14 @@ static int diff_patch_cb(void *priv, mmbuffer_t *bufs, int len)
diff_context *ctxt = patch->ctxt;
if (len == 1) {
- ctxt->cb_error = parse_hunk_header(&ctxt->cb_range, bufs[0].ptr);
- if (ctxt->cb_error < 0)
- return ctxt->cb_error;
+ ctxt->error = parse_hunk_header(&ctxt->range, bufs[0].ptr);
+ if (ctxt->error < 0)
+ return ctxt->error;
if (ctxt->hunk_cb != NULL &&
- ctxt->hunk_cb(ctxt->cb_data, patch->delta, &ctxt->cb_range,
- bufs[0].ptr, bufs[0].size))
- ctxt->cb_error = GIT_EUSER;
+ ctxt->hunk_cb(patch->delta, &ctxt->range,
+ bufs[0].ptr, bufs[0].size, ctxt->payload))
+ ctxt->error = GIT_EUSER;
}
if (len == 2 || len == 3) {
@@ -661,12 +661,12 @@ static int diff_patch_cb(void *priv, mmbuffer_t *bufs, int len)
GIT_DIFF_LINE_CONTEXT;
if (ctxt->data_cb != NULL &&
- ctxt->data_cb(ctxt->cb_data, patch->delta, &ctxt->cb_range,
- origin, bufs[1].ptr, bufs[1].size))
- ctxt->cb_error = GIT_EUSER;
+ ctxt->data_cb(patch->delta, &ctxt->range,
+ origin, bufs[1].ptr, bufs[1].size, ctxt->payload))
+ ctxt->error = GIT_EUSER;
}
- if (len == 3 && !ctxt->cb_error) {
+ if (len == 3 && !ctxt->error) {
/* If we have a '+' and a third buf, then we have added a line
* without a newline and the old code had one, so DEL_EOFNL.
* If we have a '-' and a third buf, then we have removed a line
@@ -678,12 +678,12 @@ static int diff_patch_cb(void *priv, mmbuffer_t *bufs, int len)
GIT_DIFF_LINE_CONTEXT;
if (ctxt->data_cb != NULL &&
- ctxt->data_cb(ctxt->cb_data, patch->delta, &ctxt->cb_range,
- origin, bufs[2].ptr, bufs[2].size))
- ctxt->cb_error = GIT_EUSER;
+ ctxt->data_cb(patch->delta, &ctxt->range,
+ origin, bufs[2].ptr, bufs[2].size, ctxt->payload))
+ ctxt->error = GIT_EUSER;
}
- return ctxt->cb_error;
+ return ctxt->error;
}
static int diff_patch_generate(
@@ -720,7 +720,7 @@ static int diff_patch_generate(
xdl_diff(&old_xdiff_data, &new_xdiff_data,
&ctxt->xdiff_params, &ctxt->xdiff_config, &xdiff_callback);
- error = ctxt->cb_error;
+ error = ctxt->error;
if (!error)
patch->flags |= GIT_DIFF_PATCH_DIFFED;
@@ -775,13 +775,13 @@ static void diff_patch_free(git_diff_patch *patch)
#define MIN_LINE_STEP 8
static int diff_patch_hunk_cb(
- void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
const char *header,
- size_t header_len)
+ size_t header_len,
+ void *payload)
{
- git_diff_patch *patch = cb_data;
+ git_diff_patch *patch = payload;
diff_patch_hunk *hunk;
GIT_UNUSED(delta);
@@ -822,14 +822,14 @@ static int diff_patch_hunk_cb(
}
static int diff_patch_line_cb(
- void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *content,
- size_t content_len)
+ size_t content_len,
+ void *payload)
{
- git_diff_patch *patch = cb_data;
+ git_diff_patch *patch = payload;
diff_patch_hunk *hunk;
diff_patch_line *last, *line;
@@ -904,10 +904,10 @@ static int diff_patch_line_cb(
int git_diff_foreach(
git_diff_list *diff,
- void *cb_data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn data_cb)
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb data_cb,
+ void *payload)
{
int error = 0;
diff_context ctxt;
@@ -916,7 +916,7 @@ int git_diff_foreach(
diff_context_init(
&ctxt, diff, diff->repo, &diff->opts,
- cb_data, file_cb, hunk_cb, data_cb);
+ file_cb, hunk_cb, data_cb, payload);
diff_patch_init(&ctxt, &patch);
@@ -951,8 +951,8 @@ int git_diff_foreach(
typedef struct {
git_diff_list *diff;
- git_diff_data_fn print_cb;
- void *cb_data;
+ git_diff_data_cb print_cb;
+ void *payload;
git_buf *buf;
} diff_print_info;
@@ -986,7 +986,7 @@ char git_diff_status_char(git_delta_t status)
}
static int print_compact(
- void *data, const git_diff_delta *delta, float progress)
+ const git_diff_delta *delta, float progress, void *data)
{
diff_print_info *pi = data;
char old_suffix, new_suffix, code = git_diff_status_char(delta->status);
@@ -1017,8 +1017,8 @@ static int print_compact(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, NULL, GIT_DIFF_LINE_FILE_HDR,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_FILE_HDR,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1029,8 +1029,8 @@ static int print_compact(
int git_diff_print_compact(
git_diff_list *diff,
- void *cb_data,
- git_diff_data_fn print_cb)
+ git_diff_data_cb print_cb,
+ void *payload)
{
int error;
git_buf buf = GIT_BUF_INIT;
@@ -1038,10 +1038,10 @@ int git_diff_print_compact(
pi.diff = diff;
pi.print_cb = print_cb;
- pi.cb_data = cb_data;
+ pi.payload = payload;
pi.buf = &buf;
- error = git_diff_foreach(diff, &pi, print_compact, NULL, NULL);
+ error = git_diff_foreach(diff, print_compact, NULL, NULL, &pi);
git_buf_free(&buf);
@@ -1079,7 +1079,7 @@ static int print_oid_range(diff_print_info *pi, const git_diff_delta *delta)
}
static int print_patch_file(
- void *data, const git_diff_delta *delta, float progress)
+ const git_diff_delta *delta, float progress, void *data)
{
diff_print_info *pi = data;
const char *oldpfx = pi->diff->opts.old_prefix;
@@ -1121,7 +1121,8 @@ static int print_patch_file(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, NULL, GIT_DIFF_LINE_FILE_HDR, git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_FILE_HDR,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1137,8 +1138,8 @@ static int print_patch_file(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, NULL, GIT_DIFF_LINE_BINARY,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_BINARY,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1148,11 +1149,11 @@ static int print_patch_file(
}
static int print_patch_hunk(
- void *data,
const git_diff_delta *d,
const git_diff_range *r,
const char *header,
- size_t header_len)
+ size_t header_len,
+ void *data)
{
diff_print_info *pi = data;
@@ -1163,8 +1164,8 @@ static int print_patch_hunk(
if (git_buf_printf(pi->buf, "%.*s", (int)header_len, header) < 0)
return -1;
- if (pi->print_cb(pi->cb_data, d, r, GIT_DIFF_LINE_HUNK_HDR,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(d, r, GIT_DIFF_LINE_HUNK_HDR,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1174,12 +1175,12 @@ static int print_patch_hunk(
}
static int print_patch_line(
- void *data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin, /* GIT_DIFF_LINE value from above */
const char *content,
- size_t content_len)
+ size_t content_len,
+ void *data)
{
diff_print_info *pi = data;
@@ -1198,8 +1199,8 @@ static int print_patch_line(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, range, line_origin,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, range, line_origin,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1210,8 +1211,8 @@ static int print_patch_line(
int git_diff_print_patch(
git_diff_list *diff,
- void *cb_data,
- git_diff_data_fn print_cb)
+ git_diff_data_cb print_cb,
+ void *payload)
{
int error;
git_buf buf = GIT_BUF_INIT;
@@ -1219,11 +1220,11 @@ int git_diff_print_patch(
pi.diff = diff;
pi.print_cb = print_cb;
- pi.cb_data = cb_data;
+ pi.payload = payload;
pi.buf = &buf;
error = git_diff_foreach(
- diff, &pi, print_patch_file, print_patch_hunk, print_patch_line);
+ diff, print_patch_file, print_patch_hunk, print_patch_line, &pi);
git_buf_free(&buf);
@@ -1235,14 +1236,18 @@ static void set_data_from_blob(
git_blob *blob, git_map *map, git_diff_file *file)
{
if (blob) {
- map->data = (char *)git_blob_rawcontent(blob);
- file->size = map->len = git_blob_rawsize(blob);
+ file->size = git_blob_rawsize(blob);
git_oid_cpy(&file->oid, git_object_id((const git_object *)blob));
file->mode = 0644;
+
+ map->len = (size_t)file->size;
+ map->data = (char *)git_blob_rawcontent(blob);
} else {
- map->data = "";
- file->size = map->len = 0;
+ file->size = 0;
file->flags |= GIT_DIFF_FILE_NO_DATA;
+
+ map->len = 0;
+ map->data = "";
}
}
@@ -1250,10 +1255,10 @@ int git_diff_blobs(
git_blob *old_blob,
git_blob *new_blob,
const git_diff_options *options,
- void *cb_data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn data_cb)
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb data_cb,
+ void *payload)
{
int error;
git_repository *repo;
@@ -1276,7 +1281,7 @@ int git_diff_blobs(
diff_context_init(
&ctxt, NULL, repo, options,
- cb_data, file_cb, hunk_cb, data_cb);
+ file_cb, hunk_cb, data_cb, payload);
diff_patch_init(&ctxt, &patch);
@@ -1374,7 +1379,7 @@ int git_diff_get_patch(
diff_context_init(
&ctxt, diff, diff->repo, &diff->opts,
- NULL, NULL, diff_patch_hunk_cb, diff_patch_line_cb);
+ NULL, diff_patch_hunk_cb, diff_patch_line_cb, NULL);
if (git_diff_delta__should_skip(ctxt.opts, delta))
return 0;
@@ -1384,12 +1389,12 @@ int git_diff_get_patch(
return -1;
if (!(error = diff_patch_load(&ctxt, patch))) {
- ctxt.cb_data = patch;
+ ctxt.payload = patch;
error = diff_patch_generate(&ctxt, patch);
if (error == GIT_EUSER)
- error = ctxt.cb_error;
+ error = ctxt.error;
}
if (error)
@@ -1503,22 +1508,22 @@ notfound:
}
static int print_to_buffer_cb(
- void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *content,
- size_t content_len)
+ size_t content_len,
+ void *payload)
{
- git_buf *output = cb_data;
+ git_buf *output = payload;
GIT_UNUSED(delta); GIT_UNUSED(range); GIT_UNUSED(line_origin);
return git_buf_put(output, content, content_len);
}
int git_diff_patch_print(
git_diff_patch *patch,
- void *cb_data,
- git_diff_data_fn print_cb)
+ git_diff_data_cb print_cb,
+ void *payload)
{
int error;
git_buf temp = GIT_BUF_INIT;
@@ -1529,23 +1534,23 @@ int git_diff_patch_print(
pi.diff = patch->diff;
pi.print_cb = print_cb;
- pi.cb_data = cb_data;
+ pi.payload = payload;
pi.buf = &temp;
- error = print_patch_file(&pi, patch->delta, 0);
+ error = print_patch_file(patch->delta, 0, &pi);
for (h = 0; h < patch->hunks_size && !error; ++h) {
diff_patch_hunk *hunk = &patch->hunks[h];
- error = print_patch_hunk(&pi, patch->delta,
- &hunk->range, hunk->header, hunk->header_len);
+ error = print_patch_hunk(
+ patch->delta, &hunk->range, hunk->header, hunk->header_len, &pi);
for (l = 0; l < hunk->line_count && !error; ++l) {
diff_patch_line *line = &patch->lines[hunk->line_start + l];
error = print_patch_line(
- &pi, patch->delta, &hunk->range,
- line->origin, line->ptr, line->len);
+ patch->delta, &hunk->range,
+ line->origin, line->ptr, line->len, &pi);
}
}
@@ -1561,7 +1566,7 @@ int git_diff_patch_to_str(
int error;
git_buf output = GIT_BUF_INIT;
- error = git_diff_patch_print(patch, &output, print_to_buffer_cb);
+ error = git_diff_patch_print(patch, print_to_buffer_cb, &output);
/* GIT_EUSER means git_buf_put in print_to_buffer_cb returned -1,
* meaning a memory allocation failure, so just map to -1...
@@ -1577,8 +1582,8 @@ int git_diff_patch_to_str(
int git_diff__paired_foreach(
git_diff_list *idx2head,
git_diff_list *wd2idx,
- int (*cb)(void *cbref, git_diff_delta *i2h, git_diff_delta *w2i),
- void *cbref)
+ int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload),
+ void *payload)
{
int cmp;
git_diff_delta *i2h, *w2i;
@@ -1611,15 +1616,15 @@ int git_diff__paired_foreach(
STRCMP_CASESELECT(icase, i2h->old_file.path, w2i->old_file.path);
if (cmp < 0) {
- if (cb(cbref, i2h, NULL))
+ if (cb(i2h, NULL, payload))
return GIT_EUSER;
i++;
} else if (cmp > 0) {
- if (cb(cbref, NULL, w2i))
+ if (cb(NULL, w2i, payload))
return GIT_EUSER;
j++;
} else {
- if (cb(cbref, i2h, w2i))
+ if (cb(i2h, w2i, payload))
return GIT_EUSER;
i++; j++;
}
diff --git a/src/diff_output.h b/src/diff_output.h
index f74dd3a..13f2a12 100644
--- a/src/diff_output.h
+++ b/src/diff_output.h
@@ -27,12 +27,12 @@ typedef struct {
git_repository *repo;
git_diff_list *diff;
const git_diff_options *opts;
- git_diff_file_fn file_cb;
- git_diff_hunk_fn hunk_cb;
- git_diff_data_fn data_cb;
- void *cb_data;
- int cb_error;
- git_diff_range cb_range;
+ git_diff_file_cb file_cb;
+ git_diff_hunk_cb hunk_cb;
+ git_diff_data_cb data_cb;
+ void *payload;
+ int error;
+ git_diff_range range;
xdemitconf_t xdiff_config;
xpparam_t xdiff_params;
} diff_context;
@@ -86,7 +86,7 @@ typedef struct {
extern int git_diff__paired_foreach(
git_diff_list *idx2head,
git_diff_list *wd2idx,
- int (*cb)(void *cbref, git_diff_delta *i2h, git_diff_delta *w2i),
- void *cbref);
+ int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload),
+ void *payload);
#endif
diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c
index a89dffa..469ce78 100644
--- a/src/hash/hash_win32.c
+++ b/src/hash/hash_win32.c
@@ -155,7 +155,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *data, size_
{
assert(ctx->ctx.cryptoapi.valid);
- if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, len, 0))
+ if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, (DWORD)len, 0))
return -1;
return 0;
@@ -219,7 +219,7 @@ GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx)
GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *data, size_t len)
{
- if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, len, 0) < 0)
+ if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, (ULONG)len, 0) < 0)
return -1;
return 0;
diff --git a/src/index.c b/src/index.c
index 128dd18..f3ced9e 100644
--- a/src/index.c
+++ b/src/index.c
@@ -94,7 +94,7 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe
static int read_header(struct index_header *dest, const void *buffer);
static int parse_index(git_index *index, const char *buffer, size_t buffer_size);
-static int is_index_extended(git_index *index);
+static bool is_index_extended(git_index *index);
static int write_index(git_index *index, git_filebuf *file);
static int index_find(git_index *index, const char *path, int stage);
@@ -298,7 +298,7 @@ static void index_free(git_index *index)
{
git_index_entry *e;
git_index_reuc_entry *reuc;
- unsigned int i;
+ size_t i;
git_index_clear(index);
git_vector_foreach(&index->entries, i, e) {
@@ -488,20 +488,22 @@ int git_index_write_tree_to(git_oid *oid, git_index *index, git_repository *repo
return git_tree__write_index(oid, index, repo);
}
-unsigned int git_index_entrycount(git_index *index)
+size_t git_index_entrycount(const git_index *index)
{
assert(index);
- return (unsigned int)index->entries.length;
+ return index->entries.length;
}
-git_index_entry *git_index_get_byindex(git_index *index, size_t n)
+const git_index_entry *git_index_get_byindex(
+ git_index *index, size_t n)
{
assert(index);
git_vector_sort(&index->entries);
return git_vector_get(&index->entries, n);
}
-git_index_entry *git_index_get_bypath(git_index *index, const char *path, int stage)
+const git_index_entry *git_index_get_bypath(
+ git_index *index, const char *path, int stage)
{
int pos;
@@ -580,7 +582,7 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const
*/
/* write the blob to disk and get the oid */
- if ((error = git_blob_create_fromfile(&oid, INDEX_OWNER(index), rel_path)) < 0)
+ if ((error = git_blob_create_fromworkdir(&oid, INDEX_OWNER(index), rel_path)) < 0)
return error;
entry = git__calloc(1, sizeof(git_index_entry));
@@ -810,13 +812,15 @@ int git_index_find(git_index *index, const char *path)
assert(index && path);
- if ((pos = git_vector_bsearch2(&index->entries, index->entries_search_path, path)) < 0)
+ if ((pos = git_vector_bsearch2(
+ &index->entries, index->entries_search_path, path)) < 0)
return pos;
/* Since our binary search only looked at path, we may be in the
- * middle of a list of stages. */
+ * middle of a list of stages.
+ */
while (pos > 0) {
- git_index_entry *prev = git_vector_get(&index->entries, pos-1);
+ const git_index_entry *prev = git_vector_get(&index->entries, pos-1);
if (index->entries_cmp_path(prev->path, path) != 0)
break;
@@ -827,10 +831,10 @@ int git_index_find(git_index *index, const char *path)
return pos;
}
-unsigned int git_index__prefix_position(git_index *index, const char *path)
+size_t git_index__prefix_position(git_index *index, const char *path)
{
struct entry_srch_key srch_key;
- unsigned int pos;
+ size_t pos;
srch_key.path = path;
srch_key.stage = 0;
@@ -848,7 +852,7 @@ int git_index_conflict_add(git_index *index,
const git_index_entry *their_entry)
{
git_index_entry *entries[3] = { 0 };
- size_t i;
+ unsigned short i;
int ret = 0;
assert (index);
@@ -886,7 +890,7 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
git_index_entry **their_out,
git_index *index, const char *path)
{
- int pos, stage;
+ int pos, posmax, stage;
git_index_entry *conflict_entry;
int error = GIT_ENOTFOUND;
@@ -899,7 +903,8 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
if ((pos = git_index_find(index, path)) < 0)
return pos;
- while ((unsigned int)pos < git_index_entrycount(index)) {
+ for (posmax = (int)git_index_entrycount(index); pos < posmax; ++pos) {
+
conflict_entry = git_vector_get(&index->entries, pos);
if (index->entries_cmp_path(conflict_entry->path, path) != 0)
@@ -923,8 +928,6 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
default:
break;
};
-
- ++pos;
}
return error;
@@ -932,7 +935,7 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
int git_index_conflict_remove(git_index *index, const char *path)
{
- int pos;
+ int pos, posmax;
git_index_entry *conflict_entry;
int error = 0;
@@ -941,7 +944,9 @@ int git_index_conflict_remove(git_index *index, const char *path)
if ((pos = git_index_find(index, path)) < 0)
return pos;
- while ((unsigned int)pos < git_index_entrycount(index)) {
+ posmax = (int)git_index_entrycount(index);
+
+ while (pos < posmax) {
conflict_entry = git_vector_get(&index->entries, pos);
if (index->entries_cmp_path(conflict_entry->path, path) != 0)
@@ -961,7 +966,7 @@ int git_index_conflict_remove(git_index *index, const char *path)
return error;
}
-static int index_conflicts_match(git_vector *v, size_t idx)
+static int index_conflicts_match(const git_vector *v, size_t idx)
{
git_index_entry *entry = git_vector_get(v, idx);
@@ -979,9 +984,9 @@ void git_index_conflict_cleanup(git_index *index)
git_vector_remove_matching(&index->entries, index_conflicts_match);
}
-int git_index_has_conflicts(git_index *index)
+int git_index_has_conflicts(const git_index *index)
{
- unsigned int i;
+ size_t i;
git_index_entry *entry;
assert(index);
@@ -1072,7 +1077,7 @@ const git_index_reuc_entry *git_index_reuc_get_byindex(
return git_vector_get(&index->reuc, n);
}
-int git_index_reuc_remove(git_index *index, int position)
+int git_index_reuc_remove(git_index *index, size_t position)
{
int error;
git_index_reuc_entry *reuc;
@@ -1359,9 +1364,9 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
return 0;
}
-static int is_index_extended(git_index *index)
+static bool is_index_extended(git_index *index)
{
- unsigned int i, extended;
+ size_t i, extended;
git_index_entry *entry;
extended = 0;
@@ -1374,7 +1379,7 @@ static int is_index_extended(git_index *index)
}
}
- return extended;
+ return (extended > 0);
}
static int write_disk_entry(git_filebuf *file, git_index_entry *entry)
@@ -1440,7 +1445,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry)
static int write_entries(git_index *index, git_filebuf *file)
{
int error = 0;
- unsigned int i;
+ size_t i;
git_vector case_sorted;
git_index_entry *entry;
git_vector *out = &index->entries;
@@ -1506,7 +1511,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
git_vector *out = &index->reuc;
git_index_reuc_entry *reuc;
struct index_extension extension;
- unsigned int i;
+ size_t i;
int error = 0;
git_vector_foreach(out, i, reuc) {
@@ -1516,7 +1521,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
memset(&extension, 0x0, sizeof(struct index_extension));
memcpy(&extension.signature, INDEX_EXT_UNMERGED_SIG, 4);
- extension.extension_size = reuc_buf.size;
+ extension.extension_size = (uint32_t)reuc_buf.size;
error = write_extension(file, &extension, &reuc_buf);
@@ -1529,10 +1534,8 @@ done:
static int write_index(git_index *index, git_filebuf *file)
{
git_oid hash_final;
-
struct index_header header;
-
- int is_extended;
+ bool is_extended;
assert(index && file);
@@ -1599,11 +1602,11 @@ static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *da
return 0;
}
-int git_index_read_tree(git_index *index, git_tree *tree)
+int git_index_read_tree(git_index *index, const git_tree *tree)
{
git_index_clear(index);
- return git_tree_walk(tree, read_tree_cb, GIT_TREEWALK_POST, index);
+ return git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, index);
}
git_repository *git_index_owner(const git_index *index)
diff --git a/src/index.h b/src/index.h
index f0dcd64..05123b5 100644
--- a/src/index.h
+++ b/src/index.h
@@ -43,7 +43,7 @@ struct git_index {
extern void git_index_entry__init_from_stat(git_index_entry *entry, struct stat *st);
-extern unsigned int git_index__prefix_position(git_index *index, const char *path);
+extern size_t git_index__prefix_position(git_index *index, const char *path);
extern int git_index_entry__cmp(const void *a, const void *b);
extern int git_index_entry__cmp_icase(const void *a, const void *b);
diff --git a/src/indexer.c b/src/indexer.c
index d8939f0..a51d903 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -56,12 +56,12 @@ struct delta_info {
git_off_t delta_off;
};
-const git_oid *git_indexer_hash(git_indexer *idx)
+const git_oid *git_indexer_hash(const git_indexer *idx)
{
return &idx->hash;
}
-const git_oid *git_indexer_stream_hash(git_indexer_stream *idx)
+const git_oid *git_indexer_stream_hash(const git_indexer_stream *idx)
{
return &idx->hash;
}
diff --git a/src/iterator.c b/src/iterator.c
index ee83a4f..6be45a4 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -85,7 +85,7 @@ struct tree_iterator_frame {
tree_iterator_frame *next, *prev;
git_tree *tree;
char *start;
- unsigned int index;
+ size_t index;
};
typedef struct {
@@ -329,7 +329,7 @@ int git_iterator_for_tree_range(
typedef struct {
git_iterator base;
git_index *index;
- unsigned int current;
+ size_t current;
bool free_index;
} index_iterator;
@@ -337,7 +337,7 @@ static int index_iterator__current(
git_iterator *self, const git_index_entry **entry)
{
index_iterator *ii = (index_iterator *)self;
- git_index_entry *ie = git_index_get_byindex(ii->index, ii->current);
+ const git_index_entry *ie = git_index_get_byindex(ii->index, ii->current);
if (ie != NULL &&
ii->base.end != NULL &&
@@ -434,7 +434,7 @@ typedef struct workdir_iterator_frame workdir_iterator_frame;
struct workdir_iterator_frame {
workdir_iterator_frame *next;
git_vector entries;
- unsigned int index;
+ size_t index;
char *start;
};
@@ -761,7 +761,8 @@ static int spoolandsort_iterator__current(
spoolandsort_iterator *si = (spoolandsort_iterator *)self;
if (si->position < si->entries.length)
- *entry = (const git_index_entry *)git_vector_get_const(&si->entries, si->position);
+ *entry = (const git_index_entry *)git_vector_get(
+ &si->entries, si->position);
else
*entry = NULL;
@@ -781,7 +782,8 @@ static int spoolandsort_iterator__advance(
spoolandsort_iterator *si = (spoolandsort_iterator *)self;
if (si->position < si->entries.length)
- *entry = (const git_index_entry *)git_vector_get_const(&si->entries, ++si->position);
+ *entry = (const git_index_entry *)git_vector_get(
+ &si->entries, ++si->position);
else
*entry = NULL;
diff --git a/src/merge.c b/src/merge.c
index 135af6a..c795b80 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -6,12 +6,14 @@
*/
#include "repository.h"
+#include "revwalk.h"
#include "buffer.h"
#include "merge.h"
#include "refs.h"
#include "git2/repository.h"
#include "git2/merge.h"
#include "git2/reset.h"
+#include "commit_list.h"
int git_merge__cleanup(git_repository *repo)
{
@@ -46,3 +48,197 @@ cleanup:
return error;
}
+int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_array[], size_t length)
+{
+ git_revwalk *walk;
+ git_vector list;
+ git_commit_list *result = NULL;
+ int error = -1;
+ unsigned int i;
+ git_commit_list_node *commit;
+
+ assert(out && repo && input_array);
+
+ if (length < 2) {
+ giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %u.", length);
+ return -1;
+ }
+
+ if (git_vector_init(&list, length - 1, NULL) < 0)
+ return -1;
+
+ if (git_revwalk_new(&walk, repo) < 0)
+ goto cleanup;
+
+ for (i = 1; i < length; i++) {
+ commit = commit_lookup(walk, &input_array[i]);
+ if (commit == NULL)
+ goto cleanup;
+
+ git_vector_insert(&list, commit);
+ }
+
+ commit = commit_lookup(walk, &input_array[0]);
+ if (commit == NULL)
+ goto cleanup;
+
+ if (git_merge__bases_many(&result, walk, commit, &list) < 0)
+ goto cleanup;
+
+ if (!result) {
+ error = GIT_ENOTFOUND;
+ goto cleanup;
+ }
+
+ git_oid_cpy(out, &result->item->oid);
+
+ error = 0;
+
+cleanup:
+ git_commit_list_free(&result);
+ git_revwalk_free(walk);
+ git_vector_free(&list);
+ return error;
+}
+
+int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two)
+{
+ git_revwalk *walk;
+ git_vector list;
+ git_commit_list *result = NULL;
+ git_commit_list_node *commit;
+ void *contents[1];
+
+ if (git_revwalk_new(&walk, repo) < 0)
+ return -1;
+
+ commit = commit_lookup(walk, two);
+ if (commit == NULL)
+ goto on_error;
+
+ /* This is just one value, so we can do it on the stack */
+ memset(&list, 0x0, sizeof(git_vector));
+ contents[0] = commit;
+ list.length = 1;
+ list.contents = contents;
+
+ commit = commit_lookup(walk, one);
+ if (commit == NULL)
+ goto on_error;
+
+ if (git_merge__bases_many(&result, walk, commit, &list) < 0)
+ goto on_error;
+
+ if (!result) {
+ git_revwalk_free(walk);
+ giterr_clear();
+ return GIT_ENOTFOUND;
+ }
+
+ git_oid_cpy(out, &result->item->oid);
+ git_commit_list_free(&result);
+ git_revwalk_free(walk);
+
+ return 0;
+
+on_error:
+ git_revwalk_free(walk);
+ return -1;
+}
+
+static int interesting(git_pqueue *list)
+{
+ unsigned int i;
+ /* element 0 isn't used - we need to start at 1 */
+ for (i = 1; i < list->size; i++) {
+ git_commit_list_node *commit = list->d[i];
+ if ((commit->flags & STALE) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
+{
+ int error;
+ unsigned int i;
+ git_commit_list_node *two;
+ git_commit_list *result = NULL, *tmp = NULL;
+ git_pqueue list;
+
+ /* if the commit is repeated, we have a our merge base already */
+ git_vector_foreach(twos, i, two) {
+ if (one == two)
+ return git_commit_list_insert(one, out) ? 0 : -1;
+ }
+
+ if (git_pqueue_init(&list, twos->length * 2, git_commit_list_time_cmp) < 0)
+ return -1;
+
+ if (git_commit_list_parse(walk, one) < 0)
+ return -1;
+
+ one->flags |= PARENT1;
+ if (git_pqueue_insert(&list, one) < 0)
+ return -1;
+
+ git_vector_foreach(twos, i, two) {
+ git_commit_list_parse(walk, two);
+ two->flags |= PARENT2;
+ if (git_pqueue_insert(&list, two) < 0)
+ return -1;
+ }
+
+ /* as long as there are non-STALE commits */
+ while (interesting(&list)) {
+ git_commit_list_node *commit;
+ int flags;
+
+ commit = git_pqueue_pop(&list);
+
+ flags = commit->flags & (PARENT1 | PARENT2 | STALE);
+ if (flags == (PARENT1 | PARENT2)) {
+ if (!(commit->flags & RESULT)) {
+ commit->flags |= RESULT;
+ if (git_commit_list_insert(commit, &result) == NULL)
+ return -1;
+ }
+ /* we mark the parents of a merge stale */
+ flags |= STALE;
+ }
+
+ for (i = 0; i < commit->out_degree; i++) {
+ git_commit_list_node *p = commit->parents[i];
+ if ((p->flags & flags) == flags)
+ continue;
+
+ if ((error = git_commit_list_parse(walk, p)) < 0)
+ return error;
+
+ p->flags |= flags;
+ if (git_pqueue_insert(&list, p) < 0)
+ return -1;
+ }
+ }
+
+ git_pqueue_free(&list);
+
+ /* filter out any stale commits in the results */
+ tmp = result;
+ result = NULL;
+
+ while (tmp) {
+ struct git_commit_list *next = tmp->next;
+ if (!(tmp->item->flags & STALE))
+ if (git_commit_list_insert_by_date(tmp->item, &result) == NULL)
+ return -1;
+
+ git__free(tmp);
+ tmp = next;
+ }
+
+ *out = result;
+ return 0;
+}
+
diff --git a/src/merge.h b/src/merge.h
index 2117d92..3681e24 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -8,6 +8,8 @@
#define INCLUDE_merge_h__
#include "git2/types.h"
+#include "git2/merge.h"
+#include "commit_list.h"
#define GIT_MERGE_MSG_FILE "MERGE_MSG"
#define GIT_MERGE_MODE_FILE "MERGE_MODE"
@@ -15,5 +17,6 @@
#define MERGE_CONFIG_FILE_MODE 0666
int git_merge__cleanup(git_repository *repo);
+int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos);
#endif
diff --git a/src/notes.c b/src/notes.c
index 81e4e50..dd36cc2 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -19,11 +19,11 @@ static int find_subtree_in_current_level(
const char *annotated_object_sha,
int fanout)
{
- unsigned int i;
+ size_t i;
const git_tree_entry *entry;
*out = NULL;
-
+
if (parent == NULL)
return GIT_ENOTFOUND;
@@ -34,12 +34,12 @@ static int find_subtree_in_current_level(
continue;
if (S_ISDIR(git_tree_entry_filemode(entry))
- && strlen(git_tree_entry_name(entry)) == 2
+ && strlen(git_tree_entry_name(entry)) == 2
&& !strncmp(git_tree_entry_name(entry), annotated_object_sha + fanout, 2))
return git_tree_lookup(out, repo, git_tree_entry_id(entry));
/* Not a DIR, so do we have an already existing blob? */
- if (!strcmp(git_tree_entry_name(entry), annotated_object_sha + fanout))
+ if (!strcmp(git_tree_entry_name(entry), annotated_object_sha + fanout))
return GIT_EEXISTS;
}
@@ -71,7 +71,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
static int find_blob(git_oid *blob, git_tree *tree, const char *target)
{
- unsigned int i;
+ size_t i;
const git_tree_entry *entry;
for (i=0; i<git_tree_entrycount(tree); i++) {
@@ -263,8 +263,8 @@ static int insert_note_in_tree_enotfound_cb(git_tree **out,
static int note_write(git_oid *out,
git_repository *repo,
- git_signature *author,
- git_signature *committer,
+ const git_signature *author,
+ const git_signature *committer,
const char *notes_ref,
const char *note,
git_tree *commit_tree,
@@ -343,9 +343,9 @@ cleanup:
}
static int note_remove(git_repository *repo,
- git_signature *author, git_signature *committer,
- const char *notes_ref, git_tree *tree,
- const char *target, git_commit **parents)
+ const git_signature *author, const git_signature *committer,
+ const char *notes_ref, git_tree *tree,
+ const char *target, git_commit **parents)
{
int error;
git_tree *tree_after_removal = NULL;
@@ -406,7 +406,7 @@ static int retrieve_note_tree_and_commit(
if ((error = normalize_namespace(notes_ref, repo)) < 0)
return error;
- if ((error = git_reference_name_to_oid(&oid, repo, *notes_ref)) < 0)
+ if ((error = git_reference_name_to_id(&oid, repo, *notes_ref)) < 0)
return error;
if (git_commit_lookup(commit_out, repo, &oid) < 0)
@@ -442,9 +442,12 @@ cleanup:
}
int git_note_create(
- git_oid *out, git_repository *repo,
- git_signature *author, git_signature *committer,
- const char *notes_ref, const git_oid *oid,
+ git_oid *out,
+ git_repository *repo,
+ const git_signature *author,
+ const git_signature *committer,
+ const char *notes_ref,
+ const git_oid *oid,
const char *note)
{
int error;
@@ -461,7 +464,7 @@ int git_note_create(
goto cleanup;
error = note_write(out, repo, author, committer, notes_ref,
- note, tree, target, &commit);
+ note, tree, target, &commit);
cleanup:
git__free(target);
@@ -471,8 +474,8 @@ cleanup:
}
int git_note_remove(git_repository *repo, const char *notes_ref,
- git_signature *author, git_signature *committer,
- const git_oid *oid)
+ const git_signature *author, const git_signature *committer,
+ const git_oid *oid)
{
int error;
char *target = NULL;
@@ -501,13 +504,13 @@ int git_note_default_ref(const char **out, git_repository *repo)
return note_get_default_ref(out, repo);
}
-const char * git_note_message(git_note *note)
+const char * git_note_message(const git_note *note)
{
assert(note);
return note->message;
}
-const git_oid * git_note_oid(git_note *note)
+const git_oid * git_note_oid(const git_note *note)
{
assert(note);
return ¬e->oid;
@@ -525,13 +528,13 @@ void git_note_free(git_note *note)
static int process_entry_path(
const char* entry_path,
const git_oid *note_oid,
- int (*note_cb)(git_note_data *note_data, void *payload),
+ git_note_foreach_cb note_cb,
void *payload)
{
int error = -1;
size_t i = 0, j = 0, len;
git_buf buf = GIT_BUF_INIT;
- git_note_data note_data;
+ git_oid annotated_object_id;
if ((error = git_buf_puts(&buf, entry_path)) < 0)
goto cleanup;
@@ -564,13 +567,10 @@ static int process_entry_path(
goto cleanup;
}
- if ((error = git_oid_fromstr(
- ¬e_data.annotated_object_oid, buf.ptr)) < 0)
+ if ((error = git_oid_fromstr(&annotated_object_id, buf.ptr)) < 0)
goto cleanup;
- git_oid_cpy(¬e_data.blob_oid, note_oid);
-
- if (note_cb(¬e_data, payload))
+ if (note_cb(note_oid, &annotated_object_id, payload))
error = GIT_EUSER;
cleanup:
@@ -581,7 +581,7 @@ cleanup:
int git_note_foreach(
git_repository *repo,
const char *notes_ref,
- int (*note_cb)(git_note_data *note_data, void *payload),
+ git_note_foreach_cb note_cb,
void *payload)
{
int error;
diff --git a/src/object.c b/src/object.c
index 3d95303..f71ee48 100644
--- a/src/object.c
+++ b/src/object.c
@@ -334,7 +334,7 @@ static int dereference_object(git_object **dereferenced, git_object *obj)
int git_object_peel(
git_object **peeled,
- git_object *object,
+ const git_object *object,
git_otype target_type)
{
git_object *source, *deref = NULL;
@@ -342,9 +342,9 @@ int git_object_peel(
assert(object && peeled);
if (git_object_type(object) == target_type)
- return git_object__dup(peeled, object);
+ return git_object__dup(peeled, (git_object *)object);
- source = object;
+ source = (git_object *)object;
while (!dereference_object(&deref, source)) {
diff --git a/src/odb.c b/src/odb.c
index 9c602d1..e622eb0 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -683,14 +683,14 @@ int git_odb_read_prefix(
return 0;
}
-int git_odb_foreach(git_odb *db, int (*cb)(git_oid *oid, void *data), void *data)
+int git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload)
{
unsigned int i;
backend_internal *internal;
git_vector_foreach(&db->backends, i, internal) {
git_odb_backend *b = internal->backend;
- int error = b->foreach(b, cb, data);
+ int error = b->foreach(b, cb, payload);
if (error < 0)
return error;
}
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 41121ae..e2f1aec 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -678,7 +678,7 @@ static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
struct foreach_state {
size_t dir_len;
- int (*cb)(git_oid *oid, void *data);
+ git_odb_foreach_cb cb;
void *data;
int cb_error;
};
@@ -734,7 +734,7 @@ static int foreach_cb(void *_state, git_buf *path)
return git_path_direach(path, foreach_object_dir_cb, state);
}
-static int loose_backend__foreach(git_odb_backend *_backend, int (*cb)(git_oid *oid, void *data), void *data)
+static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data)
{
char *objects_dir;
int error;
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 9f7a6ee..35bf158 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -458,7 +458,7 @@ static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid)
return pack_entry_find(&e, (struct pack_backend *)backend, oid) == 0;
}
-static int pack_backend__foreach(git_odb_backend *_backend, int (*cb)(git_oid *oid, void *data), void *data)
+static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data)
{
int error;
struct git_pack_file *p;
diff --git a/src/pack-objects.c b/src/pack-objects.c
index a146dc0..008d8f2 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -136,10 +136,11 @@ on_error:
return -1;
}
-void git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n)
+unsigned int git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n)
{
assert(pb);
pb->nr_threads = n;
+ return pb->nr_threads;
}
static void rehash(git_packbuilder *pb)
@@ -228,7 +229,7 @@ static int gen_pack_object_header(
}
*hdr++ = c;
- return hdr - hdr_base;
+ return (int)(hdr - hdr_base);
}
static int get_delta(void **out, git_odb *odb, git_pobject *po)
@@ -243,9 +244,10 @@ static int get_delta(void **out, git_odb *odb, git_pobject *po)
git_odb_read(&trg, odb, &po->id) < 0)
goto on_error;
- delta_buf = git_delta(git_odb_object_data(src), git_odb_object_size(src),
- git_odb_object_data(trg), git_odb_object_size(trg),
- &delta_size, 0);
+ delta_buf = git_delta(
+ git_odb_object_data(src), (unsigned long)git_odb_object_size(src),
+ git_odb_object_data(trg), (unsigned long)git_odb_object_size(trg),
+ &delta_size, 0);
if (!delta_buf || delta_size != po->delta_size) {
giterr_set(GITERR_INVALID, "Delta size changed");
@@ -286,7 +288,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
goto on_error;
data = (void *)git_odb_object_data(obj);
- size = git_odb_object_size(obj);
+ size = (unsigned long)git_odb_object_size(obj);
type = git_odb_object_type(obj);
}
@@ -314,7 +316,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
if (po->delta)
git__free(data);
data = zbuf.ptr;
- size = zbuf.size;
+ size = (unsigned long)zbuf.size;
}
if (git_buf_put(buf, data, size) < 0 ||
@@ -706,7 +708,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
return 0;
/* Now some size filtering heuristics. */
- trg_size = trg_object->size;
+ trg_size = (unsigned long)trg_object->size;
if (!trg_object->delta) {
max_size = trg_size/2 - 20;
ref_depth = 1;
@@ -720,7 +722,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
if (max_size == 0)
return 0;
- src_size = src_object->size;
+ src_size = (unsigned long)src_object->size;
sizediff = src_size < trg_size ? trg_size - src_size : 0;
if (sizediff >= max_size)
return 0;
@@ -732,7 +734,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
if (git_odb_read(&obj, pb->odb, &trg_object->id) < 0)
return -1;
- sz = git_odb_object_size(obj);
+ sz = (unsigned long)git_odb_object_size(obj);
trg->data = git__malloc(sz);
GITERR_CHECK_ALLOC(trg->data);
memcpy(trg->data, git_odb_object_data(obj), sz);
@@ -751,7 +753,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
if (git_odb_read(&obj, pb->odb, &src_object->id) < 0)
return -1;
- sz = git_odb_object_size(obj);
+ sz = (unsigned long)git_odb_object_size(obj);
src->data = git__malloc(sz);
GITERR_CHECK_ALLOC(src->data);
memcpy(src->data, git_odb_object_data(obj), sz);
@@ -834,7 +836,7 @@ static unsigned long free_unpacked(struct unpacked *n)
git_delta_free_index(n->index);
n->index = NULL;
if (n->data) {
- freed_mem += n->object->size;
+ freed_mem += (unsigned long)n->object->size;
git__free(n->data);
n->data = NULL;
}
@@ -940,7 +942,7 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
GITERR_CHECK_ALLOC(po->delta_data);
memcpy(po->delta_data, zbuf.ptr, zbuf.size);
- po->z_delta_size = zbuf.size;
+ po->z_delta_size = (unsigned long)zbuf.size;
git_buf_clear(&zbuf);
git_packbuilder__cache_lock(pb);
@@ -1283,7 +1285,7 @@ int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid)
git_packbuilder_insert(pb, oid, NULL) < 0)
return -1;
- if (git_tree_walk(tree, cb_tree_walk, GIT_TREEWALK_PRE, pb) < 0) {
+ if (git_tree_walk(tree, GIT_TREEWALK_PRE, cb_tree_walk, pb) < 0) {
git_tree_free(tree);
return -1;
}
diff --git a/src/pack.c b/src/pack.c
index a2a2fbc..6cb46d3 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -698,7 +698,7 @@ static int git__memcmp4(const void *a, const void *b) {
int git_pack_foreach_entry(
struct git_pack_file *p,
- int (*cb)(git_oid *oid, void *data),
+ git_odb_foreach_cb cb,
void *data)
{
const unsigned char *index = p->index_map.data, *current;
diff --git a/src/pack.h b/src/pack.h
index af87b7c..9fb26b6 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -105,7 +105,7 @@ int git_pack_entry_find(
size_t len);
int git_pack_foreach_entry(
struct git_pack_file *p,
- int (*cb)(git_oid *oid, void *data),
+ git_odb_foreach_cb cb,
void *data);
#endif
diff --git a/src/reflog.c b/src/reflog.c
index 7b07c6a..ac481fb 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -10,7 +10,7 @@
#include "filebuf.h"
#include "signature.h"
-static int reflog_init(git_reflog **reflog, git_reference *ref)
+static int reflog_init(git_reflog **reflog, const git_reference *ref)
{
git_reflog *log;
@@ -180,7 +180,7 @@ void git_reflog_free(git_reflog *reflog)
git__free(reflog);
}
-static int retrieve_reflog_path(git_buf *path, git_reference *ref)
+static int retrieve_reflog_path(git_buf *path, const git_reference *ref)
{
return git_buf_join_n(path, '/', 3,
git_reference_owner(ref)->path_repository, GIT_REFLOG_DIR, ref->name);
@@ -201,7 +201,7 @@ static int create_new_reflog_file(const char *filepath)
return p_close(fd);
}
-int git_reflog_read(git_reflog **reflog, git_reference *ref)
+int git_reflog_read(git_reflog **reflog, const git_reference *ref)
{
int error = -1;
git_buf log_path = GIT_BUF_INIT;
@@ -275,7 +275,7 @@ int git_reflog_write(git_reflog *reflog)
if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0)
goto cleanup;
}
-
+
error = git_filebuf_commit(&fbuf, GIT_REFLOG_FILE_MODE);
goto success;
@@ -405,45 +405,47 @@ int git_reflog_delete(git_reference *ref)
return error;
}
-unsigned int git_reflog_entrycount(git_reflog *reflog)
+size_t git_reflog_entrycount(git_reflog *reflog)
{
assert(reflog);
- return (unsigned int)reflog->entries.length;
+ return reflog->entries.length;
}
-const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx)
+GIT_INLINE(size_t) reflog_inverse_index(size_t idx, size_t total)
{
- int pos;
+ return (total - 1) - idx;
+}
+const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx)
+{
assert(reflog);
- pos = git_reflog_entrycount(reflog) - (idx + 1);
-
- if (pos < 0)
+ if (idx >= reflog->entries.length)
return NULL;
- return git_vector_get(&reflog->entries, pos);
+ return git_vector_get(
+ &reflog->entries, reflog_inverse_index(idx, reflog->entries.length));
}
-const git_oid * git_reflog_entry_oidold(const git_reflog_entry *entry)
+const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry)
{
assert(entry);
return &entry->oid_old;
}
-const git_oid * git_reflog_entry_oidnew(const git_reflog_entry *entry)
+const git_oid * git_reflog_entry_id_new(const git_reflog_entry *entry)
{
assert(entry);
return &entry->oid_cur;
}
-git_signature * git_reflog_entry_committer(const git_reflog_entry *entry)
+const git_signature * git_reflog_entry_committer(const git_reflog_entry *entry)
{
assert(entry);
return entry->committer;
}
-char * git_reflog_entry_msg(const git_reflog_entry *entry)
+const char * git_reflog_entry_message(const git_reflog_entry *entry)
{
assert(entry);
return entry->msg;
@@ -454,7 +456,7 @@ int git_reflog_drop(
size_t idx,
int rewrite_previous_entry)
{
- unsigned int entrycount;
+ size_t entrycount;
git_reflog_entry *entry, *previous;
assert(reflog);
@@ -468,7 +470,8 @@ int git_reflog_drop(
reflog_entry_free(entry);
- if (git_vector_remove(&reflog->entries, entrycount - (idx + 1)) < 0)
+ if (git_vector_remove(
+ &reflog->entries, reflog_inverse_index(idx, entrycount)) < 0)
return -1;
if (!rewrite_previous_entry)
@@ -489,7 +492,7 @@ int git_reflog_drop(
/* ...clear the oid_old member of the "new" oldest entry */
if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0)
return -1;
-
+
return 0;
}
diff --git a/src/refs.c b/src/refs.c
index 97c9756..76c9f42 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -647,7 +647,7 @@ static int packed_find_peel(git_repository *repo, struct packref *ref)
/*
* Find the object pointed at by this tag
*/
- git_oid_cpy(&ref->peel, git_tag_target_oid(tag));
+ git_oid_cpy(&ref->peel, git_tag_target_id(tag));
ref->flags |= GIT_PACKREF_HAS_PEEL;
/*
@@ -1074,7 +1074,7 @@ int git_reference_lookup(git_reference **ref_out,
return git_reference_lookup_resolved(ref_out, repo, name, 0);
}
-int git_reference_name_to_oid(
+int git_reference_name_to_id(
git_oid *out, git_repository *repo, const char *name)
{
int error;
@@ -1083,7 +1083,7 @@ int git_reference_name_to_oid(
if ((error = git_reference_lookup_resolved(&ref, repo, name, -1)) < 0)
return error;
- git_oid_cpy(out, git_reference_oid(ref));
+ git_oid_cpy(out, git_reference_target(ref));
git_reference_free(ref);
return 0;
}
@@ -1153,7 +1153,7 @@ int git_reference_lookup_resolved(
/**
* Getters
*/
-git_ref_t git_reference_type(git_reference *ref)
+git_ref_t git_reference_type(const git_reference *ref)
{
assert(ref);
@@ -1172,19 +1172,19 @@ int git_reference_is_packed(git_reference *ref)
return !!(ref->flags & GIT_REF_PACKED);
}
-const char *git_reference_name(git_reference *ref)
+const char *git_reference_name(const git_reference *ref)
{
assert(ref);
return ref->name;
}
-git_repository *git_reference_owner(git_reference *ref)
+git_repository *git_reference_owner(const git_reference *ref)
{
assert(ref);
return ref->owner;
}
-const git_oid *git_reference_oid(git_reference *ref)
+const git_oid *git_reference_target(const git_reference *ref)
{
assert(ref);
@@ -1194,7 +1194,7 @@ const git_oid *git_reference_oid(git_reference *ref)
return &ref->target.oid;
}
-const char *git_reference_target(git_reference *ref)
+const char *git_reference_symbolic_target(const git_reference *ref)
{
assert(ref);
@@ -1204,7 +1204,7 @@ const char *git_reference_target(git_reference *ref)
return ref->target.symbolic;
}
-int git_reference_create_symbolic(
+int git_reference_symbolic_create(
git_reference **ref_out,
git_repository *repo,
const char *name,
@@ -1231,7 +1231,7 @@ int git_reference_create_symbolic(
/* set the target; this will normalize the name automatically
* and write the reference on disk */
- if (git_reference_set_target(ref, target) < 0) {
+ if (git_reference_symbolic_set_target(ref, target) < 0) {
git_reference_free(ref);
return -1;
}
@@ -1244,7 +1244,7 @@ int git_reference_create_symbolic(
return 0;
}
-int git_reference_create_oid(
+int git_reference_create(
git_reference **ref_out,
git_repository *repo,
const char *name,
@@ -1270,7 +1270,7 @@ int git_reference_create_oid(
ref->flags |= GIT_REF_OID;
/* set the oid; this will write the reference on disk */
- if (git_reference_set_oid(ref, id) < 0) {
+ if (git_reference_set_target(ref, id) < 0) {
git_reference_free(ref);
return -1;
}
@@ -1292,7 +1292,7 @@ int git_reference_create_oid(
* We do not repack packed references because of performance
* reasons.
*/
-int git_reference_set_oid(git_reference *ref, const git_oid *id)
+int git_reference_set_target(git_reference *ref, const git_oid *id)
{
git_odb *odb = NULL;
@@ -1328,7 +1328,7 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id)
* a pack. We just change the target in memory
* and overwrite the file on disk.
*/
-int git_reference_set_target(git_reference *ref, const char *target)
+int git_reference_symbolic_set_target(git_reference *ref, const char *target)
{
char normalized[GIT_REFNAME_MAX];
@@ -1397,10 +1397,10 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
* Finally we can create the new reference.
*/
if (ref->flags & GIT_REF_SYMBOLIC) {
- result = git_reference_create_symbolic(
+ result = git_reference_symbolic_create(
NULL, ref->owner, new_name, ref->target.symbolic, force);
} else {
- result = git_reference_create_oid(
+ result = git_reference_create(
NULL, ref->owner, new_name, &ref->target.oid, force);
}
@@ -1444,10 +1444,10 @@ rollback:
* Try to create the old reference again, ignore failures
*/
if (ref->flags & GIT_REF_SYMBOLIC)
- git_reference_create_symbolic(
+ git_reference_symbolic_create(
NULL, ref->owner, ref->name, ref->target.symbolic, 0);
else
- git_reference_create_oid(
+ git_reference_create(
NULL, ref->owner, ref->name, &ref->target.oid, 0);
/* The reference is no longer packed */
@@ -1457,7 +1457,7 @@ rollback:
return -1;
}
-int git_reference_resolve(git_reference **ref_out, git_reference *ref)
+int git_reference_resolve(git_reference **ref_out, const git_reference *ref)
{
if (ref->flags & GIT_REF_OID)
return git_reference_lookup(ref_out, ref->owner, ref->name);
@@ -1478,7 +1478,7 @@ int git_reference_packall(git_repository *repo)
int git_reference_foreach(
git_repository *repo,
unsigned int list_flags,
- int (*callback)(const char *, void *),
+ git_reference_foreach_cb callback,
void *payload)
{
int result;
@@ -1797,7 +1797,7 @@ int git_reference__update(git_repository *repo, const git_oid *oid, const char *
* a new reference and that's it */
if (res == GIT_ENOTFOUND) {
giterr_clear();
- return git_reference_create_oid(NULL, repo, ref_name, oid, 1);
+ return git_reference_create(NULL, repo, ref_name, oid, 1);
}
if (res < 0)
@@ -1810,7 +1810,7 @@ int git_reference__update(git_repository *repo, const git_oid *oid, const char *
const char *sym_target;
/* The target pointed at by this reference */
- sym_target = git_reference_target(ref);
+ sym_target = git_reference_symbolic_target(ref);
/* resolve the reference to the target it points to */
res = git_reference_resolve(&aux, ref);
@@ -1822,7 +1822,7 @@ int git_reference__update(git_repository *repo, const git_oid *oid, const char *
*/
if (res == GIT_ENOTFOUND) {
giterr_clear();
- res = git_reference_create_oid(NULL, repo, sym_target, oid, 1);
+ res = git_reference_create(NULL, repo, sym_target, oid, 1);
git_reference_free(ref);
return res;
}
@@ -1840,7 +1840,7 @@ int git_reference__update(git_repository *repo, const git_oid *oid, const char *
/* ref is made to point to `oid`: ref is either the original reference,
* or the target of the symbolic reference we've looked up */
- res = git_reference_set_oid(ref, oid);
+ res = git_reference_set_target(ref, oid);
git_reference_free(ref);
return res;
}
@@ -1923,7 +1923,7 @@ static int reference_target(git_object **object, git_reference *ref)
{
const git_oid *oid;
- oid = git_reference_oid(ref);
+ oid = git_reference_target(ref);
return git_object_lookup(object, git_reference_owner(ref), oid, GIT_OBJ_ANY);
}
diff --git a/src/remote.c b/src/remote.c
index 4a4d160..bdec3c1 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -252,7 +252,7 @@ static int update_config_refspec(
&name,
"remote.%s.%s",
remote_name,
- git_direction == GIT_DIR_FETCH ? "fetch" : "push") < 0)
+ git_direction == GIT_DIRECTION_FETCH ? "fetch" : "push") < 0)
goto cleanup;
if (git_refspec__serialize(&value, refspec) < 0)
@@ -303,7 +303,7 @@ int git_remote_save(const git_remote *remote)
return -1;
}
} else {
- int error = git_config_delete(config, git_buf_cstr(&buf));
+ int error = git_config_delete_entry(config, git_buf_cstr(&buf));
if (error == GIT_ENOTFOUND) {
error = 0;
giterr_clear();
@@ -318,14 +318,14 @@ int git_remote_save(const git_remote *remote)
config,
remote->name,
&remote->fetch,
- GIT_DIR_FETCH) < 0)
+ GIT_DIRECTION_FETCH) < 0)
goto on_error;
if (update_config_refspec(
config,
remote->name,
&remote->push,
- GIT_DIR_PUSH) < 0)
+ GIT_DIRECTION_PUSH) < 0)
goto on_error;
/*
@@ -356,7 +356,7 @@ int git_remote_save(const git_remote *remote)
if (git_config_set_string(config, git_buf_cstr(&buf), "--no-tags") < 0)
goto on_error;
} else if (tagopt) {
- if (git_config_delete(config, git_buf_cstr(&buf)) < 0)
+ if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0)
goto on_error;
}
@@ -369,13 +369,13 @@ on_error:
return -1;
}
-const char *git_remote_name(git_remote *remote)
+const char *git_remote_name(const git_remote *remote)
{
assert(remote);
return remote->name;
}
-const char *git_remote_url(git_remote *remote)
+const char *git_remote_url(const git_remote *remote)
{
assert(remote);
return remote->url;
@@ -393,7 +393,7 @@ int git_remote_set_url(git_remote *remote, const char* url)
return 0;
}
-const char *git_remote_pushurl(git_remote *remote)
+const char *git_remote_pushurl(const git_remote *remote)
{
assert(remote);
return remote->pushurl;
@@ -429,7 +429,7 @@ int git_remote_set_fetchspec(git_remote *remote, const char *spec)
return 0;
}
-const git_refspec *git_remote_fetchspec(git_remote *remote)
+const git_refspec *git_remote_fetchspec(const git_remote *remote)
{
assert(remote);
return &remote->fetch;
@@ -451,7 +451,7 @@ int git_remote_set_pushspec(git_remote *remote, const char *spec)
return 0;
}
-const git_refspec *git_remote_pushspec(git_remote *remote)
+const git_refspec *git_remote_pushspec(const git_remote *remote)
{
assert(remote);
return &remote->push;
@@ -461,18 +461,18 @@ const char* git_remote__urlfordirection(git_remote *remote, int direction)
{
assert(remote);
- if (direction == GIT_DIR_FETCH) {
+ if (direction == GIT_DIRECTION_FETCH) {
return remote->url;
}
- if (direction == GIT_DIR_PUSH) {
+ if (direction == GIT_DIRECTION_PUSH) {
return remote->pushurl ? remote->pushurl : remote->url;
}
return NULL;
}
-int git_remote_connect(git_remote *remote, int direction)
+int git_remote_connect(git_remote *remote, git_direction direction)
{
git_transport *t;
const char *url;
@@ -492,7 +492,7 @@ int git_remote_connect(git_remote *remote, int direction)
return -1;
if (t->set_callbacks &&
- t->set_callbacks(t, remote->callbacks.progress, NULL, remote->callbacks.data) < 0)
+ t->set_callbacks(t, remote->callbacks.progress, NULL, remote->callbacks.payload) < 0)
goto on_error;
if (!remote->check_cert)
@@ -695,7 +695,7 @@ int git_remote_update_tips(git_remote *remote)
head = (git_remote_head *)refs.contents[0];
if (!strcmp(head->name, GIT_HEAD_FILE)) {
- if (git_reference_create_oid(&ref, remote->repo, GIT_FETCH_HEAD_FILE, &head->oid, 1) < 0)
+ if (git_reference_create(&ref, remote->repo, GIT_FETCH_HEAD_FILE, &head->oid, 1) < 0)
goto on_error;
i = 1;
@@ -735,7 +735,7 @@ int git_remote_update_tips(git_remote *remote)
if (git_vector_insert(&update_heads, head) < 0)
goto on_error;
- error = git_reference_name_to_oid(&old, remote->repo, refname.ptr);
+ error = git_reference_name_to_id(&old, remote->repo, refname.ptr);
if (error < 0 && error != GIT_ENOTFOUND)
goto on_error;
@@ -746,14 +746,14 @@ int git_remote_update_tips(git_remote *remote)
continue;
/* In autotag mode, don't overwrite any locally-existing tags */
- error = git_reference_create_oid(&ref, remote->repo, refname.ptr, &head->oid, !autotag);
+ error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag);
if (error < 0 && error != GIT_EEXISTS)
goto on_error;
git_reference_free(ref);
if (remote->callbacks.update_tips != NULL) {
- if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.data) < 0)
+ if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.payload) < 0)
goto on_error;
}
}
@@ -936,7 +936,7 @@ void git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callback
remote->transport->set_callbacks(remote->transport,
remote->callbacks.progress,
NULL,
- remote->callbacks.data);
+ remote->callbacks.payload);
}
void git_remote_set_cred_acquire_cb(
@@ -967,12 +967,12 @@ const git_transfer_progress* git_remote_stats(git_remote *remote)
return &remote->stats;
}
-int git_remote_autotag(git_remote *remote)
+git_remote_autotag_option_t git_remote_autotag(git_remote *remote)
{
return remote->download_tags;
}
-void git_remote_set_autotag(git_remote *remote, int value)
+void git_remote_set_autotag(git_remote *remote, git_remote_autotag_option_t value)
{
remote->download_tags = value;
}
@@ -1194,7 +1194,7 @@ static int rename_fetch_refspecs(
if (git_repository_config__weakptr(&config, remote->repo) < 0)
goto cleanup;
- error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIR_FETCH);
+ error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIRECTION_FETCH);
cleanup:
git_buf_free(&serialized);
@@ -1205,7 +1205,7 @@ cleanup:
int git_remote_rename(
git_remote *remote,
const char *new_name,
- int (*callback)(const char *problematic_refspec, void *payload),
+ git_remote_rename_problem_cb callback,
void *payload)
{
int error;
diff --git a/src/remote.h b/src/remote.h
index 840c9a9..448a9e9 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -27,10 +27,10 @@ struct git_remote {
git_repository *repo;
git_remote_callbacks callbacks;
git_transfer_progress stats;
- unsigned int need_pack:1,
- download_tags:2, /* There are four possible values */
- check_cert:1,
- update_fetchhead:1;
+ unsigned int need_pack;
+ git_remote_autotag_option_t download_tags;
+ unsigned int check_cert;
+ unsigned int update_fetchhead;
};
const char* git_remote__urlfordirection(struct git_remote *remote, int direction);
diff --git a/src/repository.c b/src/repository.c
index deab771..b49b49b 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -361,7 +361,7 @@ static int find_repo(
int git_repository_open_ext(
git_repository **repo_ptr,
const char *start_path,
- uint32_t flags,
+ unsigned int flags,
const char *ceiling_dirs)
{
int error;
@@ -824,7 +824,7 @@ static int repo_init_config(
SET_REPO_CONFIG(string, "core.worktree", work_dir);
}
else if ((opts->flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0) {
- if (git_config_delete(config, "core.worktree") < 0)
+ if (git_config_delete_entry(config, "core.worktree") < 0)
giterr_clear();
}
} else {
@@ -1162,14 +1162,14 @@ int git_repository_init(
}
int git_repository_init_ext(
- git_repository **repo_out,
+ git_repository **out,
const char *given_repo,
git_repository_init_options *opts)
{
int error;
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT;
- assert(repo_out && given_repo && opts);
+ assert(out && given_repo && opts);
error = repo_init_directories(&repo_path, &wd_path, given_repo, opts);
if (error < 0)
@@ -1202,10 +1202,10 @@ int git_repository_init_ext(
if (error < 0)
goto cleanup;
- error = git_repository_open(repo_out, git_buf_cstr(&repo_path));
+ error = git_repository_open(out, git_buf_cstr(&repo_path));
if (!error && opts->origin_url)
- error = repo_init_create_origin(*repo_out, opts->origin_url);
+ error = repo_init_create_origin(*out, opts->origin_url);
cleanup:
git_buf_free(&repo_path);
@@ -1231,7 +1231,7 @@ int git_repository_head_detached(git_repository *repo)
return 0;
}
- exists = git_odb_exists(odb, git_reference_oid(ref));
+ exists = git_odb_exists(odb, git_reference_target(ref));
git_reference_free(ref);
return exists;
@@ -1250,7 +1250,7 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
return 0;
}
- error = git_reference_lookup_resolved(head_out, repo, git_reference_target(head), -1);
+ error = git_reference_lookup_resolved(head_out, repo, git_reference_symbolic_target(head), -1);
git_reference_free(head);
return error == GIT_ENOTFOUND ? GIT_EORPHANEDHEAD : error;
@@ -1305,7 +1305,7 @@ int git_repository_is_empty(git_repository *repo)
goto cleanup;
if (!(error = strcmp(
- git_reference_target(head),
+ git_reference_symbolic_target(head),
GIT_REFS_HEADS_DIR "master") == 0))
goto cleanup;
@@ -1356,7 +1356,7 @@ int git_repository_set_workdir(
/* passthrough error means gitlink is unnecessary */
if (error == GIT_PASSTHROUGH)
- error = git_config_delete(config, "core.worktree");
+ error = git_config_delete_entry(config, "core.worktree");
else if (!error)
error = git_config_set_string(config, "core.worktree", path.ptr);
@@ -1531,11 +1531,11 @@ int git_repository_set_head(
if (!error) {
if (git_reference_is_branch(ref))
- error = git_reference_create_symbolic(&new_head, repo, GIT_HEAD_FILE, git_reference_name(ref), 1);
+ error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, git_reference_name(ref), 1);
else
- error = git_repository_set_head_detached(repo, git_reference_oid(ref));
+ error = git_repository_set_head_detached(repo, git_reference_target(ref));
} else if (looks_like_a_branch(refname))
- error = git_reference_create_symbolic(&new_head, repo, GIT_HEAD_FILE, refname, 1);
+ error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, refname, 1);
git_reference_free(ref);
git_reference_free(new_head);
@@ -1559,7 +1559,7 @@ int git_repository_set_head_detached(
if ((error = git_object_peel(&peeled, object, GIT_OBJ_COMMIT)) < 0)
goto cleanup;
- error = git_reference_create_oid(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), 1);
+ error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), 1);
cleanup:
git_object_free(object);
@@ -1581,10 +1581,10 @@ int git_repository_detach_head(
if ((error = git_repository_head(&old_head, repo)) < 0)
return error;
- if ((error = git_object_lookup(&object, repo, git_reference_oid(old_head), GIT_OBJ_COMMIT)) < 0)
+ if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJ_COMMIT)) < 0)
goto cleanup;
- error = git_reference_create_oid(&new_head, repo, GIT_HEAD_FILE, git_reference_oid(old_head), 1);
+ error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head), 1);
cleanup:
git_object_free(object);
diff --git a/src/reset.c b/src/reset.c
index 8f470b2..d410a88 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -41,14 +41,14 @@ static int update_head(git_repository *repo, git_object *commit)
if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
goto cleanup;
- if ((error = git_reference_create_oid(
+ if ((error = git_reference_create(
&target,
repo,
- git_reference_target(head),
+ git_reference_symbolic_target(head),
git_object_id(commit), 0)) < 0)
goto cleanup;
} else {
- if ((error = git_reference_set_oid(head, git_object_id(commit))) < 0)
+ if ((error = git_reference_set_target(head, git_object_id(commit))) < 0)
goto cleanup;
}
@@ -63,7 +63,7 @@ cleanup:
int git_reset(
git_repository *repo,
git_object *target,
- git_reset_type reset_type)
+ git_reset_t reset_type)
{
git_object *commit = NULL;
git_index *index = NULL;
diff --git a/src/revparse.c b/src/revparse.c
index 6b49402..308b929 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -140,7 +140,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
error = disambiguate_refname(&ref, repo, spec);
if (!error) {
- error = git_object_lookup(out, repo, git_reference_oid(ref), GIT_OBJ_ANY);
+ error = git_object_lookup(out, repo, git_reference_target(ref), GIT_OBJ_ANY);
git_reference_free(ref);
return error;
}
@@ -161,7 +161,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
static int try_parse_numeric(int *n, const char *curly_braces_content)
{
- int content;
+ int32_t content;
const char *end_ptr;
if (git__strtol32(&content, curly_braces_content, &end_ptr, 10) < 0)
@@ -170,16 +170,17 @@ static int try_parse_numeric(int *n, const char *curly_braces_content)
if (*end_ptr != '\0')
return -1;
- *n = content;
+ *n = (int)content;
return 0;
}
-static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *spec, const char *identifier, unsigned int position)
+static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *spec, const char *identifier, size_t position)
{
git_reference *ref = NULL;
git_reflog *reflog = NULL;
regex_t preg;
- int numentries, i, cur, error = -1;
+ int error = -1;
+ size_t i, numentries, cur;
const git_reflog_entry *entry;
const char *msg;
regmatch_t regexmatches[2];
@@ -203,8 +204,8 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
for (i = 0; i < numentries; i++) {
entry = git_reflog_entry_byindex(reflog, i);
- msg = git_reflog_entry_msg(entry);
-
+ msg = git_reflog_entry_message(entry);
+
if (regexec(&preg, msg, 2, regexmatches, 0))
continue;
@@ -212,7 +213,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
if (cur > 0)
continue;
-
+
git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so);
if ((error = disambiguate_refname(base_ref, repo, git_buf_cstr(&buf))) == 0)
@@ -225,7 +226,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
goto cleanup;
}
-
+
error = GIT_ENOTFOUND;
cleanup:
@@ -236,49 +237,47 @@ cleanup:
return error;
}
-static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned int identifier)
+static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t identifier)
{
git_reflog *reflog;
int error = -1;
- unsigned int numentries;
+ size_t numentries;
const git_reflog_entry *entry;
bool search_by_pos = (identifier <= 100000000);
if (git_reflog_read(&reflog, ref) < 0)
return -1;
- numentries = git_reflog_entrycount(reflog);
+ numentries = git_reflog_entrycount(reflog);
if (search_by_pos) {
if (numentries < identifier + 1) {
giterr_set(
GITERR_REFERENCE,
- "Reflog for '%s' has only %d entries, asked for %d",
- git_reference_name(ref),
- numentries,
- identifier);
+ "Reflog for '%s' has only "PRIuZ" entries, asked for "PRIuZ,
+ git_reference_name(ref), numentries, identifier);
error = GIT_ENOTFOUND;
goto cleanup;
}
entry = git_reflog_entry_byindex(reflog, identifier);
- git_oid_cpy(oid, git_reflog_entry_oidnew(entry));
+ git_oid_cpy(oid, git_reflog_entry_id_new(entry));
error = 0;
goto cleanup;
} else {
- unsigned int i;
+ size_t i;
git_time commit_time;
for (i = 0; i < numentries; i++) {
entry = git_reflog_entry_byindex(reflog, i);
commit_time = git_reflog_entry_committer(entry)->when;
-
- if (commit_time.time - identifier > 0)
+
+ if (commit_time.time > (git_time_t)identifier)
continue;
- git_oid_cpy(oid, git_reflog_entry_oidnew(entry));
+ git_oid_cpy(oid, git_reflog_entry_id_new(entry));
error = 0;
goto cleanup;
}
@@ -291,7 +290,7 @@ cleanup:
return error;
}
-static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, unsigned int position)
+static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position)
{
git_reference *ref;
git_oid oid;
@@ -306,7 +305,7 @@ static int retrieve_revobject_from_reflog(git_object **out, git_reference **base
}
if (position == 0) {
- error = git_object_lookup(out, repo, git_reference_oid(ref), GIT_OBJ_ANY);
+ error = git_object_lookup(out, repo, git_reference_target(ref), GIT_OBJ_ANY);
goto cleanup;
}
@@ -380,7 +379,7 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s
if (git__date_parse(×tamp, curly_braces_content) < 0)
goto cleanup;
- error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (unsigned int)timestamp);
+ error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (size_t)timestamp);
cleanup:
git_buf_free(&identifier);
@@ -394,7 +393,7 @@ static git_otype parse_obj_type(const char *str)
if (!strcmp(str, "tree"))
return GIT_OBJ_TREE;
-
+
if (!strcmp(str, "blob"))
return GIT_OBJ_BLOB;
@@ -632,7 +631,7 @@ static int object_from_reference(git_object **object, git_reference *reference)
if (git_reference_resolve(&resolved, reference) < 0)
return -1;
- error = git_object_lookup(object, reference->owner, git_reference_oid(resolved), GIT_OBJ_ANY);
+ error = git_object_lookup(object, reference->owner, git_reference_target(resolved), GIT_OBJ_ANY);
git_reference_free(resolved);
return error;
diff --git a/src/revwalk.c b/src/revwalk.c
index 4fff238..bdbbdbd 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -8,149 +8,16 @@
#include "common.h"
#include "commit.h"
#include "odb.h"
-#include "pqueue.h"
#include "pool.h"
-#include "oidmap.h"
-#include "git2/revwalk.h"
-#include "git2/merge.h"
+#include "revwalk.h"
+#include "merge.h"
#include <regex.h>
-GIT__USE_OIDMAP;
-
-#define PARENT1 (1 << 0)
-#define PARENT2 (1 << 1)
-#define RESULT (1 << 2)
-#define STALE (1 << 3)
-
-typedef struct commit_object {
- git_oid oid;
- uint32_t time;
- unsigned int seen:1,
- uninteresting:1,
- topo_delay:1,
- parsed:1,
- flags : 4;
-
- unsigned short in_degree;
- unsigned short out_degree;
-
- struct commit_object **parents;
-} commit_object;
-
-typedef struct commit_list {
- commit_object *item;
- struct commit_list *next;
-} commit_list;
-
-struct git_revwalk {
- git_repository *repo;
- git_odb *odb;
-
- git_oidmap *commits;
- git_pool commit_pool;
-
- commit_list *iterator_topo;
- commit_list *iterator_rand;
- commit_list *iterator_reverse;
- git_pqueue iterator_time;
-
- int (*get_next)(commit_object **, git_revwalk *);
- int (*enqueue)(git_revwalk *, commit_object *);
-
- unsigned walking:1;
- unsigned int sorting;
-
- /* merge base calculation */
- commit_object *one;
- git_vector twos;
-};
-
-static int commit_time_cmp(void *a, void *b)
-{
- commit_object *commit_a = (commit_object *)a;
- commit_object *commit_b = (commit_object *)b;
-
- return (commit_a->time < commit_b->time);
-}
-
-static commit_list *commit_list_insert(commit_object *item, commit_list **list_p)
-{
- commit_list *new_list = git__malloc(sizeof(commit_list));
- if (new_list != NULL) {
- new_list->item = item;
- new_list->next = *list_p;
- }
- *list_p = new_list;
- return new_list;
-}
-
-static commit_list *commit_list_insert_by_date(commit_object *item, commit_list **list_p)
-{
- commit_list **pp = list_p;
- commit_list *p;
-
- while ((p = *pp) != NULL) {
- if (commit_time_cmp(p->item, item) < 0)
- break;
-
- pp = &p->next;
- }
-
- return commit_list_insert(item, pp);
-}
-static void commit_list_free(commit_list **list_p)
-{
- commit_list *list = *list_p;
-
- if (list == NULL)
- return;
-
- while (list) {
- commit_list *temp = list;
- list = temp->next;
- git__free(temp);
- }
-
- *list_p = NULL;
-}
-
-static commit_object *commit_list_pop(commit_list **stack)
-{
- commit_list *top = *stack;
- commit_object *item = top ? top->item : NULL;
-
- if (top) {
- *stack = top->next;
- git__free(top);
- }
- return item;
-}
-
-#define PARENTS_PER_COMMIT 2
-#define COMMIT_ALLOC \
- (sizeof(commit_object) + PARENTS_PER_COMMIT * sizeof(commit_object *))
-
-static commit_object *alloc_commit(git_revwalk *walk)
-{
- return (commit_object *)git_pool_malloc(&walk->commit_pool, COMMIT_ALLOC);
-}
-
-static commit_object **alloc_parents(
- git_revwalk *walk, commit_object *commit, size_t n_parents)
-{
- if (n_parents <= PARENTS_PER_COMMIT)
- return (commit_object **)((char *)commit + sizeof(commit_object));
-
- return (commit_object **)git_pool_malloc(
- &walk->commit_pool, (uint32_t)(n_parents * sizeof(commit_object *)));
-}
-
-
-static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
+git_commit_list_node *commit_lookup(git_revwalk *walk, const git_oid *oid)
{
- commit_object *commit;
+ git_commit_list_node *commit;
khiter_t pos;
int ret;
@@ -159,7 +26,7 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
if (pos != kh_end(walk->commits))
return kh_value(walk->commits, pos);
- commit = alloc_commit(walk);
+ commit = git_commit_list_alloc_node(walk);
if (commit == NULL)
return NULL;
@@ -172,300 +39,7 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
return commit;
}
-static int commit_error(commit_object *commit, const char *msg)
-{
- char commit_oid[GIT_OID_HEXSZ + 1];
- git_oid_fmt(commit_oid, &commit->oid);
- commit_oid[GIT_OID_HEXSZ] = '\0';
-
- giterr_set(GITERR_ODB, "Failed to parse commit %s - %s", commit_oid, msg);
-
- return -1;
-}
-
-static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawobj *raw)
-{
- const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1;
- unsigned char *buffer = raw->data;
- unsigned char *buffer_end = buffer + raw->len;
- unsigned char *parents_start, *committer_start;
- int i, parents = 0;
- int commit_time;
-
- buffer += strlen("tree ") + GIT_OID_HEXSZ + 1;
-
- parents_start = buffer;
- while (buffer + parent_len < buffer_end && memcmp(buffer, "parent ", strlen("parent ")) == 0) {
- parents++;
- buffer += parent_len;
- }
-
- commit->parents = alloc_parents(walk, commit, parents);
- GITERR_CHECK_ALLOC(commit->parents);
-
- buffer = parents_start;
- for (i = 0; i < parents; ++i) {
- git_oid oid;
-
- if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) < 0)
- return -1;
-
- commit->parents[i] = commit_lookup(walk, &oid);
- if (commit->parents[i] == NULL)
- return -1;
-
- buffer += parent_len;
- }
-
- commit->out_degree = (unsigned short)parents;
-
- if ((committer_start = buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
- return commit_error(commit, "object is corrupted");
-
- buffer++;
-
- if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
- return commit_error(commit, "object is corrupted");
-
- /* Skip trailing spaces */
- while (buffer > committer_start && git__isspace(*buffer))
- buffer--;
-
- /* Seek for the begining of the pack of digits */
- while (buffer > committer_start && git__isdigit(*buffer))
- buffer--;
-
- /* Skip potential timezone offset */
- if ((buffer > committer_start) && (*buffer == '+' || *buffer == '-')) {
- buffer--;
-
- while (buffer > committer_start && git__isspace(*buffer))
- buffer--;
-
- while (buffer > committer_start && git__isdigit(*buffer))
- buffer--;
- }
-
- if ((buffer == committer_start) || (git__strtol32(&commit_time, (char *)(buffer + 1), NULL, 10) < 0))
- return commit_error(commit, "cannot parse commit time");
-
- commit->time = (time_t)commit_time;
- commit->parsed = 1;
- return 0;
-}
-
-static int commit_parse(git_revwalk *walk, commit_object *commit)
-{
- git_odb_object *obj;
- int error;
-
- if (commit->parsed)
- return 0;
-
- if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
- return error;
- assert(obj->raw.type == GIT_OBJ_COMMIT);
-
- error = commit_quick_parse(walk, commit, &obj->raw);
- git_odb_object_free(obj);
- return error;
-}
-
-static int interesting(git_pqueue *list)
-{
- unsigned int i;
- /* element 0 isn't used - we need to start at 1 */
- for (i = 1; i < list->size; i++) {
- commit_object *commit = list->d[i];
- if ((commit->flags & STALE) == 0)
- return 1;
- }
-
- return 0;
-}
-
-static int merge_bases_many(commit_list **out, git_revwalk *walk, commit_object *one, git_vector *twos)
-{
- int error;
- unsigned int i;
- commit_object *two;
- commit_list *result = NULL, *tmp = NULL;
- git_pqueue list;
-
- /* if the commit is repeated, we have a our merge base already */
- git_vector_foreach(twos, i, two) {
- if (one == two)
- return commit_list_insert(one, out) ? 0 : -1;
- }
-
- if (git_pqueue_init(&list, twos->length * 2, commit_time_cmp) < 0)
- return -1;
-
- if (commit_parse(walk, one) < 0)
- return -1;
-
- one->flags |= PARENT1;
- if (git_pqueue_insert(&list, one) < 0)
- return -1;
-
- git_vector_foreach(twos, i, two) {
- commit_parse(walk, two);
- two->flags |= PARENT2;
- if (git_pqueue_insert(&list, two) < 0)
- return -1;
- }
-
- /* as long as there are non-STALE commits */
- while (interesting(&list)) {
- commit_object *commit;
- int flags;
-
- commit = git_pqueue_pop(&list);
-
- flags = commit->flags & (PARENT1 | PARENT2 | STALE);
- if (flags == (PARENT1 | PARENT2)) {
- if (!(commit->flags & RESULT)) {
- commit->flags |= RESULT;
- if (commit_list_insert(commit, &result) == NULL)
- return -1;
- }
- /* we mark the parents of a merge stale */
- flags |= STALE;
- }
-
- for (i = 0; i < commit->out_degree; i++) {
- commit_object *p = commit->parents[i];
- if ((p->flags & flags) == flags)
- continue;
-
- if ((error = commit_parse(walk, p)) < 0)
- return error;
-
- p->flags |= flags;
- if (git_pqueue_insert(&list, p) < 0)
- return -1;
- }
- }
-
- git_pqueue_free(&list);
-
- /* filter out any stale commits in the results */
- tmp = result;
- result = NULL;
-
- while (tmp) {
- struct commit_list *next = tmp->next;
- if (!(tmp->item->flags & STALE))
- if (commit_list_insert_by_date(tmp->item, &result) == NULL)
- return -1;
-
- git__free(tmp);
- tmp = next;
- }
-
- *out = result;
- return 0;
-}
-
-int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_array[], size_t length)
-{
- git_revwalk *walk;
- git_vector list;
- commit_list *result = NULL;
- int error = -1;
- unsigned int i;
- commit_object *commit;
-
- assert(out && repo && input_array);
-
- if (length < 2) {
- giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %u.", length);
- return -1;
- }
-
- if (git_vector_init(&list, length - 1, NULL) < 0)
- return -1;
-
- if (git_revwalk_new(&walk, repo) < 0)
- goto cleanup;
-
- for (i = 1; i < length; i++) {
- commit = commit_lookup(walk, &input_array[i]);
- if (commit == NULL)
- goto cleanup;
-
- git_vector_insert(&list, commit);
- }
-
- commit = commit_lookup(walk, &input_array[0]);
- if (commit == NULL)
- goto cleanup;
-
- if (merge_bases_many(&result, walk, commit, &list) < 0)
- goto cleanup;
-
- if (!result) {
- error = GIT_ENOTFOUND;
- goto cleanup;
- }
-
- git_oid_cpy(out, &result->item->oid);
-
- error = 0;
-
-cleanup:
- commit_list_free(&result);
- git_revwalk_free(walk);
- git_vector_free(&list);
- return error;
-}
-
-int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two)
-{
- git_revwalk *walk;
- git_vector list;
- commit_list *result = NULL;
- commit_object *commit;
- void *contents[1];
-
- if (git_revwalk_new(&walk, repo) < 0)
- return -1;
-
- commit = commit_lookup(walk, two);
- if (commit == NULL)
- goto on_error;
-
- /* This is just one value, so we can do it on the stack */
- memset(&list, 0x0, sizeof(git_vector));
- contents[0] = commit;
- list.length = 1;
- list.contents = contents;
-
- commit = commit_lookup(walk, one);
- if (commit == NULL)
- goto on_error;
-
- if (merge_bases_many(&result, walk, commit, &list) < 0)
- goto on_error;
-
- if (!result) {
- git_revwalk_free(walk);
- giterr_clear();
- return GIT_ENOTFOUND;
- }
-
- git_oid_cpy(out, &result->item->oid);
- commit_list_free(&result);
- git_revwalk_free(walk);
-
- return 0;
-
-on_error:
- git_revwalk_free(walk);
- return -1;
-}
-
-static void mark_uninteresting(commit_object *commit)
+static void mark_uninteresting(git_commit_list_node *commit)
{
unsigned short i;
assert(commit);
@@ -481,7 +55,7 @@ static void mark_uninteresting(commit_object *commit)
mark_uninteresting(commit->parents[i]);
}
-static int process_commit(git_revwalk *walk, commit_object *commit, int hide)
+static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int hide)
{
int error;
@@ -493,13 +67,13 @@ static int process_commit(git_revwalk *walk, commit_object *commit, int hide)
commit->seen = 1;
- if ((error = commit_parse(walk, commit)) < 0)
+ if ((error = git_commit_list_parse(walk, commit)) < 0)
return error;
return walk->enqueue(walk, commit);
}
-static int process_commit_parents(git_revwalk *walk, commit_object *commit)
+static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit)
{
unsigned short i;
int error = 0;
@@ -514,7 +88,7 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting)
{
git_object *obj;
git_otype type;
- commit_object *commit;
+ git_commit_list_node *commit;
if (git_object_lookup(&obj, walk->repo, oid, GIT_OBJ_ANY) < 0)
return -1;
@@ -559,7 +133,7 @@ static int push_ref(git_revwalk *walk, const char *refname, int hide)
{
git_oid oid;
- if (git_reference_name_to_oid(&oid, walk->repo, refname) < 0)
+ if (git_reference_name_to_id(&oid, walk->repo, refname) < 0)
return -1;
return push_commit(walk, &oid, hide);
@@ -659,20 +233,20 @@ int git_revwalk_hide_ref(git_revwalk *walk, const char *refname)
return push_ref(walk, refname, 1);
}
-static int revwalk_enqueue_timesort(git_revwalk *walk, commit_object *commit)
+static int revwalk_enqueue_timesort(git_revwalk *walk, git_commit_list_node *commit)
{
return git_pqueue_insert(&walk->iterator_time, commit);
}
-static int revwalk_enqueue_unsorted(git_revwalk *walk, commit_object *commit)
+static int revwalk_enqueue_unsorted(git_revwalk *walk, git_commit_list_node *commit)
{
- return commit_list_insert(commit, &walk->iterator_rand) ? 0 : -1;
+ return git_commit_list_insert(commit, &walk->iterator_rand) ? 0 : -1;
}
-static int revwalk_next_timesort(commit_object **object_out, git_revwalk *walk)
+static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk *walk)
{
int error;
- commit_object *next;
+ git_commit_list_node *next;
while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) {
if ((error = process_commit_parents(walk, next)) < 0)
@@ -688,12 +262,12 @@ static int revwalk_next_timesort(commit_object **object_out, git_revwalk *walk)
return GIT_ITEROVER;
}
-static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
+static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk *walk)
{
int error;
- commit_object *next;
+ git_commit_list_node *next;
- while ((next = commit_list_pop(&walk->iterator_rand)) != NULL) {
+ while ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL) {
if ((error = process_commit_parents(walk, next)) < 0)
return error;
@@ -707,13 +281,13 @@ static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
return GIT_ITEROVER;
}
-static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
+static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk *walk)
{
- commit_object *next;
+ git_commit_list_node *next;
unsigned short i;
for (;;) {
- next = commit_list_pop(&walk->iterator_topo);
+ next = git_commit_list_pop(&walk->iterator_topo);
if (next == NULL) {
giterr_clear();
return GIT_ITEROVER;
@@ -725,11 +299,11 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
}
for (i = 0; i < next->out_degree; ++i) {
- commit_object *parent = next->parents[i];
+ git_commit_list_node *parent = next->parents[i];
if (--parent->in_degree == 0 && parent->topo_delay) {
parent->topo_delay = 0;
- if (commit_list_insert(parent, &walk->iterator_topo) == NULL)
+ if (git_commit_list_insert(parent, &walk->iterator_topo) == NULL)
return -1;
}
}
@@ -739,9 +313,9 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
}
}
-static int revwalk_next_reverse(commit_object **object_out, git_revwalk *walk)
+static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *walk)
{
- *object_out = commit_list_pop(&walk->iterator_reverse);
+ *object_out = git_commit_list_pop(&walk->iterator_reverse);
return *object_out ? 0 : GIT_ITEROVER;
}
@@ -750,8 +324,8 @@ static int prepare_walk(git_revwalk *walk)
{
int error;
unsigned int i;
- commit_object *next, *two;
- commit_list *bases = NULL;
+ git_commit_list_node *next, *two;
+ git_commit_list *bases = NULL;
/*
* If walk->one is NULL, there were no positive references,
@@ -763,10 +337,10 @@ static int prepare_walk(git_revwalk *walk)
}
/* first figure out what the merge bases are */
- if (merge_bases_many(&bases, walk, walk->one, &walk->twos) < 0)
+ if (git_merge__bases_many(&bases, walk, walk->one, &walk->twos) < 0)
return -1;
- commit_list_free(&bases);
+ git_commit_list_free(&bases);
if (process_commit(walk, walk->one, walk->one->uninteresting) < 0)
return -1;
@@ -780,11 +354,11 @@ static int prepare_walk(git_revwalk *walk)
while ((error = walk->get_next(&next, walk)) == 0) {
for (i = 0; i < next->out_degree; ++i) {
- commit_object *parent = next->parents[i];
+ git_commit_list_node *parent = next->parents[i];
parent->in_degree++;
}
- if (commit_list_insert(next, &walk->iterator_topo) == NULL)
+ if (git_commit_list_insert(next, &walk->iterator_topo) == NULL)
return -1;
}
@@ -797,7 +371,7 @@ static int prepare_walk(git_revwalk *walk)
if (walk->sorting & GIT_SORT_REVERSE) {
while ((error = walk->get_next(&next, walk)) == 0)
- if (commit_list_insert(next, &walk->iterator_reverse) == NULL)
+ if (git_commit_list_insert(next, &walk->iterator_reverse) == NULL)
return -1;
if (error != GIT_ITEROVER)
@@ -811,9 +385,6 @@ static int prepare_walk(git_revwalk *walk)
}
-
-
-
int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
{
git_revwalk *walk;
@@ -826,7 +397,7 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
walk->commits = git_oidmap_alloc();
GITERR_CHECK_ALLOC(walk->commits);
- if (git_pqueue_init(&walk->iterator_time, 8, commit_time_cmp) < 0 ||
+ if (git_pqueue_init(&walk->iterator_time, 8, git_commit_list_time_cmp) < 0 ||
git_vector_init(&walk->twos, 4, NULL) < 0 ||
git_pool_init(&walk->commit_pool, 1,
git_pool__suggest_items_per_page(COMMIT_ALLOC) * COMMIT_ALLOC) < 0)
@@ -888,7 +459,7 @@ void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
int git_revwalk_next(git_oid *oid, git_revwalk *walk)
{
int error;
- commit_object *next;
+ git_commit_list_node *next;
assert(walk && oid);
@@ -913,7 +484,7 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
void git_revwalk_reset(git_revwalk *walk)
{
- commit_object *commit;
+ git_commit_list_node *commit;
assert(walk);
@@ -925,9 +496,9 @@ void git_revwalk_reset(git_revwalk *walk)
});
git_pqueue_clear(&walk->iterator_time);
- commit_list_free(&walk->iterator_topo);
- commit_list_free(&walk->iterator_rand);
- commit_list_free(&walk->iterator_reverse);
+ git_commit_list_free(&walk->iterator_topo);
+ git_commit_list_free(&walk->iterator_rand);
+ git_commit_list_free(&walk->iterator_reverse);
walk->walking = 0;
walk->one = NULL;
diff --git a/src/revwalk.h b/src/revwalk.h
new file mode 100644
index 0000000..2d482cf
--- /dev/null
+++ b/src/revwalk.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2009-2012 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_revwalk_h__
+#define INCLUDE_revwalk_h__
+
+#include "git2/revwalk.h"
+#include "oidmap.h"
+#include "commit_list.h"
+#include "pqueue.h"
+#include "pool.h"
+#include "vector.h"
+
+GIT__USE_OIDMAP;
+
+struct git_revwalk {
+ git_repository *repo;
+ git_odb *odb;
+
+ git_oidmap *commits;
+ git_pool commit_pool;
+
+ git_commit_list *iterator_topo;
+ git_commit_list *iterator_rand;
+ git_commit_list *iterator_reverse;
+ git_pqueue iterator_time;
+
+ int (*get_next)(git_commit_list_node **, git_revwalk *);
+ int (*enqueue)(git_revwalk *, git_commit_list_node *);
+
+ unsigned walking:1;
+ unsigned int sorting;
+
+ /* merge base calculation */
+ git_commit_list_node *one;
+ git_vector twos;
+};
+
+git_commit_list_node *commit_lookup(git_revwalk *walk, const git_oid *oid);
+
+#endif
diff --git a/src/stash.c b/src/stash.c
index b74429a..107cbe3 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -56,7 +56,7 @@ static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit)
static int append_commit_description(git_buf *out, git_commit* commit)
{
const char *message;
- int pos = 0, len;
+ size_t pos = 0, len;
if (append_abbreviated_oid(out, git_commit_id(commit)) < 0)
return -1;
@@ -98,7 +98,7 @@ static int retrieve_base_commit_and_message(
"%s: ",
git_reference_name(head) + strlen(GIT_REFS_HEADS_DIR));
- if (git_commit_lookup(b_commit, repo, git_reference_oid(head)) < 0)
+ if (git_commit_lookup(b_commit, repo, git_reference_target(head)) < 0)
goto cleanup;
if (append_commit_description(stash_message, *b_commit) < 0)
@@ -169,12 +169,12 @@ struct cb_data {
};
static int update_index_cb(
- void *cb_data,
const git_diff_delta *delta,
- float progress)
+ float progress,
+ void *payload)
{
int pos;
- struct cb_data *data = (struct cb_data *)cb_data;
+ struct cb_data *data = (struct cb_data *)payload;
GIT_UNUSED(progress);
@@ -253,7 +253,7 @@ static int build_untracked_tree(
if (git_diff_workdir_to_tree(&diff, git_index_owner(index), i_tree, &opts) < 0)
goto cleanup;
- if (git_diff_foreach(diff, &data, update_index_cb, NULL, NULL) < 0)
+ if (git_diff_foreach(diff, update_index_cb, NULL, NULL, &data) < 0)
goto cleanup;
if (build_tree_from_index(tree_out, index) < 0)
@@ -334,7 +334,7 @@ static int build_workdir_tree(
data.index = index;
data.include_changed = true;
- if (git_diff_foreach(diff, &data, update_index_cb, NULL, NULL) < 0)
+ if (git_diff_foreach(diff, update_index_cb, NULL, NULL, &data) < 0)
goto cleanup;
if (build_tree_from_index(tree_out, index) < 0)
@@ -436,7 +436,7 @@ static int update_reflog(
git_reflog *reflog = NULL;
int error;
- if ((error = git_reference_create_oid(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1)) < 0)
+ if ((error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1)) < 0)
goto cleanup;
if ((error = git_reflog_read(&reflog, stash)) < 0)
@@ -579,7 +579,7 @@ cleanup:
int git_stash_foreach(
git_repository *repo,
- stash_cb callback,
+ git_stash_cb callback,
void *payload)
{
git_reference *stash;
@@ -603,8 +603,8 @@ int git_stash_foreach(
entry = git_reflog_entry_byindex(reflog, i);
if (callback(i,
- git_reflog_entry_msg(entry),
- git_reflog_entry_oidnew(entry),
+ git_reflog_entry_message(entry),
+ git_reflog_entry_id_new(entry),
payload)) {
error = GIT_EUSER;
goto cleanup;
diff --git a/src/status.c b/src/status.c
index b832cfe..c7dea2c 100644
--- a/src/status.c
+++ b/src/status.c
@@ -78,14 +78,14 @@ static unsigned int workdir_delta2status(git_delta_t workdir_status)
}
typedef struct {
- int (*cb)(const char *, unsigned int, void *);
- void *cbdata;
+ git_status_cb cb;
+ void *payload;
} status_user_callback;
static int status_invoke_cb(
- void *cbref, git_diff_delta *i2h, git_diff_delta *w2i)
+ git_diff_delta *i2h, git_diff_delta *w2i, void *payload)
{
- status_user_callback *usercb = cbref;
+ status_user_callback *usercb = payload;
const char *path = NULL;
unsigned int status = 0;
@@ -98,14 +98,14 @@ static int status_invoke_cb(
status |= index_delta2status(i2h->status);
}
- return usercb->cb(path, status, usercb->cbdata);
+ return usercb->cb(path, status, usercb->payload);
}
int git_status_foreach_ext(
git_repository *repo,
const git_status_options *opts,
- int (*cb)(const char *, unsigned int, void *),
- void *cbdata)
+ git_status_cb cb,
+ void *payload)
{
int err = 0;
git_diff_options diffopt;
@@ -152,7 +152,7 @@ int git_status_foreach_ext(
goto cleanup;
usercb.cb = cb;
- usercb.cbdata = cbdata;
+ usercb.payload = payload;
if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) {
if ((err = git_diff__paired_foreach(
@@ -178,7 +178,7 @@ cleanup:
int git_status_foreach(
git_repository *repo,
- int (*callback)(const char *, unsigned int, void *),
+ git_status_cb callback,
void *payload)
{
git_status_options opts;
diff --git a/src/submodule.c b/src/submodule.c
index 6eb1c52..b6e5c96 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -66,7 +66,7 @@ __KHASH_IMPL(
str_hash_no_trailing_slash, str_equal_no_trailing_slash);
static int load_submodule_config(git_repository *repo, bool force);
-static git_config_file *open_gitmodules(git_repository *, bool, const git_oid *);
+static git_config_backend *open_gitmodules(git_repository *, bool, const git_oid *);
static int lookup_head_remote(git_buf *url, git_repository *repo);
static int submodule_get(git_submodule **, git_repository *, const char *, const char *);
static void submodule_release(git_submodule *sm, int decr);
@@ -201,7 +201,7 @@ int git_submodule_add_setup(
int use_gitlink)
{
int error = 0;
- git_config_file *mods = NULL;
+ git_config_backend *mods = NULL;
git_submodule *sm;
git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
git_repository_init_options initopt;
@@ -412,7 +412,7 @@ cleanup:
int git_submodule_save(git_submodule *submodule)
{
int error = 0;
- git_config_file *mods;
+ git_config_backend *mods;
git_buf key = GIT_BUF_INIT;
assert(submodule);
@@ -513,7 +513,7 @@ int git_submodule_set_url(git_submodule *submodule, const char *url)
return 0;
}
-const git_oid *git_submodule_index_oid(git_submodule *submodule)
+const git_oid *git_submodule_index_id(git_submodule *submodule)
{
assert(submodule);
@@ -523,7 +523,7 @@ const git_oid *git_submodule_index_oid(git_submodule *submodule)
return NULL;
}
-const git_oid *git_submodule_head_oid(git_submodule *submodule)
+const git_oid *git_submodule_head_id(git_submodule *submodule)
{
assert(submodule);
@@ -533,7 +533,7 @@ const git_oid *git_submodule_head_oid(git_submodule *submodule)
return NULL;
}
-const git_oid *git_submodule_wd_oid(git_submodule *submodule)
+const git_oid *git_submodule_wd_id(git_submodule *submodule)
{
assert(submodule);
@@ -695,7 +695,7 @@ int git_submodule_open(
/* if we have opened the submodule successfully, let's grab the HEAD OID */
if (!error && !(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) {
- if (!git_reference_name_to_oid(
+ if (!git_reference_name_to_id(
&submodule->wd_oid, *subrepo, GIT_HEAD_FILE))
submodule->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
else
@@ -717,7 +717,7 @@ int git_submodule_reload(git_submodule *submodule)
git_index *index;
int pos, error;
git_tree *head;
- git_config_file *mods;
+ git_config_backend *mods;
assert(submodule);
@@ -733,7 +733,7 @@ int git_submodule_reload(git_submodule *submodule)
pos = git_index_find(index, submodule->path);
if (pos >= 0) {
- git_index_entry *entry = git_index_get_byindex(index, pos);
+ const git_index_entry *entry = git_index_get_byindex(index, pos);
if (S_ISGITLINK(entry->mode)) {
if ((error = submodule_load_from_index(repo, entry)) < 0)
@@ -1187,14 +1187,14 @@ static int load_submodule_config_from_head(
return error;
}
-static git_config_file *open_gitmodules(
+static git_config_backend *open_gitmodules(
git_repository *repo,
bool okay_to_create,
const git_oid *gitmodules_oid)
{
const char *workdir = git_repository_workdir(repo);
git_buf path = GIT_BUF_INIT;
- git_config_file *mods = NULL;
+ git_config_backend *mods = NULL;
if (workdir != NULL) {
if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0)
@@ -1230,7 +1230,7 @@ static int load_submodule_config(git_repository *repo, bool force)
int error;
git_oid gitmodules_oid;
git_buf path = GIT_BUF_INIT;
- git_config_file *mods = NULL;
+ git_config_backend *mods = NULL;
if (repo->submodules && !force)
return 0;
@@ -1316,7 +1316,7 @@ static int lookup_head_remote(git_buf *url, git_repository *repo)
/* remote should refer to something like refs/remotes/ORIGIN/BRANCH */
if (git_reference_type(remote) != GIT_REF_SYMBOLIC ||
- git__prefixcmp(git_reference_target(remote), GIT_REFS_REMOTES_DIR) != 0)
+ git__prefixcmp(git_reference_symbolic_target(remote), GIT_REFS_REMOTES_DIR) != 0)
{
giterr_set(GITERR_SUBMODULE,
"Cannot resolve relative URL when HEAD is not symbolic");
@@ -1324,7 +1324,7 @@ static int lookup_head_remote(git_buf *url, git_repository *repo)
goto cleanup;
}
- scan = tgt = git_reference_target(remote) + strlen(GIT_REFS_REMOTES_DIR);
+ scan = tgt = git_reference_symbolic_target(remote) + strlen(GIT_REFS_REMOTES_DIR);
while (*scan && (*scan != '/' || (scan > tgt && scan[-1] != '\\')))
scan++; /* find non-escaped slash to end ORIGIN name */
@@ -1378,7 +1378,7 @@ static int submodule_update_config(
goto cleanup;
if (!value)
- error = git_config_delete(config, key.ptr);
+ error = git_config_delete_entry(config, key.ptr);
else
error = git_config_set_string(config, key.ptr, value);
@@ -1389,8 +1389,8 @@ cleanup:
static int submodule_index_status(unsigned int *status, git_submodule *sm)
{
- const git_oid *head_oid = git_submodule_head_oid(sm);
- const git_oid *index_oid = git_submodule_index_oid(sm);
+ const git_oid *head_oid = git_submodule_head_id(sm);
+ const git_oid *index_oid = git_submodule_index_id(sm);
if (!head_oid) {
if (index_oid)
@@ -1410,7 +1410,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
const git_oid *wd_oid, *index_oid;
git_repository *sm_repo = NULL;
- /* open repo now if we need it (so wd_oid() call won't reopen) */
+ /* open repo now if we need it (so wd_id() call won't reopen) */
if ((sm->ignore == GIT_SUBMODULE_IGNORE_NONE ||
sm->ignore == GIT_SUBMODULE_IGNORE_UNTRACKED) &&
(sm->flags & GIT_SUBMODULE_STATUS_IN_WD) != 0)
@@ -1419,8 +1419,8 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
return error;
}
- index_oid = git_submodule_index_oid(sm);
- wd_oid = git_submodule_wd_oid(sm);
+ index_oid = git_submodule_index_id(sm);
+ wd_oid = git_submodule_wd_id(sm);
if (!index_oid) {
if (wd_oid)
diff --git a/src/tag.c b/src/tag.c
index 13369d9..606afd6 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -22,41 +22,41 @@ void git_tag__free(git_tag *tag)
git__free(tag);
}
-const git_oid *git_tag_id(git_tag *c)
+const git_oid *git_tag_id(const git_tag *c)
{
- return git_object_id((git_object *)c);
+ return git_object_id((const git_object *)c);
}
-int git_tag_target(git_object **target, git_tag *t)
+int git_tag_target(git_object **target, const git_tag *t)
{
assert(t);
return git_object_lookup(target, t->object.repo, &t->target, t->type);
}
-const git_oid *git_tag_target_oid(git_tag *t)
+const git_oid *git_tag_target_id(const git_tag *t)
{
assert(t);
return &t->target;
}
-git_otype git_tag_target_type(git_tag *t)
+git_otype git_tag_target_type(const git_tag *t)
{
assert(t);
return t->type;
}
-const char *git_tag_name(git_tag *t)
+const char *git_tag_name(const git_tag *t)
{
assert(t);
return t->tag_name;
}
-const git_signature *git_tag_tagger(git_tag *t)
+const git_signature *git_tag_tagger(const git_tag *t)
{
return t->tagger;
}
-const char *git_tag_message(git_tag *t)
+const char *git_tag_message(const git_tag *t)
{
assert(t);
return t->message;
@@ -188,7 +188,7 @@ static int retrieve_tag_reference_oid(
if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0)
return -1;
- return git_reference_name_to_oid(oid, repo, ref_name_out->ptr);
+ return git_reference_name_to_id(oid, repo, ref_name_out->ptr);
}
static int write_tag_annotation(
@@ -267,7 +267,7 @@ static int git_tag_create__internal(
} else
git_oid_cpy(oid, git_object_id(target));
- error = git_reference_create_oid(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
+ error = git_reference_create(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
git_reference_free(new_ref);
git_buf_free(&ref_name);
@@ -358,7 +358,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
return -1;
}
- error = git_reference_create_oid(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
+ error = git_reference_create(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
git_reference_free(new_ref);
git_buf_free(&ref_name);
@@ -409,7 +409,7 @@ static int tags_cb(const char *ref, void *data)
if (git__prefixcmp(ref, GIT_REFS_TAGS_DIR) != 0)
return 0; /* no tag */
- if (git_reference_name_to_oid(&oid, d->repo, ref) < 0)
+ if (git_reference_name_to_id(&oid, d->repo, ref) < 0)
return -1;
return d->cb(ref, &oid, d->cb_data);
@@ -425,8 +425,8 @@ int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data)
data.cb_data = cb_data;
data.repo = repo;
- return git_reference_foreach(repo, GIT_REF_OID | GIT_REF_PACKED,
- &tags_cb, &data);
+ return git_reference_foreach(
+ repo, GIT_REF_OID | GIT_REF_PACKED, &tags_cb, &data);
}
typedef struct {
@@ -477,7 +477,7 @@ int git_tag_list(git_strarray *tag_names, git_repository *repo)
return git_tag_list_match(tag_names, "", repo);
}
-int git_tag_peel(git_object **tag_target, git_tag *tag)
+int git_tag_peel(git_object **tag_target, const git_tag *tag)
{
- return git_object_peel(tag_target, (git_object *)tag, GIT_OBJ_ANY);
+ return git_object_peel(tag_target, (const git_object *)tag, GIT_OBJ_ANY);
}
diff --git a/src/transports/cred.c b/src/transports/cred.c
index 5529537..e137ca9 100644
--- a/src/transports/cred.c
+++ b/src/transports/cred.c
@@ -11,7 +11,7 @@
static void plaintext_free(struct git_cred *cred)
{
git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
- int pass_len = strlen(c->password);
+ size_t pass_len = strlen(c->password);
git__free(c->username);
@@ -19,6 +19,8 @@ static void plaintext_free(struct git_cred *cred)
memset(c->password, 0x0, pass_len);
git__free(c->password);
+ memset(c, 0, sizeof(*c));
+
git__free(c);
}
@@ -54,4 +56,4 @@ int git_cred_userpass_plaintext_new(
*cred = &c->parent;
return 0;
-}
\ No newline at end of file
+}
diff --git a/src/transports/local.c b/src/transports/local.c
index 46c9218..5154441 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -48,7 +48,7 @@ static int add_ref(transport_local *t, const char *name)
head->name = git__strdup(name);
GITERR_CHECK_ALLOC(head->name);
- if (git_reference_name_to_oid(&head->oid, t->repo, name) < 0) {
+ if (git_reference_name_to_id(&head->oid, t->repo, name) < 0) {
git__free(head->name);
git__free(head);
return -1;
@@ -306,7 +306,7 @@ static int local_download_pack(
if (git_odb_exists(odb, &oid)) continue;
if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) {
- const git_oid *tree_oid = git_commit_tree_oid(commit);
+ const git_oid *tree_oid = git_commit_tree_id(commit);
git_commit_free(commit);
/* Add the commit and its tree */
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 8f9715a..e8dbbef 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -24,7 +24,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
buf->offset += bytes_read;
if (t->packetsize_cb)
- t->packetsize_cb(bytes_read, t->packetsize_payload);
+ t->packetsize_cb((int)bytes_read, t->packetsize_payload);
return (int)(buf->offset - old_len);
}
@@ -73,7 +73,7 @@ static int git_smart__connect(
t->flags = flags;
t->cred_acquire_cb = cred_acquire_cb;
- if (GIT_DIR_FETCH == direction)
+ if (GIT_DIRECTION_FETCH == direction)
{
if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK_LS)) < 0)
return error;
@@ -159,7 +159,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
if (t->rpc)
git_smart__reset_stream(t);
- if (GIT_DIR_FETCH == t->direction) {
+ if (GIT_DIRECTION_FETCH == t->direction) {
if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) < 0)
return error;
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 046bc89..b37c4ba 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -94,7 +94,7 @@ typedef struct transport_smart_caps {
include_tag:1;
} transport_smart_caps;
-typedef void (*packetsize_cb)(int received, void *payload);
+typedef void (*packetsize_cb)(size_t received, void *payload);
typedef struct {
git_transport parent;
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index e24eb27..99d34e2 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -188,7 +188,7 @@ static int fetch_setup_walk(git_revwalk **out, git_repository *repo)
if (git_reference_type(ref) == GIT_REF_SYMBOLIC)
continue;
- if (git_revwalk_push(walk, git_reference_oid(ref)) < 0)
+ if (git_revwalk_push(walk, git_reference_target(ref)) < 0)
goto on_error;
git_reference_free(ref);
@@ -367,7 +367,7 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
return 0;
}
-struct network_packetsize_payload
+struct network_packetsize_payload
{
git_transfer_progress_callback callback;
void *payload;
@@ -375,7 +375,7 @@ struct network_packetsize_payload
size_t last_fired_bytes;
};
-static void network_packetsize(int received, void *payload)
+static void network_packetsize(size_t received, void *payload)
{
struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload;
@@ -384,8 +384,8 @@ static void network_packetsize(int received, void *payload)
/* Fire notification if the threshold is reached */
if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) {
- npp->last_fired_bytes = npp->stats->received_bytes;
- npp->callback(npp->stats, npp->payload);
+ npp->last_fired_bytes = npp->stats->received_bytes;
+ npp->callback(npp->stats, npp->payload);
}
}
@@ -414,7 +414,7 @@ int git_smart__download_pack(
/* We might have something in the buffer already from negotiate_fetch */
if (t->buffer.offset > 0)
- t->packetsize_cb(t->buffer.offset, t->packetsize_payload);
+ t->packetsize_cb((int)t->buffer.offset, t->packetsize_payload);
}
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index df6cd87..f3abe85 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -376,7 +376,7 @@ replay:
if (!WinHttpReadData(s->request,
(LPVOID)buffer,
- buf_size,
+ (DWORD)buf_size,
&dw_bytes_read))
{
giterr_set(GITERR_OS, "Failed to read data");
diff --git a/src/tree.c b/src/tree.c
index 6f98388..b3f5c30 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -98,11 +98,11 @@ static int homing_search_cmp(const void *key, const void *array_member)
* ambiguous because of folder vs file sorting, we look linearly
* around the area for our target file.
*/
-static int tree_key_search(git_vector *entries, const char *filename, size_t filename_len)
+static int tree_key_search(
+ git_vector *entries, const char *filename, size_t filename_len)
{
struct tree_key_search ksearch;
const git_tree_entry *entry;
-
int homing, i;
ksearch.filename = filename;
@@ -166,6 +166,7 @@ git_tree_entry *git_tree_entry_dup(const git_tree_entry *entry)
return NULL;
memcpy(copy, entry, total_size);
+
return copy;
}
@@ -225,7 +226,8 @@ int git_tree_entry_to_object(
return git_object_lookup(object_out, repo, &entry->oid, GIT_OBJ_ANY);
}
-static git_tree_entry *entry_fromname(git_tree *tree, const char *name, size_t name_len)
+static const git_tree_entry *entry_fromname(
+ git_tree *tree, const char *name, size_t name_len)
{
int idx = tree_key_search(&tree->entries, name, name_len);
if (idx < 0)
@@ -234,22 +236,25 @@ static git_tree_entry *entry_fromname(git_tree *tree, const char *name, size_t n
return git_vector_get(&tree->entries, idx);
}
-const git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename)
+const git_tree_entry *git_tree_entry_byname(
+ git_tree *tree, const char *filename)
{
assert(tree && filename);
return entry_fromname(tree, filename, strlen(filename));
}
-const git_tree_entry *git_tree_entry_byindex(git_tree *tree, size_t idx)
+const git_tree_entry *git_tree_entry_byindex(
+ git_tree *tree, size_t idx)
{
assert(tree);
return git_vector_get(&tree->entries, idx);
}
-const git_tree_entry *git_tree_entry_byoid(git_tree *tree, const git_oid *oid)
+const git_tree_entry *git_tree_entry_byoid(
+ const git_tree *tree, const git_oid *oid)
{
- unsigned int i;
- git_tree_entry *e;
+ size_t i;
+ const git_tree_entry *e;
assert(tree);
@@ -265,7 +270,7 @@ int git_tree__prefix_position(git_tree *tree, const char *path)
{
git_vector *entries = &tree->entries;
struct tree_key_search ksearch;
- unsigned int at_pos;
+ size_t at_pos;
ksearch.filename = path;
ksearch.filename_len = strlen(path);
@@ -285,13 +290,13 @@ int git_tree__prefix_position(git_tree *tree, const char *path)
break;
}
- return at_pos;
+ return (int)at_pos;
}
-unsigned int git_tree_entrycount(const git_tree *tree)
+size_t git_tree_entrycount(const git_tree *tree)
{
assert(tree);
- return (unsigned int)tree->entries.length;
+ return tree->entries.length;
}
static int tree_error(const char *str)
@@ -348,14 +353,13 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj)
return tree_parse_buffer(tree, (char *)obj->raw.data, (char *)obj->raw.data + obj->raw.len);
}
-static unsigned int find_next_dir(const char *dirname, git_index *index, unsigned int start)
+static size_t find_next_dir(const char *dirname, git_index *index, size_t start)
{
- unsigned int i, entries = git_index_entrycount(index);
- size_t dirlen;
+ size_t dirlen, i, entries = git_index_entrycount(index);
dirlen = strlen(dirname);
for (i = start; i < entries; ++i) {
- git_index_entry *entry = git_index_get_byindex(index, i);
+ const git_index_entry *entry = git_index_get_byindex(index, i);
if (strlen(entry->path) < dirlen ||
memcmp(entry->path, dirname, dirlen) ||
(dirlen > 0 && entry->path[dirlen] != '/')) {
@@ -394,11 +398,10 @@ static int write_tree(
git_repository *repo,
git_index *index,
const char *dirname,
- unsigned int start)
+ size_t start)
{
git_treebuilder *bld = NULL;
-
- unsigned int i, entries = git_index_entrycount(index);
+ size_t i, entries = git_index_entrycount(index);
int error;
size_t dirname_len = strlen(dirname);
const git_tree_cache *cache;
@@ -406,13 +409,11 @@ static int write_tree(
cache = git_tree_cache_get(index->tree, dirname);
if (cache != NULL && cache->entries >= 0){
git_oid_cpy(oid, &cache->oid);
- return find_next_dir(dirname, index, start);
+ return (int)find_next_dir(dirname, index, start);
}
- error = git_treebuilder_create(&bld, NULL);
- if (bld == NULL) {
+ if ((error = git_treebuilder_create(&bld, NULL)) < 0 || bld == NULL)
return -1;
- }
/*
* This loop is unfortunate, but necessary. The index doesn't have
@@ -420,8 +421,8 @@ static int write_tree(
* need to keep track of the current position.
*/
for (i = start; i < entries; ++i) {
- git_index_entry *entry = git_index_get_byindex(index, i);
- char *filename, *next_slash;
+ const git_index_entry *entry = git_index_get_byindex(index, i);
+ const char *filename, *next_slash;
/*
* If we've left our (sub)tree, exit the loop and return. The
@@ -489,14 +490,15 @@ static int write_tree(
goto on_error;
git_treebuilder_free(bld);
- return i;
+ return (int)i;
on_error:
git_treebuilder_free(bld);
return -1;
}
-int git_tree__write_index(git_oid *oid, git_index *index, git_repository *repo)
+int git_tree__write_index(
+ git_oid *oid, git_index *index, git_repository *repo)
{
int ret;
@@ -694,7 +696,10 @@ on_error:
return -1;
}
-void git_treebuilder_filter(git_treebuilder *bld, int (*filter)(const git_tree_entry *, void *), void *payload)
+void git_treebuilder_filter(
+ git_treebuilder *bld,
+ git_treebuilder_filter_cb filter,
+ void *payload)
{
unsigned int i;
@@ -803,17 +808,17 @@ int git_tree_entry_bypath(
}
static int tree_walk(
- git_tree *tree,
+ const git_tree *tree,
git_treewalk_cb callback,
git_buf *path,
void *payload,
bool preorder)
{
int error = 0;
- unsigned int i;
+ size_t i;
for (i = 0; i < tree->entries.length; ++i) {
- git_tree_entry *entry = tree->entries.contents[i];
+ const git_tree_entry *entry = tree->entries.contents[i];
if (preorder) {
error = callback(path->ptr, entry, payload);
@@ -855,23 +860,27 @@ static int tree_walk(
return error;
}
-int git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload)
+int git_tree_walk(
+ const git_tree *tree,
+ git_treewalk_mode mode,
+ git_treewalk_cb callback,
+ void *payload)
{
int error = 0;
git_buf root_path = GIT_BUF_INIT;
switch (mode) {
- case GIT_TREEWALK_POST:
- error = tree_walk(tree, callback, &root_path, payload, false);
- break;
+ case GIT_TREEWALK_POST:
+ error = tree_walk(tree, callback, &root_path, payload, false);
+ break;
- case GIT_TREEWALK_PRE:
- error = tree_walk(tree, callback, &root_path, payload, true);
- break;
+ case GIT_TREEWALK_PRE:
+ error = tree_walk(tree, callback, &root_path, payload, true);
+ break;
- default:
- giterr_set(GITERR_INVALID, "Invalid walking mode for tree walk");
- return -1;
+ default:
+ giterr_set(GITERR_INVALID, "Invalid walking mode for tree walk");
+ return -1;
}
git_buf_free(&root_path);
diff --git a/src/tree.h b/src/tree.h
index b67c552..e0bcd6a 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -51,7 +51,8 @@ int git_tree__prefix_position(git_tree *tree, const char *prefix);
/**
* Write a tree to the given repository
*/
-int git_tree__write_index(git_oid *oid, git_index *index, git_repository *repo);
+int git_tree__write_index(
+ git_oid *oid, git_index *index, git_repository *repo);
/**
* Obsolete mode kept for compatibility reasons
diff --git a/src/util.c b/src/util.c
index 3a08d45..9813eb6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -447,7 +447,7 @@ int git__bsearch(
/**
* A strcmp wrapper
- *
+ *
* We don't want direct pointers to the CRT on Windows, we may
* get stdcall conflicts.
*/
diff --git a/src/vector.c b/src/vector.c
index 4763792..5d3bc08 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -9,14 +9,14 @@
#include "repository.h"
#include "vector.h"
-static const double resize_factor = 1.75;
-static const unsigned int minimum_size = 8;
+static const double git_vector_resize_factor = 1.75;
+static const size_t git_vector_minimum_size = 8;
static int resize_vector(git_vector *v)
{
- v->_alloc_size = ((unsigned int)(v->_alloc_size * resize_factor)) + 1;
- if (v->_alloc_size < minimum_size)
- v->_alloc_size = minimum_size;
+ v->_alloc_size = (size_t)(v->_alloc_size * git_vector_resize_factor) + 1;
+ if (v->_alloc_size < git_vector_minimum_size)
+ v->_alloc_size = git_vector_minimum_size;
v->contents = git__realloc(v->contents, v->_alloc_size * sizeof(void *));
GITERR_CHECK_ALLOC(v->contents);
@@ -24,7 +24,7 @@ static int resize_vector(git_vector *v)
return 0;
}
-int git_vector_dup(git_vector *v, git_vector *src, git_vector_cmp cmp)
+int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp)
{
assert(v && src);
@@ -58,7 +58,7 @@ int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp)
memset(v, 0x0, sizeof(git_vector));
if (initial_size == 0)
- initial_size = minimum_size;
+ initial_size = git_vector_minimum_size;
v->_alloc_size = initial_size;
v->_cmp = cmp;
@@ -133,7 +133,7 @@ void git_vector_sort(git_vector *v)
}
int git_vector_bsearch3(
- unsigned int *at_pos,
+ size_t *at_pos,
git_vector *v,
git_vector_cmp key_lookup,
const void *key)
@@ -151,21 +151,21 @@ int git_vector_bsearch3(
rval = git__bsearch(v->contents, v->length, key, key_lookup, &pos);
if (at_pos != NULL)
- *at_pos = (unsigned int)pos;
+ *at_pos = pos;
return (rval >= 0) ? (int)pos : GIT_ENOTFOUND;
}
int git_vector_search2(
- git_vector *v, git_vector_cmp key_lookup, const void *key)
+ const git_vector *v, git_vector_cmp key_lookup, const void *key)
{
- unsigned int i;
+ size_t i;
assert(v && key && key_lookup);
for (i = 0; i < v->length; ++i) {
if (key_lookup(key, v->contents[i]) == 0)
- return i;
+ return (int)i;
}
return GIT_ENOTFOUND;
@@ -176,14 +176,14 @@ static int strict_comparison(const void *a, const void *b)
return (a == b) ? 0 : -1;
}
-int git_vector_search(git_vector *v, const void *entry)
+int git_vector_search(const git_vector *v, const void *entry)
{
return git_vector_search2(v, v->_cmp ? v->_cmp : strict_comparison, entry);
}
-int git_vector_remove(git_vector *v, unsigned int idx)
+int git_vector_remove(git_vector *v, size_t idx)
{
- unsigned int i;
+ size_t i;
assert(v);
@@ -206,7 +206,7 @@ void git_vector_pop(git_vector *v)
void git_vector_uniq(git_vector *v)
{
git_vector_cmp cmp;
- unsigned int i, j;
+ size_t i, j;
if (v->length <= 1)
return;
@@ -223,9 +223,10 @@ void git_vector_uniq(git_vector *v)
v->length -= j - i - 1;
}
-void git_vector_remove_matching(git_vector *v, int (*match)(git_vector *v, size_t idx))
+void git_vector_remove_matching(
+ git_vector *v, int (*match)(const git_vector *v, size_t idx))
{
- unsigned int i, j;
+ size_t i, j;
for (i = 0, j = 0; j < v->length; ++j) {
v->contents[i] = v->contents[j];
diff --git a/src/vector.h b/src/vector.h
index 6d820b8..15356ef 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -24,23 +24,23 @@ typedef struct git_vector {
int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp);
void git_vector_free(git_vector *v);
void git_vector_clear(git_vector *v);
-int git_vector_dup(git_vector *v, git_vector *src, git_vector_cmp cmp);
+int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp);
void git_vector_swap(git_vector *a, git_vector *b);
void git_vector_sort(git_vector *v);
/** Linear search for matching entry using internal comparison function */
-int git_vector_search(git_vector *v, const void *entry);
+int git_vector_search(const git_vector *v, const void *entry);
/** Linear search for matching entry using explicit comparison function */
-int git_vector_search2(git_vector *v, git_vector_cmp cmp, const void *key);
+int git_vector_search2(const git_vector *v, git_vector_cmp cmp, const void *key);
/**
* Binary search for matching entry using explicit comparison function that
* returns position where item would go if not found.
*/
int git_vector_bsearch3(
- unsigned int *at_pos, git_vector *v, git_vector_cmp cmp, const void *key);
+ size_t *at_pos, git_vector *v, git_vector_cmp cmp, const void *key);
/** Binary search for matching entry using internal comparison function */
GIT_INLINE(int) git_vector_bsearch(git_vector *v, const void *key)
@@ -55,19 +55,14 @@ GIT_INLINE(int) git_vector_bsearch2(
return git_vector_bsearch3(NULL, v, cmp, key);
}
-GIT_INLINE(void *) git_vector_get(git_vector *v, size_t position)
-{
- return (position < v->length) ? v->contents[position] : NULL;
-}
-
-GIT_INLINE(const void *) git_vector_get_const(const git_vector *v, size_t position)
+GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position)
{
return (position < v->length) ? v->contents[position] : NULL;
}
#define GIT_VECTOR_GET(V,I) ((I) < (V)->length ? (V)->contents[(I)] : NULL)
-GIT_INLINE(void *) git_vector_last(git_vector *v)
+GIT_INLINE(void *) git_vector_last(const git_vector *v)
{
return (v->length > 0) ? git_vector_get(v, v->length - 1) : NULL;
}
@@ -81,10 +76,11 @@ GIT_INLINE(void *) git_vector_last(git_vector *v)
int git_vector_insert(git_vector *v, void *element);
int git_vector_insert_sorted(git_vector *v, void *element,
int (*on_dup)(void **old, void *new));
-int git_vector_remove(git_vector *v, unsigned int idx);
+int git_vector_remove(git_vector *v, size_t idx);
void git_vector_pop(git_vector *v);
void git_vector_uniq(git_vector *v);
-void git_vector_remove_matching(git_vector *v, int (*match)(git_vector *v, size_t idx));
+void git_vector_remove_matching(
+ git_vector *v, int (*match)(const git_vector *v, size_t idx));
int git_vector_resize_to(git_vector *v, size_t new_length);
int git_vector_set(void **old, git_vector *v, size_t position, void *value);
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 0efcaf5..3a4398b 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -520,24 +520,24 @@ int p_inet_pton(int af, const char* src, void* dst)
struct sockaddr_in6 sin6;
struct sockaddr_in sin;
} sa;
- size_t srcsize;
+ int srcsize;
switch(af)
{
case AF_INET:
sa.sin.sin_family = AF_INET;
- srcsize = sizeof (sa.sin);
+ srcsize = (int)sizeof(sa.sin);
break;
case AF_INET6:
sa.sin6.sin6_family = AF_INET6;
- srcsize = sizeof (sa.sin6);
+ srcsize = (int)sizeof(sa.sin6);
break;
default:
errno = WSAEPFNOSUPPORT;
return -1;
}
- if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
+ if (WSAStringToAddress((LPSTR)src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
{
errno = WSAGetLastError();
return -1;
diff --git a/tests-clar/attr/repo.c b/tests-clar/attr/repo.c
index b51d5e3..1d2b1e8 100644
--- a/tests-clar/attr/repo.c
+++ b/tests-clar/attr/repo.c
@@ -267,7 +267,7 @@ static void add_to_workdir(const char *filename, const char *content)
static void assert_proper_normalization(git_index *index, const char *filename, const char *expected_sha)
{
int index_pos;
- git_index_entry *entry;
+ const git_index_entry *entry;
add_to_workdir(filename, CONTENT);
cl_git_pass(git_index_add_from_workdir(index, filename));
diff --git a/tests-clar/checkout/index.c b/tests-clar/checkout/index.c
index c7b19db..b6d6372 100644
--- a/tests-clar/checkout/index.c
+++ b/tests-clar/checkout/index.c
@@ -247,7 +247,7 @@ void test_checkout_index__options_dir_modes(void)
git_oid oid;
git_commit *commit;
- cl_git_pass(git_reference_name_to_oid(&oid, g_repo, "refs/heads/dir"));
+ cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/dir"));
cl_git_pass(git_commit_lookup(&commit, g_repo, &oid));
reset_index_to_treeish((git_object *)commit);
diff --git a/tests-clar/clone/network.c b/tests-clar/clone/network.c
index def5214..d519e45 100644
--- a/tests-clar/clone/network.c
+++ b/tests-clar/clone/network.c
@@ -74,7 +74,7 @@ void test_clone_network__empty_repository(void)
cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE));
cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
- cl_assert_equal_s("refs/heads/master", git_reference_target(head));
+ cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
git_reference_free(head);
}
@@ -109,7 +109,7 @@ static void fetch_progress(const git_transfer_progress *stats, void *payload)
void test_clone_network__can_checkout_a_cloned_repo(void)
{
- git_checkout_opts opts = {0};
+ git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
git_buf path = GIT_BUF_INIT;
git_reference *head;
bool checkout_progress_cb_was_called = false,
@@ -121,15 +121,15 @@ void test_clone_network__can_checkout_a_cloned_repo(void)
cl_set_cleanup(&cleanup_repository, "./default-checkout");
- cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./default-checkout",
- &fetch_progress, &fetch_progress_cb_was_called, &opts));
+ cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./default-checkout", &opts,
+ &fetch_progress, &fetch_progress_cb_was_called));
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&path)));
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
- cl_assert_equal_s("refs/heads/master", git_reference_target(head));
+ cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
cl_assert_equal_i(true, checkout_progress_cb_was_called);
cl_assert_equal_i(true, fetch_progress_cb_was_called);
diff --git a/tests-clar/commit/commit.c b/tests-clar/commit/commit.c
index 4cedcea..8f071ff 100644
--- a/tests-clar/commit/commit.c
+++ b/tests-clar/commit/commit.c
@@ -37,7 +37,7 @@ void test_commit_commit__create_unexisting_update_ref(void)
NULL, "some msg", tree, 1, (const git_commit **) &commit));
cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
- cl_assert(!git_oid_cmp(&oid, git_reference_oid(ref)));
+ cl_assert(!git_oid_cmp(&oid, git_reference_target(ref)));
git_tree_free(tree);
git_commit_free(commit);
diff --git a/tests-clar/commit/write.c b/tests-clar/commit/write.c
index 6d62809..7b9868b 100644
--- a/tests-clar/commit/write.c
+++ b/tests-clar/commit/write.c
@@ -112,10 +112,10 @@ void test_commit_write__root(void)
/* First we need to update HEAD so it points to our non-existant branch */
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_assert(git_reference_type(head) == GIT_REF_SYMBOLIC);
- head_old = git__strdup(git_reference_target(head));
+ head_old = git__strdup(git_reference_symbolic_target(head));
cl_assert(head_old != NULL);
- cl_git_pass(git_reference_set_target(head, branch_name));
+ cl_git_pass(git_reference_symbolic_set_target(head, branch_name));
cl_git_pass(git_commit_create_v(
&commit_id, /* out id */
@@ -140,7 +140,7 @@ void test_commit_write__root(void)
cl_git_pass(git_commit_lookup(&commit, g_repo, &commit_id));
cl_assert(git_commit_parentcount(commit) == 0);
cl_git_pass(git_reference_lookup(&branch, g_repo, branch_name));
- branch_oid = git_reference_oid(branch);
+ branch_oid = git_reference_target(branch);
cl_git_pass(git_oid_cmp(branch_oid, &commit_id));
cl_assert(!strcmp(git_commit_message(commit), root_commit_message));
}
diff --git a/tests-clar/config/add.c b/tests-clar/config/add.c
index 9854fbb..405f1e2 100644
--- a/tests-clar/config/add.c
+++ b/tests-clar/config/add.c
@@ -19,7 +19,7 @@ void test_config_add__to_existing_section(void)
cl_git_pass(git_config_set_int32(cfg, "empty.tmp", 5));
cl_git_pass(git_config_get_int32(&i, cfg, "empty.tmp"));
cl_assert(i == 5);
- cl_git_pass(git_config_delete(cfg, "empty.tmp"));
+ cl_git_pass(git_config_delete_entry(cfg, "empty.tmp"));
git_config_free(cfg);
}
@@ -32,6 +32,6 @@ void test_config_add__to_new_section(void)
cl_git_pass(git_config_set_int32(cfg, "section.tmp", 5));
cl_git_pass(git_config_get_int32(&i, cfg, "section.tmp"));
cl_assert(i == 5);
- cl_git_pass(git_config_delete(cfg, "section.tmp"));
+ cl_git_pass(git_config_delete_entry(cfg, "section.tmp"));
git_config_free(cfg);
}
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c
index d98d1dd..411d40a 100644
--- a/tests-clar/config/write.c
+++ b/tests-clar/config/write.c
@@ -62,7 +62,7 @@ void test_config_write__delete_value(void)
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
- cl_git_pass(git_config_delete(cfg, "core.dummy"));
+ cl_git_pass(git_config_delete_entry(cfg, "core.dummy"));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
@@ -94,7 +94,7 @@ void test_config_write__delete_value_at_specific_level(void)
cl_git_pass(git_config_open_level(&cfg_specific, cfg, GIT_CONFIG_LEVEL_GLOBAL));
- cl_git_pass(git_config_delete(cfg_specific, "core.dummy2"));
+ cl_git_pass(git_config_delete_entry(cfg_specific, "core.dummy2"));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config15"));
@@ -125,7 +125,7 @@ void test_config_write__delete_inexistent(void)
git_config *cfg;
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
- cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND);
+ cl_assert(git_config_delete_entry(cfg, "core.imaginary") == GIT_ENOTFOUND);
git_config_free(cfg);
}
diff --git a/tests-clar/core/vector.c b/tests-clar/core/vector.c
index b165905..c9e43a1 100644
--- a/tests-clar/core/vector.c
+++ b/tests-clar/core/vector.c
@@ -190,7 +190,7 @@ void test_core_vector__5(void)
git_vector_free(&x);
}
-static int remove_ones(git_vector *v, size_t idx)
+static int remove_ones(const git_vector *v, size_t idx)
{
return (git_vector_get(v, idx) == (void *)0x001);
}
diff --git a/tests-clar/diff/blob.c b/tests-clar/diff/blob.c
index a9ebcc2..6a5645d 100644
--- a/tests-clar/diff/blob.c
+++ b/tests-clar/diff/blob.c
@@ -59,7 +59,7 @@ void test_diff_blob__can_compare_text_blobs(void)
/* diff on tests/resources/attr/root_test1 */
cl_git_pass(git_diff_blobs(
- a, b, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ a, b, &opts, diff_file_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_MODIFIED]);
@@ -74,7 +74,7 @@ void test_diff_blob__can_compare_text_blobs(void)
/* diff on tests/resources/attr/root_test2 */
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- b, c, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ b, c, &opts, diff_file_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_MODIFIED]);
@@ -89,7 +89,7 @@ void test_diff_blob__can_compare_text_blobs(void)
/* diff on tests/resources/attr/root_test3 */
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- a, c, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ a, c, &opts, diff_file_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_MODIFIED]);
@@ -103,7 +103,7 @@ void test_diff_blob__can_compare_text_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- c, d, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ c, d, &opts, diff_file_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_MODIFIED]);
@@ -125,7 +125,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
git_blob *e = NULL;
cl_git_pass(git_diff_blobs(
- d, e, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ d, e, &opts, diff_file_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]);
@@ -140,7 +140,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- d, e, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ d, e, &opts, diff_file_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]);
@@ -155,7 +155,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- alien, NULL, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ alien, NULL, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.files_binary);
@@ -166,7 +166,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- NULL, alien, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ NULL, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.files_binary);
@@ -186,21 +186,21 @@ static void assert_identical_blobs_comparison(diff_expects *expected)
void test_diff_blob__can_compare_identical_blobs(void)
{
cl_git_pass(git_diff_blobs(
- d, d, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(0, expected.files_binary);
assert_identical_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- NULL, NULL, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ NULL, NULL, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(0, expected.files_binary);
assert_identical_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- alien, alien, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ alien, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert(expected.files_binary > 0);
assert_identical_blobs_comparison(&expected);
@@ -226,14 +226,14 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
cl_git_pass(git_blob_lookup_prefix(&heart, g_repo, &h_oid, 4));
cl_git_pass(git_diff_blobs(
- alien, heart, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ alien, heart, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- heart, alien, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ heart, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
@@ -243,14 +243,14 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
void test_diff_blob__can_compare_a_binary_blob_and_a_text_blob(void)
{
cl_git_pass(git_diff_blobs(
- alien, d, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ alien, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- d, alien, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ d, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
}
@@ -291,7 +291,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, d, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ old_d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(2, expected.hunks);
@@ -299,7 +299,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
opts.interhunk_lines = 0;
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- old_d, d, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ old_d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(2, expected.hunks);
@@ -307,7 +307,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
opts.interhunk_lines = 1;
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
- old_d, d, &opts, &expected, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ old_d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.hunks);
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 992c87d..1436ada 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -21,12 +21,12 @@ git_tree *resolve_commit_oid_to_tree(
return tree;
}
-int diff_file_fn(
- void *cb_data,
+int diff_file_cb(
const git_diff_delta *delta,
- float progress)
+ float progress,
+ void *payload)
{
- diff_expects *e = cb_data;
+ diff_expects *e = payload;
GIT_UNUSED(progress);
@@ -42,14 +42,14 @@ int diff_file_fn(
return 0;
}
-int diff_hunk_fn(
- void *cb_data,
+int diff_hunk_cb(
const git_diff_delta *delta,
const git_diff_range *range,
const char *header,
- size_t header_len)
+ size_t header_len,
+ void *payload)
{
- diff_expects *e = cb_data;
+ diff_expects *e = payload;
GIT_UNUSED(delta);
GIT_UNUSED(header);
@@ -61,15 +61,15 @@ int diff_hunk_fn(
return 0;
}
-int diff_line_fn(
- void *cb_data,
+int diff_line_cb(
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *content,
- size_t content_len)
+ size_t content_len,
+ void *payload)
{
- diff_expects *e = cb_data;
+ diff_expects *e = payload;
GIT_UNUSED(delta);
GIT_UNUSED(range);
@@ -103,10 +103,10 @@ int diff_line_fn(
int diff_foreach_via_iterator(
git_diff_list *diff,
- void *data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn line_cb)
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb line_cb,
+ void *data)
{
size_t d, num_d = git_diff_num_deltas(diff);
@@ -119,7 +119,7 @@ int diff_foreach_via_iterator(
cl_assert(delta);
/* call file_cb for this file */
- if (file_cb != NULL && file_cb(data, delta, (float)d / num_d) != 0) {
+ if (file_cb != NULL && file_cb(delta, (float)d / num_d, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
@@ -145,7 +145,7 @@ int diff_foreach_via_iterator(
cl_git_pass(git_diff_patch_get_hunk(
&range, &hdr, &hdr_len, &num_l, patch, h));
- if (hunk_cb && hunk_cb(data, delta, range, hdr, hdr_len) != 0) {
+ if (hunk_cb && hunk_cb(delta, range, hdr, hdr_len, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
@@ -160,7 +160,8 @@ int diff_foreach_via_iterator(
&origin, &line, &line_len, &old_lineno, &new_lineno,
patch, h, l));
- if (line_cb(data, delta, range, origin, line, line_len) != 0) {
+ if (line_cb &&
+ line_cb(delta, range, origin, line, line_len, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
@@ -178,23 +179,23 @@ abort:
}
static int diff_print_cb(
- void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin, /**< GIT_DIFF_LINE_... value from above */
const char *content,
- size_t content_len)
+ size_t content_len,
+ void *payload)
{
- GIT_UNUSED(cb_data);
+ GIT_UNUSED(payload);
GIT_UNUSED(delta);
GIT_UNUSED(range);
GIT_UNUSED(line_origin);
GIT_UNUSED(content_len);
- fputs(content, (FILE *)cb_data);
+ fputs(content, (FILE *)payload);
return 0;
}
void diff_print(FILE *fp, git_diff_list *diff)
{
- cl_git_pass(git_diff_print_patch(diff, fp ? fp : stderr, diff_print_cb));
+ cl_git_pass(git_diff_print_patch(diff, diff_print_cb, fp ? fp : stderr));
}
diff --git a/tests-clar/diff/diff_helpers.h b/tests-clar/diff/diff_helpers.h
index 6ff493d..12591f6 100644
--- a/tests-clar/diff/diff_helpers.h
+++ b/tests-clar/diff/diff_helpers.h
@@ -20,31 +20,31 @@ typedef struct {
int line_dels;
} diff_expects;
-extern int diff_file_fn(
- void *cb_data,
+extern int diff_file_cb(
const git_diff_delta *delta,
- float progress);
+ float progress,
+ void *cb_data);
-extern int diff_hunk_fn(
- void *cb_data,
+extern int diff_hunk_cb(
const git_diff_delta *delta,
const git_diff_range *range,
const char *header,
- size_t header_len);
+ size_t header_len,
+ void *cb_data);
-extern int diff_line_fn(
- void *cb_data,
+extern int diff_line_cb(
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *content,
- size_t content_len);
+ size_t content_len,
+ void *cb_data);
extern int diff_foreach_via_iterator(
git_diff_list *diff,
- void *data,
- git_diff_file_fn file_cb,
- git_diff_hunk_fn hunk_cb,
- git_diff_data_fn line_cb);
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_data_cb line_cb,
+ void *data);
extern void diff_print(FILE *fp, git_diff_list *diff);
diff --git a/tests-clar/diff/index.c b/tests-clar/diff/index.c
index 4b96bfa..9591e34 100644
--- a/tests-clar/diff/index.c
+++ b/tests-clar/diff/index.c
@@ -35,7 +35,7 @@ void test_diff_index__0(void)
cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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_index_to_tree(&diff, g_repo, b, NULL, &opts));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
@@ -92,11 +92,11 @@ void test_diff_index__0(void)
}
static int diff_stop_after_2_files(
- void *cb_data,
const git_diff_delta *delta,
- float progress)
+ float progress,
+ void *payload)
{
- diff_expects *e = cb_data;
+ diff_expects *e = payload;
GIT_UNUSED(progress);
GIT_UNUSED(delta);
@@ -129,7 +129,7 @@ void test_diff_index__1(void)
cl_assert_equal_i(
GIT_EUSER,
- git_diff_foreach(diff, &exp, diff_stop_after_2_files, NULL, NULL)
+ git_diff_foreach(diff, diff_stop_after_2_files, NULL, NULL, &exp)
);
cl_assert_equal_i(2, exp.files);
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index 6aaf765..6a3c5bc 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -22,14 +22,14 @@ void test_diff_patch__cleanup(void)
#define EXPECTED_HUNK "@@ -1,2 +0,0 @@\n"
static int check_removal_cb(
- void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *formatted_output,
- size_t output_len)
+ size_t output_len,
+ void *payload)
{
- GIT_UNUSED(cb_data);
+ GIT_UNUSED(payload);
GIT_UNUSED(output_len);
switch (line_origin) {
@@ -90,7 +90,7 @@ void test_diff_patch__can_properly_display_the_removal_of_a_file(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
- cl_git_pass(git_diff_print_patch(diff, NULL, check_removal_cb));
+ cl_git_pass(git_diff_print_patch(diff, check_removal_cb, NULL));
git_diff_list_free(diff);
@@ -113,7 +113,7 @@ void test_diff_patch__to_string(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
- cl_assert_equal_i(1, git_diff_num_deltas(diff));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c
index 1ea2e3f..0d57f8f 100644
--- a/tests-clar/diff/rename.c
+++ b/tests-clar/diff/rename.c
@@ -55,7 +55,7 @@ void test_diff_rename__match_oid(void)
*/
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -69,7 +69,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -91,7 +91,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c
index 8e89399..58dc4e6 100644
--- a/tests-clar/diff/tree.c
+++ b/tests-clar/diff/tree.c
@@ -37,7 +37,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, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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_ADDED]);
@@ -59,7 +59,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, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -94,17 +94,18 @@ void test_diff_tree__options(void)
int test_ab_or_cd[] = { 0, 0, 0, 0, 1, 1, 1, 1, 1 };
git_diff_options test_options[] = {
/* a vs b tests */
- { GIT_DIFF_NORMAL, 1, 1, NULL, NULL, {0} },
- { GIT_DIFF_NORMAL, 3, 1, NULL, NULL, {0} },
- { GIT_DIFF_REVERSE, 2, 1, NULL, NULL, {0} },
- { GIT_DIFF_FORCE_TEXT, 2, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_NORMAL, 1, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_NORMAL, 3, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_REVERSE, 2, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_FORCE_TEXT, 2, 1, NULL, NULL, {0} },
/* c vs d tests */
- { GIT_DIFF_NORMAL, 3, 1, NULL, NULL, {0} },
- { GIT_DIFF_IGNORE_WHITESPACE, 3, 1, NULL, NULL, {0} },
- { GIT_DIFF_IGNORE_WHITESPACE_CHANGE, 3, 1, NULL, NULL, {0} },
- { GIT_DIFF_IGNORE_WHITESPACE_EOL, 3, 1, NULL, NULL, {0} },
- { GIT_DIFF_IGNORE_WHITESPACE | GIT_DIFF_REVERSE, 1, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_NORMAL, 3, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_IGNORE_WHITESPACE, 3, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_IGNORE_WHITESPACE_CHANGE, 3, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_IGNORE_WHITESPACE_EOL, 3, 1, NULL, NULL, {0} },
+ { 1, GIT_DIFF_IGNORE_WHITESPACE | GIT_DIFF_REVERSE, 1, 1, NULL, NULL, {0} },
};
+
/* to generate these values:
* - cd to tests/resources/attr,
* - mv .gitted .git
@@ -112,6 +113,7 @@ void test_diff_tree__options(void)
* - mv .git .gitted
*/
#define EXPECT_STATUS_ADM(ADDS,DELS,MODS) { 0, ADDS, DELS, MODS, 0, 0, 0, 0, 0 }
+
diff_expects test_expects[] = {
/* a vs b tests */
{ 5, 0, EXPECT_STATUS_ADM(3, 0, 2), 4, 0, 0, 51, 2, 46, 3 },
@@ -146,7 +148,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, &actual, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &actual));
expected = &test_expects[i];
cl_assert_equal_i(actual.files, expected->files);
@@ -190,7 +192,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, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
@@ -240,7 +242,7 @@ void test_diff_tree__merge(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff1, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff1, diff_file_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]);
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c
index a4dbe37..7636c6e 100644
--- a/tests-clar/diff/workdir.c
+++ b/tests-clar/diff/workdir.c
@@ -33,10 +33,10 @@ void test_diff_workdir__to_index(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
@@ -101,10 +101,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -137,10 +137,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -174,10 +174,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -223,9 +223,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, NULL, NULL));
+ diff, diff_file_cb, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, &exp, diff_file_fn, NULL, NULL));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(13, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -246,9 +246,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, NULL, NULL));
+ diff, diff_file_cb, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, &exp, diff_file_fn, NULL, NULL));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -269,9 +269,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, NULL, NULL));
+ diff, diff_file_cb, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, &exp, diff_file_fn, NULL, NULL));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -292,9 +292,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, NULL, NULL));
+ diff, diff_file_cb, NULL, NULL, &exp));
else
- cl_git_pass(git_diff_foreach(diff, &exp, diff_file_fn, NULL, NULL));
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
@@ -331,10 +331,10 @@ void test_diff_workdir__filemode_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -354,10 +354,10 @@ void test_diff_workdir__filemode_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -390,7 +390,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -406,7 +406,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -450,10 +450,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff_i2t, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff_i2t, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff_i2t, diff_file_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]);
@@ -471,10 +471,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff_w2i, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff_w2i, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff_w2i, diff_file_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]);
@@ -494,10 +494,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff_i2t, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff_i2t, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff_i2t, diff_file_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]);
@@ -536,10 +536,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -563,10 +563,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -590,10 +590,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_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]);
@@ -792,7 +792,7 @@ void test_diff_workdir__submodules(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
- diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+ diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* the following differs from "git diff 873585" by one "untracked" file
* because the diff list includes the "not_submodule/" directory which
diff --git a/tests-clar/fetchhead/network.c b/tests-clar/fetchhead/network.c
index 0710480..46cb977 100644
--- a/tests-clar/fetchhead/network.c
+++ b/tests-clar/fetchhead/network.c
@@ -46,7 +46,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
if(fetchspec != NULL)
git_remote_set_fetchspec(remote, fetchspec);
- cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(remote, NULL, NULL));
cl_git_pass(git_remote_update_tips(remote));
git_remote_disconnect(remote);
diff --git a/tests-clar/index/conflicts.c b/tests-clar/index/conflicts.c
index 91ff926..2fbad3e 100644
--- a/tests-clar/index/conflicts.c
+++ b/tests-clar/index/conflicts.c
@@ -132,9 +132,9 @@ void test_index_conflicts__get(void)
void test_index_conflicts__remove(void)
{
- git_index_entry *entry;
+ const git_index_entry *entry;
size_t i;
-
+
cl_assert(git_index_entrycount(repo_index) == 8);
cl_git_pass(git_index_conflict_remove(repo_index, "conflicts-one.txt"));
@@ -156,7 +156,7 @@ void test_index_conflicts__remove(void)
void test_index_conflicts__moved_to_reuc(void)
{
- git_index_entry *entry;
+ const git_index_entry *entry;
size_t i;
cl_assert(git_index_entrycount(repo_index) == 8);
@@ -178,7 +178,7 @@ void test_index_conflicts__moved_to_reuc(void)
void test_index_conflicts__remove_all_conflicts(void)
{
size_t i;
- git_index_entry *entry;
+ const git_index_entry *entry;
cl_assert(git_index_entrycount(repo_index) == 8);
diff --git a/tests-clar/index/filemodes.c b/tests-clar/index/filemodes.c
index 882d417..6140b11 100644
--- a/tests-clar/index/filemodes.c
+++ b/tests-clar/index/filemodes.c
@@ -22,10 +22,10 @@ void test_index_filemodes__read(void)
static bool expected[6] = { 0, 1, 0, 1, 0, 1 };
cl_git_pass(git_repository_index(&index, g_repo));
- cl_assert_equal_i(6, git_index_entrycount(index));
+ cl_assert_equal_i(6, (int)git_index_entrycount(index));
for (i = 0; i < 6; ++i) {
- git_index_entry *entry = git_index_get_byindex(index, i);
+ const git_index_entry *entry = git_index_get_byindex(index, i);
cl_assert(entry != NULL);
cl_assert(((entry->mode & 0100) ? 1 : 0) == expected[i]);
}
@@ -54,7 +54,7 @@ static void add_and_check_mode(
git_index *index, const char *filename, unsigned int expect_mode)
{
int pos;
- git_index_entry *entry;
+ const git_index_entry *entry;
cl_git_pass(git_index_add_from_workdir(index, filename));
diff --git a/tests-clar/index/inmemory.c b/tests-clar/index/inmemory.c
index c997b96..a5f72c4 100644
--- a/tests-clar/index/inmemory.c
+++ b/tests-clar/index/inmemory.c
@@ -5,7 +5,7 @@ void test_index_inmemory__can_create_an_inmemory_index(void)
git_index *index;
cl_git_pass(git_index_new(&index));
- cl_assert_equal_i(0, git_index_entrycount(index));
+ cl_assert_equal_i(0, (int)git_index_entrycount(index));
git_index_free(index);
}
diff --git a/tests-clar/index/rename.c b/tests-clar/index/rename.c
index e16ec00..adbbcfa 100644
--- a/tests-clar/index/rename.c
+++ b/tests-clar/index/rename.c
@@ -7,7 +7,7 @@ void test_index_rename__single_file(void)
git_index *index;
int position;
git_oid expected;
- git_index_entry *entry;
+ const git_index_entry *entry;
p_mkdir("rename", 0700);
diff --git a/tests-clar/index/stage.c b/tests-clar/index/stage.c
index 9c9d296..0f3b298 100644
--- a/tests-clar/index/stage.c
+++ b/tests-clar/index/stage.c
@@ -27,7 +27,7 @@ void test_index_stage__cleanup(void)
void test_index_stage__add_always_adds_stage_0(void)
{
int entry_idx;
- git_index_entry *entry;
+ const git_index_entry *entry;
cl_git_mkfile("./mergedrepo/new-file.txt", "new-file\n");
@@ -41,7 +41,7 @@ void test_index_stage__add_always_adds_stage_0(void)
void test_index_stage__find_gets_first_stage(void)
{
int entry_idx;
- git_index_entry *entry;
+ const git_index_entry *entry;
cl_assert((entry_idx = git_index_find(repo_index, "one.txt")) >= 0);
cl_assert((entry = git_index_get_byindex(repo_index, entry_idx)) != NULL);
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 3b71b70..30a5a31 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -1,8 +1,8 @@
#include "clar_libgit2.h"
#include "index.h"
-static const int index_entry_count = 109;
-static const int index_entry_count_2 = 1437;
+static const size_t index_entry_count = 109;
+static const size_t index_entry_count_2 = 1437;
#define TEST_INDEX_PATH cl_fixture("testrepo.git/index")
#define TEST_INDEX2_PATH cl_fixture("gitgit.index")
#define TEST_INDEXBIG_PATH cl_fixture("big.index")
@@ -99,7 +99,7 @@ void test_index_tests__default_test_index(void)
cl_git_pass(git_index_open(&index, TEST_INDEX_PATH));
cl_assert(index->on_disk);
- cl_assert(git_index_entrycount(index) == (unsigned int)index_entry_count);
+ cl_assert(git_index_entrycount(index) == index_entry_count);
cl_assert(index->entries.sorted);
entries = (git_index_entry **)index->entries.contents;
@@ -122,7 +122,7 @@ void test_index_tests__gitgit_index(void)
cl_git_pass(git_index_open(&index, TEST_INDEX2_PATH));
cl_assert(index->on_disk);
- cl_assert(git_index_entrycount(index) == (unsigned int)index_entry_count_2);
+ cl_assert(git_index_entrycount(index) == index_entry_count_2);
cl_assert(index->entries.sorted);
cl_assert(index->tree != NULL);
@@ -208,7 +208,7 @@ void test_index_tests__add(void)
git_index *index;
git_filebuf file = GIT_FILEBUF_INIT;
git_repository *repo;
- git_index_entry *entry;
+ const git_index_entry *entry;
git_oid id1;
/* Intialize a new repository */
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index 9c37d72..81a0eed 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -29,7 +29,7 @@ static int update_tips(const char *refname, const git_oid *a, const git_oid *b,
static void progress(const git_transfer_progress *stats, void *payload)
{
- int *bytes_received = (int*)payload;
+ size_t *bytes_received = (size_t *)payload;
*bytes_received = stats->received_bytes;
}
@@ -37,7 +37,7 @@ static void do_fetch(const char *url, int flag, int n)
{
git_remote *remote;
git_remote_callbacks callbacks;
- int bytes_received = 0;
+ size_t bytes_received = 0;
memset(&callbacks, 0, sizeof(git_remote_callbacks));
callbacks.update_tips = update_tips;
@@ -46,7 +46,7 @@ static void do_fetch(const char *url, int flag, int n)
cl_git_pass(git_remote_add(&remote, _repo, "test", url));
git_remote_set_callbacks(remote, &callbacks);
git_remote_set_autotag(remote, flag);
- cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(remote, progress, &bytes_received));
git_remote_disconnect(remote);
cl_git_pass(git_remote_update_tips(remote));
diff --git a/tests-clar/network/fetchlocal.c b/tests-clar/network/fetchlocal.c
index bff0bb0..018531c 100644
--- a/tests-clar/network/fetchlocal.c
+++ b/tests-clar/network/fetchlocal.c
@@ -22,12 +22,12 @@ void test_network_fetchlocal__complete(void)
cl_git_pass(git_repository_init(&repo, "foo", true));
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
- cl_git_pass(git_remote_connect(origin, GIT_DIR_FETCH));
+ cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
cl_git_pass(git_remote_update_tips(origin));
cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL));
- cl_assert_equal_i(18, refnames.count);
+ cl_assert_equal_i(18, (int)refnames.count);
cl_assert(callcount > 0);
git_strarray_free(&refnames);
@@ -44,18 +44,18 @@ void test_network_fetchlocal__partial(void)
const char *url;
cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL));
- cl_assert_equal_i(1, refnames.count);
+ cl_assert_equal_i(1, (int)refnames.count);
url = cl_git_fixture_url("testrepo.git");
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
- cl_git_pass(git_remote_connect(origin, GIT_DIR_FETCH));
+ cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
cl_git_pass(git_remote_update_tips(origin));
git_strarray_free(&refnames);
cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL));
- cl_assert_equal_i(19, refnames.count); /* 18 remote + 1 local */
+ cl_assert_equal_i(19, (int)refnames.count); /* 18 remote + 1 local */
cl_assert(callcount > 0);
git_strarray_free(&refnames);
diff --git a/tests-clar/network/refspecs.c b/tests-clar/network/refspecs.c
index 3b12817..b3d80fb 100644
--- a/tests-clar/network/refspecs.c
+++ b/tests-clar/network/refspecs.c
@@ -7,7 +7,7 @@ static void assert_refspec(unsigned int direction, const char *input, bool is_ex
git_refspec refspec;
int error;
- error = git_refspec__parse(&refspec, input, direction == GIT_DIR_FETCH);
+ error = git_refspec__parse(&refspec, input, direction == GIT_DIRECTION_FETCH);
git_refspec__free(&refspec);
if (is_expected_to_be_valid)
@@ -20,19 +20,19 @@ void test_network_refspecs__parsing(void)
{
// Ported from https://github.com/git/git/blob/abd2bde78bd994166900290434a2048e660dabed/t/t5511-refspec.sh
- assert_refspec(GIT_DIR_PUSH, "", false);
- assert_refspec(GIT_DIR_PUSH, ":", true);
- assert_refspec(GIT_DIR_PUSH, "::", false);
- assert_refspec(GIT_DIR_PUSH, "+:", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "", false);
+ assert_refspec(GIT_DIRECTION_PUSH, ":", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "::", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "+:", true);
- assert_refspec(GIT_DIR_FETCH, "", true);
- assert_refspec(GIT_DIR_PUSH, ":", true);
- assert_refspec(GIT_DIR_FETCH, "::", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "", true);
+ assert_refspec(GIT_DIRECTION_PUSH, ":", true);
+ assert_refspec(GIT_DIRECTION_FETCH, "::", false);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/*:refs/remotes/frotz/*", true);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/*:refs/remotes/frotz", false);
- assert_refspec(GIT_DIR_PUSH, "refs/heads:refs/remotes/frotz/*", false);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*:refs/remotes/frotz/*", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*:refs/remotes/frotz", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads:refs/remotes/frotz/*", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
/*
* These have invalid LHS, but we do not have a formal "valid sha-1
@@ -40,45 +40,45 @@ void test_network_refspecs__parsing(void)
* code. They will be caught downstream anyway, but we may want to
* have tighter check later...
*/
- //assert_refspec(GIT_DIR_PUSH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
- //assert_refspec(GIT_DIR_PUSH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
-
- assert_refspec(GIT_DIR_FETCH, "refs/heads/*:refs/remotes/frotz/*", true);
- assert_refspec(GIT_DIR_FETCH, "refs/heads/*:refs/remotes/frotz", false);
- assert_refspec(GIT_DIR_FETCH, "refs/heads:refs/remotes/frotz/*", false);
- assert_refspec(GIT_DIR_FETCH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
- assert_refspec(GIT_DIR_FETCH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
- assert_refspec(GIT_DIR_FETCH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
-
- assert_refspec(GIT_DIR_PUSH, "master~1:refs/remotes/frotz/backup", true);
- assert_refspec(GIT_DIR_FETCH, "master~1:refs/remotes/frotz/backup", false);
- assert_refspec(GIT_DIR_PUSH, "HEAD~4:refs/remotes/frotz/new", true);
- assert_refspec(GIT_DIR_FETCH, "HEAD~4:refs/remotes/frotz/new", false);
-
- assert_refspec(GIT_DIR_PUSH, "HEAD", true);
- assert_refspec(GIT_DIR_FETCH, "HEAD", true);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/ nitfol", false);
- assert_refspec(GIT_DIR_FETCH, "refs/heads/ nitfol", false);
-
- assert_refspec(GIT_DIR_PUSH, "HEAD:", false);
- assert_refspec(GIT_DIR_FETCH, "HEAD:", true);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/ nitfol:", false);
- assert_refspec(GIT_DIR_FETCH, "refs/heads/ nitfol:", false);
-
- assert_refspec(GIT_DIR_PUSH, ":refs/remotes/frotz/deleteme", true);
- assert_refspec(GIT_DIR_FETCH, ":refs/remotes/frotz/HEAD-to-me", true);
- assert_refspec(GIT_DIR_PUSH, ":refs/remotes/frotz/delete me", false);
- assert_refspec(GIT_DIR_FETCH, ":refs/remotes/frotz/HEAD to me", false);
-
- assert_refspec(GIT_DIR_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
-
- assert_refspec(GIT_DIR_FETCH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
- assert_refspec(GIT_DIR_PUSH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
-
- assert_refspec(GIT_DIR_FETCH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
-
- assert_refspec(GIT_DIR_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
- assert_refspec(GIT_DIR_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
+ //assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
+ //assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
+
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*:refs/remotes/frotz/*", true);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*:refs/remotes/frotz", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads:refs/remotes/frotz/*", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
+
+ assert_refspec(GIT_DIRECTION_PUSH, "master~1:refs/remotes/frotz/backup", true);
+ assert_refspec(GIT_DIRECTION_FETCH, "master~1:refs/remotes/frotz/backup", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "HEAD~4:refs/remotes/frotz/new", true);
+ assert_refspec(GIT_DIRECTION_FETCH, "HEAD~4:refs/remotes/frotz/new", false);
+
+ assert_refspec(GIT_DIRECTION_PUSH, "HEAD", true);
+ assert_refspec(GIT_DIRECTION_FETCH, "HEAD", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/ nitfol", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/ nitfol", false);
+
+ assert_refspec(GIT_DIRECTION_PUSH, "HEAD:", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "HEAD:", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/ nitfol:", false);
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/ nitfol:", false);
+
+ assert_refspec(GIT_DIRECTION_PUSH, ":refs/remotes/frotz/deleteme", true);
+ assert_refspec(GIT_DIRECTION_FETCH, ":refs/remotes/frotz/HEAD-to-me", true);
+ assert_refspec(GIT_DIRECTION_PUSH, ":refs/remotes/frotz/delete me", false);
+ assert_refspec(GIT_DIRECTION_FETCH, ":refs/remotes/frotz/HEAD to me", false);
+
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
+
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
+
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
+
+ assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
+ assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
}
diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c
index f7dcfc0..8376b8b 100644
--- a/tests-clar/network/remotelocal.c
+++ b/tests-clar/network/remotelocal.c
@@ -51,7 +51,7 @@ static void connect_to_local_repository(const char *local_repository)
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
- cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
}
diff --git a/tests-clar/network/remoterename.c b/tests-clar/network/remoterename.c
index e9a7fc0..b145545 100644
--- a/tests-clar/network/remoterename.c
+++ b/tests-clar/network/remoterename.c
@@ -64,7 +64,7 @@ void test_network_remoterename__renaming_a_remote_without_a_fetchrefspec_doesnt_
git_remote_free(_remote);
cl_git_pass(git_repository_config__weakptr(&config, _repo));
- cl_git_pass(git_config_delete(config, "remote.test.fetch"));
+ cl_git_pass(git_config_delete_entry(config, "remote.test.fetch"));
cl_git_pass(git_remote_load(&_remote, _repo, "test"));
diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c
index 4fe3ebe..14fda16 100644
--- a/tests-clar/network/remotes.c
+++ b/tests-clar/network/remotes.c
@@ -33,9 +33,9 @@ void test_network_remotes__parsing(void)
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
cl_assert(git_remote_pushurl(_remote) == NULL);
- cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIR_FETCH),
+ cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_FETCH),
"git://github.com/libgit2/libgit2");
- cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIR_PUSH),
+ cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_PUSH),
"git://github.com/libgit2/libgit2");
cl_git_pass(git_remote_load(&_remote2, _repo, "test_with_pushurl"));
@@ -43,9 +43,9 @@ void test_network_remotes__parsing(void)
cl_assert_equal_s(git_remote_url(_remote2), "git://github.com/libgit2/fetchlibgit2");
cl_assert_equal_s(git_remote_pushurl(_remote2), "git://github.com/libgit2/pushlibgit2");
- cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIR_FETCH),
+ cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_FETCH),
"git://github.com/libgit2/fetchlibgit2");
- cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIR_PUSH),
+ cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_PUSH),
"git://github.com/libgit2/pushlibgit2");
git_remote_free(_remote2);
diff --git a/tests-clar/notes/notes.c b/tests-clar/notes/notes.c
index 706bc03..3f5194c 100644
--- a/tests-clar/notes/notes.c
+++ b/tests-clar/notes/notes.c
@@ -50,7 +50,8 @@ static struct {
#define EXPECTATIONS_COUNT (sizeof(list_expectations)/sizeof(list_expectations[0])) - 1
-static int note_list_cb(git_note_data *note_data, void *payload)
+static int note_list_cb(
+ const git_oid *blob_id, const git_oid *annotated_obj_id, void *payload)
{
git_oid expected_note_oid, expected_target_oid;
@@ -59,10 +60,10 @@ static int note_list_cb(git_note_data *note_data, void *payload)
cl_assert(*count < EXPECTATIONS_COUNT);
cl_git_pass(git_oid_fromstr(&expected_note_oid, list_expectations[*count].note_sha));
- cl_assert(git_oid_cmp(&expected_note_oid, ¬e_data->blob_oid) == 0);
+ cl_assert(git_oid_cmp(&expected_note_oid, blob_id) == 0);
cl_git_pass(git_oid_fromstr(&expected_target_oid, list_expectations[*count].annotated_object_sha));
- cl_assert(git_oid_cmp(&expected_target_oid, ¬e_data->annotated_object_oid) == 0);
+ cl_assert(git_oid_cmp(&expected_target_oid, annotated_obj_id) == 0);
(*count)++;
@@ -103,11 +104,13 @@ void test_notes_notes__can_retrieve_a_list_of_notes_for_a_given_namespace(void)
cl_assert_equal_i(4, retrieved_notes);
}
-static int note_cancel_cb(git_note_data *note_data, void *payload)
+static int note_cancel_cb(
+ const git_oid *blob_id, const git_oid *annotated_obj_id, void *payload)
{
unsigned int *count = (unsigned int *)payload;
- GIT_UNUSED(note_data);
+ GIT_UNUSED(blob_id);
+ GIT_UNUSED(annotated_obj_id);
(*count)++;
diff --git a/tests-clar/notes/notesref.c b/tests-clar/notes/notesref.c
index 67c4003..d26056f 100644
--- a/tests-clar/notes/notesref.c
+++ b/tests-clar/notes/notesref.c
@@ -57,7 +57,7 @@ void test_notes_notesref__config_corenotesref(void)
cl_git_pass(git_note_default_ref(&default_ref, _repo));
cl_assert(!strcmp(default_ref, "refs/notes/mydefaultnotesref"));
- cl_git_pass(git_config_delete(_cfg, "core.notesRef"));
+ cl_git_pass(git_config_delete_entry(_cfg, "core.notesRef"));
cl_git_pass(git_note_default_ref(&default_ref, _repo));
cl_assert(!strcmp(default_ref, GIT_NOTES_DEFAULT_REF));
diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c
index 0b87b2b..7854898 100644
--- a/tests-clar/object/blob/filter.c
+++ b/tests-clar/object/blob/filter.c
@@ -14,7 +14,7 @@ static const char *g_raw[NUM_TEST_OBJECTS] = {
"foo\nbar\rboth\r\nreversed\n\ragain\nproblems\r",
"123\n\000\001\002\003\004abc\255\254\253\r\n"
};
-static int g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17 };
+static git_off_t g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17 };
static git_text_stats g_stats[NUM_TEST_OBJECTS] = {
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 2, 0, 6, 0 },
@@ -43,7 +43,7 @@ void test_object_blob_filter__initialize(void)
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
size_t len = (g_len[i] < 0) ? strlen(g_raw[i]) : (size_t)g_len[i];
- g_len[i] = (int)len;
+ g_len[i] = (git_off_t)len;
cl_git_pass(
git_blob_create_frombuffer(&g_oids[i], g_repo, g_raw[i], len)
@@ -65,8 +65,8 @@ void test_object_blob_filter__unfiltered(void)
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i]));
- cl_assert((size_t)g_len[i] == git_blob_rawsize(blob));
- cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], g_len[i]) == 0);
+ cl_assert(g_len[i] == git_blob_rawsize(blob));
+ cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], (size_t)g_len[i]) == 0);
git_blob_free(blob);
}
}
diff --git a/tests-clar/object/blob/write.c b/tests-clar/object/blob/write.c
index 6d4cbab..203bc67 100644
--- a/tests-clar/object/blob/write.c
+++ b/tests-clar/object/blob/write.c
@@ -33,7 +33,7 @@ void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_file_lo
{
repo = cl_git_sandbox_init(WORKDIR);
- assert_blob_creation(WORKDIR "/test.txt", "test.txt", &git_blob_create_fromfile);
+ assert_blob_creation(WORKDIR "/test.txt", "test.txt", &git_blob_create_fromworkdir);
}
void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_absolute_filepath_pointing_outside_of_the_working_directory(void)
diff --git a/tests-clar/object/commit/commitstagedfile.c b/tests-clar/object/commit/commitstagedfile.c
index 6dc536e..55c70d9 100644
--- a/tests-clar/object/commit/commitstagedfile.c
+++ b/tests-clar/object/commit/commitstagedfile.c
@@ -21,7 +21,7 @@ void test_object_commit_commitstagedfile__cleanup(void)
void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
{
git_index *index;
- git_index_entry *entry;
+ const git_index_entry *entry;
git_oid expected_blob_oid, tree_oid, expected_tree_oid, commit_oid, expected_commit_oid;
git_signature *signature;
git_tree *tree;
diff --git a/tests-clar/object/tag/write.c b/tests-clar/object/tag/write.c
index 10d0479..ad6ca76 100644
--- a/tests-clar/object/tag/write.c
+++ b/tests-clar/object/tag/write.c
@@ -45,7 +45,7 @@ void test_object_tag_write__basic(void)
git_signature_free(tagger);
cl_git_pass(git_tag_lookup(&tag, g_repo, &tag_id));
- cl_assert(git_oid_cmp(git_tag_target_oid(tag), &target_id) == 0);
+ cl_assert(git_oid_cmp(git_tag_target_id(tag), &target_id) == 0);
/* Check attributes were set correctly */
tagger1 = git_tag_tagger(tag);
@@ -58,7 +58,7 @@ void test_object_tag_write__basic(void)
cl_assert_equal_s(git_tag_message(tag), tagger_message);
cl_git_pass(git_reference_lookup(&ref_tag, g_repo, "refs/tags/the-tag"));
- cl_assert(git_oid_cmp(git_reference_oid(ref_tag), &tag_id) == 0);
+ cl_assert(git_oid_cmp(git_reference_target(ref_tag), &tag_id) == 0);
cl_git_pass(git_reference_delete(ref_tag));
git_tag_free(tag);
@@ -103,7 +103,7 @@ void test_object_tag_write__replace(void)
cl_git_pass(git_object_lookup(&target, g_repo, &target_id, GIT_OBJ_COMMIT));
cl_git_pass(git_reference_lookup(&ref_tag, g_repo, "refs/tags/e90810b"));
- git_oid_cpy(&old_tag_id, git_reference_oid(ref_tag));
+ git_oid_cpy(&old_tag_id, git_reference_target(ref_tag));
git_reference_free(ref_tag);
/* create signature */
@@ -122,8 +122,8 @@ void test_object_tag_write__replace(void)
git_signature_free(tagger);
cl_git_pass(git_reference_lookup(&ref_tag, g_repo, "refs/tags/e90810b"));
- cl_assert(git_oid_cmp(git_reference_oid(ref_tag), &tag_id) == 0);
- cl_assert(git_oid_cmp(git_reference_oid(ref_tag), &old_tag_id) != 0);
+ cl_assert(git_oid_cmp(git_reference_target(ref_tag), &tag_id) == 0);
+ cl_assert(git_oid_cmp(git_reference_target(ref_tag), &old_tag_id) != 0);
git_reference_free(ref_tag);
}
@@ -150,7 +150,7 @@ void test_object_tag_write__lightweight(void)
cl_assert(git_oid_cmp(&object_id, &target_id) == 0);
cl_git_pass(git_reference_lookup(&ref_tag, g_repo, "refs/tags/light-tag"));
- cl_assert(git_oid_cmp(git_reference_oid(ref_tag), &target_id) == 0);
+ cl_assert(git_oid_cmp(git_reference_target(ref_tag), &target_id) == 0);
cl_git_pass(git_tag_delete(g_repo, "light-tag"));
diff --git a/tests-clar/object/tree/duplicateentries.c b/tests-clar/object/tree/duplicateentries.c
index 3052e29..9262f9a 100644
--- a/tests-clar/object/tree/duplicateentries.c
+++ b/tests-clar/object/tree/duplicateentries.c
@@ -42,7 +42,7 @@ static void tree_checker(
git_oid oid;
cl_git_pass(git_tree_lookup(&tree, _repo, tid));
- cl_assert_equal_i(1, git_tree_entrycount(tree));
+ cl_assert_equal_i(1, (int)git_tree_entrycount(tree));
entry = git_tree_entry_byindex(tree, 0);
cl_git_pass(git_oid_fromstr(&oid, expected_sha));
diff --git a/tests-clar/object/tree/walk.c b/tests-clar/object/tree/walk.c
index 58b0bca..b7af492 100644
--- a/tests-clar/object/tree/walk.c
+++ b/tests-clar/object/tree/walk.c
@@ -38,11 +38,11 @@ void test_object_tree_walk__0(void)
cl_git_pass(git_tree_lookup(&tree, g_repo, &id));
ct = 0;
- cl_git_pass(git_tree_walk(tree, treewalk_count_cb, GIT_TREEWALK_PRE, &ct));
+ cl_git_pass(git_tree_walk(tree, GIT_TREEWALK_PRE, treewalk_count_cb, &ct));
cl_assert_equal_i(3, ct);
ct = 0;
- cl_git_pass(git_tree_walk(tree, treewalk_count_cb, GIT_TREEWALK_POST, &ct));
+ cl_git_pass(git_tree_walk(tree, GIT_TREEWALK_POST, treewalk_count_cb, &ct));
cl_assert_equal_i(3, ct);
git_tree_free(tree);
@@ -83,21 +83,21 @@ void test_object_tree_walk__1(void)
ct = 0;
cl_assert_equal_i(
- GIT_EUSER, git_tree_walk(tree, treewalk_stop_cb, GIT_TREEWALK_PRE, &ct));
+ GIT_EUSER, git_tree_walk(tree, GIT_TREEWALK_PRE, treewalk_stop_cb, &ct));
cl_assert_equal_i(2, ct);
ct = 0;
cl_assert_equal_i(
- GIT_EUSER, git_tree_walk(tree, treewalk_stop_cb, GIT_TREEWALK_POST, &ct));
+ GIT_EUSER, git_tree_walk(tree, GIT_TREEWALK_POST, treewalk_stop_cb, &ct));
cl_assert_equal_i(2, ct);
cl_assert_equal_i(
GIT_EUSER, git_tree_walk(
- tree, treewalk_stop_immediately_cb, GIT_TREEWALK_PRE, NULL));
+ tree, GIT_TREEWALK_PRE, treewalk_stop_immediately_cb, NULL));
cl_assert_equal_i(
GIT_EUSER, git_tree_walk(
- tree, treewalk_stop_immediately_cb, GIT_TREEWALK_POST, NULL));
+ tree, GIT_TREEWALK_POST, treewalk_stop_immediately_cb, NULL));
git_tree_free(tree);
}
diff --git a/tests-clar/odb/foreach.c b/tests-clar/odb/foreach.c
index bf52cc1..37158d4 100644
--- a/tests-clar/odb/foreach.c
+++ b/tests-clar/odb/foreach.c
@@ -16,7 +16,7 @@ void test_odb_foreach__cleanup(void)
_repo = NULL;
}
-static int foreach_cb(git_oid *oid, void *data)
+static int foreach_cb(const git_oid *oid, void *data)
{
GIT_UNUSED(data);
GIT_UNUSED(oid);
@@ -59,7 +59,7 @@ void test_odb_foreach__one_pack(void)
cl_assert(nobj == 1628);
}
-static int foreach_stop_cb(git_oid *oid, void *data)
+static int foreach_stop_cb(const git_oid *oid, void *data)
{
GIT_UNUSED(data);
GIT_UNUSED(oid);
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c
index 1ec768d..b450be6 100644
--- a/tests-clar/pack/packbuilder.c
+++ b/tests-clar/pack/packbuilder.c
@@ -67,7 +67,7 @@ static void seed_packbuilder(void)
git_object *obj;
cl_git_pass(git_object_lookup(&obj, _repo, o, GIT_OBJ_COMMIT));
cl_git_pass(git_packbuilder_insert_tree(_packbuilder,
- git_commit_tree_oid((git_commit *)obj)));
+ git_commit_tree_id((git_commit *)obj)));
git_object_free(obj);
}
}
diff --git a/tests-clar/refs/branches/create.c b/tests-clar/refs/branches/create.c
index 5ecb428..a8c4d4f 100644
--- a/tests-clar/refs/branches/create.c
+++ b/tests-clar/refs/branches/create.c
@@ -2,7 +2,7 @@
#include "refs.h"
static git_repository *repo;
-static git_object *target;
+static git_commit *target;
static git_reference *branch;
void test_refs_branches_create__initialize(void)
@@ -18,7 +18,7 @@ void test_refs_branches_create__cleanup(void)
git_reference_free(branch);
branch = NULL;
- git_object_free(target);
+ git_commit_free(target);
target = NULL;
git_repository_free(repo);
@@ -27,17 +27,17 @@ void test_refs_branches_create__cleanup(void)
cl_fixture_cleanup("testrepo.git");
}
-static void retrieve_target_from_oid(git_object **object_out, git_repository *repo, const char *sha)
+static void retrieve_target_from_oid(git_commit **out, git_repository *repo, const char *sha)
{
git_oid oid;
cl_git_pass(git_oid_fromstr(&oid, sha));
- cl_git_pass(git_object_lookup(object_out, repo, &oid, GIT_OBJ_ANY));
+ cl_git_pass(git_commit_lookup(out, repo, &oid));
}
-static void retrieve_known_commit(git_object **object, git_repository *repo)
+static void retrieve_known_commit(git_commit **commit, git_repository *repo)
{
- retrieve_target_from_oid(object, repo, "e90810b8df3e80c413d903f631643c716887138d");
+ retrieve_target_from_oid(commit, repo, "e90810b8df3e80c413d903f631643c716887138d");
}
#define NEW_BRANCH_NAME "new-branch-on-the-block"
@@ -47,7 +47,7 @@ void test_refs_branches_create__can_create_a_local_branch(void)
retrieve_known_commit(&target, repo);
cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0));
- cl_git_pass(git_oid_cmp(git_reference_oid(branch), git_object_id(target)));
+ cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target)));
}
void test_refs_branches_create__can_not_create_a_branch_if_its_name_collide_with_an_existing_one(void)
@@ -62,29 +62,6 @@ void test_refs_branches_create__can_force_create_over_an_existing_branch(void)
retrieve_known_commit(&target, repo);
cl_git_pass(git_branch_create(&branch, repo, "br2", target, 1));
- cl_git_pass(git_oid_cmp(git_reference_oid(branch), git_object_id(target)));
+ cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target)));
cl_assert_equal_s("refs/heads/br2", git_reference_name(branch));
}
-
-void test_refs_branches_create__creating_a_branch_targeting_a_tag_dereferences_it_to_its_commit(void)
-{
- /* b25fa35 is a tag, pointing to another tag which points to a commit */
- retrieve_target_from_oid(&target, repo, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
-
- cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0));
- cl_git_pass(git_oid_streq(git_reference_oid(branch), "e90810b8df3e80c413d903f631643c716887138d"));
-}
-
-void test_refs_branches_create__can_not_create_a_branch_pointing_to_a_non_commit_object(void)
-{
- /* 53fc32d is the tree of commit e90810b */
- retrieve_target_from_oid(&target, repo, "53fc32d17276939fc79ed05badaef2db09990016");
-
- cl_git_fail(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0));
- git_object_free(target);
-
- /* 521d87c is an annotated tag pointing to a blob */
- retrieve_target_from_oid(&target, repo, "521d87c1ec3aef9824daf6d96cc0ae3710766d91");
-
- cl_git_fail(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0));
-}
diff --git a/tests-clar/refs/branches/delete.c b/tests-clar/refs/branches/delete.c
index 75271a2..1843036 100644
--- a/tests-clar/refs/branches/delete.c
+++ b/tests-clar/refs/branches/delete.c
@@ -14,7 +14,7 @@ void test_refs_branches_delete__initialize(void)
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
- cl_git_pass(git_reference_create_oid(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
+ cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
}
void test_refs_branches_delete__cleanup(void)
@@ -35,7 +35,7 @@ void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
/* Ensure HEAD targets the local master branch */
cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE));
- cl_assert(strcmp("refs/heads/master", git_reference_target(head)) == 0);
+ cl_assert(strcmp("refs/heads/master", git_reference_symbolic_target(head)) == 0);
git_reference_free(head);
cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL));
@@ -71,7 +71,7 @@ void test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD(
cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE));
cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
- cl_assert_equal_s("refs/heads/master", git_reference_target(head));
+ cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
git_reference_free(head);
/* Detach HEAD and make it target the commit that "master" points to */
@@ -107,4 +107,4 @@ void test_refs_branches_delete__deleting_a_branch_removes_related_configuration_
assert_config_entry_existence(repo, "branch.track-local.remote", false);
assert_config_entry_existence(repo, "branch.track-local.merge", false);
-}
\ No newline at end of file
+}
diff --git a/tests-clar/refs/branches/foreach.c b/tests-clar/refs/branches/foreach.c
index dfa0439..96a5bc2 100644
--- a/tests-clar/refs/branches/foreach.c
+++ b/tests-clar/refs/branches/foreach.c
@@ -12,7 +12,7 @@ void test_refs_branches_foreach__initialize(void)
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
- cl_git_pass(git_reference_create_oid(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
+ cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
}
void test_refs_branches_foreach__cleanup(void)
@@ -119,7 +119,7 @@ void test_refs_branches_foreach__retrieve_remote_symbolic_HEAD_when_present(void
};
git_reference_free(fake_remote);
- cl_git_pass(git_reference_create_symbolic(&fake_remote, repo, "refs/remotes/nulltoken/HEAD", "refs/remotes/nulltoken/master", 0));
+ cl_git_pass(git_reference_symbolic_create(&fake_remote, repo, "refs/remotes/nulltoken/HEAD", "refs/remotes/nulltoken/master", 0));
assert_retrieval(GIT_BRANCH_REMOTE, 3);
diff --git a/tests-clar/refs/branches/ishead.c b/tests-clar/refs/branches/ishead.c
index 2ab488f..dfcf1b5 100644
--- a/tests-clar/refs/branches/ishead.c
+++ b/tests-clar/refs/branches/ishead.c
@@ -98,9 +98,9 @@ void test_refs_branches_ishead__only_direct_references_are_considered(void)
git_repository_free(repo);
repo = cl_git_sandbox_init("testrepo.git");
- cl_git_pass(git_reference_create_symbolic(&linked, repo, "refs/heads/linked", "refs/heads/master", 0));
- cl_git_pass(git_reference_create_symbolic(&super, repo, "refs/heads/super", "refs/heads/linked", 0));
- cl_git_pass(git_reference_create_symbolic(&head, repo, GIT_HEAD_FILE, "refs/heads/super", 1));
+ cl_git_pass(git_reference_symbolic_create(&linked, repo, "refs/heads/linked", "refs/heads/master", 0));
+ cl_git_pass(git_reference_symbolic_create(&super, repo, "refs/heads/super", "refs/heads/linked", 0));
+ cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/heads/super", 1));
cl_assert_equal_i(false, git_branch_is_head(linked));
cl_assert_equal_i(false, git_branch_is_head(super));
diff --git a/tests-clar/refs/crashes.c b/tests-clar/refs/crashes.c
index e1b289a..9fb5ff6 100644
--- a/tests-clar/refs/crashes.c
+++ b/tests-clar/refs/crashes.c
@@ -7,7 +7,7 @@ void test_refs_crashes__double_free(void)
const char *REFNAME = "refs/heads/xxx";
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- cl_git_pass(git_reference_create_symbolic(&ref, repo, REFNAME, "refs/heads/master", 0));
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, REFNAME, "refs/heads/master", 0));
cl_git_pass(git_reference_lookup(&ref2, repo, REFNAME));
cl_git_pass(git_reference_delete(ref));
/* reference is gone from disk, so reloading it will fail */
diff --git a/tests-clar/refs/create.c b/tests-clar/refs/create.c
index bf234bc..bef9bfd 100644
--- a/tests-clar/refs/create.c
+++ b/tests-clar/refs/create.c
@@ -36,7 +36,7 @@ void test_refs_create__symbolic(void)
git_buf_free(&ref_path);
/* Create and write the new symbolic reference */
- cl_git_pass(git_reference_create_symbolic(&new_reference, g_repo, new_head_tracker, current_head_target, 0));
+ cl_git_pass(git_reference_symbolic_create(&new_reference, g_repo, new_head_tracker, current_head_target, 0));
/* Ensure the reference can be looked-up... */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head_tracker));
@@ -49,7 +49,7 @@ void test_refs_create__symbolic(void)
cl_assert(git_reference_type(resolved_ref) == GIT_REF_OID);
/* ...and that it points to the current master tip */
- cl_assert(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0);
+ cl_assert(git_oid_cmp(&id, git_reference_target(resolved_ref)) == 0);
git_reference_free(looked_up_ref);
git_reference_free(resolved_ref);
@@ -58,7 +58,7 @@ void test_refs_create__symbolic(void)
cl_git_pass(git_reference_lookup(&looked_up_ref, repo2, new_head_tracker));
cl_git_pass(git_reference_resolve(&resolved_ref, looked_up_ref));
- cl_assert(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0);
+ cl_assert(git_oid_cmp(&id, git_reference_target(resolved_ref)) == 0);
git_repository_free(repo2);
@@ -79,10 +79,10 @@ void test_refs_create__deep_symbolic(void)
git_oid_fromstr(&id, current_master_tip);
cl_git_pass(git_buf_joinpath(&ref_path, g_repo->path_repository, new_head_tracker));
- cl_git_pass(git_reference_create_symbolic(&new_reference, g_repo, new_head_tracker, current_head_target, 0));
+ cl_git_pass(git_reference_symbolic_create(&new_reference, g_repo, new_head_tracker, current_head_target, 0));
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head_tracker));
cl_git_pass(git_reference_resolve(&resolved_ref, looked_up_ref));
- cl_assert(git_oid_cmp(&id, git_reference_oid(resolved_ref)) == 0);
+ cl_assert(git_oid_cmp(&id, git_reference_target(resolved_ref)) == 0);
git_reference_free(new_reference);
git_reference_free(looked_up_ref);
@@ -106,7 +106,7 @@ void test_refs_create__oid(void)
cl_git_pass(git_buf_joinpath(&ref_path, g_repo->path_repository, new_head));
/* Create and write the new object id reference */
- cl_git_pass(git_reference_create_oid(&new_reference, g_repo, new_head, &id, 0));
+ cl_git_pass(git_reference_create(&new_reference, g_repo, new_head, &id, 0));
/* Ensure the reference can be looked-up... */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head));
@@ -115,14 +115,14 @@ void test_refs_create__oid(void)
cl_assert_equal_s(looked_up_ref->name, new_head);
/* ...and that it points to the current master tip */
- cl_assert(git_oid_cmp(&id, git_reference_oid(looked_up_ref)) == 0);
+ cl_assert(git_oid_cmp(&id, git_reference_target(looked_up_ref)) == 0);
git_reference_free(looked_up_ref);
/* Similar test with a fresh new repository */
cl_git_pass(git_repository_open(&repo2, "testrepo"));
cl_git_pass(git_reference_lookup(&looked_up_ref, repo2, new_head));
- cl_assert(git_oid_cmp(&id, git_reference_oid(looked_up_ref)) == 0);
+ cl_assert(git_oid_cmp(&id, git_reference_target(looked_up_ref)) == 0);
git_repository_free(repo2);
@@ -142,7 +142,7 @@ void test_refs_create__oid_unknown(void)
git_oid_fromstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644");
/* Create and write the new object id reference */
- cl_git_fail(git_reference_create_oid(&new_reference, g_repo, new_head, &id, 0));
+ cl_git_fail(git_reference_create(&new_reference, g_repo, new_head, &id, 0));
/* Ensure the reference can't be looked-up... */
cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, new_head));
@@ -156,9 +156,9 @@ void test_refs_create__propagate_eexists(void)
/* Make sure it works for oid and for symbolic both */
git_oid_fromstr(&oid, current_master_tip);
- error = git_reference_create_oid(&ref, g_repo, current_head_target, &oid, false);
+ error = git_reference_create(&ref, g_repo, current_head_target, &oid, false);
cl_assert(error == GIT_EEXISTS);
- error = git_reference_create_symbolic(&ref, g_repo, "HEAD", current_head_target, false);
+ error = git_reference_symbolic_create(&ref, g_repo, "HEAD", current_head_target, false);
cl_assert(error == GIT_EEXISTS);
}
diff --git a/tests-clar/refs/delete.c b/tests-clar/refs/delete.c
index 912f414..cc5ab39 100644
--- a/tests-clar/refs/delete.c
+++ b/tests-clar/refs/delete.c
@@ -62,7 +62,7 @@ void test_refs_delete__packed_only(void)
git_oid_fromstr(&id, current_master_tip);
/* Create and write the new object id reference */
- cl_git_pass(git_reference_create_oid(&ref, g_repo, new_ref, &id, 0));
+ cl_git_pass(git_reference_create(&ref, g_repo, new_ref, &id, 0));
git_reference_free(ref);
/* Lookup the reference */
diff --git a/tests-clar/refs/foreachglob.c b/tests-clar/refs/foreachglob.c
index 8ecce9c..88516dd 100644
--- a/tests-clar/refs/foreachglob.c
+++ b/tests-clar/refs/foreachglob.c
@@ -12,7 +12,7 @@ void test_refs_foreachglob__initialize(void)
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
- cl_git_pass(git_reference_create_oid(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
+ cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
}
void test_refs_foreachglob__cleanup(void)
diff --git a/tests-clar/refs/lookup.c b/tests-clar/refs/lookup.c
index 71ab1b7..11fd68f 100644
--- a/tests-clar/refs/lookup.c
+++ b/tests-clar/refs/lookup.c
@@ -36,7 +36,7 @@ void test_refs_lookup__oid(void)
{
git_oid tag, expected;
- cl_git_pass(git_reference_name_to_oid(&tag, g_repo, "refs/tags/point_to_blob"));
+ cl_git_pass(git_reference_name_to_id(&tag, g_repo, "refs/tags/point_to_blob"));
cl_git_pass(git_oid_fromstr(&expected, "1385f264afb75a56a5bec74243be9b367ba4ca08"));
cl_assert(git_oid_cmp(&tag, &expected) == 0);
}
diff --git a/tests-clar/refs/overwrite.c b/tests-clar/refs/overwrite.c
index 410e39a..ebe7206 100644
--- a/tests-clar/refs/overwrite.c
+++ b/tests-clar/refs/overwrite.c
@@ -27,25 +27,25 @@ void test_refs_overwrite__symbolic(void)
git_reference *ref, *branch_ref;
/* The target needds to exist and we need to check the name has changed */
- cl_git_pass(git_reference_create_symbolic(&branch_ref, g_repo, ref_branch_name, ref_master_name, 0));
- cl_git_pass(git_reference_create_symbolic(&ref, g_repo, ref_name, ref_branch_name, 0));
+ cl_git_pass(git_reference_symbolic_create(&branch_ref, g_repo, ref_branch_name, ref_master_name, 0));
+ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_branch_name, 0));
git_reference_free(ref);
/* Ensure it points to the right place*/
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
cl_assert(git_reference_type(ref) & GIT_REF_SYMBOLIC);
- cl_assert_equal_s(git_reference_target(ref), ref_branch_name);
+ cl_assert_equal_s(git_reference_symbolic_target(ref), ref_branch_name);
git_reference_free(ref);
/* Ensure we can't create it unless we force it to */
- cl_git_fail(git_reference_create_symbolic(&ref, g_repo, ref_name, ref_master_name, 0));
- cl_git_pass(git_reference_create_symbolic(&ref, g_repo, ref_name, ref_master_name, 1));
+ cl_git_fail(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0));
+ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 1));
git_reference_free(ref);
/* Ensure it points to the right place */
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
cl_assert(git_reference_type(ref) & GIT_REF_SYMBOLIC);
- cl_assert_equal_s(git_reference_target(ref), ref_master_name);
+ cl_assert_equal_s(git_reference_symbolic_target(ref), ref_master_name);
git_reference_free(ref);
git_reference_free(branch_ref);
@@ -59,26 +59,26 @@ void test_refs_overwrite__object_id(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
git_reference_free(ref);
/* Create it */
- cl_git_pass(git_reference_create_oid(&ref, g_repo, ref_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 0));
git_reference_free(ref);
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_test_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
git_reference_free(ref);
/* Ensure we can't overwrite unless we force it */
- cl_git_fail(git_reference_create_oid(&ref, g_repo, ref_name, &id, 0));
- cl_git_pass(git_reference_create_oid(&ref, g_repo, ref_name, &id, 1));
+ cl_git_fail(git_reference_create(&ref, g_repo, ref_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 1));
git_reference_free(ref);
/* Ensure it has been overwritten */
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
- cl_assert(!git_oid_cmp(&id, git_reference_oid(ref)));
+ cl_assert(!git_oid_cmp(&id, git_reference_target(ref)));
git_reference_free(ref);
}
@@ -91,19 +91,19 @@ void test_refs_overwrite__object_id_with_symbolic(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
git_reference_free(ref);
- cl_git_pass(git_reference_create_oid(&ref, g_repo, ref_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 0));
git_reference_free(ref);
- cl_git_fail(git_reference_create_symbolic(&ref, g_repo, ref_name, ref_master_name, 0));
- cl_git_pass(git_reference_create_symbolic(&ref, g_repo, ref_name, ref_master_name, 1));
+ cl_git_fail(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0));
+ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 1));
git_reference_free(ref);
/* Ensure it points to the right place */
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
cl_assert(git_reference_type(ref) & GIT_REF_SYMBOLIC);
- cl_assert_equal_s(git_reference_target(ref), ref_master_name);
+ cl_assert_equal_s(git_reference_symbolic_target(ref), ref_master_name);
git_reference_free(ref);
}
@@ -116,21 +116,21 @@ void test_refs_overwrite__symbolic_with_object_id(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
git_reference_free(ref);
/* Create the symbolic ref */
- cl_git_pass(git_reference_create_symbolic(&ref, g_repo, ref_name, ref_master_name, 0));
+ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0));
git_reference_free(ref);
/* It shouldn't overwrite unless we tell it to */
- cl_git_fail(git_reference_create_oid(&ref, g_repo, ref_name, &id, 0));
- cl_git_pass(git_reference_create_oid(&ref, g_repo, ref_name, &id, 1));
+ cl_git_fail(git_reference_create(&ref, g_repo, ref_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 1));
git_reference_free(ref);
/* Ensure it points to the right place */
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- cl_assert(!git_oid_cmp(git_reference_oid(ref), &id));
+ cl_assert(!git_oid_cmp(git_reference_target(ref), &id));
git_reference_free(ref);
}
diff --git a/tests-clar/refs/read.c b/tests-clar/refs/read.c
index b867c97..c10a540 100644
--- a/tests-clar/refs/read.c
+++ b/tests-clar/refs/read.c
@@ -37,7 +37,7 @@ void test_refs_read__loose_tag(void)
cl_assert(git_reference_is_packed(reference) == 0);
cl_assert_equal_s(reference->name, loose_tag_ref_name);
- cl_git_pass(git_object_lookup(&object, g_repo, git_reference_oid(reference), GIT_OBJ_ANY));
+ cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(reference), GIT_OBJ_ANY));
cl_assert(object != NULL);
cl_assert(git_object_type(object) == GIT_OBJ_TAG);
@@ -77,7 +77,7 @@ void test_refs_read__symbolic(void)
cl_git_pass(git_reference_resolve(&resolved_ref, reference));
cl_assert(git_reference_type(resolved_ref) == GIT_REF_OID);
- cl_git_pass(git_object_lookup(&object, g_repo, git_reference_oid(resolved_ref), GIT_OBJ_ANY));
+ cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(resolved_ref), GIT_OBJ_ANY));
cl_assert(object != NULL);
cl_assert(git_object_type(object) == GIT_OBJ_COMMIT);
@@ -105,7 +105,7 @@ void test_refs_read__nested_symbolic(void)
cl_git_pass(git_reference_resolve(&resolved_ref, reference));
cl_assert(git_reference_type(resolved_ref) == GIT_REF_OID);
- cl_git_pass(git_object_lookup(&object, g_repo, git_reference_oid(resolved_ref), GIT_OBJ_ANY));
+ cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(resolved_ref), GIT_OBJ_ANY));
cl_assert(object != NULL);
cl_assert(git_object_type(object) == GIT_OBJ_COMMIT);
@@ -129,13 +129,13 @@ void test_refs_read__head_then_master(void)
cl_git_pass(git_reference_lookup(&reference, g_repo, GIT_HEAD_FILE));
cl_git_pass(git_reference_resolve(&resolved_ref, reference));
- cl_git_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref)));
+ cl_git_pass(git_oid_cmp(git_reference_target(comp_base_ref), git_reference_target(resolved_ref)));
git_reference_free(reference);
git_reference_free(resolved_ref);
cl_git_pass(git_reference_lookup(&reference, g_repo, current_head_target));
cl_git_pass(git_reference_resolve(&resolved_ref, reference));
- cl_git_pass(git_oid_cmp(git_reference_oid(comp_base_ref), git_reference_oid(resolved_ref)));
+ cl_git_pass(git_oid_cmp(git_reference_target(comp_base_ref), git_reference_target(resolved_ref)));
git_reference_free(reference);
git_reference_free(resolved_ref);
@@ -151,7 +151,7 @@ void test_refs_read__master_then_head(void)
cl_git_pass(git_reference_lookup(&reference, g_repo, GIT_HEAD_FILE));
cl_git_pass(git_reference_resolve(&resolved_ref, reference));
- cl_git_pass(git_oid_cmp(git_reference_oid(master_ref), git_reference_oid(resolved_ref)));
+ cl_git_pass(git_oid_cmp(git_reference_target(master_ref), git_reference_target(resolved_ref)));
git_reference_free(reference);
git_reference_free(resolved_ref);
@@ -170,7 +170,7 @@ void test_refs_read__packed(void)
cl_assert(git_reference_is_packed(reference));
cl_assert_equal_s(reference->name, packed_head_name);
- cl_git_pass(git_object_lookup(&object, g_repo, git_reference_oid(reference), GIT_OBJ_ANY));
+ cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(reference), GIT_OBJ_ANY));
cl_assert(object != NULL);
cl_assert(git_object_type(object) == GIT_OBJ_COMMIT);
@@ -200,7 +200,7 @@ void test_refs_read__chomped(void)
cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test"));
cl_git_pass(git_reference_lookup(&chomped, g_repo, "refs/heads/chomped"));
- cl_git_pass(git_oid_cmp(git_reference_oid(test), git_reference_oid(chomped)));
+ cl_git_pass(git_oid_cmp(git_reference_target(test), git_reference_target(chomped)));
git_reference_free(test);
git_reference_free(chomped);
@@ -212,7 +212,7 @@ void test_refs_read__trailing(void)
cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test"));
cl_git_pass(git_reference_lookup(&trailing, g_repo, "refs/heads/trailing"));
- cl_git_pass(git_oid_cmp(git_reference_oid(test), git_reference_oid(trailing)));
+ cl_git_pass(git_oid_cmp(git_reference_target(test), git_reference_target(trailing)));
git_reference_free(trailing);
cl_git_pass(git_reference_lookup(&trailing, g_repo, "FETCH_HEAD"));
diff --git a/tests-clar/refs/reflog/drop.c b/tests-clar/refs/reflog/drop.c
index d805d1e..21cc847 100644
--- a/tests-clar/refs/reflog/drop.c
+++ b/tests-clar/refs/reflog/drop.c
@@ -4,15 +4,15 @@
static git_repository *g_repo;
static git_reflog *g_reflog;
-static unsigned int entrycount;
+static size_t entrycount;
void test_refs_reflog_drop__initialize(void)
{
git_reference *ref;
-
+
g_repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
-
+
git_reflog_read(&g_reflog, ref);
entrycount = git_reflog_entrycount(g_reflog);
@@ -31,7 +31,7 @@ void test_refs_reflog_drop__dropping_a_non_exisiting_entry_from_the_log_returns_
{
cl_assert_equal_i(GIT_ENOTFOUND, git_reflog_drop(g_reflog, entrycount, 0));
- cl_assert_equal_i(entrycount, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount, git_reflog_entrycount(g_reflog));
}
void test_refs_reflog_drop__can_drop_an_entry(void)
@@ -39,7 +39,7 @@ void test_refs_reflog_drop__can_drop_an_entry(void)
cl_assert(entrycount > 4);
cl_git_pass(git_reflog_drop(g_reflog, 2, 0));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
}
void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
@@ -57,7 +57,7 @@ void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
cl_git_pass(git_reflog_drop(g_reflog, 1, 1));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
after_current = git_reflog_entry_byindex(g_reflog, 0);
@@ -72,7 +72,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void)
cl_assert(entrycount > 2);
cl_git_pass(git_reflog_drop(g_reflog, entrycount - 1, 0));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) != 0);
@@ -85,7 +85,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_histor
cl_assert(entrycount > 2);
cl_git_pass(git_reflog_drop(g_reflog, entrycount - 1, 1));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
@@ -101,7 +101,7 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void)
cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
- cl_assert_equal_i(0, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_i(0, (int)git_reflog_entrycount(g_reflog));
}
void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
@@ -112,7 +112,7 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, g_reflog->ref_name));
cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
cl_git_pass(git_reflog_write(g_reflog));
git_reflog_free(g_reflog);
@@ -120,5 +120,5 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
git_reflog_read(&g_reflog, ref);
git_reference_free(ref);
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
}
diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c
index 09b9356..8743c8a 100644
--- a/tests-clar/refs/reflog/reflog.c
+++ b/tests-clar/refs/reflog/reflog.c
@@ -46,7 +46,7 @@ void test_refs_reflog_reflog__append_then_read(void)
/* Create a new branch pointing at the HEAD */
git_oid_fromstr(&oid, current_master_tip);
- cl_git_pass(git_reference_create_oid(&ref, g_repo, new_ref, &oid, 0));
+ cl_git_pass(git_reference_create(&ref, g_repo, new_ref, &oid, 0));
cl_git_pass(git_signature_now(&committer, "foo", "foo@bar"));
@@ -66,7 +66,7 @@ void test_refs_reflog_reflog__append_then_read(void)
/* Read and parse the reflog for this branch */
cl_git_pass(git_reflog_read(&reflog, lookedup_ref));
- cl_assert_equal_i(2, git_reflog_entrycount(reflog));
+ cl_assert_equal_i(2, (int)git_reflog_entrycount(reflog));
entry = git_reflog_entry_byindex(reflog, 1);
assert_signature(committer, entry->committer);
@@ -143,7 +143,7 @@ void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_re
cl_git_pass(git_reflog_read(&reflog, subtrees));
- cl_assert_equal_i(0, git_reflog_entrycount(reflog));
+ cl_assert_equal_i(0, (int)git_reflog_entrycount(reflog));
git_reflog_free(reflog);
git_reference_free(subtrees);
@@ -160,7 +160,7 @@ void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void)
cl_git_pass(git_reflog_read(&reflog, master));
cl_git_pass(git_reflog_write(reflog));
-
+
cl_git_pass(git_reference_rename(master, "refs/moved", 0));
cl_git_fail(git_reflog_write(reflog));
diff --git a/tests-clar/refs/rename.c b/tests-clar/refs/rename.c
index 19bf875..ec5c125 100644
--- a/tests-clar/refs/rename.c
+++ b/tests-clar/refs/rename.c
@@ -201,7 +201,7 @@ void test_refs_rename__force_loose_packed(void)
/* An existing reference... */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name));
- git_oid_cpy(&oid, git_reference_oid(looked_up_ref));
+ git_oid_cpy(&oid, git_reference_target(looked_up_ref));
/* Can be force-renamed to the name of another existing reference. */
cl_git_pass(git_reference_rename(looked_up_ref, packed_test_head_name, 1));
@@ -210,7 +210,7 @@ void test_refs_rename__force_loose_packed(void)
/* Check we actually renamed it */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name));
cl_assert_equal_s(looked_up_ref->name, packed_test_head_name);
- cl_assert(!git_oid_cmp(&oid, git_reference_oid(looked_up_ref)));
+ cl_assert(!git_oid_cmp(&oid, git_reference_target(looked_up_ref)));
git_reference_free(looked_up_ref);
/* And that the previous one doesn't exist any longer */
@@ -225,7 +225,7 @@ void test_refs_rename__force_loose(void)
/* An existing reference... */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, "refs/heads/br2"));
- git_oid_cpy(&oid, git_reference_oid(looked_up_ref));
+ git_oid_cpy(&oid, git_reference_target(looked_up_ref));
/* Can be force-renamed to the name of another existing reference. */
cl_git_pass(git_reference_rename(looked_up_ref, "refs/heads/test", 1));
@@ -234,7 +234,7 @@ void test_refs_rename__force_loose(void)
/* Check we actually renamed it */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, "refs/heads/test"));
cl_assert_equal_s(looked_up_ref->name, "refs/heads/test");
- cl_assert(!git_oid_cmp(&oid, git_reference_oid(looked_up_ref)));
+ cl_assert(!git_oid_cmp(&oid, git_reference_target(looked_up_ref)));
git_reference_free(looked_up_ref);
/* And that the previous one doesn't exist any longer */
@@ -253,17 +253,17 @@ void test_refs_rename__overwrite(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
/* Create loose references */
- cl_git_pass(git_reference_create_oid(&ref_one, g_repo, ref_one_name, &id, 0));
- cl_git_pass(git_reference_create_oid(&ref_two, g_repo, ref_two_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref_one, g_repo, ref_one_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref_two, g_repo, ref_two_name, &id, 0));
/* Pack everything */
cl_git_pass(git_reference_packall(g_repo));
/* Attempt to create illegal reference */
- cl_git_fail(git_reference_create_oid(&ref_one_new, g_repo, ref_one_name_new, &id, 0));
+ cl_git_fail(git_reference_create(&ref_one_new, g_repo, ref_one_name_new, &id, 0));
/* Illegal reference couldn't be created so this is supposed to fail */
cl_git_fail(git_reference_lookup(&ref_one_new, g_repo, ref_one_name_new));
@@ -284,10 +284,10 @@ void test_refs_rename__prefix(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
/* Create loose references */
- cl_git_pass(git_reference_create_oid(&ref_two, g_repo, ref_two_name, &id, 0));
+ cl_git_pass(git_reference_create(&ref_two, g_repo, ref_two_name, &id, 0));
/* An existing reference... */
cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name));
@@ -316,10 +316,10 @@ void test_refs_rename__move_up(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name));
cl_assert(git_reference_type(ref) & GIT_REF_OID);
- git_oid_cpy(&id, git_reference_oid(ref));
+ git_oid_cpy(&id, git_reference_target(ref));
/* Create loose references */
- cl_git_pass(git_reference_create_oid(&ref_two, g_repo, ref_two_name_new, &id, 0));
+ cl_git_pass(git_reference_create(&ref_two, g_repo, ref_two_name_new, &id, 0));
git_reference_free(ref_two);
/* An existing reference... */
diff --git a/tests-clar/refs/revparse.c b/tests-clar/refs/revparse.c
index a1f0dbf..3698b51 100644
--- a/tests-clar/refs/revparse.c
+++ b/tests-clar/refs/revparse.c
@@ -468,11 +468,11 @@ void test_refs_revparse__issue_994(void)
cl_git_pass(git_repository_head(&head, repo));
- cl_git_pass(git_reference_create_oid(
+ cl_git_pass(git_reference_create(
&with_at,
repo,
"refs/remotes/origin/bim_with_3d@11296",
- git_reference_oid(head),
+ git_reference_target(head),
0));
cl_git_pass(git_revparse_single(&target, repo, "origin/bim_with_3d@11296"));
diff --git a/tests-clar/refs/unicode.c b/tests-clar/refs/unicode.c
index fbe95b1..424ee64 100644
--- a/tests-clar/refs/unicode.c
+++ b/tests-clar/refs/unicode.c
@@ -27,14 +27,14 @@ void test_refs_unicode__create_and_lookup(void)
/* Create the reference */
cl_git_pass(git_reference_lookup(&ref0, repo, master));
- cl_git_pass(git_reference_create_oid(&ref1, repo, REFNAME, git_reference_oid(ref0), 0));
+ cl_git_pass(git_reference_create(&ref1, repo, REFNAME, git_reference_target(ref0), 0));
cl_assert(strcmp(REFNAME, git_reference_name(ref1)) == 0);
/* Lookup the reference in a different instance of the repository */
cl_git_pass(git_repository_open(&repo2, "testrepo.git"));
cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME));
- cl_assert(git_oid_cmp(git_reference_oid(ref1), git_reference_oid(ref2)) == 0);
+ cl_assert(git_oid_cmp(git_reference_target(ref1), git_reference_target(ref2)) == 0);
cl_assert(strcmp(REFNAME, git_reference_name(ref2)) == 0);
git_reference_free(ref0);
diff --git a/tests-clar/repo/head.c b/tests-clar/repo/head.c
index 1c1e905..a9f5cfc 100644
--- a/tests-clar/repo/head.c
+++ b/tests-clar/repo/head.c
@@ -26,7 +26,7 @@ void test_repo_head__head_detached(void)
cl_assert_equal_i(true, git_repository_head_detached(repo));
/* take the reop back to it's original state */
- cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1));
git_reference_free(ref);
cl_assert_equal_i(false, git_repository_head_detached(repo));
@@ -44,7 +44,7 @@ void test_repo_head__head_orphan(void)
/* take the repo back to it's original state */
- cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1));
cl_assert(git_repository_head_orphan(repo) == 0);
git_reference_free(ref);
@@ -94,7 +94,7 @@ static void assert_head_is_correctly_detached(void)
cl_git_pass(git_repository_head(&head, repo));
- cl_git_pass(git_object_lookup(&commit, repo, git_reference_oid(head), GIT_OBJ_COMMIT));
+ cl_git_pass(git_object_lookup(&commit, repo, git_reference_target(head), GIT_OBJ_COMMIT));
git_object_free(commit);
git_reference_free(head);
@@ -156,7 +156,7 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void
{
git_reference *head;
- cl_git_pass(git_reference_create_symbolic(&head, repo, GIT_HEAD_FILE, "refs/tags/point_to_blob", 1));
+ cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/tags/point_to_blob", 1));
cl_git_fail(git_repository_detach_head(repo));
diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c
index f29f540..3b14c97 100644
--- a/tests-clar/repo/init.c
+++ b/tests-clar/repo/init.c
@@ -353,7 +353,7 @@ void test_repo_init__extended_1(void)
cl_git_pass(git_reference_lookup(&ref, _repo, "HEAD"));
cl_assert(git_reference_type(ref) == GIT_REF_SYMBOLIC);
- cl_assert_equal_s("refs/heads/development", git_reference_target(ref));
+ cl_assert_equal_s("refs/heads/development", git_reference_symbolic_target(ref));
git_reference_free(ref);
cl_git_pass(git_remote_load(&remote, _repo, "origin"));
diff --git a/tests-clar/repo/repo_helpers.c b/tests-clar/repo/repo_helpers.c
index 19ab38e..74902e4 100644
--- a/tests-clar/repo/repo_helpers.c
+++ b/tests-clar/repo/repo_helpers.c
@@ -7,7 +7,7 @@ void make_head_orphaned(git_repository* repo, const char *target)
{
git_reference *head;
- cl_git_pass(git_reference_create_symbolic(&head, repo, GIT_HEAD_FILE, target, 1));
+ cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, target, 1));
git_reference_free(head);
}
diff --git a/tests-clar/reset/soft.c b/tests-clar/reset/soft.c
index 7914d46..9ebd637 100644
--- a/tests-clar/reset/soft.c
+++ b/tests-clar/reset/soft.c
@@ -24,7 +24,7 @@ static void assert_reset_soft(bool should_be_detached)
{
git_oid oid;
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
+ cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_fail(git_oid_streq(&oid, KNOWN_COMMIT_IN_BARE_REPO));
retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
@@ -35,7 +35,7 @@ static void assert_reset_soft(bool should_be_detached)
cl_assert(git_repository_head_detached(repo) == should_be_detached);
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
+ cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_pass(git_oid_streq(&oid, KNOWN_COMMIT_IN_BARE_REPO));
}
@@ -56,7 +56,7 @@ void test_reset_soft__resetting_to_the_commit_pointed_at_by_the_Head_does_not_ch
git_oid oid;
char raw_head_oid[GIT_OID_HEXSZ + 1];
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
+ cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
git_oid_fmt(raw_head_oid, &oid);
raw_head_oid[GIT_OID_HEXSZ] = '\0';
@@ -64,7 +64,7 @@ void test_reset_soft__resetting_to_the_commit_pointed_at_by_the_Head_does_not_ch
cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
+ cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_pass(git_oid_streq(&oid, raw_head_oid));
}
@@ -78,7 +78,7 @@ void test_reset_soft__resetting_to_a_tag_sets_the_Head_to_the_peeled_commit(void
cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
cl_assert(git_repository_head_detached(repo) == false);
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
+ cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_pass(git_oid_streq(&oid, KNOWN_COMMIT_IN_BARE_REPO));
}
@@ -110,7 +110,7 @@ void test_reset_soft__resetting_against_an_orphaned_head_repo_makes_the_head_no_
cl_assert_equal_i(false, git_repository_head_orphan(repo));
cl_git_pass(git_reference_lookup(&head, repo, NON_EXISTING_HEAD));
- cl_assert_equal_i(0, git_oid_streq(git_reference_oid(head), KNOWN_COMMIT_IN_BARE_REPO));
+ cl_assert_equal_i(0, git_oid_streq(git_reference_target(head), KNOWN_COMMIT_IN_BARE_REPO));
git_reference_free(head);
}
diff --git a/tests-clar/revwalk/signatureparsing.c b/tests-clar/revwalk/signatureparsing.c
index cf1d31e..4f29dd1 100644
--- a/tests-clar/revwalk/signatureparsing.c
+++ b/tests-clar/revwalk/signatureparsing.c
@@ -31,10 +31,10 @@ void test_revwalk_signatureparsing__do_not_choke_when_name_contains_angle_bracke
*/
cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/haacked"));
- git_revwalk_push(_walk, git_reference_oid(ref));
+ git_revwalk_push(_walk, git_reference_target(ref));
cl_git_pass(git_revwalk_next(&commit_oid, _walk));
- cl_git_pass(git_commit_lookup(&commit, _repo, git_reference_oid(ref)));
+ cl_git_pass(git_commit_lookup(&commit, _repo, git_reference_target(ref)));
signature = git_commit_committer(commit);
cl_assert_equal_s("Yu V. Bin Haacked", signature->email);
diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c
index 9d1aeda..c146e90 100644
--- a/tests-clar/stash/drop.c
+++ b/tests-clar/stash/drop.c
@@ -91,13 +91,13 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
push_three_states();
cl_git_pass(git_reference_lookup(&stash, repo, "refs/stash"));
-
+
cl_git_pass(git_reflog_read(&reflog, stash));
entry = git_reflog_entry_byindex(reflog, 1);
- git_oid_cpy(&oid, git_reflog_entry_oidold(entry));
+ git_oid_cpy(&oid, git_reflog_entry_id_old(entry));
count = git_reflog_entrycount(reflog);
-
+
git_reflog_free(reflog);
cl_git_pass(git_stash_drop(repo, 1));
@@ -105,8 +105,8 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
cl_git_pass(git_reflog_read(&reflog, stash));
entry = git_reflog_entry_byindex(reflog, 0);
- cl_assert_equal_i(0, git_oid_cmp(&oid, git_reflog_entry_oidold(entry)));
- cl_assert_equal_i(count - 1, git_reflog_entrycount(reflog));
+ cl_assert_equal_i(0, git_oid_cmp(&oid, git_reflog_entry_id_old(entry)));
+ cl_assert_equal_sz(count - 1, git_reflog_entrycount(reflog));
git_reflog_free(reflog);
diff --git a/tests-clar/stash/save.c b/tests-clar/stash/save.c
index 4eaf2a3..f8b4278 100644
--- a/tests-clar/stash/save.c
+++ b/tests-clar/stash/save.c
@@ -193,7 +193,7 @@ void test_stash_save__cannot_stash_against_an_unborn_branch(void)
git_reference *head;
cl_git_pass(git_reference_lookup(&head, repo, "HEAD"));
- cl_git_pass(git_reference_set_target(head, "refs/heads/unborn"));
+ cl_git_pass(git_reference_symbolic_set_target(head, "refs/heads/unborn"));
cl_assert_equal_i(GIT_EORPHANEDHEAD,
git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT));
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index c154179..838a043 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -464,7 +464,7 @@ void test_status_worktree__status_file_without_index_or_workdir(void)
cl_git_pass(git_repository_set_workdir(repo, "wd", false));
cl_git_pass(git_index_open(&index, "empty-index"));
- cl_assert_equal_i(0, git_index_entrycount(index));
+ cl_assert_equal_i(0, (int)git_index_entrycount(index));
git_repository_set_index(repo, index);
cl_git_pass(git_status_file(&status, repo, "branch_file.txt"));
@@ -482,7 +482,7 @@ static void fill_index_wth_head_entries(git_repository *repo, git_index *index)
git_commit *commit;
git_tree *tree;
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
+ cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
cl_git_pass(git_commit_tree(&tree, commit));
diff --git a/tests-clar/submodule/lookup.c b/tests-clar/submodule/lookup.c
index 94eb19b..868b51e 100644
--- a/tests-clar/submodule/lookup.c
+++ b/tests-clar/submodule/lookup.c
@@ -62,9 +62,9 @@ void test_submodule_lookup__accessors(void)
cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0);
cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0);
- cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
- cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0);
- cl_assert(git_oid_streq(git_submodule_wd_oid(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE);
cl_assert(git_submodule_update(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT);
@@ -72,24 +72,24 @@ void test_submodule_lookup__accessors(void)
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head"));
cl_assert_equal_s("sm_changed_head", git_submodule_name(sm));
- cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
- cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0);
- cl_assert(git_oid_streq(git_submodule_wd_oid(sm),
+ cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm),
"3d9386c507f6b093471a3e324085657a3c2b4247") == 0);
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited"));
cl_assert_equal_s("sm_added_and_uncommited", git_submodule_name(sm));
- cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
- cl_assert(git_submodule_head_oid(sm) == NULL);
- cl_assert(git_oid_streq(git_submodule_wd_oid(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+ cl_assert(git_submodule_head_id(sm) == NULL);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits"));
cl_assert_equal_s("sm_missing_commits", git_submodule_name(sm));
- cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
- cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0);
- cl_assert(git_oid_streq(git_submodule_wd_oid(sm),
+ cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm),
"5e4963595a9774b90524d35a807169049de8ccad") == 0);
}
diff --git a/tests-clar/submodule/modify.c b/tests-clar/submodule/modify.c
index bfb8c8a..f6d41fd 100644
--- a/tests-clar/submodule/modify.c
+++ b/tests-clar/submodule/modify.c
@@ -76,7 +76,7 @@ void test_submodule_modify__add(void)
static int delete_one_config(const git_config_entry *entry, void *payload)
{
git_config *cfg = payload;
- return git_config_delete(cfg, entry->name);
+ return git_config_delete_entry(cfg, entry->name);
}
static int init_one_submodule(