Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 7382 lines (6932 sloc) 236.301 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381
/*
* libgit2 Vala binding
*
* Homepage: http://libgit2.github.com/
* VAPI Homepage: https://github.com/apmasell/vapis/blob/master/libgit2.vapi
* VAPI Maintainer: Andre Masella <andre@masella.name>
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/

/**
* Library to access the contents of git repositories
*
* libgit2 can access and manipulate the contents of git repositories. To begin, create an instance of a {@link Git.Repository} like so:
* {{{
* Git.Repository? repo;
* if (Git.Repository.open(out repo, "/path/to/repo") != Git.Error.OK) {
* stderr.printf("Could not open repository because: %s\n", Git.ErrorInfo.get_last().message);
* return false;
* }
* }}}
* Then use the methods of //repo// to access the repository.
*/
[CCode(cheader_filename = "git2.h")]
namespace Git {
namespace Configuration {
/**
* Generic backend that implements the interface to
* access a configuration file
*/
[CCode(cname = "git_config_backend", has_type_id = false, default_value = "GIT_CONFIG_BACKEND_INIT")]
public struct backend {
[CCode(cname = "GIT_CONFIG_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public unowned Config cfg;
public Delete @delete;
[CCode(cname = "foreach")]
public ForEach for_each;
public Free free;
public Get @get;
[CCode(cname = "get_multivar")]
public GetMulti get_multi;
[CCode(cname = "refersh")]
public Refresh refresh;
public Open open;
public Set @set;
public SetMulti set_multi;
}

[CCode(cname = "git_config_file_delete_cb", has_type_id = false, has_target = false)]
public delegate int Delete(backend backend, string key);
[CCode(cname = "git_config_file_foreach_cb", has_type_id = false, has_target = false)]
public delegate int ForEach(backend backend, string regex, ConfigForEach config_for_each);
[CCode(cname = "git_config_file_free_cb", has_type_id = false, has_target = false)]
public delegate void Free(backend backend);
[CCode(cname = "git_config_file_get_cb", has_type_id = false, has_target = false)]
public delegate int Get(backend backend, string key, out string value);
[CCode(cname = "git_config_file_get_mulivar_cb", has_type_id = false, has_target = false)]
public delegate int GetMulti(backend backend, string key, string? regexp, Setter func);
[CCode(cname = "git_config_file_refresh", has_type_id = false, has_target = false)]
public delegate Error Refresh(backend backend);
[CCode(cname = "git_config_file_set_cb", has_type_id = false, has_target = false)]
public delegate int Setter(string val);
[CCode(cname = "git_config_file_open_cb", has_type_id = false, has_target = false)]
public delegate int Open(backend backend);
[CCode(cname = "git_config_file_set_cb", has_type_id = false, has_target = false)]
public delegate int Set(backend backend, string key, string value);
[CCode(cname = "git_config_file_set_multivar_cb", has_type_id = false, has_target = false)]
public delegate int SetMulti(backend backend, string name, string regexp, string val);
}
namespace Database {
/**
* An open object database handle
*/
[CCode(cname = "git_odb", free_function = "git_odb_close", has_type_id = false)]
[Compact]
public class Handle {
/**
* Create a new object database with no backends.
*
* Before the ODB can be used for read/writing, a custom database
* backend must be manually added using {@link Handle.add_backend}.
*
* @param db location to store the database pointer, if opened. Set to null if the open failed.
*/
[CCode(cname = "git_odb_new")]
public static Error create(out Handle? db);

/**
* Create a new object database and automatically add
* the two default backends.
*
* Automatically added are:
* - {@link backend.create_loose}: read and write loose object files
* from disk, assuming //objects_dir// as the Objects folder
*
* - {@link backend.create_pack}: read objects from packfiles,
* assuming //objects_dir// as the Objects folder which
* contains a //pack// folder with the corresponding data
*
* @param db location to store the database pointer, if opened.
* Set to null if the open failed.
* @param objects_dir path of the backends' //objects// directory.
*/
[CCode(cname = "git_odb_open")]
public static Error open(out Handle db, string objects_dir);

/**
* Add a custom backend to an existing Object DB; this
* backend will work as an alternate.
*
* Alternate backends are always checked for objects ''after''
* all the main backends have been exhausted.
*
* The backends are checked in relative ordering, based on the
* value of the //priority// parameter.
*
* Writing is disabled on alternate backends.
*
* @param backend the backend instance
* @param priority Value for ordering the backends queue
*/
[CCode(cname = "git_odb_add_alternate")]
public Error add_alternate(backend backend, int priority);

/**
* Add a custom backend to an existing Object DB
*
* The backends are checked in relative ordering, based on the
* value of the //priority// parameter.
* @param backend the backend instance
* @param priority Value for ordering the backends queue
*/
[CCode(cname = "git_odb_add_backend")]
public Error add_backend(backend backend, int priority);

/**
* Determine if the given object can be found in the object database.
*
* @param id the object to search for.
*/
[CCode(cname = "git_odb_exists")]
public bool contains(object_id id);

/**
* Create a "fake" repository to wrap an object database
*
* Create a repository object to wrap an object database to be used with
* the API when all you have is an object database. This doesn't have any
* paths associated with it, so use with care.
*/
[CCode(cname = "git_repository_wrap_odb", instance_pos = -1)]
public Error create_repository(out Repository? repository);

/**
* List all objects available in the database
*
* The callback will be called for each object available in the
* database. Note that the objects are likely to be returned in the index
* order, which would make accessing the objects in that order inefficient.
*/
[CCode(cname = "git_odb_foreach")]
public Error for_each(ObjectIdForEach object_for_each);

/**
* Read an object from the database.
*
* This method queries all available ODB backends
* trying to read the given id.
*
* @param obj pointer where to store the read object
* @param id identity of the object to read.
*/
[CCode(cname = "git_odb_read", instance_pos = 1.2)]
public Error read(out Object obj, object_id id);

/**
* Read an object from the database, given a prefix
* of its identifier.
*
* This method queries all available ODB backends
* trying to match the //len// first hexadecimal
* characters of the //short_id//.
* The remaining //({@link object_id.HEX_SIZE}-len)*4// bits of
* //short_id// must be 0s.
* //len// must be at least {@link object_id.MIN_PREFIX_LENGTH},
* and the prefix must be long enough to identify
* a unique object in all the backends; the
* method will fail otherwise.
*
* The returned object is reference counted and
* internally cached, so it should be closed
* by the user once it's no longer in use.
*
* @param obj pointer where to store the read object
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
*/
[CCode(cname = "git_odb_read_prefix", instance_pos = 1.2)]
public Error read_by_prefix(out Object obj, object_id short_id, size_t len);

/**
* Read the header of an object from the database, without
* reading its full contents.
*
* The header includes the length and the type of an object.
*
* Note that most backends do not support reading only the header
* of an object, so the whole object will be read and then the
* header will be returned.
*
* @param len the length of the object
* @param type the type of the object
* @param id identity of the object to read.
*/
[CCode(cname = "git_odb_read_header", instance_pos = 2.3)]
public Error read_header(out size_t len, out ObjectType type, object_id id);

/**
* Refresh the object database to load newly added files.
*
* If the object databases have changed on disk while the library is
* running, this function will force a reload of the underlying indexes.
*
* Use this function when you're confident that an external application
* has tampered with the ODB.
*
* Note that it is not necessary to call this function at all. The
* library will automatically attempt to refresh the ODB when a lookup
* fails, to see if the looked up object exists on disk but hasn't been
* loaded yet.
*/
[CCode(cname = "git_odb_refresh")]
public Error refresh();

/**
* Open a stream to write an object into the ODB
*
* The type and final length of the object must be specified
* when opening the stream.
*
* The returned stream will be of type {@link StreamMode.WRONLY} and
* will have the following methods:
*
* * {@link stream.write}: write //n// bytes into the stream
* * {@link stream.finalize_write}: close the stream and store the object in the ODB
*
* The streaming write won't be effective until {@link stream.finalize_write}
* is called and returns without an error
*
* @param stream where to store the stream
* @param size final size of the object that will be written
* @param type type of the object that will be written
*/
[CCode(cname = "git_odb_open_wstream", instance_pos = 1.2)]
public Error open_write_stream(out stream stream, size_t size, ObjectType type);

/**
* Open a stream to read an object from the ODB
*
* Note that most backends do ''not'' support streaming reads
* because they store their objects as compressed/delta'ed blobs.
*
* It's recommended to use {@link Handle.read} instead, which is
* assured to work on all backends.
*
* The returned stream will be of type {@link StreamMode.RDONLY} and
* will have the following methods:
*
* * {@link stream.read}: read //n// bytes from the stream
*
* @param stream where to store the stream
* @param id id of the object the stream will read from
*/
[CCode(cname = "git_odb_open_rstream")]
public Error open_read_stream(out stream stream, object_id id);

/**
* Write an object directly into the ODB
*
* This method writes a full object straight into the ODB.
* For most cases, it is preferred to write objects through a write
* stream, which is both faster and less memory intensive, specially
* for big objects.
*
* This method is provided for compatibility with custom backends
* which are not able to support streaming writes
*
* @param id pointer to store the id result of the write
* @param data buffer with the data to store
* @param type type of the data to store
*/
[CCode(cname = "git_odb_write", instance_pos = 1.2)]
public Error write(object_id id, [CCode(array_length_Type = "size_t")] uint8[] data, ObjectType type);
}

/**
* An object read from the database
*/
[CCode(cname = "git_odb_object", free_function = "git_odb_object_free", has_type_id = false)]
[Compact]
public class Object {

/**
* The data of an ODB object
*
* This is the uncompressed, raw data as read from the ODB,
* without the leading header.
*/
public uint8[] data {
[CCode(cname = "git_odb_object_data", array_length_cexpr = "git_odb_object_size")]
get;
}

/**
* The id of an ODB object
*/
public object_id? id {
[CCode(cname = "git_odb_object_id")]
get;
}

/**
* The type of an ODB object
*/
public ObjectType type {
[CCode(cname = "git_odb_object_type")]
get;
}
}

/**
* A custom backend in an ODB
*/
[CCode(cname = "git_odb_backend", has_type_id = false, default_value = "GIT_ODB_BACKEND_INIT")]
public struct backend {
[CCode(cname = "GIT_ODB_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public unowned Handle odb;

public BackendExists exists;
public BackendFree free;
[CCode(cname = "foreach")]
public BackendForEach for_each;
public BackendRead read;
public BackendReadHeader read_header;
public BackendReadPrefix read_prefix;
[CCode(cname = "readstream")]
public BackendReadStream read_stream;
public BackendWrite write;
public BackendWritePack write_pack;
[CCode(cname = "writestream")]
public BackendWriteStream write_stream;

[CCode(cname = "git_odb_backend_loose")]
public static Error create_loose(out backend backend, string objects_dir);
[CCode(cname = "git_odb_backend_one_pack")]
public static Error create_one_pack(out backend backend, string index_file);
[CCode(cname = "git_odb_backend_pack")]
public static Error create_pack(out backend backend, string objects_dir);
[CCode(cname = "git_odb_backend_malloc", simple_generics = true)]
public T malloc<T>(size_t len);
}

/**
* A stream to read/write from the ODB
*/
[CCode(cname = "git_odb_stream", has_type_id = false)]
public struct stream {
public unowned backend? backend;

public StreamMode mode;

public StreamFinalizeWrite finalize_write;
public StreamFree free;
public StreamRead read;
public StreamWrite write;
}
/**
* A stream to write a pack file to the ODB
*/
[CCode(cname = "git_odb_writepack", has_type_id = false)]
public struct write_pack {
public unowned backend? backend;
[CCode(cname = "add")]
public WritePackAdd add;
[CCode(cname = "commit")]
public WritePackCommit commit;
[CCode(cname = "free")]
public WritePackFree free;
}
/**
* Streaming mode
*/
[CCode(cname = "git_odb_streammode", cprefix = "GIT_STREAM_", has_type_id = false)]
public enum StreamMode {
RDONLY,
WRONLY,
RW
}
[CCode(has_target = false, has_type_id = false)]
public delegate bool BackendExists(backend self, object_id id);
[CCode(has_target = false, has_type_id = false)]
public delegate void BackendFree(backend self);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendForEach(backend self, ObjectIdForEach cb);
/**
* Read each return to libgit2 a buffer which will be freed later.
*
* The buffer should be allocated using the function {@link backend.malloc} to
* ensure that it can be safely freed later.
*/
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendRead([CCode(array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id);
/**
* Find a unique object given a prefix
*
* The id given must be so that the remaining
* ({@link object_id.HEX_SIZE} - len)*4 bits are 0s.
*/
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendReadHeader(out size_t size, out ObjectType type, backend self, object_id id);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendReadPrefix(out object_id id, [CCode(array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id_prefix, size_t len);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendReadStream(out stream stream, backend self, object_id id);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendWrite(out object_id id, backend self, [CCode(array_length_type = "size_t")] out uint8[] data, ObjectType type);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendWriteStream(out stream stream, backend self, size_t size, ObjectType type);
[CCode(has_target = false, has_type_id = false)]
public delegate int BackendWritePack(out write_pack write_pack, backend self, TransferProgress progress);

[CCode(has_target = false, has_type_id = false)]
public delegate Error StreamFinalizeWrite(out object_id id, stream stream);
[CCode(has_target = false, has_type_id = false)]
public delegate void StreamFree(stream stream);
[CCode(has_target = false, has_type_id = false)]
public delegate int StreamRead(stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer);
[CCode(has_target = false, has_type_id = false)]
public delegate int StreamWrite(stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer);

[CCode(has_target = false)]
public delegate int WritePackAdd(write_pack write_pack, [CCode(array_length_type = "size_t")] uint8[] data, transfer_progress stats);
[CCode(has_target = false)]
public delegate int WritePackCommit(write_pack write_pack, transfer_progress stats);
[CCode(has_target = false)]
public delegate void WritePackFree(write_pack write_pack);
}
namespace Threads {
/**
* Init the threading system.
*
* If libgit2 has been built with GIT_THREADS
* on, this function must be called once before
* any other library functions.
*
* If libgit2 has been built without GIT_THREADS
* support, this function is a no-op.
*/
[CCode(cname = "git_threads_init")]
public Error init();

/**
* Shutdown the threading system.
*
* If libgit2 has been built with GIT_THREADS
* on, this function must be called before shutting
* down the library.
*
* If libgit2 has been built without GIT_THREADS
* support, this function is a no-op.
*/
[CCode(cname = "git_threads_shutdown")]
public void shutdown();
}
namespace Version {
[CCode(cname = "LIBGIT2_VERSION")]
public const string VERSION;
[CCode(cname = "LIBGIT2_VER_MAJOR")]
public const int MAJOR;
[CCode(cname = "LIBGIT2_VER_MINOR")]
public const int MINOR;
[CCode(cname = "LIBGIT2_VER_REVISION")]
public const int REVISION;
/**
* Return the version of the libgit2 library
* being currently used.
*
* @param major Store the major version number
* @param minor Store the minor version number
* @param rev Store the revision (patch) number
*/
[CCode(cname = "git_libgit2_version")]
public void get_version(out int major, out int minor, out int rev);
}

/*
* Attribute management routines
*/
[CCode(cname = "git_repository", cheader_filename = "git2/attr.h", has_type_id = false)]
public class Attr {
[CCode(cname = "git_attr_t", cprefix = "GIT_ATTR_", has_type_id = false)]
public enum AttrType {
[CCode(cname = "GIT_ATTR_UNSPECIFIED_T")]
UNSPECIFIED,
[CCode(cname = "GIT_ATTR_TRUE_T")]
TRUE,
[CCode(cname = "GIT_ATTR_FALSE_T")]
FALSE,
[CCode(cname = "GIT_ATTR_VALUE_T")]
VALUE;
/**
* Return the value type for a given attribute.
*
* This can be either {@link TRUE}, {@link FALSE}, {@link UNSPECIFIED}
* (if the attribute was not set at all), or {@link VALUE}, if the
* attribute was set to an actual string.
*
* If the attribute has a {@link VALUE} string, it can be accessed
* normally as a string.
*/
[CCode(cname = "git_attr_value")]
public static AttrType from(string attr);
}

/**
* Checks if an attribute is set on.
*
* In core git parlance, this the value for "Set" attributes.
*/
[CCode(cname = "GIT_ATTR_TRUE")]
public static bool is_true(string? attr);
/**
* Checks if an attribute is set off.
*
* In core git parlance, this is the value for attributes that are "Unset"
* (not to be confused with values that a "Unspecified").
*/
[CCode(cname = "GIT_ATTR_FALSE")]
public static bool is_false(string? attr);
/**
* Checks if an attribute is set to a value (as opposied to TRUE, FALSE or
* UNSPECIFIED).
*/
[CCode(cname = "GIT_ATTR_SET_TO_VALUE")]
public static bool is_set(string? attr);
/*
* Checks if an attribute is unspecified. This may be due to the attribute
* not being mentioned at all or because the attribute was explicitly set
* unspecified via the `!` operator.
*/
[CCode(cname = "GIT_ATTR_UNSPECIFIED")]
public static bool is_unspecified(string? attr);

/**
* Add a macro definition.
*
* Macros will automatically be loaded from the top level .gitattributes
* file of the repository (plus the build-in "binary" macro). This
* function allows you to add others. For example, to add the default
* macro, you would call:
* {{{
* repo.attributes.add_macro("binary", "-diff -crlf");
* }}}
*/
[CCode(cname = "git_attr_add_macro")]
public Error add_macro(string name, string val);

/**
* Lookup attribute for path returning string caller must free
*/
[CCode(cname = "git_attr_get")]
public Error lookup(AttrCheck flags, string path, string name, out unowned string? val);

/**
* Lookup list of attributes for path, populating array of strings
*
* Use this if you have a known list of attributes that you want to
* look up in a single call. This is somewhat more efficient than
* calling {@link lookup} multiple times.
*
* For example, you might write:
* {{{
* string attrs[] = { "crlf", "diff", "foo" };
* string results[];
* repo.attributes.lookup_many(AttrCheck.FILE_THEN_INDEX, "my/fun/file.c", attrs, out values);
* }}}
* Then you could loop through the 3 values to get the settings for
* the three attributes you asked about.
*
* @param path The path inside the repo to check attributes. This does not
* have to exist, but if it does not, then it will be treated as a plain
* file (i.e. not a directory).
* @param names The attribute names.
* @param values The values of the attributes.
*/
[CCode(cname = "_vala_git_attr_get_many")]
public Error lookup_many(AttrCheck flags, string path, string[] names, out string[] values) {
unstr[] temp = new unstr[names.length];
var e = _lookup_many(flags, path, names, temp);
values = new string[names.length];
for (var it = 0; it < temp.length; it++) {
values[it] = temp[it].dup();
}
return e;
}

[CCode(cname = "git_attr_get_many")]
private Error _lookup_many(AttrCheck flags, string path, [CCode(array_length_pos = 2.1, array_length_type = "size_t")] string[] names, void* values);

/**
* Perform an operation on each attribute of a path.
* @param path The path inside the repo to check attributes. This does not
* have to exist, but if it does not, then it will be treated as a plain
* file (i.e. not a directory).
* @param attribute_for_each The function that will be invoked on each
* attribute and attribute value. The name parameter will be the name of
* the attribute and the value will be the value it is set to, including
* possibly null if the attribute is explicitly set to UNSPECIFIED using
* the ! sign. This will be invoked only once per attribute name, even if
* there are multiple rules for a given file. The highest priority rule
* will be used.
*/
[CCode(cname = "git_attr_foreach")]
public Error for_each(AttrCheck flags, string path, AttributeForEach attribute_for_each);

/**
* Flush the gitattributes cache.
*
* Call this if you have reason to believe that the attributes files
* on disk no longer match the cached contents of memory. This will cause
* the attributes files to be reloaded the next time that an attribute
* access function is called.
*/
[CCode(cname = "git_attr_cache_flush")]
public void flush();
}

/**
* In-memory representation of a blob object.
*/
[CCode(cname = "git_blob", free_function = "git_blob_free", has_type_id = false)]
[Compact]
public class Blob : Object {
[CCode(array_length = false, cname = "git_blob_rawcontent")]
private unowned uint8[]? _get_content();

/**
* Get a read-only buffer with the raw content of a blob.
*
* A pointer to the raw content of a blob is returned.
* The pointer may be invalidated at a later time.
*/
public uint8[]? content {
get {
unowned uint8[]? content = _get_content();
if (content != null) {
content.length = (int) size;
}
return content;
}
}
/**
* The id of a blob.
*/
public object_id? id {
[CCode(cname = "git_blob_id")]
get;
}
/**
* Determine if the blob content is most certainly binary or not.
*
* The heuristic used to guess if a file is binary is taken from core git:
* Searching for NUL bytes and looking for a reasonable ratio of printable
* to non-printable characters among the first 4000 bytes.
*/
public bool is_binary {
[CCode(cname = "git_blob_is_binary")]
get;
}

/**
* Get the size in bytes of the contents of a blob
*/
public size_t size {
[CCode(cname = "git_blob_rawsize")]
get;
}
/**
* Directly run a text diff on two blobs.
*
* Compared to a file, a blob lacks some contextual information. As such, the
* {@link diff_file} parameters of the callbacks will be filled accordingly to the following:
* mode will be set to 0, path will be null. When dealing with a null blob, object id
* will be set to 0.
*
* When at least one of the blobs being dealt with is binary, the {@link diff_delta} binary
* attribute will be set to true and no call to the hunk nor line will be made.
*
* We do run a binary content check on the two blobs and if either of the
* blobs looks like binary data, {@link diff_delta.flags} will {@link DiffFlag.BINARY}
* and no call to the {@link DiffHunk} nor {@link DiffData} will be made
* (unless you pass {@link DiffFlags.FORCE_TEXT} of course).
*/
[CCode(cname = "git_diff_blobs", simple_generics = true)]
public Error diff<T>(Blob new_blob, diff_options options, DiffFile<T> file, DiffHunk<T> hunk, DiffData<T> line, T context);
/**
* Directly run a diff between a blob and a buffer.
*
* As with {@link diff}, comparing a blob and buffer lacks some context, so
* the {@link diff_file} parameters to the callbacks will be faked.
*/
[CCode(cname = "git_diff_blob_to_buffer", simple_generics = true)]
public Error diff_buffer<T>([CCode(array_length_type = "size_t")] uint8[] buffer, diff_options options, DiffFile<T> file, DiffHunk<T> hunk, DiffData<T> line, T context);
}

/**
* Parsed representation of a commit object.
*/
[CCode(cname = "git_commit", free_function = "git_commit_free", has_type_id = false)]
[Compact]
public class Commit : Object {
/**
* The author of a commit.
*/
public Signature author {
[CCode(cname = "git_commit_author")]
get;
}

/**
* The committer of a commit.
*/
public Signature committer {
[CCode(cname = "git_commit_committer")]
get;
}

/**
* The id of a commit.
*/
public object_id? id {
[CCode(cname = "git_commit_id")]
get;
}

/**
* The full message of a commit.
*/
public string message {
[CCode(cname = "git_commit_message")]
get;
}

/**
* The encoding for the message of a commit, as a string representing a
* standard encoding name.
*
* The encoding may be null if the encoding header in the commit is
* missing; in that case UTF-8 is assumed.
*/
public string? message_encoding {
[CCode(cname = "git_commit_message_encoding")]
get;
}

/**
* The parent(s) of this commit
*
* Typically, commits have a single parent, but merges can have many.
*/
public Parents parents {
[CCode(cname = "")]
get;
}

/**
* Get the commit time (i.e., committer time) of a commit.
*/
public int64 time {
[CCode(cname = "git_commit_time")]
get;
}

/**
* Get the commit timezone offset (i.e., committer's preferred timezone) in minutes from UTC of a commit.
*/
public int time_offset {
[CCode(cname = "git_commit_time_offset")]
get;
}

/**
* Get the id of the tree pointed to by a commit.
*
* This differs from {@link lookup_tree} in that no attempts
* are made to fetch an object from the ODB.
*/
public object_id? tree_id {
[CCode(cname = "git_commit_tree_oid")]
get;
}
/**
* Get the commit object that is an ancestor of the named commit object,
* following only the first parents.
*
* @param ancestor the ancestor received, if any
* @param n the requested generation, or 0 for a copy of the commit.
*/
[CCode(cname = "git_commit_nth_gen_ancestor", instance_pos = 1.2)]
public Error get_ancestor(out Commit? ancestor, uint n);

/**
* The message of a commit converted to UTF-8.
*/
public string get_message_utf8() throws GLib.ConvertError {
return this.message_encoding == null ? this.message : GLib.convert(this.message, this.message.length, "utf-8", this.message_encoding);
}

/**
* Get the tree pointed to by a commit.
*/
[CCode(cname = "git_commit_tree", instance_pos = -1)]
public Error lookup_tree(out Tree tree);
}

/**
* Memory representation of a set of config files
*/
[CCode(cname = "git_config", free_function = "git_config_free", has_type_id = false)]
[Compact]
public class Config {
/**
* Allocate a new configuration object
*
* This object is empty, so you have to add a file to it before you can do
* anything with it.
*
* @param config the new configuration
*/
[CCode(cname = "git_config_new")]
public static Error create(out Config config);

/**
* Locate the path to the global configuration file
*
* The user or global configuration file is usually located in
* //$HOME/.gitconfig//.
*
* This method will try to guess the full path to that file, if the file
* exists. The returned path may be used on any call to load the global
* configuration file.
*
* @param config_path Buffer store the path
* @return {@link Error.OK} if a global configuration file has been found.
*/
[CCode(cname = "git_config_find_global")]
public static Error find_global([CCode(array_length_type = "size_t")] char[] config_path);
/**
* Locate the path to the global xdg compatible configuration file
*
* The xdg compatible configuration file is usually located in
* //$HOME/.config/git/config//.
*
* This method will try to guess the full path to that file, if the file
* exists.
* @param config_path Buffer store the path
* @return {@link Error.OK} if an XDG configuration file has been found.
*/
[CCode(cname = "git_config_find_xdg")]
public static Error find_xdg([CCode(array_length_type = "size_t")] char[] config_path);

/**
* Locate the path to the system configuration file
*
* If /etc/gitconfig doesn't exist, it will look for
* %PROGRAMFILES%\Git\etc\gitconfig.
* @param config_path Buffer of {@link PATH_MAX} length to store the path
* @return {@link Error.OK} if a system configuration file has been found. Its path will be stored in //buffer//.
*/
[CCode(cname = "git_config_find_system")]
public static Error find_system([CCode(array_length_type = "size_t")] char[] config_path);


/**
* Maps a string value to an integer constant
*/
[CCode(cname = "git_config_lookup_map_value")]
public static Error lookup_map_value(out int result, [CCode(array_length_type = "size_t")] config_var_map[] map, string name);

/**
* Create a new config instance containing a single on-disk file
*
* This method is a simple utility wrapper for the following sequence of
* calls:
* * {@link create}
* * {@link add_filename}
*
* @param cfg the configuration instance to create
* @param path path to the on-disk file to open
*/
[CCode(cname = "git_config_open_ondisk")]
public static Error open(out Config? cfg, string path);

/**
* Open the global and system configuration files
*
* Utility wrapper that calls {@link find_global}, {@link find_xdg}, and
* {@link find_system} and opens the located file, if it exists.
*
* @param config where to store the config instance
*/
[CCode(cname = "git_config_open_default")]
public static Error open_default(out Config? config);

/**
* Build a single-level focused config object from a multi-level one.
*
* The returned config object can be used to perform get/set/delete
* operations on a single specific level.
*
* Getting several times the same level from the same parent multi-level
* config will return different config instances, but containing the same
* config_file instance.
*
* @param parent Multi-level config to search for the given level
* @param level Configuration level to search for
*/
[CCode(cname = "git_config_open_level")]
public static Error open_level(out Config? config, Config parent, ConfigLevel level);

/**
* Parse a string value as a bool.
*
* Valid values for true are: 'true', 'yes', 'on', 1 or any number
* different from 0
*
* Valid values for false are: 'false', 'no', 'off', 0
*/
[CCode(cname = "git_config_parse_bool")]
public static Error bool(out bool result, string @value);

/**
* Parse a string value as an int32.
*
* An optional value suffix of 'k', 'm', or 'g' will cause the value to be
* multiplied by 1024, 1048576, or 1073741824 prior to output.
*/
[CCode(cname = "git_config_parse_int32")]
public static Error parse_int32(out int32 result, string @value);

/**
* Parse a string value as an int64.
*
* An optional value suffix of 'k', 'm', or 'g' will cause the value to be
* multiplied by 1024, 1048576, or 1073741824 prior to output.
*/
[CCode(cname = "git_config_parse_int64")]
public static Error parse_int64(out int64 result, string @value);

/**
* Add a generic config file instance to an existing config
*
* Further queries on this config object will access each of the config
* file instances in order (instances with a higher priority will be
* accessed first).
*
* @param backend the configuration file (backend) to add
* @param level the priority level of the backend
* @param force if a config file already exists for the given priority level, replace it
*/
[CCode(cname = "git_config_add_backend")]
public Error add_backend(Configuration.backend backend, ConfigLevel level, bool force);

/**
* Add an on-disk config file instance to an existing config
*
* The on-disk file pointed at by path will be opened and parsed; it's
* expected to be a native Git config file following the default Git config
* syntax (see man git-config).
*
* Further queries on this config object will access each of the config
* file instances in order (instances with a higher priority will be
* accessed first).
*
* @param path path to the configuration file (backend) to add
* @param level the priority the backend should have
*/
[CCode(cname = "git_config_add_file_ondisk")]
public Error add_filename(string path, ConfigLevel level, bool force);

/**
* Delete a config variable
*
* @param name the variable to delete
*/
[CCode(cname = "git_config_delete_entry")]
public Error delete(string name);

/**
* Perform an operation on each config variable.
*
* The callback receives the normalized name and value of each variable in
* the config backend. As soon as one of the callback functions returns
* something other than 0, this function returns that value.
*
* @param config_for_each the function to call on each variable
*/
[CCode(cname = "git_config_foreach")]
public int for_each(ConfigForEach config_for_each);
/**
* Perform an operation on each config variable matching a regular expression.
*
* This behaviors like {@link for_each} with an additional filter of a
* regular expression that filters which config keys are passed to the
* callback.
*
* @param regexp regular expression to match against config names
* @param config_for_each the function to call on each variable
* @return 0 or the return value of the callback which didn't return 0
*/
[CCode(cname = "git_config_foreach_match")]
public int for_each_match(string regexp, ConfigForEach config_for_each);

/**
* Get the value of a boolean config variable.
*
* @param name the variable's name
* @param value where the value should be stored
*/
[CCode(cname = "git_config_get_bool")]
public Error get_bool(string name, out bool value);

/**
* Get the entry of a config variable.
* @param name the variable's name
*/
[CCode(cname = "git_config_get_entry", instance_pos = 1.1)]
public Error get_entry(out unowned config_entry? entry, string name);

/**
* Get the value of an integer config variable.
*
* @param name the variable's name
* @param value where the value should be stored
*/
[CCode(cname = "git_config_get_int")]
public Error get_int32(string name, out int32 value);

/**
* Get the value of a long integer config variable.
*
* @param name the variable's name
* @param value where the value should be stored
*/
[CCode(cname = "git_config_get_int64")]
public Error get_int64(string name, out int64 value);

/**
* Get each value of a multivar.
*
* The callback will be called on each variable found
*
* @param name the variable's name
* @param regexp regular expression to filter which variables we're interested in. Use NULL to indicate all
* @param fn the function to be called on each value of the variable
*/
[CCode(cname = "git_config_get_multivar")]
public Error get_multivar(string name, string? regexp, Configuration.Setter fn);

/**
* Get the value of a string config variable.
*
* @param name the variable's name
* @param value the variable's value
*/
public Error get_string(string name, out unowned string value);

/**
* Reload changed config files
*
* A config file may be changed on disk out from under the in-memory config
* object. This function causes us to look for files that have been
* modified since we last loaded them and refresh the config with the
* latest information.
*/
[CCode(cname = "git_config_refresh")]
public Error refresh();
/**
* Set the value of a boolean config variable.
*
* @param name the variable's name
* @param value the value to store
*/
[CCode(cname = "git_config_set_bool")]
public Error set_bool(string name, bool value);

/**
* Set the value of an integer config variable.
*
* @param name the variable's name
* @param value integer value for the variable
*/
[CCode(cname = "git_config_set_int32")]
public Error set_int32(string name, int32 value);

/**
* Set the value of a long integer config variable.
*
* @param name the variable's name
* @param value Long integer value for the variable
*/
[CCode(cname = "git_config_set_long64")]
public Error set_int64(string name, int64 value);

/**
* Set a multivar
*
* @param name the variable's name
* @param regexp a regular expression to indicate which values to replace
* @param value the new value.
*/
[CCode(cname = "git_config_set_multivar")]
public Error set_multivar(string name, string regexp, string @value);
/**
* Set the value of a string config variable.
*
* A copy of the string is made and the user is free to use it
* afterwards.
*
* @param name the variable's name
* @param value the string to store.
*/
[CCode(cname = "git_config_set_string")]
public Error set_string(string name, string value);
/**
* Query the value of a config variable and return it mapped to an integer
* constant.
*
* This is a helper method to easily map different possible values to a
* variable to integer constants that easily identify them.
*
* A mapping array looks as follows:
* {{{
* var autocrlf_mapping = Git.config_var_map[] {
* {Git.ConfigVar.FALSE, null, GIT_AUTO_CRLF_FALSE},
* {Git.ConfigVar.TRUE, null, GIT_AUTO_CRLF_TRUE},
* {Git.ConfigVar.STRING, "input", GIT_AUTO_CRLF_INPUT},
* {Git.ConfigVar.STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
* }}}
*
* On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
* mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
*
* The same thing applies for any "true" value such as "true", "yes" or "1", storing
* the `GIT_AUTO_CRLF_TRUE` variable.
*
* Otherwise, if the value matches the string "input" (with case insensitive comparison),
* the given constant will be stored in `out`, and likewise for "default".
*
* If not a single match can be made to store in `out`, an error code will be
* returned.
*
* @param name name of the config variable to lookup
* @param map array of objects specifying the possible mappings
* @param result place to store the result of the mapping
*/
[CCode(cname = "git_config_get_mapped", instance_pos = 1.1)]
public Error get_mapped(out int result, string name, [CCode(array_length_type = "size_t")] config_var_map[] map);

}
/**
* The diff list object that contains all individual file deltas.
*/
[CCode(cname = "git_diff_list", free_function = "git_diff_list_free")]
[Compact]
public class DiffList {
/**
* How many diff records are there in a diff list.
*/
public size_t num_deltas {
[CCode(cname = "git_diff_num_deltas")]
get;
}
/**
* Query how many diff records are there in a diff list.
* @param delta_t A delta type to filter the count, or -1 for all records
* @return Count of number of deltas matching delta_t type
*/
[CCode(cname = "git_diff_num_deltas_of_type")]
public size_t get_count(DeltaType delta_t = DeltaType.ALL);
/**
* Return the diff delta and patch for an entry in the diff list.
*
* For an unchanged file or a binary file, no patch will be created, and
* the {@link diff_delta.flags} will contain {@link DiffFlag.BINARY}.
*
* @param patch contains the text diffs for the delta.
* @param delta Output parameter for the delta object
* @param idx Index into diff list
*/
[CCode(cname = "git_diff_get_patch", instance_pos = 2.1)]
public Error get_patch(out Patch? patch, out unowned diff_delta? delta, size_t idx);
/**
* Merge one diff list into another.
*
* This merges items from the "from" list into the current list. The
* resulting diff list will have all items that appear in either list.
* If an item appears in both lists, then it will be "merged" to appear
* as if the old version was from the "onto" list and the new version
* is from the "from" list (with the exception that if the item has a
* pending DELETE in the middle, then it will show as deleted).
*
* @param from Diff to merge.
*/
[CCode(cname = "git_diff_merge")]
public Error merge(DiffList from);

/**
* Iterate over a diff list issuing callbacks.
*
* If the hunk and/or line callbacks are not null, then this will calculate
* text diffs for all files it thinks are not binary. If those are both
* null, then this will not bother with the text diffs, so it can be
* efficient.
*/
[CCode(cname = "git_diff_foreach", simple_generics = true)]
public Error foreach<T>(DiffFile<T>? file, DiffHunk<T> hunk, DiffLine<T>? line, T context);

/**
* Iterate over a diff generating text output like "git diff --name-status".
*/
[CCode(cname = "git_diff_print_compact")]
public Error print_compact(DiffOutput print);

/**
* Iterate over a diff generating text output like "git diff".
*
* This is a super easy way to generate a patch from a diff.
*/
[CCode(cname = "git_diff_print_patch")]
public Error print_patch(DiffOutput print);
/**
* Transform a diff list marking file renames, copies, etc.
*
* This modifies a diff list in place, replacing old entries that look like
* renames or copies with new entries reflecting those changes. This also
* will, if requested, break modified files into add/remove pairs if the
* amount of change is above a threshold.
*
* @param options Control how detection should be run, null for defaults
*/
[CCode(cname = "git_diff_find_similar")]
public Error find_similar(find_options? options = null);
}

[CCode(cname = "git_error", has_type_id = false, free_function = "")]
public class ErrorInfo {
/**
* The explanation of the error.
*/
public string message;
/**
* The error code.
*/
[CCode(cname = "klass")]
public ErrClass @class;
/**
* Return a detailed error string with the latest error
* that occurred in the library in this thread.
*/
[CCode(cname = "giterr_last")]
public static unowned ErrorInfo? get_last();

/**
* Clear the last library error for this thread.
*/
[CCode(cname = "giterr_clear")]
public static void clear();
}


/**
* Object ID Shortener object
*/
[CCode(cname = "git_oid_shorten", free_function = "git_oid_shorten_free", has_type_id = false)]
[Compact]
public class IdShortener {
/**
* Create a new id shortener.
*
* The id shortener is used to process a list of ids in text form and
* return the shortest length that would uniquely identify all of them.
*
* (e.g., look at the result of //git log --abbrev//)
*
* @param min_length The minimal length for all identifiers, which will be used even if shorter ids would still be unique.
*/
[CCode(cname = "git_oid_shorten_new")]
public IdShortener(size_t min_length);

/**
* Add a new id to set of shortened ids and calculate the minimal length to
* uniquely identify all the ids in the set.
*
* The id is expected to be a 40-char hexadecimal string.
*
* For performance reasons, there is a hard-limit of how many ids can be
* added to a single set (around ~22000, assuming a mostly randomized
* distribution), which should be enough for any kind of program, and keeps
* the algorithm fast and memory-efficient.
*
* Attempting to add more than those ids will result in a {@link ErrClass.NOMEMORY} error
*
* @param text_id an id in text form
* @return the minimal length to uniquely identify all ids added so far to the set; or an error code (<0) if an error occurs.
*/
[CCode(cname = "git_oid_shorten_add")]
public int add(string text_id);
}

/**
* Memory representation of an index file.
*/
[CCode(cname = "git_index", free_function = "git_index_free", has_type_id = false)]
[Compact]
public class Index {
/**
* Index capabilities flags.
*/
public IndexCapability capability {
[CCode(cname = "git_index_caps")]
get;
[CCode(cname = "git_index_set_caps")]
set;
}

/**
* Does the index contains entries representing file conflicts?
*/
public bool has_conflicts {
[CCode(cname = "git_index_has_conflicts")]
get;
}

public ReucIndex reuc {
[CCode(cname = "")]
get;
}

/**
* The repository this index relates to
*/
public Repository owner {
[CCode(cname = "git_index_owner")]
get;
}

/**
* The count of entries currently in the index
*/
public uint size {
[CCode(cname = "git_index_entrycount")]
get;
}

/**
* Create an in-memory index object.
*
* This index object cannot be read/written to the filesystem,
* but may be used to perform in-memory index operations.
*
* The index must be freed once it's no longer in use.
*/
[CCode(cname = "git_index_new")]
public static Error create(out Index? index);
/**
* Create a new bare Git index object as a memory representation of the Git
* index file in the index path, without a repository to back it.
*
* Since there is no ODB or working directory behind this index, any index
* methods which rely on these (e.g., {@link add}) will fail.
*
* If you need to access the index of an actual repository, use {@link Repository.get_index}.
*
* @param index where to put the new index
* @param index_path the path to the index file in disk
*/
public static Error open(out Index index, string index_path);

/**
* Add or update an index entry from an in-memory struct
*
* A full copy (including the path string) of the given source will be
* inserted on the index.
*
* @param entry new entry object
*/
[CCode(cname = "git_index_add")]
public Error add(IndexEntry entry);

/**
* Add (append) an index entry from a file on disk
*
* A new entry will always be inserted into the index; if the index already
* contains an entry for such path, the old entry will ''not'' be replaced.
*
* The file path must be relative to the repository's working folder and
* must be readable.
*
* This method will fail in bare index instances.
*
* This forces the file to be added to the index, not looking at gitignore
* rules.
*
* If this file currently is the result of a merge conflict, this file will
* no longer be marked as conflicting. The data about the conflict will be
* moved to the "resolve undo" (REUC) section.
*
* @param path filename to add
*/
[CCode(cname = "git_index_add_bypath")]
public Error add_path(string path);

/**
* Clear the contents (all the entries) of an index object.
*
* This clears the index object in memory; changes must be manually written
* to disk for them to take effect.
*/
[CCode(cname = "git_index_clear")]
public void clear();

/**
* Add or update index entries to represent a conflict
*
* The entries are the entries from the tree included in the merge. Any
* entry may be null to indicate that that file was not present in the
* trees during the merge. For example, the ancestor entry may be null to
* indicate that a file was added in both branches and must be resolved.
*
* @param ancestor_entry the entry data for the ancestor of the conflict
* @param our_entry the entry data for our side of the merge conflict
* @param their_entry the entry data for their side of the merge conflict
*/
[CCode(cname = "git_index_conflict_add")]
public Error conflict_add(IndexEntry? ancestor_entry, IndexEntry? our_entry, IndexEntry? their_entry);

/**
* Get the index entries that represent a conflict of a single file.
*
* The values of this entry can be modified (except the paths)
* and the changes will be written back to disk on the next
* write() call.
*
* @param ancestor Pointer to store the ancestor entry
* @param our Pointer to store the our entry
* @param their Pointer to store the their entry
* @param path path to search
*/
[CCode(cname = "git_index_conflict_get", instance_pos = 3.1)]
public Error conflict_get(out unowned IndexEntry? ancestor, out unowned IndexEntry? our, out unowned IndexEntry? their, string path);

/**
* Remove all conflicts in the index (entries with a stage greater than 0.)
*/
[CCode(cname = "git_index_conflict_cleanup")]
public void conflict_cleanup();
/**
* Removes the index entries that represent a conflict of a single file.
*
* @param path to search
*/
[CCode(cname = "git_index_conflict_remove")]
public Error conflict_remove(string path);

/**
* Find the first index of any entries which point to given path in the Git
* index.
*
* @param at_pos the address to which the position of the reuc entry is written (optional)
* @param path path to search
*/
[CCode(cname = "git_index_find", instance_pos = 1.1)]
public Error find(out size_t at_pos, string path);

/**
* Get a pointer to one of the entries in the index
*
* This entry can be modified, and the changes will be written back to disk
* on the next {@link write} call.
*
* @param n the position of the entry
* @return the entry; null if out of bounds
*/
[CCode(cname = "git_index_get_byindex")]
public unowned IndexEntry? get(size_t n);

/**
* Get a pointer to one of the entries in the index
*
* The values of this entry can be modified (except the path) and the
* changes will be written back to disk on the next {@link write} call.
*
* @param path path to search
* @param stage stage to search
*/
[CCode(cname = "git_index_get_bypath")]
public unowned IndexEntry? get_by_path(string path, int stage);

/**
* Remove all entries with equal path except last added
*/
[CCode(cname = "git_index_uniq")]
public void make_unique();

/**
* Update the contents of an existing index object in memory by reading
* from the hard disk.
*/
[CCode(cname = "git_index_read")]
public Error read();

/**
* Read a tree into the index file with stats
*
* The current index contents will be replaced by the specified tree.
*
* @param tree tree to read
*/
[CCode(cname = "git_index_read_tree")]
public Error read_tree(Tree tree);

/**
* Remove an entry from the index
*/
[CCode(cname = "git_index_remove")]
public Error remove(string path, int stage);
/**
* Remove all entries from the index under a given directory
*
* @param dir container directory path
* @param stage stage to search
*/
[CCode(cname = "git_index_remove_directory")]
public Error remove_directory(string dir, int stage);

/**
* Remove an index entry corresponding to a file on disk
*
* The file path must be relative to the repository's working folder. It
* may exist.
*
* If this file currently is the result of a merge conflict, this file will
* no longer be marked as conflicting. The data about the conflict will be
* moved to the "resolve undo" (REUC) section.
*
* @param path filename to remove
*/
[CCode(cname = "git_index_remove_bypath")]
public Error remove_path(string path);

/**
* Write an existing index object from memory back to disk using an atomic
* file lock.
*/
[CCode(cname = "git_index_write")]
public Error write();

/**
* Write the index as a tree
*
* This method will scan the index and write a representation of its
* current state back to disk; it recursively creates
* tree objects for each of the subtrees stored in the index, but only
* returns the OID of the root tree. This is the OID that can be used e.g.
* to create a commit.
*
* The index instance cannot be bare, and needs to be associated to an
* existing repository.
*
* The index must not contain any file in conflict.
*/
[CCode(cname = "git_index_write_tree", instance_pos = -1)]
public Error write_tree(out object_id id);

/**
* Write the index as a tree to the given repository
*
* This method will do the same as {@link write_tree}, but letting the user
* choose the repository where the tree will be written.
*
* The index must not contain any file in conflict.
*
* @param id Pointer where to store OID of the the written tree
* @param repo Repository where to write the tree
*/
[CCode(cname = "git_index_write_tree_to", instance_pos = 1.1)]
public Error write_tree_to(out object_id id, Repository repo);

}

[CCode(cname = "git_indexer_stream", free_function = "git_indexer_stream_free", has_type_id = false)]
public class IndexerStream {
/**
* The packfile's hash
*
* A packfile's name is derived from the sorted hashing of all object
* names. This is only correct after the index has been finalized.
*/
public object_id? hash {
[CCode(cname = "git_indexer_stream_hash")]
get;
}
/**
* Create a new streaming indexer instance
*
* @param indexer_stream where to store the indexer instance
* @param path to the directory where the packfile should be stored
*/
[CCode(cname = "git_indexer_stream_new")]
public static Error open(out IndexerStream indexer_stream, string path, TransferProgress transfer);

/**
* Add data to the indexer
*
* @param data the data to add
* @param stats stat storage
*/
[CCode(cname = "git_indexer_stream_add")]
public Error add([CCode(array_length_type = "size_t")] uint8[] data, transfer_progress stats);

/**
* Finalize the pack and index
*
* Resolve any pending deltas and write out the index file
*/
[CCode(cname = "git_indexer_stream_finalize")]
public Error finalize(transfer_progress stats);
}

/**
* Memory representation of a file entry in the index.
*/
[CCode(cname = "git_index_entry", has_type_id = false)]
[Compact]
public class IndexEntry {
public Attributes flags;
public index_time ctime;
public index_time mtime;
public int64 file_size;
[CCode(cname = "oid")]
public object_id id;
public string path;
public uint16 flags_extended;
public uint dev;
public uint gid;
public uint ino;
public uint mode;
public uint uid;

/**
* The stage number from a git index entry
*/
public int stage {
[CCode(cname = "git_index_entry_stage")]
get;
}
}
/**
* A note attached to an object
*/
[CCode(cname = "git_note", free_function = "git_note_free", has_type_id = false)]
[Compact]
public class Note {
/**
* The message for this note
*/
public string message {
[CCode(cname = "git_note_message")]
get;
}

/**
* The note object OID
*/
public object_id? id {
[CCode(cname = "git_note_oid")]
get;
}
}
[CCode(cname = "git_note_iterator ", free_function = "git_note_iterator_free", has_type_id = false)]
[Compact]
public class NoteIterator {
/**
* Returns the current item and advance the iterator internally to the next
* value.
*/
[CCode(cname = "git_note_next", instance_pos = -1)]
public Error next(out object_id note_id, out object_id annotated_id);
}
/**
* Representation of a generic object in a repository
*/
[CCode(cname = "git_object", free_function = "git_object_free", has_type_id = false)]
[Compact]
public class Object {
/**
* The id (SHA1) of a repository object
*/
public object_id? id {
[CCode(cname = "git_object_id")]
get;
}

/**
* The object type of an object
*/
public ObjectType type {
[CCode(cname = "git_object_type")]
get;
}

/**
* The repository that owns this object
*/
public Repository repository {
[CCode(cname = "git_object_owner")]
get;
}
/**
* Recursively peel an object until an object of the specified type is met
*
* @param target_type The type of the requested object
*/
[CCode(cname = "git_object_peel", instance_pos = 1.1)]
public Error peel(out Object? peeled, ObjectType target_type);
}

[Compact]
[CCode(cname = "git_packbuilder", free_function = "git_packbuilder_free", has_type_id = false)]
public class PackBuilder {

/**
* The total number of objects the packbuilder will write out
*/
public uint32 count {
[CCode(cname = "packbuilder_object_count")]
get;
}
/**
* The number of objects the packbuilder has already written out
*/
public uint32 written {
[CCode(cname = "git_packbuilder_written")]
get;
}

/**
* Set number of threads to spawn
*
* By default, libgit2 won't spawn any threads at all; when set to 0,
* libgit2 will autodetect the number of CPUs.
*
* @param n Number of threads to spawn
* @return number of actual threads to be used
*/
[CCode(cname = "git_packbuilder_set_threads")]
public uint set_threads(uint n);

/**
* Insert a single object
*
* For an optimal pack it's mandatory to insert objects in recency order,
* commits followed by trees and blobs.
*
* @param id The oid of the commit
* @param name The name
*/
[CCode(cname = "git_packbuilder_insert")]
public Error insert(object_id id, string? name);
/**
* Insert a root tree object
*
* This will add the tree as well as all referenced trees and blobs.
*
* @param id The oid of the root tree
*/
[CCode(cname = "git_packbuilder_insert_tree")]
public Error insert_tree(object_id id);

/**
* Write the new pack and the corresponding index to path
*
* @param path Directory to store the new pack and index
*/
[CCode(cname = "git_packbuilder_write")]
public Error write(string path);

/**
* Create the new pack and pass each object to the callback
*/
[CCode(cname = "git_packbuilder_foreach")]
public Error for_each(PackBuilderForEach pack_builder_for_each);
}
/**
* The list of parents of a commit
*/
[Compact]
[CCode(cname = "git_commit", has_type_id = false)]
public class Parents {
/**
* Get the number of parents of this commit
*/
public uint size {
[CCode(cname = "git_commit_parentcount")]
get;
}

/**
* Get the id of a specified parent for a commit.
*
* This is different from {@link Parents.lookup}, which will attempt
* to load the parent commit from the ODB.
*
* @param n the position of the parent
* @return the id of the parent, null on error.
*/
[CCode(cname = "git_commit_parent_id")]
public unowned object_id? get(uint n);

/**
* Get the specified parent of the commit.
*
* @param parent where to store the parent commit
* @param n the position of the parent
*/
[CCode(cname = "git_commit_parent", instance_pos = 1.2)]
public Error lookup(out Commit parent, uint n);
}
[CCode(cname = "git_diff_patch ", free_function = "git_diff_patch_free", has_type_id = false)]
[Compact]
public class Patch {
/**
* The delta associated with a patch
*/
public diff_delta? delta {
[CCode(cname = "git_diff_patch_delta")]
get;
}
/**
* The number of hunks in a patch
*/
public size_t num_hunks {
[CCode(cname = "git_diff_patch_num_hunks")]
get;
}
/**
* Get the information about a hunk in a patch
*
* Given a patch and a hunk index into the patch, this returns detailed
* information about that hunk. Any of the output pointers can be passed
* as NULL if you don't care about that particular piece of information.
*
* @param range Range of the hunk
* @param header Header string for hunk. Unlike the content for each line,
* this will be NUL-terminated
* @param lines_in_hunk Count of total lines in this hunk
* @param hunk_idx Input index of hunk to get information about
*/
[CCode(cname = "git_diff_patch_get_hunk", instance_pos = 3.1)]
public Error get_hunk(out unowned diff_range? range, [CCode(array_length_type = "size_t")] out unowned uint8[]? header, out size_t lines_in_hunk, size_t hunk_idx);
/**
* Get data about a line in a hunk of a patch.
*
* Given a patch, a hunk index, and a line index in the hunk, this will
* return a lot of details about that line. If you pass a hunk index
* larger than the number of hunks or a line index larger than the number
* of lines in the hunk, this will return -1.
*
* @param old_lineno Line number in old file or -1 if line is added
* @param new_lineno Line number in new file or -1 if line is deleted
* @param hunk_idx The index of the hunk
* @param line_of_hunk The index of the line in the hunk
*/
[CCode(cname = "git_diff_patch_get_line_in_hunk", instance_pos = 4.1)]
public Error get_line_in_hunk(out DiffLineType line_origin, [CCode(array_length_type = "size_t")] out unowned uint8[]? content, out int old_lineno, out int new_lineno, size_t hunk_idx, size_t line_of_hunk);
/**
* Get line counts of each type in a patch.
*
* This helps imitate a '''diff --numstat''' type of output. For that
* purpose, you only need the total additions and total_deletions values,
* but we include the total context line count in case you want the total
* number of lines of diff output that will be generated.
*
* @param total_context Count of context lines in output.
* @param total_additions Count of addition lines in output.
* @param total_deletions Count of deletion lines in output.
* @return Number of lines in hunk or -1 if invalid hunk index
*/
[CCode(cname = "git_diff_patch_line_stats", instance_pos = -1)]
public int get_line_stats(out size_t total_context, out size_t total_additions, out size_t total_deletions);

/**
* Get the number of lines in a hunk.
*
* @param hunk_idx Index of the hunk
* @return Number of lines in hunk or -1 if invalid hunk index
*/
[CCode(cname = "git_diff_patch_num_lines_in_hunk")]
public int num_lines_in_hunk(size_t hunk_idx);

/**
* Serialize the patch to text via callback.
*/
[CCode(cname = "git_diff_patch_print")]
public Error patch_print(DiffOutput print);

/**
* Get the content of a patch as a single diff text.
*/
[CCode(cname = "git_diff_patch_to_str", instance_pos = -1)]
public Error to_str(out string str);

public string? to_string() {
string str;
return to_str(out str) == Error.OK ? str : null;
}
}
[Compact]
[CCode(cname = "git_push", free_function = "git_push_free", has_type_id = false)]
public class Push {
/**
* Check if remote side successfully unpacked
*/
public bool unpack_ok {
[CCode(cname = "git_push_unpack_ok")]
get;
}

/**
* Add a refspec to be pushed
*/
[CCode(cname = "git_push_add_refspec")]
public Error add_refspec(string refspec);

/**
* Actually push all given refspecs
*
* To check if the push was successful (i.e. all remote references have
* been updated as requested), you need to call both {@link unpack_ok} and
* {@link for_each}. The remote repository might have refused to update
* some or all of the references.
*/
[CCode(cname = "git_push_finish")]
public Error finish();
/**
* Iterate over each status.
*
* For each of the updated references, we receive a status report in the
* form of '''ok refs/heads/master''' or '''ng refs/heads/master ///msg///'''.
* If the message is not null, this means the reference has not been
* updated for the given reason.
*
*/
[CCode(cname = "git_push_status_foreach")]
public Error for_each(PushForEach push_for_each);
/**
* Set options on a push object
*
* @param opts The options to set on the push object
*/
[CCode(cname = "git_push_set_options")]
public Error set_options(push_options opts);
/**
* Update remote tips after a push
*/
[CCode(cname = "git_push_update_tips")]
public Error update_tips();
}
[CCode(cname = "git_refdb", has_type_id = false, free_function = "git_refdb_free")]
public class RefDb {
/**
* Create a new reference. Either an oid or a symbolic target must be
* specified.
*
* @param name the reference name
* @param id the object id for a direct reference
* @param symbolic the target for a symbolic reference
*/
[CCode(cname = "git_reference__alloc")]
public Reference? alloc(string name, object_id id, string symbolic);

/**
* Suggests that the given refdb compress or optimize its references.
*
* This mechanism is implementation specific. For on-disk reference
* databases, for example, this may pack all loose references.
*/
[CCode(cname = "git_refdb_compress")]
public Error compress();

/**
* Sets the custom backend to an existing reference DB
*/
[CCode(cname = "git_refdb_set_backend")]
public Error set_backend(owned refdb_backend backend);
}
/**
* In-memory representation of a reference.
*/
[CCode(cname = "git_reference", free_function = "git_reference_free", has_type_id = false)]
[Compact]
public class Reference {
/**
* Check if a reflog exists for the specified reference.
*/
public bool has_log {
[CCode(cname = "git_reference_has_log")]
get;
}
/**
* Check if a reference is a local branch.
*/
public bool is_branch {
[CCode(cname = "git_reference_is_branch")]
get;
}

/**
* Determine if the current local branch is pointed at by HEAD.
*/
public bool is_head {
[CCode(cname = "0 != git_branch_is_head")]
get;
}

/**
* If a reference is a remote tracking branch
*/
public bool is_remote {
[CCode(cname = "git_reference_is_remote")]
get;
}

/**
* The full name of a reference
*/
public string name {
[CCode(cname = "git_reference_name")]
get;
}

/**
* The repository where a reference resides
*/
public Repository repository {
[CCode(cname = "git_reference_owner")]
get;
}

/**
* The full name to the reference pointed by this reference
*
* Only available if the reference is symbolic
*/
public string? symbolic_target {
[CCode(cname = "git_reference_symbolic_target")]
get;
}

/**
* The id pointed to by a reference.
*
* Only available if the reference is direct (i.e., not symbolic)
*/
public object_id? target {
[CCode(cname = "git_reference_target")]
get;
}

/**
* The type of a reference
*
* Either direct, {@link ReferenceType.ID}, or symbolic, {@link ReferenceType.SYMBOLIC}
*/
public ReferenceType type {
[CCode(cname = "git_reference_type")]
get;
}
/**
* Ensure the reference name is well-formed.
*
* Valid reference names must follow one of two patterns:
*
* 1. Top-level names must contain only capital letters and underscores,
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
* sequences ".." and "@{" which have special meaning to revparse.
*/
[CCode(cname = "git_reference_is_valid_name")]
public static bool is_valid_name(string refname);

/**
* Delete an existing branch reference.
*/
[CCode(cname = "git_branch_delete")]
public static Error delete_branch(owned Reference reference);
/**
* Normalize the reference name by removing any leading slash (/)
* characters and collapsing runs of adjacent slashes between name
* components into a single slash.
*
* Once normalized, if the reference name is valid, it will be returned in
* the user allocated buffer.

* @param buffer The buffer where the normalized name will be stored.
* @param name name to be checked.
* @param flags Flags to determine the options to be applied while checking
* the validatity of the name.
*/
[CCode(cname = "git_reference_normalize_name")]
public static Error normalize_name([CCode(array_length_type = "size_t")] uint8[] buffer, string name, ReferenceFormat flags);

/**
* Compare two references.
*
* @return 0 if the same, else a stable but meaningless ordering.
*/
[CCode(cname = "git_reference_cmp")]
public int compare(Reference other);

/**
* Delete an existing reference
*
* This method works for both direct and symbolic references.
*
* The reference will be immediately removed on disk.
*/
[CCode(cname = "git_reference_delete")]
public void @delete();

/**
* Delete the reflog for the given reference
*/
[CCode(cname = "git_reflog_delete")]
public Error delete_reflog();

/**
* Return the name of the given local or remote branch.
*
* The name of the branch matches the definition of the name for
* {@link Repository.lookup_branch}. That is, if the returned name is
* looked up then the reference is returned that was given to this
* function.
*
* @param name where the pointer of branch name is stored;
* this is valid as long as the ref is not freed.
*/
[CCode(cname = "git_branch_name", instance_pos = -1)]
public Error get_branch_name(out unowned string name);

/**
* Read the reflog for the given reference
*
* @param reflog where to put the reflog
*/
[CCode(cname = "git_reflog_read", instance_pos = -1)]
public Error get_reflog(out ReferenceLog? reflog);
/**
* Return the reference supporting the remote tracking branch, given a
* reference branch.
*
* The input reference has to be located in the '''refs/heads''' namespace.
*
*/
[CCode(cname = "git_reference_remote_tracking_from_branch", instance_pos = -1)]
public Error get_remote_tracking_from_branch(out Reference tracking_ref);
/**
* Return the reference supporting the remote tracking branch, given a
* local branch reference.
*/
[CCode(cname = "git_branch_tracking", instance_pos = -1)]
public Error get_tracking(out Reference? tracking);

/**
* Move/rename an existing branch reference.
*
* @param new_branch_name Target name of the branch once the move
* is performed; this name is validated for consistency.
*
* @param force Overwrite existing branch.
*/
[CCode(cname = "git_branch_move", instance_pos = 1.1)]
public Error move_branch(out Reference? moved, string new_branch_name, bool force);

/**
* Recursively peel an reference until an object of the specified type is
* met.
*
* If you pass {@link ObjectType.ANY} as the target type, then the object
* will be peeled until a non-tag object is met.
*
* @param target_type The type of the requested object
*/
[CCode(cname = "git_reference_peel", instance_pos = 1.1)]
public Error peel(out Object? peeled, ObjectType target_type);

/**
* Rename an existing reference
*
* This method works for both direct and symbolic references.
* The new name will be checked for validity and may be
* modified into a normalized form.
*
* The refernece will be immediately renamed in-memory
* and on disk.
*
* ''IMPORTANT:'' The user needs to write a proper reflog entry if the
* reflog is enabled for the repository. We only rename the reflog if it
* exists.
*
*/
[CCode(cname = "git_reference_rename", instance_pos = 1.1)]
public Error rename(out Reference? renamed_reference, string new_name, bool force);

/**
* Resolve a symbolic reference
*
* Thie method iteratively peels a symbolic reference
* until it resolves to a direct reference to an id.
*
* If a direct reference is passed as an argument,
* that reference is returned immediately
*
* @param resolved the peeled reference
*/
[CCode(cname = "git_reference_resolve", instance_pos = -1)]
public Error resolve(out Reference resolved);

/**
* Create a new reference with the same name as the given reference but a
* different symbolic target.
*
* The reference must be a symbolic reference, otherwise this will fail.
*
* The new reference will be written to disk, overwriting the given
* reference.
*
* @param id the new target id for the reference
*/
[CCode(cname = "git_reference_set_oid", instance_pos = 1.1)]
public Error set_target(out Reference? retargeted, object_id id);

/**
* Set the symbolic target of a reference.
*
* The reference must be a symbolic reference, otherwise this method will
* fail.
*
* The reference will be automatically updated in memory and on disk.
*
* @param target The new target for the reference
*/
[CCode(cname = "git_reference_symbolic_set_target")]
public Error set_symbolic_target(string target);
}

/**
* Representation of a reference log
*/
[CCode(cname = "git_reflog", free_function = "git_reflog_free", has_type_id = false)]
[Compact]
public class ReferenceLog {
/**
* The number of log entries in a reflog
*/
public size_t size {
[CCode(cname = "git_reflog_entrycount")]
get;
}

/**
* Add a new entry to the reflog.
*
* If there is no reflog file for the given reference yet, it will be
* created.
*
* @param id the id the reference is now pointing to
* @param committer the signature of the committer
* @param msg the reflog message
*/
[CCode(cname = "git_reflog_append")]
public Error append(out object_id id, Signature committer, string? msg = null);

/**
* Remove an entry from the reflog by its index
*
* To ensure there's no gap in the log history, when deleting an entry,
* member old_oid of the previous entry (if any) will be updated with the
* value of memeber new_oid of next entry.
*
* @param idx the position of the entry to remove.
*
* @param rewrite_previous_entry true to rewrite the history; 0 otherwise.
*
*/
[CCode(cname = "git_reflog_drop")]
public Error drop(size_t idx, bool rewrite_previous_entry);

/**
* Lookup an entry by its index
*
* @param idx the position to lookup
* @return the entry; null if not found
*/
[CCode(cname = "git_reflog_entry_byindex")]
public unowned ReferenceLogEntry? get(size_t idx);

/**
* Rename the reflog for the given reference
*
* @param new_name the new name of the reference
*/
[CCode(cname = "git_reflog_rename")]
public Error rename(string new_name);
/**
* Write an existing in-memory reflog object back to disk using an atomic
* file lock.
*
* If there is no reflog file for the given reference yet, it will be
* created.
*/
[CCode(cname = "git_reflog_write")]
public Error write();
}

/**
* Representation of a reference log entry
*/
[CCode(cname = "git_reflog_entry", has_type_id = false)]
[Compact]
public class ReferenceLogEntry {

/**
* The committer of this entry
*/
public Signature commiter {
[CCode(cname = "git_reflog_entry_committer")]
get;
}

/**
* The log message
*/
public string message {
[CCode(cname = "git_reflog_entry_msg")]
get;
}

/**
* The new id at this time
*/
public object_id? new_id {
[CCode(cname = "git_reflog_entry_id_new")]
get;
}

/**
* The old id
*/
public object_id? old_id {
[CCode(cname = "git_reflog_entry_id_old")]
get;
}
}

/**
* Reference to a remote repository
*/
[CCode(cname = "git_remote", free_function = "git_remote_free", has_type_id = false)]
[Compact]
public class Remote {
[CCode(cname = "git_remote_rename_problem_cb")]
public delegate bool RenameProblem(string problematic_refspec);
/**
* The tag auto-follow setting
*/
public AutoTag autotag {
[CCode(cname = "git_remote_autotag")]
get;
[CCode(cname = "git_remote_set_autotag")]
set;
}

/**
* Choose whether to check the server's certificate (applies to HTTPS only)
*/
public bool check_cert {
[CCode(cname = "git_remote_check_cert")]
set;
}

/**
* Whether the remote is connected
*
* Whether the remote's underlying transport is connected to the remote
* host.
*/
public bool is_connected {
[CCode(cname = "git_remote_connected")]
get;
}

/**
* The fetch refspec, if it exists
*/
public ref_spec? fetch_spec {
[CCode(cname = "git_remote_fetchspec")]
get;
[CCode(cname = "git_remote_set_fetchspec")]
set;
}

/**
* The remote's name
*/
public string? name {
[CCode(cname = "git_remote_name")]
get;
}

/**
* The push refspec, if it existsc
*/
public ref_spec? push_spec {
[CCode(cname = "git_remote_pushspec")]
get;
[CCode(cname = "git_remote_set_pushspec")]
set;
}

/**
* The statistics structure that is filled in by the fetch operation.
*/
public transfer_progress stats {
[CCode(cname = "git_remote_stats")]
get;
}

/**
* Update FETCH_HEAD on ever fetch.
*/
public bool update_fetchhead {
[CCode(cname = "git_remote_update_fetchhead")]
get;
[CCode(cname = "git_remote_set_update_fetchhead")]
set;
}
/**
* The remote's URL
*/
public string url {
[CCode(cname = "git_remote_url")]
get;
}

/**
* Ensure the remote name is well-formed.
*
* @param remote_name name to be checked.
*/
[CCode(cname = "git_remote_is_valid_name")]
public static bool is_valid_name(string remote_name);

/**
* Return whether a string is a valid remote URL
*
* @param url the url to check
*/
[CCode(cname = "git_remote_valid_url")]
public static bool is_valid_url(string url);

/**
* Return whether the passed URL is supported by this version of the library.
*
* @param url the url to check
*/
[CCode(cname = "git_remote_supported_url")]
public static bool is_supported_url(string url);
/**
* Create a new push object
*/
[CCode(cname = "git_push_new", instance_pos = -1)]
public Error create_push(out Push? push);

/**
* Open a connection to a remote
*
* The transport is selected based on the URL. The direction argument is
* due to a limitation of the git protocol (over TCP or SSH) which starts
* up a specific binary which can only do the one or the other.
*
* @param direction whether you want to receive or send data
*/
[CCode(cname = "git_remote_connect")]
public Error connect(Direction direction);

/**
* Download the packfile
*
* Negotiate what objects should be downloaded and download the packfile
* with those objects.
*/
[CCode(cname = "git_remote_download")]
public Error download(Progress progress);

/**
* Disconnect from the remote
*
* Close the connection to the remote and free the underlying transport.
*/
[CCode(cname = "git_remote_disconnect")]
public void disconnect();

/**
* Get a list of refs at the remote
*
* The remote (or more exactly its transport) must be connected.
*/
[CCode(cname = "git_remote_ls", instance_pos = -1)]
public Error list(Head headcb);

/**
* Give the remote a new name
*
* All remote-tracking branches and configuration settings for the remote
* are updated.
*
* The new name will be checked for validity.
*
* A temporary in-memory remote cannot be given a name with this method.
*
* @param new_name the new name the remote should bear
* @param rename_problem Optional callback to notify the consumer of fetch refspecs
* that haven't been automatically updated and need potential manual tweaking.
* @see Repository.create_tag
*/
[CCode(cname = "git_remote_rename")]
public Error rename(string new_name, RenameProblem? rename_problem = null);
/**
* Save a remote to its repository's configuration
*
* One can't save a in-memory remote. Doing so will result in a
* {@link Error.INVALIDSPEC} being returned.
*/
[CCode(cname = "git_remote_save")]
public Error save();
/**
* Set the callbacks for a remote
*/
[CCode(cname = "git_remote_set_callbacks", simple_generics = true)]
public Error set_callbacks<T>(remote_callbacks<T> callbacks);

/**
* Sets the owning repository for the remote. This is only allowed on
* dangling remotes.
*/
[CCode(cname = "git_remote_set_repository")]
public Error set_repository(Repository repo);

/**
* Sets a credentials acquisition callback for this remote.
*
* If the remote is not available for anonymous access, then you must set
* this callback in order to provide credentials to the transport at the
* time of authentication failure so that retry can be performed.
*/
[CCode(cname = "git_remote_set_cred_acquire_cb")]
public void set_cred_acquire(CredAcquire? cred_acquire);

/**
* Sets a custom transport for the remote. The caller can use this function
* to bypass the automatic discovery of a transport by URL scheme (i.e.,
* http, https, git) and supply their own transport to be used
* instead. After providing the transport to a remote using this function,
* the transport object belongs exclusively to that remote, and the remote will
* free it when it is freed with git_remote_free.
*
* @param transport the transport object for the remote to use
*/
[CCode(cname = "git_remote_set_transport")]
public Error set_transport(transport transport);

/**
* Cancel the operation
*
* At certain points in its operation, the network code checks whether the
* operation has been cancelled and if so stops the operation.
*/
[CCode(cname = "git_remote_stop")]
public void stop();

/**
* Update the tips to the new state
*
* Make sure that you only call this once you've successfully indexed or
* expanded the packfile.
*/
[CCode(cname = "git_remote_update_tips")]
public Error update_tips(Update update);
}

/**
* Representation of an existing git repository,
* including all its object contents
*/
[CCode(cname = "git_repository", free_function = "git_repository_free", has_type_id = false)]
[Compact]
public class Repository {
public Attr attributes {
[CCode(cname = "")]
get;
}
/**
* Check if a repository is bare
*/
public bool is_bare {
[CCode(cname = "git_repository_is_bare")]
get;
}
/**
* Check if a repository's HEAD is detached
*
* A repository's HEAD is detached when it points directly to a commit
* instead of a branch.
*/
public bool is_head_detached {
[CCode(cname = "git_repository_head_detached")]
get;
}

/**
* Check if the current branch is an orphan
*
* An orphan branch is one named from HEAD but which doesn't exist in
* the refs namespace, because it doesn't have any commit to point to.
*/
public bool is_head_orphan {
[CCode(cname = "git_repository_head_orphan")]
get;
}

/**
* Check if a repository is empty
*
* An empty repository has just been initialized and contains no commits.
*/
public bool is_empty {
[CCode(cname = "git_repository_is_empty")]
get;
}

/**
* The path to the repository.
*/
public string? path {
[CCode(cname = "git_repository_path")]
get;
}
/**
* Determines the status of a git repository (i.e., whether an operation
* such as a merge or cherry-pick is in progress).
*/
public State state {
[CCode(cname = "git_repository_state")]
get;
}

/**
* The working directory for this repository
*
* If the repository is bare, this is null.
*
* If this repository is bare, setting its working directory will turn it
* into a normal repository, capable of performing all the common workdir
* operations (checkout, status, index manipulation, etc).
*/
public string? workdir {
[CCode(cname = "git_repository_workdir")]
get;
set {
set_workdir(value, true);
}
}

/**
* Clone a remote repository, and checkout the branch pointed to by the remote
* HEAD.
*
* @param origin_url repository to clone from
* @param dest_path local directory to clone to
* @param clone_opts configuration options for the clone.
*/
[CCode(cname = "git_clone")]
public static Error clone(out Repository? repo, string origin_url, string dest_path, clone_opts? clone_opts = null);

/**
* Look for a git repository and copy its path in the given buffer. The lookup start
* from base_path and walk across parent directories if nothing has been found. The
* lookup ends when the first repository is found, or when reaching a directory
* referenced in ceiling_dirs or when the filesystem changes (in case across_fs
* is true).
*
* The method will automatically detect if the repository is bare (if there is
* a repository).
*
* @param repository_path The buffer which will contain the found path.
*
* @param start_path The base path where the lookup starts.
*
* @param across_fs If true, then the lookup will not stop when a filesystem device change
* is detected while exploring parent directories.
*
* @param ceiling_dirs A {@link PATH_LIST_SEPARATOR} separated list of absolute symbolic link free paths. The lookup will stop when any of this paths is reached. Note that the lookup always performs on //start_path// no matter start_path appears in //ceiling_dirs//. //ceiling_dirs// might be null, which is equivalent to an empty string.
*/
public static Error discover([CCode(array_length_type = "size_t")] char[] repository_path, string start_path, bool across_fs = true, string? ceiling_dirs = null);

/**
* Creates a new Git repository in the given folder.
*
* @param repo the repo which will be created or reinitialized
* @param path the path to the repository
* @param is_bare if true, a git repository without a working directory is created at the pointed path. If false, provided path will be considered as the working directory into which the //.git// directory will be created.
*/
[CCode(cname = "git_repository_init")]
public static Error init(out Repository repo, string path, bool is_bare);
/**
* Create a new Git repository in the given folder with extended controls.
*
* This will initialize a new git repository (creating the path if
* requested by flags) and working directory as needed. It will
* auto-detect the case sensitivity of the file system and if the file
* system supports file mode bits correctly.
*
* @param repo_path The path to the repository.
* @param opts Pointer to git_repository_init_options struct.
*/
[CCode(cname = "git_repository_init_ext")]
public static Error init_ext(out Repository? repo, string repo_path, init_options opts);

/**
* Open a git repository.
*
* The path argument must point to an existing git repository
* folder. The repository can be normal (having a //.git// directory)
* or bare (having objects, index, and HEAD directly).
* The method will automatically detect if path is a normal
* or bare repository or fail is path is neither.
*
* @param repository the repo which will be opened
* @param path the path to the repository
*/
[CCode(cname = "git_repository_open")]
public static Error open(out Repository? repository, string path);

/**
* Find and open a repository with extended controls.
*/
[CCode(cname = "git_repository_open_ext")]
public static Error open_ext(out Repository? repository, string start_path, OpenFlags flags, string ceiling_dirs);
/**
* Add ignore rules for a repository.
*
* Excludesfile rules (i.e. .gitignore rules) are generally read from
* .gitignore files in the repository tree or from a shared system file
* only if a "core.excludesfile" config value is set. The library also
* keeps a set of per-repository internal ignores that can be configured
* in-memory and will not persist. This function allows you to add to
* that internal rules list.
*
* @param rules Text of rules, a la the contents of a .gitignore file. It
* is okay to have multiple rules in the text; if so, each rule should be
* terminated with a newline.
*/
[CCode(cname = "git_ignore_add_rule")]
public Error add_ignore(string rules);
/**
* Set up a new git submodule for checkout.
*
* This does '''git submodule add''' up to the fetch and checkout of the
* submodule contents. It preps a new submodule, creates an entry in
* .gitmodules and creates an empty initialized repository either at the
* given path in the working directory or in .git/modules with a gitlink
* from the working directory to the new repo.
*
* To fully emulate '''git submodule add''' call this function, then open
* the submodule repo and perform the clone step as needed. Lastly, call
* {@link Submodule.add_finalize} to wrap up adding the new submodule and
* .gitmodules to the index to be ready to commit.
*
* @param submodule The newly created submodule ready to open for clone
* @param url URL for the submodules remote
* @param path Path at which the submodule should be created
* @param use_gitlink Should workdir contain a gitlink to the repo in
* .git/modules vs. repo directly in workdir.
*/
[CCode(cname = "git_submodule_add_setup", instance_pos = 1.1)]
public Error add_submodule_setup(out Submodule? submodule, string url, string path, bool use_gitlink);

/**
* Remove all the metadata associated with an ongoing git merge, including
* MERGE_HEAD, MERGE_MSG, etc.
*/
[CCode(cname = "git_repository_merge_cleanup")]
public Error cleanup_merge();

/**
* Clear ignore rules that were explicitly added.
*
* Resets to the default internal ignore rules. This will not turn off
* rules in .gitignore files that actually exist in the filesystem.
*
* The default internal ignores ignore '''.''', '''..''' and '''.git''' entries.
*/
public Error clear_internal_ignores();

/**
* Updates files in the index and the working tree to match the commit pointed to by HEAD.
*
* @param opts specifies checkout options
*/
[CCode(cname = "git_checkout_head")]
public Error checkout_head(checkout_opts? opts = null);
/**
* Updates files in the working tree to match the content of the index.
*
* @param opts specifies checkout options
* @param index index to be checked out (or null to use repository index)
*/
[CCode(cname = "git_checkout_index")]
public Error checkout_index(Index? index = null, checkout_opts? opts = null);
/**
* Updates files in the index and working tree to match the content of a
* tree.
*
* @param treeish a commit, tag or tree which content will be used to
* update the working directory
* @param opts specifies checkout options
*/
[CCode(cname = "git_checkout_tree")]
public Error checkout_tree(Object treeish, checkout_opts? opts = null);
/**
* Count the number of unique commits between two commit objects
*
* There is no need for branches containing the commits to have any
* upstream relationship, but it helps to think of one as a branch and the
* other as its upstream, the ahead and behind values will be what git
* would report for the branches.
*
* @param ahead number of unique commits in upstream
* @param behind number of unique commits in local
* @param local one of the commits
* @param upstream the other commit
*/
[CCode(cname = "git_graph_ahead_behind", instance_pos = 2.1)]
public Error count_ahead_behind(out size_t ahead, out size_t behind, object_id local, object_id upstream);
/**
* Write an in-memory buffer to the ODB as a blob
*
* @param id return the id of the written blob
* @param buffer data to be written into the blob
*/
[CCode(cname = "git_blob_create_frombuffer", instance_pos = 1.2)]
public Error create_blob_from_buffer(object_id id, [CCode(array_length_type = "size_t")] uint8[] buffer);
/**
* Write a loose blob to the Object Database from a provider of chunks of
* data.
*
* @param id Return the id of the written blob
* @param hint_path will help to determine what git filters should be
* applied to the object before it can be placed to the object database.
*/
[CCode(cname = "git_blob_create_fromchunks", instance_pos = 1.2)]
public Error create_blob_from_chunks(object_id id, string? hint_path, ChunkSource source);

/**
* Read a file from the filesystem and write its content to the Object
* Database as a loose blob
*
* @param id return the id of the written blob
* @param path file from which the blob will be created
*/
[CCode(cname = "git_blob_create_fromdisk", instance_pos = 1.2)]
public Error create_blob_from_disk(out object_id id, string path);

/**
* Read a file from the working folder of a repository
* and write it to the object database as a loose blob
*
* This repository cannot be bare.
*
* @param id return the id of the written blob
* @param path file from which the blob will be created, relative to the repository's working dir
*/
[CCode(cname = "git_blob_create_fromworkdir", instance_pos = 1.2)]
public Error create_blob_from_file(object_id id, string path);

/**
* Create a new branch pointing at a target commit
*
* A new direct reference will be created pointing to this target commit.
* If forced and a reference already exists with the given name, it'll be
* replaced.
*
* @param branch_name Name for the branch; this name is
* validated for consistency. It should also not conflict with
* an already existing branch name.
*
* @param target Object to which this branch should point. This object must
* belong to the given repository and can either be a commit or a tag. When
* a tag is being passed, it should be dereferencable to a commit which oid
* will be used as the target of the branch.
*
* @param force Overwrite existing branch.
*/
[CCode(cname = "git_branch_create", instance_pos = 1.2)]
public Error create_branch(out Reference? branch, string branch_name, Commit target, bool force = false);

/**
* Create a new commit in the repository using {@link Object}
* instances as parameters.
*
* The message will not be cleaned up.
*
* @param id the id of the newly created commit
*
* @param update_ref If not null, name of the reference that will be updated to point to this commit. If the reference is not direct, it will be resolved to a direct reference. Use //"HEAD"// to update the HEAD of the current branch and make it point to this commit.
* @param author Signature representing the author and the author time of this commit
* @param committer Signature representing the committer and the commit time of this commit
* @param message_encoding The encoding for the message in the commit, represented with a standard encoding name (e.g., //"UTF-8"//). If null, no encoding header is written and UTF-8 is assumed.
* @param message Full message for this commit
* @param tree The tree that will be used as the tree for the commit. This tree object must also be owned by this repository.
* @param parents The commits that will be used as the parents for this commit. This array may be empty for the root commit. All the given commits must be owned by this repository.
* @see prettify_message
*/
[CCode(cname = "git_commit_create", instance_pos = 1.2)]
public Error create_commit(object_id id, string? update_ref, Signature author, Signature committer, string? message_encoding, string message, Tree tree, [CCode(array_length_pos = 7.8)] Commit[] parents);

/**
* Create a new commit in the repository using a variable argument list.
*
* The parents for the commit are specified as a variable arguments. Note
* that this is a convenience method which may not be safe to export for
* certain languages or compilers
*
* The message will be cleaned up from excess whitespace it will be made
* sure that the last line ends with a new line.
*
* All other parameters remain the same.
*
* @see create_commit
*/
[CCode(cname = "git_commit_create_v", instance_pos = 1.2)]
public Error create_commit_v(object_id id, string update_ref, Signature author, Signature committer, string message_encoding, string message, Tree tree, int parent_count, ...);

/**
* Create a new lightweight tag pointing at a target object
*
* A new direct reference will be created pointing to this target object.
* If //force// is true and a reference already exists with the given name,
* it'll be replaced.
*
* The message will be cleaned up from excess whitespace
* it will be made sure that the last line ends with a new line.
*
* @param id where to store the id of the newly created tag. If the tag already exists, this parameter will be the id of the existing tag, and the function will return a {@link Error.EXISTS} error code.
*
* @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name.
*
* @param target Object to which this tag points. This object must belong to this repository.
*
* @param force Overwrite existing references
*
* @return on success, a proper reference is written in the ///refs/tags// folder, pointing to the provided target object
* @see create_tag
*/
[CCode(cname = "git_tag_create_lightweight", instance_pos = 1.2)]
public Error create_lightweight_tag(object_id id, string tag_name, Object target, bool force);

/**
* Add a note for an object
*
* @param note_id the object id of the note crated
* @param author signature of the notes commit author
* @param committer signature of the notes commit committer
* @param notes_ref ID reference to update (optional); defaults to "refs/notes/commits"
* @param id The ID of the object
* @param note The note to add for the object
* @param force Overwrite existing note
*/
[CCode(cname = "git_note_create", instance_pos = 1.2)]
public Error create_note(out object_id note_id, Signature author, Signature committer, string? notes_ref, object_id id, string note, bool force = false);

/**
* Creates a new iterator for notes.
*
* @param notes_ref canonical name of the reference to use (optional);
* defaults to "refs/notes/commits"
*/
[CCode(cname = "git_note_iterator_new", instance_pos = 1.1)]
public Error create_note_iterator(out NoteIterator? iterator, string? notes_ref = null);

/**
* Initialize a new packbuilder
*
* @param pack_builder The new packbuilder object
*/
[CCode(cname = "git_packbuilder_new", instance_pos = -1)]
public Error create_pack_builder(out PackBuilder? pack_builder);

/**
* Create a new reference database with no backends.
*
* Before the Ref DB can be used for read/writing, a custom database
* backend must be manually set using {@link RefDb.set_backend}.
*/
[CCode(cname = "git_refdb_new", instance_pos = -1)]
public Error create_refdb(out RefDb? refdb);

/**
* Create a new object id reference.
*
* The reference will be created in the repository and written to the disk.
*
* @param reference the newly created reference
* @param name The name of the reference
* @param id The object id pointed to by the reference.
* @param force Overwrite existing references
*/
[CCode(cname = "git_reference_create", instance_pos = 1.2)]
public Error create_reference(out unowned Reference reference, string name, object_id id, bool force);

/**
* Add a remote with the default fetch refspec to the repository's configuration.
*
* This calls {@link Remote.save} before returning.
*
* @param remote the resulting remote
* @param name the remote's name
* @param url the remote's url
*/
[CCode(cname = "git_remote_create", instance_pos = 1.2)]
public Error create_remote(out Remote? remote, string name, string url);
/**
* Create a remote with the given refspec in memory.
*
* You can use this when you have a URL instead of a remote's name. Note
* that in-memory remotes cannot be converted to persisted remotes.
*
* @param remote the newly created remote reference
* @param fetch the fetch refspec to use for this remote; null for defaults
* @param url the remote repository's URL
*/
[CCode(cname = "git_remote_create_inmemory", instance_pos = 1.2)]
public Error create_remote_in_memory(out Remote? remote, string? fetch, string url);

/**
* Create a new symbolic reference.
*
* The reference will be created in the repository and written to the disk.
*
* @param reference the newly created reference
* @param name The name of the reference
* @param target The target of the reference
* @param force Overwrite existing references
*/
[CCode(cname = "git_reference_symbolic_create", instance_pos = 1.2)]
public Error create_symbolic_reference(out unowned Reference reference, string name, string target, bool force);

/**
* Create a new tag in the repository from an object
*
* A new reference will also be created pointing to this tag object. If
* //force// is true and a reference already exists with the given name,
* it'll be replaced.
*
* The tag name will be checked for validity. You must avoid the characters
* ~, ^, :, \, ?, [, and *, and the sequences '''..''' and '''@{''' which
* have special meaning to revparse.
*
* @param id where to store the id of the newly created tag. If the tag already exists, this parameter will be the id of the existing tag, and the function will return a {@link Error.EXISTS} error code.
* @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name.
* @param target Object to which this tag points. This object must belong to this repository.
* @param tagger Signature of the tagger for this tag, and of the tagging time
* @param message Full message for this tag
* @param force Overwrite existing references
* @return on success, a tag object is written to the ODB, and a proper reference is written in the ///refs/tags// folder, pointing to it
*/
[CCode(cname = "git_tag_create", instance_pos = 1.2)]
public Error create_tag(object_id id, string tag_name, Object target, Signature tagger, string message, bool force);

/**
* Create a new tag in the repository from a buffer
*
* @param id Pointer where to store the id of the newly created tag
* @param buffer Raw tag data
* @param force Overwrite existing tags
* @see create_tag
*/
[CCode(cname = "git_tag_create_frombuffer", instance_pos = 1.2)]
public Error create_tag_from_buffer(object_id id, string buffer, bool force);

/**
* Delete an existing tag reference.
*
* @param tag_name Name of the tag to be deleted; this name is validated for consistency.
*/
[CCode(cname = "git_tag_delete")]
public Error delete_tag(string tag_name);

/**
* Detach the HEAD.
*
* If the HEAD is already detached and points to a commit, the call is successful.
*
* If the HEAD is already detached and points to a tag, the HEAD is updated
* into making it point to the peeled commit, and the call is successful.
*
* If the HEAD is already detached and points to a non commitish, the HEAD
* is unaletered, and an error is returned.
*
* Otherwise, the HEAD will be detached and point to the peeled commit.
*/
[CCode(cname = "git_repository_detach_head")]
public Error detach_head();

/**
* Compute a difference between two tree objects.
*
* @param diff The diff that will be allocated.
* @param old_tree A tree to diff from.
* @param new_tree A tree to diff to.
* @param opts Structure with options to influence diff or null for defaults.
*/
[CCode(cname = "git_diff_tree_to_tree", instance_pos = 1.1)]
public Error diff_tree_to_tree(out DiffList? diff, Tree old_tree, Tree new_tree, diff_options? opts = null);

/**
* Compute a difference between a tree and the index.
*
* @param diff The diff that will be allocated.
* @param old_tree A tree object to diff from.
* @param opts Structure with options to influence diff or null for defaults.
*/
[CCode(cname = "git_diff_tree_to_index", instance_pos = 1.1)]
public Error diff_tree_to_index(out DiffList? diff, Tree old_tree, diff_options? opts = null);

/**
* Compute a difference between the working directory and the index.
*
* @param diff A pointer to a git_diff_list pointer that will be allocated.
* @param opts Structure with options to influence diff or null for defaults.
*/
[CCode(cname = "git_diff_index_to_workdir", instance_pos = 1.1)]
public Error diff_index_to_workdir(out DiffList? diff, diff_options? opts = null);

/**
* Compute a difference between the working directory and a tree.
*
* Please note: this is //not// the same as '''git diff //treeish//'''.
* Running '''git diff HEAD''' or the like actually uses information from
* the index, along with the tree and working directory info.
*
* This function returns strictly the differences between the tree and the
* The tree you provide will be used for the {@link diff_delta.old_file}
* side of the delta, and the working directory will be used for the
* {@link diff_delta.new_file} side.
*
* Files contained in the working directory, regardless of the state of
* files in the index. It may come as a surprise, but there is no direct
* equivalent in core git.
*
* This is //not// the same as '''git diff HEAD''' or '''git diff <SHA>'''.
* Those commands diff the tree, the index, and the workdir. To emulate
* those functions, call {@link diff_tree_to_index} and
* {@link diff_index_to_workdir}, then call {@link DiffList.merge} on the
* results.
*
* If this seems confusing, take the case of a file with a staged deletion
* where the file has then been put back into the working dir and modified.
* The tree-to-workdir diff for that file is 'modified', but core git would
* show status 'deleted' since there is a pending deletion in the index.
*
* @param old_tree A tree to diff from.
* @param opts Structure with options to influence diff or NULL for defaults.
*/
[CCode(cname = "git_diff_workdir_to_tree", instance_pos = 1.1)]
public Error diff_tree_to_workdir(out DiffList? diff, Tree old_tree, diff_options? opts = null);

/**
* Remove a single stashed state from the stash list.
* @param index The position within the stash list. 0 points to the
* most recent stashed state.
*/
[CCode(cname = "git_stash_drop")]
public Error drop_stash(size_t index);

/**
* Iterate over each entry in the FETCH_HEAD file.
*/
[CCode(cname = "git_repository_fetchhead_foreach")]
public Error for_each_fetchhead(FetchHeadForEach fetch_head_for_each);

/**
* If a merge is in progress, iterate over each commit ID in the MERGE_HEAD
* file.
*/
[CCode(cname = "git_repository_mergehead_foreach")]
public Error for_each_merge_head(MergeHeadForEach merge_head_for_each);

/**
* Perform an operation on each reference in the repository
*
* The processed references may be filtered by type, or using a bitwise OR
* of several types. Use the magic value {@link ReferenceType.LISTALL} to
* obtain all references, including packed ones.
*
* @param list_flags Filtering flags for the reference listing.
* @param reference_for_each Function which will be called for every listed ref
*/
[CCode(cname = "git_reference_foreach")]
public Error for_each_reference(ReferenceType list_flags, ReferenceForEach reference_for_each);
/**
* Loop over all the references and issue a callback for each one which
* name matches the given glob pattern.
*
* @param list_flags Filtering flags for the reference listing.
* @param reference_for_each to invoke per found reference.
*/
[CCode(cname = "git_reference_foreach_glob")]
public Error for_each_reference_glob(string glob, ReferenceType list_flags, ReferenceForEach reference_for_each);

/**
* Iterate over all submodules of a repository.
*/
[CCode(cname = "git_submodule_foreach")]
public Error for_each_submodule(SubmoduleForEach submodule_for_each);
/**
* Iterate over each tag in the repository.
*/
[CCode(cname = "git_tag_foreach")]
public Error for_each_tag(TagForEach tag_for_each);

/**
* Find a merge base between two commits
*
* @param merge_base the OID of a merge base between 'one' and 'two'
* @param one one of the commits
* @param two the other commit
*/
[CCode(cname = "git_merge_base", instance_pos = 1.2)]
public Error find_merge_base(out object_id merge_base, object_id one, object_id two);

/**
* Find a merge base given a list of commits
*
* @param id the ID of a merge base considering all the commits
* @param input ids of the commits
*/
[CCode(cname = "git_merge_base_many", instance_pos = 1.1)]
public Error find_merge_base_many(out object_id id, [CCode(array_length_type = "size_t")]object_id[] input);

/**
* Loop over all the notes within a specified namespace.
* @param notes_ref OID reference to read from (optional); defaults to "refs/notes/commits".
*/
[CCode(cname = "git_note_foreach")]
public Error for_each_note(string? notes_ref, NoteForEach note_for_each);

/**
* Loop over all the stashed states.
*
* The most recent stash state will be enumerated first.
*/
[CCode(cname = "git_stash_foreach")]
public Error for_each_stash(StashForEach stash_for_each);

/**
* Gather file statuses and run a callback for each one.
*
* The callback is passed the path of the file, the status and the data
* pointer passed to this function. If the callback returns something other
* than {@link Error.OK}, this function will return that value.
*
* @param status_for_each the function to call on each file
* @return {@link Error.OK} or the return value of the callback
*/
[CCode(cname = "git_status_foreach")]
public Error for_each_status(StatusForEach status_for_each);

/**
* Gather file status information and run callbacks as requested.
*/
[CCode(cname = "git_status_foreach_ext")]
public Error for_each_status_ext(status_options opts, StatusForEach status_for_each);

/**
* Get the configuration file for this repository.
*
* If a configuration file has not been set, the default
* config set for the repository will be returned, including
* global and system configurations (if they are available).
*
* @param config the repository's configuration
*/
[CCode(cname = "git_repository_config", instance_pos = -1)]
public Error get_config(out Config config);

/**
* Get the Object Database for this repository.
*
* If a custom ODB has not been set, the default database for the
* repository will be returned (the one located in //.git/objects//).
*/
[CCode(cname = "git_repository_odb", instance_pos = -1)]
public Error get_db(out Database.Handle db);

/**
* Get file status for a single file
*
* @param status the status value
* @param path the file to retrieve status for, rooted at the repo's workdir
* @return {@link Error.ERROR} when //path// points at a folder, {@link Error.NOTFOUND} when the file doesn't exist in any of HEAD, the index or the worktree, {@link Error.OK} otherwise
*/
[CCode(cname = "git_status_file", instance_pos = 1.2)]
public Error get_file_status(out Status status, string path);

/**
* Retrieve and resolve the reference pointed at by HEAD.
*
* @param head the reference which will be retrieved
*/
[CCode(cname = "git_repository_head", instance_pos = -1)]
public Error get_head(out Reference head);

/**
* Get the index file for this repository.
*
* If a custom index has not been set, the default
* index for the repository will be returned (the one
* located in //.git/index//).
*
* If a custom index has not been set, the default
* index for the repository will be returned (the one
* located in //.git/index//).
*
*/
[CCode(cname = "git_repository_index", instance_pos = -1)]
public void get_index(out Index index);

/**
* Get the information for a particular remote
*
* The name will be checked for validity.
* @param remote the new remote object
* @param name the remote's name
* @see create_tag
*/
[CCode(cname = "git_remote_load", instance_pos = 1.2)]
public Error get_remote(out Remote remote, string name);

/**
* Return the name of remote that the remote tracking branch belongs to.
*
* @param remote_name The buffer which will be filled with the name of the
* remote. Pass null if you just want to get the needed size of the name of
* the remote as the output value.
*
* @param canonical_branch_name name of the remote tracking branch.
*
* @return Number of characters in the reference name including the
* trailing NUL byte; {@link Error.NOTFOUND} when no remote matching remote
* was found, {@link Error.AMBIGUOUS} when the branch maps to several
* remotes, otherwise an error code.
*/
[CCode(cname = "git_branch_remote_name", insance_pos = 1.2)]
public int get_branch_remote_name([CCode(array_length_type = "size_t")] uint8[]? remote_name, string canonical_branch_name);

/**
* Get the Reference Database Backend for this repository.
*
* If a custom refsdb has not been set, the default database for the
* repository will be returned (the one that manipulates loose and packed
* references in the '''.git''' directory).
*/
[CCode(cname = "git_repository_refdb", instance_pos = -1)]
public Error get_refdb(out RefDb? refdb);

/**
* Get a list of the configured remotes for a repo
*
* @param remotes_list a string array with the names of the remotes
*/
[CCode(cname = "git_remote_list", instance_pos = -1)]
public Error get_remote_list(out string_array remotes_list);

/**
* Fill a list with all the tags in the Repository
*
* @param tag_names where the tag names will be stored
*/
[CCode(cname = "git_tag_list", instance_pos = -1)]
public Error get_tag_list(string_array tag_names);

/**
* Fill a list with all the tags in the Repository which name match a
* defined pattern
*
* If an empty pattern is provided, all the tags will be returned.
*
* @param tag_names the tag names will be stored
* @param pattern standard shell-like (fnmatch) pattern
*/
[CCode(cname = "git_tag_list_match", instance_pos = -1)]
public Error get_tag_list_match(out string_array tag_names, string pattern);

/**
* Return the name of the reference supporting the remote tracking branch,
* given the name of a local branch reference.
*
* @param tracking_branch_name The buffer which will be filled with the
* name of the reference, or null if you just want to get the needed size
* of the name of the reference as the output value.
*
* @param canonical_branch_name name of the local branch.
*
* @return number of characters in the reference name including the
* trailing NUL byte; otherwise an error code.
*/
[CCode(cname = "git_branch_tracking_name", instance_pos = 1.3)]
public int get_tracking_branch_name([CCode(array_length_type = "size_t")] char[]? tracking_branch_name, string canonical_branch_name);

/**
* Allocate a new revision walker to iterate through a repo.
*
* This revision walker uses a custom memory pool and an internal commit
* cache, so it is relatively expensive to allocate.
*
* For maximum performance, this revision walker should be reused for
* different walks.
*
* This revision walker is ''not'' thread safe: it may only be used to walk
* a repository on a single thread; however, it is possible to have several
* revision walkers in several different threads walking the same
* repository.
*
* @param walker the new revision walker
*/
[CCode(cname = "git_revwalk_new", instance_pos = -1)]
public Error get_walker(out RevisionWalker walker);

/**
* Calculate hash of file using repository filtering rules.
*
* If you simply want to calculate the hash of a file on disk with no filters,
* you can just use the {@link object_id.hashfile} API. However, if you
* want to hash a file in the repository and you want to apply filtering
* rules (e.g. crlf filters) before generating the SHA, then use this
* function.
*
* @param path Path to file on disk whose contents should be hashed. This can be a relative path.
* @param type The object type to hash
* @param as_path The path to use to look up filtering rules. If this is
* null, then the path parameter will be used instead. If this is passed as
* the empty string, then no filters will be applied when calculating the
* hash.
*/
[CCode(cname = "git_repository_hashfile", instance_pos = 1.1)]
public Error hashfile(out object_id id, string path, ObjectType type, string? as_path = null);

/**
* Iterate over the branches in the repository.
*
* @param list_flags Filtering flags for the branch listing.
*/
[CCode(cname = "git_branch_foreach")]
public Error for_each_branch(BranchType list_flags, Branch branch);
/**
* Test if the ignore rules apply to a given path.
*
* This function checks the ignore rules to see if they would apply to the
* given file. This indicates if the file would be ignored regardless of
* whether the file is already in the index or commited to the repository.
*
* One way to think of this is if you were to do '''git add .''' on the
* directory containing the file, would it be added or not?
*
* @param path the file to check ignores for, relative to the repo's
* workdir.
*/
[CCode(cname = "git_ignore_path_is_ignored", instance_pos = 1.1)]
public Error is_path_ignored(out bool ignored, string path);

[CCode(cname = "git_branch_foreach", instance_pos = 1.2)]
public Error list_branches(out string_array branch_names, BranchType list_flags);

/**
* Fill a list with all the references that can be found
* in a repository.
*
* The listed references may be filtered by type, or using
* a bitwise OR of several types. Use the magic value
* {@link ReferenceType.LISTALL} to obtain all references, including
* packed ones.
*
* @param array where the reference names will be stored
* @param list_flags Filtering flags for the reference listing.
*/
[CCode(cname = "git_reference_listall", instance_pos = 1.2)]
public Error list_all(out string_array array, ReferenceType list_flags);

/**
* Convert a tree entry to the object it points too.
*
* @param object pointer to the converted object
* @param entry a tree entry
*/
[CCode(cname = "git_tree_entry_to_object", instance_pos = 1.2)]
public Error load(out Object object, TreeEntry entry);

/**
* Lookup a blob object from a repository.
*
* @param blob the looked up blob
* @param id identity of the blob to locate.
*/
[CCode(cname = "git_blob_lookup", instance_pos = 1.2)]
public Error lookup_blob(out Blob blob, object_id id);

/**
* Lookup a blob object from a repository, given a prefix of its identifier
* (short id).
*
* @see lookup_object_by_prefix
*
* @param blob the looked up blob
* @param id identity of the blob to locate.
* @param len the length of the short identifier
*/
[CCode(cname = "git_blob_lookup_prefix", instance_pos = 1.2)]
public Error lookup_blob_by_prefix(out Blob blob, object_id id, size_t len);
/**
* Lookup a branch by its name.
*
* @param branch_name Name of the branch to be looked-up; this name is
* validated for consistency.
*/
[CCode(cname = "git_branch_lookup", instance_pos = 1.1)]
public Error lookup_branch(out Reference? branch, string branch_name, BranchType branch_type);

/**
* Lookup a commit object from a repository.
*
* @param commit the looked up commit
* @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit.
*/
[CCode(cname = "git_commit_lookup", instance_pos = 1.2)]
public Error lookup_commit(out Commit commit, object_id id);

/**
* Lookup a commit object from a repository, given a prefix of its
* identifier (short id).
*
* @see lookup_object_by_prefix
*
* @param commit the looked up commit
* @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
*/
[CCode(cname = "git_commit_lookup_prefix", instance_pos = 1.2)]
public Error lookup_commit_by_prefix(out Commit commit, object_id id, size_t len);

/**
* Lookup a reference to one of the objects in a repostory.
*
* The //type// parameter must match the type of the object in the ODB; the
* method will fail otherwise. The special value {@link ObjectType.ANY}
* may be passed to let the method guess the object's type.
*
* @param object the looked-up object
* @param id the unique identifier for the object
* @param type the type of the object
* @return a reference to the object
*/
[CCode(cname = "git_object_lookup", instance_pos = 1.2)]
public Error lookup_object(out Object object, object_id id, ObjectType type);

/**
* Lookup a reference to one of the objects in a repostory, given a prefix
* of its identifier (short id).
*
* The object obtained will be so that its identifier matches the first
* //len// hexadecimal characters (packets of 4 bits) of the given //id//.
* //len// must be at least {@link object_id.MIN_PREFIX_LENGTH}, and long
* enough to identify a unique object matching the prefix; otherwise the
* method will fail.
*
* The //type// parameter must match the type of the object in the ODB; the
* method will fail otherwise. The special value {@link ObjectType.ANY}
* may be passed to let the method guess the object's type.
*
* @param object where to store the looked-up object
* @param id a short identifier for the object
* @param len the length of the short identifier
* @param type the type of the object
*/
[CCode(cname = "git_object_lookup_prefix", instance_pos = 1.2)]
public Error lookup_object_by_prefix(out Object object, object_id id, size_t len, ObjectType type);

/**
* Lookup a reference by its name in a repository.
*
* @param reference the looked-up reference
* @param name the long name for the reference (e.g., HEAD, ref/heads/master, refs/tags/v0.1.0, ...)
*/
[CCode(cname = "git_reference_lookup", instance_pos = 1.2)]
public Error lookup_reference(out Reference reference, string name);

/**
* Lookup a reference by name and resolve immediately to an ID.
*
* @param name The long name for the reference
*/
[CCode(cname = "git_reference_name_to_id", instance_pos = 1.2)]
public Error lookup_reference_to_id(out object_id id, string name);

/**
* Lookup submodule information by name or path.
*
* Given either the submodule name or path (they are ususally the same),
* this returns a structure describing the submodule.
*
* @param name The name of the submodule. Trailing slashes will be ignored.
*/
[CCode(cname = "git_submodule_lookup", instance_pos = 1.2)]
public Error lookup_submodule(out unowned Submodule? submodule, string name);

/**
* Lookup a tag object from the repository.
*
* @param tag pointer to the looked up tag
* @param id identity of the tag to locate.
*/
[CCode(cname = "git_tag_lookup", instance_pos = 1.2)]
public Error lookup_tag(out Tag tag, object_id id);

/**
* Lookup a tag object from the repository, given a prefix of its
* identifier (short id).
*
* @see lookup_object_by_prefix
*
* @param tag pointer to the looked up tag
* @param id identity of the tag to locate.
* @param len the length of the short identifier
*/
[CCode(cname = "git_tag_lookup_prefix", instance_pos = 1.2)]
public Error prefix_lookup_tag(out Tag tag, object_id id, uint len);

/**
* Lookup a tree object from the repository.
*
* @param tree the looked up tree
* @param id identity of the tree to locate.
*/
[CCode(cname = "git_tree_lookup", instance_pos = 1.2)]
public Error lookup_tree(out Tree tree, object_id id);

/**
* Lookup a tree object from the repository, given a prefix of its
* identifier (short id).
*
* @see lookup_object_by_prefix
*
* @param tree the looked up tree
* @param id identity of the tree to locate.
* @param len the length of the short identifier
*/
[CCode(cname = "git_tree_lookup_prefix", instance_pos = 1.2)]
public Error lookup_tree_by_prefix(out Tree tree, object_id id, uint len);

/**
* Create a new reference database and automatically add
* the default backends:
*
* - git_refdb_dir: read and write loose and packed refs from disk,
* assuming the repository dir as the folder
*/
[CCode(cname = "git_refdb_open", instance_pos = -1)]
public Error open_refdb(out RefDb? refdb);

/**
* Find an object, as specified by a revision string. See the gitrevisions
* manual page, or the documentation for '''git rev-parse''' for
* information on the syntax accepted.
*
* @param spec the textual specification for an object
*/
[CCode(cname = "git_revparse_single", instance_pos = 1.1)]
public Error parse(out Object? obj, string spec);

/**
* Read the note for an object
* @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits"
* @param id ID of the object
*/
[CCode(cname = "git_note_read", instance_pos = 1.2)]
public Error read_note(out Note? note, string? notes_ref, object_id id);
/**
* Get the default notes reference for a repository
*/
[CCode(cname = "git_note_default_ref", instance_pos = -1)]
public Error read_note_default_ref(out unowned string note);

/**
* Reread all submodule info.
*
* Call this to reload all cached submodule information for the repo.
*/
[CCode(cname = "git_submodule_reload_all")]
public Error reload_submodules();

/**
* Remove the note for an object
*
* @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits"
* @param author signature of the notes commit author
* @param committer signature of the notes commit committer
* @param id the id which note's to be removed
*/
[CCode(cname = "git_note_remove")]
public Error remove_note(string? notes_ref, Signature author, Signature committer, object_id id);

/**
* Sets the current head to the specified commit oid and optionally resets
* the index and working tree to match.
*
* When specifying a Soft kind of reset, the head will be moved to the commit.
*
* Specifying a Mixed kind of reset will trigger a Soft reset and the index
* will be replaced with the content of the commit tree.
*
* @param target Object to which the Head should be moved to. This object
* must belong to this repository and can either be a {@link Commit} or a
* {@link Tag}. When a {@link Tag} is being passed, it should be
* dereferencable to a {@link Commit} which oid will be used as the target
* of the branch.
* @param reset_type Kind of reset operation to perform.
*/
[CCode(cname = "git_reset")]
public Error reset(Object target, ResetType reset_type);

/**
* Updates some entries in the index from the target commit tree.
*
* The scope of the updated entries is determined by the paths
* specified.
*
* @param target The committish which content will be used to reset the
* content of the index. Passing null will result in removing entries in
* the index matching the provided pathspecs.
*
* @param pathspecs List of pathspecs to operate on.
*/
[CCode(cname = "git_reset_default")]
public Error reset_default(Object? target, string_array pathspecs);

/**
* Save the local modifications to a new stash.
*
* @param id id of the commit containing the stashed state. This commit is
* also the target of the direct reference refs/stash.
* @param stasher The identity of the person performing the stashing.
* @param message description along with the stashed state.
*/
[CCode(cname = "git_stash_save", instance_pos = 1.1)]
public Error save_stash(out object_id id, Signature stasher, string? message = null, StashFlag flags = StashFlag.DEFAULT);

/**
* Set the configuration file for this repository
*
* This configuration file will be used for all configuration
* queries involving this repository.
*/
[CCode(cname = "git_repository_set_config")]
public void set_config(Config config);

/**
* Set the Object Database for this repository
*
* The ODB will be used for all object-related operations involving this
* repository.
*/
[CCode(cname = "git_repository_set_odb")]
public void set_db(Database.Handle db);
/**
* Make the repository HEAD point to the specified reference.
*
* If the provided reference points to a Tree or a Blob, the HEAD is
* unaltered and an error is returned.
*
* If the provided reference points to a branch, the HEAD will point to
* that branch, staying attached, or become attached if it isn't yet. If
* the branch doesn't exist yet, no error will be return. The HEAD will
* then be attached to an unborn branch.
*
* Otherwise, the HEAD will be detached and will directly point to the
* Commit.
*
* @param refname Canonical name of the reference the HEAD should point at
*/
[CCode(cname = "git_repository_set_head")]
public Error set_head(string refname);

/**
* Make the repository HEAD directly point to the Commit.
*
* If the provided committish cannot be found in the repository, the HEAD
* is unaltered and {@link Error.NOTFOUND} is returned.
*
* If the provided commitish cannot be peeled into a commit, the HEAD is
* unaltered and and error is returned.
*
* Otherwise, the HEAD will eventually be detached and will directly point to
* the peeled Commit.
*
* @param commitish Object id of the Commit the HEAD should point to
* @return 0 on success, or an error code
*/
[CCode(cname = "git_repository_set_head_detached")]
public Error set_head_detached(object_id commitish);

/**
* Set the index file for this repository
*
* This index will be used for all index-related operations
* involving this repository.
*/
[CCode(cname = "git_repository_set_index")]
public void set_index(Index index);

/**
* Set the Reference Database Backend for this repository
*
* The refdb will be used for all reference related operations involving
* this repository.
*/
[CCode(cname = "git_repository_set_refdb")]
public void set_refdb(RefDb refdb);

/**
* Set the working directory.
* @param workdir The path to a working directory
* @param update_gitlink Create/update gitlink in workdir and set config
* "core.worktree" (if workdir is not the parent of the .git directory)
*/
[CCode(cname = "git_repository_set_workdir")]
public Error set_workdir(string workdir, bool update_gitlink);

/**
* Test if the ignore rules apply to a given file.
*
* This function simply checks the ignore rules to see if they would apply
* to the given file. Unlike {@link get_file_status}, this indicates if
* the file would be ignored regardless of whether the file is already in
* the index or in the repository.
*
* @param path the file to check ignores for, rooted at the repo's workdir
* @param ignored false if the file is not ignored, true if it is
* @return {@link Error.OK} if the ignore rules could be processed
* for the file (regardless of whether it exists or not), or an error if
* they could not.
*/
[CCode(cname = "git_status_should_ignore", instance_pos = 1.2)]
public Error should_ignore(out bool ignored, string path);

/**
* Write the contents of the tree builder as a tree object
*
* The tree builder will be written to the repositrory, and it's
* identifying SHA1 hash will be stored in the id pointer.
*
* @param id Pointer where to store the written id
* @param builder Tree builder to write
*/
[CCode(cname = "git_treebuilder_write", instance_pos = 1.2)]
public Error write(object_id id, TreeBuilder builder);

}

/**
* An in-progress walk through the commits in a repo
*/
[CCode(cname = "git_revwalk", free_function = "git_revwalk_free", has_type_id = false)]
[Compact]
public class RevisionWalker {

/**
* The repository on which this walker is operating.
*/
public Repository repository {
[CCode(cname = "git_revwalk_repository")]
get;
}

/**
* Mark a commit (and its ancestors) uninteresting for the output.
*
* The given id must belong to a commit on the walked repository.
*
* The resolved commit and all its parents will be hidden from the output
* on the revision walk.
*
* @param id the id of commit that will be ignored during the traversal
*/
[CCode(cname = "git_revwalk_hide")]
public Error hide(object_id id);

/**
* Hide the OID pointed to by a reference
*
* The reference must point to a commit.
*
* @param refname the referece to hide
*/
[CCode(cname = "git_revwalk_hide_ref")]
public Error hide_ref(string refname);

/**
* Get the next commit from the revision walk.
*
* The initial call to this method is ''not'' blocking when iterating through
* a repo with a time-sorting mode.
*
* Iterating with topological or inverted modes makes the initial call
* blocking to preprocess the commit list, but this block should be mostly
* unnoticeable on most repositories (topological preprocessing times at
* 0.3s on the git.git repo).
*
* The revision walker is reset when the walk is over.
*
* @param id where to store the id of the next commit
*/
[CCode(cname = "git_revwalk_next", instance_pos = -1)]
public Error next(out object_id id);

/**
* Mark a commit to start traversal from.
*
* The given id must belong to a commit on the walked repository.
*
* The given commit will be used as one of the roots when starting the
* revision walk. At least one commit must be pushed the repository before
* a walk can be started.
*
* @param id the id of the commit to start from.
*/
[CCode(cname = "git_revwalk_push")]
public Error push(object_id id);

/**
* Push the OID pointed to by a reference
*
* The reference must point to a commit.
*
* @param refname the referece to push
*/
[CCode(cname = "git_revwalk_push_ref")]
public Error push_ref(string refname);

/**
* Push matching references
*
* The OIDs pinted to by the references that match the given glob
* pattern will be pushed to the revision walker.
*
* A leading 'refs/' is implied it not present as well as a trailing
* '/ *' if the glob lacks '?', '*' or '['.
*
* @param glob the glob pattern references should match
*/
[CCode(cname = "git_revwalk_push_glob")]
public Error push_glob(string glob);

/**
* Push the repository's HEAD
*/
[CCode(cname = "git_revwalk_push_head")]
public Error push_head();

/**
* Reset the revision walker for reuse.
*
* This will clear all the pushed and hidden commits, and leave the walker
* in a blank state (just like at creation) ready to receive new commit
* pushes and start a new walk.
*
* The revision walk is automatically reset when a walk is over.
*/
[CCode(cname = "git_revwalk_reset")]
public void reset();

/**
* Change the sorting mode when iterating through the repository's
* contents.
*
* Changing the sorting mode resets the walker.
*
* @param sort combination of sort flags
*/
[CCode(cname = "git_revwalk_sorting")]
public void set_sorting(Sorting sort);

/**
* Hide matching references.
*
* The OIDs pinted to by the references that match the given glob
* pattern and their ancestors will be hidden from the output on the
* revision walk.
*
* A leading 'refs/' is implied it not present as well as a trailing
* '/ *' if the glob lacks '?', '*' or '['.
*
* @param glob the glob pattern references should match
*/
[CCode(cname = "git_revwalk_hide_glob")]
public Error hide_glob(string glob);

/**
* Hide the repository's HEAD
*/
[CCode(cname = "git_revwalk_hide_head")]
public Error hide_head();
}

/**
* An action signature (e.g. for committers, taggers, etc)
*/
[CCode(cname = "git_signature", free_function = "git_signature_free", copy_function = "git_signature_dup", has_type_id = false)]
[Compact]
public class Signature {
/**
* Email of the author
*/
public string email;
/**
* Full name of the author
*/
public string name;
/**
* Time when the action happened
*/
public time when;

/**
* Create a new action signature.
*
* Note: angle brackets characters are not allowed in either the name or
* the email.
* @param sig new signature, null in case of error
* @param name name of the person
* @param email email of the person
* @param time time when the action happened
* @param offset timezone offset in minutes for the time
*/
[CCode(cname = "git_signature_new")]
public static int create(out Signature? sig, string name, string email, int64 time, int offset);

/**
* Create a new action signature with a timestamp of now.
*
* @param sig new signature, null in case of error
* @param name name of the person
* @param email email of the person
*/
[CCode(cname = "git_signature_now")]
public static int create_now(out Signature? sig, string name, string email);
}

/**
* Description of submodule
*
* This record describes a submodule found in a repository. There
* should be an entry for every submodule found in the HEAD and for
* every submodule described in .gitmodules.
*/
[CCode(cname = "git_submodule", has_type_id = false)]
[Compact]
public class Submodule {
/**
* The name of the submodule from .gitmodules.
*/
public string name {
[CCode(cname = "git_submodule_name")]
get;
}
/**
* The path to the submodule from the repo working directory.
*
* It is almost always the same as {@link name}.
*/
public string path {
[CCode(cname = "git_submodule_path")]
get;
}
/**
* The url for the submodule.
*
* If deleted but not commited, this will be null.
*/
public string? url {
[CCode(cname = "git_submodule_url")]
get;
[CCode(cname = "git_submodule_set_url")]
set;
}
/**
* Get the OID for the submodule in the index.
*/
public object_id? index_id {
[CCode(cname = "git_submodule_index_id")]
get;
}
/**
* Get the OID for the submodule in the current HEAD tree.
*/
public object_id? head_id {
[CCode(cname = "git_submodule_head_id")]
get;
}
/**
* Whether or not to fetch submodules of submodules recursively.
*/
public bool fetch_recurse {
[CCode(cname = "git_submodule_fetch_recurse_submodules")]
get;
[CCode(cname = "git_submodule_set_fetch_recurse_submodules")]
set;
}
/**
* The containing repository for a submodule.
*
* This returns a pointer to the repository that contains the submodule.
*/
public Repository repository {
[CCode(cname = "git_submodule_owner")]
get;
}

/**
* Get the OID for the submodule in the current working directory.
*
* This returns the OID that corresponds to looking up 'HEAD' in the
* checked out submodule. If there are pending changes in the index or
* anything else, this won't notice that. You should check
* {@link status} for a more complete picture about the state of the
* working directory.
*/
public object_id? wd_id {
[CCode(cname = "git_submodule_wd_id")]
get;
}

/**
* The ignore rule for the submodule.
*/
[CCode(cname = "git_submodule_ignore")]
public SubmoduleIgnore ignore {
[CCode(cname = "git_submodule_ignore")]
get;
[CCode(cname = "git_submodule_set_ignore")]
set;
}

/**
* The update rule for the submodule.
*/
public SubmoduleUpdate update {
[CCode(cname = "git_submodule_update")]
get;
[CCode(cname = "git_submodule_set_update")]
set;
}

/**
* Resolve the setup of a new git submodule.
*
* This should be called on a submodule once you have called add setup and
* done the clone of the submodule. This adds the .gitmodules file and the
* newly cloned submodule to the index to be ready to be committed (but
* doesn't actually do the commit).
*/
[CCode(cname = "git_submodule_add_finalize")]
public Error add_finalize();

/**
* Add current submodule HEAD commit to index of superproject.
*
* @param write_index if this should immediately write the index file. If
* you pass this as false, you will have to explicitly call {@link Index.write}
* on it to save the change.
*/
[CCode(cname = "git_submodule_add_to_index")]
public Error add_to_index(bool write_index);

/**
* Copy submodule info into ".git/config" file.
*
* Just like "git submodule init", this copies information about the
* submodule into ".git/config". You can use the accessor functions above
* to alter the in-memory git_submodule object and control what is written
* to the config, overriding what is in .gitmodules.
*
* @param overwrite By default, existing entries will not be overwritten,
* but setting this to true forces them to be updated.
*/
[CCode(cname = "git_submodule_init")]
public Error init(bool overwrite);

/**
* Get the locations of submodule information.
*
* This is a bit like a very lightweight version of {@link status}.
* It just returns a made of the first four submodule status values (i.e.
* the ones like {@link SubmoduleStatus.IN_HEAD}, etc) that tell you where
* the submodule data comes from (i.e. the HEAD commit, gitmodules file,
* etc.).
*
* This can be useful if you want to know if the submodule is present in
* the working directory at this point in time, etc.
*/
[CCode(cname = "git_submodule_location", instance_pos = -1)]
public Error location(out SubmoduleStatus status);

/**
* Copy submodule remote info into submodule repo.
*
* This copies the information about the submodules URL into the checked
* out submodule config, acting like "git submodule sync". This is useful
* if you have altered the URL for the submodule (or it has been altered by
* a fetch of upstream changes) and you need to update your local repo.
*/
[CCode(cname = "git_submodule_sync")]
public Error sync();

/**
* Open the repository for a submodule.
*
* This will only work if the submodule is checked out into the working
* directory.
*/
[CCode(cname = "git_submodule_open", instance_pos = -1)]
public Error open(out Repository? repo);

/**
* Reread submodule info from config, index, and HEAD.
*
* Call this to reread cached submodule information for this submodule if
* you have reason to believe that it has changed.
*/
[CCode(cname = "git_submodule_reload")]
public Error reload();

/**
* Write submodule settings to .gitmodules file.
*
* This commits any in-memory changes to the submodule to the gitmodules
* file on disk. You may also be interested in `git_submodule_init()`
* which writes submodule info to ".git/config" (which is better for local
* changes to submodule settings) and/or `git_submodule_sync()` which
* writes settings about remotes to the actual submodule repository.
*/
[CCode(cname = "git_submodule_save")]
public Error save();

/**
* Get the status for a submodule.
*
* This looks at a submodule and tries to determine the status.
*/
[CCode(cname = "git_submodule_status", instance_pos = -1)]
public Error status(out SubmoduleStatus status);
}

/**
* Parsed representation of a tag object.
*/
[CCode(cname = "git_tag", free_function = "git_tag_free", has_type_id = false)]
[Compact]
public class Tag : Object {
/**
* The id of a tag.
*/
public object_id? id {
[CCode(cname = "git_tag_id")]
get;
}

/**
* The message of a tag
*/
public string message {
[CCode(cname = "git_tag_message")]
get;
}

/**
* The name of a tag
*/
public string name {
[CCode(cname = "git_tag_name")]
get;
}

/**
* The tagger (author) of a tag
*/
public Signature tagger {
[CCode(cname = "git_tag_tagger")]
get;
}

/**
* The id of the tagged object of a tag
*/
public object_id? target_id {
[CCode(cname = "git_tag_target_id")]
get;
}

/**
* The type of a tag's tagged object
*/
public ObjectType target_type {
[CCode(cname = "git_tag_target_type")]
get;
}

/**
* Get the tagged object of a tag
*
* This method performs a repository lookup for the given object and
* returns it
*
* @param target where to store the target
*/
[CCode(cname = "git_tag_target", instance_pos = -1)]
public Error lookup_target(out Object target);

/**
* Recursively peel a tag until a non-tag-object is met
*/
[CCode(cname = "git_tag_peel", instance_pos = -1)]
public Error peel(out Object result);
}

/**
* Representation of a tree object.
*/
[CCode(cname = "git_tree", free_function = "git_tree_free", has_type_id = false)]
[Compact]
public class Tree : Object {
/**
* The id of a tree.
*/
public object_id? id {
[CCode(cname = "git_tree_id")]
get;
}

public Repository repository {
[CCode(cname = "git_tree_owner")]
get;
}

/**
* Get the number of entries listed in a tree
*/
public size_t size {
[CCode(cname = "git_tree_entrycount")]
get;
}

/**
* Lookup a tree entry by its position in the tree
*
* @param idx the position in the entry list
* @return the tree entry; null if not found
*/
[CCode(cname = "git_tree_entry_byindex")]
public unowned TreeEntry? get(size_t idx);
/**
* Lookup a tree entry by SHA value.
*
* Warning: this must examine every entry in the tree, so it is not fast.
*
* @param id the sha being looked for
* @return the tree entry; null if not found
*/
[CCode(cname = "git_tree_entry_byoid")]
public unowned TreeEntry? get_by_id(object_id id);

/**
* Lookup a tree entry by its filename
*
* @param filename the filename of the desired entry
* @return the tree entry; null if not found
*/
[CCode(cname = "git_tree_entry_byname")]
public unowned TreeEntry? get_by_name(string filename);

/**
* Retrieve a subtree contained in a tree, given its relative path.
*
* @param path Path to the tree entry from which to extract the last tree object
* @return {@link Error.OK} on success; {@link Error.NOTFOUND} if the path does not lead to an entry; otherwise, an error code
*/
[CCode(cname = "git_tree_entry_bypath", instance_pos = 1.2)]
public Error get_by_path(out TreeEntry entry, string path);

/**
* Traverse the entries in a tree and its subtrees in post or pre order
*
* The entries will be traversed in the specified order, children subtrees
* will be automatically loaded as required, and the callback will be
* called once per entry with the current (relative) root for the entry and
* the entry data itself.
*
* If the callback returns a negative value, the passed entry will be
* skiped on the traversal.
*
* @param mode Traversal mode (pre or post-order)
* @param tree_walker Function to call on each tree entry
*/
[CCode(cname = "git_tree_walk")]
public Error walk(WalkMode mode, TreeWalker tree_walker);
}

/**
* Constructor for in-memory trees
*/
[CCode(cname = "git_treebuilder", free_function = "git_treebuilder_free", has_type_id = false)]
[Compact]
public class TreeBuilder {
/**
* The number of entries listed in a treebuilder.
*/
public uint size {
[CCode(cname = "git_treebuilder_entrycount")]
get;
}

/**
* Create a new tree builder.
*
* The tree builder can be used to create or modify trees in memory and
* write them as tree objects to the database.
*
* If the source parameter is not null, the tree builder will be
* initialized with the entries of the given tree.
*
* If the source parameter is null, the tree builder will have no entries
* and will have to be filled manually.
*
* @param builder where to store the tree builder
* @param source source tree to initialize the builder (optional)
*/
[CCode(cname = "git_treebuilder_create")]
public static Error create(out TreeBuilder builder, Tree? source = null);

/**
* Clear all the entires in the builder
*/
[CCode(cname = "git_treebuilder_clear")]
public void clear();

/**
* Filter the entries in the tree
*
* The filter will be called for each entry in the tree with an entry. If
* the callback returns true, the entry will be filtered (removed from the
* builder).
* @param filter function to filter entries
*/
[CCode(cname = "git_treebuilder_filter")]
public void filter(Filter filter);

/**
* Add or update an entry to the builder
*
* Insert a new entry for the given filename in the builder with the given
* attributes.
*
* If an entry named filename already exists, its attributes will be
* updated with the given ones.
*
* @param entry where to store the entry (optional)
* @param filename Filename of the entry
* @param id SHA1 id of the entry
* @param attributes Folder attributes of the entry
* @return 0 on success; error code otherwise
*/
[CCode(cname = "git_treebuilder_insert", instance_pos = 1.2)]
public Error insert(out unowned TreeEntry? entry = null, string filename, object_id id, Attributes attributes);

/**
* Get an entry from the builder from its filename
* @param filename Name of the entry
* @return the entry; null if not found
*/
[CCode(cname = "git_treebuilder_get")]
public unowned TreeEntry? get(string filename);

/**
* Remove an entry from the builder by its filename
*
* @param filename Filename of the entry to remove
*/
[CCode(cname = "git_treebuilder_remove")]
public Error remove(string filename);
}

/**
* Representation of each one of the entries in a tree object.
*/
[CCode(cname = "git_tree_entry", has_type_id = false, free_function = "git_tree_entry_free", copy_function = "git_tree_entry_dup")]
[Compact]
public class TreeEntry {

/**
* The id of the object pointed by the entry
*/
public unowned object_id? id {
[CCode(cname = "git_tree_entry_id")]
get;
}

/**
* The filename of a tree entry
*/
public string name {
[CCode(cname = "git_tree_entry_name")]
get;
}

/**
* The UNIX file attributes of a tree entry
*/
public FileMode mode {
[CCode(cname = "git_tree_entry_filemode")]
get;
}

/**
* The type of the object pointed by the entry
*/
public ObjectType type {
[CCode(cname = "git_tree_entry_type")]
get;
}
/**
* Compare two tree entries
*
* @param that second tree entry
* @return <0 if this is before that, 0 if this == that, >0 if this is after that
*/
[CCode(cname = "git_tree_entry_cmp")]
public int cmp(TreeEntry that);

/**
* Create a new tree builder.
*
* The tree builder can be used to create or modify trees in memory and
* write them as tree objects to the database.
*
* The tree builder will be initialized with the entries of the given tree.
*
* @param builder where to store the tree builder
*/
[CCode(cname = "git_treebuilder_create", instance_pos = -1)]
public Error create_builder(out TreeBuilder builder);
/**
* Create a copy of a tree entry.
*/
[CCode(cname = "git_tree_entry_dup")]
public TreeEntry dup();
}

/**
* List of unmerged index entries
*/
[CCode(cname = "git_index", has_type_id = false)]
[Compact]
public class ReucIndex {
/**
* The count of unmerged entries currently in the index
*/
public uint size {
[CCode(cname = "git_index_reuc_entrycount")]
get;
}
/**
* Adds a resolve undo entry for a file based on the given parameters.
*
* The resolve undo entry contains the OIDs of files that were involved in
* a merge conflict after the conflict has been resolved. This allows
* conflicts to be re-resolved later.
*
* If there exists a resolve undo entry for the given path in the index, it
* will be removed.
*
* This method will fail in bare index instances.
*
* @param path filename to add
* @param ancestor_mode mode of the ancestor file
* @param ancestor_id oid of the ancestor file
* @param our_mode mode of our file
* @param our_id oid of our file
* @param their_mode mode of their file
* @param their_id oid of their file
*/
[CCode(cname = "git_index_reuc_add")]
public Error add(string path, FileMode ancestor_mode, object_id ancestor_id, FileMode our_mode, object_id our_id, FileMode their_mode, object_id their_id);

/**
* Remove all resolve undo entries from the index
*/
[CCode(cname = "git_index_reuc_clear")]
public void clear();

/**
* Finds the resolve undo entry that points to the given path in the Git
* index.
*
* @param path path to search
* @return an index >= 0 if found, -1 otherwise
*/
[CCode(cname = "git_index_reuc_find")]
public Error find(string path);

/**
* Get an unmerged entry from the index.
*
* @param n the position of the entry
* @return a pointer to the unmerged entry; null if out of bounds
*/
[CCode(cname = "git_index_reuc_get_byindex")]
public unowned index_reuc_entry? get(uint n);

/**
* Get an unmerged entry from the index.
*
* @param path path to search
* @return the unmerged entry; null if not found
*/
[CCode(cname = "git_index_reuc_get_bypath")]
public unowned index_reuc_entry? get_by_path(string path);

/**
* Remove an resolve undo entry from the index
*
* @param n position of the resolve undo entry to remove
*/
[CCode(cname = "git_index_reuc_remove")]
public Error remove(size_t n);
}
[CCode(cname = "git_checkout_opts", has_type_id = false, default_value = "GIT_CHECKOUT_OPTS_INIT")]
public struct checkout_opts {
[CCode(cname = "GIT_CHECKOUT_OPTS_VERSION")]
public const uint VERSION;

public uint version;
public unowned CheckoutStategy checkout_strategy;
public bool disable_filters;
/**
* Directory mode.
*
* If set to 0, the default is 0755 used.
*/
public int dir_mode;
/**
* File mode.
*
* If set to 0, the default is 0644 is used.
*/
public int file_mode;
/**
* File open(3) flags.
*
* If set to 0, the default is O_CREAT | O_TRUNC | O_WRONLY is used.
*/
public int file_open_flags;
public CheckoutNotify notify_flags;
[CCode(cname = "notify_cb", delegate_target_cname = "notify_payload")]
public unowned CheckoutNotify? notify;

/**
* Notify the consumer of checkout progress.
*/
[CCode(cname = "progress_cb", delegate_target_cname = "progress_payload")]
public unowned Progress? progress;

/**
* When not null, arrays of fnmatch pattern specifying which paths should be taken into account
*/
public string_array paths;
/**
* Expected content of workdir, defaults to HEAD
*/
public unowned Tree? baseline;
}

[CCode(cname = "git_config_entry", has_type_id = false)]
public struct config_entry{
public string name;
public string @value;
public ConfigLevel level;
}

/**
* Clone options structure
*/
[CCode(cname = "git_clone_options", has_type_id = false, default_value = "GIT_CLONE_OPTIONS_INIT")]
public struct clone_opts {
[CCode(cname = "GIT_CLONE_OPTIONS_VERSION")]
public const uint VERSION;
public uint version;
public checkout_opts checkout_opts;
/**
* False to create a standard repo, true for a bare repo.
*/
public bool bare;
[CCode(cname = "fetch_progress_cb", delegate_target_cname = "fetch_progress_payload")]
public unowned TransferProgress? fetch_progress;

/**
* The name given to the "origin" remote.
*
* The default is "origin".
*/
public string? remote_name;
/**
* The URL to be used for pushing.
*
* If unset, the fetch URL will be used.
*/
public string? pushurl;
/**
* The fetch specification to be used for fetching.
*
* If unset, "+refs/heads/ *:refs/remotes/<remote_name>/ *"
*/
public string? fetch_spec;
/**
* The fetch specification to be used for pushing.
*
* If unset, the same spec as for fetching.
*/
public string? push_spec;
/**
* Callback to be used if credentials are required during the initial
* fetch.
*/
[CCode(cname = "git_cred_acquire_cb", delegate_target_cname = "cred_acquire_payload")]
public unowned CredAcquire cred_acquire;
/**
* A custom transport to be used for the initial fetch.
*
* If unset, the transport autodetected from the URL.
*/
public unowned transport? transport;
/**
* May be used to specify custom progress callbacks for the origin remote
* before the fetch is initiated.
*/
public unowned remote_callbacks? remote_callbacks;
/**
* May be used to specify the autotag setting before the initial fetch.
*/
AutoTag remote_autotag;
/**
* Gives the name of the branch to checkout.
*
* If unset, use the remote's HEAD.
*/
public string? checkout_branch;
}

[CCode(cname = "git_cvar_map", has_type_id = false)]
public struct config_var_map {
public ConfigVar cvar_type;
public string? str_match;
public int map_value;
}
[CCode(cname = "git_cred")]
public struct cred {
public CredTypes credtype;
public CredFree free;

/**
* Creates a new plain-text username and password credential object.
*
* @param username The username of the credential.
* @param password The password of the credential.
*/
[CCode(cname = "git_cred_userpass_plaintext_new")]
public static Error create_userpass_plaintext(out cred? cred, string username, string password);
}
[CCode(cname = "git_cred_userpass_payload", has_type_id = false)]
public struct cred_userpass {
public string username;
public string password;
/**
* Method usable as {@link CredAcquire}.
*
* This calls {@link cred.create_userpass_plaintext} unless the protocol
* has not specified {@link CredTypes.USERPASS_PLAINTEXT} as an allowed
* type.
*
* @param cred The newly created credential object.
* @param url The resource for which we are demanding a credential.
* @param username_from_url The username that was embedded in a "user@host"
* remote url, or null if not included.
*/
[CCode(cname = "git_cred_userpass", instance_pos = -1)]
public Error acquire(out cred? cred, string url, string? username_from_url, CredTypes allowed_types);
}

/**
* Description of changes to one entry.
*
* When iterating over a diff list object, this will be passed to most
* callback functions and you can use the contents to understand exactly what
* has changed.
*
* The {@link diff_delta.old_file} repesents the "from" side of the diff and
* the {@link diff_delta.new_file} repesents to "to" side of the diff. What
* those means depend on the function that was used to generate the diff and
* will be documented below. You can also use the {@link DiffFlags.REVERSE}
* flag to flip it around.
*
* Although the two sides of the delta are named "old_file" and "new_file",
* they actually may correspond to entries that represent a file, a symbolic
* link, a submodule commit id, or even a tree (if you are tracking type
* changes or ignored/untracked directories).
*
* Under some circumstances, in the name of efficiency, not all fields will
* be filled in, but we generally try to fill in as much as possible.
*/
[CCode(cname = "git_diff_delta", has_type_id = false)]
public struct diff_delta {
public diff_file old_file;
public diff_file new_file;
public DeltaType status;
/**
* For RENAMED and COPIED, value 0-100
*/
public uint similarity;
public DiffFlag flags;
}

/**
* Description of one side of a diff.
* Although this is called a "file", it may actually represent a file, a
* symbolic link, a submodule commit id, or even a tree (although that only
* if you are tracking type changes or ignored/untracked directories).
*

*/
[CCode(cname = "git_diff_file", has_type_id = false)]
public struct diff_file {
/**
* The object id.
*
* If the entry represents an absent side of a diff (e.g., the {@link diff_delta.old_file}
* of a {@link DeltaType.ADDED} delta), then the oid will be zeroes.
*/
[CCode(cname = "oid")]
public object_id id;
/**
* The path to the entry relative to the working directory of the
* repository.
*/
public string path;
public FileMode mode;
/**
* The size of the entry in bytes.
*/
public int size;
public DiffFlag flags;
}

/**
* Structure describing options about how the diff should be executed.
*
* Setting all values of the structure to zero will yield the default
* values. Similarly, passing NULL for the options structure will
* give the defaults. The default values are marked below.
*
* Most of the parameters here are not actually supported at this time.
*/
[CCode(cname = "git_diff_options", has_type_id = false, default_value = "GIT_DIFF_OPTIONS_INIT")]
public struct diff_options {
[CCode(cname = "GIT_DIFF_OPTIONS_VERSION")]
public const uint VERSION;
/**
* Version for the struct
*/
public uint version;
public DiffFlags flags;
/**
* Number of lines of context to show around diffs
*/
public uint16 context_lines;
/**
* Min lines between diff hunks to merge them
*/
public uint16 interhunk_lines;
/**
* "Directory" to prefix to old file names (default "a")
*/
public string? old_prefix;
/**
* "Directory" to prefix to new file names (default "b")
*/
public string? new_prefix;
/**
* Array of paths / patterns to constrain diff
*
* Defaults to all paths
*/
public string_array pathspec;
/**
* Maximum blob size to diff, above this treated as binary
*
* Defaults to 512 MB.
*/
public uint64 max_size;
}

/**
* Structure describing a hunk of a diff.
*/
[CCode(cname = "git_diff_range", has_type_id = false)]
public struct diff_range {
public int old_start;
public int old_lines;
public int new_start;
public int new_lines;
}

[CCode(cname = "git_diff_find_options", has_type_id = false, default_value = "GIT_DIFF_FIND_OPTIONS_INIT ")]
public struct find_options {
[CCode(cname = "GIT_DIFF_FIND_OPTIONS_VERSION")]
public const uint VERSION;
public uint version;
public DiffFind flags;
/**
* Similarity to consider a file renamed (default 50)
*/
public uint rename_threshold;
/**
* Similarity of modified to be eligible rename source (default 50)
*/
public uint rename_from_rewrite_threshold;
/**
* Similarity to consider a file a copy (default 50)
*/
public uint copy_threshold;
/**
* Similarity to split modify into delete/add pair (default 60)
*/
public uint break_rewrite_threshold;
/**
* Maximum similarity sources to examine (e.g., diff's '''-l''' option or
* the '''diff.renameLimit''' config) (default 200)
*/
public uint target_limit;
}

/**
* Time used in a index entry
*/
[CCode(cname = "git_index_time", has_type_id = false)]
public struct index_time {
public int64 seconds;
public uint nanoseconds;
}

/**
* A resolve undo entry in the index.
*/
[CCode(cname = "git_index_reuc_entry", has_type_id = false)]
public struct index_reuc_entry {
uint mode[3];
[CCode(cname = "oid")]
public object_id id[3];
public string path;
}

/**
* Extended options structure for {@link Repository.init_ext}.
*
* This contains extra options that enable additional initialization
* features.
*/
[CCode(cname = "git_repository_init_options", has_type_id = false, default_value = "GIT_REPOSITORY_INIT_OPTIONS_INIT")]
public struct init_options {
/**
* Use permissions configured by umask - the default.
*/
[CCode(cname = "GIT_REPOSITORY_INIT_SHARED_UMASK")]
public const uint32 MODE_SHARED_UMASK;
/**
* Use '''--shared=group''' behavior, chmod'ing the new repo to be group
* writable and "g+sx" for sticky group assignment.
*/
[CCode(cname = "GIT_REPOSITORY_INIT_SHARED_GROUP")]
public const uint32 MODE_SHARED_GROUP;
/**
* Use '''--shared=all''' behavior, adding world readability.
*/
[CCode(cname = "GIT_REPOSITORY_INIT_SHARED_ALL")]
public const uint32 MODE_SHARED_ALL;
[CCode(cname = "GIT_REPOSITORY_INIT_OPTIONS_VERSION")]
public const uint VERSION;
public uint version;
public InitFlag flags;
/**
* The UNIX file mode.
*
* The standard values are {@link MODE_SHARED_UMASK},
* {@link MODE_SHARED_GROUP}, or {@link MODE_SHARED_ALL}, but a custom
* value may be used instead.
*/
public uint32 mode;
/**
* The path to the working dir or null for default (i.e., the repoistory
* path's parent on non-bare repos).
*
* If this is relative path, it will be evaluated relative to the
* repository path.
*
* If this is not the natural working directory, a .git gitlink file will
* be created here linking to the repoitory path.
*/
public string? workdir_path;
/**
* If set, this will be used to initialize the '''description''' file in
* the repository, instead of using the template content.
*/
public string? description;
/**
* When {@link InitFlag.EXTERNAL_TEMPLATE} is set, this contains the path
* to use for the template directory.
*
* If this is null, the config or default directory options will be used
* instead.
*/
public string? template_path;
/**
* The name of the head to point HEAD at. If null, then this will be
* treated as '''master''' and the HEAD ref will be set to
* '''refs/heads/master'''. If this begins with '''refs/''' it will be
* used verbatim; otherwise '''refs/heads/''' will be prefixed.
*/
public string? initial_head;
/**
* If this is non-null, then after the rest of the repository
* initialization is completed, an '''origin''' remote will be added
* pointing to this URL.
*/
public string? origin_url;
}

/**
* Unique identity of any object (commit, tree, blob, tag).
*/
[CCode(cname = "git_oid", has_type_id = false)]
public struct object_id {
/**
* Raw binary formatted id
*/
uint8 id[20];

[CCode(cname = "GIT_OID_HEX_ZERO")]
public const string HEX_ZERO;

/**
* Size (in bytes) of a raw/binary id
*/
[CCode(cname = "GIT_OID_RAWSZ")]
public const int RAW_SIZE;

/**
* Size (in bytes) of a hex formatted id
*/
[CCode(cname = "GIT_OID_HEXSZ")]
public const int HEX_SIZE;

/**
* Minimum length (in number of hex characters,
* (i.e., packets of 4 bits) of an id prefix
*/
[CCode(cname = "GIT_OID_MINPREFIXLEN")]
public const int MIN_PREFIX_LENGTH;

/**
* Parse a hex formatted null-terminated string.
*
* @param id id structure the result is written into.
* @param str input hex string; must be at least 4 characters long.
*/
[CCode(cname = "git_oid_fromstrp")]
public static Error from_string(out object_id id, string str);

/**
* Parse a hex formatted object id
*
* @param id id structure the result is written into.
* @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 id encoded
* in hex (40 bytes).
* @return {@link Error.OK} if valid, {@link Error.NOTID} on failure.
*/
[CCode(cname = "git_oid_fromstr")]
public static Error from_string_exact(out object_id id, string str);

/**
* Parse N characters of a hex formatted object id
*
* If N is odd, N-1 characters will be parsed instead.
* The remaining space in the git_oid will be set to zero.
*
* @param id id structure the result is written into.
* @param data input hex string
* @return {@link Error.OK} if valid.
*/
[CCode(cname = "git_oid_fromstrn")]
public static Error from_array(out object_id id, [CCode(array_length_type = "size_t")] uint8[] data);

/**
* Copy an already raw id
*/
[CCode(cname = "git_oid_fromraw")]
public static void from_raw(out object_id id, [CCode(array_length = false)] uint8[] raw);

/**
* Format an id into a hex string.
*
* @param str output hex string; must be pointing at the start of the hex
* sequence and have at least the number of bytes needed for an id encoded
* in hex (40 bytes). Only the id digits are written; a nul terminator must
* be added by the caller if it is required.
*/
[CCode(cname = "git_oid_fmt", instance_pos = -1)]
public void to_buffer([CCode(array_length = false)] char[] str);

/**
* Format an id into a loose-object path string.
*
* The resulting string is "aa/...", where "aa" is the first two
* hex digitis of the id and "..." is the remaining 38 digits.
*
* @param str output hex string; must be pointing at the start of the hex
* sequence and have at least the number of bytes needed for an oid encoded
* in hex (41 bytes). Only the id digits are written; a nul terminator
* must be added by the caller if it is required.
*/
[CCode(cname = "git_oid_pathfmt", instance_pos = -1)]
public void to_path([CCode(array_length = false)] char[] str);

/**
* Format an id into a string.
*
* @return the string; null if memory is exhausted.
*/
[CCode(cname = "git_oid_allocfmt")]
public string? to_string();

/**
* Format an id into a buffer as a hex format string.
*
* If the buffer is smaller than {@link HEX_SIZE}+1, then the resulting
* id string will be truncated to data.length-1 characters. If there are
* any input parameter errors, then a pointer to an empty string is returned,
* so that the return value can always be printed.
*
* @param buffer the buffer into which the id string is output.
* @return the out buffer pointer, assuming no input parameter errors,
* otherwise a pointer to an empty string.
*/
[CCode(cname = "git_oid_tostr", instance_pos = -1)]
public unowned string to_string_buffer([CCode(array_length_type = "size_t")] char[] buffer);

/**
* Copy an id from one structure to another.
*
* @param dest id structure the result is written into.
* @param src id structure to copy from.
*/
[CCode(cname = "git_oid_cpy")]
public static void copy(out object_id dest, object_id src);

/**
* Copy an id from one structure to another.
*
* @param dest id structure the result is written into.
*/
[CCode(cname = "git_oid_cpy", instance_pos = -1)]
public void copy_to(out object_id dest);

/**
* Compare two id structures.
*
* @param a first id structure.
* @param b second id structure.
* @return <0, 0, >0 if a < b, a == b, a > b.
*/
[CCode(cname = "git_oid_cmp")]
public static int compare(object_id a, object_id b);

/**
* Compare two id structures.
*
* @param b second id structure.
* @return <0, 0, >0 if a < b, a == b, a > b.
*/
[CCode(cname = "git_oid_cmp")]
public int compare_to(object_id b);

/**
* Compare the first //len// hexadecimal characters (packets of 4 bits)
* of two id structures.
*
* @param a first id structure.
* @param b second id structure.
* @param len the number of hex chars to compare
* @return 0 in case of a match
*/
[CCode(cname = "git_oid_ncmp")]
public static int compare_n(object_id a, object_id b, size_t len);

/**
* Compare the first //len// hexadecimal characters (packets of 4 bits)
* of two id structures.
*
* @param b second id structure.
* @param len the number of hex chars to compare
* @return 0 in case of a match
*/
[CCode(cname = "git_oid_ncmp")]
public int compare_n_to(object_id b, size_t len);

/**
* Check if an oid equals an hex formatted object id.
*
* @param str input hex string of an object id.
* @return {@link Error.OK} in case of a match, {@link Error.ERROR} otherwise.
*/
[CCode(cname = "git_oid_streq")]
public Error compare_string(string str);
/**
* Compare two oid structures for equality
*
* @param a first id structure.
* @param b second id structure.
* @return true if equal, false otherwise
*/
[CCode(cname = "git_oid_equal")]
public static bool equal(object_id a, object_id b);
/**
* Compare two oid structures for equality
*
* @param b second id structure.
* @return true if equal, false otherwise
*/
[CCode(cname = "git_oid_equal")]
public bool equal_to(object_id b);

/**
* Determine the id of a buffer containing an object
*
* The resulting id will the itentifier for the data
* buffer as if the data buffer it were to written to the ODB.
*
* @param id the resulting id.
* @param data data to hash
* @param type of the data to hash
*/
[CCode(cname = "git_odb_hash")]
public static Error from_data(out object_id id, [CCode(array_length_type = "size_t")] uint8[] data, ObjectType type);

/**
* Read a file from disk and determine the id
*
* Read the file and compute the id have if it were
* written to the database as an object of the given type.
* Similar functionality to git's //git hash-object// without
* the //-w// flag.
*
* @param id id 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
*/
[CCode(cname = "git_odb_hashfile")]
public static Error hashfile(out object_id id, string path, ObjectType type);
/**
* Check is an oid is all zeros.
*/
[CCode(cname = "git_oid_iszero")]
public bool is_zero();

}
/**
* Controls the behavior of a {@link Push} object.
*/
[CCode(cname = "git_push_options", has_type_id = false, default_value = "GIT_PUSH_OPTIONS_INIT")]
public struct push_options {
[CCode(cname = "GIT_PUSH_OPTIONS_VERSION")]
public const uint VERSION;
public uint version;
/**
* If the transport being used to push to the remote requires the creation
* of a pack file, this controls the number of worker threads used by the
* packbuilder when creating that pack file to be sent to the remote.
*
* If set to false, the packbuilder will auto-detect the number of threads
* to create. The default value is true.
*/
public bool pb_parallelism;
}
[CCode(cname = "struct git_refdb_backend", default_value = "GIT_ODB_BACKEND_INIT", has_type_id = false)]
public struct refdb_backend {
[CCode(cname = "GIT_ODB_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public RefDbCompress? compress;
public RefDbDelete @delete;
public RefDbExists exists;
public RefDbForEach @foreach;
public RefDbForEachGlob? foreach_glob;
public RefDbFree? free;
public RefDbLookup lookup;
public RefDbWrite write;
/**
* Constructors for default refdb backend.
*/
[CCode(cname = "git_refdb_backend_fs")]
public static Error create_backend_fs(out refdb_backend? backend, Repository repo, RefDb refdb);
}
/**
* Reference specification (i.e., some kind of local or remote branch)
*/
[CCode(cname = "git_refspec", has_type_id = false, destroy_function = "")]
public struct ref_spec {
/**
* The destination specifier
*/
public string destination {
[CCode(cname = "git_refspec_dst")]
get;
}
/**
* The force update setting
*/
public bool is_forced {
[CCode(cname = "git_refspec_force")]
get;
}

/**
* The source specifier
*/
public string source {
[CCode(cname = "git_refspec_src")]
get;
}

/**
* Check if a refspec's source descriptor matches a reference name
*
* @param refname the name of the reference to check
*/
[CCode(cname = "git_refspec_src_matches")]
public bool matches_source(string refname);

/**
* Check if a refspec's destination descriptor matches a reference
*
* @param refname the name of the reference to check
*/
[CCode(cname = "git_refspec_dst_matches")]
public bool matches_destination(string refname);

/**
* Transform a target reference to its source reference following the refspec's rules
*
* @param refname where to store the source reference name
* @param name the name of the reference to transform
*/
[CCode(cname = "git_refspec_rtransform", instance_pos = 1.2)]
public Error rtransform([CCode(array_length_type = "size_t")] uint8[] refname, string name);

/**
* Transform a reference to its target following the refspec's rules