Merge pull request #710 from libgit2/breaking-changes Break everything before the release
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
diff --git a/examples/general.c b/examples/general.c
index 46f2009..4585a4a 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -335,7 +335,7 @@ int main (int argc, char** argv)
// We can then lookup and parse the commited pointed at by the returned OID;
// note that this operation is specially fast since the raw contents of the commit object will
// be cached in memory
- while ((git_revwalk_next(&oid, walk)) == GIT_SUCCESS) {
+ while ((git_revwalk_next(&oid, walk)) == 0) {
error = git_commit_lookup(&wcommit, repo, &oid);
cmsg = git_commit_message(wcommit);
cauth = git_commit_author(wcommit);
diff --git a/examples/network/git2.c b/examples/network/git2.c
index d6ea419..7c02305 100644
--- a/examples/network/git2.c
+++ b/examples/network/git2.c
@@ -25,12 +25,12 @@ int run_command(git_cb fn, int argc, char **argv)
// repository and pass it to the function.
error = git_repository_open(&repo, ".git");
- if (error < GIT_SUCCESS)
+ if (error < 0)
repo = NULL;
// Run the command. If something goes wrong, print the error message to stderr
error = fn(repo, argc, argv);
- if (error < GIT_SUCCESS) {
+ if (error < 0) {
if (giterr_last() == NULL)
fprintf(stderr, "Error without message");
else
diff --git a/examples/network/index-pack.c b/examples/network/index-pack.c
index 881c149..03f3ae3 100644
--- a/examples/network/index-pack.c
+++ b/examples/network/index-pack.c
@@ -80,13 +80,13 @@ int index_pack_old(git_repository *repo, int argc, char **argv)
// Create a new indexer
error = git_indexer_new(&indexer, argv[1]);
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error;
// Index the packfile. This function can take a very long time and
// should be run in a worker thread.
error = git_indexer_run(indexer, &stats);
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error;
// Write the information out to an index file
@@ -98,5 +98,5 @@ int index_pack_old(git_repository *repo, int argc, char **argv)
git_indexer_free(indexer);
- return GIT_SUCCESS;
+ return 0;
}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 958a886..39cc647 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -9,7 +9,7 @@ static int show_ref__cb(git_remote_head *head, void *payload)
char oid[GIT_OID_HEXSZ + 1] = {0};
git_oid_fmt(oid, &head->oid);
printf("%s\t%s\n", oid, head->name);
- return GIT_SUCCESS;
+ return 0;
}
int use_unnamed(git_repository *repo, const char *url)
@@ -20,13 +20,13 @@ int use_unnamed(git_repository *repo, const char *url)
// Create an instance of a remote from the URL. The transport to use
// is detected from the URL
error = git_remote_new(&remote, repo, NULL, url, NULL);
- if (error < GIT_SUCCESS)
+ if (error < 0)
goto cleanup;
// When connecting, the underlying code needs to know wether we
// want to push or fetch
error = git_remote_connect(remote, GIT_DIR_FETCH);
- if (error < GIT_SUCCESS)
+ if (error < 0)
goto cleanup;
// With git_remote_ls we can retrieve the advertised heads
@@ -44,11 +44,11 @@ int use_remote(git_repository *repo, char *name)
// Find the remote by name
error = git_remote_load(&remote, repo, name);
- if (error < GIT_SUCCESS)
+ if (error < 0)
goto cleanup;
error = git_remote_connect(remote, GIT_DIR_FETCH);
- if (error < GIT_SUCCESS)
+ if (error < 0)
goto cleanup;
error = git_remote_ls(remote, &show_ref__cb, NULL);
diff --git a/include/git2/attr.h b/include/git2/attr.h
index 6a05496..28ca3bc 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -65,7 +65,7 @@ GIT_BEGIN_DECL
#define GIT_ATTR_UNSPECIFIED(attr) (!(attr) || (attr) == git_attr__unset)
/**
- * GIT_ATTR_SET_TO_VALUE checks if an attribute is set to a value (as
+ * GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as
* opposied to TRUE, FALSE or UNSPECIFIED). This would be the case if
* for a file with something like:
*
@@ -74,7 +74,7 @@ GIT_BEGIN_DECL
* Given this, looking up "eol" for `onefile.txt` will give back the
* string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true.
*/
-#define GIT_ATTR_SET_TO_VALUE(attr) \
+#define GIT_ATTR_HAS_VALUE(attr) \
((attr) && (attr) != git_attr__unset && \
(attr) != git_attr__true && (attr) != git_attr__false)
@@ -111,6 +111,10 @@ GIT_EXTERN(const char *) git_attr__unset;
/**
* Look up the value of one git attribute for path.
*
+ * @param value_out Output of the value of the attribute. Use the GIT_ATTR_...
+ * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just
+ * use the string value for attributes set to a value. You
+ * should NOT modify or free this value.
* @param repo The repository containing the path.
* @param flags A combination of GIT_ATTR_CHECK... flags.
* @param path The path to check for attributes. Relative paths are
@@ -118,17 +122,13 @@ GIT_EXTERN(const char *) git_attr__unset;
* not have to exist, but if it does not, then it will be
* treated as a plain file (not a directory).
* @param name The name of the attribute to look up.
- * @param value Output of the value of the attribute. Use the GIT_ATTR_...
- * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just
- * use the string value for attributes set to a value. You
- * should NOT modify or free this value.
*/
GIT_EXTERN(int) git_attr_get(
+ const char **value_out,
git_repository *repo,
uint32_t flags,
const char *path,
- const char *name,
- const char **value);
+ const char *name);
/**
* Look up a list of git attributes for path.
@@ -141,11 +141,16 @@ GIT_EXTERN(int) git_attr_get(
*
* const char *attrs[] = { "crlf", "diff", "foo" };
* const char **values[3];
- * git_attr_get_many(repo, 0, "my/fun/file.c", 3, attrs, values);
+ * git_attr_get_many(values, repo, 0, "my/fun/file.c", 3, attrs);
*
* Then you could loop through the 3 values to get the settings for
* the three attributes you asked about.
*
+ * @param values An array of num_attr entries that will have string
+ * pointers written into it for the values of the attributes.
+ * You should not modify or free the values that are written
+ * into this array (although of course, you should free the
+ * array itself if you allocated it).
* @param repo The repository containing the path.
* @param flags A combination of GIT_ATTR_CHECK... flags.
* @param path The path inside the repo to check attributes. This
@@ -153,19 +158,14 @@ GIT_EXTERN(int) git_attr_get(
* it will be treated as a plain file (i.e. not a directory).
* @param num_attr The number of attributes being looked up
* @param names An array of num_attr strings containing attribute names.
- * @param values An array of num_attr entries that will have string
- * pointers written into it for the values of the attributes.
- * You should not modify or free the values that are written
- * into this array (although of course, you should free the
- * array itself if you allocated it).
*/
GIT_EXTERN(int) git_attr_get_many(
+ const char **values_out,
git_repository *repo,
uint32_t flags,
const char *path,
size_t num_attr,
- const char **names,
- const char **values);
+ const char **names);
/**
* Loop over all the git attributes for a path.
diff --git a/include/git2/blob.h b/include/git2/blob.h
index afa350b..5517706 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -27,7 +27,7 @@ GIT_BEGIN_DECL
* @param blob pointer to the looked up blob
* @param repo the repo to use when locating the blob.
* @param id identity of the blob to locate.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id)
{
@@ -44,7 +44,7 @@ GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git
* @param repo the repo to use when locating the blob.
* @param id identity of the blob to locate.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, unsigned int len)
{
@@ -99,7 +99,7 @@ GIT_EXTERN(size_t) git_blob_rawsize(git_blob *blob);
* this repository cannot be bare
* @param path file from which the blob will be created,
* relative to the repository's working dir
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path);
@@ -111,7 +111,7 @@ GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, con
* @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 GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, const char *path);
@@ -123,7 +123,7 @@ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, con
* @param repo repository where to blob will be written
* @param buffer data to be written into the blob
* @param len length of the data
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *buffer, size_t len);
diff --git a/include/git2/branch.h b/include/git2/branch.h
index f4681dc..e2432bc 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -41,7 +41,7 @@ GIT_BEGIN_DECL
*
* @param force Overwrite existing branch.
*
- * @return GIT_SUCCESS or an error code.
+ * @return 0 or an error code.
* A proper reference is written in the refs/heads namespace
* pointing to the provided target commit.
*/
@@ -63,13 +63,13 @@ GIT_EXTERN(int) git_branch_create(
* @param branch_type Type of the considered branch. This should
* be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
*
- * @return GIT_SUCCESS on success, GIT_ENOTFOUND if the branch
+ * @return 0 on success, GIT_ENOTFOUND if the branch
* doesn't exist or an error code.
*/
GIT_EXTERN(int) git_branch_delete(
git_repository *repo,
const char *branch_name,
- git_branch_type branch_type);
+ git_branch_t branch_type);
/**
* Fill a list with all the branches in the Repository
@@ -88,7 +88,7 @@ GIT_EXTERN(int) git_branch_delete(
* listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE
* or a combination of the two.
*
- * @return GIT_SUCCESS or an error code.
+ * @return 0 or an error code.
*/
GIT_EXTERN(int) git_branch_list(
git_strarray *branch_names,
@@ -108,7 +108,7 @@ GIT_EXTERN(int) git_branch_list(
*
* @param force Overwrite existing branch.
*
- * @return GIT_SUCCESS on success, GIT_ENOTFOUND if the branch
+ * @return 0 on success, GIT_ENOTFOUND if the branch
* doesn't exist or an error code.
*/
GIT_EXTERN(int) git_branch_move(
diff --git a/include/git2/commit.h b/include/git2/commit.h
index e519bc1..a6d9bb0 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* @param repo the repo to use when locating the commit.
* @param id identity of the commit to locate. If the object is
* an annotated tag it will be peeled back to the commit.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id)
{
@@ -46,7 +46,7 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
* @param id identity of the commit to locate. If the object is
* an annotated tag it will be peeled back to the commit.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *repo, const git_oid *id, unsigned len)
{
@@ -135,7 +135,7 @@ GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
*
* @param tree_out pointer where to store the tree object
* @param commit a previously loaded commit.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
@@ -163,7 +163,7 @@ GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
* @param parent 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 GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n);
@@ -221,7 +221,7 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
* array may be NULL if `parent_count` is 0 (root commit). All the
* given commits must be owned by the `repo`.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
* The created commit will be written to the Object Database and
* the given reference will be updated to point to it
*/
diff --git a/include/git2/config.h b/include/git2/config.h
index acc45b0..36946c4 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -62,10 +62,10 @@ typedef struct {
* global configuration file.
*
* @param global_config_path Buffer of GIT_PATH_MAX length to store the path
- * @return GIT_SUCCESS if a global configuration file has been
+ * @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);
+GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
/**
* Locate the path to the system configuration file
@@ -74,10 +74,10 @@ GIT_EXTERN(int) git_config_find_global(char *global_config_path);
* %PROGRAMFILES%\Git\etc\gitconfig.
* @param system_config_path Buffer of GIT_PATH_MAX length to store the path
- * @return GIT_SUCCESS if a system configuration file has been
+ * @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);
+GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
/**
* Open the global configuration file
@@ -86,7 +86,7 @@ GIT_EXTERN(int) git_config_find_system(char *system_config_path);
* and opens the located file, if it exists.
*
* @param out Pointer to store the config instance
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_open_global(git_config **out);
@@ -110,7 +110,7 @@ GIT_EXTERN(int) git_config_file__ondisk(struct git_config_file **out, const char
* can do anything with it.
*
* @param out pointer to the new configuration
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_new(git_config **out);
@@ -127,7 +127,7 @@ GIT_EXTERN(int) git_config_new(git_config **out);
* @param cfg the configuration to add the file to
* @param file the configuration file (backend) to add
* @param priority the priority the backend should have
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_add_file(git_config *cfg, git_config_file *file, int priority);
@@ -148,7 +148,7 @@ GIT_EXTERN(int) git_config_add_file(git_config *cfg, git_config_file *file, int
* @param cfg the configuration to add the file to
* @param path path to the configuration file (backend) to add
* @param priority the priority the backend should have
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_add_file_ondisk(git_config *cfg, const char *path, int priority);
@@ -163,7 +163,7 @@ GIT_EXTERN(int) git_config_add_file_ondisk(git_config *cfg, const char *path, in
*
* @param cfg The configuration instance to create
* @param path Path to the on-disk file to open
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_open_ondisk(git_config **cfg, const char *path);
@@ -177,22 +177,22 @@ GIT_EXTERN(void) git_config_free(git_config *cfg);
/**
* Get the value of an integer config variable.
*
+ * @param out pointer to the variable where the value should be stored
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_int32(git_config *cfg, const char *name, int32_t *out);
+GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *name);
/**
* Get the value of a long integer config variable.
*
+ * @param out pointer to the variable where the value should be stored
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_int64(git_config *cfg, const char *name, int64_t *out);
+GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *name);
/**
* Get the value of a boolean config variable.
@@ -200,12 +200,12 @@ GIT_EXTERN(int) git_config_get_int64(git_config *cfg, const char *name, int64_t
* This function uses the usual C convention of 0 being false and
* anything else true.
*
+ * @param out pointer to the variable where the value should be stored
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_bool(git_config *cfg, const char *name, int *out);
+GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name);
/**
* Get the value of a string config variable.
@@ -213,12 +213,12 @@ GIT_EXTERN(int) git_config_get_bool(git_config *cfg, const char *name, int *out)
* The string is owned by the variable and should not be freed by the
* user.
*
+ * @param out pointer to the variable's value
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable's value
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_string(git_config *cfg, const char *name, const char **out);
+GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const char *name);
/**
* Get each value of a multivar.
@@ -240,7 +240,7 @@ GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const
* @param cfg where to look for the variable
* @param name the variable's name
* @param value Integer value for the variable
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value);
@@ -250,7 +250,7 @@ GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t
* @param cfg where to look for the variable
* @param name the variable's name
* @param value Long integer value for the variable
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value);
@@ -260,7 +260,7 @@ GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t
* @param cfg where to look for the variable
* @param name the variable's name
* @param value the value to store
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value);
@@ -273,7 +273,7 @@ GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value
* @param cfg where to look for the variable
* @param name the variable's name
* @param value the string to store.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value);
@@ -307,7 +307,7 @@ GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
* @param cfg where to get the variables from
* @param callback the function to call on each variable
* @param payload the data to pass to the callback
- * @return GIT_SUCCESS or the return value of the callback which didn't return 0
+ * @return 0 or the return value of the callback which didn't return 0
*/
GIT_EXTERN(int) git_config_foreach(
git_config *cfg,
@@ -342,14 +342,14 @@ GIT_EXTERN(int) git_config_foreach(
* If not a single match can be made to store in `out`, an error code will be
* returned.
*
+ * @param out place to store the result of the mapping
* @param cfg config file to get the variables from
* @param name name of the config variable to lookup
* @param maps array of `git_cvar_map` objects specifying the possible mappings
* @param map_n number of mapping objects in `maps`
- * @param out place to store the result of the mapping
- * @return GIT_SUCCESS on success, error code otherwise
+ * @return 0 on success, error code otherwise
*/
-GIT_EXTERN(int) git_config_get_mapped(git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n, int *out);
+GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n);
/** @} */
GIT_END_DECL
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 8563438..fb66700 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -17,30 +17,55 @@
*/
GIT_BEGIN_DECL
-typedef enum {
+#ifdef GIT_OLD_ERRORS
+enum {
GIT_SUCCESS = 0,
- GIT_ERROR = -1,
-
- /** Input does not exist in the scope searched. */
+ GIT_ENOTOID = -2,
GIT_ENOTFOUND = -3,
-
- /** A reference with this name already exists */
+ GIT_ENOMEM = -4,
+ GIT_EOSERR = -5,
+ GIT_EOBJTYPE = -6,
+ GIT_ENOTAREPO = -7,
+ GIT_EINVALIDTYPE = -8,
+ GIT_EMISSINGOBJDATA = -9,
+ GIT_EPACKCORRUPTED = -10,
+ GIT_EFLOCKFAIL = -11,
+ GIT_EZLIB = -12,
+ GIT_EBUSY = -13,
+ GIT_EBAREINDEX = -14,
+ GIT_EINVALIDREFNAME = -15,
+ GIT_EREFCORRUPTED = -16,
+ GIT_ETOONESTEDSYMREF = -17,
+ GIT_EPACKEDREFSCORRUPTED = -18,
+ GIT_EINVALIDPATH = -19,
+ GIT_EREVWALKOVER = -20,
+ GIT_EINVALIDREFSTATE = -21,
+ GIT_ENOTIMPLEMENTED = -22,
GIT_EEXISTS = -23,
-
- /** The given integer literal is too large to be parsed */
GIT_EOVERFLOW = -24,
-
- /** The given short oid is ambiguous */
+ GIT_ENOTNUM = -25,
+ GIT_ESTREAM = -26,
+ GIT_EINVALIDARGS = -27,
+ GIT_EOBJCORRUPTED = -28,
GIT_EAMBIGUOUS = -29,
-
- /** Skip and passthrough the given ODB backend */
GIT_EPASSTHROUGH = -30,
-
- /** The buffer is too short to satisfy the request */
+ GIT_ENOMATCH = -31,
GIT_ESHORTBUFFER = -32,
+};
+#endif
- GIT_EREVWALKOVER = -33,
-} git_error_t;
+/** Generic return codes */
+enum {
+ GIT_OK = 0,
+ GIT_ERROR = -1,
+ GIT_ENOTFOUND = -3,
+ GIT_EEXISTS = -4,
+ GIT_EAMBIGUOUS = -5,
+ GIT_EBUFS = -6,
+
+ GIT_PASSTHROUGH = -30,
+ GIT_REVWALKOVER = -31,
+};
typedef struct {
char *message;
@@ -63,7 +88,7 @@ typedef enum {
GITERR_TAG,
GITERR_TREE,
GITERR_INDEXER,
-} git_error_class;
+} git_error_t;
/**
* Return the last `git_error` object that was generated for the
diff --git a/include/git2/index.h b/include/git2/index.h
index ae727c5..6a42c85 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -106,7 +106,7 @@ typedef struct git_index_entry_unmerged {
*
* @param index the pointer for the new index
* @param index_path the path to the index file in disk
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_open(git_index **index, const char *index_path);
@@ -131,7 +131,7 @@ GIT_EXTERN(void) git_index_free(git_index *index);
* by reading from the hard disk.
*
* @param index an existing index object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_read(git_index *index);
@@ -140,7 +140,7 @@ GIT_EXTERN(int) git_index_read(git_index *index);
* using an atomic file lock.
*
* @param index an existing index object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_write(git_index *index);
@@ -176,7 +176,7 @@ GIT_EXTERN(void) git_index_uniq(git_index *index);
* @param index an existing index object
* @param path filename to add
* @param stage stage for the entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_add(git_index *index, const char *path, int stage);
@@ -188,7 +188,7 @@ GIT_EXTERN(int) git_index_add(git_index *index, const char *path, int stage);
*
* @param index an existing index object
* @param source_entry new entry object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_add2(git_index *index, const git_index_entry *source_entry);
@@ -207,7 +207,7 @@ GIT_EXTERN(int) git_index_add2(git_index *index, const git_index_entry *source_e
* @param index an existing index object
* @param path filename to add
* @param stage stage for the entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_append(git_index *index, const char *path, int stage);
@@ -224,7 +224,7 @@ GIT_EXTERN(int) git_index_append(git_index *index, const char *path, int stage);
*
* @param index an existing index object
* @param source_entry new entry object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_append2(git_index *index, const git_index_entry *source_entry);
@@ -233,7 +233,7 @@ GIT_EXTERN(int) git_index_append2(git_index *index, const git_index_entry *sourc
*
* @param index an existing index object
* @param position position of the entry to remove
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_remove(git_index *index, int position);
@@ -312,7 +312,7 @@ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
*
* @param index an existing index object
* @param tree tree to read
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
diff --git a/include/git2/notes.h b/include/git2/notes.h
index ece5b27..19073ab 100644
--- a/include/git2/notes.h
+++ b/include/git2/notes.h
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* @param notes_ref OID reference to use (optional); defaults to "refs/notes/commits"
* @param oid OID of the object
*
- * @return GIT_SUCCESS or an error code
+ * @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);
@@ -62,7 +62,7 @@ GIT_EXTERN(const git_oid *) git_note_oid(git_note *note);
* @param oid The OID of the object
* @param oid The note to add for object oid
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
git_signature *author, git_signature *committer,
@@ -79,7 +79,7 @@ GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
* @param committer signature of the notes commit committer
* @param oid the oid which note's to be removed
*
- * @return GIT_SUCCESS or an error code
+ * @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,
@@ -98,7 +98,7 @@ GIT_EXTERN(void) git_note_free(git_note *note);
* @param out Pointer to the default notes reference
* @param repo The Git repository
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_note_default_ref(const char **out, git_repository *repo);
@@ -125,7 +125,7 @@ typedef struct {
*
* @param payload Extra parameter to callback function.
*
- * @return GIT_SUCCESS or an error code.
+ * @return 0 or an error code.
*/
GIT_EXTERN(int) git_note_foreach(
git_repository *repo,
diff --git a/include/git2/object.h b/include/git2/object.h
index 859d0c4..9e988b7 100644
--- a/include/git2/object.h
+++ b/include/git2/object.h
@@ -69,7 +69,7 @@ GIT_EXTERN(int) git_object_lookup(
* @param id a short identifier for the object
* @param len the length of the short identifier
* @param type the type of the object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_object_lookup_prefix(
git_object **object_out,
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 87d70a6..1df1933 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -29,7 +29,7 @@ GIT_BEGIN_DECL
*
* @param out location to store the database pointer, if opened.
* Set to NULL if the open failed.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_new(git_odb **out);
@@ -47,7 +47,7 @@ GIT_EXTERN(int) git_odb_new(git_odb **out);
* @param out location to store the database pointer, if opened.
* Set to NULL if the open failed.
* @param objects_dir path of the backends' "objects" directory.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
@@ -108,7 +108,7 @@ GIT_EXTERN(void) git_odb_free(git_odb *db);
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
- * - GIT_SUCCESS if the object was read;
+ * - 0 if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
@@ -135,7 +135,7 @@ 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 GIT_SUCCESS if the object was read;
+ * @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)
*/
@@ -156,7 +156,7 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
- * - GIT_SUCCESS if the object was read;
+ * - 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);
@@ -188,7 +188,7 @@ GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
* @param data buffer with the data to storr
* @param len size of the buffer
* @param type type of the data to store
- * @return GIT_SUCCESS or an error code
+ * @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);
@@ -257,7 +257,7 @@ GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const
* @param data data to hash
* @param len size of the data
* @param type of the data to hash
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type);
@@ -270,7 +270,7 @@ GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otyp
* @param out oid structure the result is written into.
* @param path file to read and determine object id for
* @param type the type of the object that will be hashed
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index 9a0133f..f4620f5 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -74,6 +74,13 @@ struct git_odb_backend {
void (* free)(struct git_odb_backend *);
};
+/** Streaming mode */
+enum {
+ GIT_STREAM_RDONLY = (1 << 1),
+ GIT_STREAM_WRONLY = (1 << 2),
+ GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
+};
+
/** A stream to read/write from a backend */
struct git_odb_stream {
struct git_odb_backend *backend;
@@ -85,13 +92,6 @@ struct git_odb_stream {
void (*free)(struct git_odb_stream *stream);
};
-/** Streaming mode */
-typedef enum {
- GIT_STREAM_RDONLY = (1 << 1),
- GIT_STREAM_WRONLY = (1 << 2),
- GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
-} git_odb_streammode;
-
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);
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 87efbab..c06458d 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -43,7 +43,7 @@ struct _git_oid {
* @param str input 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).
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
@@ -56,7 +56,7 @@ GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
* @param out oid structure the result is written into.
* @param str input hex string of at least size `length`
* @param length length of the input string
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
@@ -155,7 +155,7 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, unsigned int le
* @param a oid structure.
* @param str input hex string of an object id.
* @return GIT_ENOTOID if str is not a valid hex string,
- * GIT_SUCCESS in case of a match, GIT_ERROR otherwise.
+ * 0 in case of a match, GIT_ERROR otherwise.
*/
GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str);
diff --git a/include/git2/reflog.h b/include/git2/reflog.h
index d622abc..f490e29 100644
--- a/include/git2/reflog.h
+++ b/include/git2/reflog.h
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
*
* @param reflog pointer to reflog
* @param ref reference to read the reflog for
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_read(git_reflog **reflog, git_reference *ref);
@@ -46,7 +46,7 @@ GIT_EXTERN(int) git_reflog_read(git_reflog **reflog, git_reference *ref);
* @param oid_old the OID the reference was pointing to
* @param committer the signature of the committer
* @param msg the reflog message
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_write(git_reference *ref, const git_oid *oid_old, const git_signature *committer, const char *msg);
@@ -55,7 +55,7 @@ GIT_EXTERN(int) git_reflog_write(git_reference *ref, const git_oid *oid_old, con
*
* @param ref the reference
* @param new_name the new name of the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *new_name);
@@ -63,7 +63,7 @@ GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *new_name);
* Delete the reflog for the given reference
*
* @param ref the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_delete(git_reference *ref);
diff --git a/include/git2/refs.h b/include/git2/refs.h
index 2073aab..882e327 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* @param reference_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, ref/heads/master, refs/tags/v0.1.0, ...)
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_repository *repo, const char *name);
@@ -59,7 +59,7 @@ GIT_EXTERN(int) git_reference_name_to_oid(
* @param name The name of the reference
* @param target The target of the reference
* @param force Overwrite existing references
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force);
@@ -79,7 +79,7 @@ GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repos
* @param name The name of the reference
* @param id The object id pointed to by the reference.
* @param force Overwrite existing references
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force);
@@ -111,7 +111,7 @@ GIT_EXTERN(const char *) git_reference_target(git_reference *ref);
* @param ref The reference
* @return the type
*/
-GIT_EXTERN(git_rtype) git_reference_type(git_reference *ref);
+GIT_EXTERN(git_ref_t) git_reference_type(git_reference *ref);
/**
* Get the full name of a reference
@@ -137,7 +137,7 @@ GIT_EXTERN(const char *) git_reference_name(git_reference *ref);
*
* @param resolved_ref Pointer to the peeled reference
* @param ref The reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_resolve(git_reference **resolved_ref, git_reference *ref);
@@ -160,7 +160,7 @@ GIT_EXTERN(git_repository *) git_reference_owner(git_reference *ref);
*
* @param ref The reference
* @param target The new target for the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const char *target);
@@ -175,7 +175,7 @@ GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const char *target)
*
* @param ref The reference
* @param id The new target OID for the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
@@ -202,7 +202,7 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
* @param ref The reference to rename
* @param new_name The new name for the reference
* @param force Overwrite an existing reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*
*/
GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name, int force);
@@ -216,7 +216,7 @@ GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name, i
* memory. The given reference pointer will no longer be valid.
*
* @param ref The reference to remove
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_delete(git_reference *ref);
@@ -231,7 +231,7 @@ GIT_EXTERN(int) git_reference_delete(git_reference *ref);
* the loose references will be removed from disk.
*
* @param repo Repository where the loose refs will be packed
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_packall(git_repository *repo);
@@ -254,9 +254,9 @@ GIT_EXTERN(int) git_reference_packall(git_repository *repo);
* @param repo Repository where to find the refs
* @param list_flags Filtering flags for the reference
* listing.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_reference_listall(git_strarray *array, git_repository *repo, unsigned int list_flags);
+GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo, unsigned int list_flags);
/**
@@ -276,7 +276,7 @@ GIT_EXTERN(int) git_reference_listall(git_strarray *array, git_repository *repo,
* listing.
* @param callback Function which will be called for every listed ref
* @param payload Additional data to pass to the callback
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_foreach(git_repository *repo, unsigned int list_flags, int (*callback)(const char *, void *), void *payload);
@@ -304,7 +304,7 @@ GIT_EXTERN(int) git_reference_is_packed(git_reference *ref);
* returned and the reference pointer will be invalidated.
*
* @param ref The reference to reload
- * @return GIT_SUCCESS on success, or an error code
+ * @return 0 on success, or an error code
*/
GIT_EXTERN(int) git_reference_reload(git_reference *ref);
@@ -320,7 +320,7 @@ GIT_EXTERN(void) git_reference_free(git_reference *ref);
*
* @param ref1 The first git_reference
* @param ref2 The second git_reference
- * @return GIT_SUCCESS if the same, else a stable but meaningless ordering.
+ * @return 0 if the same, else a stable but meaningless ordering.
*/
GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2);
diff --git a/include/git2/refspec.h b/include/git2/refspec.h
index 50aa596..c0a8eab 100644
--- a/include/git2/refspec.h
+++ b/include/git2/refspec.h
@@ -51,7 +51,7 @@ GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *
* @param outlen the size ouf the `out` buffer
* @param spec the refspec
* @param name the name of the reference to transform
- * @return GIT_SUCCESS, GIT_ESHORTBUFFER or another error
+ * @return 0, GIT_EBUFS or another error
*/
GIT_EXTERN(int) git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name);
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 6550cd2..865dfef 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -41,7 +41,7 @@ GIT_BEGIN_DECL
* @param name the remote's name
* @param url the remote repository's URL
* @param fetch the fetch refspec to use for this remote
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
@@ -51,7 +51,7 @@ GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const cha
* @param out pointer to the new remote object
* @param cfg the repository's configuration
* @param name the remote's name
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
@@ -59,7 +59,7 @@ GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const ch
* Save a remote to its repository's configuration
*
* @param remote the remote to save to config
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_save(const git_remote *remote);
@@ -84,7 +84,7 @@ GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
*
* @param remote the remote
* @apram spec the new fetch refspec
- * @return GIT_SUCCESS or an error value
+ * @return 0 or an error value
*/
GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
@@ -101,7 +101,7 @@ GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
*
* @param remote the remote
* @apram spec the new push refspec
- * @return GIT_SUCCESS or an error value
+ * @return 0 or an error value
*/
GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
@@ -123,7 +123,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
*
* @param remote the remote to connect to
* @param direction whether you want to receive or send data
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
@@ -135,7 +135,7 @@ GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
*
* @param refs where to store the refs
* @param remote the remote
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload);
@@ -150,7 +150,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
*
* @param remote the remote to download from
* @param filename where to store the temproray filename
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats);
@@ -215,7 +215,7 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
*
* @param remotes_list a string array with the names of the remotes
* @param repo the repository to query
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
diff --git a/include/git2/repository.h b/include/git2/repository.h
index d760c23..3949438 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -31,7 +31,7 @@ GIT_BEGIN_DECL
*
* @param repository pointer to the repo which will be opened
* @param path the path to the repository
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
@@ -61,7 +61,7 @@ GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *pat
* start_path no matter start_path appears in ceiling_dirs ceiling_dirs
* might be NULL (which is equivalent to an empty string)
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_discover(
char *repository_path,
@@ -109,7 +109,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
* at the pointed path. If false, provided path will be considered as the working
* directory into which the .git directory will be created.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_init(git_repository **repo_out, const char *path, unsigned is_bare);
@@ -194,7 +194,7 @@ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo);
*
* @param repo A repository object
* @param workdir The path to a working directory
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_set_workdir(git_repository *repo, const char *workdir);
@@ -218,7 +218,7 @@ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
*
* @param out Pointer to store the loaded config file
* @param repo A repository object
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
@@ -249,7 +249,7 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con
*
* @param out Pointer to store the loaded ODB
* @param repo A repository object
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
@@ -280,7 +280,7 @@ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
*
* @param out Pointer to store the loaded index
* @param repo A repository object
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h
index 632c675..aac6fb7 100644
--- a/include/git2/revwalk.h
+++ b/include/git2/revwalk.h
@@ -65,7 +65,7 @@ GIT_BEGIN_DECL
*
* @param walker pointer to the new revision walker
* @param repo the repo to walk through
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_new(git_revwalk **walker, git_repository *repo);
@@ -97,7 +97,7 @@ GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
*
* @param walk the walker being used for the traversal.
* @param oid the oid of the commit to start from.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *oid);
@@ -112,7 +112,7 @@ GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *oid);
*
* @param walk the walker being used for the traversal
* @param glob the glob pattern references should match
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_push_glob(git_revwalk *walk, const char *glob);
@@ -120,7 +120,7 @@ GIT_EXTERN(int) git_revwalk_push_glob(git_revwalk *walk, const char *glob);
* Push the repository's HEAD
*
* @param walk the walker being used for the traversal
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk);
@@ -135,7 +135,7 @@ GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk);
*
* @param walk the walker being used for the traversal.
* @param oid the oid of commit that will be ignored during the traversal
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *oid);
@@ -151,7 +151,7 @@ GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *oid);
*
* @param walk the walker being used for the traversal
* @param glob the glob pattern references should match
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_hide_glob(git_revwalk *walk, const char *glob);
@@ -159,7 +159,7 @@ GIT_EXTERN(int) git_revwalk_hide_glob(git_revwalk *walk, const char *glob);
* Hide the repository's HEAD
*
* @param walk the walker being used for the traversal
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_hide_head(git_revwalk *walk);
@@ -170,7 +170,7 @@ GIT_EXTERN(int) git_revwalk_hide_head(git_revwalk *walk);
*
* @param walk the walker being used for the traversal
* @param refname the referece to push
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_push_ref(git_revwalk *walk, const char *refname);
@@ -181,7 +181,7 @@ GIT_EXTERN(int) git_revwalk_push_ref(git_revwalk *walk, const char *refname);
*
* @param walk the walker being used for the traversal
* @param refname the referece to hide
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_hide_ref(git_revwalk *walk, const char *refname);
@@ -200,8 +200,8 @@ GIT_EXTERN(int) git_revwalk_hide_ref(git_revwalk *walk, const char *refname);
*
* @param oid Pointer where to store the oid of the next commit
* @param walk the walker to pop the commit from.
- * @return GIT_SUCCESS if the next commit was found;
- * GIT_EREVWALKOVER if there are no commits left to iterate
+ * @return 0 if the next commit was found;
+ * GIT_REVWALKOVER if there are no commits left to iterate
*/
GIT_EXTERN(int) git_revwalk_next(git_oid *oid, git_revwalk *walk);
diff --git a/include/git2/signature.h b/include/git2/signature.h
index e26a6c8..cbf9426 100644
--- a/include/git2/signature.h
+++ b/include/git2/signature.h
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* @param email email of the person
* @param time time when the action happened
* @param offset timezone offset in minutes for the time
- * @return GIT_SUCCESS or an error code
+ * @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);
@@ -39,7 +39,7 @@ GIT_EXTERN(int) git_signature_new(git_signature **sig_out, const char *name, con
* @param sig_out new signature, in case of error NULL
* @param name name of the person
* @param email email of the person
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_signature_now(git_signature **sig_out, const char *name, const char *email);
diff --git a/include/git2/status.h b/include/git2/status.h
index 0130b40..6a424df 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -19,19 +19,19 @@
*/
GIT_BEGIN_DECL
-#define GIT_STATUS_CURRENT 0
+enum {
+ GIT_STATUS_CURRENT = 0,
-/** Flags for index status */
-#define GIT_STATUS_INDEX_NEW (1 << 0)
-#define GIT_STATUS_INDEX_MODIFIED (1 << 1)
-#define GIT_STATUS_INDEX_DELETED (1 << 2)
+ GIT_STATUS_INDEX_NEW = (1 << 0),
+ GIT_STATUS_INDEX_MODIFIED = (1 << 1),
+ GIT_STATUS_INDEX_DELETED = (1 << 2),
-/** Flags for worktree status */
-#define GIT_STATUS_WT_NEW (1 << 3)
-#define GIT_STATUS_WT_MODIFIED (1 << 4)
-#define GIT_STATUS_WT_DELETED (1 << 5)
+ GIT_STATUS_WT_NEW = (1 << 3),
+ GIT_STATUS_WT_MODIFIED = (1 << 4),
+ GIT_STATUS_WT_DELETED = (1 << 5),
-#define GIT_STATUS_IGNORED (1 << 6)
+ GIT_STATUS_IGNORED = (1 << 6),
+};
/**
* Gather file statuses and run a callback for each one.
@@ -97,11 +97,14 @@ typedef enum {
* slash on the entry name). Given this flag, the directory
* itself will not be included, but all the files in it will.
*/
-#define GIT_STATUS_OPT_INCLUDE_UNTRACKED (1 << 0)
-#define GIT_STATUS_OPT_INCLUDE_IGNORED (1 << 1)
-#define GIT_STATUS_OPT_INCLUDE_UNMODIFIED (1 << 2)
-#define GIT_STATUS_OPT_EXCLUDE_SUBMODULES (1 << 3)
-#define GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS (1 << 4)
+
+enum {
+ GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1 << 0),
+ GIT_STATUS_OPT_INCLUDE_IGNORED = (1 << 1),
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1 << 2),
+ GIT_STATUS_OPT_EXCLUDE_SUBMODULED = (1 << 3),
+ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1 << 4),
+};
/**
* Options to control how callbacks will be made by
@@ -130,7 +133,7 @@ GIT_EXTERN(int) git_status_foreach_ext(
* @param path the file to retrieve status for, rooted at the repo's workdir
* @return GIT_EINVALIDPATH when `path` points at a folder, GIT_ENOTFOUND when
* the file doesn't exist in any of HEAD, the index or the worktree,
- * GIT_SUCCESS otherwise
+ * 0 otherwise
*/
GIT_EXTERN(int) git_status_file(
unsigned int *status_flags,
diff --git a/include/git2/tag.h b/include/git2/tag.h
index 8224edf..859c289 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -27,7 +27,7 @@ GIT_BEGIN_DECL
* @param tag 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 GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oid *id)
{
@@ -44,7 +44,7 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi
* @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 GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const git_oid *id, unsigned int len)
{
@@ -85,7 +85,7 @@ GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
*
* @param target pointer where to store the target
* @param tag a previously loaded tag.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_target(git_object **target, git_tag *tag);
@@ -161,7 +161,7 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
*
* @param force Overwrite existing references
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
* A tag object is written to the ODB, and a proper reference
* is written in the /refs/tags folder, pointing to it
*/
@@ -212,7 +212,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
*
* @param force Overwrite existing references
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
* A proper reference is written in the /refs/tags folder,
* pointing to the provided target object
*/
@@ -231,7 +231,7 @@ GIT_EXTERN(int) git_tag_create_lightweight(
* @param tag_name Name of the tag to be deleted;
* this name is validated for consistency.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_delete(
git_repository *repo,
@@ -248,7 +248,7 @@ GIT_EXTERN(int) git_tag_delete(
* @param tag_names Pointer to a git_strarray structure where
* the tag names will be stored
* @param repo Repository where to find the tags
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_list(
git_strarray *tag_names,
@@ -270,7 +270,7 @@ GIT_EXTERN(int) git_tag_list(
* the tag names will be stored
* @param pattern Standard fnmatch pattern
* @param repo Repository where to find the tags
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_list_match(
git_strarray *tag_names,
@@ -286,7 +286,7 @@ GIT_EXTERN(int) git_tag_list_match(
*
* @param tag_target Pointer to the peeled git_object
* @param tag The tag to be processed
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_peel(
git_object **tag_target,
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 0d9db43..777f8ff 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -27,7 +27,7 @@ GIT_BEGIN_DECL
* @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.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git_oid *id)
{
@@ -44,7 +44,7 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git
* @param repo the repo to use when locating the tree.
* @param id identity of the tree to locate.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, const git_oid *id, unsigned int len)
{
@@ -141,7 +141,7 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
* @param object pointer to the converted object
* @param repo repository where to lookup the pointed object
* @param entry a tree entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tree_entry_to_object(git_object **object_out, git_repository *repo, const git_tree_entry *entry);
@@ -159,7 +159,7 @@ GIT_EXTERN(int) git_tree_entry_to_object(git_object **object_out, git_repository
*
* @param oid Pointer where to store the written tree
* @param index Index to write
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tree_create_fromindex(git_oid *oid, git_index *index);
@@ -229,7 +229,7 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
* @param filename Filename of the entry
* @param id SHA1 oid of the entry
* @param attributes Folder attributes of the entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_treebuilder_insert(git_tree_entry **entry_out, git_treebuilder *bld, const char *filename, const git_oid *id, unsigned int attributes);
@@ -264,7 +264,7 @@ GIT_EXTERN(void) git_treebuilder_filter(git_treebuilder *bld, int (*filter)(cons
* @param oid Pointer where to store the written OID
* @param repo Repository where to store the object
* @param bld Tree builder to write
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld);
@@ -278,8 +278,7 @@ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_tr
* @param subtree Pointer where to store the subtree
* @param root A previously loaded tree which will be the root of the relative path
* @param subtree_path Path to the contained subtree
- * @return GIT_SUCCESS on success; GIT_ENOTFOUND if the path does not lead to a
- * subtree, GIT_EINVALIDPATH or an error code
+ * @return 0 on success; GIT_ENOTFOUND if the path does not lead to a subtree
*/
GIT_EXTERN(int) git_tree_get_subtree(git_tree **subtree, git_tree *root, const char *subtree_path);
@@ -309,7 +308,7 @@ enum git_treewalk_mode {
* @param callback Function to call on each tree entry
* @param mode Traversal mode (pre or post-order)
* @param payload Opaque pointer to be passed on each callback
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);
diff --git a/include/git2/types.h b/include/git2/types.h
index 98eea53..cfb0acf 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -158,13 +158,13 @@ typedef enum {
GIT_REF_PACKED = 4,
GIT_REF_HAS_PEEL = 8,
GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC|GIT_REF_PACKED,
-} git_rtype;
+} git_ref_t;
/** Basic type of any Git branch. */
typedef enum {
GIT_BRANCH_LOCAL = 1,
GIT_BRANCH_REMOTE = 2,
-} git_branch_type;
+} git_branch_t;
typedef struct git_refspec git_refspec;
typedef struct git_remote git_remote;
diff --git a/src/attr.c b/src/attr.c
index 1aa965d..093f64d 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -13,11 +13,11 @@ static int collect_attr_files(
int git_attr_get(
+ const char **value,
git_repository *repo,
uint32_t flags,
const char *pathname,
- const char *name,
- const char **value)
+ const char *name)
{
int error;
git_attr_path path;
@@ -64,12 +64,12 @@ typedef struct {
} attr_get_many_info;
int git_attr_get_many(
+ const char **values,
git_repository *repo,
uint32_t flags,
const char *pathname,
size_t num_attr,
- const char **names,
- const char **values)
+ const char **names)
{
int error;
git_attr_path path;
@@ -576,11 +576,11 @@ int git_attr_cache__init(git_repository *repo)
if (git_repository_config__weakptr(&cfg, repo) < 0)
return -1;
- ret = git_config_get_string(cfg, GIT_ATTR_CONFIG, &cache->cfg_attr_file);
+ ret = git_config_get_string(&cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG);
if (ret < 0 && ret != GIT_ENOTFOUND)
return ret;
- ret = git_config_get_string(cfg, GIT_IGNORE_CONFIG, &cache->cfg_excl_file);
+ ret = git_config_get_string(&cache->cfg_excl_file, cfg, GIT_IGNORE_CONFIG);
if (ret < 0 && ret != GIT_ENOTFOUND)
return ret;
diff --git a/src/branch.c b/src/branch.c
index 881e749..5d5a240 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -105,7 +105,7 @@ cleanup:
return error;
}
-int git_branch_delete(git_repository *repo, const char *branch_name, git_branch_type branch_type)
+int git_branch_delete(git_repository *repo, const char *branch_name, git_branch_t branch_type)
{
git_reference *branch = NULL;
git_reference *head = NULL;
diff --git a/src/config.c b/src/config.c
index 0ab0cd4..618202c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -199,30 +199,6 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
return file->set(file, name, value);
}
-int git_config_parse_bool(int *out, const char *value)
-{
- /* A missing value means true */
- if (value == NULL) {
- *out = 1;
- return 0;
- }
-
- if (!strcasecmp(value, "true") ||
- !strcasecmp(value, "yes") ||
- !strcasecmp(value, "on")) {
- *out = 1;
- return 0;
- }
- if (!strcasecmp(value, "false") ||
- !strcasecmp(value, "no") ||
- !strcasecmp(value, "off")) {
- *out = 0;
- return 0;
- }
-
- return -1;
-}
-
static int parse_int64(int64_t *out, const char *value)
{
const char *num_end;
@@ -297,7 +273,7 @@ int git_config_lookup_map_value(
case GIT_CVAR_TRUE: {
int bool_val;
- if (git_config_parse_bool(&bool_val, value) == 0 &&
+ if (git__parse_bool(&bool_val, value) == 0 &&
bool_val == (int)m->cvar_type) {
*out = m->map_value;
return 0;
@@ -322,12 +298,17 @@ int git_config_lookup_map_value(
return GIT_ENOTFOUND;
}
-int git_config_get_mapped(git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n, int *out)
+int git_config_get_mapped(
+ int *out,
+ git_config *cfg,
+ const char *name,
+ git_cvar_map *maps,
+ size_t map_n)
{
const char *value;
int ret;
- ret = git_config_get_string(cfg, name, &value);
+ ret = git_config_get_string(&value, cfg, name);
if (ret < 0)
return ret;
@@ -339,12 +320,12 @@ int git_config_get_mapped(git_config *cfg, const char *name, git_cvar_map *maps,
return -1;
}
-int git_config_get_int64(git_config *cfg, const char *name, int64_t *out)
+int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
{
const char *value;
int ret;
- ret = git_config_get_string(cfg, name, &value);
+ ret = git_config_get_string(&value, cfg, name);
if (ret < 0)
return ret;
@@ -356,12 +337,12 @@ int git_config_get_int64(git_config *cfg, const char *name, int64_t *out)
return 0;
}
-int git_config_get_int32(git_config *cfg, const char *name, int32_t *out)
+int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
{
const char *value;
int ret;
- ret = git_config_get_string(cfg, name, &value);
+ ret = git_config_get_string(&value, cfg, name);
if (ret < 0)
return ret;
@@ -373,16 +354,16 @@ int git_config_get_int32(git_config *cfg, const char *name, int32_t *out)
return 0;
}
-int git_config_get_bool(git_config *cfg, const char *name, int *out)
+int git_config_get_bool(int *out, git_config *cfg, const char *name)
{
const char *value;
int ret;
- ret = git_config_get_string(cfg, name, &value);
+ ret = git_config_get_string(&value, cfg, name);
if (ret < 0)
return ret;
- if (git_config_parse_bool(out, value) == 0)
+ if (git__parse_bool(out, value) == 0)
return 0;
if (parse_int32(out, value) == 0) {
@@ -394,7 +375,7 @@ int git_config_get_bool(git_config *cfg, const char *name, int *out)
return -1;
}
-int git_config_get_string(git_config *cfg, const char *name, const char **out)
+int git_config_get_string(const char **out, git_config *cfg, const char *name)
{
file_internal *internal;
unsigned int i;
@@ -462,7 +443,7 @@ int git_config_find_global_r(git_buf *path)
return git_futils_find_global_file(path, GIT_CONFIG_FILENAME);
}
-int git_config_find_global(char *global_config_path)
+int git_config_find_global(char *global_config_path, size_t length)
{
git_buf path = GIT_BUF_INIT;
int ret = git_config_find_global_r(&path);
@@ -472,14 +453,14 @@ int git_config_find_global(char *global_config_path)
return ret;
}
- if (path.size > GIT_PATH_MAX) {
+ if (path.size >= length) {
git_buf_free(&path);
giterr_set(GITERR_NOMEMORY,
"Path is to long to fit on the given buffer");
return -1;
}
- git_buf_copy_cstr(global_config_path, GIT_PATH_MAX, &path);
+ git_buf_copy_cstr(global_config_path, length, &path);
git_buf_free(&path);
return 0;
}
@@ -489,7 +470,7 @@ int git_config_find_system_r(git_buf *path)
return git_futils_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM);
}
-int git_config_find_system(char *system_config_path)
+int git_config_find_system(char *system_config_path, size_t length)
{
git_buf path = GIT_BUF_INIT;
int ret = git_config_find_system_r(&path);
@@ -499,14 +480,14 @@ int git_config_find_system(char *system_config_path)
return ret;
}
- if (path.size > GIT_PATH_MAX) {
+ if (path.size >= length) {
git_buf_free(&path);
giterr_set(GITERR_NOMEMORY,
"Path is to long to fit on the given buffer");
return -1;
}
- git_buf_copy_cstr(system_config_path, GIT_PATH_MAX, &path);
+ git_buf_copy_cstr(system_config_path, length, &path);
git_buf_free(&path);
return 0;
}
@@ -514,11 +495,14 @@ int git_config_find_system(char *system_config_path)
int git_config_open_global(git_config **out)
{
int error;
- char global_path[GIT_PATH_MAX];
+ git_buf path = GIT_BUF_INIT;
- if ((error = git_config_find_global(global_path)) < 0)
+ if ((error = git_config_find_global_r(&path)) < 0)
return error;
- return git_config_open_ondisk(out, global_path);
+ error = git_config_open_ondisk(out, git_buf_cstr(&path));
+ git_buf_free(&path);
+
+ return error;
}
diff --git a/src/config_cache.c b/src/config_cache.c
index 3679a96..ca9602e 100644
--- a/src/config_cache.c
+++ b/src/config_cache.c
@@ -66,22 +66,22 @@ int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar)
int error;
error = git_repository_config__weakptr(&config, repo);
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error;
- error = git_config_get_mapped(
- config, data->cvar_name, data->maps, data->map_count, out);
+ error = git_config_get_mapped(out,
+ config, data->cvar_name, data->maps, data->map_count);
if (error == GIT_ENOTFOUND)
*out = data->default_value;
- else if (error < GIT_SUCCESS)
+ else if (error < 0)
return error;
repo->cvar_cache[(int)cvar] = *out;
}
- return GIT_SUCCESS;
+ return 0;
}
void git_repository__cvar_cache_clear(git_repository *repo)
diff --git a/src/crlf.c b/src/crlf.c
index 5d09a1f..303a46d 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -82,8 +82,8 @@ static int crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, con
const char *attr_vals[NUM_CONV_ATTRS];
int error;
- error = git_attr_get_many(
- repo, 0, path, NUM_CONV_ATTRS, attr_names, attr_vals);
+ error = git_attr_get_many(attr_vals,
+ repo, 0, path, NUM_CONV_ATTRS, attr_names);
if (error == GIT_ENOTFOUND) {
ca->crlf_action = GIT_CRLF_GUESS;
@@ -91,7 +91,7 @@ static int crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, con
return 0;
}
- if (error == GIT_SUCCESS) {
+ if (error == 0) {
ca->crlf_action = check_crlf(attr_vals[2]); /* text */
if (ca->crlf_action == GIT_CRLF_GUESS)
ca->crlf_action = check_crlf(attr_vals[0]); /* clrf */
@@ -100,7 +100,7 @@ static int crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, con
return 0;
}
- return error;
+ return -1;
}
static int drop_crlf(git_buf *dest, const git_buf *source)
@@ -207,7 +207,7 @@ int git_filter_add__crlf_to_odb(git_vector *filters, git_repository *repo, const
int auto_crlf;
if ((error = git_repository__cvar(
- &auto_crlf, repo, GIT_CVAR_AUTO_CRLF)) < GIT_SUCCESS)
+ &auto_crlf, repo, GIT_CVAR_AUTO_CRLF)) < 0)
return error;
if (auto_crlf == GIT_AUTO_CRLF_FALSE)
diff --git a/src/delta-apply.c b/src/delta-apply.c
index d3be084..815ca8f 100644
--- a/src/delta-apply.c
+++ b/src/delta-apply.c
@@ -111,7 +111,7 @@ int git__delta_apply(
if (delta != delta_end || res_sz)
goto fail;
- return GIT_SUCCESS;
+ return 0;
fail:
git__free(out->data);
diff --git a/src/delta-apply.h b/src/delta-apply.h
index e46ef9a..66fa76d 100644
--- a/src/delta-apply.h
+++ b/src/delta-apply.h
@@ -20,7 +20,7 @@
* @param delta the delta to execute copy/insert instructions from.
* @param delta_len total number of bytes in the delta.
* @return
- * - GIT_SUCCESS on a successful delta unpack.
+ * - 0 on a successful delta unpack.
* - GIT_ERROR if the delta is corrupt or doesn't match the base.
*/
extern int git__delta_apply(
diff --git a/src/diff.c b/src/diff.c
index d5c0c8b..0b2f8fb 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -270,8 +270,10 @@ static int diff_delta__cmp(const void *a, const void *b)
static int config_bool(git_config *cfg, const char *name, int defvalue)
{
int val = defvalue;
- if (git_config_get_bool(cfg, name, &val) < 0)
+
+ if (git_config_get_bool(&val, cfg, name) < 0)
giterr_clear();
+
return val;
}
diff --git a/src/diff_output.c b/src/diff_output.c
index 4ad736e..ba7ef82 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -103,7 +103,7 @@ static int diff_output_cb(void *priv, mmbuffer_t *bufs, int len)
static int update_file_is_binary_by_attr(git_repository *repo, git_diff_file *file)
{
const char *value;
- if (git_attr_get(repo, 0, file->path, "diff", &value) < 0)
+ if (git_attr_get(&value, repo, 0, file->path, "diff") < 0)
return -1;
if (GIT_ATTR_FALSE(value))
diff --git a/src/fetch.c b/src/fetch.c
index 08c789d..c92cf4e 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -165,7 +165,7 @@ int git_fetch_setup_walk(git_revwalk **out, git_repository *repo)
unsigned int i;
git_reference *ref;
- if (git_reference_listall(&refs, repo, GIT_REF_LISTALL) < 0)
+ if (git_reference_list(&refs, repo, GIT_REF_LISTALL) < 0)
return -1;
if (git_revwalk_new(&walk, repo) < 0)
diff --git a/src/filter.c b/src/filter.c
index 73fe83e..8fa3eb6 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -129,7 +129,7 @@ int git_filters_apply(git_buf *dest, git_buf *source, git_vector *filters)
if (git_buf_len(source) == 0) {
git_buf_clear(dest);
- return GIT_SUCCESS;
+ return 0;
}
/* Pre-grow the destination buffer to more or less the size
@@ -160,6 +160,6 @@ int git_filters_apply(git_buf *dest, git_buf *source, git_vector *filters)
if (src != 1)
git_buf_swap(dest, source);
- return GIT_SUCCESS;
+ return 0;
}
diff --git a/src/filter.h b/src/filter.h
index 5a77f25..66e370a 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -75,7 +75,7 @@ extern int git_filters_load(git_vector *filters, git_repository *repo, const cha
* @param dest Buffer to store the result of the filtering
* @param source Buffer containing the document to filter
* @param filters A non-empty vector of filters as supplied by `git_filters_load`
- * @return GIT_SUCCESS on success, an error code otherwise
+ * @return 0 on success, an error code otherwise
*/
extern int git_filters_apply(git_buf *dest, git_buf *source, git_vector *filters);
diff --git a/src/indexer.c b/src/indexer.c
index 01bec08..6f735e6 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -205,9 +205,9 @@ static int store_delta(git_indexer_stream *idx)
}
error = packfile_unpack_compressed(&obj, idx->pack, &w, &idx->off, entry_size, type);
- if (error == GIT_ESHORTBUFFER) {
+ if (error == GIT_EBUFS) {
idx->off = entry_start;
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
} else if (error < 0){
return -1;
}
@@ -355,7 +355,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
return 0;
error = git_packfile_unpack(&obj, idx->pack, &idx->off);
- if (error == GIT_ESHORTBUFFER) {
+ if (error == GIT_EBUFS) {
idx->off = entry_start;
return 0;
}
@@ -363,7 +363,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
if (error < 0) {
idx->off = entry_start;
error = store_delta(idx);
- if (error == GIT_ESHORTBUFFER)
+ if (error == GIT_EBUFS)
return 0;
if (error < 0)
return error;
diff --git a/src/notes.c b/src/notes.c
index a86a75b..84ad940 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -274,7 +274,7 @@ static int note_get_default_ref(const char **out, git_repository *repo)
if (git_repository_config__weakptr(&cfg, repo) < 0)
return -1;
- ret = git_config_get_string(cfg, "core.notesRef", out);
+ ret = git_config_get_string(out, cfg, "core.notesRef");
if (ret == GIT_ENOTFOUND) {
*out = GIT_NOTES_DEFAULT_REF;
return 0;
diff --git a/src/object.c b/src/object.c
index deeacb2..d3673ed 100644
--- a/src/object.c
+++ b/src/object.c
@@ -74,7 +74,7 @@ static int create_object(git_object **object_out, git_otype type)
object->type = type;
*object_out = object;
- return GIT_SUCCESS;
+ return 0;
}
int git_object_lookup_prefix(
@@ -87,7 +87,7 @@ int git_object_lookup_prefix(
git_object *object = NULL;
git_odb *odb = NULL;
git_odb_object *odb_obj;
- int error = GIT_SUCCESS;
+ int error = 0;
assert(repo && object_out && id);
@@ -95,7 +95,7 @@ int git_object_lookup_prefix(
return GIT_EAMBIGUOUS;
error = git_repository_odb__weakptr(&odb, repo);
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error;
if (len > GIT_OID_HEXSZ)
diff --git a/src/odb.c b/src/odb.c
index 03cd912..a6a18f8 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -505,7 +505,7 @@ int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git
error = b->read_header(len_p, type_p, b, id);
}
- if (!error || error == GIT_EPASSTHROUGH)
+ if (!error || error == GIT_PASSTHROUGH)
return 0;
/*
@@ -545,7 +545,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
* will never have called giterr_set().
*/
- if (error && error != GIT_EPASSTHROUGH)
+ if (error && error != GIT_PASSTHROUGH)
return error;
*out = git_cache_try_store(&db->cache, new_odb_object(id, &raw));
@@ -582,7 +582,7 @@ int git_odb_read_prefix(
if (b->read != NULL) {
git_oid full_oid;
error = b->read_prefix(&full_oid, &raw.data, &raw.len, &raw.type, b, short_id, len);
- if (error == GIT_ENOTFOUND || error == GIT_EPASSTHROUGH)
+ if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH)
continue;
if (error)
@@ -623,7 +623,7 @@ int git_odb_write(
error = b->write(oid, b, data, len, type);
}
- if (!error || error == GIT_EPASSTHROUGH)
+ if (!error || error == GIT_PASSTHROUGH)
return 0;
/* if no backends were able to write the object directly, we try a streaming
@@ -662,7 +662,7 @@ int git_odb_open_wstream(
error = init_fake_wstream(stream, b, size, type);
}
- if (error == GIT_EPASSTHROUGH)
+ if (error == GIT_PASSTHROUGH)
error = 0;
return error;
@@ -683,7 +683,7 @@ int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oi
error = b->readstream(stream, b, oid);
}
- if (error == GIT_EPASSTHROUGH)
+ if (error == GIT_PASSTHROUGH)
error = 0;
return error;
diff --git a/src/pack.c b/src/pack.c
index 4a6bc6a..0db1069 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -222,7 +222,7 @@ static int packfile_unpack_header1(
shift = 4;
while (c & 0x80) {
if (len <= used)
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
if (bitsizeof(long) <= shift) {
*usedp = 0;
@@ -260,11 +260,11 @@ int git_packfile_unpack_header(
// base = pack_window_open(p, w_curs, *curpos, &left);
base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left);
if (base == NULL)
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
git_mwindow_close(w_curs);
- if (ret == GIT_ESHORTBUFFER)
+ if (ret == GIT_EBUFS)
return ret;
else if (ret < 0)
return packfile_error("header length is zero");
@@ -428,7 +428,7 @@ int packfile_unpack_compressed(
if (st == Z_BUF_ERROR && in == NULL) {
inflateEnd(&stream);
git__free(buffer);
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
}
*curpos += stream.next_in - in;
@@ -467,7 +467,7 @@ git_off_t get_delta_base(
base_info = pack_window_open(p, w_curs, *curpos, &left);
/* Assumption: the only reason this would fail is because the file is too small */
if (base_info == NULL)
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
/* pack_window_open() assured us we have [base_info, base_info + 20)
* as a range that we can look at without walking off the
* end of the mapped window. Its actually the hash size
@@ -480,7 +480,7 @@ git_off_t get_delta_base(
base_offset = c & 127;
while (c & 128) {
if (left <= used)
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
base_offset += 1;
if (!base_offset || MSB(base_offset, 7))
return 0; /* overflow */
diff --git a/src/pkt.c b/src/pkt.c
index b9c87f1..95430dd 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -208,7 +208,7 @@ int git_pkt_parse_line(
/* Not even enough for the length */
if (bufflen > 0 && bufflen < PKT_LEN_SIZE)
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
len = parse_len(line);
if (len < 0) {
@@ -230,7 +230,7 @@ int git_pkt_parse_line(
* enough in the buffer to satisfy this line
*/
if (bufflen > 0 && bufflen < (size_t)len)
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
line += PKT_LEN_SIZE;
/*
diff --git a/src/protocol.c b/src/protocol.c
index a753541..6b38617 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -34,7 +34,7 @@ int git_protocol_store_refs(git_protocol *p, const char *data, size_t len)
return 0;
error = git_pkt_parse_line(&pkt, ptr, &line_end, git_buf_len(buf));
- if (error == GIT_ESHORTBUFFER)
+ if (error == GIT_EBUFS)
return 0; /* Ask for more */
if (error < 0)
return p->error = -1;
diff --git a/src/refs.c b/src/refs.c
index 28e8f78..1ef3e13 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -194,10 +194,10 @@ corrupt:
return -1;
}
-static git_rtype loose_guess_rtype(const git_buf *full_path)
+static git_ref_t loose_guess_rtype(const git_buf *full_path)
{
git_buf ref_file = GIT_BUF_INIT;
- git_rtype type;
+ git_ref_t type;
type = GIT_REF_INVALID;
@@ -1153,7 +1153,7 @@ int git_reference_lookup_resolved(
/**
* Getters
*/
-git_rtype git_reference_type(git_reference *ref)
+git_ref_t git_reference_type(git_reference *ref)
{
assert(ref);
@@ -1518,7 +1518,7 @@ static int cb__reflist_add(const char *ref, void *data)
return git_vector_insert((git_vector *)data, git__strdup(ref));
}
-int git_reference_listall(
+int git_reference_list(
git_strarray *array,
git_repository *repo,
unsigned int list_flags)
diff --git a/src/refspec.c b/src/refspec.c
index ee4d3a1..697b1bf 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -68,7 +68,7 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con
baselen = strlen(spec->dst);
if (outlen <= baselen) {
giterr_set(GITERR_INVALID, "Reference name too long");
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
}
/*
@@ -90,7 +90,7 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con
if (outlen <= baselen + namelen) {
giterr_set(GITERR_INVALID, "Reference name too long");
- return GIT_ESHORTBUFFER;
+ return GIT_EBUFS;
}
memcpy(out, spec->dst, baselen);
diff --git a/src/refspec.h b/src/refspec.h
index 64c0ded..2db5049 100644
--- a/src/refspec.h
+++ b/src/refspec.h
@@ -28,7 +28,7 @@ int git_refspec_parse(struct git_refspec *refspec, const char *str);
* @param out where to store the target name
* @param spec the refspec
* @param name the name of the reference to transform
- * @return GIT_SUCCESS or error if buffer allocation fails
+ * @return 0 or error if buffer allocation fails
*/
int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name);
diff --git a/src/remote.c b/src/remote.c
index a5cfc82..9740344 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -48,7 +48,7 @@ static int parse_remote_refspec(git_config *cfg, git_refspec *refspec, const cha
int error;
const char *val;
- if ((error = git_config_get_string(cfg, var, &val)) < 0)
+ if ((error = git_config_get_string(&val, cfg, var)) < 0)
return error;
return refspec_parse(refspec, val);
@@ -121,7 +121,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
goto cleanup;
}
- if ((error = git_config_get_string(config, git_buf_cstr(&buf), &val)) < 0)
+ if ((error = git_config_get_string(&val, config, git_buf_cstr(&buf))) < 0)
goto cleanup;
remote->repo = repo;
@@ -338,7 +338,7 @@ int git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, co
assert(remote);
if (refs->length == 0)
- return GIT_SUCCESS;
+ return 0;
/* HEAD is only allowed to be the first in the list */
head = refs->contents[0];
diff --git a/src/repository.c b/src/repository.c
index c5eed53..6ce3a56 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -25,8 +25,7 @@
#define GIT_BRANCH_MASTER "master"
-#define GIT_CONFIG_CORE_REPOSITORYFORMATVERSION "core.repositoryformatversion"
-#define GIT_REPOSITORYFORMATVERSION 0
+#define GIT_REPO_VERSION 0
static void drop_odb(git_repository *repo)
{
@@ -125,7 +124,7 @@ static int load_config_data(git_repository *repo)
if (git_repository_config__weakptr(&config, repo) < 0)
return -1;
- if (git_config_get_bool(config, "core.bare", &is_bare) < 0)
+ if (git_config_get_bool(&is_bare, config, "core.bare") < 0)
return -1; /* FIXME: We assume that a missing core.bare
variable is an error. Is this right? */
@@ -146,7 +145,7 @@ static int load_workdir(git_repository *repo, git_buf *parent_path)
if (git_repository_config__weakptr(&config, repo) < 0)
return -1;
- error = git_config_get_string(config, "core.worktree", &worktree);
+ error = git_config_get_string(&worktree, config, "core.worktree");
if (!error && worktree != NULL)
repo->workdir = git__strdup(worktree);
else if (error != GIT_ENOTFOUND)
@@ -607,13 +606,13 @@ static int check_repositoryformatversion(git_repository *repo)
if (git_repository_config__weakptr(&config, repo) < 0)
return -1;
- if (git_config_get_int32(config, GIT_CONFIG_CORE_REPOSITORYFORMATVERSION, &version) < 0)
+ if (git_config_get_int32(&version, config, "core.repositoryformatversion") < 0)
return -1;
- if (GIT_REPOSITORYFORMATVERSION < version) {
+ if (GIT_REPO_VERSION < version) {
giterr_set(GITERR_REPOSITORY,
"Unsupported repository version %d. Only versions up to %d are supported.",
- version, GIT_REPOSITORYFORMATVERSION);
+ version, GIT_REPO_VERSION);
return -1;
}
@@ -676,7 +675,7 @@ static int repo_init_config(const char *git_dir, int is_bare)
}
SET_REPO_CONFIG(bool, "core.bare", is_bare);
- SET_REPO_CONFIG(int32, GIT_CONFIG_CORE_REPOSITORYFORMATVERSION, GIT_REPOSITORYFORMATVERSION);
+ SET_REPO_CONFIG(int32, "core.repositoryformatversion", GIT_REPO_VERSION);
/* TODO: what other defaults? */
git_buf_free(&cfg_path);
diff --git a/src/revwalk.c b/src/revwalk.c
index d0a5120..e64d93f 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -316,7 +316,7 @@ static int merge_bases_many(commit_list **out, git_revwalk *walk, commit_object
if ((p->flags & flags) == flags)
continue;
- if ((error = commit_parse(walk, p)) < GIT_SUCCESS)
+ if ((error = commit_parse(walk, p)) < 0)
return error;
p->flags |= flags;
@@ -600,7 +600,7 @@ static int revwalk_next_timesort(commit_object **object_out, git_revwalk *walk)
}
}
- return GIT_EREVWALKOVER;
+ return GIT_REVWALKOVER;
}
static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
@@ -618,7 +618,7 @@ static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
}
}
- return GIT_EREVWALKOVER;
+ return GIT_REVWALKOVER;
}
static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
@@ -629,7 +629,7 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
for (;;) {
next = commit_list_pop(&walk->iterator_topo);
if (next == NULL)
- return GIT_EREVWALKOVER;
+ return GIT_REVWALKOVER;
if (next->in_degree > 0) {
next->topo_delay = 1;
@@ -654,7 +654,7 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
static int revwalk_next_reverse(commit_object **object_out, git_revwalk *walk)
{
*object_out = commit_list_pop(&walk->iterator_reverse);
- return *object_out ? 0 : GIT_EREVWALKOVER;
+ return *object_out ? 0 : GIT_REVWALKOVER;
}
@@ -670,7 +670,7 @@ static int prepare_walk(git_revwalk *walk)
* so we know that the walk is already over.
*/
if (walk->one == NULL)
- return GIT_EREVWALKOVER;
+ return GIT_REVWALKOVER;
/* first figure out what the merge bases are */
if (merge_bases_many(&bases, walk, walk->one, &walk->twos) < 0)
@@ -698,7 +698,7 @@ static int prepare_walk(git_revwalk *walk)
return -1;
}
- if (error != GIT_EREVWALKOVER)
+ if (error != GIT_REVWALKOVER)
return error;
walk->get_next = &revwalk_next_toposort;
@@ -710,7 +710,7 @@ static int prepare_walk(git_revwalk *walk)
if (commit_list_insert(next, &walk->iterator_reverse) == NULL)
return -1;
- if (error != GIT_EREVWALKOVER)
+ if (error != GIT_REVWALKOVER)
return error;
walk->get_next = &revwalk_next_reverse;
@@ -809,9 +809,9 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
error = walk->get_next(&next, walk);
- if (error == GIT_EREVWALKOVER) {
+ if (error == GIT_REVWALKOVER) {
git_revwalk_reset(walk);
- return GIT_EREVWALKOVER;
+ return GIT_REVWALKOVER;
}
if (!error)
diff --git a/src/signature.c b/src/signature.c
index 4d6d11c..7d329c4 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -167,7 +167,7 @@ static int parse_timezone_offset(const char *buffer, int *offset_out)
if (*offset_start == '\n') {
*offset_out = 0;
- return GIT_SUCCESS;
+ return 0;
}
if (offset_start[0] != '-' && offset_start[0] != '+')
@@ -176,7 +176,7 @@ static int parse_timezone_offset(const char *buffer, int *offset_out)
if (offset_start[1] < '0' || offset_start[1] > '9')
return timezone_error("expected initial digit");
- if (git__strtol32(&dec_offset, offset_start + 1, &offset_end, 10) < GIT_SUCCESS)
+ if (git__strtol32(&dec_offset, offset_start + 1, &offset_end, 10) < 0)
return timezone_error("not a valid number");
if (offset_end - offset_start != 5)
diff --git a/src/submodule.c b/src/submodule.c
index 1b5b59f..3c07e65 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -218,8 +218,11 @@ static int submodule_from_config(
sm->update = (git_submodule_update_t)val;
}
else if (strcmp(property, "fetchRecurseSubmodules") == 0) {
- if (git_config_parse_bool(&sm->fetch_recurse, value) < 0)
+ if (git__parse_bool(&sm->fetch_recurse, value) < 0) {
+ giterr_set(GITERR_INVALID,
+ "Invalid value for submodule 'fetchRecurseSubmodules' property: '%s'", value);
goto fail;
+ }
}
else if (strcmp(property, "ignore") == 0) {
int val;
diff --git a/src/tag.c b/src/tag.c
index 13481c2..63424f5 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -168,7 +168,7 @@ static int retrieve_tag_reference(
return -1;
error = git_reference_lookup(&tag_ref, repo, ref_name_out->ptr);
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error; /* Be it not foundo or corrupted */
*tag_reference_out = tag_ref;
@@ -254,7 +254,7 @@ static int git_tag_create__internal(
}
error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag_name);
- if (error < GIT_SUCCESS && error != GIT_ENOTFOUND)
+ if (error < 0 && error != GIT_ENOTFOUND)
return -1;
/** Ensure the tag name doesn't conflict with an already existing
@@ -332,7 +332,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
}
error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag.tag_name);
- if (error < GIT_SUCCESS && error != GIT_ENOTFOUND)
+ if (error < 0 && error != GIT_ENOTFOUND)
goto on_error;
/* We don't need these objects after this */
@@ -414,7 +414,7 @@ static int tag_list_cb(const char *tag_name, void *payload)
return 0;
filter = (tag_filter_data *)payload;
- if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == GIT_SUCCESS)
+ if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == 0)
return git_vector_insert(filter->taglist, git__strdup(tag_name));
return 0;
@@ -428,7 +428,7 @@ int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_reposit
assert(tag_names && repo && pattern);
- if (git_vector_init(&taglist, 8, NULL) < GIT_SUCCESS)
+ if (git_vector_init(&taglist, 8, NULL) < 0)
return -1;
filter.taglist = &taglist;
diff --git a/src/transport.c b/src/transport.c
index bc4248d..5b2cd7e 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -37,7 +37,7 @@ static git_transport_cb transport_find_fn(const char *url)
}
/* still here? Check to see if the path points to a file on the local file system */
- if ((git_path_exists(url) == GIT_SUCCESS) && git_path_isdir(url))
+ if ((git_path_exists(url) == 0) && git_path_isdir(url))
return &git_transport_local;
/* It could be a SSH remote path. Check to see if there's a : */
@@ -72,7 +72,7 @@ int git_transport_new(git_transport **out, const char *url)
}
error = fn(&transport);
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error;
transport->url = git__strdup(url);
@@ -80,7 +80,7 @@ int git_transport_new(git_transport **out, const char *url)
*out = transport;
- return GIT_SUCCESS;
+ return 0;
}
/* from remote.h */
diff --git a/src/transports/git.c b/src/transports/git.c
index 9a17419..5baa810 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -147,7 +147,7 @@ static int store_refs(transport_git *t)
return 0;
ret = git_protocol_store_refs(&t->proto, buf->data, buf->offset);
- if (ret == GIT_ESHORTBUFFER) {
+ if (ret == GIT_EBUFS) {
gitno_consume_n(buf, buf->len);
continue;
}
@@ -279,7 +279,7 @@ static int recv_pkt(gitno_buffer *buf)
return -1;
error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->offset);
- if (error == GIT_ESHORTBUFFER)
+ if (error == GIT_EBUFS)
continue;
if (error < 0)
return -1;
@@ -344,7 +344,7 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, c
}
}
- if (error < 0 && error != GIT_EREVWALKOVER)
+ if (error < 0 && error != GIT_REVWALKOVER)
goto on_error;
/* Tell the other end that we're done negotiating */
@@ -384,10 +384,10 @@ static int git_download_pack(git_transport *transport, git_repository *repo, git
}
error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->offset);
- if (error == GIT_ESHORTBUFFER)
+ if (error == GIT_EBUFS)
break;
- if (error < GIT_SUCCESS)
+ if (error < 0)
return error;
if (pkt->type == GIT_PKT_PACK) {
diff --git a/src/transports/http.c b/src/transports/http.c
index bc4a615..2a8ebbb 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -354,10 +354,10 @@ static int on_body_parse_response(http_parser *parser, const char *str, size_t l
return 0;
error = git_pkt_parse_line(&pkt, ptr, &line_end, git_buf_len(buf));
- if (error == GIT_ESHORTBUFFER) {
+ if (error == GIT_EBUFS) {
return 0; /* Ask for more */
}
- if (error < GIT_SUCCESS)
+ if (error < 0)
return t->error = -1;
git_buf_consume(buf, line_end);
@@ -486,7 +486,7 @@ static int http_negotiate_fetch(git_transport *transport, git_repository *repo,
git_buf_clear(&request);
git_buf_clear(&data);
- if (ret < GIT_SUCCESS || i >= 256)
+ if (ret < 0 || i >= 256)
break;
if ((ret = parse_response(t)) < 0)
diff --git a/src/transports/local.c b/src/transports/local.c
index aa5155e..000993e 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -91,7 +91,7 @@ static int store_refs(transport_local *t)
assert(t);
- if (git_reference_listall(&ref_names, t->repo, GIT_REF_LISTALL) < 0 ||
+ if (git_reference_list(&ref_names, t->repo, GIT_REF_LISTALL) < 0 ||
git_vector_init(&t->refs, (unsigned int)ref_names.count, NULL) < 0)
goto on_error;
diff --git a/src/tree.c b/src/tree.c
index 5acee4a..92b1b1e 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -647,7 +647,7 @@ static int tree_frompath(
{
char *slash_pos = NULL;
const git_tree_entry* entry;
- int error = GIT_SUCCESS;
+ int error = 0;
git_tree *subtree;
if (!*(treeentry_path->ptr + offset)) {
@@ -724,7 +724,7 @@ static int tree_walk_post(
git_buf *path,
void *payload)
{
- int error = GIT_SUCCESS;
+ int error = 0;
unsigned int i;
for (i = 0; i < tree->entries.length; ++i) {
@@ -761,7 +761,7 @@ static int tree_walk_post(
int git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload)
{
- int error = GIT_SUCCESS;
+ int error = 0;
git_buf root_path = GIT_BUF_INIT;
switch (mode) {
diff --git a/src/util.c b/src/util.c
index 9fd5f28..ce77020 100644
--- a/src/util.c
+++ b/src/util.c
@@ -411,3 +411,27 @@ int git__strcmp_cb(const void *a, const void *b)
return strcmp(stra, strb);
}
+
+int git__parse_bool(int *out, const char *value)
+{
+ /* A missing value means true */
+ if (value == NULL) {
+ *out = 1;
+ return 0;
+ }
+
+ if (!strcasecmp(value, "true") ||
+ !strcasecmp(value, "yes") ||
+ !strcasecmp(value, "on")) {
+ *out = 1;
+ return 0;
+ }
+ if (!strcasecmp(value, "false") ||
+ !strcasecmp(value, "no") ||
+ !strcasecmp(value, "off")) {
+ *out = 0;
+ return 0;
+ }
+
+ return -1;
+}
diff --git a/src/util.h b/src/util.h
index cb5e83c..c6851ac 100644
--- a/src/util.h
+++ b/src/util.h
@@ -214,4 +214,13 @@ GIT_INLINE(bool) git__iswildcard(int c)
return (c == '*' || c == '?' || c == '[');
}
+/*
+ * Parse a string value as a boolean, just like Core Git
+ * does.
+ *
+ * Valid values for true are: 'true', 'yes', 'on'
+ * Valid values for false are: 'false', 'no', 'off'
+ */
+extern int git__parse_bool(int *out, const char *value);
+
#endif /* INCLUDE_util_h__ */
diff --git a/tests-clar/attr/flags.c b/tests-clar/attr/flags.c
index 5081de8..80c6e11 100644
--- a/tests-clar/attr/flags.c
+++ b/tests-clar/attr/flags.c
@@ -14,7 +14,7 @@ void test_attr_flags__bare(void)
cl_assert(git_repository_is_bare(repo));
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM, "README.md", "diff", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM, "README.md", "diff"));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
}
@@ -27,34 +27,34 @@ void test_attr_flags__index_vs_workdir(void)
/* wd then index */
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "README.md", "bar", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "README.md", "bar"));
cl_assert(GIT_ATTR_FALSE(value));
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "README.md", "blargh", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "README.md", "blargh"));
cl_assert_equal_s(value, "goop");
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "README.txt", "foo", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "README.txt", "foo"));
cl_assert(GIT_ATTR_FALSE(value));
/* index then wd */
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "README.md", "bar", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "README.md", "bar"));
cl_assert(GIT_ATTR_TRUE(value));
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "README.md", "blargh", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "README.md", "blargh"));
cl_assert_equal_s(value, "garble");
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "README.txt", "foo", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "README.txt", "foo"));
cl_assert(GIT_ATTR_TRUE(value));
}
@@ -65,44 +65,44 @@ void test_attr_flags__subdir(void)
/* wd then index */
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "sub/sub/README.md", "bar", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.md", "bar"));
cl_assert_equal_s(value, "1234");
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "sub/sub/README.txt", "another", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.txt", "another"));
cl_assert_equal_s(value, "one");
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "sub/sub/README.txt", "again", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.txt", "again"));
cl_assert(GIT_ATTR_TRUE(value));
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
- "sub/sub/README.txt", "beep", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.txt", "beep"));
cl_assert_equal_s(value, "10");
/* index then wd */
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "sub/sub/README.md", "bar", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.md", "bar"));
cl_assert_equal_s(value, "1337");
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "sub/sub/README.txt", "another", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.txt", "another"));
cl_assert_equal_s(value, "one");
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "sub/sub/README.txt", "again", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.txt", "again"));
cl_assert(GIT_ATTR_TRUE(value));
cl_git_pass(git_attr_get(
- repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
- "sub/sub/README.txt", "beep", &value));
+ &value, repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.txt", "beep"));
cl_assert_equal_s(value, "5");
}
diff --git a/tests-clar/attr/repo.c b/tests-clar/attr/repo.c
index 006a490..a88dfb3 100644
--- a/tests-clar/attr/repo.c
+++ b/tests-clar/attr/repo.c
@@ -64,7 +64,7 @@ void test_attr_repo__get_one(void)
for (scan = test_cases; scan->path != NULL; scan++) {
const char *value;
- cl_git_pass(git_attr_get(g_repo, 0, scan->path, scan->attr, &value));
+ cl_git_pass(git_attr_get(&value, g_repo, 0, scan->path, scan->attr));
attr_check_expected(scan->expected, scan->expected_str, value);
}
@@ -78,21 +78,21 @@ void test_attr_repo__get_many(void)
const char *names[4] = { "repoattr", "rootattr", "missingattr", "subattr" };
const char *values[4];
- cl_git_pass(git_attr_get_many(g_repo, 0, "root_test1", 4, names, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "root_test1", 4, names));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
- cl_git_pass(git_attr_get_many(g_repo, 0, "root_test2", 4, names, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "root_test2", 4, names));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_FALSE(values[1]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
- cl_git_pass(git_attr_get_many(g_repo, 0, "sub/subdir_test1", 4, names, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "sub/subdir_test1", 4, names));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
@@ -137,19 +137,19 @@ void test_attr_repo__manpage_example(void)
{
const char *value;
- cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "foo", &value));
+ cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "foo"));
cl_assert(GIT_ATTR_TRUE(value));
- cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "bar", &value));
+ cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "bar"));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
- cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "baz", &value));
+ cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "baz"));
cl_assert(GIT_ATTR_FALSE(value));
- cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "merge", &value));
+ cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "merge"));
cl_assert_equal_s("filfre", value);
- cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "frotz", &value));
+ cl_git_pass(git_attr_get(&value, g_repo, 0, "sub/abc", "frotz"));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
}
@@ -160,7 +160,7 @@ void test_attr_repo__macros(void)
const char *names3[3] = { "macro2", "multi2", "multi3" };
const char *values[5];
- cl_git_pass(git_attr_get_many(g_repo, 0, "binfile", 5, names, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "binfile", 5, names));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
@@ -168,7 +168,7 @@ void test_attr_repo__macros(void)
cl_assert(GIT_ATTR_FALSE(values[3]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[4]));
- cl_git_pass(git_attr_get_many(g_repo, 0, "macro_test", 5, names2, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "macro_test", 5, names2));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
@@ -176,7 +176,7 @@ void test_attr_repo__macros(void)
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
cl_assert_equal_s("77", values[4]);
- cl_git_pass(git_attr_get_many(g_repo, 0, "macro_test", 3, names3, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "macro_test", 3, names3));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_FALSE(values[1]));
@@ -189,7 +189,7 @@ void test_attr_repo__bad_macros(void)
"firstmacro", "secondmacro", "thirdmacro" };
const char *values[6];
- cl_git_pass(git_attr_get_many(g_repo, 0, "macro_bad", 6, names, values));
+ cl_git_pass(git_attr_get_many(values, g_repo, 0, "macro_bad", 6, names));
/* these three just confirm that the "mymacro" rule ran */
cl_assert(GIT_ATTR_UNSPECIFIED(values[0]));
diff --git a/tests-clar/commit/signature.c b/tests-clar/commit/signature.c
index 605b833..290b11f 100644
--- a/tests-clar/commit/signature.c
+++ b/tests-clar/commit/signature.c
@@ -3,9 +3,9 @@
static int try_build_signature(const char *name, const char *email, git_time_t time, int offset)
{
git_signature *sign;
- int error = GIT_SUCCESS;
+ int error = 0;
- if ((error = git_signature_new(&sign, name, email, time, offset)) < GIT_SUCCESS)
+ if ((error = git_signature_new(&sign, name, email, time, offset)) < 0)
return error;
git_signature_free((git_signature *)sign);
diff --git a/tests-clar/config/add.c b/tests-clar/config/add.c
index b580299..9854fbb 100644
--- a/tests-clar/config/add.c
+++ b/tests-clar/config/add.c
@@ -17,7 +17,7 @@ void test_config_add__to_existing_section(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config10"));
cl_git_pass(git_config_set_int32(cfg, "empty.tmp", 5));
- cl_git_pass(git_config_get_int32(cfg, "empty.tmp", &i));
+ cl_git_pass(git_config_get_int32(&i, cfg, "empty.tmp"));
cl_assert(i == 5);
cl_git_pass(git_config_delete(cfg, "empty.tmp"));
git_config_free(cfg);
@@ -30,7 +30,7 @@ void test_config_add__to_new_section(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config10"));
cl_git_pass(git_config_set_int32(cfg, "section.tmp", 5));
- cl_git_pass(git_config_get_int32(cfg, "section.tmp", &i));
+ cl_git_pass(git_config_get_int32(&i, cfg, "section.tmp"));
cl_assert(i == 5);
cl_git_pass(git_config_delete(cfg, "section.tmp"));
git_config_free(cfg);
diff --git a/tests-clar/config/multivar.c b/tests-clar/config/multivar.c
index d3784c0..3b40cd0 100644
--- a/tests-clar/config/multivar.c
+++ b/tests-clar/config/multivar.c
@@ -21,7 +21,7 @@ static int mv_read_cb(const char *name, const char *value, void *data)
if (!strcmp(name, _name))
(*n)++;
- return GIT_SUCCESS;
+ return 0;
}
void test_config_multivar__foreach(void)
@@ -45,7 +45,7 @@ static int cb(const char *val, void *data)
(*n)++;
- return GIT_SUCCESS;
+ return 0;
}
void test_config_multivar__get(void)
diff --git a/tests-clar/config/new.c b/tests-clar/config/new.c
index 78e8ec8..fae3ce9 100644
--- a/tests-clar/config/new.c
+++ b/tests-clar/config/new.c
@@ -25,9 +25,9 @@ void test_config_new__write_new_config(void)
cl_git_pass(git_config_new(&config));
cl_git_pass(git_config_add_file(config, file, 0));
- cl_git_pass(git_config_get_string(config, "color.ui", &out));
+ cl_git_pass(git_config_get_string(&out, config, "color.ui"));
cl_assert_equal_s(out, "auto");
- cl_git_pass(git_config_get_string(config, "core.editor", &out));
+ cl_git_pass(git_config_get_string(&out, config, "core.editor"));
cl_assert_equal_s(out, "ed");
git_config_free(config);
diff --git a/tests-clar/config/read.c b/tests-clar/config/read.c
index 3e9a8d4..f33bdd8 100644
--- a/tests-clar/config/read.c
+++ b/tests-clar/config/read.c
@@ -7,13 +7,13 @@ void test_config_read__simple_read(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config0")));
- cl_git_pass(git_config_get_int32(cfg, "core.repositoryformatversion", &i));
+ cl_git_pass(git_config_get_int32(&i, cfg, "core.repositoryformatversion"));
cl_assert(i == 0);
- cl_git_pass(git_config_get_bool(cfg, "core.filemode", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "core.filemode"));
cl_assert(i == 1);
- cl_git_pass(git_config_get_bool(cfg, "core.bare", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "core.bare"));
cl_assert(i == 0);
- cl_git_pass(git_config_get_bool(cfg, "core.logallrefupdates", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "core.logallrefupdates"));
cl_assert(i == 1);
git_config_free(cfg);
@@ -27,18 +27,18 @@ void test_config_read__case_sensitive(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config1")));
- cl_git_pass(git_config_get_string(cfg, "this.that.other", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "this.that.other"));
cl_assert_equal_s(str, "true");
- cl_git_pass(git_config_get_string(cfg, "this.That.other", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "this.That.other"));
cl_assert_equal_s(str, "yes");
- cl_git_pass(git_config_get_bool(cfg, "this.that.other", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "this.that.other"));
cl_assert(i == 1);
- cl_git_pass(git_config_get_bool(cfg, "this.That.other", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "this.That.other"));
cl_assert(i == 1);
/* This one doesn't exist */
- cl_must_fail(git_config_get_bool(cfg, "this.thaT.other", &i));
+ cl_must_fail(git_config_get_bool(&i, cfg, "this.thaT.other"));
git_config_free(cfg);
}
@@ -54,7 +54,7 @@ void test_config_read__multiline_value(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config2")));
- cl_git_pass(git_config_get_string(cfg, "this.That.and", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "this.That.and"));
cl_assert_equal_s(str, "one one one two two three three");
git_config_free(cfg);
@@ -70,11 +70,11 @@ void test_config_read__subsection_header(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config3")));
- cl_git_pass(git_config_get_string(cfg, "section.subsection.var", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "section.subsection.var"));
cl_assert_equal_s(str, "hello");
/* The subsection is transformed to lower-case */
- cl_must_fail(git_config_get_string(cfg, "section.subSectIon.var", &str));
+ cl_must_fail(git_config_get_string(&str, cfg, "section.subSectIon.var"));
git_config_free(cfg);
}
@@ -87,10 +87,10 @@ void test_config_read__lone_variable(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config4")));
- cl_git_pass(git_config_get_string(cfg, "some.section.variable", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "some.section.variable"));
cl_assert(str == NULL);
- cl_git_pass(git_config_get_bool(cfg, "some.section.variable", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variable"));
cl_assert(i == 1);
git_config_free(cfg);
@@ -103,25 +103,25 @@ void test_config_read__number_suffixes(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config5")));
- cl_git_pass(git_config_get_int64(cfg, "number.simple", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.simple"));
cl_assert(i == 1);
- cl_git_pass(git_config_get_int64(cfg, "number.k", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.k"));
cl_assert(i == 1 * 1024);
- cl_git_pass(git_config_get_int64(cfg, "number.kk", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.kk"));
cl_assert(i == 1 * 1024);
- cl_git_pass(git_config_get_int64(cfg, "number.m", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.m"));
cl_assert(i == 1 * 1024 * 1024);
- cl_git_pass(git_config_get_int64(cfg, "number.mm", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.mm"));
cl_assert(i == 1 * 1024 * 1024);
- cl_git_pass(git_config_get_int64(cfg, "number.g", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.g"));
cl_assert(i == 1 * 1024 * 1024 * 1024);
- cl_git_pass(git_config_get_int64(cfg, "number.gg", &i));
+ cl_git_pass(git_config_get_int64(&i, cfg, "number.gg"));
cl_assert(i == 1 * 1024 * 1024 * 1024);
git_config_free(cfg);
@@ -134,10 +134,10 @@ void test_config_read__blank_lines(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config6")));
- cl_git_pass(git_config_get_bool(cfg, "valid.subsection.something", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "valid.subsection.something"));
cl_assert(i == 1);
- cl_git_pass(git_config_get_bool(cfg, "something.else.something", &i));
+ cl_git_pass(git_config_get_bool(&i, cfg, "something.else.something"));
cl_assert(i == 0);
git_config_free(cfg);
@@ -170,10 +170,10 @@ void test_config_read__prefixes(void)
const char *str;
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9")));
- cl_git_pass(git_config_get_string(cfg, "remote.ab.url", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "remote.ab.url"));
cl_assert_equal_s(str, "http://example.com/git/ab");
- cl_git_pass(git_config_get_string(cfg, "remote.abba.url", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "remote.abba.url"));
cl_assert_equal_s(str, "http://example.com/git/abba");
git_config_free(cfg);
@@ -185,7 +185,7 @@ void test_config_read__escaping_quotes(void)
const char *str;
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config13")));
- cl_git_pass(git_config_get_string(cfg, "core.editor", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "core.editor"));
cl_assert(strcmp(str, "\"C:/Program Files/Nonsense/bah.exe\" \"--some option\"") == 0);
git_config_free(cfg);
diff --git a/tests-clar/config/stress.c b/tests-clar/config/stress.c
index 54a61ad..3de1f76 100644
--- a/tests-clar/config/stress.c
+++ b/tests-clar/config/stress.c
@@ -32,8 +32,8 @@ void test_config_stress__dont_break_on_invalid_input(void)
cl_git_pass(git_config_new(&config));
cl_git_pass(git_config_add_file(config, file, 0));
- cl_git_pass(git_config_get_string(config, "color.ui", &color));
- cl_git_pass(git_config_get_string(config, "core.editor", &editor));
+ cl_git_pass(git_config_get_string(&color, config, "color.ui"));
+ cl_git_pass(git_config_get_string(&editor, config, "core.editor"));
git_config_free(config);
}
@@ -48,13 +48,13 @@ void test_config_stress__comments(void)
cl_git_pass(git_config_new(&config));
cl_git_pass(git_config_add_file(config, file, 0));
- cl_git_pass(git_config_get_string(config, "some.section.other", &str));
+ cl_git_pass(git_config_get_string(&str, config, "some.section.other"));
cl_assert(!strcmp(str, "hello! \" ; ; ; "));
- cl_git_pass(git_config_get_string(config, "some.section.multi", &str));
+ cl_git_pass(git_config_get_string(&str, config, "some.section.multi"));
cl_assert(!strcmp(str, "hi, this is a ; multiline comment # with ;\n special chars and other stuff !@#"));
- cl_git_pass(git_config_get_string(config, "some.section.back", &str));
+ cl_git_pass(git_config_get_string(&str, config, "some.section.back"));
cl_assert(!strcmp(str, "this is \ba phrase"));
git_config_free(config);
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c
index f25bf5a..f877447 100644
--- a/tests-clar/config/write.c
+++ b/tests-clar/config/write.c
@@ -22,7 +22,7 @@ void test_config_write__replace_value(void)
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
- cl_git_pass(git_config_get_int32(cfg, "core.dummy", &i));
+ cl_git_pass(git_config_get_int32(&i, cfg, "core.dummy"));
cl_assert(i == 5);
git_config_free(cfg);
@@ -35,12 +35,12 @@ void test_config_write__replace_value(void)
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
- cl_git_pass(git_config_get_int64(cfg, "core.verylong", &l));
+ cl_git_pass(git_config_get_int64(&l, cfg, "core.verylong"));
cl_assert(l == expected);
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
- cl_must_fail(git_config_get_int32(cfg, "core.verylong", &i));
+ cl_must_fail(git_config_get_int32(&i, cfg, "core.verylong"));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
@@ -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_assert(git_config_get_int32(cfg, "core.dummy", &i) == GIT_ENOTFOUND);
+ cl_assert(git_config_get_int32(&i, cfg, "core.dummy") == GIT_ENOTFOUND);
cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1));
git_config_free(cfg);
}
@@ -77,7 +77,7 @@ void test_config_write__write_subsection(void)
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
- cl_git_pass(git_config_get_string(cfg, "my.own.var", &str));
+ cl_git_pass(git_config_get_string(&str, cfg, "my.own.var"));
cl_git_pass(strcmp(str, "works"));
git_config_free(cfg);
}
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 3d01b7c..3436f8d 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -50,10 +50,10 @@ static void files_are_equal(const char *a, const char *b)
git_buf buf_b = GIT_BUF_INIT;
int pass;
- if (git_futils_readbuffer(&buf_a, a) < GIT_SUCCESS)
+ if (git_futils_readbuffer(&buf_a, a) < 0)
cl_assert(0);
- if (git_futils_readbuffer(&buf_b, b) < GIT_SUCCESS) {
+ if (git_futils_readbuffer(&buf_b, b) < 0) {
git_buf_free(&buf_a);
cl_assert(0);
}
diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c
index 35fa072..98abbbe 100644
--- a/tests-clar/network/remotelocal.c
+++ b/tests-clar/network/remotelocal.c
@@ -68,7 +68,7 @@ static int count_ref__cb(git_remote_head *head, void *payload)
(void)head;
(*count)++;
- return GIT_SUCCESS;
+ return 0;
}
static int ensure_peeled__cb(git_remote_head *head, void *payload)
diff --git a/tests-clar/object/tag/read.c b/tests-clar/object/tag/read.c
index cfeb3ae..6a0ad8a 100644
--- a/tests-clar/object/tag/read.c
+++ b/tests-clar/object/tag/read.c
@@ -17,9 +17,9 @@ static void ensure_tag_pattern_match(git_repository *repo,
const size_t expected_matches)
{
git_strarray tag_list;
- int error = GIT_SUCCESS;
+ int error = 0;
- if ((error = git_tag_list_match(&tag_list, pattern, repo)) < GIT_SUCCESS)
+ if ((error = git_tag_list_match(&tag_list, pattern, repo)) < 0)
goto exit;
if (tag_list.count != expected_matches)
diff --git a/tests-clar/object/tree/frompath.c b/tests-clar/object/tree/frompath.c
index ea0add3..06c69ac 100644
--- a/tests-clar/object/tree/frompath.c
+++ b/tests-clar/object/tree/frompath.c
@@ -30,10 +30,10 @@ static void assert_tree_from_path(git_tree *root, const char *path, int expected
cl_assert(git_tree_get_subtree(&containing_tree, root, path) == expected_result);
- if (containing_tree == NULL && expected_result != GIT_SUCCESS)
+ if (containing_tree == NULL && expected_result != 0)
return;
- cl_assert(containing_tree != NULL && expected_result == GIT_SUCCESS);
+ cl_assert(containing_tree != NULL && expected_result == 0);
cl_git_pass(git_oid_streq(git_object_id((const git_object *)containing_tree), expected_raw_oid));
@@ -49,19 +49,19 @@ static void assert_tree_from_path_klass(git_tree *root, const char *path, int ex
void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void)
{
/* Will return self if given a one path segment... */
- assert_tree_from_path(tree, "README", GIT_SUCCESS, tree_with_subtrees_oid);
+ assert_tree_from_path(tree, "README", 0, tree_with_subtrees_oid);
/* ...even one that lead to a non existent tree entry. */
- assert_tree_from_path(tree, "i-do-not-exist.txt", GIT_SUCCESS, tree_with_subtrees_oid);
+ assert_tree_from_path(tree, "i-do-not-exist.txt", 0, tree_with_subtrees_oid);
/* Will return fgh tree oid given this following path... */
- assert_tree_from_path(tree, "ab/de/fgh/1.txt", GIT_SUCCESS, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
+ assert_tree_from_path(tree, "ab/de/fgh/1.txt", 0, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
/* ... and ab tree oid given this one. */
- assert_tree_from_path(tree, "ab/de", GIT_SUCCESS, "f1425cef211cc08caa31e7b545ffb232acb098c3");
+ assert_tree_from_path(tree, "ab/de", 0, "f1425cef211cc08caa31e7b545ffb232acb098c3");
/* Will succeed if given a valid path which leads to a tree entry which doesn't exist */
- assert_tree_from_path(tree, "ab/de/fgh/i-do-not-exist.txt", GIT_SUCCESS, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
+ assert_tree_from_path(tree, "ab/de/fgh/i-do-not-exist.txt", 0, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
}
void test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment(void)
diff --git a/tests-clar/refs/branches/delete.c b/tests-clar/refs/branches/delete.c
index 8ccfaf3..03d3c56 100644
--- a/tests-clar/refs/branches/delete.c
+++ b/tests-clar/refs/branches/delete.c
@@ -75,7 +75,7 @@ void test_refs_branches_delete__can_delete_a_remote_branch(void)
cl_git_pass(git_branch_delete(repo, "nulltoken/master", GIT_BRANCH_REMOTE));
}
-static void assert_non_exisitng_branch_removal(const char *branch_name, git_branch_type branch_type)
+static void assert_non_exisitng_branch_removal(const char *branch_name, git_branch_t branch_type)
{
int error;
error = git_branch_delete(repo, branch_name, branch_type);
diff --git a/tests-clar/refs/list.c b/tests-clar/refs/list.c
index f673bd9..2a7b157 100644
--- a/tests-clar/refs/list.c
+++ b/tests-clar/refs/list.c
@@ -25,7 +25,7 @@ void test_refs_list__all(void)
// try to list all the references in our test repo
git_strarray ref_list;
- cl_git_pass(git_reference_listall(&ref_list, g_repo, GIT_REF_LISTALL));
+ cl_git_pass(git_reference_list(&ref_list, g_repo, GIT_REF_LISTALL));
/*{
unsigned short i;
@@ -46,7 +46,7 @@ void test_refs_list__symbolic_only(void)
// try to list only the symbolic references
git_strarray ref_list;
- cl_git_pass(git_reference_listall(&ref_list, g_repo, GIT_REF_SYMBOLIC));
+ cl_git_pass(git_reference_list(&ref_list, g_repo, GIT_REF_SYMBOLIC));
cl_assert(ref_list.count == 0); /* no symrefs in the test repo */
git_strarray_free(&ref_list);
diff --git a/tests-clar/refs/listall.c b/tests-clar/refs/listall.c
index ced40a2..7f1de74 100644
--- a/tests-clar/refs/listall.c
+++ b/tests-clar/refs/listall.c
@@ -9,7 +9,7 @@ static void ensure_no_refname_starts_with_a_forward_slash(const char *path)
size_t i;
cl_git_pass(git_repository_open(&repo, path));
- cl_git_pass(git_reference_listall(&ref_list, repo, GIT_REF_LISTALL));
+ cl_git_pass(git_reference_list(&ref_list, repo, GIT_REF_LISTALL));
cl_assert(ref_list.count > 0);
diff --git a/tests-clar/repo/open.c b/tests-clar/repo/open.c
index 2924663..c70ec83 100644
--- a/tests-clar/repo/open.c
+++ b/tests-clar/repo/open.c
@@ -279,4 +279,4 @@ void test_repo_open__opening_a_non_existing_repository_returns_ENOTFOUND(void)
{
git_repository *repo;
cl_assert_equal_i(GIT_ENOTFOUND, git_repository_open(&repo, "i-do-not/exist"));
-}
\ No newline at end of file
+}
diff --git a/tests-clar/revwalk/basic.c b/tests-clar/revwalk/basic.c
index 7d54ce9..a5a9b2e 100644
--- a/tests-clar/revwalk/basic.c
+++ b/tests-clar/revwalk/basic.c
@@ -73,7 +73,7 @@ static int test_walk(git_revwalk *walk, const git_oid *root,
i = 0;
- while (git_revwalk_next(&oid, walk) == GIT_SUCCESS) {
+ while (git_revwalk_next(&oid, walk) == 0) {
result_array[i++] = get_commit_index(&oid);
/*{
char str[41];
@@ -86,7 +86,7 @@ static int test_walk(git_revwalk *walk, const git_oid *root,
for (i = 0; i < results_count; ++i)
if (memcmp(possible_results[i],
result_array, result_bytes) == 0)
- return GIT_SUCCESS;
+ return 0;
return GIT_ERROR;
}
@@ -125,7 +125,7 @@ void test_revwalk_basic__glob_heads(void)
cl_git_pass(git_revwalk_push_glob(_walk, "heads"));
- while (git_revwalk_next(&oid, _walk) == GIT_SUCCESS) {
+ while (git_revwalk_next(&oid, _walk) == 0) {
i++;
}
@@ -140,7 +140,7 @@ void test_revwalk_basic__push_head(void)
cl_git_pass(git_revwalk_push_head(_walk));
- while (git_revwalk_next(&oid, _walk) == GIT_SUCCESS) {
+ while (git_revwalk_next(&oid, _walk) == 0) {
i++;
}
@@ -156,7 +156,7 @@ void test_revwalk_basic__push_head_hide_ref(void)
cl_git_pass(git_revwalk_push_head(_walk));
cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/packed-test"));
- while (git_revwalk_next(&oid, _walk) == GIT_SUCCESS) {
+ while (git_revwalk_next(&oid, _walk) == 0) {
i++;
}
@@ -172,7 +172,7 @@ void test_revwalk_basic__push_head_hide_ref_nobase(void)
cl_git_pass(git_revwalk_push_head(_walk));
cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/packed"));
- while (git_revwalk_next(&oid, _walk) == GIT_SUCCESS) {
+ while (git_revwalk_next(&oid, _walk) == 0) {
i++;
}