Merge branch 'main' into http-use-eauth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 22265 22266 22267 22268 22269 22270 22271 22272 22273 22274 22275 22276 22277 22278 22279 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 22296 22297 22298 22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 22432 22433 22434 22435 22436 22437 22438 22439 22440 22441 22442 22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 22492 22493 22494 22495 22496 22497 22498 22499 22500 22501 22502 22503 22504 22505 22506 22507 22508 22509 22510 22511 22512 22513 22514 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 22530 22531 22532 22533 22534 22535 22536 22537 22538 22539 22540 22541 22542 22543 22544 22545 22546 22547 22548 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 22645 22646 22647 22648 22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 22659 22660 22661 22662 22663 22664 22665 22666 22667 22668 22669 22670 22671 22672 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 22691 22692 22693 22694 22695 22696 22697 22698 22699 22700 22701 22702 22703 22704 22705 22706 22707 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974 22975 22976 22977 22978 22979 22980 22981 22982 22983 22984 22985 22986 22987 22988 22989 22990 22991 22992 22993 22994 22995 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 23122 23123 23124 23125 23126 23127 23128 23129 23130 23131 23132 23133 23134 23135 23136 23137 23138 23139 23140 23141 23142 23143 23144 23145 23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23195 23196 23197 23198 23199 23200 23201 23202 23203 23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 23417 23418 23419 23420 23421 23422 23423 23424 23425 23426 23427 23428 23429 23430 23431 23432 23433 23434 23435 23436 23437 23438 23439 23440 23441 23442 23443 23444 23445 23446 23447 23448 23449 23450 23451 23452 23453 23454 23455 23456 23457 23458 23459 23460 23461 23462 23463 23464 23465 23466 23467 23468 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 23483 23484 23485 23486 23487 23488 23489 23490 23491 23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 23504 23505 23506 23507 23508 23509 23510 23511 23512 23513 23514 23515 23516 23517 23518 23519 23520 23521 23522 23523 23524 23525 23526 23527 23528 23529 23530 23531 23532 23533 23534 23535 23536 23537 23538 23539 23540 23541 23542 23543 23544 23545 23546 23547 23548 23549 23550 23551 23552 23553 23554 23555 23556 23557 23558 23559 23560 23561 23562 23563 23564 23565 23566 23567 23568 23569 23570 23571 23572 23573 23574 23575 23576 23577 23578 23579 23580 23581 23582 23583 23584 23585 23586 23587 23588 23589 23590 23591 23592 23593 23594 23595 23596 23597 23598 23599 23600 23601 23602 23603 23604 23605 23606 23607 23608 23609 23610 23611 23612 23613 23614 23615 23616 23617 23618 23619 23620 23621 23622 23623 23624 23625 23626 23627 23628 23629 23630 23631 23632 23633 23634 23635 23636 23637 23638 23639 23640 23641 23642 23643 23644 23645 23646 23647 23648 23649 23650 23651 23652 23653 23654 23655 23656 23657 23658 23659 23660 23661 23662 23663 23664 23665 23666 23667 23668 23669 23670 23671 23672 23673 23674 23675 23676 23677 23678 23679 23680 23681 23682 23683 23684 23685 23686 23687 23688 23689 23690 23691 23692 23693 23694 23695 23696 23697 23698 23699 23700 23701 23702 23703 23704 23705 23706 23707 23708 23709 23710 23711 23712 23713 23714 23715 23716 23717 23718 23719 23720 23721 23722 23723 23724 23725 23726 23727 23728 23729 23730 23731 23732 23733 23734 23735 23736 23737 23738 23739 23740 23741 23742 23743 23744 23745 23746 23747 23748 23749 23750 23751 23752 23753 23754 23755 23756 23757 23758 23759 23760 23761 23762 23763 23764 23765 23766 23767 23768 23769 23770 23771 23772 23773 23774 23775 23776 23777 23778 23779 23780 23781 23782 23783 23784 23785 23786 23787 23788 23789 23790 23791 23792 23793 23794 23795 23796 23797 23798 23799 23800 23801 23802 23803 23804 23805 23806 23807 23808 23809 23810 23811 23812 23813 23814 23815 23816 23817 23818 23819 23820 23821 23822 23823 23824 23825 23826 23827 23828 23829 23830 23831 23832 23833 23834 23835 23836 23837 23838 23839 23840 23841 23842 23843 23844 23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 23859 23860 23861 23862 23863 23864 23865 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 23903 23904 23905 23906 23907 23908 23909 23910 23911 23912 23913 23914 23915 23916 23917 23918 23919 23920 23921 23922 23923 23924 23925 23926 23927 23928 23929 23930 23931 23932 23933 23934 23935 23936 23937 23938 23939 23940 23941 23942 23943 23944 23945 23946 23947 23948 23949 23950 23951 23952 23953 23954 23955 23956 23957 23958 23959 23960 23961 23962 23963 23964 23965 23966 23967 23968 23969 23970 23971 23972 23973 23974 23975 23976 23977 23978 23979 23980 23981 23982 23983 23984 23985 23986 23987 23988 23989 23990 23991 23992 23993 23994 23995 23996 23997 23998 23999 24000 24001 24002 24003 24004 24005 24006 24007 24008 24009 24010 24011 24012 24013 24014 24015 24016 24017 24018 24019 24020 24021 24022 24023 24024 24025 24026 24027 24028 24029 24030 24031 24032 24033 24034 24035 24036 24037 24038 24039 24040 24041 24042 24043 24044 24045 24046 24047 24048 24049 24050 24051 24052 24053 24054 24055 24056 24057 24058 24059 24060 24061 24062 24063 24064 24065 24066 24067 24068 24069 24070 24071 24072 24073 24074 24075 24076 24077 24078 24079 24080 24081 24082 24083 24084 24085 24086 24087 24088 24089 24090 24091 24092 24093 24094 24095 24096 24097 24098 24099 24100 24101 24102 24103 24104 24105 24106 24107 24108 24109 24110 24111 24112 24113 24114 24115 24116 24117 24118 24119 24120 24121 24122 24123 24124 24125 24126 24127 24128 24129 24130 24131 24132 24133 24134 24135 24136 24137 24138 24139 24140 24141 24142 24143 24144 24145 24146 24147 24148 24149 24150 24151 24152 24153 24154 24155 24156 24157 24158 24159 24160 24161 24162 24163 24164 24165 24166 24167 24168 24169 24170 24171 24172 24173 24174 24175 24176 24177 24178 24179 24180 24181 24182 24183 24184 24185 24186 24187 24188 24189 24190 24191 24192 24193 24194 24195 24196 24197 24198 24199 24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 24216 24217 24218 24219 24220 24221 24222 24223 24224 24225 24226 24227 24228 24229 24230 24231 24232 24233 24234 24235 24236 24237 24238 24239 24240 24241 24242 24243 24244 24245 24246 24247 24248 24249 24250 24251 24252 24253 24254 24255 24256 24257 24258 24259 24260 24261 24262 24263 24264 24265 24266 24267 24268 24269 24270 24271 24272 24273 24274 24275 24276 24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 24294 24295 24296 24297 24298 24299 24300 24301 24302 24303 24304 24305 24306 24307 24308 24309 24310 24311 24312 24313 24314 24315 24316 24317 24318 24319 24320 24321 24322 24323 24324 24325 24326 24327 24328 24329 24330 24331 24332 24333 24334 24335 24336 24337 24338 24339 24340 24341 24342 24343 24344 24345 24346 24347 24348 24349 24350 24351 24352 24353 24354 24355 24356 24357 24358 24359 24360 24361 24362 24363 24364 24365 24366 24367 24368 24369 24370 24371 24372 24373 24374 24375 24376 24377 24378 24379 24380 24381 24382 24383 24384 24385 24386 24387 24388 24389 24390 24391 24392 24393 24394 24395 24396 24397 24398 24399 24400 24401 24402 24403 24404 24405 24406 24407 24408 24409 24410 24411 24412 24413 24414 24415 24416 24417 24418 24419 24420 24421 24422 24423 24424 24425 24426 24427 24428 24429 24430 24431 24432 24433 24434 24435 24436 24437 24438 24439 24440 24441 24442 24443 24444 24445 24446 24447 24448 24449 24450 24451 24452 24453 24454 24455 24456 24457 24458 24459 24460 24461 24462 24463 24464 24465 24466 24467 24468 24469 24470 24471 24472 24473 24474 24475 24476 24477 24478 24479 24480 24481 24482 24483 24484 24485 24486 24487 24488 24489 24490 24491 24492 24493 24494 24495 24496 24497 24498 24499 24500 24501 24502 24503 24504 24505 24506 24507 24508 24509 24510 24511 24512 24513 24514 24515 24516 24517 24518 24519 24520 24521 24522 24523 24524 24525 24526 24527 24528 24529 24530 24531 24532 24533 24534 24535 24536 24537 24538 24539 24540 24541 24542 24543 24544 24545 24546 24547 24548 24549 24550 24551 24552 24553 24554 24555 24556 24557 24558 24559 24560 24561 24562 24563 24564 24565 24566 24567 24568 24569 24570 24571 24572 24573 24574 24575 24576 24577 24578 24579 24580 24581 24582 24583 24584 24585 24586 24587 24588 24589 24590 24591 24592 24593 24594 24595 24596 24597 24598 24599 24600 24601 24602 24603 24604 24605 24606 24607 24608 24609 24610 24611 24612 24613 24614 24615 24616 24617 24618 24619 24620 24621 24622 24623 24624 24625 24626 24627 24628 24629 24630 24631 24632 24633 24634 24635 24636 24637 24638 24639 24640 24641 24642 24643 24644 24645 24646 24647 24648 24649 24650 24651 24652 24653 24654 24655 24656 24657 24658 24659 24660 24661 24662 24663 24664 24665 24666 24667 24668 24669 24670 24671 24672 24673 24674 24675 24676 24677 24678 24679 24680 24681 24682 24683 24684 24685 24686 24687 24688 24689 24690 24691 24692 24693 24694 24695 24696 24697 24698 24699 24700 24701 24702 24703 24704 24705 24706 24707 24708 24709 24710 24711 24712 24713 24714 24715 24716 24717 24718 24719 24720 24721 24722 24723 24724 24725 24726 24727 24728 24729 24730 24731 24732 24733 24734 24735 24736 24737 24738 24739 24740 24741 24742 24743 24744 24745 24746 24747 24748 24749 24750 24751 24752 24753 24754 24755 24756 24757 24758 24759 24760 24761 24762 24763 24764 24765 24766 24767 24768 24769 24770 24771 24772 24773 24774 24775 24776 24777 24778 24779 24780 24781 24782 24783 24784 24785 24786 24787 24788 24789 24790 24791 24792 24793 24794 24795 24796 24797 24798 24799 24800 24801 24802 24803 24804 24805 24806 24807 24808 24809 24810 24811 24812 24813 24814 24815 24816 24817 24818 24819 24820 24821 24822 24823 24824 24825 24826 24827 24828 24829 24830 24831 24832 24833 24834 24835 24836 24837 24838 24839 24840 24841 24842 24843 24844 24845 24846 24847 24848 24849 24850 24851 24852 24853 24854 24855 24856 24857 24858 24859 24860 24861 24862 24863 24864 24865 24866 24867 24868 24869 24870 24871 24872 24873 24874 24875 24876 24877 24878 24879 24880 24881 24882 24883 24884 24885 24886 24887 24888 24889 24890 24891 24892 24893 24894 24895 24896 24897 24898 24899 24900 24901 24902 24903 24904 24905 24906 24907 24908 24909 24910 24911 24912 24913 24914 24915 24916 24917 24918 24919 24920 24921 24922 24923 24924 24925 24926 24927 24928 24929 24930 24931 24932 24933 24934 24935 24936 24937 24938 24939 24940 24941 24942 24943 24944 24945 24946 24947 24948 24949 24950 24951 24952 24953 24954 24955 24956 24957 24958 24959 24960 24961 24962 24963 24964 24965 24966 24967 24968 24969 24970 24971 24972 24973 24974 24975 24976 24977 24978 24979 24980 24981 24982 24983 24984 24985 24986 24987 24988 24989 24990 24991 24992 24993 24994 24995 24996 24997 24998 24999 25000 25001 25002 25003 25004 25005 25006 25007 25008 25009 25010 25011 25012 25013 25014 25015 25016 25017 25018 25019 25020 25021 25022 25023 25024 25025 25026 25027 25028 25029 25030 25031 25032 25033 25034 25035 25036 25037 25038 25039 25040 25041 25042 25043 25044 25045 25046 25047 25048 25049 25050 25051 25052 25053 25054 25055 25056 25057 25058 25059 25060 25061 25062 25063 25064 25065 25066 25067 25068 25069 25070 25071 25072 25073 25074 25075 25076 25077 25078 25079 25080 25081 25082 25083 25084 25085 25086 25087 25088 25089 25090 25091 25092 25093 25094 25095 25096 25097 25098 25099 25100 25101 25102 25103 25104 25105 25106 25107 25108 25109 25110 25111 25112 25113 25114 25115 25116 25117 25118 25119 25120 25121 25122 25123 25124 25125 25126 25127 25128 25129 25130 25131 25132 25133 25134 25135 25136 25137 25138 25139 25140 25141 25142 25143 25144 25145 25146 25147 25148 25149 25150 25151 25152 25153 25154 25155 25156 25157 25158 25159 25160 25161 25162 25163 25164 25165 25166 25167 25168 25169 25170 25171 25172 25173 25174 25175 25176 25177 25178 25179 25180 25181 25182 25183 25184 25185 25186 25187 25188 25189 25190 25191 25192 25193 25194 25195 25196 25197 25198 25199 25200 25201 25202 25203 25204 25205 25206 25207 25208 25209 25210 25211 25212 25213 25214 25215 25216 25217 25218 25219 25220 25221 25222 25223 25224 25225 25226 25227 25228 25229 25230 25231 25232 25233 25234 25235 25236 25237 25238 25239 25240 25241 25242 25243 25244 25245 25246 25247 25248 25249 25250 25251 25252 25253 25254 25255 25256 25257 25258 25259 25260 25261 25262 25263 25264 25265 25266 25267 25268 25269 25270 25271 25272 25273 25274 25275 25276 25277 25278 25279 25280 25281 25282 25283 25284 25285 25286 25287 25288 25289 25290 25291 25292 25293 25294 25295 25296 25297 25298 25299 25300 25301 25302 25303 25304 25305 25306 25307 25308 25309 25310 25311 25312 25313 25314 25315 25316 25317 25318 25319 25320 25321 25322 25323 25324 25325 25326 25327 25328 25329 25330 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 25343 25344 25345 25346 25347 25348 25349 25350 25351 25352 25353 25354 25355 25356 25357 25358 25359 25360 25361 25362 25363 25364 25365 25366 25367 25368 25369 25370 25371 25372 25373 25374 25375 25376 25377 25378 25379 25380 25381 25382 25383 25384 25385 25386 25387 25388 25389 25390 25391 25392 25393 25394 25395 25396 25397 25398 25399 25400 25401 25402 25403 25404 25405 25406 25407 25408 25409 25410 25411 25412 25413 25414 25415 25416 25417 25418 25419 25420 25421 25422 25423 25424 25425 25426 25427 25428 25429 25430 25431 25432 25433 25434 25435 25436 25437 25438 25439 25440 25441 25442 25443 25444 25445 25446 25447 25448 25449 25450 25451 25452 25453 25454 25455 25456 25457 25458 25459 25460 25461 25462 25463 25464 25465 25466 25467 25468 25469 25470 25471 25472 25473 25474 25475 25476 25477 25478 25479 25480 25481 25482 25483 25484 25485 25486 25487 25488 25489 25490 25491 25492 25493 25494 25495 25496 25497 25498 25499 25500 25501 25502 25503 25504 25505 25506 25507 25508 25509 25510 25511 25512 25513 25514 25515 25516 25517 25518 25519 25520 25521 25522 25523 25524 25525 25526 25527 25528 25529 25530 25531 25532 25533 25534 25535 25536 25537 25538 25539 25540 25541 25542 25543 25544 25545 25546 25547 25548 25549 25550 25551 25552 25553 25554 25555 25556 25557 25558 25559 25560 25561 25562 25563 25564 25565 25566 25567 25568 25569 25570 25571 25572 25573 25574 25575 25576 25577 25578 25579 25580 25581 25582 25583 25584 25585 25586 25587 25588 25589 25590 25591 25592 25593 25594 25595 25596 25597 25598 25599 25600 25601 25602 25603 25604 25605 25606 25607 25608 25609 25610 25611 25612 25613 25614 25615 25616 25617 25618 25619 25620 25621 25622 25623 25624 25625 25626 25627 25628 25629 25630 25631 25632 25633 25634 25635 25636 25637 25638 25639 25640 25641 25642 25643 25644 25645 25646 25647 25648 25649 25650 25651 25652 25653 25654 25655 25656 25657 25658 25659 25660 25661 25662 25663 25664 25665 25666 25667 25668 25669 25670 25671 25672 25673 25674 25675 25676 25677 25678 25679 25680 25681 25682 25683 25684 25685 25686 25687 25688 25689 25690 25691 25692 25693 25694 25695 25696 25697 25698 25699 25700 25701 25702 25703 25704 25705 25706 25707 25708 25709 25710 25711 25712 25713 25714 25715 25716 25717 25718 25719 25720 25721 25722 25723 25724 25725 25726 25727 25728 25729 25730 25731 25732 25733 25734 25735 25736 25737 25738 25739 25740 25741 25742 25743 25744 25745 25746 25747 25748 25749 25750 25751 25752 25753 25754 25755 25756 25757 25758 25759 25760 25761 25762 25763 25764 25765 25766 25767 25768 25769 25770 25771 25772 25773 25774 25775 25776 25777 25778 25779 25780 25781 25782 25783 25784 25785 25786 25787 25788 25789 25790 25791 25792 25793 25794 25795 25796 25797 25798 25799 25800 25801 25802 25803 25804 25805 25806 25807 25808 25809 25810 25811 25812 25813 25814 25815 25816 25817 25818 25819 25820 25821 25822 25823 25824 25825 25826 25827 25828 25829 25830 25831 25832 25833 25834 25835 25836 25837 25838 25839 25840 25841 25842 25843 25844 25845 25846 25847 25848 25849 25850 25851 25852 25853 25854 25855 25856 25857 25858 25859 25860 25861 25862 25863 25864 25865 25866 25867 25868 25869 25870 25871 25872 25873 25874 25875 25876 25877 25878 25879 25880 25881 25882 25883 25884 25885 25886 25887 25888 25889 25890 25891 25892 25893 25894 25895 25896 25897 25898 25899 25900 25901 25902 25903 25904 25905 25906 25907 25908 25909 25910 25911 25912 25913 25914 25915 25916 25917 25918 25919 25920 25921 25922 25923 25924 25925 25926 25927 25928 25929 25930 25931 25932 25933 25934 25935 25936 25937 25938 25939 25940 25941 25942 25943 25944 25945 25946 25947 25948 25949 25950 25951 25952 25953 25954 25955 25956 25957 25958 25959 25960 25961 25962 25963 25964 25965 25966 25967 25968 25969 25970 25971 25972 25973 25974 25975 25976 25977 25978 25979 25980 25981 25982 25983 25984 25985 25986 25987 25988 25989 25990 25991 25992 25993 25994 25995 25996 25997 25998 25999 26000 26001 26002 26003 26004 26005 26006 26007 26008 26009 26010 26011 26012 26013 26014 26015 26016 26017 26018 26019 26020 26021 26022 26023 26024 26025 26026 26027 26028 26029 26030 26031 26032 26033 26034 26035 26036 26037 26038 26039 26040 26041 26042 26043 26044 26045 26046 26047 26048 26049 26050 26051 26052 26053 26054 26055 26056 26057 26058 26059 26060 26061 26062 26063 26064 26065 26066 26067 26068 26069 26070 26071 26072 26073 26074 26075 26076 26077 26078 26079 26080 26081 26082 26083 26084 26085 26086 26087 26088 26089 26090 26091 26092 26093 26094 26095 26096 26097 26098 26099 26100 26101 26102 26103 26104 26105 26106 26107 26108 26109 26110 26111 26112 26113 26114 26115 26116 26117 26118 26119 26120 26121 26122 26123 26124 26125 26126 26127 26128 26129 26130 26131 26132 26133 26134 26135 26136 26137 26138 26139 26140 26141 26142 26143 26144 26145 26146 26147 26148 26149 26150 26151 26152 26153 26154 26155 26156 26157 26158 26159 26160 26161 26162 26163 26164 26165 26166 26167 26168 26169 26170 26171 26172 26173 26174 26175 26176 26177 26178 26179 26180 26181 26182 26183 26184 26185 26186 26187 26188 26189 26190 26191 26192 26193 26194 26195 26196 26197 26198 26199 26200 26201 26202 26203 26204 26205 26206 26207 26208 26209 26210 26211 26212 26213 26214 26215 26216 26217 26218 26219 26220 26221 26222 26223 26224 26225 26226 26227 26228 26229 26230 26231 26232 26233 26234 26235 26236 26237 26238 26239 26240 26241 26242 26243 26244 26245 26246 26247 26248 26249 26250 26251 26252 26253 26254 26255 26256 26257 26258 26259 26260 26261 26262 26263 26264 26265 26266 26267 26268 26269 26270 26271 26272 26273 26274 26275 26276 26277 26278 26279 26280 26281 26282 26283 26284 26285 26286 26287 26288 26289 26290 26291 26292 26293 26294 26295 26296 26297 26298 26299 26300 26301 26302 26303 26304 26305 26306 26307 26308 26309 26310 26311 26312 26313 26314 26315 26316 26317 26318 26319 26320 26321 26322 26323 26324 26325 26326 26327 26328 26329 26330 26331 26332 26333 26334 26335 26336 26337 26338 26339 26340 26341 26342 26343 26344 26345 26346 26347 26348 26349 26350 26351 26352 26353 26354 26355 26356 26357 26358 26359 26360 26361 26362 26363 26364 26365 26366 26367 26368 26369 26370 26371 26372 26373 26374 26375 26376 26377 26378 26379 26380 26381 26382 26383 26384 26385 26386 26387 26388 26389 26390 26391 26392 26393 26394 26395 26396 26397 26398 26399 26400 26401 26402 26403 26404 26405 26406 26407 26408 26409 26410 26411 26412 26413 26414 26415 26416 26417 26418 26419 26420 26421 26422 26423 26424 26425 26426 26427 26428 26429 26430 26431 26432 26433 26434 26435 26436 26437 26438 26439 26440 26441 26442 26443 26444 26445 26446 26447 26448 26449 26450 26451 26452 26453 26454 26455 26456 26457 26458 26459 26460 26461 26462 26463 26464 26465 26466 26467 26468 26469 26470 26471 26472 26473 26474 26475 26476 26477 26478 26479 26480 26481 26482 26483 26484 26485 26486 26487 26488 26489 26490 26491 26492 26493 26494 26495 26496 26497 26498 26499 26500 26501 26502 26503 26504 26505 26506 26507 26508 26509 26510 26511 26512 26513 26514 26515 26516 26517 26518 26519 26520 26521 26522 26523 26524 26525 26526 26527 26528 26529 26530 26531 26532 26533 26534 26535 26536 26537 26538 26539 26540 26541 26542 26543 26544 26545 26546 26547 26548 26549 26550 26551 26552 26553 26554 26555 26556 26557 26558 26559 26560 26561 26562 26563 26564 26565 26566 26567 26568 26569 26570 26571 26572 26573 26574 26575 26576 26577 26578 26579 26580 26581 26582 26583 26584 26585 26586 26587 26588 26589 26590 26591 26592 26593 26594 26595 26596 26597 26598 26599 26600 26601 26602 26603 26604 26605 26606 26607 26608 26609 26610 26611 26612 26613 26614 26615 26616 26617 26618 26619 26620 26621 26622 26623 26624 26625 26626 26627 26628 26629 26630 26631 26632 26633 26634 26635 26636 26637 26638 26639 26640 26641 26642 26643 26644 26645 26646 26647 26648 26649 26650 26651 26652 26653 26654 26655 26656 26657 26658 26659 26660 26661 26662 26663 26664 26665 26666 26667 26668 26669 26670 26671 26672 26673 26674 26675 26676 26677 26678 26679 26680 26681 26682 26683 26684 26685 26686 26687 26688 26689 26690 26691 26692 26693 26694 26695 26696 26697 26698 26699 26700 26701 26702 26703 26704 26705 26706 26707 26708 26709 26710 26711 26712 26713 26714 26715 26716 26717 26718 26719 26720 26721 26722 26723 26724 26725 26726 26727 26728 26729 26730 26731 26732 26733 26734 26735 26736 26737 26738 26739 26740 26741 26742 26743 26744 26745 26746 26747 26748 26749 26750 26751 26752 26753 26754 26755 26756 26757 26758 26759 26760 26761 26762 26763 26764 26765 26766 26767 26768 26769 26770 26771 26772 26773 26774 26775 26776 26777 26778 26779 26780 26781 26782 26783 26784 26785 26786 26787 26788 26789 26790 26791 26792 26793 26794 26795 26796 26797 26798 26799 26800 26801 26802 26803 26804 26805 26806 26807 26808 26809 26810 26811 26812 26813 26814 26815 26816 26817 26818 26819 26820 26821 26822 26823 26824 26825 26826 26827 26828 26829 26830 26831 26832 26833 26834 26835 26836 26837 26838 26839 26840 26841 26842 26843 26844 26845 26846 26847 26848 26849 26850 26851 26852 26853 26854 26855 26856 26857 26858 26859 26860 26861 26862 26863 26864 26865 26866 26867 26868 26869 26870 26871 26872 26873 26874 26875 26876 26877 26878 26879 26880 26881 26882 26883 26884 26885 26886 26887 26888 26889 26890 26891 26892 26893 26894 26895 26896 26897 26898 26899 26900 26901 26902 26903 26904 26905 26906 26907 26908 26909 26910 26911 26912 26913 26914 26915 26916 26917 26918 26919 26920 26921 26922 26923 26924 26925 26926 26927 26928 26929 26930 26931 26932 26933 26934 26935 26936 26937 26938 26939 26940 26941 26942 26943 26944 26945 26946 26947 26948 26949 26950 26951 26952 26953 26954 26955 26956 26957 26958 26959 26960 26961 26962 26963 26964 26965 26966 26967 26968 26969 26970 26971 26972 26973 26974 26975 26976 26977 26978 26979 26980 26981 26982 26983 26984 26985 26986 26987 26988 26989 26990 26991 26992 26993 26994 26995 26996 26997 26998 26999 27000 27001 27002 27003 27004 27005 27006 27007 27008 27009 27010 27011 27012 27013 27014 27015 27016 27017 27018 27019 27020 27021 27022 27023 27024 27025 27026 27027 27028 27029 27030 27031 27032 27033 27034 27035 27036 27037 27038 27039 27040 27041 27042 27043 27044 27045 27046 27047 27048 27049 27050 27051 27052 27053 27054 27055 27056 27057 27058 27059 27060 27061 27062 27063 27064 27065 27066 27067 27068 27069 27070 27071 27072 27073 27074 27075 27076 27077 27078 27079 27080 27081 27082 27083 27084 27085 27086 27087 27088 27089 27090 27091 27092 27093 27094 27095 27096 27097 27098 27099 27100 27101 27102 27103 27104 27105 27106 27107 27108 27109 27110 27111 27112 27113 27114 27115 27116 27117 27118 27119 27120 27121 27122 27123 27124 27125 27126 27127 27128 27129 27130 27131 27132 27133 27134 27135 27136 27137 27138 27139 27140 27141 27142 27143 27144 27145 27146 27147 27148 27149 27150 27151 27152 27153 27154 27155 27156 27157 27158 27159 27160 27161 27162 27163 27164 27165 27166 27167 27168 27169 27170 27171 27172 27173 27174 27175 27176 27177 27178 27179 27180 27181 27182 27183 27184 27185 27186 27187 27188 27189 27190 27191 27192 27193 27194 27195 27196 27197 27198 27199 27200 27201 27202 27203 27204 27205 27206 27207 27208 27209 27210 27211 27212 27213 27214 27215 27216 27217 27218 27219 27220 27221 27222 27223 27224 27225 27226 27227 27228 27229 27230 27231 27232 27233 27234 27235 27236 27237 27238 27239 27240 27241 27242 27243 27244 27245 27246 27247 27248 27249 27250 27251 27252 27253 27254 27255 27256 27257 27258 27259 27260 27261 27262 27263 27264 27265 27266 27267 27268 27269 27270 27271 27272 27273 27274 27275 27276 27277 27278 27279 27280 27281 27282 27283 27284 27285 27286 27287 27288 27289 27290 27291 27292 27293 27294 27295 27296 27297 27298 27299 27300 27301 27302 27303 27304 27305 27306 27307 27308 27309 27310 27311 27312 27313 27314 27315 27316 27317 27318 27319 27320 27321 27322 27323 27324 27325 27326 27327 27328 27329 27330 27331 27332 27333 27334 27335 27336 27337 27338 27339 27340 27341 27342 27343 27344 27345 27346 27347 27348 27349 27350 27351 27352 27353 27354 27355 27356 27357 27358 27359 27360 27361 27362 27363 27364 27365 27366 27367 27368 27369 27370 27371 27372 27373 27374 27375 27376 27377 27378 27379 27380 27381 27382 27383 27384 27385 27386 27387 27388 27389 27390 27391 27392 27393 27394 27395 27396 27397 27398 27399 27400 27401 27402 27403 27404 27405 27406 27407 27408 27409 27410 27411 27412 27413 27414 27415 27416 27417 27418 27419 27420 27421 27422 27423 27424 27425 27426 27427 27428 27429 27430 27431 27432 27433 27434 27435 27436 27437 27438 27439 27440 27441 27442 27443 27444 27445 27446 27447 27448 27449 27450 27451 27452 27453 27454 27455 27456 27457 27458 27459 27460 27461 27462 27463 27464 27465 27466 27467 27468 27469 27470 27471 27472 27473 27474 27475 27476 27477 27478 27479 27480 27481 27482 27483 27484 27485 27486 27487 27488 27489 27490 27491 27492 27493 27494 27495 27496 27497 27498 27499 27500 27501 27502 27503 27504 27505 27506 27507 27508 27509 27510 27511 27512 27513 27514 27515 27516 27517 27518 27519 27520 27521 27522 27523 27524 27525 27526 27527 27528 27529 27530 27531 27532 27533 27534 27535 27536 27537 27538 27539 27540 27541 27542 27543 27544 27545 27546 27547 27548 27549 27550 27551 27552 27553 27554 27555 27556 27557 27558 27559 27560 27561 27562 27563 27564 27565 27566 27567 27568 27569 27570 27571 27572 27573 27574 27575 27576 27577 27578 27579 27580 27581 27582 27583 27584 27585 27586 27587 27588 27589 27590 27591 27592 27593 27594 27595 27596 27597 27598 27599 27600 27601 27602 27603 27604 27605 27606 27607 27608 27609 27610 27611 27612 27613 27614 27615 27616 27617 27618 27619 27620 27621 27622 27623 27624 27625 27626 27627 27628 27629 27630 27631 27632 27633 27634 27635 27636 27637 27638 27639 27640 27641 27642 27643 27644 27645 27646 27647 27648 27649 27650 27651 27652 27653 27654 27655 27656 27657 27658 27659 27660 27661 27662 27663 27664 27665 27666 27667 27668 27669 27670 27671 27672 27673 27674 27675 27676 27677 27678 27679 27680 27681 27682 27683 27684 27685 27686 27687 27688 27689 27690 27691 27692 27693 27694 27695 27696 27697 27698 27699 27700 27701 27702 27703 27704 27705 27706 27707 27708 27709 27710 27711 27712 27713 27714 27715 27716 27717 27718 27719 27720 27721 27722 27723 27724 27725 27726 27727 27728 27729 27730 27731 27732 27733 27734 27735 27736 27737 27738 27739 27740 27741 27742 27743 27744 27745 27746 27747 27748 27749 27750 27751 27752 27753 27754 27755 27756 27757 27758 27759 27760 27761 27762 27763 27764 27765 27766 27767 27768 27769 27770 27771 27772 27773 27774 27775 27776 27777 27778 27779 27780 27781 27782 27783 27784 27785 27786 27787 27788 27789 27790 27791 27792 27793 27794 27795 27796 27797 27798 27799 27800 27801 27802 27803 27804 27805 27806 27807 27808 27809 27810 27811 27812 27813 27814 27815 27816 27817 27818 27819 27820 27821 27822 27823 27824 27825 27826 27827 27828 27829 27830 27831 27832 27833 27834 27835 27836 27837 27838 27839 27840 27841 27842 27843 27844 27845 27846 27847 27848 27849 27850 27851 27852 27853 27854 27855 27856 27857 27858 27859 27860 27861 27862 27863 27864 27865 27866 27867 27868 27869 27870 27871 27872 27873 27874 27875 27876 27877 27878 27879 27880 27881 27882 27883 27884 27885 27886 27887 27888 27889 27890 27891 27892 27893 27894 27895 27896 27897 27898 27899 27900 27901 27902 27903 27904 27905 27906 27907 27908 27909 27910 27911 27912 27913 27914 27915 27916 27917 27918 27919 27920 27921 27922 27923 27924 27925 27926 27927 27928 27929 27930 27931 27932 27933 27934 27935 27936 27937 27938 27939 27940 27941 27942 27943 27944 27945 27946 27947 27948 27949 27950 27951 27952 27953 27954 27955 27956 27957 27958 27959 27960 27961 27962 27963 27964 27965 27966 27967 27968 27969 27970 27971 27972 27973 27974 27975 27976 27977 27978 27979 27980 27981 27982 27983 27984 27985 27986 27987 27988 27989 27990 27991 27992 27993 27994 27995 27996 27997 27998 27999 28000 28001 28002 28003 28004 28005 28006 28007 28008 28009 28010 28011 28012 28013 28014 28015 28016 28017 28018 28019 28020 28021 28022 28023 28024 28025 28026 28027 28028 28029 28030 28031 28032 28033 28034 28035 28036 28037 28038 28039 28040 28041 28042 28043 28044 28045 28046 28047 28048 28049 28050 28051 28052 28053 28054 28055 28056 28057 28058 28059 28060 28061 28062 28063 28064 28065 28066 28067 28068 28069 28070 28071 28072 28073 28074 28075 28076 28077 28078 28079 28080 28081 28082 28083 28084 28085 28086 28087 28088 28089 28090 28091 28092 28093 28094 28095 28096 28097 28098 28099 28100 28101 28102 28103 28104 28105 28106 28107 28108 28109 28110 28111 28112 28113 28114 28115 28116 28117 28118 28119 28120 28121 28122 28123 28124 28125 28126 28127 28128 28129 28130 28131 28132 28133 28134 28135 28136 28137 28138 28139 28140 28141 28142 28143 28144 28145 28146 28147 28148 28149 28150 28151 28152 28153 28154 28155 28156 28157 28158 28159 28160 28161 28162 28163 28164 28165 28166 28167 28168 28169 28170 28171 28172 28173 28174 28175 28176 28177 28178 28179 28180 28181 28182 28183 28184 28185 28186 28187 28188 28189 28190 28191 28192 28193 28194 28195 28196 28197 28198 28199 28200 28201 28202 28203 28204 28205 28206 28207 28208 28209 28210 28211 28212 28213 28214 28215 28216 28217 28218 28219 28220 28221 28222 28223 28224 28225 28226 28227 28228 28229 28230 28231 28232 28233 28234 28235 28236 28237 28238 28239 28240 28241 28242 28243 28244 28245 28246 28247 28248 28249 28250 28251 28252 28253 28254 28255 28256 28257 28258 28259 28260 28261 28262 28263 28264 28265 28266 28267 28268 28269 28270 28271 28272 28273 28274 28275 28276 28277 28278 28279 28280 28281 28282 28283 28284 28285 28286 28287 28288 28289 28290 28291 28292 28293 28294 28295 28296 28297 28298 28299 28300 28301 28302 28303 28304 28305 28306 28307 28308 28309 28310 28311 28312 28313 28314 28315 28316 28317 28318 28319 28320 28321 28322 28323 28324 28325 28326 28327 28328 28329 28330 28331 28332 28333 28334 28335 28336 28337 28338 28339 28340 28341 28342 28343 28344 28345 28346 28347 28348 28349 28350 28351 28352 28353 28354 28355 28356 28357 28358 28359 28360 28361 28362 28363 28364 28365 28366 28367 28368 28369 28370 28371 28372 28373 28374 28375 28376 28377 28378 28379 28380 28381 28382 28383 28384 28385 28386 28387 28388 28389 28390 28391 28392 28393 28394 28395 28396 28397 28398 28399 28400 28401 28402 28403 28404 28405 28406 28407 28408 28409 28410 28411 28412 28413 28414 28415 28416 28417 28418 28419 28420 28421 28422 28423 28424 28425 28426 28427 28428 28429 28430 28431 28432 28433 28434 28435 28436 28437 28438 28439 28440 28441 28442 28443 28444 28445 28446 28447 28448 28449 28450 28451 28452 28453 28454 28455 28456 28457 28458 28459 28460 28461 28462 28463 28464 28465 28466 28467 28468 28469 28470 28471 28472 28473 28474 28475 28476 28477 28478 28479 28480 28481 28482 28483 28484 28485 28486 28487 28488 28489 28490 28491 28492 28493 28494 28495 28496 28497 28498 28499 28500 28501 28502 28503 28504 28505 28506 28507 28508 28509 28510 28511 28512 28513 28514 28515 28516 28517 28518 28519 28520 28521 28522 28523 28524 28525 28526 28527 28528 28529 28530 28531 28532 28533 28534 28535 28536 28537 28538 28539 28540 28541 28542 28543 28544 28545 28546 28547 28548 28549 28550 28551 28552 28553 28554 28555 28556 28557 28558 28559 28560 28561 28562 28563 28564 28565 28566 28567 28568 28569 28570 28571 28572 28573 28574 28575 28576 28577 28578 28579 28580 28581 28582 28583 28584 28585 28586 28587 28588 28589 28590 28591 28592 28593 28594 28595 28596 28597 28598 28599 28600 28601 28602 28603 28604 28605 28606 28607 28608 28609 28610 28611 28612 28613 28614 28615 28616 28617 28618 28619 28620 28621 28622 28623 28624 28625 28626 28627 28628 28629 28630 28631 28632 28633 28634 28635 28636 28637 28638 28639 28640 28641 28642 28643 28644 28645 28646 28647 28648 28649 28650 28651 28652 28653 28654 28655 28656 28657 28658 28659 28660 28661 28662 28663 28664 28665 28666 28667 28668 28669 28670 28671 28672 28673 28674 28675 28676 28677 28678 28679 28680 28681 28682 28683 28684 28685 28686 28687 28688 28689 28690 28691 28692 28693 28694 28695 28696 28697 28698 28699 28700 28701 28702 28703 28704 28705 28706 28707 28708 28709 28710 28711 28712 28713 28714 28715 28716 28717 28718 28719 28720 28721 28722 28723 28724 28725 28726 28727 28728 28729 28730 28731 28732 28733 28734 28735 28736 28737 28738 28739 28740 28741 28742 28743 28744 28745 28746 28747 28748 28749 28750 28751 28752 28753 28754 28755 28756 28757 28758 28759 28760 28761 28762 28763 28764 28765 28766 28767 28768 28769 28770 28771 28772 28773 28774 28775 28776 28777 28778 28779 28780 28781 28782 28783 28784 28785 28786 28787 28788 28789 28790 28791 28792 28793 28794 28795 28796 28797 28798 28799 28800 28801 28802 28803 28804 28805 28806 28807 28808 28809 28810 28811 28812 28813 28814 28815 28816 28817 28818 28819 28820 28821 28822 28823 28824 28825 28826 28827 28828 28829 28830 28831 28832 28833 28834 28835 28836 28837 28838 28839 28840 28841 28842 28843 28844 28845 28846 28847 28848 28849 28850 28851 28852 28853 28854 28855 28856 28857 28858 28859 28860 28861 28862 28863 28864 28865 28866 28867 28868 28869 28870 28871 28872 28873 28874 28875 28876 28877 28878 28879 28880 28881 28882 28883 28884 28885 28886 28887 28888 28889 28890 28891 28892 28893 28894 28895 28896 28897 28898 28899 28900 28901 28902 28903 28904 28905 28906 28907 28908 28909 28910 28911 28912 28913 28914 28915 28916 28917 28918 28919 28920 28921 28922 28923 28924 28925 28926 28927 28928 28929 28930 28931 28932 28933 28934 28935 28936 28937 28938 28939 28940 28941 28942 28943 28944 28945 28946 28947 28948 28949 28950 28951 28952 28953 28954 28955 28956 28957 28958 28959 28960 28961 28962 28963 28964 28965 28966 28967 28968 28969 28970 28971 28972 28973 28974 28975 28976 28977 28978 28979 28980 28981 28982 28983 28984 28985 28986 28987 28988 28989 28990 28991 28992 28993 28994 28995 28996 28997 28998 28999 29000 29001 29002 29003 29004 29005 29006 29007 29008 29009 29010 29011 29012 29013 29014 29015 29016 29017 29018 29019 29020 29021 29022 29023 29024 29025 29026 29027 29028 29029 29030 29031 29032 29033 29034 29035 29036 29037 29038 29039 29040 29041 29042 29043 29044 29045 29046 29047 29048 29049 29050 29051 29052 29053 29054 29055 29056 29057 29058 29059 29060 29061 29062 29063 29064 29065 29066 29067 29068 29069 29070 29071 29072 29073 29074 29075 29076 29077 29078 29079 29080 29081 29082 29083 29084 29085 29086 29087 29088 29089 29090 29091 29092 29093 29094 29095 29096 29097 29098 29099 29100 29101 29102 29103 29104 29105 29106 29107 29108 29109 29110 29111 29112 29113 29114 29115 29116 29117 29118 29119 29120 29121 29122 29123 29124 29125 29126 29127 29128 29129 29130 29131 29132 29133 29134 29135 29136 29137 29138 29139 29140 29141 29142 29143 29144 29145 29146 29147 29148 29149 29150 29151 29152 29153 29154 29155 29156 29157 29158 29159 29160 29161 29162 29163 29164 29165 29166 29167 29168 29169 29170 29171 29172 29173 29174 29175 29176 29177 29178 29179 29180 29181 29182 29183 29184 29185 29186 29187 29188 29189 29190 29191 29192 29193 29194 29195 29196 29197 29198 29199 29200 29201 29202 29203 29204 29205 29206 29207 29208 29209 29210 29211 29212 29213 29214 29215 29216 29217 29218 29219 29220 29221 29222 29223 29224 29225 29226 29227 29228 29229 29230 29231 29232 29233 29234 29235 29236 29237 29238 29239 29240 29241 29242 29243 29244 29245 29246 29247 29248 29249 29250 29251 29252 29253 29254 29255 29256 29257 29258 29259 29260 29261 29262 29263 29264 29265 29266 29267 29268 29269 29270 29271 29272 29273 29274 29275 29276 29277 29278 29279 29280 29281 29282 29283 29284 29285 29286 29287 29288 29289 29290 29291 29292 29293 29294 29295 29296 29297 29298 29299 29300 29301 29302 29303 29304 29305 29306 29307 29308 29309 29310 29311 29312 29313 29314 29315 29316 29317 29318 29319 29320 29321 29322 29323 29324 29325 29326 29327 29328 29329 29330 29331 29332 29333 29334 29335 29336 29337 29338 29339 29340 29341 29342 29343 29344 29345 29346 29347 29348 29349 29350 29351 29352 29353 29354 29355 29356 29357 29358 29359 29360 29361 29362 29363 29364 29365 29366 29367 29368 29369 29370 29371 29372 29373 29374 29375 29376 29377 29378 29379 29380 29381 29382 29383 29384 29385 29386 29387 29388 29389 29390 29391 29392 29393 29394 29395 29396 29397 29398 29399 29400 29401 29402 29403 29404 29405 29406 29407 29408 29409 29410 29411 29412 29413 29414 29415 29416 29417 29418 29419 29420 29421 29422 29423 29424 29425 29426 29427 29428 29429 29430 29431 29432 29433 29434 29435 29436 29437 29438 29439 29440 29441 29442 29443 29444 29445 29446 29447 29448 29449 29450 29451 29452 29453 29454 29455 29456 29457 29458 29459 29460 29461 29462 29463 29464 29465 29466 29467 29468 29469 29470 29471 29472 29473 29474 29475 29476 29477 29478 29479 29480 29481 29482 29483 29484 29485 29486 29487 29488 29489 29490 29491 29492 29493 29494 29495 29496 29497 29498 29499 29500 29501 29502 29503 29504 29505 29506 29507 29508 29509 29510 29511 29512 29513 29514 29515 29516 29517 29518 29519 29520 29521 29522 29523 29524 29525 29526 29527 29528 29529 29530 29531 29532 29533 29534 29535 29536 29537 29538 29539 29540 29541 29542 29543 29544 29545 29546 29547 29548 29549 29550 29551 29552 29553 29554 29555 29556 29557 29558 29559 29560 29561 29562 29563 29564 29565 29566 29567 29568 29569 29570 29571 29572 29573 29574 29575 29576 29577 29578 29579 29580 29581 29582 29583 29584 29585 29586 29587 29588 29589 29590 29591 29592 29593 29594 29595 29596 29597 29598 29599 29600 29601 29602 29603 29604 29605 29606 29607 29608 29609 29610 29611 29612 29613 29614 29615 29616 29617 29618 29619 29620 29621 29622 29623 29624 29625 29626 29627 29628 29629 29630 29631 29632 29633 29634 29635 29636 29637 29638 29639 29640 29641 29642 29643 29644 29645 29646 29647 29648 29649 29650 29651 29652 29653 29654 29655 29656 29657 29658 29659 29660 29661 29662 29663 29664 29665 29666 29667 29668 29669 29670 29671 29672 29673 29674 29675 29676 29677 29678 29679 29680 29681 29682 29683 29684 29685 29686 29687 29688 29689 29690 29691 29692 29693 29694 29695 29696 29697 29698 29699 29700 29701 29702 29703 29704 29705 29706 29707 29708 29709 29710 29711 29712 29713 29714 29715 29716 29717 29718 29719 29720 29721 29722 29723 29724 29725 29726 29727 29728 29729 29730 29731 29732 29733 29734 29735 29736 29737 29738 29739 29740 29741 29742 29743 29744 29745 29746 29747 29748 29749 29750 29751 29752 29753 29754 29755 29756 29757 29758 29759 29760 29761 29762 29763 29764 29765 29766 29767 29768 29769 29770 29771 29772 29773 29774 29775 29776 29777 29778 29779 29780 29781 29782 29783 29784 29785 29786 29787 29788 29789 29790 29791 29792 29793 29794 29795 29796 29797 29798 29799 29800 29801 29802 29803 29804 29805 29806 29807 29808 29809 29810 29811 29812 29813 29814 29815 29816 29817 29818 29819 29820 29821 29822 29823 29824 29825 29826 29827 29828 29829 29830 29831 29832 29833 29834 29835 29836 29837 29838 29839 29840 29841 29842 29843 29844 29845 29846 29847 29848 29849 29850 29851 29852 29853 29854 29855 29856 29857 29858 29859 29860 29861 29862 29863 29864 29865 29866 29867 29868 29869 29870 29871 29872 29873 29874 29875 29876 29877 29878 29879 29880 29881 29882 29883 29884 29885 29886 29887 29888 29889 29890 29891 29892 29893 29894 29895 29896 29897 29898 29899 29900 29901 29902 29903 29904 29905 29906 29907 29908 29909 29910 29911 29912 29913 29914 29915 29916 29917 29918 29919 29920 29921 29922 29923 29924 29925 29926 29927 29928 29929 29930 29931 29932 29933 29934 29935 29936 29937 29938 29939 29940 29941 29942 29943 29944 29945 29946 29947 29948 29949 29950 29951 29952 29953 29954 29955 29956 29957 29958 29959 29960 29961 29962 29963 29964 29965 29966 29967 29968 29969 29970 29971 29972 29973 29974 29975 29976 29977 29978 29979 29980 29981 29982 29983 29984 29985 29986 29987 29988 29989 29990 29991 29992 29993 29994 29995 29996 29997 29998 29999 30000 30001 30002 30003 30004 30005 30006 30007 30008 30009 30010 30011 30012 30013 30014 30015 30016 30017 30018 30019 30020 30021 30022 30023 30024 30025 30026 30027 30028 30029 30030 30031 30032 30033 30034 30035 30036 30037 30038 30039 30040 30041 30042 30043 30044 30045 30046 30047 30048 30049 30050 30051 30052 30053 30054 30055 30056 30057 30058 30059 30060 30061 30062 30063 30064 30065 30066 30067 30068 30069 30070 30071 30072 30073 30074 30075 30076 30077 30078 30079 30080 30081 30082 30083 30084 30085 30086 30087 30088 30089 30090 30091 30092 30093 30094 30095 30096 30097 30098 30099 30100 30101 30102 30103 30104 30105 30106 30107 30108 30109 30110 30111 30112 30113 30114 30115 30116 30117 30118 30119 30120 30121 30122 30123 30124 30125 30126 30127 30128 30129 30130 30131 30132 30133 30134 30135 30136 30137 30138 30139 30140 30141 30142 30143 30144 30145 30146 30147 30148 30149 30150 30151 30152 30153 30154 30155 30156 30157 30158 30159 30160 30161 30162 30163 30164 30165 30166 30167 30168 30169 30170 30171 30172 30173 30174 30175 30176 30177 30178 30179 30180 30181 30182 30183 30184 30185 30186 30187 30188 30189 30190 30191 30192 30193 30194 30195 30196 30197 30198 30199 30200 30201 30202 30203 30204 30205 30206 30207 30208 30209 30210 30211 30212 30213 30214 30215 30216 30217 30218 30219 30220 30221 30222 30223 30224 30225 30226 30227 30228 30229 30230 30231 30232 30233 30234 30235 30236 30237 30238 30239 30240 30241 30242 30243 30244 30245 30246 30247 30248 30249 30250 30251 30252 30253 30254 30255 30256 30257 30258 30259 30260 30261 30262 30263 30264 30265 30266 30267 30268 30269 30270 30271 30272 30273 30274 30275 30276 30277 30278 30279 30280 30281 30282 30283 30284 30285 30286 30287 30288 30289 30290 30291 30292 30293 30294 30295 30296 30297 30298 30299 30300 30301 30302 30303 30304 30305 30306 30307 30308 30309 30310 30311 30312 30313 30314 30315 30316 30317 30318 30319 30320 30321 30322 30323 30324 30325 30326 30327 30328 30329 30330 30331 30332 30333 30334 30335 30336 30337 30338 30339 30340 30341 30342 30343 30344 30345 30346 30347 30348 30349 30350 30351 30352 30353 30354 30355 30356 30357 30358 30359 30360 30361 30362 30363 30364 30365 30366 30367 30368 30369 30370 30371 30372 30373 30374 30375 30376 30377 30378 30379 30380 30381 30382 30383 30384 30385 30386 30387 30388 30389 30390 30391 30392 30393 30394 30395 30396 30397 30398 30399 30400 30401 30402 30403 30404 30405 30406 30407 30408 30409 30410 30411 30412 30413 30414 30415 30416 30417 30418 30419 30420 30421 30422 30423 30424 30425 30426 30427 30428 30429 30430 30431 30432 30433 30434 30435 30436 30437 30438 30439 30440 30441 30442 30443 30444 30445 30446 30447 30448 30449 30450 30451 30452 30453 30454 30455 30456 30457 30458 30459 30460 30461 30462 30463 30464 30465 30466 30467 30468 30469 30470 30471 30472 30473 30474 30475 30476 30477 30478 30479 30480 30481 30482 30483 30484 30485 30486 30487 30488 30489 30490 30491 30492 30493 30494 30495 30496 30497 30498 30499 30500 30501 30502 30503 30504 30505 30506 30507 30508 30509 30510 30511 30512 30513 30514 30515 30516 30517 30518 30519 30520 30521 30522 30523 30524 30525 30526 30527 30528 30529 30530 30531 30532 30533 30534 30535 30536 30537 30538 30539 30540 30541 30542 30543 30544 30545 30546 30547 30548 30549 30550 30551 30552 30553 30554 30555 30556 30557 30558 30559 30560 30561 30562 30563 30564 30565 30566 30567 30568 30569 30570 30571 30572 30573 30574 30575 30576 30577 30578 30579 30580 30581 30582 30583 30584 30585 30586 30587 30588 30589 30590 30591 30592 30593 30594 30595 30596 30597 30598 30599 30600 30601 30602 30603 30604 30605 30606 30607 30608 30609 30610 30611 30612 30613 30614 30615 30616 30617 30618 30619 30620 30621 30622 30623 30624 30625 30626 30627 30628 30629 30630 30631 30632 30633 30634 30635 30636 30637 30638 30639 30640 30641 30642 30643 30644 30645 30646 30647 30648 30649 30650 30651 30652 30653 30654 30655 30656 30657 30658 30659 30660 30661 30662 30663 30664 30665 30666 30667 30668 30669 30670 30671 30672 30673 30674 30675 30676 30677 30678 30679 30680 30681 30682 30683 30684 30685 30686 30687 30688 30689 30690 30691 30692 30693 30694 30695 30696 30697 30698 30699 30700 30701 30702 30703 30704 30705 30706 30707 30708 30709 30710 30711 30712 30713 30714 30715 30716 30717 30718 30719 30720 30721 30722 30723 30724 30725 30726 30727 30728 30729 30730 30731 30732 30733 30734 30735 30736 30737 30738 30739 30740 30741 30742 30743 30744 30745 30746 30747 30748 30749 30750 30751 30752 30753 30754 30755 30756 30757 30758 30759 30760 30761 30762 30763 30764 30765 30766 30767 30768 30769 30770 30771 30772 30773 30774 30775 30776 30777 30778 30779 30780 30781 30782 30783 30784 30785 30786 30787 30788 30789 30790 30791 30792 30793 30794 30795 30796 30797 30798 30799 30800 30801 30802 30803 30804 30805 30806 30807 30808 30809 30810 30811 30812 30813 30814 30815 30816 30817 30818 30819 30820 30821 30822 30823 30824 30825 30826 30827 30828 30829 30830 30831 30832 30833 30834 30835 30836 30837 30838 30839 30840 30841 30842 30843 30844 30845 30846 30847 30848 30849 30850 30851 30852 30853 30854 30855 30856 30857 30858 30859 30860 30861 30862 30863 30864 30865 30866 30867 30868 30869 30870 30871 30872 30873 30874 30875 30876 30877 30878 30879 30880 30881 30882 30883 30884 30885 30886 30887 30888 30889 30890 30891 30892 30893 30894 30895 30896 30897 30898 30899 30900 30901 30902 30903 30904 30905 30906 30907 30908 30909 30910 30911 30912 30913 30914 30915 30916 30917 30918 30919 30920 30921 30922 30923 30924 30925 30926 30927 30928 30929 30930 30931 30932 30933 30934 30935 30936 30937 30938 30939 30940 30941 30942 30943 30944 30945 30946 30947 30948 30949 30950 30951 30952 30953 30954 30955 30956 30957 30958 30959 30960 30961 30962 30963 30964 30965 30966 30967 30968 30969 30970 30971 30972 30973 30974 30975 30976 30977 30978 30979 30980 30981 30982 30983 30984 30985 30986 30987 30988 30989 30990 30991 30992 30993 30994 30995 30996 30997 30998 30999 31000 31001 31002 31003 31004 31005 31006 31007 31008 31009 31010 31011 31012 31013 31014 31015 31016 31017 31018 31019 31020 31021 31022 31023 31024 31025 31026 31027 31028 31029 31030 31031 31032 31033 31034 31035 31036 31037 31038 31039 31040 31041 31042 31043 31044 31045 31046 31047 31048 31049 31050 31051 31052 31053 31054 31055 31056 31057 31058 31059 31060 31061 31062 31063 31064 31065 31066 31067 31068 31069 31070 31071 31072 31073 31074 31075 31076 31077 31078 31079 31080 31081 31082 31083 31084 31085 31086 31087 31088 31089 31090 31091 31092 31093 31094 31095 31096 31097 31098 31099 31100 31101 31102 31103 31104 31105 31106 31107 31108 31109 31110 31111 31112 31113 31114 31115 31116 31117 31118 31119 31120 31121 31122 31123 31124 31125 31126 31127 31128 31129 31130 31131 31132 31133 31134 31135 31136 31137 31138 31139 31140 31141 31142 31143 31144 31145 31146 31147 31148 31149 31150 31151 31152 31153 31154 31155 31156 31157 31158 31159 31160 31161 31162 31163 31164 31165 31166 31167 31168 31169 31170 31171 31172 31173 31174 31175 31176 31177 31178 31179 31180 31181 31182 31183 31184 31185 31186 31187 31188 31189 31190 31191 31192 31193 31194 31195 31196 31197 31198 31199 31200 31201 31202 31203 31204 31205 31206 31207 31208 31209 31210 31211 31212 31213 31214 31215 31216 31217 31218 31219 31220 31221 31222 31223 31224 31225 31226 31227 31228 31229 31230 31231 31232 31233 31234 31235 31236 31237 31238 31239 31240 31241 31242 31243 31244 31245 31246 31247 31248 31249 31250 31251 31252 31253 31254 31255 31256 31257 31258 31259 31260 31261 31262 31263 31264 31265 31266 31267 31268 31269 31270 31271 31272 31273 31274 31275 31276 31277 31278 31279 31280 31281 31282 31283 31284 31285 31286 31287 31288 31289 31290 31291 31292 31293 31294 31295 31296 31297 31298 31299 31300 31301 31302 31303 31304 31305 31306 31307 31308 31309 31310 31311 31312 31313 31314 31315 31316 31317 31318 31319 31320 31321 31322 31323 31324 31325 31326 31327 31328 31329 31330 31331 31332 31333 31334 31335 31336 31337 31338 31339 31340 31341 31342 31343 31344 31345 31346 31347 31348 31349 31350 31351 31352 31353 31354 31355 31356 31357 31358 31359 31360 31361 31362 31363 31364 31365 31366 31367 31368 31369 31370 31371 31372 31373 31374 31375 31376 31377 31378 31379 31380 31381 31382 31383 31384 31385 31386 31387 31388 31389 31390 31391 31392 31393 31394 31395 31396 31397 31398 31399 31400 31401 31402 31403 31404 31405 31406 31407 31408 31409 31410 31411 31412 31413 31414 31415 31416 31417 31418 31419 31420 31421 31422 31423 31424 31425 31426 31427 31428 31429 31430 31431 31432 31433 31434 31435 31436 31437 31438 31439 31440 31441 31442 31443 31444 31445 31446 31447 31448 31449 31450 31451 31452 31453 31454 31455 31456 31457 31458 31459 31460 31461 31462 31463 31464 31465 31466 31467 31468 31469 31470 31471 31472 31473 31474 31475 31476 31477 31478 31479 31480 31481 31482 31483 31484 31485 31486 31487 31488 31489 31490 31491 31492 31493 31494 31495 31496 31497 31498 31499 31500 31501 31502 31503 31504 31505 31506 31507 31508 31509 31510 31511 31512 31513 31514 31515 31516 31517 31518 31519 31520 31521 31522 31523 31524 31525 31526 31527 31528 31529 31530 31531 31532 31533 31534 31535 31536 31537 31538 31539 31540 31541 31542 31543 31544 31545 31546 31547 31548 31549 31550 31551 31552 31553 31554 31555 31556 31557 31558 31559 31560 31561 31562 31563 31564 31565 31566 31567 31568 31569 31570 31571 31572 31573 31574 31575 31576 31577 31578 31579 31580 31581 31582 31583 31584 31585 31586 31587 31588 31589 31590 31591 31592 31593 31594 31595 31596 31597 31598 31599 31600 31601 31602 31603 31604 31605 31606 31607 31608 31609 31610 31611 31612 31613 31614 31615 31616 31617 31618 31619 31620 31621 31622 31623 31624 31625 31626 31627 31628 31629 31630 31631 31632 31633 31634 31635 31636 31637 31638 31639 31640 31641 31642 31643 31644 31645 31646 31647 31648 31649 31650 31651 31652 31653 31654 31655 31656 31657 31658 31659 31660 31661 31662 31663 31664 31665 31666 31667 31668 31669 31670 31671 31672 31673 31674 31675 31676 31677 31678 31679 31680 31681 31682 31683 31684 31685 31686 31687 31688 31689 31690 31691 31692 31693 31694 31695 31696 31697 31698 31699 31700 31701 31702 31703 31704 31705 31706 31707 31708 31709 31710 31711 31712 31713 31714 31715 31716 31717 31718 31719 31720 31721 31722 31723 31724 31725 31726 31727 31728 31729 31730 31731 31732 31733 31734 31735 31736 31737 31738 31739 31740 31741 31742 31743 31744 31745 31746 31747 31748 31749 31750 31751 31752 31753 31754 31755 31756 31757 31758 31759 31760 31761 31762 31763 31764 31765 31766 31767 31768 31769 31770 31771 31772 31773 31774 31775 31776 31777 31778 31779 31780 31781 31782 31783 31784 31785 31786 31787 31788 31789 31790 31791 31792 31793 31794 31795 31796 31797 31798 31799 31800 31801 31802 31803 31804 31805 31806 31807 31808 31809 31810 31811 31812 31813 31814 31815 31816 31817 31818 31819 31820 31821 31822 31823 31824 31825 31826 31827 31828 31829 31830 31831 31832 31833 31834 31835 31836 31837 31838 31839 31840 31841 31842 31843 31844 31845 31846 31847 31848 31849 31850 31851 31852 31853 31854 31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 31865 31866 31867 31868 31869 31870 31871 31872 31873 31874 31875 31876 31877 31878 31879 31880 31881 31882 31883 31884 31885 31886 31887 31888 31889 31890 31891 31892 31893 31894 31895 31896 31897 31898 31899 31900 31901 31902 31903 31904 31905 31906 31907 31908 31909 31910 31911 31912 31913 31914 31915 31916 31917 31918 31919 31920 31921 31922 31923 31924 31925 31926 31927 31928 31929 31930 31931 31932 31933 31934 31935 31936 31937 31938 31939 31940 31941 31942 31943 31944 31945 31946 31947 31948 31949 31950 31951 31952 31953 31954 31955 31956 31957 31958 31959 31960 31961 31962 31963 31964 31965 31966 31967 31968 31969 31970 31971 31972 31973 31974 31975 31976 31977 31978 31979 31980 31981 31982 31983 31984 31985 31986 31987 31988 31989 31990 31991 31992 31993 31994 31995 31996 31997 31998 31999 32000 32001 32002 32003 32004 32005 32006 32007 32008 32009 32010 32011 32012 32013 32014 32015 32016 32017 32018 32019 32020 32021 32022 32023 32024 32025 32026 32027 32028 32029 32030 32031 32032 32033 32034 32035 32036 32037 32038 32039 32040 32041 32042 32043 32044 32045 32046 32047 32048 32049 32050 32051 32052 32053 32054 32055 32056 32057 32058 32059 32060 32061 32062 32063 32064 32065 32066 32067 32068 32069 32070 32071 32072 32073 32074 32075 32076 32077 32078 32079 32080 32081 32082 32083 32084 32085 32086 32087 32088 32089 32090 32091 32092 32093 32094 32095 32096 32097 32098 32099 32100 32101 32102 32103 32104 32105 32106 32107 32108 32109 32110 32111 32112 32113 32114 32115 32116 32117 32118 32119 32120 32121 32122 32123 32124 32125 32126 32127 32128 32129 32130 32131 32132 32133 32134 32135 32136 32137 32138 32139 32140 32141 32142 32143 32144 32145 32146 32147 32148 32149 32150 32151 32152 32153 32154 32155 32156 32157 32158 32159 32160 32161 32162 32163 32164 32165 32166 32167 32168 32169 32170 32171 32172 32173 32174 32175 32176 32177 32178 32179 32180 32181 32182 32183 32184 32185 32186 32187 32188 32189 32190 32191 32192 32193 32194 32195 32196 32197 32198 32199 32200 32201 32202 32203 32204 32205 32206 32207 32208 32209 32210 32211 32212 32213 32214 32215 32216 32217 32218 32219 32220 32221 32222 32223 32224 32225 32226 32227 32228 32229 32230 32231 32232 32233 32234 32235 32236 32237 32238 32239 32240 32241 32242 32243 32244 32245 32246 32247 32248 32249 32250 32251 32252 32253 32254 32255 32256 32257 32258 32259 32260 32261 32262 32263 32264 32265 32266 32267 32268 32269 32270 32271 32272 32273 32274 32275 32276 32277 32278 32279 32280 32281 32282 32283 32284 32285 32286 32287 32288 32289 32290 32291 32292 32293 32294 32295 32296 32297 32298 32299 32300 32301 32302 32303 32304 32305 32306 32307 32308 32309 32310 32311 32312 32313 32314 32315 32316 32317 32318 32319 32320 32321 32322 32323 32324 32325 32326 32327 32328 32329 32330 32331 32332 32333 32334 32335 32336 32337 32338 32339 32340 32341 32342 32343 32344 32345 32346 32347 32348 32349 32350 32351 32352 32353 32354 32355 32356 32357 32358 32359 32360 32361 32362 32363 32364 32365 32366 32367 32368 32369 32370 32371 32372 32373 32374 32375 32376 32377 32378 32379 32380 32381 32382 32383 32384 32385 32386 32387 32388 32389 32390 32391 32392 32393 32394 32395 32396 32397 32398 32399 32400 32401 32402 32403 32404 32405 32406 32407 32408 32409 32410 32411 32412 32413 32414 32415 32416 32417 32418 32419 32420 32421 32422 32423 32424 32425 32426 32427 32428 32429 32430 32431 32432 32433 32434 32435 32436 32437 32438 32439 32440 32441 32442 32443 32444 32445 32446 32447 32448 32449 32450 32451 32452 32453 32454 32455 32456 32457 32458 32459 32460 32461 32462 32463 32464 32465 32466 32467 32468 32469 32470 32471 32472 32473 32474 32475 32476 32477 32478 32479 32480 32481 32482 32483 32484 32485 32486 32487 32488 32489 32490 32491 32492 32493 32494 32495 32496 32497 32498 32499 32500 32501 32502 32503 32504 32505 32506 32507 32508 32509 32510 32511 32512 32513 32514 32515 32516 32517 32518 32519 32520 32521 32522 32523 32524 32525 32526 32527 32528 32529 32530 32531 32532 32533 32534 32535 32536 32537 32538 32539 32540 32541 32542 32543 32544 32545 32546 32547 32548 32549 32550 32551 32552 32553 32554 32555 32556 32557 32558 32559 32560 32561 32562 32563 32564 32565 32566 32567 32568 32569 32570 32571 32572 32573 32574 32575 32576 32577 32578 32579 32580 32581 32582 32583 32584 32585 32586 32587 32588 32589 32590 32591 32592 32593 32594 32595 32596 32597 32598 32599 32600 32601 32602 32603 32604 32605 32606 32607 32608 32609 32610 32611 32612 32613 32614 32615 32616 32617 32618 32619 32620 32621 32622 32623 32624 32625 32626 32627 32628 32629 32630 32631 32632 32633 32634 32635 32636 32637 32638 32639 32640 32641 32642 32643 32644 32645 32646 32647 32648 32649 32650 32651 32652 32653 32654 32655 32656 32657 32658 32659 32660 32661 32662 32663 32664 32665 32666 32667 32668 32669 32670 32671 32672 32673 32674 32675 32676 32677 32678 32679 32680 32681 32682 32683 32684 32685 32686 32687 32688 32689 32690 32691 32692 32693 32694 32695 32696 32697 32698 32699 32700 32701 32702 32703 32704 32705 32706 32707 32708 32709 32710 32711 32712 32713 32714 32715 32716 32717 32718 32719 32720 32721 32722 32723 32724 32725 32726 32727 32728 32729 32730 32731 32732 32733 32734 32735 32736 32737 32738 32739 32740 32741 32742 32743 32744 32745 32746 32747 32748 32749 32750 32751 32752 32753 32754 32755 32756 32757 32758 32759 32760 32761 32762 32763 32764 32765 32766 32767 32768 32769 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779 32780 32781 32782 32783 32784 32785 32786 32787 32788 32789 32790 32791 32792 32793 32794 32795 32796 32797 32798 32799 32800 32801 32802 32803 32804 32805 32806 32807 32808 32809 32810 32811 32812 32813 32814 32815 32816 32817 32818 32819 32820 32821 32822 32823 32824 32825 32826 32827 32828 32829 32830 32831 32832 32833 32834 32835 32836 32837 32838 32839 32840 32841 32842 32843 32844 32845 32846 32847 32848 32849 32850 32851 32852 32853 32854 32855 32856 32857 32858 32859 32860 32861 32862 32863 32864 32865 32866 32867 32868 32869 32870 32871 32872 32873 32874 32875 32876 32877 32878 32879 32880 32881 32882 32883 32884 32885 32886 32887 32888 32889 32890 32891 32892 32893 32894 32895 32896 32897 32898 32899 32900 32901 32902 32903 32904 32905 32906 32907 32908 32909 32910 32911 32912 32913 32914 32915 32916 32917 32918 32919 32920 32921 32922 32923 32924 32925 32926 32927 32928 32929 32930 32931 32932 32933 32934 32935 32936 32937 32938 32939 32940 32941 32942 32943 32944 32945 32946 32947 32948 32949 32950 32951 32952 32953 32954 32955 32956 32957 32958 32959 32960 32961 32962 32963 32964 32965 32966 32967 32968 32969 32970 32971 32972 32973 32974 32975 32976 32977 32978 32979 32980 32981 32982 32983 32984 32985 32986 32987 32988 32989 32990 32991 32992 32993 32994 32995 32996 32997 32998 32999 33000 33001 33002 33003 33004 33005 33006 33007 33008 33009 33010 33011 33012 33013 33014 33015 33016 33017 33018 33019 33020 33021 33022 33023 33024 33025 33026 33027 33028 33029 33030 33031 33032 33033 33034 33035 33036 33037 33038 33039 33040 33041 33042 33043 33044 33045 33046 33047 33048 33049 33050 33051 33052 33053 33054 33055 33056 33057 33058 33059 33060 33061 33062 33063 33064 33065 33066 33067 33068 33069 33070 33071 33072 33073 33074 33075 33076 33077 33078 33079 33080 33081 33082 33083 33084 33085 33086 33087 33088 33089 33090 33091 33092 33093 33094 33095 33096 33097 33098 33099 33100 33101 33102 33103 33104 33105 33106 33107 33108 33109 33110 33111 33112 33113 33114 33115 33116 33117 33118 33119 33120 33121 33122 33123 33124 33125 33126 33127 33128 33129 33130 33131 33132 33133 33134 33135 33136 33137 33138 33139 33140 33141 33142 33143 33144 33145 33146 33147 33148 33149 33150 33151 33152 33153 33154 33155 33156 33157 33158 33159 33160 33161 33162 33163 33164 33165 33166 33167 33168 33169 33170 33171 33172 33173 33174 33175 33176 33177 33178 33179 33180 33181 33182 33183 33184 33185 33186 33187 33188 33189 33190 33191 33192 33193 33194 33195 33196 33197 33198 33199 33200 33201 33202 33203 33204 33205 33206 33207 33208 33209 33210 33211 33212 33213 33214 33215 33216 33217 33218 33219 33220 33221 33222 33223 33224 33225 33226 33227 33228 33229 33230 33231 33232 33233 33234 33235 33236 33237 33238 33239 33240 33241 33242 33243 33244 33245 33246 33247 33248 33249 33250 33251 33252 33253 33254 33255 33256 33257 33258 33259 33260 33261 33262 33263 33264 33265 33266 33267 33268 33269 33270 33271 33272 33273 33274 33275 33276 33277 33278 33279 33280 33281 33282 33283 33284 33285 33286 33287 33288 33289 33290 33291 33292 33293 33294 33295 33296 33297 33298 33299 33300 33301 33302 33303 33304 33305 33306 33307 33308 33309 33310 33311 33312 33313 33314 33315 33316 33317 33318 33319 33320 33321 33322 33323 33324 33325 33326 33327 33328 33329 33330 33331 33332 33333 33334 33335 33336 33337 33338 33339 33340 33341 33342 33343 33344 33345 33346 33347 33348 33349 33350 33351 33352 33353 33354 33355 33356 33357 33358 33359 33360 33361 33362 33363 33364 33365 33366 33367 33368 33369 33370 33371 33372 33373 33374 33375 33376 33377 33378 33379 33380 33381 33382 33383 33384 33385 33386 33387 33388 33389 33390 33391 33392 33393 33394 33395 33396 33397 33398 33399 33400 33401 33402 33403 33404 33405 33406 33407 33408 33409 33410 33411 33412 33413 33414 33415 33416 33417 33418 33419 33420 33421 33422 33423 33424 33425 33426 33427 33428 33429 33430 33431 33432 33433 33434 33435 33436 33437 33438 33439 33440 33441 33442 33443 33444 33445 33446 33447 33448 33449 33450 33451 33452 33453 33454 33455 33456 33457 33458 33459 33460 33461 33462 33463 33464 33465 33466 33467 33468 33469 33470 33471 33472 33473 33474 33475 33476 33477 33478 33479 33480 33481 33482 33483 33484 33485 33486 33487 33488 33489 33490 33491 33492 33493 33494 33495 33496 33497 33498 33499 33500 33501 33502 33503 33504 33505 33506 33507 33508 33509 33510 33511 33512 33513 33514 33515 33516 33517 33518 33519 33520 33521 33522 33523 33524 33525 33526 33527 33528 33529 33530 33531 33532 33533 33534 33535 33536 33537 33538 33539 33540 33541 33542 33543 33544 33545 33546 33547 33548 33549 33550 33551 33552 33553 33554 33555 33556 33557 33558 33559 33560 33561 33562 33563 33564 33565 33566 33567 33568 33569 33570 33571 33572 33573 33574 33575 33576 33577 33578 33579 33580 33581 33582 33583 33584 33585 33586 33587 33588 33589 33590 33591 33592 33593 33594 33595 33596 33597 33598 33599 33600 33601 33602 33603 33604 33605 33606 33607 33608 33609 33610 33611 33612 33613 33614 33615 33616 33617 33618 33619 33620 33621 33622 33623 33624 33625 33626 33627 33628 33629 33630 33631 33632 33633 33634 33635 33636 33637 33638 33639 33640 33641 33642 33643 33644 33645 33646 33647 33648 33649 33650 33651 33652 33653 33654 33655 33656 33657 33658 33659 33660 33661 33662 33663 33664 33665 33666 33667 33668 33669 33670 33671 33672 33673 33674 33675 33676 33677 33678 33679 33680 33681 33682 33683 33684 33685 33686 33687 33688 33689 33690 33691 33692 33693 33694 33695 33696 33697 33698 33699 33700 33701 33702 33703 33704 33705 33706 33707 33708 33709 33710 33711 33712 33713 33714 33715 33716 33717 33718 33719 33720 33721 33722 33723 33724 33725 33726 33727 33728 33729 33730 33731 33732 33733 33734 33735 33736 33737 33738 33739 33740 33741 33742 33743 33744 33745 33746 33747 33748 33749 33750 33751 33752 33753 33754 33755 33756 33757 33758 33759 33760 33761 33762 33763 33764 33765 33766 33767 33768 33769 33770 33771 33772 33773 33774 33775 33776 33777 33778 33779 33780 33781 33782 33783 33784 33785 33786 33787 33788 33789 33790 33791 33792 33793 33794 33795 33796 33797 33798 33799 33800 33801 33802 33803 33804 33805 33806 33807 33808 33809 33810 33811 33812 33813 33814 33815 33816 33817 33818 33819 33820 33821 33822 33823 33824 33825 33826 33827 33828 33829 33830 33831 33832 33833 33834 33835 33836 33837 33838 33839 33840 33841 33842 33843 33844 33845 33846 33847 33848 33849 33850 33851 33852 33853 33854 33855 33856 33857 33858 33859 33860 33861 33862 33863 33864 33865 33866 33867 33868 33869 33870 33871 33872 33873 33874 33875 33876 33877 33878 33879 33880 33881 33882 33883 33884 33885 33886 33887 33888 33889 33890 33891 33892 33893 33894 33895 33896 33897 33898 33899 33900 33901 33902 33903 33904 33905 33906 33907 33908 33909 33910 33911 33912 33913 33914 33915 33916 33917 33918 33919 33920 33921 33922 33923 33924 33925 33926 33927 33928 33929 33930 33931 33932 33933 33934 33935 33936 33937 33938 33939 33940 33941 33942 33943 33944 33945 33946 33947 33948 33949 33950 33951 33952 33953 33954 33955 33956 33957 33958 33959 33960 33961 33962 33963 33964 33965 33966 33967 33968 33969 33970 33971 33972 33973 33974 33975 33976 33977 33978 33979 33980 33981 33982 33983 33984 33985 33986 33987 33988 33989 33990 33991 33992 33993 33994 33995 33996 33997 33998 33999 34000 34001 34002 34003 34004 34005 34006 34007 34008 34009 34010 34011 34012 34013 34014 34015 34016 34017 34018 34019 34020 34021 34022 34023 34024 34025 34026 34027 34028 34029 34030 34031 34032 34033 34034 34035 34036 34037 34038 34039 34040 34041 34042 34043 34044 34045 34046 34047 34048 34049 34050 34051 34052 34053 34054 34055 34056 34057 34058 34059 34060 34061 34062 34063 34064 34065 34066 34067 34068 34069 34070 34071 34072 34073 34074 34075 34076 34077 34078 34079 34080 34081 34082 34083 34084 34085 34086 34087 34088 34089 34090 34091 34092 34093 34094 34095 34096 34097 34098 34099 34100 34101 34102 34103 34104 34105 34106 34107 34108 34109 34110 34111 34112 34113 34114 34115 34116 34117 34118 34119 34120 34121 34122 34123 34124 34125 34126 34127 34128 34129 34130 34131 34132 34133 34134 34135 34136 34137 34138 34139 34140 34141 34142 34143 34144 34145 34146 34147 34148 34149 34150 34151 34152 34153 34154 34155 34156 34157 34158 34159 34160 34161 34162 34163 34164 34165 34166 34167 34168 34169 34170 34171 34172 34173 34174 34175 34176 34177 34178 34179 34180 34181 34182 34183 34184 34185 34186 34187 34188 34189 34190 34191 34192 34193 34194 34195 34196 34197 34198 34199 34200 34201 34202 34203 34204 34205 34206 34207 34208 34209 34210 34211 34212 34213 34214 34215 34216 34217 34218 34219 34220 34221 34222 34223 34224 34225 34226 34227 34228 34229 34230 34231 34232 34233 34234 34235 34236 34237 34238 34239 34240 34241 34242 34243 34244 34245 34246 34247 34248 34249 34250 34251 34252 34253 34254 34255 34256 34257 34258 34259 34260 34261 34262 34263 34264 34265 34266 34267 34268 34269 34270 34271 34272 34273 34274 34275 34276 34277 34278 34279 34280 34281 34282 34283 34284 34285 34286 34287 34288 34289 34290 34291 34292 34293 34294 34295 34296 34297 34298 34299 34300 34301 34302 34303 34304 34305 34306 34307 34308 34309 34310 34311 34312 34313 34314 34315 34316 34317 34318 34319 34320 34321 34322 34323 34324 34325 34326 34327 34328 34329 34330 34331 34332 34333 34334 34335 34336 34337 34338 34339 34340 34341 34342 34343 34344 34345 34346 34347 34348 34349 34350 34351 34352 34353 34354 34355 34356 34357 34358 34359 34360 34361 34362 34363 34364 34365 34366 34367 34368 34369 34370 34371 34372 34373 34374 34375 34376 34377 34378 34379 34380 34381 34382 34383 34384 34385 34386 34387 34388 34389 34390 34391 34392 34393 34394 34395 34396 34397 34398 34399 34400 34401 34402 34403 34404 34405 34406 34407 34408 34409 34410 34411 34412 34413 34414 34415 34416 34417 34418 34419 34420 34421 34422 34423 34424 34425 34426 34427 34428 34429 34430 34431 34432 34433 34434 34435 34436 34437 34438 34439 34440 34441 34442 34443 34444 34445 34446 34447 34448 34449 34450 34451 34452 34453 34454 34455 34456 34457 34458 34459 34460 34461 34462 34463 34464 34465 34466 34467 34468 34469 34470 34471 34472 34473 34474 34475 34476 34477 34478 34479 34480 34481 34482 34483 34484 34485 34486 34487 34488 34489 34490 34491 34492 34493 34494 34495 34496 34497 34498 34499 34500 34501 34502 34503 34504 34505 34506 34507 34508 34509 34510 34511 34512 34513 34514 34515 34516 34517 34518 34519 34520 34521 34522 34523 34524 34525 34526 34527 34528 34529 34530 34531 34532 34533 34534 34535 34536 34537 34538 34539 34540 34541 34542 34543 34544 34545 34546 34547 34548 34549 34550 34551 34552 34553 34554 34555 34556 34557 34558 34559 34560 34561 34562 34563 34564 34565 34566 34567 34568 34569 34570 34571 34572 34573 34574 34575 34576 34577 34578 34579 34580 34581 34582 34583 34584 34585 34586 34587 34588 34589 34590 34591 34592 34593 34594 34595 34596 34597 34598 34599 34600 34601 34602 34603 34604 34605 34606 34607 34608 34609 34610 34611 34612 34613 34614 34615 34616 34617 34618 34619 34620 34621 34622 34623 34624 34625 34626 34627 34628 34629 34630 34631 34632 34633 34634 34635 34636 34637 34638 34639 34640 34641 34642 34643 34644 34645 34646 34647 34648 34649 34650 34651 34652 34653 34654 34655 34656 34657 34658 34659 34660 34661 34662 34663 34664 34665 34666 34667 34668 34669 34670 34671 34672 34673 34674 34675 34676 34677 34678 34679 34680 34681 34682 34683 34684 34685 34686 34687 34688 34689 34690 34691 34692 34693 34694 34695 34696 34697 34698 34699 34700 34701 34702 34703 34704 34705 34706 34707 34708 34709 34710 34711 34712 34713 34714 34715 34716 34717 34718 34719 34720 34721 34722 34723 34724 34725 34726 34727 34728 34729 34730 34731 34732 34733 34734 34735 34736 34737 34738 34739 34740 34741 34742 34743 34744 34745 34746 34747 34748 34749 34750 34751 34752 34753 34754 34755 34756 34757 34758 34759 34760 34761 34762 34763 34764 34765 34766 34767 34768 34769 34770 34771 34772 34773 34774 34775 34776 34777 34778 34779 34780 34781 34782 34783 34784 34785 34786 34787 34788 34789 34790 34791 34792 34793 34794 34795 34796 34797 34798 34799 34800 34801 34802 34803 34804 34805 34806 34807 34808 34809 34810 34811 34812 34813 34814 34815 34816 34817 34818 34819 34820 34821 34822 34823 34824 34825 34826 34827 34828 34829 34830 34831 34832 34833 34834 34835 34836 34837 34838 34839 34840 34841 34842 34843 34844 34845 34846 34847 34848 34849 34850 34851 34852 34853 34854 34855 34856 34857 34858 34859 34860 34861 34862 34863 34864 34865 34866 34867 34868 34869 34870 34871 34872 34873 34874 34875 34876 34877 34878 34879 34880 34881 34882 34883 34884 34885 34886 34887 34888 34889 34890 34891 34892 34893 34894 34895 34896 34897 34898 34899 34900 34901 34902 34903 34904 34905 34906 34907 34908 34909 34910 34911 34912 34913 34914 34915 34916 34917 34918 34919 34920 34921 34922 34923 34924 34925 34926 34927 34928 34929 34930 34931 34932 34933 34934 34935 34936 34937 34938 34939 34940 34941 34942 34943 34944 34945 34946 34947 34948 34949 34950 34951 34952 34953 34954 34955 34956 34957 34958 34959 34960 34961 34962 34963 34964 34965 34966 34967 34968 34969 34970 34971 34972 34973 34974 34975 34976 34977 34978 34979 34980 34981 34982 34983 34984 34985 34986 34987 34988 34989 34990 34991 34992 34993 34994 34995 34996 34997 34998 34999 35000 35001 35002 35003 35004 35005 35006 35007 35008 35009 35010 35011 35012 35013 35014 35015 35016 35017 35018 35019 35020 35021 35022 35023 35024 35025 35026 35027 35028 35029 35030 35031 35032 35033 35034 35035 35036 35037 35038 35039 35040 35041 35042 35043 35044 35045 35046 35047 35048 35049 35050 35051 35052 35053 35054 35055 35056 35057 35058 35059 35060 35061 35062 35063 35064 35065 35066 35067 35068 35069 35070 35071 35072 35073 35074 35075 35076 35077 35078 35079 35080 35081 35082 35083 35084 35085 35086 35087 35088 35089 35090 35091 35092 35093 35094 35095 35096 35097 35098 35099 35100 35101 35102 35103 35104 35105 35106 35107 35108 35109 35110 35111 35112 35113 35114 35115 35116 35117 35118 35119 35120 35121 35122 35123 35124 35125 35126 35127 35128 35129 35130 35131 35132 35133 35134 35135 35136 35137 35138 35139 35140 35141 35142 35143 35144 35145 35146 35147 35148 35149 35150 35151 35152 35153 35154 35155 35156 35157 35158 35159 35160 35161 35162 35163 35164 35165 35166 35167 35168 35169 35170 35171 35172 35173 35174 35175 35176 35177 35178 35179 35180 35181 35182 35183 35184 35185 35186 35187 35188 35189 35190 35191 35192 35193 35194 35195 35196 35197 35198 35199 35200 35201 35202 35203 35204 35205 35206 35207 35208 35209 35210 35211 35212 35213 35214 35215 35216 35217 35218 35219 35220 35221 35222 35223 35224 35225 35226 35227 35228 35229 35230 35231 35232 35233 35234 35235 35236 35237 35238 35239 35240 35241 35242 35243 35244 35245 35246 35247 35248 35249 35250 35251 35252 35253 35254 35255 35256 35257 35258 35259 35260 35261 35262 35263 35264 35265 35266 35267 35268 35269 35270 35271 35272 35273 35274 35275 35276 35277 35278 35279 35280 35281 35282 35283 35284 35285 35286 35287 35288 35289 35290 35291 35292 35293 35294 35295 35296 35297 35298 35299 35300 35301 35302 35303 35304 35305 35306 35307 35308 35309 35310 35311 35312 35313 35314 35315 35316 35317 35318 35319 35320 35321 35322 35323 35324 35325 35326 35327 35328 35329 35330 35331 35332 35333 35334 35335 35336 35337 35338 35339 35340 35341 35342 35343 35344 35345 35346 35347 35348 35349 35350 35351 35352 35353 35354 35355 35356 35357 35358 35359 35360 35361 35362 35363 35364 35365 35366 35367 35368 35369 35370 35371 35372 35373 35374 35375 35376 35377 35378 35379 35380 35381 35382 35383 35384 35385 35386 35387 35388 35389 35390 35391 35392 35393 35394 35395 35396 35397 35398 35399 35400 35401 35402 35403 35404 35405 35406 35407 35408 35409 35410 35411 35412 35413 35414 35415 35416 35417 35418 35419 35420 35421 35422 35423 35424 35425 35426 35427 35428 35429 35430 35431 35432 35433 35434 35435 35436 35437 35438 35439 35440 35441 35442 35443 35444 35445 35446 35447 35448 35449 35450 35451 35452 35453 35454 35455 35456 35457 35458 35459 35460 35461 35462 35463 35464 35465 35466 35467 35468 35469 35470 35471 35472 35473 35474 35475 35476 35477 35478 35479 35480 35481 35482 35483 35484 35485 35486 35487 35488 35489 35490 35491 35492 35493 35494 35495 35496 35497 35498 35499 35500 35501 35502 35503 35504 35505 35506 35507 35508 35509 35510 35511 35512 35513 35514 35515 35516 35517 35518 35519 35520 35521 35522 35523 35524 35525 35526 35527 35528 35529 35530 35531 35532 35533 35534 35535 35536 35537 35538 35539 35540 35541 35542 35543 35544 35545 35546 35547 35548 35549 35550 35551 35552 35553 35554 35555 35556 35557 35558 35559 35560 35561 35562 35563 35564 35565 35566 35567 35568 35569 35570 35571 35572 35573 35574 35575 35576 35577 35578 35579 35580 35581 35582 35583 35584 35585 35586 35587 35588 35589 35590 35591 35592 35593 35594 35595 35596 35597 35598 35599 35600 35601 35602 35603 35604 35605 35606 35607 35608 35609 35610 35611 35612 35613 35614 35615 35616 35617 35618 35619 35620 35621 35622 35623 35624 35625 35626 35627 35628 35629 35630 35631 35632 35633 35634 35635 35636 35637 35638 35639 35640 35641 35642 35643 35644 35645 35646 35647 35648 35649 35650 35651 35652 35653 35654 35655 35656 35657 35658 35659 35660 35661 35662 35663 35664 35665 35666 35667 35668 35669 35670 35671 35672 35673 35674 35675 35676 35677 35678 35679 35680 35681 35682 35683 35684 35685 35686 35687 35688 35689 35690 35691 35692 35693 35694 35695 35696 35697 35698 35699 35700 35701 35702 35703 35704 35705 35706 35707 35708 35709 35710 35711 35712 35713 35714 35715 35716 35717 35718 35719 35720 35721 35722 35723 35724 35725 35726 35727 35728 35729 35730 35731 35732 35733 35734 35735 35736 35737 35738 35739 35740 35741 35742 35743 35744 35745 35746 35747 35748 35749 35750 35751 35752 35753 35754 35755 35756 35757 35758 35759 35760 35761 35762 35763 35764 35765 35766 35767 35768 35769 35770 35771 35772 35773 35774 35775 35776 35777 35778 35779 35780 35781 35782 35783 35784 35785 35786 35787 35788 35789 35790 35791 35792 35793 35794 35795 35796 35797 35798 35799 35800 35801 35802 35803 35804 35805 35806 35807 35808 35809 35810 35811 35812 35813 35814 35815 35816 35817 35818 35819 35820 35821 35822 35823 35824 35825 35826 35827 35828 35829 35830 35831 35832 35833 35834 35835 35836 35837 35838 35839 35840 35841 35842 35843 35844 35845 35846 35847 35848 35849 35850 35851 35852 35853 35854 35855 35856 35857 35858 35859 35860 35861 35862 35863 35864 35865 35866 35867 35868 35869 35870 35871 35872 35873 35874 35875 35876 35877 35878 35879 35880 35881 35882 35883 35884 35885 35886 35887 35888 35889 35890 35891 35892 35893 35894 35895 35896 35897 35898 35899 35900 35901 35902 35903 35904 35905 35906 35907 35908 35909 35910 35911 35912 35913 35914 35915 35916 35917 35918 35919 35920 35921 35922 35923 35924 35925 35926 35927 35928 35929 35930 35931 35932 35933 35934 35935 35936 35937 35938 35939 35940 35941 35942 35943 35944 35945 35946 35947 35948 35949 35950 35951 35952 35953 35954 35955 35956 35957 35958 35959 35960 35961 35962 35963 35964 35965 35966 35967 35968 35969 35970 35971 35972 35973 35974 35975 35976 35977 35978 35979 35980 35981 35982 35983 35984 35985 35986 35987 35988 35989 35990 35991 35992 35993 35994 35995 35996 35997 35998 35999 36000 36001 36002 36003 36004 36005 36006 36007 36008 36009 36010 36011 36012 36013 36014 36015 36016 36017 36018 36019 36020 36021 36022 36023 36024 36025 36026 36027 36028 36029 36030 36031 36032 36033 36034 36035 36036 36037 36038 36039 36040 36041 36042 36043 36044 36045 36046 36047 36048 36049 36050 36051 36052 36053 36054 36055 36056 36057 36058 36059 36060 36061 36062 36063 36064 36065 36066 36067 36068 36069 36070 36071 36072 36073 36074 36075 36076 36077 36078 36079 36080 36081 36082 36083 36084 36085 36086 36087 36088 36089 36090 36091 36092 36093 36094 36095 36096 36097 36098 36099 36100 36101 36102 36103 36104 36105 36106 36107 36108 36109 36110 36111 36112 36113 36114 36115 36116 36117 36118 36119 36120 36121 36122 36123 36124 36125 36126 36127 36128 36129 36130 36131 36132 36133 36134 36135 36136 36137 36138 36139 36140 36141 36142 36143 36144 36145 36146 36147 36148 36149 36150 36151 36152 36153 36154 36155 36156 36157 36158 36159 36160 36161 36162 36163 36164 36165 36166 36167 36168 36169 36170 36171 36172 36173 36174 36175 36176 36177 36178 36179 36180 36181 36182 36183 36184 36185 36186 36187 36188 36189 36190 36191 36192 36193 36194 36195 36196 36197 36198 36199 36200 36201 36202 36203 36204 36205 36206 36207 36208 36209 36210 36211 36212 36213 36214 36215 36216 36217 36218 36219 36220 36221 36222 36223 36224 36225 36226 36227 36228 36229 36230 36231 36232 36233 36234 36235 36236 36237 36238 36239 36240 36241 36242 36243 36244 36245 36246 36247 36248 36249 36250 36251 36252 36253 36254 36255 36256 36257 36258 36259 36260 36261 36262 36263 36264 36265 36266 36267 36268 36269 36270 36271 36272 36273 36274 36275 36276 36277 36278 36279 36280 36281 36282 36283 36284 36285 36286 36287 36288 36289 36290 36291 36292 36293 36294 36295 36296 36297 36298 36299 36300 36301 36302 36303 36304 36305 36306 36307 36308 36309 36310 36311 36312 36313 36314 36315 36316 36317 36318 36319 36320 36321 36322 36323 36324 36325 36326 36327 36328 36329 36330 36331 36332 36333 36334 36335 36336 36337 36338 36339 36340 36341 36342 36343 36344 36345 36346 36347 36348 36349 36350 36351 36352 36353 36354 36355 36356 36357 36358 36359 36360 36361 36362 36363 36364 36365 36366 36367 36368 36369 36370 36371 36372 36373 36374 36375 36376 36377 36378 36379 36380 36381 36382 36383 36384 36385 36386 36387 36388 36389 36390 36391 36392 36393 36394 36395 36396 36397 36398 36399 36400 36401 36402 36403 36404 36405 36406 36407 36408 36409 36410 36411 36412 36413 36414 36415 36416 36417 36418 36419 36420 36421 36422 36423 36424 36425 36426 36427 36428 36429 36430 36431 36432 36433 36434 36435 36436 36437 36438 36439 36440 36441 36442 36443 36444 36445 36446 36447 36448 36449 36450 36451 36452 36453 36454 36455 36456 36457 36458 36459 36460 36461 36462 36463 36464 36465 36466 36467 36468 36469 36470 36471 36472 36473 36474 36475 36476 36477 36478 36479 36480 36481 36482 36483 36484 36485 36486 36487 36488 36489 36490 36491 36492 36493 36494 36495 36496 36497 36498 36499 36500 36501 36502 36503 36504 36505 36506 36507 36508 36509 36510 36511 36512 36513 36514 36515 36516 36517 36518 36519 36520 36521 36522 36523 36524 36525 36526 36527 36528 36529 36530 36531 36532 36533 36534 36535 36536 36537 36538 36539 36540 36541 36542 36543 36544 36545 36546 36547 36548 36549 36550 36551 36552 36553 36554 36555 36556 36557 36558 36559 36560 36561 36562 36563 36564 36565 36566 36567 36568 36569 36570 36571 36572 36573 36574 36575 36576 36577 36578 36579 36580 36581 36582 36583 36584 36585 36586 36587 36588 36589 36590 36591 36592 36593 36594 36595 36596 36597 36598 36599 36600 36601 36602 36603 36604 36605 36606 36607 36608 36609 36610 36611 36612 36613 36614 36615 36616 36617 36618 36619 36620 36621 36622 36623 36624 36625 36626 36627 36628 36629 36630 36631 36632 36633 36634 36635 36636 36637 36638 36639 36640 36641 36642 36643 36644 36645 36646 36647 36648 36649 36650 36651 36652 36653 36654 36655 36656 36657 36658 36659 36660 36661 36662 36663 36664 36665 36666 36667 36668 36669 36670 36671 36672 36673 36674 36675 36676 36677 36678 36679 36680 36681 36682 36683 36684 36685 36686 36687 36688 36689 36690 36691 36692 36693 36694 36695 36696 36697 36698 36699 36700 36701 36702 36703 36704 36705 36706 36707 36708 36709 36710 36711 36712 36713 36714 36715 36716 36717 36718 36719 36720 36721 36722 36723 36724 36725 36726 36727 36728 36729 36730 36731 36732 36733 36734 36735 36736 36737 36738 36739 36740 36741 36742 36743 36744 36745 36746 36747 36748 36749 36750 36751 36752 36753 36754 36755 36756 36757 36758 36759 36760 36761 36762 36763 36764 36765 36766 36767 36768 36769 36770 36771 36772 36773 36774 36775 36776 36777 36778 36779 36780 36781 36782 36783 36784 36785 36786 36787 36788 36789 36790 36791 36792 36793 36794 36795 36796 36797 36798 36799 36800 36801 36802 36803 36804 36805 36806 36807 36808 36809 36810 36811 36812 36813 36814 36815 36816 36817 36818 36819 36820 36821 36822 36823 36824 36825 36826 36827 36828 36829 36830 36831 36832 36833 36834 36835 36836 36837 36838 36839 36840 36841 36842 36843 36844 36845 36846 36847 36848 36849 36850 36851 36852 36853 36854 36855 36856 36857 36858 36859 36860 36861 36862 36863 36864 36865 36866 36867 36868 36869 36870 36871 36872 36873 36874 36875 36876 36877 36878 36879 36880 36881 36882 36883 36884 36885 36886 36887 36888 36889 36890 36891 36892 36893 36894 36895 36896 36897 36898 36899 36900 36901 36902 36903 36904 36905 36906 36907 36908 36909 36910 36911 36912 36913 36914 36915 36916 36917 36918 36919 36920 36921 36922 36923 36924 36925 36926 36927 36928 36929 36930 36931 36932 36933 36934 36935 36936 36937 36938 36939 36940 36941 36942 36943 36944 36945 36946 36947 36948 36949 36950 36951 36952 36953 36954 36955 36956 36957 36958 36959 36960 36961 36962 36963 36964 36965 36966 36967 36968 36969 36970 36971 36972 36973 36974 36975 36976 36977 36978 36979 36980 36981 36982 36983 36984 36985 36986 36987 36988 36989 36990 36991 36992 36993 36994 36995 36996 36997 36998 36999 37000 37001 37002 37003 37004 37005 37006 37007 37008 37009 37010 37011 37012 37013 37014 37015 37016 37017 37018 37019 37020 37021 37022 37023 37024 37025 37026 37027 37028 37029 37030 37031 37032 37033 37034 37035 37036 37037 37038 37039 37040 37041 37042 37043 37044 37045 37046 37047 37048 37049 37050 37051 37052 37053 37054 37055 37056 37057 37058 37059 37060 37061 37062 37063 37064 37065 37066 37067 37068 37069 37070 37071 37072 37073 37074 37075 37076 37077 37078 37079 37080 37081 37082 37083 37084 37085 37086 37087 37088 37089 37090 37091 37092 37093 37094 37095 37096 37097 37098 37099 37100 37101 37102 37103 37104 37105 37106 37107 37108 37109 37110 37111 37112 37113 37114 37115 37116 37117 37118 37119 37120 37121 37122 37123 37124 37125 37126 37127 37128 37129 37130 37131 37132 37133 37134 37135 37136 37137 37138 37139 37140 37141 37142 37143 37144 37145 37146 37147 37148 37149 37150 37151 37152 37153 37154 37155 37156 37157 37158 37159 37160 37161 37162 37163 37164 37165 37166 37167 37168 37169 37170 37171 37172 37173 37174 37175 37176 37177 37178 37179 37180 37181 37182 37183 37184 37185 37186 37187 37188 37189 37190 37191 37192 37193 37194 37195 37196 37197 37198 37199 37200 37201 37202 37203 37204 37205 37206 37207 37208 37209 37210 37211 37212 37213 37214 37215 37216 37217 37218 37219 37220 37221 37222 37223 37224 37225 37226 37227 37228 37229 37230 37231 37232 37233 37234 37235 37236 37237 37238 37239 37240 37241 37242 37243 37244 37245 37246 37247 37248 37249 37250 37251 37252 37253 37254 37255 37256 37257 37258 37259 37260 37261 37262 37263 37264 37265 37266 37267 37268 37269 37270 37271 37272 37273 37274 37275 37276 37277 37278 37279 37280 37281 37282 37283 37284 37285 37286 37287 37288 37289 37290 37291 37292 37293 37294 37295 37296 37297 37298 37299 37300 37301 37302 37303 37304 37305 37306 37307 37308 37309 37310 37311 37312 37313 37314 37315 37316 37317 37318 37319 37320 37321 37322 37323 37324 37325 37326 37327 37328 37329 37330 37331 37332 37333 37334 37335 37336 37337 37338 37339 37340 37341 37342 37343 37344 37345 37346 37347 37348 37349 37350 37351 37352 37353 37354 37355 37356 37357 37358 37359 37360 37361 37362 37363 37364 37365 37366 37367 37368 37369 37370 37371 37372 37373 37374 37375 37376 37377 37378 37379 37380 37381 37382 37383 37384 37385 37386 37387 37388 37389 37390 37391 37392 37393 37394 37395 37396 37397 37398 37399 37400 37401 37402 37403 37404 37405 37406 37407 37408 37409 37410 37411 37412 37413 37414 37415 37416 37417 37418 37419 37420 37421 37422 37423 37424 37425 37426 37427 37428 37429 37430 37431 37432 37433 37434 37435 37436 37437 37438 37439 37440 37441 37442 37443 37444 37445 37446 37447 37448 37449 37450 37451 37452 37453 37454 37455 37456 37457 37458 37459 37460 37461 37462 37463 37464 37465 37466 37467 37468 37469 37470 37471 37472 37473 37474 37475 37476 37477 37478 37479 37480 37481 37482 37483 37484 37485 37486 37487 37488 37489 37490 37491 37492 37493 37494 37495 37496 37497 37498 37499 37500 37501 37502 37503 37504 37505 37506 37507 37508 37509 37510 37511 37512 37513 37514 37515 37516 37517 37518 37519 37520 37521 37522 37523 37524 37525 37526 37527 37528 37529 37530 37531 37532 37533 37534 37535 37536 37537 37538 37539 37540 37541 37542 37543 37544 37545 37546 37547 37548 37549 37550 37551 37552 37553 37554 37555 37556 37557 37558 37559 37560 37561 37562 37563 37564 37565 37566 37567 37568 37569 37570 37571 37572 37573 37574 37575 37576 37577 37578 37579 37580 37581 37582 37583 37584 37585 37586 37587 37588 37589 37590 37591 37592 37593 37594 37595 37596 37597 37598 37599 37600 37601 37602 37603 37604 37605 37606 37607 37608 37609 37610 37611 37612 37613 37614 37615 37616 37617 37618 37619 37620 37621 37622 37623 37624 37625 37626 37627 37628 37629 37630 37631 37632 37633 37634 37635 37636 37637 37638 37639 37640 37641 37642 37643 37644 37645 37646 37647 37648 37649 37650 37651 37652 37653 37654 37655 37656 37657 37658 37659 37660 37661 37662 37663 37664 37665 37666 37667 37668 37669 37670 37671 37672 37673 37674 37675 37676 37677 37678 37679 37680 37681 37682 37683 37684 37685 37686 37687 37688 37689 37690 37691 37692 37693 37694 37695 37696 37697 37698 37699 37700 37701 37702 37703 37704 37705 37706 37707 37708 37709 37710 37711 37712 37713 37714 37715 37716 37717 37718 37719 37720 37721 37722 37723 37724 37725 37726 37727 37728 37729 37730 37731 37732 37733 37734 37735 37736 37737 37738 37739 37740 37741 37742 37743 37744 37745 37746 37747 37748 37749 37750 37751 37752 37753 37754 37755 37756 37757 37758 37759 37760 37761 37762 37763 37764 37765 37766 37767 37768 37769 37770 37771 37772 37773 37774 37775 37776 37777 37778 37779 37780 37781 37782 37783 37784 37785 37786 37787 37788 37789 37790 37791 37792 37793 37794 37795 37796 37797 37798 37799 37800 37801 37802 37803 37804 37805 37806 37807 37808 37809 37810 37811 37812 37813 37814 37815 37816 37817 37818 37819 37820 37821 37822 37823 37824 37825 37826 37827 37828 37829 37830 37831 37832 37833 37834 37835 37836 37837 37838 37839 37840 37841 37842 37843 37844 37845 37846 37847 37848 37849 37850 37851 37852 37853 37854 37855 37856 37857 37858 37859 37860 37861 37862 37863 37864 37865 37866 37867 37868 37869 37870 37871 37872 37873 37874 37875 37876 37877 37878 37879 37880 37881 37882 37883 37884 37885 37886 37887 37888 37889 37890 37891 37892 37893 37894 37895 37896 37897 37898 37899 37900 37901 37902 37903 37904 37905 37906 37907 37908 37909 37910 37911 37912 37913 37914 37915 37916 37917 37918 37919 37920 37921 37922 37923 37924 37925 37926 37927 37928 37929 37930 37931 37932 37933 37934 37935 37936 37937 37938 37939 37940 37941 37942 37943 37944 37945 37946 37947 37948 37949 37950 37951 37952 37953 37954 37955 37956 37957 37958 37959 37960 37961 37962 37963 37964 37965 37966 37967 37968 37969 37970 37971 37972 37973 37974 37975 37976 37977 37978 37979 37980 37981 37982 37983 37984 37985 37986 37987 37988 37989 37990 37991 37992 37993 37994 37995 37996 37997 37998 37999 38000 38001 38002 38003 38004 38005 38006 38007 38008 38009 38010 38011 38012 38013 38014 38015 38016 38017 38018 38019 38020 38021 38022 38023 38024 38025 38026 38027 38028 38029 38030 38031 38032 38033 38034 38035 38036 38037 38038 38039 38040 38041 38042 38043 38044 38045 38046 38047 38048 38049 38050 38051 38052 38053 38054 38055 38056 38057 38058 38059 38060 38061 38062 38063 38064 38065 38066 38067 38068 38069 38070 38071 38072 38073 38074 38075 38076 38077 38078 38079 38080 38081 38082 38083 38084 38085 38086 38087 38088 38089 38090 38091 38092 38093 38094 38095 38096 38097 38098 38099 38100 38101 38102 38103 38104 38105 38106 38107 38108 38109 38110 38111 38112 38113 38114 38115 38116 38117 38118 38119 38120 38121 38122 38123 38124 38125 38126 38127 38128 38129 38130 38131 38132 38133 38134 38135 38136 38137 38138 38139 38140 38141 38142 38143 38144 38145 38146 38147 38148 38149 38150 38151 38152 38153 38154 38155 38156 38157 38158 38159 38160 38161 38162 38163 38164 38165 38166 38167 38168 38169 38170 38171 38172 38173 38174 38175 38176 38177 38178 38179 38180 38181 38182 38183 38184 38185 38186 38187 38188 38189 38190 38191 38192 38193 38194 38195 38196 38197 38198 38199 38200 38201 38202 38203 38204 38205 38206 38207 38208 38209 38210 38211 38212 38213 38214 38215 38216 38217 38218 38219 38220 38221 38222 38223 38224 38225 38226 38227 38228 38229 38230 38231 38232 38233 38234 38235 38236 38237 38238 38239 38240 38241 38242 38243 38244 38245 38246 38247 38248 38249 38250 38251 38252 38253 38254 38255 38256 38257 38258 38259 38260 38261 38262 38263 38264 38265 38266 38267 38268 38269 38270 38271 38272 38273 38274 38275 38276 38277 38278 38279 38280 38281 38282 38283 38284 38285 38286 38287 38288 38289 38290 38291 38292 38293 38294 38295 38296 38297 38298 38299 38300 38301 38302 38303 38304 38305 38306 38307 38308 38309 38310 38311 38312 38313 38314 38315 38316 38317 38318 38319 38320 38321 38322 38323 38324 38325 38326 38327 38328 38329 38330 38331 38332 38333 38334 38335 38336 38337 38338 38339 38340 38341 38342 38343 38344 38345 38346 38347 38348 38349 38350 38351 38352 38353 38354 38355 38356 38357 38358 38359 38360 38361 38362 38363 38364 38365 38366 38367 38368 38369 38370 38371 38372 38373 38374 38375 38376 38377 38378 38379 38380 38381 38382 38383 38384 38385 38386 38387 38388 38389 38390 38391 38392 38393 38394 38395 38396 38397 38398 38399 38400 38401 38402 38403 38404 38405 38406 38407 38408 38409 38410 38411 38412 38413 38414 38415 38416 38417 38418 38419 38420 38421 38422 38423 38424 38425 38426 38427 38428 38429 38430 38431 38432 38433 38434 38435 38436 38437 38438 38439 38440 38441 38442 38443 38444 38445 38446 38447 38448 38449 38450 38451 38452 38453 38454 38455 38456 38457 38458 38459 38460 38461 38462 38463 38464 38465 38466 38467 38468 38469 38470 38471 38472 38473 38474 38475 38476 38477 38478 38479 38480 38481 38482 38483 38484 38485 38486 38487 38488 38489 38490 38491 38492 38493 38494 38495 38496 38497 38498 38499 38500 38501 38502 38503 38504 38505 38506 38507 38508 38509 38510 38511 38512 38513 38514 38515 38516 38517 38518 38519 38520 38521 38522 38523 38524 38525 38526 38527 38528 38529 38530 38531 38532 38533 38534 38535 38536 38537 38538 38539 38540 38541 38542 38543 38544 38545 38546 38547 38548 38549 38550 38551 38552 38553 38554 38555 38556 38557 38558 38559 38560 38561 38562 38563 38564 38565 38566 38567 38568 38569 38570 38571 38572 38573 38574 38575 38576 38577 38578 38579 38580 38581 38582 38583 38584 38585 38586 38587 38588 38589 38590 38591 38592 38593 38594 38595 38596 38597 38598 38599 38600 38601 38602 38603 38604 38605 38606 38607 38608 38609 38610 38611 38612 38613 38614 38615 38616 38617 38618 38619 38620 38621 38622 38623 38624 38625 38626 38627 38628 38629 38630 38631 38632 38633 38634 38635 38636 38637 38638 38639 38640 38641 38642 38643 38644 38645 38646 38647 38648 38649 38650 38651 38652 38653 38654 38655 38656 38657 38658 38659 38660 38661 38662 38663 38664 38665 38666 38667 38668 38669 38670 38671 38672 38673 38674 38675 38676 38677 38678 38679 38680 38681 38682 38683 38684 38685 38686 38687 38688 38689 38690 38691 38692 38693 38694 38695 38696 38697 38698 38699 38700 38701 38702 38703 38704 38705 38706 38707 38708 38709 38710 38711 38712 38713 38714 38715 38716 38717 38718 38719 38720 38721 38722 38723 38724 38725 38726 38727 38728 38729 38730 38731 38732 38733 38734 38735 38736 38737 38738 38739 38740 38741 38742 38743 38744 38745 38746 38747 38748 38749 38750 38751 38752 38753 38754 38755 38756 38757 38758 38759 38760 38761 38762 38763 38764 38765 38766 38767 38768 38769 38770 38771 38772 38773 38774 38775 38776 38777 38778 38779 38780 38781 38782 38783 38784 38785 38786 38787 38788 38789 38790 38791 38792 38793 38794 38795 38796 38797 38798 38799 38800 38801 38802 38803 38804 38805 38806 38807 38808 38809 38810 38811 38812 38813 38814 38815 38816 38817 38818 38819 38820 38821 38822 38823 38824 38825 38826 38827 38828 38829 38830 38831 38832 38833 38834 38835 38836 38837 38838 38839 38840 38841 38842 38843 38844 38845 38846 38847 38848 38849 38850 38851 38852 38853 38854 38855 38856 38857 38858 38859 38860 38861 38862 38863 38864 38865 38866 38867 38868 38869 38870 38871 38872 38873 38874 38875 38876 38877 38878 38879 38880 38881 38882 38883 38884 38885 38886 38887 38888 38889 38890 38891 38892 38893 38894 38895 38896 38897 38898 38899 38900 38901 38902 38903 38904 38905 38906 38907 38908 38909 38910 38911 38912 38913 38914 38915 38916 38917 38918 38919 38920 38921 38922 38923 38924 38925 38926 38927 38928 38929 38930 38931 38932 38933 38934 38935 38936 38937 38938 38939 38940 38941 38942 38943 38944 38945 38946 38947 38948 38949 38950 38951 38952 38953 38954 38955 38956 38957 38958 38959 38960 38961 38962 38963 38964 38965 38966 38967 38968 38969 38970 38971 38972 38973 38974 38975 38976 38977 38978 38979 38980 38981 38982 38983 38984 38985 38986 38987 38988 38989 38990 38991 38992 38993 38994 38995 38996 38997 38998 38999 39000 39001 39002 39003 39004 39005 39006 39007 39008 39009 39010 39011 39012 39013 39014 39015 39016 39017 39018 39019 39020 39021 39022 39023 39024 39025 39026 39027 39028 39029 39030 39031 39032 39033 39034 39035 39036 39037 39038 39039 39040 39041 39042 39043 39044 39045 39046 39047 39048 39049 39050 39051 39052 39053 39054 39055 39056 39057 39058 39059 39060 39061 39062 39063 39064 39065 39066 39067 39068 39069 39070 39071 39072 39073 39074 39075 39076 39077 39078 39079 39080 39081 39082 39083 39084 39085 39086 39087 39088 39089 39090 39091 39092 39093 39094 39095 39096 39097 39098 39099 39100 39101 39102 39103 39104 39105 39106 39107 39108 39109 39110 39111 39112 39113 39114 39115 39116 39117 39118 39119 39120 39121 39122 39123 39124 39125 39126 39127 39128 39129 39130 39131 39132 39133 39134 39135 39136 39137 39138 39139 39140 39141 39142 39143 39144 39145 39146 39147 39148 39149 39150 39151 39152 39153 39154 39155 39156 39157 39158 39159 39160 39161 39162 39163 39164 39165 39166 39167 39168 39169 39170 39171 39172 39173 39174 39175 39176 39177 39178 39179 39180 39181 39182 39183 39184 39185 39186 39187 39188 39189 39190 39191 39192 39193 39194 39195 39196 39197 39198 39199 39200 39201 39202 39203 39204 39205 39206 39207 39208 39209 39210 39211 39212 39213 39214 39215 39216 39217 39218 39219 39220 39221 39222 39223 39224 39225 39226 39227 39228 39229 39230 39231 39232 39233 39234 39235 39236 39237 39238 39239 39240 39241 39242 39243 39244 39245 39246 39247 39248 39249 39250 39251 39252 39253 39254 39255 39256 39257 39258 39259 39260 39261 39262 39263 39264 39265 39266 39267 39268 39269 39270 39271 39272 39273 39274 39275 39276 39277 39278 39279 39280 39281 39282 39283 39284 39285 39286 39287 39288 39289 39290 39291 39292 39293 39294 39295 39296 39297 39298 39299 39300 39301 39302 39303 39304 39305 39306 39307 39308 39309 39310 39311 39312 39313 39314 39315 39316 39317 39318 39319 39320 39321 39322 39323 39324 39325 39326 39327 39328 39329 39330 39331 39332 39333 39334 39335 39336 39337 39338 39339 39340 39341 39342 39343 39344 39345 39346 39347 39348 39349 39350 39351 39352 39353 39354 39355 39356 39357 39358 39359 39360 39361 39362 39363 39364 39365 39366 39367 39368 39369 39370 39371 39372 39373 39374 39375 39376 39377 39378 39379 39380 39381 39382 39383 39384 39385 39386 39387 39388 39389 39390 39391 39392 39393 39394 39395 39396 39397 39398 39399 39400 39401 39402 39403 39404 39405 39406 39407 39408 39409 39410 39411 39412 39413 39414 39415 39416 39417 39418 39419 39420 39421 39422 39423 39424 39425 39426 39427 39428 39429 39430 39431 39432 39433 39434 39435 39436 39437 39438 39439 39440 39441 39442 39443 39444 39445 39446 39447 39448 39449 39450 39451 39452 39453 39454 39455 39456 39457 39458 39459 39460 39461 39462 39463 39464 39465 39466 39467 39468 39469 39470 39471 39472 39473 39474 39475 39476 39477 39478 39479 39480 39481 39482 39483 39484 39485 39486 39487 39488 39489 39490 39491 39492 39493 39494 39495 39496 39497 39498 39499 39500 39501 39502 39503 39504 39505 39506 39507 39508 39509 39510 39511 39512 39513 39514 39515 39516 39517 39518 39519 39520 39521 39522 39523 39524 39525 39526 39527 39528 39529 39530 39531 39532 39533 39534 39535 39536 39537 39538 39539 39540 39541 39542 39543 39544 39545 39546 39547 39548 39549 39550 39551 39552 39553 39554 39555 39556 39557 39558 39559 39560 39561 39562 39563 39564 39565 39566 39567 39568 39569 39570 39571 39572 39573 39574 39575 39576 39577 39578 39579 39580 39581 39582 39583 39584 39585 39586 39587 39588 39589 39590 39591 39592 39593 39594 39595 39596 39597 39598 39599 39600 39601 39602 39603 39604 39605 39606 39607 39608 39609 39610 39611 39612 39613 39614 39615 39616 39617 39618 39619 39620 39621 39622 39623 39624 39625 39626 39627 39628 39629 39630 39631 39632 39633 39634 39635 39636 39637 39638 39639 39640 39641 39642 39643 39644 39645 39646 39647 39648 39649 39650 39651 39652 39653 39654 39655 39656 39657 39658 39659 39660 39661 39662 39663 39664 39665 39666 39667 39668 39669 39670 39671 39672 39673 39674 39675 39676 39677 39678 39679 39680 39681 39682 39683 39684 39685 39686 39687 39688 39689 39690 39691 39692 39693 39694 39695 39696 39697 39698 39699 39700 39701 39702 39703 39704 39705 39706 39707 39708 39709 39710 39711 39712 39713 39714 39715 39716 39717 39718 39719 39720 39721 39722 39723 39724 39725 39726 39727 39728 39729 39730 39731 39732 39733 39734 39735 39736 39737 39738 39739 39740 39741 39742 39743 39744 39745 39746 39747 39748 39749 39750 39751 39752 39753 39754 39755 39756 39757 39758 39759 39760 39761 39762 39763 39764 39765 39766 39767 39768 39769 39770 39771 39772 39773 39774 39775 39776 39777 39778 39779 39780 39781 39782 39783 39784 39785 39786 39787 39788 39789 39790 39791 39792 39793 39794 39795 39796 39797 39798 39799 39800 39801 39802 39803 39804 39805 39806 39807 39808 39809 39810 39811 39812 39813 39814 39815 39816 39817 39818 39819 39820 39821 39822 39823 39824 39825 39826 39827 39828 39829 39830 39831 39832 39833 39834 39835 39836 39837 39838 39839 39840 39841 39842 39843 39844 39845 39846 39847 39848 39849 39850 39851 39852 39853 39854 39855 39856 39857 39858 39859 39860 39861 39862 39863 39864 39865 39866 39867 39868 39869 39870 39871 39872 39873 39874 39875 39876 39877 39878 39879 39880 39881 39882 39883 39884 39885 39886 39887 39888 39889 39890 39891 39892 39893 39894 39895 39896 39897 39898 39899 39900 39901 39902 39903 39904 39905 39906 39907 39908 39909 39910 39911 39912 39913 39914 39915 39916 39917 39918 39919 39920 39921 39922 39923 39924 39925 39926 39927 39928 39929 39930 39931 39932 39933 39934 39935 39936 39937 39938 39939 39940 39941 39942 39943 39944 39945 39946 39947 39948 39949 39950 39951 39952 39953 39954 39955 39956 39957 39958 39959 39960 39961 39962 39963 39964 39965 39966 39967 39968 39969 39970 39971 39972 39973 39974 39975 39976 39977 39978 39979 39980 39981 39982 39983 39984 39985 39986 39987 39988 39989 39990 39991 39992 39993 39994 39995 39996 39997 39998 39999 40000 40001 40002 40003 40004 40005 40006 40007 40008 40009 40010 40011 40012 40013 40014 40015 40016 40017 40018 40019 40020 40021 40022 40023 40024 40025 40026 40027 40028 40029 40030 40031 40032 40033 40034 40035 40036 40037 40038 40039 40040 40041 40042 40043 40044 40045 40046 40047 40048 40049 40050 40051 40052 40053 40054 40055 40056 40057 40058 40059 40060 40061 40062 40063 40064 40065 40066 40067 40068 40069 40070 40071 40072 40073 40074 40075 40076 40077 40078 40079 40080 40081 40082 40083 40084 40085 40086 40087 40088 40089 40090 40091 40092 40093 40094 40095 40096 40097 40098 40099 40100 40101 40102 40103 40104 40105 40106 40107 40108 40109 40110 40111 40112 40113 40114 40115 40116 40117 40118 40119 40120 40121 40122 40123 40124 40125 40126 40127 40128 40129 40130 40131 40132 40133 40134 40135 40136 40137 40138 40139 40140 40141 40142 40143 40144 40145 40146 40147 40148 40149 40150 40151 40152 40153 40154 40155 40156 40157 40158 40159 40160 40161 40162 40163 40164 40165 40166 40167 40168 40169 40170 40171 40172 40173 40174 40175 40176 40177 40178 40179 40180 40181 40182 40183 40184 40185 40186 40187 40188 40189 40190 40191 40192 40193 40194 40195 40196 40197 40198 40199 40200 40201 40202 40203 40204 40205 40206 40207 40208 40209 40210 40211 40212 40213 40214 40215 40216 40217 40218 40219 40220 40221 40222 40223 40224 40225 40226 40227 40228 40229 40230 40231 40232 40233 40234 40235 40236 40237 40238 40239 40240 40241 40242 40243 40244 40245 40246 40247 40248 40249 40250 40251 40252 40253 40254 40255 40256 40257 40258 40259 40260 40261 40262 40263 40264 40265 40266 40267 40268 40269 40270 40271 40272 40273 40274 40275 40276 40277 40278 40279 40280 40281 40282 40283 40284 40285 40286 40287 40288 40289 40290 40291 40292 40293 40294 40295 40296 40297 40298 40299 40300 40301 40302 40303 40304 40305 40306 40307 40308 40309 40310 40311 40312 40313 40314 40315 40316 40317 40318 40319 40320 40321 40322 40323 40324 40325 40326 40327 40328 40329 40330 40331 40332 40333 40334 40335 40336 40337 40338 40339 40340 40341 40342 40343 40344 40345 40346 40347 40348 40349 40350 40351 40352 40353 40354 40355 40356 40357 40358 40359 40360 40361 40362 40363 40364 40365 40366 40367 40368 40369 40370 40371 40372 40373 40374 40375 40376 40377 40378 40379 40380 40381 40382 40383 40384 40385 40386 40387 40388 40389 40390 40391 40392 40393 40394 40395 40396 40397 40398 40399 40400 40401 40402 40403 40404 40405 40406 40407 40408 40409 40410 40411 40412 40413 40414 40415 40416 40417 40418 40419 40420 40421 40422 40423 40424 40425 40426 40427 40428 40429 40430 40431 40432 40433 40434 40435 40436 40437 40438 40439 40440 40441 40442 40443 40444 40445 40446 40447 40448 40449 40450 40451 40452 40453 40454 40455 40456 40457 40458 40459 40460 40461 40462 40463 40464 40465 40466 40467 40468 40469 40470 40471 40472 40473 40474 40475 40476 40477 40478 40479 40480 40481 40482 40483 40484 40485 40486 40487 40488 40489 40490 40491 40492 40493 40494 40495 40496 40497 40498 40499 40500 40501 40502 40503 40504 40505 40506 40507 40508 40509 40510 40511 40512 40513 40514 40515 40516 40517 40518 40519 40520 40521 40522 40523 40524 40525 40526 40527 40528 40529 40530 40531 40532 40533 40534 40535 40536 40537 40538 40539 40540 40541 40542 40543 40544 40545 40546 40547 40548 40549 40550 40551 40552 40553 40554 40555 40556 40557 40558 40559 40560 40561 40562 40563 40564 40565 40566 40567 40568 40569 40570 40571 40572 40573 40574 40575 40576 40577 40578 40579 40580 40581 40582 40583 40584 40585 40586 40587 40588 40589 40590 40591 40592 40593 40594 40595 40596 40597 40598 40599 40600 40601 40602 40603 40604 40605 40606 40607 40608 40609 40610 40611 40612 40613 40614 40615 40616 40617 40618 40619 40620 40621 40622 40623 40624 40625 40626 40627 40628 40629 40630 40631 40632 40633 40634 40635 40636 40637 40638 40639 40640 40641 40642 40643 40644 40645 40646 40647 40648 40649 40650 40651 40652 40653 40654 40655 40656 40657 40658 40659 40660 40661 40662 40663 40664 40665 40666 40667 40668 40669 40670 40671 40672 40673 40674 40675 40676 40677 40678 40679 40680 40681 40682 40683 40684 40685 40686 40687 40688 40689 40690 40691 40692 40693 40694 40695 40696 40697 40698 40699 40700 40701 40702 40703 40704 40705 40706 40707 40708 40709 40710 40711 40712 40713 40714 40715 40716 40717 40718 40719 40720 40721 40722 40723 40724 40725 40726 40727 40728 40729 40730 40731 40732 40733 40734 40735 40736 40737 40738 40739 40740 40741 40742 40743 40744 40745 40746 40747 40748 40749 40750 40751 40752 40753 40754 40755 40756 40757 40758 40759 40760 40761 40762 40763 40764 40765 40766 40767 40768 40769 40770 40771 40772 40773 40774 40775 40776 40777 40778 40779 40780 40781 40782 40783 40784 40785 40786 40787 40788 40789 40790 40791 40792 40793 40794 40795 40796 40797 40798 40799 40800 40801 40802 40803 40804 40805 40806 40807 40808 40809 40810 40811 40812 40813 40814 40815 40816 40817 40818 40819 40820 40821 40822 40823 40824 40825 40826 40827 40828 40829 40830 40831 40832 40833 40834 40835 40836 40837 40838 40839 40840 40841 40842 40843 40844 40845 40846 40847 40848 40849 40850 40851 40852 40853 40854 40855 40856 40857 40858 40859 40860 40861 40862 40863 40864 40865 40866 40867 40868 40869 40870 40871 40872 40873 40874 40875 40876 40877 40878 40879 40880 40881 40882 40883 40884 40885 40886 40887 40888 40889 40890 40891 40892 40893 40894 40895 40896 40897 40898 40899 40900 40901 40902 40903 40904 40905 40906 40907 40908 40909 40910 40911 40912 40913 40914 40915 40916 40917 40918 40919 40920 40921 40922 40923 40924 40925 40926 40927 40928 40929 40930 40931 40932 40933 40934 40935 40936 40937 40938 40939 40940 40941 40942 40943 40944 40945 40946 40947 40948 40949 40950 40951 40952 40953 40954 40955 40956 40957 40958 40959 40960 40961 40962 40963 40964 40965 40966 40967 40968 40969 40970 40971 40972 40973 40974 40975 40976 40977 40978 40979 40980 40981 40982 40983 40984 40985 40986 40987 40988 40989 40990 40991 40992 40993 40994 40995 40996 40997 40998 40999 41000 41001 41002 41003 41004 41005 41006 41007 41008 41009 41010 41011 41012 41013 41014 41015 41016 41017 41018 41019 41020 41021 41022 41023 41024 41025 41026 41027 41028 41029 41030 41031 41032 41033 41034 41035 41036 41037 41038 41039 41040 41041 41042 41043 41044 41045 41046 41047 41048 41049 41050 41051 41052 41053 41054 41055 41056 41057 41058 41059 41060 41061 41062 41063 41064 41065 41066 41067 41068 41069 41070 41071 41072 41073 41074 41075 41076 41077 41078 41079 41080 41081 41082 41083 41084 41085 41086 41087 41088 41089 41090 41091 41092 41093 41094 41095 41096 41097 41098 41099 41100 41101 41102 41103 41104 41105 41106 41107 41108 41109 41110 41111 41112 41113 41114 41115 41116 41117 41118 41119 41120 41121 41122 41123 41124 41125 41126 41127 41128 41129 41130 41131 41132 41133 41134 41135 41136 41137 41138 41139 41140 41141 41142 41143 41144 41145 41146 41147 41148 41149 41150 41151 41152 41153 41154 41155 41156 41157 41158 41159 41160 41161 41162 41163 41164 41165 41166 41167 41168 41169 41170 41171 41172 41173 41174 41175 41176 41177 41178 41179 41180 41181 41182 41183 41184 41185 41186 41187 41188 41189 41190 41191 41192 41193 41194 41195 41196 41197 41198 41199 41200 41201 41202 41203 41204 41205 41206 41207 41208 41209 41210 41211 41212 41213 41214 41215 41216 41217 41218 41219 41220 41221 41222 41223 41224 41225 41226 41227 41228 41229 41230 41231 41232 41233 41234 41235 41236 41237 41238 41239 41240 41241 41242 41243 41244 41245 41246 41247 41248 41249 41250 41251 41252 41253 41254 41255 41256 41257 41258 41259 41260 41261 41262 41263 41264 41265 41266 41267 41268 41269 41270 41271 41272 41273 41274 41275 41276 41277 41278 41279 41280 41281 41282 41283 41284 41285 41286 41287 41288 41289 41290 41291 41292 41293 41294 41295 41296 41297 41298 41299 41300 41301 41302 41303 41304 41305 41306 41307 41308 41309 41310 41311 41312 41313 41314 41315 41316 41317 41318 41319 41320 41321 41322 41323 41324 41325 41326 41327 41328 41329 41330 41331 41332 41333 41334 41335 41336 41337 41338 41339 41340 41341 41342 41343 41344 41345 41346 41347 41348 41349 41350 41351 41352 41353 41354 41355 41356 41357 41358 41359 41360 41361 41362 41363 41364 41365 41366 41367 41368 41369 41370 41371 41372 41373 41374 41375 41376 41377 41378 41379 41380 41381 41382 41383 41384 41385 41386 41387 41388 41389 41390 41391 41392 41393 41394 41395 41396 41397 41398 41399 41400 41401 41402 41403 41404 41405 41406 41407 41408 41409 41410 41411 41412 41413 41414 41415 41416 41417 41418 41419 41420 41421 41422 41423 41424 41425 41426 41427 41428 41429 41430 41431 41432 41433 41434 41435 41436 41437 41438 41439 41440 41441 41442 41443 41444 41445 41446 41447 41448 41449 41450 41451 41452 41453 41454 41455 41456 41457 41458 41459 41460 41461 41462 41463 41464 41465 41466 41467 41468 41469 41470 41471 41472 41473 41474 41475 41476 41477 41478 41479 41480 41481 41482 41483 41484 41485 41486 41487 41488 41489 41490 41491 41492 41493 41494 41495 41496 41497 41498 41499 41500 41501 41502 41503 41504 41505 41506 41507 41508 41509 41510 41511 41512 41513 41514 41515 41516 41517 41518 41519 41520 41521 41522 41523 41524 41525 41526 41527 41528 41529 41530 41531 41532 41533 41534 41535 41536 41537 41538 41539 41540 41541 41542 41543 41544 41545 41546 41547 41548 41549 41550 41551 41552 41553 41554 41555 41556 41557 41558 41559 41560 41561 41562 41563 41564 41565 41566 41567 41568 41569 41570 41571 41572 41573 41574 41575 41576 41577 41578 41579 41580 41581 41582 41583 41584 41585 41586 41587 41588 41589 41590 41591 41592 41593 41594 41595 41596 41597 41598 41599 41600 41601 41602 41603 41604 41605 41606 41607 41608 41609 41610 41611 41612 41613 41614 41615 41616 41617 41618 41619 41620 41621 41622 41623 41624 41625 41626 41627 41628 41629 41630 41631 41632 41633 41634 41635 41636 41637 41638 41639 41640 41641 41642 41643 41644 41645 41646 41647 41648 41649 41650 41651 41652 41653 41654 41655 41656 41657 41658 41659 41660 41661 41662 41663 41664 41665 41666 41667 41668 41669 41670 41671 41672 41673 41674 41675 41676 41677 41678 41679 41680 41681 41682 41683 41684 41685 41686 41687 41688 41689 41690 41691 41692 41693 41694 41695 41696 41697 41698 41699 41700 41701 41702 41703 41704 41705 41706 41707 41708 41709 41710 41711 41712 41713 41714 41715 41716 41717 41718 41719 41720 41721 41722 41723 41724 41725 41726 41727 41728 41729 41730 41731 41732 41733 41734 41735 41736 41737 41738 41739 41740 41741 41742 41743 41744 41745 41746 41747 41748 41749 41750 41751 41752 41753 41754 41755 41756 41757 41758 41759 41760 41761 41762 41763 41764 41765 41766 41767 41768 41769 41770 41771 41772 41773 41774 41775 41776 41777 41778 41779 41780 41781 41782 41783 41784 41785 41786 41787 41788 41789 41790 41791 41792 41793 41794 41795 41796 41797 41798 41799 41800 41801 41802 41803 41804 41805 41806 41807 41808 41809 41810 41811 41812 41813 41814 41815 41816 41817 41818 41819 41820 41821 41822 41823 41824 41825 41826 41827 41828 41829 41830 41831 41832 41833 41834 41835 41836 41837 41838 41839 41840 41841 41842 41843 41844 41845 41846 41847 41848 41849 41850 41851 41852 41853 41854 41855 41856 41857 41858 41859 41860 41861 41862 41863 41864 41865 41866 41867 41868 41869 41870 41871 41872 41873 41874 41875 41876 41877 41878 41879 41880 41881 41882 41883 41884 41885 41886 41887 41888 41889 41890 41891 41892 41893 41894 41895 41896 41897 41898 41899 41900 41901 41902 41903 41904 41905 41906 41907 41908 41909 41910 41911 41912 41913 41914 41915 41916 41917 41918 41919 41920 41921 41922 41923 41924 41925 41926 41927 41928 41929 41930 41931 41932 41933 41934 41935 41936 41937 41938 41939 41940 41941 41942 41943 41944 41945 41946 41947 41948 41949 41950 41951 41952 41953 41954 41955 41956 41957 41958 41959 41960 41961 41962 41963 41964 41965 41966 41967 41968 41969 41970 41971 41972 41973 41974 41975 41976 41977 41978 41979 41980 41981 41982 41983 41984 41985 41986 41987 41988 41989 41990 41991 41992 41993 41994 41995 41996 41997 41998 41999 42000 42001 42002 42003 42004 42005 42006 42007 42008 42009 42010 42011 42012 42013 42014 42015 42016 42017 42018 42019 42020 42021 42022 42023 42024 42025 42026 42027 42028 42029 42030 42031 42032 42033 42034 42035 42036 42037 42038 42039 42040 42041 42042 42043 42044 42045 42046 42047 42048 42049 42050 42051 42052 42053 42054 42055 42056 42057 42058 42059 42060 42061 42062 42063 42064 42065 42066 42067 42068 42069 42070 42071 42072 42073 42074 42075 42076 42077 42078 42079 42080 42081 42082 42083 42084 42085 42086 42087 42088 42089 42090 42091 42092 42093 42094 42095 42096 42097 42098 42099 42100 42101 42102 42103 42104 42105 42106 42107 42108 42109 42110 42111 42112 42113 42114 42115 42116 42117 42118 42119 42120 42121 42122 42123 42124 42125 42126 42127 42128 42129 42130 42131 42132 42133 42134 42135 42136 42137 42138 42139 42140 42141 42142 42143 42144 42145 42146 42147 42148 42149 42150 42151 42152 42153 42154 42155 42156 42157 42158 42159 42160 42161 42162 42163 42164 42165 42166 42167 42168 42169 42170 42171 42172 42173 42174 42175 42176 42177 42178 42179 42180 42181 42182 42183 42184 42185 42186 42187 42188 42189 42190 42191 42192 42193 42194 42195 42196 42197 42198 42199 42200 42201 42202 42203 42204 42205 42206 42207 42208 42209 42210 42211 42212 42213 42214 42215 42216 42217 42218 42219 42220 42221 42222 42223 42224 42225 42226 42227 42228 42229 42230 42231 42232 42233 42234 42235 42236 42237 42238 42239 42240 42241 42242 42243 42244 42245 42246 42247 42248 42249 42250 42251 42252 42253 42254 42255 42256 42257 42258 42259 42260 42261 42262 42263 42264 42265 42266 42267 42268 42269 42270 42271 42272 42273 42274 42275 42276 42277 42278 42279 42280 42281 42282 42283 42284 42285 42286 42287 42288 42289 42290 42291 42292 42293 42294 42295 42296 42297 42298 42299 42300 42301 42302 42303 42304 42305 42306 42307 42308 42309 42310 42311 42312 42313 42314 42315 42316 42317 42318 42319 42320 42321 42322 42323 42324 42325 42326 42327 42328 42329 42330 42331 42332 42333 42334 42335 42336 42337 42338 42339 42340 42341 42342 42343 42344 42345 42346 42347 42348 42349 42350 42351 42352 42353 42354 42355 42356 42357 42358 42359 42360 42361 42362 42363 42364 42365 42366 42367 42368 42369 42370 42371 42372 42373 42374 42375 42376 42377 42378 42379 42380 42381 42382 42383 42384 42385 42386 42387 42388 42389 42390 42391 42392 42393 42394 42395 42396 42397 42398 42399 42400 42401 42402 42403 42404 42405 42406 42407 42408 42409 42410 42411 42412 42413 42414 42415 42416 42417 42418 42419 42420 42421 42422 42423 42424 42425 42426 42427 42428 42429 42430 42431 42432 42433 42434 42435 42436 42437 42438 42439 42440 42441 42442 42443 42444 42445 42446 42447 42448 42449 42450 42451 42452 42453 42454 42455 42456 42457 42458 42459 42460 42461 42462 42463 42464 42465 42466 42467 42468 42469 42470 42471 42472 42473 42474 42475 42476 42477 42478 42479 42480 42481 42482 42483 42484 42485 42486 42487 42488 42489 42490 42491 42492 42493 42494 42495 42496 42497 42498 42499 42500 42501 42502 42503 42504 42505 42506 42507 42508 42509 42510 42511 42512 42513 42514 42515 42516 42517 42518 42519 42520 42521 42522 42523 42524 42525 42526 42527 42528 42529 42530 42531 42532 42533 42534 42535 42536 42537 42538 42539 42540 42541 42542 42543 42544 42545 42546 42547 42548 42549 42550 42551 42552 42553 42554 42555 42556 42557 42558 42559 42560 42561 42562 42563 42564 42565 42566 42567 42568 42569 42570 42571 42572 42573 42574 42575 42576 42577 42578 42579 42580 42581 42582 42583 42584 42585 42586 42587 42588 42589 42590 42591 42592 42593 42594 42595 42596 42597 42598 42599 42600 42601 42602 42603 42604 42605 42606 42607 42608 42609 42610 42611 42612 42613 42614 42615 42616 42617 42618 42619 42620 42621 42622 42623 42624 42625 42626 42627 42628 42629 42630 42631 42632 42633 42634 42635 42636 42637 42638 42639 42640 42641 42642 42643 42644 42645 42646 42647 42648 42649 42650 42651 42652 42653 42654 42655 42656 42657 42658 42659 42660 42661 42662 42663 42664 42665 42666 42667 42668 42669 42670 42671 42672 42673 42674 42675 42676 42677 42678 42679 42680 42681 42682 42683 42684 42685 42686 42687 42688 42689 42690 42691 42692 42693 42694 42695 42696 42697 42698 42699 42700 42701 42702 42703 42704 42705 42706 42707 42708 42709 42710 42711 42712 42713 42714 42715 42716 42717 42718 42719 42720 42721 42722 42723 42724 42725 42726 42727 42728 42729 42730 42731 42732 42733 42734 42735 42736 42737 42738 42739 42740 42741 42742 42743 42744 42745 42746 42747 42748 42749 42750 42751 42752 42753 42754 42755 42756 42757 42758 42759 42760 42761 42762 42763 42764 42765 42766 42767 42768 42769 42770 42771 42772 42773 42774 42775 42776 42777 42778 42779 42780 42781 42782 42783 42784 42785 42786 42787 42788 42789 42790 42791 42792 42793 42794 42795 42796 42797 42798 42799 42800 42801 42802 42803 42804 42805 42806 42807 42808 42809 42810 42811 42812 42813 42814 42815 42816 42817 42818 42819 42820 42821 42822 42823 42824 42825 42826 42827 42828 42829 42830 42831 42832 42833 42834 42835 42836 42837 42838 42839 42840 42841 42842 42843 42844 42845 42846 42847 42848 42849 42850 42851 42852 42853 42854 42855 42856 42857 42858 42859 42860 42861 42862 42863 42864 42865 42866 42867 42868 42869 42870 42871 42872 42873 42874 42875 42876 42877 42878 42879 42880 42881 42882 42883 42884 42885 42886 42887 42888 42889 42890 42891 42892 42893 42894 42895 42896 42897 42898 42899 42900 42901 42902 42903 42904 42905 42906 42907 42908 42909 42910 42911 42912 42913 42914 42915 42916 42917 42918 42919 42920 42921 42922 42923 42924 42925 42926 42927 42928 42929 42930 42931 42932 42933 42934 42935 42936 42937 42938 42939 42940 42941 42942 42943 42944 42945 42946 42947 42948 42949 42950 42951 42952 42953 42954 42955 42956 42957 42958 42959 42960 42961 42962 42963 42964 42965 42966 42967 42968 42969 42970 42971 42972 42973 42974 42975 42976 42977 42978 42979 42980 42981 42982 42983 42984 42985 42986 42987 42988 42989 42990 42991 42992 42993 42994 42995 42996 42997 42998 42999 43000 43001 43002 43003 43004 43005 43006 43007 43008 43009 43010 43011 43012 43013 43014 43015 43016 43017 43018 43019 43020 43021 43022 43023 43024 43025 43026 43027 43028 43029 43030 43031 43032 43033 43034 43035 43036 43037 43038 43039 43040 43041 43042 43043 43044 43045 43046 43047 43048 43049 43050 43051 43052 43053 43054 43055 43056 43057 43058 43059 43060 43061 43062 43063 43064 43065 43066 43067 43068 43069 43070 43071 43072 43073 43074 43075 43076 43077 43078 43079 43080 43081 43082 43083 43084 43085 43086 43087 43088 43089 43090 43091 43092 43093 43094 43095 43096 43097 43098 43099 43100 43101 43102 43103 43104 43105 43106 43107 43108 43109 43110 43111 43112 43113 43114 43115 43116 43117 43118 43119 43120 43121 43122 43123 43124 43125 43126 43127 43128 43129 43130 43131 43132 43133 43134 43135 43136 43137 43138 43139 43140 43141 43142 43143 43144 43145 43146 43147 43148 43149 43150 43151 43152 43153 43154 43155 43156 43157 43158 43159 43160 43161 43162 43163 43164 43165 43166 43167 43168 43169 43170 43171 43172 43173 43174 43175 43176 43177 43178 43179 43180 43181 43182 43183 43184 43185 43186 43187 43188 43189 43190 43191 43192 43193 43194 43195 43196 43197 43198 43199 43200 43201 43202 43203 43204 43205 43206 43207 43208 43209 43210 43211 43212 43213 43214 43215 43216 43217 43218 43219 43220 43221 43222 43223 43224 43225 43226 43227 43228 43229 43230 43231 43232 43233 43234 43235 43236 43237 43238 43239 43240 43241 43242 43243 43244 43245 43246 43247 43248 43249 43250 43251 43252 43253 43254 43255 43256 43257 43258 43259 43260 43261 43262 43263 43264 43265 43266 43267 43268 43269 43270 43271 43272 43273 43274 43275 43276 43277 43278 43279 43280 43281 43282 43283 43284 43285 43286 43287 43288 43289 43290 43291 43292 43293 43294 43295 43296 43297 43298 43299 43300 43301 43302 43303 43304 43305 43306 43307 43308 43309 43310 43311 43312 43313 43314 43315 43316 43317 43318 43319 43320 43321 43322 43323 43324 43325 43326 43327 43328 43329 43330 43331 43332 43333 43334 43335 43336 43337 43338 43339 43340 43341 43342 43343 43344 43345 43346 43347 43348 43349 43350 43351 43352 43353 43354 43355 43356 43357 43358 43359 43360 43361 43362 43363 43364 43365 43366 43367 43368 43369 43370 43371 43372 43373 43374 43375 43376 43377 43378 43379 43380 43381 43382 43383 43384 43385 43386 43387 43388 43389 43390 43391 43392 43393 43394 43395 43396 43397 43398 43399 43400 43401 43402 43403 43404 43405 43406 43407 43408 43409 43410 43411 43412 43413 43414 43415 43416 43417 43418 43419 43420 43421 43422 43423 43424 43425 43426 43427 43428 43429 43430 43431 43432 43433 43434 43435 43436 43437 43438 43439 43440 43441 43442 43443 43444 43445 43446 43447 43448 43449 43450 43451 43452 43453 43454 43455 43456 43457 43458 43459 43460 43461 43462 43463 43464 43465 43466 43467 43468 43469 43470 43471 43472 43473 43474 43475 43476 43477 43478 43479 43480 43481 43482 43483 43484 43485 43486 43487 43488 43489 43490 43491 43492 43493 43494 43495 43496 43497 43498 43499 43500 43501 43502 43503 43504 43505 43506 43507 43508 43509 43510 43511 43512 43513 43514 43515 43516 43517 43518 43519 43520 43521 43522 43523 43524 43525 43526 43527 43528 43529 43530 43531 43532 43533 43534 43535 43536 43537 43538 43539 43540 43541 43542 43543 43544 43545 43546 43547 43548 43549 43550 43551 43552 43553 43554 43555 43556 43557 43558 43559 43560 43561 43562 43563 43564 43565 43566 43567 43568 43569 43570 43571 43572 43573 43574 43575 43576 43577 43578 43579 43580 43581 43582 43583 43584 43585 43586 43587 43588 43589 43590 43591 43592 43593 43594 43595 43596 43597 43598 43599 43600 43601 43602 43603 43604 43605 43606 43607 43608 43609 43610 43611 43612 43613 43614 43615 43616 43617 43618 43619 43620 43621 43622 43623 43624 43625 43626 43627 43628 43629 43630 43631 43632 43633 43634 43635 43636 43637 43638 43639 43640 43641 43642 43643 43644 43645 43646 43647 43648 43649 43650 43651 43652 43653 43654 43655 43656 43657 43658 43659 43660 43661 43662 43663 43664 43665 43666 43667 43668 43669 43670 43671 43672 43673 43674 43675 43676 43677 43678 43679 43680 43681 43682 43683 43684 43685 43686 43687 43688 43689 43690 43691 43692 43693 43694 43695 43696 43697 43698 43699 43700 43701 43702 43703 43704 43705 43706 43707 43708 43709 43710 43711 43712 43713 43714 43715 43716 43717 43718 43719 43720 43721 43722 43723 43724 43725 43726 43727 43728 43729 43730 43731 43732 43733 43734 43735 43736 43737 43738 43739 43740 43741 43742 43743 43744 43745 43746 43747 43748 43749 43750 43751 43752 43753 43754 43755 43756 43757 43758 43759 43760 43761 43762 43763 43764 43765 43766 43767 43768 43769 43770 43771 43772 43773 43774 43775 43776 43777 43778 43779 43780 43781 43782 43783 43784 43785 43786 43787 43788 43789 43790 43791 43792 43793 43794 43795 43796 43797 43798 43799 43800 43801 43802 43803 43804 43805 43806 43807 43808 43809 43810 43811 43812 43813 43814 43815 43816 43817 43818 43819 43820 43821 43822 43823 43824 43825 43826 43827 43828 43829 43830 43831 43832 43833 43834 43835 43836 43837 43838 43839 43840 43841 43842 43843 43844 43845 43846 43847 43848 43849 43850 43851 43852 43853 43854 43855 43856 43857 43858 43859 43860 43861 43862 43863 43864 43865 43866 43867 43868 43869 43870 43871 43872 43873 43874 43875 43876 43877 43878 43879 43880 43881 43882 43883 43884 43885 43886 43887 43888 43889 43890 43891 43892 43893 43894 43895 43896 43897 43898 43899 43900 43901 43902 43903 43904 43905 43906 43907 43908 43909 43910 43911 43912 43913 43914 43915 43916 43917 43918 43919 43920 43921 43922 43923 43924 43925 43926 43927 43928 43929 43930 43931 43932 43933 43934 43935 43936 43937 43938 43939 43940 43941 43942 43943 43944 43945 43946 43947 43948 43949 43950 43951 43952 43953 43954 43955 43956 43957 43958 43959 43960 43961 43962 43963 43964 43965 43966 43967 43968 43969 43970 43971 43972 43973 43974 43975 43976 43977 43978 43979 43980 43981 43982 43983 43984 43985 43986 43987 43988 43989 43990 43991 43992 43993 43994 43995 43996 43997 43998 43999 44000 44001 44002 44003 44004 44005 44006 44007 44008 44009 44010 44011 44012 44013 44014 44015 44016 44017 44018 44019 44020 44021 44022 44023 44024 44025 44026 44027 44028 44029 44030 44031 44032 44033 44034 44035 44036 44037 44038 44039 44040 44041 44042 44043 44044 44045 44046 44047 44048 44049 44050 44051 44052 44053 44054 44055 44056 44057 44058 44059 44060 44061 44062 44063 44064 44065 44066 44067 44068 44069 44070 44071 44072 44073 44074 44075 44076 44077 44078 44079 44080 44081 44082 44083 44084 44085 44086 44087 44088 44089 44090 44091 44092 44093 44094 44095 44096 44097 44098 44099 44100 44101 44102 44103 44104 44105 44106 44107 44108 44109 44110 44111 44112 44113 44114 44115 44116 44117 44118 44119 44120 44121 44122 44123 44124 44125 44126 44127 44128 44129 44130 44131 44132 44133 44134 44135 44136 44137 44138 44139 44140 44141 44142 44143 44144 44145 44146 44147 44148 44149 44150 44151 44152 44153 44154 44155 44156 44157 44158 44159 44160 44161 44162 44163 44164 44165 44166 44167 44168 44169 44170 44171 44172 44173 44174 44175 44176 44177 44178 44179 44180 44181 44182 44183 44184 44185 44186 44187 44188 44189 44190 44191 44192 44193 44194 44195 44196 44197 44198 44199 44200 44201 44202 44203 44204 44205 44206 44207 44208 44209 44210 44211 44212 44213 44214 44215 44216 44217 44218 44219 44220 44221 44222 44223 44224 44225 44226 44227 44228 44229 44230 44231 44232 44233 44234 44235 44236 44237 44238 44239 44240 44241 44242 44243 44244 44245 44246 44247 44248 44249 44250 44251 44252 44253 44254 44255 44256 44257 44258 44259 44260 44261 44262 44263 44264 44265 44266 44267 44268 44269 44270 44271 44272 44273 44274 44275 44276 44277 44278 44279 44280 44281 44282 44283 44284 44285 44286 44287 44288 44289 44290 44291 44292 44293 44294 44295 44296 44297 44298 44299 44300 44301 44302 44303 44304 44305 44306 44307 44308 44309 44310 44311 44312 44313 44314 44315 44316 44317 44318 44319 44320 44321 44322 44323 44324 44325 44326 44327 44328 44329 44330 44331 44332 44333 44334 44335 44336 44337 44338 44339 44340 44341 44342 44343 44344 44345 44346 44347 44348 44349 44350 44351 44352 44353 44354 44355 44356 44357 44358 44359 44360 44361 44362 44363 44364 44365 44366 44367 44368 44369 44370 44371 44372 44373 44374 44375 44376 44377 44378 44379 44380 44381 44382 44383 44384 44385 44386 44387 44388 44389 44390 44391 44392 44393 44394 44395 44396 44397 44398 44399 44400 44401 44402 44403 44404 44405 44406 44407 44408 44409 44410 44411 44412 44413 44414 44415 44416 44417 44418 44419 44420 44421 44422 44423 44424 44425 44426 44427 44428 44429 44430 44431 44432 44433 44434 44435 44436 44437 44438 44439 44440 44441 44442 44443 44444 44445 44446 44447 44448 44449 44450 44451 44452 44453 44454 44455 44456 44457 44458 44459 44460 44461 44462 44463 44464 44465 44466 44467 44468 44469 44470 44471 44472 44473 44474 44475 44476 44477 44478 44479 44480 44481 44482 44483 44484 44485 44486 44487 44488 44489 44490 44491 44492 44493 44494 44495 44496 44497 44498 44499 44500 44501 44502 44503 44504 44505 44506 44507 44508 44509 44510 44511 44512 44513 44514 44515 44516 44517 44518 44519 44520 44521 44522 44523 44524 44525 44526 44527 44528 44529 44530 44531 44532 44533 44534 44535 44536 44537 44538 44539 44540 44541 44542 44543 44544 44545 44546 44547 44548 44549 44550 44551 44552 44553 44554 44555 44556 44557 44558 44559 44560 44561 44562 44563 44564 44565 44566 44567 44568 44569 44570 44571 44572 44573 44574 44575 44576 44577 44578 44579 44580 44581 44582 44583 44584 44585 44586 44587 44588 44589 44590 44591 44592 44593 44594 44595 44596 44597 44598 44599 44600 44601 44602 44603 44604 44605 44606 44607 44608 44609 44610 44611 44612 44613 44614 44615 44616 44617 44618 44619 44620 44621 44622 44623 44624 44625 44626 44627 44628 44629 44630 44631 44632 44633 44634 44635 44636 44637 44638 44639 44640 44641 44642 44643 44644 44645 44646 44647 44648 44649 44650 44651 44652 44653 44654 44655 44656 44657 44658 44659 44660 44661 44662 44663 44664 44665 44666 44667 44668 44669 44670 44671 44672 44673 44674 44675 44676 44677 44678 44679 44680 44681 44682 44683 44684 44685 44686 44687 44688 44689 44690 44691 44692 44693 44694 44695 44696 44697 44698 44699 44700 44701 44702 44703 44704 44705 44706 44707 44708 44709 44710 44711 44712 44713 44714 44715 44716 44717 44718 44719 44720 44721 44722 44723 44724 44725 44726 44727 44728 44729 44730 44731 44732 44733 44734 44735 44736 44737 44738 44739 44740 44741 44742 44743 44744 44745 44746 44747 44748 44749 44750 44751 44752 44753 44754 44755 44756 44757 44758 44759 44760 44761 44762 44763 44764 44765 44766 44767 44768 44769 44770 44771 44772 44773 44774 44775 44776 44777 44778 44779 44780 44781 44782 44783 44784 44785 44786 44787 44788 44789 44790 44791 44792 44793 44794 44795 44796 44797 44798 44799 44800 44801 44802 44803 44804 44805 44806 44807 44808 44809 44810 44811 44812 44813 44814 44815 44816 44817 44818 44819 44820 44821 44822 44823 44824 44825 44826 44827 44828 44829 44830 44831 44832 44833 44834 44835 44836 44837 44838 44839 44840 44841 44842 44843 44844 44845 44846 44847 44848 44849 44850 44851 44852 44853 44854 44855 44856 44857 44858 44859 44860 44861 44862 44863 44864 44865 44866 44867 44868 44869 44870 44871 44872 44873 44874 44875 44876 44877 44878 44879 44880 44881 44882 44883 44884 44885 44886 44887 44888 44889 44890 44891 44892 44893 44894 44895 44896 44897 44898 44899 44900 44901 44902 44903 44904 44905 44906 44907 44908 44909 44910 44911 44912 44913 44914 44915 44916 44917 44918 44919 44920 44921 44922 44923 44924 44925 44926 44927 44928 44929 44930 44931 44932 44933 44934 44935 44936 44937 44938 44939 44940 44941 44942 44943 44944 44945 44946 44947 44948 44949 44950 44951 44952 44953 44954 44955 44956 44957 44958 44959 44960 44961 44962 44963 44964 44965 44966 44967 44968 44969 44970 44971 44972 44973 44974 44975 44976 44977 44978 44979 44980 44981 44982 44983 44984 44985 44986 44987 44988 44989 44990 44991 44992 44993 44994 44995 44996 44997 44998 44999 45000 45001 45002 45003 45004 45005 45006 45007 45008 45009 45010 45011 45012 45013 45014 45015 45016 45017 45018 45019 45020 45021 45022 45023 45024 45025 45026 45027 45028 45029 45030 45031 45032 45033 45034 45035 45036 45037 45038 45039 45040 45041 45042 45043 45044 45045 45046 45047 45048 45049 45050 45051 45052 45053 45054 45055 45056 45057 45058 45059 45060 45061 45062 45063 45064 45065 45066 45067 45068 45069 45070 45071 45072 45073 45074 45075 45076 45077 45078 45079 45080 45081 45082 45083 45084 45085 45086 45087 45088 45089 45090 45091 45092 45093 45094 45095 45096 45097 45098 45099 45100 45101 45102 45103 45104 45105 45106 45107 45108 45109 45110 45111 45112 45113 45114 45115 45116 45117 45118 45119 45120 45121 45122 45123 45124 45125 45126 45127 45128 45129 45130 45131 45132 45133 45134 45135 45136 45137 45138 45139 45140 45141 45142 45143 45144 45145 45146 45147 45148 45149 45150 45151 45152 45153 45154 45155 45156 45157 45158 45159 45160 45161 45162 45163 45164 45165 45166 45167 45168 45169 45170 45171 45172 45173 45174 45175 45176 45177 45178 45179 45180 45181 45182 45183 45184 45185 45186 45187 45188 45189 45190 45191 45192 45193 45194 45195 45196 45197 45198 45199 45200 45201 45202 45203 45204 45205 45206 45207 45208 45209 45210 45211 45212 45213 45214 45215 45216 45217 45218 45219 45220 45221 45222 45223 45224 45225 45226 45227 45228 45229 45230 45231 45232 45233 45234 45235 45236 45237 45238 45239 45240 45241 45242 45243 45244 45245 45246 45247 45248 45249 45250 45251 45252 45253 45254 45255 45256 45257 45258 45259 45260 45261 45262 45263 45264 45265 45266 45267 45268 45269 45270 45271 45272 45273 45274 45275 45276 45277 45278 45279 45280 45281 45282 45283 45284 45285 45286 45287 45288 45289 45290 45291 45292 45293 45294 45295 45296 45297 45298 45299 45300 45301 45302 45303 45304 45305 45306 45307 45308 45309 45310 45311 45312 45313 45314 45315 45316 45317 45318 45319 45320 45321 45322 45323 45324 45325 45326 45327 45328 45329 45330 45331 45332 45333 45334 45335 45336 45337 45338 45339 45340 45341 45342 45343 45344 45345 45346 45347 45348 45349 45350 45351 45352 45353 45354 45355 45356 45357 45358 45359 45360 45361 45362 45363 45364 45365 45366 45367 45368 45369 45370 45371 45372 45373 45374 45375 45376 45377 45378 45379 45380 45381 45382 45383 45384 45385 45386 45387 45388 45389 45390 45391 45392 45393 45394 45395 45396 45397 45398 45399 45400 45401 45402 45403 45404 45405 45406 45407 45408 45409 45410 45411 45412 45413 45414 45415 45416 45417 45418 45419 45420 45421 45422 45423 45424 45425 45426 45427 45428 45429 45430 45431 45432 45433 45434 45435 45436 45437 45438 45439 45440 45441 45442 45443 45444 45445 45446 45447 45448 45449 45450 45451 45452 45453 45454 45455 45456 45457 45458 45459 45460 45461 45462 45463 45464 45465 45466 45467 45468 45469 45470 45471 45472 45473 45474 45475 45476 45477 45478 45479 45480 45481 45482 45483 45484 45485 45486 45487 45488 45489 45490 45491 45492 45493 45494 45495 45496 45497 45498 45499 45500 45501 45502 45503 45504 45505 45506 45507 45508 45509 45510 45511 45512 45513 45514 45515 45516 45517 45518 45519 45520 45521 45522 45523 45524 45525 45526 45527 45528 45529 45530 45531 45532 45533 45534 45535 45536 45537 45538 45539 45540 45541 45542 45543 45544 45545 45546 45547 45548 45549 45550 45551 45552 45553 45554 45555 45556 45557 45558 45559 45560 45561 45562 45563 45564 45565 45566 45567 45568 45569 45570 45571 45572 45573 45574 45575 45576 45577 45578 45579 45580 45581 45582 45583 45584 45585 45586 45587 45588 45589 45590 45591 45592 45593 45594 45595 45596 45597 45598 45599 45600 45601 45602 45603 45604 45605 45606 45607 45608 45609 45610 45611 45612 45613 45614 45615 45616 45617 45618 45619 45620 45621 45622 45623 45624 45625 45626 45627 45628 45629 45630 45631 45632 45633 45634 45635 45636 45637 45638 45639 45640 45641 45642 45643 45644 45645 45646 45647 45648 45649 45650 45651 45652 45653 45654 45655 45656 45657 45658 45659 45660 45661 45662 45663 45664 45665 45666 45667 45668 45669 45670 45671 45672 45673 45674 45675 45676 45677 45678 45679 45680 45681 45682 45683 45684 45685 45686 45687 45688 45689 45690 45691 45692 45693 45694 45695 45696 45697 45698 45699 45700 45701 45702 45703 45704 45705 45706 45707 45708 45709 45710 45711 45712 45713 45714 45715 45716 45717 45718 45719 45720 45721 45722 45723 45724 45725 45726 45727 45728 45729 45730 45731 45732 45733 45734 45735 45736 45737 45738 45739 45740 45741 45742 45743 45744 45745 45746 45747 45748 45749 45750 45751 45752 45753 45754 45755 45756 45757 45758 45759 45760 45761 45762 45763 45764 45765 45766 45767 45768 45769 45770 45771 45772 45773 45774 45775 45776 45777 45778 45779 45780 45781 45782 45783 45784 45785 45786 45787 45788 45789 45790 45791 45792 45793 45794 45795 45796 45797 45798 45799 45800 45801 45802 45803 45804 45805 45806 45807 45808 45809 45810 45811 45812 45813 45814 45815 45816 45817 45818 45819 45820 45821 45822 45823 45824 45825 45826 45827 45828 45829 45830 45831 45832 45833 45834 45835 45836 45837 45838 45839 45840 45841 45842 45843 45844 45845 45846 45847 45848 45849 45850 45851 45852 45853 45854 45855 45856 45857 45858 45859 45860 45861 45862 45863 45864 45865 45866 45867 45868 45869 45870 45871 45872 45873 45874 45875 45876 45877 45878 45879 45880 45881 45882 45883 45884 45885 45886 45887 45888 45889 45890 45891 45892 45893 45894 45895 45896 45897 45898 45899 45900 45901 45902 45903 45904 45905 45906 45907 45908 45909 45910 45911 45912 45913 45914 45915 45916 45917 45918 45919 45920 45921 45922 45923 45924 45925 45926 45927 45928 45929 45930 45931 45932 45933 45934 45935 45936 45937 45938 45939 45940 45941 45942 45943 45944 45945 45946 45947 45948 45949 45950 45951 45952 45953 45954 45955 45956 45957 45958 45959 45960 45961 45962 45963 45964 45965 45966 45967 45968 45969 45970 45971 45972 45973 45974 45975 45976 45977 45978 45979 45980 45981 45982 45983 45984 45985 45986 45987 45988 45989 45990 45991 45992 45993 45994 45995 45996 45997 45998 45999 46000 46001 46002 46003 46004 46005 46006 46007 46008 46009 46010 46011 46012 46013 46014 46015 46016 46017 46018 46019 46020 46021 46022 46023 46024 46025 46026 46027 46028 46029 46030 46031 46032 46033 46034 46035 46036 46037 46038 46039 46040 46041 46042 46043 46044 46045 46046 46047 46048 46049 46050 46051 46052 46053 46054 46055 46056 46057 46058 46059 46060 46061 46062 46063 46064 46065 46066 46067 46068 46069 46070 46071 46072 46073 46074 46075 46076 46077 46078 46079 46080 46081 46082 46083 46084 46085 46086 46087 46088 46089 46090 46091 46092 46093 46094 46095 46096 46097 46098 46099 46100 46101 46102 46103 46104 46105 46106 46107 46108 46109 46110 46111 46112 46113 46114 46115 46116 46117 46118 46119 46120 46121 46122 46123 46124 46125 46126 46127 46128 46129 46130 46131 46132 46133 46134 46135 46136 46137 46138 46139 46140 46141 46142 46143 46144 46145 46146 46147 46148 46149 46150 46151 46152 46153 46154 46155 46156 46157 46158 46159 46160 46161 46162 46163 46164 46165 46166 46167 46168 46169 46170 46171 46172 46173 46174 46175 46176 46177 46178 46179 46180 46181 46182 46183 46184 46185 46186 46187 46188 46189 46190 46191 46192 46193 46194 46195 46196 46197 46198 46199 46200 46201 46202 46203 46204 46205 46206 46207 46208 46209 46210 46211 46212 46213 46214 46215 46216 46217 46218 46219 46220 46221 46222 46223 46224 46225 46226 46227 46228 46229 46230 46231 46232 46233 46234 46235 46236 46237 46238 46239 46240 46241 46242 46243 46244 46245 46246 46247 46248 46249 46250 46251 46252 46253 46254 46255 46256 46257 46258 46259 46260 46261 46262 46263 46264 46265 46266 46267 46268 46269 46270 46271 46272 46273 46274 46275 46276 46277 46278 46279 46280 46281 46282 46283 46284 46285 46286 46287 46288 46289 46290 46291 46292 46293 46294 46295 46296 46297 46298 46299 46300 46301 46302 46303 46304 46305 46306 46307 46308 46309 46310 46311 46312 46313 46314 46315 46316 46317 46318 46319 46320 46321 46322 46323 46324 46325 46326 46327 46328 46329 46330 46331 46332 46333 46334 46335 46336 46337 46338 46339 46340 46341 46342 46343 46344 46345 46346 46347 46348 46349 46350 46351 46352 46353 46354 46355 46356 46357 46358 46359 46360 46361 46362 46363 46364 46365 46366 46367 46368 46369 46370 46371 46372 46373 46374 46375 46376 46377 46378 46379 46380 46381 46382 46383 46384 46385 46386 46387 46388 46389 46390 46391 46392 46393 46394 46395 46396 46397 46398 46399 46400 46401 46402 46403 46404 46405 46406 46407 46408 46409 46410 46411 46412 46413 46414 46415 46416 46417 46418 46419 46420 46421 46422 46423 46424 46425 46426 46427 46428 46429 46430 46431 46432 46433 46434 46435 46436 46437 46438 46439 46440 46441 46442 46443 46444 46445 46446 46447 46448 46449 46450 46451 46452 46453 46454 46455 46456 46457 46458 46459 46460 46461 46462 46463 46464 46465 46466 46467 46468 46469 46470 46471 46472 46473 46474 46475 46476 46477 46478 46479 46480 46481 46482 46483 46484 46485 46486 46487 46488 46489 46490 46491 46492 46493 46494 46495 46496 46497 46498 46499 46500 46501 46502 46503 46504 46505 46506 46507 46508 46509 46510 46511 46512 46513 46514 46515 46516 46517 46518 46519 46520 46521 46522 46523 46524 46525 46526 46527 46528 46529 46530 46531 46532 46533 46534 46535 46536 46537 46538 46539 46540 46541 46542 46543 46544 46545 46546 46547 46548 46549 46550 46551 46552 46553 46554 46555 46556 46557 46558 46559 46560 46561 46562 46563 46564 46565 46566 46567 46568 46569 46570 46571 46572 46573 46574 46575 46576 46577 46578 46579 46580 46581 46582 46583 46584 46585 46586 46587 46588 46589 46590 46591 46592 46593 46594 46595 46596 46597 46598 46599 46600 46601 46602 46603 46604 46605 46606 46607 46608 46609 46610 46611 46612 46613 46614 46615 46616 46617 46618 46619 46620 46621 46622 46623 46624 46625 46626 46627 46628 46629 46630 46631 46632 46633 46634 46635 46636 46637 46638 46639 46640 46641 46642 46643 46644 46645 46646 46647 46648 46649 46650 46651 46652 46653 46654 46655 46656 46657 46658 46659 46660 46661 46662 46663 46664 46665 46666 46667 46668 46669 46670 46671 46672 46673 46674 46675 46676 46677 46678 46679 46680 46681 46682 46683 46684 46685 46686 46687 46688 46689 46690 46691 46692 46693 46694 46695 46696 46697 46698 46699 46700 46701 46702 46703 46704 46705 46706 46707 46708 46709 46710 46711 46712 46713 46714 46715 46716 46717 46718 46719 46720 46721 46722 46723 46724 46725 46726 46727 46728 46729 46730 46731 46732 46733 46734 46735 46736 46737 46738 46739 46740 46741 46742 46743 46744 46745 46746 46747 46748 46749 46750 46751 46752 46753 46754 46755 46756 46757 46758 46759 46760 46761 46762 46763 46764 46765 46766 46767 46768 46769 46770 46771 46772 46773 46774 46775 46776 46777 46778 46779 46780 46781 46782 46783 46784 46785 46786 46787 46788 46789 46790 46791 46792 46793 46794 46795 46796 46797 46798 46799 46800 46801 46802 46803 46804 46805 46806 46807 46808 46809 46810 46811 46812 46813 46814 46815 46816 46817 46818 46819 46820 46821 46822 46823 46824 46825 46826 46827 46828 46829 46830 46831 46832 46833 46834 46835 46836 46837 46838 46839 46840 46841 46842 46843 46844 46845 46846 46847 46848 46849 46850 46851 46852 46853 46854 46855 46856 46857 46858 46859 46860 46861 46862 46863 46864 46865 46866 46867 46868 46869 46870 46871 46872 46873 46874 46875 46876 46877 46878 46879 46880 46881 46882 46883 46884 46885 46886 46887 46888 46889 46890 46891 46892 46893 46894 46895 46896 46897 46898 46899 46900 46901 46902 46903 46904 46905 46906 46907 46908 46909 46910 46911 46912 46913 46914 46915 46916 46917 46918 46919 46920 46921 46922 46923 46924 46925 46926 46927 46928 46929 46930 46931 46932 46933 46934 46935 46936 46937 46938 46939 46940 46941 46942 46943 46944 46945 46946 46947 46948 46949 46950 46951 46952 46953 46954 46955 46956 46957 46958 46959 46960 46961 46962 46963 46964 46965 46966 46967 46968 46969 46970 46971 46972 46973 46974 46975 46976 46977 46978 46979 46980 46981 46982 46983 46984 46985 46986 46987 46988 46989 46990 46991 46992 46993 46994 46995 46996 46997 46998 46999 47000 47001 47002 47003 47004 47005 47006 47007 47008 47009 47010 47011 47012 47013 47014 47015 47016 47017 47018 47019 47020 47021 47022 47023 47024 47025 47026 47027 47028 47029 47030 47031 47032 47033 47034 47035 47036 47037 47038 47039 47040 47041 47042 47043 47044 47045 47046 47047 47048 47049 47050 47051 47052 47053 47054 47055 47056 47057 47058 47059 47060 47061 47062 47063 47064 47065 47066 47067 47068 47069 47070 47071 47072 47073 47074 47075 47076 47077 47078 47079 47080 47081 47082 47083 47084 47085 47086 47087 47088 47089 47090 47091 47092 47093 47094 47095 47096 47097 47098 47099 47100 47101 47102 47103 47104 47105 47106 47107 47108 47109 47110 47111 47112 47113 47114 47115 47116 47117 47118 47119 47120 47121 47122 47123 47124 47125 47126 47127 47128 47129 47130 47131 47132 47133 47134 47135 47136 47137 47138 47139 47140 47141 47142 47143 47144 47145 47146 47147 47148 47149 47150 47151 47152 47153 47154 47155 47156 47157 47158 47159 47160 47161 47162 47163 47164 47165 47166 47167 47168 47169 47170 47171 47172 47173 47174 47175 47176 47177 47178 47179 47180 47181 47182 47183 47184 47185 47186 47187 47188 47189 47190 47191 47192 47193 47194 47195 47196 47197 47198 47199 47200 47201 47202 47203 47204 47205 47206 47207 47208 47209 47210 47211 47212 47213 47214 47215 47216 47217 47218 47219 47220 47221 47222 47223 47224 47225 47226 47227 47228 47229 47230 47231 47232 47233 47234 47235 47236 47237 47238 47239 47240 47241 47242 47243 47244 47245 47246 47247 47248 47249 47250 47251 47252 47253 47254 47255 47256 47257 47258 47259 47260 47261 47262 47263 47264 47265 47266 47267 47268 47269 47270 47271 47272 47273 47274 47275 47276 47277 47278 47279 47280 47281 47282 47283 47284 47285 47286 47287 47288 47289 47290 47291 47292 47293 47294 47295 47296 47297 47298 47299 47300 47301 47302 47303 47304 47305 47306 47307 47308 47309 47310 47311 47312 47313 47314 47315 47316 47317 47318 47319 47320 47321 47322 47323 47324 47325 47326 47327 47328 47329 47330 47331 47332 47333 47334 47335 47336 47337 47338 47339 47340 47341 47342 47343 47344 47345 47346 47347 47348 47349 47350 47351 47352 47353 47354 47355 47356 47357 47358 47359 47360 47361 47362 47363 47364 47365 47366 47367 47368 47369 47370 47371 47372 47373 47374 47375 47376 47377 47378 47379 47380 47381 47382 47383 47384 47385 47386 47387 47388 47389 47390 47391 47392 47393 47394 47395 47396 47397 47398 47399 47400 47401 47402 47403 47404 47405 47406 47407 47408 47409 47410 47411 47412 47413 47414 47415 47416 47417 47418 47419 47420 47421 47422 47423 47424 47425 47426 47427 47428 47429 47430 47431 47432 47433 47434 47435 47436 47437 47438 47439 47440 47441 47442 47443 47444 47445 47446 47447 47448 47449 47450 47451 47452 47453 47454 47455 47456 47457 47458 47459 47460 47461 47462 47463 47464 47465 47466 47467 47468 47469 47470 47471 47472 47473 47474 47475 47476 47477 47478 47479 47480 47481 47482 47483 47484 47485 47486 47487 47488 47489 47490 47491 47492 47493 47494 47495 47496 47497 47498 47499 47500 47501 47502 47503 47504 47505 47506 47507 47508 47509 47510 47511 47512 47513 47514 47515 47516 47517 47518 47519 47520 47521 47522 47523 47524 47525 47526 47527 47528 47529 47530 47531 47532 47533 47534 47535 47536 47537 47538 47539 47540 47541 47542 47543 47544 47545 47546 47547 47548 47549 47550 47551 47552 47553 47554 47555 47556 47557 47558 47559 47560 47561 47562 47563 47564 47565 47566 47567 47568 47569 47570 47571 47572 47573 47574 47575 47576 47577 47578 47579 47580 47581 47582 47583 47584 47585 47586 47587 47588 47589 47590 47591 47592 47593 47594 47595 47596 47597 47598 47599 47600 47601 47602 47603 47604 47605 47606 47607 47608 47609 47610 47611 47612 47613 47614 47615 47616 47617 47618 47619 47620 47621 47622 47623 47624 47625 47626 47627 47628 47629 47630 47631 47632 47633 47634 47635 47636 47637 47638 47639 47640 47641 47642 47643 47644 47645 47646 47647 47648 47649 47650 47651 47652 47653 47654 47655 47656 47657 47658 47659 47660 47661 47662 47663 47664 47665 47666 47667 47668 47669 47670 47671 47672 47673 47674 47675 47676 47677 47678 47679 47680 47681 47682 47683 47684 47685 47686 47687 47688 47689 47690 47691 47692 47693 47694 47695 47696 47697 47698 47699 47700 47701 47702 47703 47704 47705 47706 47707 47708 47709 47710 47711 47712 47713 47714 47715 47716 47717 47718 47719 47720 47721 47722 47723 47724 47725 47726 47727 47728 47729 47730 47731 47732 47733 47734 47735 47736 47737 47738 47739 47740 47741 47742 47743 47744 47745 47746 47747 47748 47749 47750 47751 47752 47753 47754 47755 47756 47757 47758 47759 47760 47761 47762 47763 47764 47765 47766 47767 47768 47769 47770 47771 47772 47773 47774 47775 47776 47777 47778 47779 47780 47781 47782 47783 47784 47785 47786 47787 47788 47789 47790 47791 47792 47793 47794 47795 47796 47797 47798 47799 47800 47801 47802 47803 47804 47805 47806 47807 47808 47809 47810 47811 47812 47813 47814 47815 47816 47817 47818 47819 47820 47821 47822 47823 47824 47825 47826 47827 47828 47829 47830 47831 47832 47833 47834 47835 47836 47837 47838 47839 47840 47841 47842 47843 47844 47845 47846 47847 47848 47849 47850 47851 47852 47853 47854 47855 47856 47857 47858 47859 47860 47861 47862 47863 47864 47865 47866 47867 47868 47869 47870 47871 47872 47873 47874 47875 47876 47877 47878 47879 47880 47881 47882 47883 47884 47885 47886 47887 47888 47889 47890 47891 47892 47893 47894 47895 47896 47897 47898 47899 47900 47901 47902 47903 47904 47905 47906 47907 47908 47909 47910 47911 47912 47913 47914 47915 47916 47917 47918 47919 47920 47921 47922 47923 47924 47925 47926 47927 47928 47929 47930 47931 47932 47933 47934 47935 47936 47937 47938 47939 47940 47941 47942 47943 47944 47945 47946 47947 47948 47949 47950 47951 47952 47953 47954 47955 47956 47957 47958 47959 47960 47961 47962 47963 47964 47965 47966 47967 47968 47969 47970 47971 47972 47973 47974 47975 47976 47977 47978 47979 47980 47981 47982 47983 47984 47985 47986 47987 47988 47989 47990 47991 47992 47993 47994 47995 47996 47997 47998 47999 48000 48001 48002 48003 48004 48005 48006 48007 48008 48009 48010 48011 48012 48013 48014 48015 48016 48017 48018 48019 48020 48021 48022 48023 48024 48025 48026 48027 48028 48029 48030 48031 48032 48033 48034 48035 48036 48037 48038 48039 48040 48041 48042 48043 48044 48045 48046 48047 48048 48049 48050 48051 48052 48053 48054 48055 48056 48057 48058 48059 48060 48061 48062 48063 48064 48065 48066 48067 48068 48069 48070 48071 48072 48073 48074 48075 48076 48077 48078 48079 48080 48081 48082 48083 48084 48085 48086 48087 48088 48089 48090 48091 48092 48093 48094 48095 48096 48097 48098 48099 48100 48101 48102 48103 48104 48105 48106 48107 48108 48109 48110 48111 48112 48113 48114 48115 48116 48117 48118 48119 48120 48121 48122 48123 48124 48125 48126 48127 48128 48129 48130 48131 48132 48133 48134 48135 48136 48137 48138 48139 48140 48141 48142 48143 48144 48145 48146 48147 48148 48149 48150 48151 48152 48153 48154 48155 48156 48157 48158 48159 48160 48161 48162 48163 48164 48165 48166 48167 48168 48169 48170 48171 48172 48173 48174 48175 48176 48177 48178 48179 48180 48181 48182 48183 48184 48185 48186 48187 48188 48189 48190 48191 48192 48193 48194 48195 48196 48197 48198 48199 48200 48201 48202 48203 48204 48205 48206 48207 48208 48209 48210 48211 48212 48213 48214 48215 48216 48217 48218 48219 48220 48221 48222 48223 48224 48225 48226 48227 48228 48229 48230 48231 48232 48233 48234 48235 48236 48237 48238 48239 48240 48241 48242 48243 48244 48245 48246 48247 48248 48249 48250 48251 48252 48253 48254 48255 48256 48257 48258 48259 48260 48261 48262 48263 48264 48265 48266 48267 48268 48269 48270 48271 48272 48273 48274 48275 48276 48277 48278 48279 48280 48281 48282 48283 48284 48285 48286 48287 48288 48289 48290 48291 48292 48293 48294 48295 48296 48297 48298 48299 48300 48301 48302 48303 48304 48305 48306 48307 48308 48309 48310 48311 48312 48313 48314 48315 48316 48317 48318 48319 48320 48321 48322 48323 48324 48325 48326 48327 48328 48329 48330 48331 48332 48333 48334 48335 48336 48337 48338 48339 48340 48341 48342 48343 48344 48345 48346 48347 48348 48349 48350 48351 48352 48353 48354 48355 48356 48357 48358 48359 48360 48361 48362 48363 48364 48365 48366 48367 48368 48369 48370 48371 48372 48373 48374 48375 48376 48377 48378 48379 48380 48381 48382 48383 48384 48385 48386 48387 48388 48389 48390 48391 48392 48393 48394 48395 48396 48397 48398 48399 48400 48401 48402 48403 48404 48405 48406 48407 48408 48409 48410 48411 48412 48413 48414 48415 48416 48417 48418 48419 48420 48421 48422 48423 48424 48425 48426 48427 48428 48429 48430 48431 48432 48433 48434 48435 48436 48437 48438 48439 48440 48441 48442 48443 48444 48445 48446 48447 48448 48449 48450 48451 48452 48453 48454 48455 48456 48457 48458 48459 48460 48461 48462 48463 48464 48465 48466 48467 48468 48469 48470 48471 48472 48473 48474 48475 48476 48477 48478 48479 48480 48481 48482 48483 48484 48485 48486 48487 48488 48489 48490 48491 48492 48493 48494 48495 48496 48497 48498 48499 48500 48501 48502 48503 48504 48505 48506 48507 48508 48509 48510 48511 48512 48513 48514 48515 48516 48517 48518 48519 48520 48521 48522 48523 48524 48525 48526 48527 48528 48529 48530 48531 48532 48533 48534 48535 48536 48537 48538 48539 48540 48541 48542 48543 48544 48545 48546 48547 48548 48549 48550 48551 48552 48553 48554 48555 48556 48557 48558 48559 48560 48561 48562 48563 48564 48565 48566 48567 48568 48569 48570 48571 48572 48573 48574 48575 48576 48577 48578 48579 48580 48581 48582 48583 48584 48585 48586 48587 48588 48589 48590 48591 48592 48593 48594 48595 48596 48597 48598 48599 48600 48601 48602 48603 48604 48605 48606 48607 48608 48609 48610 48611 48612 48613 48614 48615 48616 48617 48618 48619 48620 48621 48622 48623 48624 48625 48626 48627 48628 48629 48630 48631 48632 48633 48634 48635 48636 48637 48638 48639 48640 48641 48642 48643 48644 48645 48646 48647 48648 48649 48650 48651 48652 48653 48654 48655 48656 48657 48658 48659 48660 48661 48662 48663 48664 48665 48666 48667 48668 48669 48670 48671 48672 48673 48674 48675 48676 48677 48678 48679 48680 48681 48682 48683 48684 48685 48686 48687 48688 48689 48690 48691 48692 48693 48694 48695 48696 48697 48698 48699 48700 48701 48702 48703 48704 48705 48706 48707 48708 48709 48710 48711 48712 48713 48714 48715 48716 48717 48718 48719 48720 48721 48722 48723 48724 48725 48726 48727 48728 48729 48730 48731 48732 48733 48734 48735 48736 48737 48738 48739 48740 48741 48742 48743 48744 48745 48746 48747 48748 48749 48750 48751 48752 48753 48754 48755 48756 48757 48758 48759 48760 48761 48762 48763 48764 48765 48766 48767 48768 48769 48770 48771 48772 48773 48774 48775 48776 48777 48778 48779 48780 48781 48782 48783 48784 48785 48786 48787 48788 48789 48790 48791 48792 48793 48794 48795 48796 48797 48798 48799 48800 48801 48802 48803 48804 48805 48806 48807 48808 48809 48810 48811 48812 48813 48814 48815 48816 48817 48818 48819 48820 48821 48822 48823 48824 48825 48826 48827 48828 48829 48830 48831 48832 48833 48834 48835 48836 48837 48838 48839 48840 48841 48842 48843 48844 48845 48846 48847 48848 48849 48850 48851 48852 48853 48854 48855 48856 48857 48858 48859 48860 48861 48862 48863 48864 48865 48866 48867 48868 48869 48870 48871 48872 48873 48874 48875 48876 48877 48878 48879 48880 48881 48882 48883 48884 48885 48886 48887 48888 48889 48890 48891 48892 48893 48894 48895 48896 48897 48898 48899 48900 48901 48902 48903 48904 48905 48906 48907 48908 48909 48910 48911 48912 48913 48914 48915 48916 48917 48918 48919 48920 48921 48922 48923 48924 48925 48926 48927 48928 48929 48930 48931 48932 48933 48934 48935 48936 48937 48938 48939 48940 48941 48942 48943 48944 48945 48946 48947 48948 48949 48950 48951 48952 48953 48954 48955 48956 48957 48958 48959 48960 48961 48962 48963 48964 48965 48966 48967 48968 48969 48970 48971 48972 48973 48974 48975 48976 48977 48978 48979 48980 48981 48982 48983 48984 48985 48986 48987 48988 48989 48990 48991 48992 48993 48994 48995 48996 48997 48998 48999 49000 49001 49002 49003 49004 49005 49006 49007 49008 49009 49010 49011 49012 49013 49014 49015 49016 49017 49018 49019 49020 49021 49022 49023 49024 49025 49026 49027 49028 49029 49030 49031 49032 49033 49034 49035 49036 49037 49038 49039 49040 49041 49042 49043 49044 49045 49046 49047 49048 49049 49050 49051 49052 49053 49054 49055 49056 49057 49058 49059 49060 49061 49062 49063 49064 49065 49066 49067 49068 49069 49070 49071 49072 49073 49074 49075 49076 49077 49078 49079 49080 49081 49082 49083 49084 49085 49086 49087 49088 49089 49090 49091 49092 49093 49094 49095 49096 49097 49098 49099 49100 49101 49102 49103 49104 49105 49106 49107 49108 49109 49110 49111 49112 49113 49114 49115 49116 49117 49118 49119 49120 49121 49122 49123 49124 49125 49126 49127 49128 49129 49130 49131 49132 49133 49134 49135 49136 49137 49138 49139 49140 49141 49142 49143 49144 49145 49146 49147 49148 49149 49150 49151 49152 49153 49154 49155 49156 49157 49158 49159 49160 49161 49162 49163 49164 49165 49166 49167 49168 49169 49170 49171 49172 49173 49174 49175 49176 49177 49178 49179 49180 49181 49182 49183 49184 49185 49186 49187 49188 49189 49190 49191 49192 49193 49194 49195 49196 49197 49198 49199 49200 49201 49202 49203 49204 49205 49206 49207 49208 49209 49210 49211 49212 49213 49214 49215 49216 49217 49218 49219 49220 49221 49222 49223 49224 49225 49226 49227 49228 49229 49230 49231 49232 49233 49234 49235 49236 49237 49238 49239 49240 49241 49242 49243 49244 49245 49246 49247 49248 49249 49250 49251 49252 49253 49254 49255 49256 49257 49258 49259 49260 49261 49262 49263 49264 49265 49266 49267 49268 49269 49270 49271 49272 49273 49274 49275 49276 49277 49278 49279 49280 49281 49282 49283 49284 49285 49286 49287 49288 49289 49290 49291 49292 49293 49294 49295 49296 49297 49298 49299 49300 49301 49302 49303 49304 49305 49306 49307 49308 49309 49310 49311 49312 49313 49314 49315 49316 49317 49318 49319 49320 49321 49322 49323 49324 49325 49326 49327 49328 49329 49330 49331 49332 49333 49334 49335 49336 49337 49338 49339 49340 49341 49342 49343 49344 49345 49346 49347 49348 49349 49350 49351 49352 49353 49354 49355 49356 49357 49358 49359 49360 49361 49362 49363 49364 49365 49366 49367 49368 49369 49370 49371 49372 49373 49374 49375 49376 49377 49378 49379 49380 49381 49382 49383 49384 49385 49386 49387 49388 49389 49390 49391 49392 49393 49394 49395 49396 49397 49398 49399 49400 49401 49402 49403 49404 49405 49406 49407 49408 49409 49410 49411 49412 49413 49414 49415 49416 49417 49418 49419 49420 49421 49422 49423 49424 49425 49426 49427 49428 49429 49430 49431 49432 49433 49434 49435 49436 49437 49438 49439 49440 49441 49442 49443 49444 49445 49446 49447 49448 49449 49450 49451 49452 49453 49454 49455 49456 49457 49458 49459 49460 49461 49462 49463 49464 49465 49466 49467 49468 49469 49470 49471 49472 49473 49474 49475 49476 49477 49478 49479 49480 49481 49482 49483 49484 49485 49486 49487 49488 49489 49490 49491 49492 49493 49494 49495 49496 49497 49498 49499 49500 49501 49502 49503 49504 49505 49506 49507 49508 49509 49510 49511 49512 49513 49514 49515 49516 49517 49518 49519 49520 49521 49522 49523 49524 49525 49526 49527 49528 49529 49530 49531 49532 49533 49534 49535 49536 49537 49538 49539 49540 49541 49542 49543 49544 49545 49546 49547 49548 49549 49550 49551 49552 49553 49554 49555 49556 49557 49558 49559 49560 49561 49562 49563 49564 49565 49566 49567 49568 49569 49570 49571 49572 49573 49574 49575 49576 49577 49578 49579 49580 49581 49582 49583 49584 49585 49586 49587 49588 49589 49590 49591 49592 49593 49594 49595 49596 49597 49598 49599 49600 49601 49602 49603 49604 49605 49606 49607 49608 49609 49610 49611 49612 49613 49614 49615 49616 49617 49618 49619 49620 49621 49622 49623 49624 49625 49626 49627 49628 49629 49630 49631 49632 49633 49634 49635 49636 49637 49638 49639 49640 49641 49642 49643 49644 49645 49646 49647 49648 49649 49650 49651 49652 49653 49654 49655 49656 49657 49658 49659 49660 49661 49662 49663 49664 49665 49666 49667 49668 49669 49670 49671 49672 49673 49674 49675 49676 49677 49678 49679 49680 49681 49682 49683 49684 49685 49686 49687 49688 49689 49690 49691 49692 49693 49694 49695 49696 49697 49698 49699 49700 49701 49702 49703 49704 49705 49706 49707 49708 49709 49710 49711 49712 49713 49714 49715 49716 49717 49718 49719 49720 49721 49722 49723 49724 49725 49726 49727 49728 49729 49730 49731 49732 49733 49734 49735 49736 49737 49738 49739 49740 49741 49742 49743 49744 49745 49746 49747 49748 49749 49750 49751 49752 49753 49754 49755 49756 49757 49758 49759 49760 49761 49762 49763 49764 49765 49766 49767 49768 49769 49770 49771 49772 49773 49774 49775 49776 49777 49778 49779 49780 49781 49782 49783 49784 49785 49786 49787 49788 49789 49790 49791 49792 49793 49794 49795 49796 49797 49798 49799 49800 49801 49802 49803 49804 49805 49806 49807 49808 49809 49810 49811 49812 49813 49814 49815 49816 49817 49818 49819 49820 49821 49822 49823 49824 49825 49826 49827 49828 49829 49830 49831 49832 49833 49834 49835 49836 49837 49838 49839 49840 49841 49842 49843 49844 49845 49846 49847 49848 49849 49850 49851 49852 49853 49854 49855 49856 49857 49858 49859 49860 49861 49862 49863 49864 49865 49866 49867 49868 49869 49870 49871 49872 49873 49874 49875 49876 49877 49878 49879 49880 49881 49882 49883 49884 49885 49886 49887 49888 49889 49890 49891 49892 49893 49894 49895 49896 49897 49898 49899 49900 49901 49902 49903 49904 49905 49906 49907 49908 49909 49910 49911 49912 49913 49914 49915 49916 49917 49918 49919 49920 49921 49922 49923 49924 49925 49926 49927 49928 49929 49930 49931 49932 49933 49934 49935 49936 49937 49938 49939 49940 49941 49942 49943 49944 49945 49946 49947 49948 49949 49950 49951 49952 49953 49954 49955 49956 49957 49958 49959 49960 49961 49962 49963 49964 49965 49966 49967 49968 49969 49970 49971 49972 49973 49974 49975 49976 49977 49978 49979 49980 49981 49982 49983 49984 49985 49986 49987 49988 49989 49990 49991 49992 49993 49994 49995 49996 49997 49998 49999 50000 50001 50002 50003 50004 50005 50006 50007 50008 50009 50010 50011 50012 50013 50014 50015 50016 50017 50018 50019 50020 50021 50022 50023 50024 50025 50026 50027 50028 50029 50030 50031 50032 50033 50034 50035 50036 50037 50038 50039 50040 50041 50042 50043 50044 50045 50046 50047 50048 50049 50050 50051 50052 50053 50054 50055 50056 50057 50058 50059 50060 50061 50062 50063 50064 50065 50066 50067 50068 50069 50070 50071 50072 50073 50074 50075 50076 50077 50078 50079 50080 50081 50082 50083 50084 50085 50086 50087 50088 50089 50090 50091 50092 50093 50094 50095 50096 50097 50098 50099 50100 50101 50102 50103 50104 50105 50106 50107 50108 50109 50110 50111 50112 50113 50114 50115 50116 50117 50118 50119 50120 50121 50122 50123 50124 50125 50126 50127 50128 50129 50130 50131 50132 50133 50134 50135 50136 50137 50138 50139 50140 50141 50142 50143 50144 50145 50146 50147 50148 50149 50150 50151 50152 50153 50154 50155 50156 50157 50158 50159 50160 50161 50162 50163 50164 50165 50166 50167 50168 50169 50170 50171 50172 50173 50174 50175 50176 50177 50178 50179 50180 50181 50182 50183 50184 50185 50186 50187 50188 50189 50190 50191 50192 50193 50194 50195 50196 50197 50198 50199 50200 50201 50202 50203 50204 50205 50206 50207 50208 50209 50210 50211 50212 50213 50214 50215 50216 50217 50218 50219 50220 50221 50222 50223 50224 50225 50226 50227 50228 50229 50230 50231 50232 50233 50234 50235 50236 50237 50238 50239 50240 50241 50242 50243 50244 50245 50246 50247 50248 50249 50250 50251 50252 50253 50254 50255 50256 50257 50258 50259 50260 50261 50262 50263 50264 50265 50266 50267 50268 50269 50270 50271 50272 50273 50274 50275 50276 50277 50278 50279 50280 50281 50282 50283 50284 50285 50286 50287 50288 50289 50290 50291 50292 50293 50294 50295 50296 50297 50298 50299 50300 50301 50302 50303 50304 50305 50306 50307 50308 50309 50310 50311 50312 50313 50314 50315 50316 50317 50318 50319 50320 50321 50322 50323 50324 50325 50326 50327 50328 50329 50330 50331 50332 50333 50334 50335 50336 50337 50338 50339 50340 50341 50342 50343 50344 50345 50346 50347 50348 50349 50350 50351 50352 50353 50354 50355 50356 50357 50358 50359 50360 50361 50362 50363 50364 50365 50366 50367 50368 50369 50370 50371 50372 50373 50374 50375 50376 50377 50378 50379 50380 50381 50382 50383 50384 50385 50386 50387 50388 50389 50390 50391 50392 50393 50394 50395 50396 50397 50398 50399 50400 50401 50402 50403 50404 50405 50406 50407 50408 50409 50410 50411 50412 50413 50414 50415 50416 50417 50418 50419 50420 50421 50422 50423 50424 50425 50426 50427 50428 50429 50430 50431 50432 50433 50434 50435 50436 50437 50438 50439 50440 50441 50442 50443 50444 50445 50446 50447 50448 50449 50450 50451 50452 50453 50454 50455 50456 50457 50458 50459 50460 50461 50462 50463 50464 50465 50466 50467 50468 50469 50470 50471 50472 50473 50474 50475 50476 50477 50478 50479 50480 50481 50482 50483 50484 50485 50486 50487 50488 50489 50490 50491 50492 50493 50494 50495 50496 50497 50498 50499 50500 50501 50502 50503 50504 50505 50506 50507 50508 50509 50510 50511 50512 50513 50514 50515 50516 50517 50518 50519 50520 50521 50522 50523 50524 50525 50526 50527 50528 50529 50530 50531 50532 50533 50534 50535 50536 50537 50538 50539 50540 50541 50542 50543 50544 50545 50546 50547 50548 50549 50550 50551 50552 50553 50554 50555 50556 50557 50558 50559 50560 50561 50562 50563 50564 50565 50566 50567 50568 50569 50570 50571 50572 50573 50574 50575 50576 50577 50578 50579 50580 50581 50582 50583 50584 50585 50586 50587 50588 50589 50590 50591 50592 50593 50594 50595 50596 50597 50598 50599 50600 50601 50602 50603 50604 50605 50606 50607 50608 50609 50610 50611 50612 50613 50614 50615 50616 50617 50618 50619 50620 50621 50622 50623 50624 50625 50626 50627 50628 50629 50630 50631 50632 50633 50634 50635 50636 50637 50638 50639 50640 50641 50642 50643 50644 50645 50646 50647 50648 50649 50650 50651 50652 50653 50654 50655 50656 50657 50658 50659 50660 50661 50662 50663 50664 50665 50666 50667 50668 50669 50670 50671 50672 50673 50674 50675 50676 50677 50678 50679 50680 50681 50682 50683 50684 50685 50686 50687 50688 50689 50690 50691 50692 50693 50694 50695 50696 50697 50698 50699 50700 50701 50702 50703 50704 50705 50706 50707 50708 50709 50710 50711 50712 50713 50714 50715 50716 50717 50718 50719 50720 50721 50722 50723 50724 50725 50726 50727 50728 50729 50730 50731 50732 50733 50734 50735 50736 50737 50738 50739 50740 50741 50742 50743 50744 50745 50746 50747 50748 50749 50750 50751 50752 50753 50754 50755 50756 50757 50758 50759 50760 50761 50762 50763 50764 50765 50766 50767 50768 50769 50770 50771 50772 50773 50774 50775 50776 50777 50778 50779 50780 50781 50782 50783 50784 50785 50786 50787 50788 50789 50790 50791 50792 50793 50794 50795 50796 50797 50798 50799 50800 50801 50802 50803 50804 50805 50806 50807 50808 50809 50810 50811 50812 50813 50814 50815 50816 50817 50818 50819 50820 50821 50822 50823 50824 50825 50826 50827 50828 50829 50830 50831 50832 50833 50834 50835 50836 50837 50838 50839 50840 50841 50842 50843 50844 50845 50846 50847 50848 50849 50850 50851 50852 50853 50854 50855 50856 50857 50858 50859 50860 50861 50862 50863 50864 50865 50866 50867 50868 50869 50870 50871 50872 50873 50874 50875 50876 50877 50878 50879 50880 50881 50882 50883 50884 50885 50886 50887 50888 50889 50890 50891 50892 50893 50894 50895 50896 50897 50898 50899 50900 50901 50902 50903 50904 50905 50906 50907 50908 50909 50910 50911 50912 50913 50914 50915 50916 50917 50918 50919 50920 50921 50922 50923 50924 50925 50926 50927 50928 50929 50930 50931 50932 50933 50934 50935 50936 50937 50938 50939 50940 50941 50942 50943 50944 50945 50946 50947 50948 50949 50950 50951 50952 50953 50954 50955 50956 50957 50958 50959 50960 50961 50962 50963 50964 50965 50966 50967 50968 50969 50970 50971 50972 50973 50974 50975 50976 50977 50978 50979 50980 50981 50982 50983 50984 50985 50986 50987 50988 50989 50990 50991 50992 50993 50994 50995 50996 50997 50998 50999 51000 51001 51002 51003 51004 51005 51006 51007 51008 51009 51010 51011 51012 51013 51014 51015 51016 51017 51018 51019 51020 51021 51022 51023 51024 51025 51026 51027 51028 51029 51030 51031 51032 51033 51034 51035 51036 51037 51038 51039 51040 51041 51042 51043 51044 51045 51046 51047 51048 51049 51050 51051 51052 51053 51054 51055 51056 51057 51058 51059 51060 51061 51062 51063 51064 51065 51066 51067 51068 51069 51070 51071 51072 51073 51074 51075 51076 51077 51078 51079 51080 51081 51082 51083 51084 51085 51086 51087 51088 51089 51090 51091 51092 51093 51094 51095 51096 51097 51098 51099 51100 51101 51102 51103 51104 51105 51106 51107 51108 51109 51110 51111 51112 51113 51114 51115 51116 51117 51118 51119 51120 51121 51122 51123 51124 51125 51126 51127 51128 51129 51130 51131 51132 51133 51134 51135 51136 51137 51138 51139 51140 51141 51142 51143 51144 51145 51146 51147 51148 51149 51150 51151 51152 51153 51154 51155 51156 51157 51158 51159 51160 51161 51162 51163 51164 51165 51166 51167 51168 51169 51170 51171 51172 51173 51174 51175 51176 51177 51178 51179 51180 51181 51182 51183 51184 51185 51186 51187 51188 51189 51190 51191 51192 51193 51194 51195 51196 51197 51198 51199 51200 51201 51202 51203 51204 51205 51206 51207 51208 51209 51210 51211 51212 51213 51214 51215 51216 51217 51218 51219 51220 51221 51222 51223 51224 51225 51226 51227 51228 51229 51230 51231 51232 51233 51234 51235 51236 51237 51238 51239 51240 51241 51242 51243 51244 51245 51246 51247 51248 51249 51250 51251 51252 51253 51254 51255 51256 51257 51258 51259 51260 51261 51262 51263 51264 51265 51266 51267 51268 51269 51270 51271 51272 51273 51274 51275 51276 51277 51278 51279 51280 51281 51282 51283 51284 51285 51286 51287 51288 51289 51290 51291 51292 51293 51294 51295 51296 51297 51298 51299 51300 51301 51302 51303 51304 51305 51306 51307 51308 51309 51310 51311 51312 51313 51314 51315 51316 51317 51318 51319 51320 51321 51322 51323 51324 51325 51326 51327 51328 51329 51330 51331 51332 51333 51334 51335 51336 51337 51338 51339 51340 51341 51342 51343 51344 51345 51346 51347 51348 51349 51350 51351 51352 51353 51354 51355 51356 51357 51358 51359 51360 51361 51362 51363 51364 51365 51366 51367 51368 51369 51370 51371 51372 51373 51374 51375 51376 51377 51378 51379 51380 51381 51382 51383 51384 51385 51386 51387 51388 51389 51390 51391 51392 51393 51394 51395 51396 51397 51398 51399 51400 51401 51402 51403 51404 51405 51406 51407 51408 51409 51410 51411 51412 51413 51414 51415 51416 51417 51418 51419 51420 51421 51422 51423 51424 51425 51426 51427 51428 51429 51430 51431 51432 51433 51434 51435 51436 51437 51438 51439 51440 51441 51442 51443 51444 51445 51446 51447 51448 51449 51450 51451 51452 51453 51454 51455 51456 51457 51458 51459 51460 51461 51462 51463 51464 51465 51466 51467 51468 51469 51470 51471 51472 51473 51474 51475 51476 51477 51478 51479 51480 51481 51482 51483 51484 51485 51486 51487 51488 51489 51490 51491 51492 51493 51494 51495 51496 51497 51498 51499 51500 51501 51502 51503 51504 51505 51506 51507 51508 51509 51510 51511 51512 51513 51514 51515 51516 51517 51518 51519 51520 51521 51522 51523 51524 51525 51526 51527 51528 51529 51530 51531 51532 51533 51534 51535 51536 51537 51538 51539 51540 51541 51542 51543 51544 51545 51546 51547 51548 51549 51550 51551 51552 51553 51554 51555 51556 51557 51558 51559 51560 51561 51562 51563 51564 51565 51566 51567 51568 51569 51570 51571 51572 51573 51574 51575 51576 51577 51578 51579 51580 51581 51582 51583 51584 51585 51586 51587 51588 51589 51590 51591 51592 51593 51594 51595 51596 51597 51598 51599 51600 51601 51602 51603 51604 51605 51606 51607 51608 51609 51610 51611 51612 51613 51614 51615 51616 51617 51618 51619 51620 51621 51622 51623 51624 51625 51626 51627 51628 51629 51630 51631 51632 51633 51634 51635 51636 51637 51638 51639 51640 51641 51642 51643 51644 51645 51646 51647 51648 51649 51650 51651 51652 51653 51654 51655 51656 51657 51658 51659 51660 51661 51662 51663 51664 51665 51666 51667 51668 51669 51670 51671 51672 51673 51674 51675 51676 51677 51678 51679 51680 51681 51682 51683 51684 51685 51686 51687 51688 51689 51690 51691 51692 51693 51694 51695 51696 51697 51698 51699 51700 51701 51702 51703 51704 51705 51706 51707 51708 51709 51710 51711 51712 51713 51714 51715 51716 51717 51718 51719 51720 51721 51722 51723 51724 51725 51726 51727 51728 51729 51730 51731 51732 51733 51734 51735 51736 51737 51738 51739 51740 51741 51742 51743 51744 51745 51746 51747 51748 51749 51750 51751 51752 51753 51754 51755 51756 51757 51758 51759 51760 51761 51762 51763 51764 51765 51766 51767 51768 51769 51770 51771 51772 51773 51774 51775 51776 51777 51778 51779 51780 51781 51782 51783 51784 51785 51786 51787 51788 51789 51790 51791 51792 51793 51794 51795 51796 51797 51798 51799 51800 51801 51802 51803 51804 51805 51806 51807 51808 51809 51810 51811 51812 51813 51814 51815 51816 51817 51818 51819 51820 51821 51822 51823 51824 51825 51826 51827 51828 51829 51830 51831 51832 51833 51834 51835 51836 51837 51838 51839 51840 51841 51842 51843 51844 51845 51846 51847 51848 51849 51850 51851 51852 51853 51854 51855 51856 51857 51858 51859 51860 51861 51862 51863 51864 51865 51866 51867 51868 51869 51870 51871 51872 51873 51874 51875 51876 51877 51878 51879 51880 51881 51882 51883 51884 51885 51886 51887 51888 51889 51890 51891 51892 51893 51894 51895 51896 51897 51898 51899 51900 51901 51902 51903 51904 51905 51906 51907 51908 51909 51910 51911 51912 51913 51914 51915 51916 51917 51918 51919 51920 51921 51922 51923 51924 51925 51926 51927 51928 51929 51930 51931 51932 51933 51934 51935 51936 51937 51938 51939 51940 51941 51942 51943 51944 51945 51946 51947 51948 51949 51950 51951 51952 51953 51954 51955 51956 51957 51958 51959 51960 51961 51962 51963 51964 51965 51966 51967 51968 51969 51970 51971 51972 51973 51974 51975 51976 51977 51978 51979 51980 51981 51982 51983 51984 51985 51986 51987 51988 51989 51990 51991 51992 51993 51994 51995 51996 51997 51998 51999 52000 52001 52002 52003 52004 52005 52006 52007 52008 52009 52010 52011 52012 52013 52014 52015 52016 52017 52018 52019 52020 52021 52022 52023 52024 52025 52026 52027 52028 52029 52030 52031 52032 52033 52034 52035 52036 52037 52038 52039 52040 52041 52042 52043 52044 52045 52046 52047 52048 52049 52050 52051 52052 52053 52054 52055 52056 52057 52058 52059 52060 52061 52062 52063 52064 52065 52066 52067 52068 52069 52070 52071 52072 52073 52074 52075 52076 52077 52078 52079 52080 52081 52082 52083 52084 52085 52086 52087 52088 52089 52090 52091 52092 52093 52094 52095 52096 52097 52098 52099 52100 52101 52102 52103 52104 52105 52106 52107 52108 52109 52110 52111 52112 52113 52114 52115 52116 52117 52118 52119 52120 52121 52122 52123 52124 52125 52126 52127 52128 52129 52130 52131 52132 52133 52134 52135 52136 52137 52138 52139 52140 52141 52142 52143 52144 52145 52146 52147 52148 52149 52150 52151 52152 52153 52154 52155 52156 52157 52158 52159 52160 52161 52162 52163 52164 52165 52166 52167 52168 52169 52170 52171 52172 52173 52174 52175 52176 52177 52178 52179 52180 52181 52182 52183 52184 52185 52186 52187 52188 52189 52190 52191 52192 52193 52194 52195 52196 52197 52198 52199 52200 52201 52202 52203 52204 52205 52206 52207 52208 52209 52210 52211 52212 52213 52214 52215 52216 52217 52218 52219 52220 52221 52222 52223 52224 52225 52226 52227 52228 52229 52230 52231 52232 52233 52234 52235 52236 52237 52238 52239 52240 52241 52242 52243 52244 52245 52246 52247 52248 52249 52250 52251 52252 52253 52254 52255 52256 52257 52258 52259 52260 52261 52262 52263 52264 52265 52266 52267 52268 52269 52270 52271 52272 52273 52274 52275 52276 52277 52278 52279 52280 52281 52282 52283 52284 52285 52286 52287 52288 52289 52290 52291 52292 52293 52294 52295 52296 52297 52298 52299 52300 52301 52302 52303 52304 52305 52306 52307 52308 52309 52310 52311 52312 52313 52314 52315 52316 52317 52318 52319 52320 52321 52322 52323 52324 52325 52326 52327 52328 52329 52330 52331 52332 52333 52334 52335 52336 52337 52338 52339 52340 52341 52342 52343 52344 52345 52346 52347 52348 52349 52350 52351 52352 52353 52354 52355 52356 52357 52358 52359 52360 52361 52362 52363 52364 52365 52366 52367 52368 52369 52370 52371 52372 52373 52374 52375 52376 52377 52378 52379 52380 52381 52382 52383 52384 52385 52386 52387 52388 52389 52390 52391 52392 52393 52394 52395 52396 52397 52398 52399 52400 52401 52402 52403 52404 52405 52406 52407 52408 52409 52410 52411 52412 52413 52414 52415 52416 52417 52418 52419 52420 52421 52422 52423 52424 52425 52426 52427 52428 52429 52430 52431 52432 52433 52434 52435 52436 52437 52438 52439 52440 52441 52442 52443 52444 52445 52446 52447 52448 52449 52450 52451 52452 52453 52454 52455 52456 52457 52458 52459 52460 52461 52462 52463 52464 52465 52466 52467 52468 52469 52470 52471 52472 52473 52474 52475 52476 52477 52478 52479 52480 52481 52482 52483 52484 52485 52486 52487 52488 52489 52490 52491 52492 52493 52494 52495 52496 52497 52498 52499 52500 52501 52502 52503 52504 52505 52506 52507 52508 52509 52510 52511 52512 52513 52514 52515 52516 52517 52518 52519 52520 52521 52522 52523 52524 52525 52526 52527 52528 52529 52530 52531 52532 52533 52534 52535 52536 52537 52538 52539 52540 52541 52542 52543 52544 52545 52546 52547 52548 52549 52550 52551 52552 52553 52554 52555 52556 52557 52558 52559 52560 52561 52562 52563 52564 52565 52566 52567 52568 52569 52570 52571 52572 52573 52574 52575 52576 52577 52578 52579 52580 52581 52582 52583 52584 52585 52586 52587 52588 52589 52590 52591 52592 52593 52594 52595 52596 52597 52598 52599 52600 52601 52602 52603 52604 52605 52606 52607 52608 52609 52610 52611 52612 52613 52614 52615 52616 52617 52618 52619 52620 52621 52622 52623 52624 52625 52626 52627 52628 52629 52630 52631 52632 52633 52634 52635 52636 52637 52638 52639 52640 52641 52642 52643 52644 52645 52646 52647 52648 52649 52650 52651 52652 52653 52654 52655 52656 52657 52658 52659 52660 52661 52662 52663 52664 52665 52666 52667 52668 52669 52670 52671 52672 52673 52674 52675 52676 52677 52678 52679 52680 52681 52682 52683 52684 52685 52686 52687 52688 52689 52690 52691 52692 52693 52694 52695 52696 52697 52698 52699 52700 52701 52702 52703 52704 52705 52706 52707 52708 52709 52710 52711 52712 52713 52714 52715 52716 52717 52718 52719 52720 52721 52722 52723 52724 52725 52726 52727 52728 52729 52730 52731 52732 52733 52734 52735 52736 52737 52738 52739 52740 52741 52742 52743 52744 52745 52746 52747 52748 52749 52750 52751 52752 52753 52754 52755 52756 52757 52758 52759 52760 52761 52762 52763 52764 52765 52766 52767 52768 52769 52770 52771 52772 52773 52774 52775 52776 52777 52778 52779 52780 52781 52782 52783 52784 52785 52786 52787 52788 52789 52790 52791 52792 52793 52794 52795 52796 52797 52798 52799 52800 52801 52802 52803 52804 52805 52806 52807 52808 52809 52810 52811 52812 52813 52814 52815 52816 52817 52818 52819 52820 52821 52822 52823 52824 52825 52826 52827 52828 52829 52830 52831 52832 52833 52834 52835 52836 52837 52838 52839 52840 52841 52842 52843 52844 52845 52846 52847 52848 52849 52850 52851 52852 52853 52854 52855 52856 52857 52858 52859 52860 52861 52862 52863 52864 52865 52866 52867 52868 52869 52870 52871 52872 52873 52874 52875 52876 52877 52878 52879 52880 52881 52882 52883 52884 52885 52886 52887 52888 52889 52890 52891 52892 52893 52894 52895 52896 52897 52898 52899 52900 52901 52902 52903 52904 52905 52906 52907 52908 52909 52910 52911 52912 52913 52914 52915 52916 52917 52918 52919 52920 52921 52922 52923 52924 52925 52926 52927 52928 52929 52930 52931 52932 52933 52934 52935 52936 52937 52938 52939 52940 52941 52942 52943 52944 52945 52946 52947 52948 52949 52950 52951 52952 52953 52954 52955 52956 52957 52958 52959 52960 52961 52962 52963 52964 52965 52966 52967 52968 52969 52970 52971 52972 52973 52974 52975 52976 52977 52978 52979 52980 52981 52982 52983 52984 52985 52986 52987 52988 52989 52990 52991 52992 52993 52994 52995 52996 52997 52998 52999 53000 53001 53002 53003 53004 53005 53006 53007 53008 53009 53010 53011 53012 53013 53014 53015 53016 53017 53018 53019 53020 53021 53022 53023 53024 53025 53026 53027 53028 53029 53030 53031 53032 53033 53034 53035 53036 53037 53038 53039 53040 53041 53042 53043 53044 53045 53046 53047 53048 53049 53050 53051 53052 53053 53054 53055 53056 53057 53058 53059 53060 53061 53062 53063 53064 53065 53066 53067 53068 53069 53070 53071 53072 53073 53074 53075 53076 53077 53078 53079 53080 53081 53082 53083 53084 53085 53086 53087 53088 53089 53090 53091 53092 53093 53094 53095 53096 53097 53098 53099 53100 53101 53102 53103 53104 53105 53106 53107 53108 53109 53110 53111 53112 53113 53114 53115 53116 53117 53118 53119 53120 53121 53122 53123 53124 53125 53126 53127 53128 53129 53130 53131 53132 53133 53134 53135 53136 53137 53138 53139 53140 53141 53142 53143 53144 53145 53146 53147 53148 53149 53150 53151 53152 53153 53154 53155 53156 53157 53158 53159 53160 53161 53162 53163 53164 53165 53166 53167 53168 53169 53170 53171 53172 53173 53174 53175 53176 53177 53178 53179 53180 53181 53182 53183 53184 53185 53186 53187 53188 53189 53190 53191 53192 53193 53194 53195 53196 53197 53198 53199 53200 53201 53202 53203 53204 53205 53206 53207 53208 53209 53210 53211 53212 53213 53214 53215 53216 53217 53218 53219 53220 53221 53222 53223 53224 53225 53226 53227 53228 53229 53230 53231 53232 53233 53234 53235 53236 53237 53238 53239 53240 53241 53242 53243 53244 53245 53246 53247 53248 53249 53250 53251 53252 53253 53254 53255 53256 53257 53258 53259 53260 53261 53262 53263 53264 53265 53266 53267 53268 53269 53270 53271 53272 53273 53274 53275 53276 53277 53278 53279 53280 53281 53282 53283 53284 53285 53286 53287 53288 53289 53290 53291 53292 53293 53294 53295 53296 53297 53298 53299 53300 53301 53302 53303 53304 53305 53306 53307 53308 53309 53310 53311 53312 53313 53314 53315 53316 53317 53318 53319 53320 53321 53322 53323 53324 53325 53326 53327 53328 53329 53330 53331 53332 53333 53334 53335 53336 53337 53338 53339 53340 53341 53342 53343 53344 53345 53346 53347 53348 53349 53350 53351 53352 53353 53354 53355 53356 53357 53358 53359 53360 53361 53362 53363 53364 53365 53366 53367 53368 53369 53370 53371 53372 53373 53374 53375 53376 53377 53378 53379 53380 53381 53382 53383 53384 53385 53386 53387 53388 53389 53390 53391 53392 53393 53394 53395 53396 53397 53398 53399 53400 53401 53402 53403 53404 53405 53406 53407 53408 53409 53410 53411 53412 53413 53414 53415 53416 53417 53418 53419 53420 53421 53422 53423 53424 53425 53426 53427 53428 53429 53430 53431 53432 53433 53434 53435 53436 53437 53438 53439 53440 53441 53442 53443 53444 53445 53446 53447 53448 53449 53450 53451 53452 53453 53454 53455 53456 53457 53458 53459 53460 53461 53462 53463 53464 53465 53466 53467 53468 53469 53470 53471 53472 53473 53474 53475 53476 53477 53478 53479 53480 53481 53482 53483 53484 53485 53486 53487 53488 53489 53490 53491 53492 53493 53494 53495 53496 53497 53498 53499 53500 53501 53502 53503 53504 53505 53506 53507 53508 53509 53510 53511 53512 53513 53514 53515 53516 53517 53518 53519 53520 53521 53522 53523 53524 53525 53526 53527 53528 53529 53530 53531 53532 53533 53534 53535 53536 53537 53538 53539 53540 53541 53542 53543 53544 53545 53546 53547 53548 53549 53550 53551 53552 53553 53554 53555 53556 53557 53558 53559 53560 53561 53562 53563 53564 53565 53566 53567 53568 53569 53570 53571 53572 53573 53574 53575 53576 53577 53578 53579 53580 53581 53582 53583 53584 53585 53586 53587 53588 53589 53590 53591 53592 53593 53594 53595 53596 53597 53598 53599 53600 53601 53602 53603 53604 53605 53606 53607 53608 53609 53610 53611 53612 53613 53614 53615 53616 53617 53618 53619 53620 53621 53622 53623 53624 53625 53626 53627 53628 53629 53630 53631 53632 53633 53634 53635 53636 53637 53638 53639 53640 53641 53642 53643 53644 53645 53646 53647 53648 53649 53650 53651 53652 53653 53654 53655 53656 53657 53658 53659 53660 53661 53662 53663 53664 53665 53666 53667 53668 53669 53670 53671 53672 53673 53674 53675 53676 53677 53678 53679 53680 53681 53682 53683 53684 53685 53686 53687 53688 53689 53690 53691 53692 53693 53694 53695 53696 53697 53698 53699 53700 53701 53702 53703 53704 53705 53706 53707 53708 53709 53710 53711 53712 53713 53714 53715 53716 53717 53718 53719 53720 53721 53722 53723 53724 53725 53726 53727 53728 53729 53730 53731 53732 53733 53734 53735 53736 53737 53738 53739 53740 53741 53742 53743 53744 53745 53746 53747 53748 53749 53750 53751 53752 53753 53754 53755 53756 53757 53758 53759 53760 53761 53762 53763 53764 53765 53766 53767 53768 53769 53770 53771 53772 53773 53774 53775 53776 53777 53778 53779 53780 53781 53782 53783 53784 53785 53786 53787 53788 53789 53790 53791 53792 53793 53794 53795 53796 53797 53798 53799 53800 53801 53802 53803 53804 53805 53806 53807 53808 53809 53810 53811 53812 53813 53814 53815 53816 53817 53818 53819 53820 53821 53822 53823 53824 53825 53826 53827 53828 53829 53830 53831 53832 53833 53834 53835 53836 53837 53838 53839 53840 53841 53842 53843 53844 53845 53846 53847 53848 53849 53850 53851 53852 53853 53854 53855 53856 53857 53858 53859 53860 53861 53862 53863 53864 53865 53866 53867 53868 53869 53870 53871 53872 53873 53874 53875 53876 53877 53878 53879 53880 53881 53882 53883 53884 53885 53886 53887 53888 53889 53890 53891 53892 53893 53894 53895 53896 53897 53898 53899 53900 53901 53902 53903 53904 53905 53906 53907 53908 53909 53910 53911 53912 53913 53914 53915 53916 53917 53918 53919 53920 53921 53922 53923 53924 53925 53926 53927 53928 53929 53930 53931 53932 53933 53934 53935 53936 53937 53938 53939 53940 53941 53942 53943 53944 53945 53946 53947 53948 53949 53950 53951 53952 53953 53954 53955 53956 53957 53958 53959 53960 53961 53962 53963 53964 53965 53966 53967 53968 53969 53970 53971 53972 53973 53974 53975 53976 53977 53978 53979 53980 53981 53982 53983 53984 53985 53986 53987 53988 53989 53990 53991 53992 53993 53994 53995 53996 53997 53998 53999 54000 54001 54002 54003 54004 54005 54006 54007 54008 54009 54010 54011 54012 54013 54014 54015 54016 54017 54018 54019 54020 54021 54022 54023 54024 54025 54026 54027 54028 54029 54030 54031 54032 54033 54034 54035 54036 54037 54038 54039 54040 54041 54042 54043 54044 54045 54046 54047 54048 54049 54050 54051 54052 54053 54054 54055 54056 54057 54058 54059 54060 54061 54062 54063 54064 54065 54066 54067 54068 54069 54070 54071 54072 54073 54074 54075 54076 54077 54078 54079 54080 54081 54082 54083 54084 54085 54086 54087 54088 54089 54090 54091 54092 54093 54094 54095 54096 54097 54098 54099 54100 54101 54102 54103 54104 54105 54106 54107 54108 54109 54110 54111 54112 54113 54114 54115 54116 54117 54118 54119 54120 54121 54122 54123 54124 54125 54126 54127 54128 54129 54130 54131 54132 54133 54134 54135 54136 54137 54138 54139 54140 54141 54142 54143 54144 54145 54146 54147 54148 54149 54150 54151 54152 54153 54154 54155 54156 54157 54158 54159 54160 54161 54162 54163 54164 54165 54166 54167 54168 54169 54170 54171 54172 54173 54174 54175 54176 54177 54178 54179 54180 54181 54182 54183 54184 54185 54186 54187 54188 54189 54190 54191 54192 54193 54194 54195 54196 54197 54198 54199 54200 54201 54202 54203 54204 54205 54206 54207 54208 54209 54210 54211 54212 54213 54214 54215 54216 54217 54218 54219 54220 54221 54222 54223 54224 54225 54226 54227 54228 54229 54230 54231 54232 54233 54234 54235 54236 54237 54238 54239 54240 54241 54242 54243 54244 54245 54246 54247 54248 54249 54250 54251 54252 54253 54254 54255 54256 54257 54258 54259 54260 54261 54262 54263 54264 54265 54266 54267 54268 54269 54270 54271 54272 54273 54274 54275 54276 54277 54278 54279 54280 54281 54282 54283 54284 54285 54286 54287 54288 54289 54290 54291 54292 54293 54294 54295 54296 54297 54298 54299 54300 54301 54302 54303 54304 54305 54306 54307 54308 54309 54310 54311 54312 54313 54314 54315 54316 54317 54318 54319 54320 54321 54322 54323 54324 54325 54326 54327 54328 54329 54330 54331 54332 54333 54334 54335 54336 54337 54338 54339 54340 54341 54342 54343 54344 54345 54346 54347 54348 54349 54350 54351 54352 54353 54354 54355 54356 54357 54358 54359 54360 54361 54362 54363 54364 54365 54366 54367 54368 54369 54370 54371 54372 54373 54374 54375 54376 54377 54378 54379 54380 54381 54382 54383 54384 54385 54386 54387 54388 54389 54390 54391 54392 54393 54394 54395 54396 54397 54398 54399 54400 54401 54402 54403 54404 54405 54406 54407 54408 54409 54410 54411 54412 54413 54414 54415 54416 54417 54418 54419 54420 54421 54422 54423 54424 54425 54426 54427 54428 54429 54430 54431 54432 54433 54434 54435 54436 54437 54438 54439 54440 54441 54442 54443 54444 54445 54446 54447 54448 54449 54450 54451 54452 54453 54454 54455 54456 54457 54458 54459 54460 54461 54462 54463 54464 54465 54466 54467 54468 54469 54470 54471 54472 54473 54474 54475 54476 54477 54478 54479 54480 54481 54482 54483 54484 54485 54486 54487 54488 54489 54490 54491 54492 54493 54494 54495 54496 54497 54498 54499 54500 54501 54502 54503 54504 54505 54506 54507 54508 54509 54510 54511 54512 54513 54514 54515 54516 54517 54518 54519 54520 54521 54522 54523 54524 54525 54526 54527 54528 54529 54530 54531 54532 54533 54534 54535 54536 54537 54538 54539 54540 54541 54542 54543 54544 54545 54546 54547 54548 54549 54550 54551 54552 54553 54554 54555 54556 54557 54558 54559 54560 54561 54562 54563 54564 54565 54566 54567 54568 54569 54570 54571 54572 54573 54574 54575 54576 54577 54578 54579 54580 54581 54582 54583 54584 54585 54586 54587 54588 54589 54590 54591 54592 54593 54594 54595 54596 54597 54598 54599 54600 54601 54602 54603 54604 54605 54606 54607 54608 54609 54610 54611 54612 54613 54614 54615 54616 54617 54618 54619 54620 54621 54622 54623 54624 54625 54626 54627 54628 54629 54630 54631 54632 54633 54634 54635 54636 54637 54638 54639 54640 54641 54642 54643 54644 54645 54646 54647 54648 54649 54650 54651 54652 54653 54654 54655 54656 54657 54658 54659 54660 54661 54662 54663 54664 54665 54666 54667 54668 54669 54670 54671 54672 54673 54674 54675 54676 54677 54678 54679 54680 54681 54682 54683 54684 54685 54686 54687 54688 54689 54690 54691 54692 54693 54694 54695 54696 54697 54698 54699 54700 54701 54702 54703 54704 54705 54706 54707 54708 54709 54710 54711 54712 54713 54714 54715 54716 54717 54718 54719 54720 54721 54722 54723 54724 54725 54726 54727 54728 54729 54730 54731 54732 54733 54734 54735 54736 54737 54738 54739 54740 54741 54742 54743 54744 54745 54746 54747 54748 54749 54750 54751 54752 54753 54754 54755 54756 54757 54758 54759 54760 54761 54762 54763 54764 54765 54766 54767 54768 54769 54770 54771 54772 54773 54774 54775 54776 54777 54778 54779 54780 54781 54782 54783 54784 54785 54786 54787 54788 54789 54790 54791 54792 54793 54794 54795 54796 54797 54798 54799 54800 54801 54802 54803 54804 54805 54806 54807 54808 54809 54810 54811 54812 54813 54814 54815 54816 54817 54818 54819 54820 54821 54822 54823 54824 54825 54826 54827 54828 54829 54830 54831 54832 54833 54834 54835 54836 54837 54838 54839 54840 54841 54842 54843 54844 54845 54846 54847 54848 54849 54850 54851 54852 54853 54854 54855 54856 54857 54858 54859 54860 54861 54862 54863 54864 54865 54866 54867 54868 54869 54870 54871 54872 54873 54874 54875 54876 54877 54878 54879 54880 54881 54882 54883 54884 54885 54886 54887 54888 54889 54890 54891 54892 54893 54894 54895 54896 54897 54898 54899 54900 54901 54902 54903 54904 54905 54906 54907 54908 54909 54910 54911 54912 54913 54914 54915 54916 54917 54918 54919 54920 54921 54922 54923 54924 54925 54926 54927 54928 54929 54930 54931 54932 54933 54934 54935 54936 54937 54938 54939 54940 54941 54942 54943 54944 54945 54946 54947 54948 54949 54950 54951 54952 54953 54954 54955 54956 54957 54958 54959 54960 54961 54962 54963 54964 54965 54966 54967 54968 54969 54970 54971 54972 54973 54974 54975 54976 54977 54978 54979 54980 54981 54982 54983 54984 54985 54986 54987 54988 54989 54990 54991 54992 54993 54994 54995 54996 54997 54998 54999 55000 55001 55002 55003 55004 55005 55006 55007 55008 55009 55010 55011 55012 55013 55014 55015 55016 55017 55018 55019 55020 55021 55022 55023 55024 55025 55026 55027 55028 55029 55030 55031 55032 55033 55034 55035 55036 55037 55038 55039 55040 55041 55042 55043 55044 55045 55046 55047 55048 55049 55050 55051 55052 55053 55054 55055 55056 55057 55058 55059 55060 55061 55062 55063 55064 55065 55066 55067 55068 55069 55070 55071 55072 55073 55074 55075 55076 55077 55078 55079 55080 55081 55082 55083 55084 55085 55086 55087 55088 55089 55090 55091 55092 55093 55094 55095 55096 55097 55098 55099 55100 55101 55102 55103 55104 55105 55106 55107 55108 55109 55110 55111 55112 55113 55114 55115 55116 55117 55118 55119 55120 55121 55122 55123 55124 55125 55126 55127 55128 55129 55130 55131 55132 55133 55134 55135 55136 55137 55138 55139 55140 55141 55142 55143 55144 55145 55146 55147 55148 55149 55150 55151 55152 55153 55154 55155 55156 55157 55158 55159 55160 55161 55162 55163 55164 55165 55166 55167 55168 55169 55170 55171 55172 55173 55174 55175 55176 55177 55178 55179 55180 55181 55182 55183 55184 55185 55186 55187 55188 55189 55190 55191 55192 55193 55194 55195 55196 55197 55198 55199 55200 55201 55202 55203 55204 55205 55206 55207 55208 55209 55210 55211 55212 55213 55214 55215 55216 55217 55218 55219 55220 55221 55222 55223 55224 55225 55226 55227 55228 55229 55230 55231 55232 55233 55234 55235 55236 55237 55238 55239 55240 55241 55242 55243 55244 55245 55246 55247 55248 55249 55250 55251 55252 55253 55254 55255 55256 55257 55258 55259 55260 55261 55262 55263 55264 55265 55266 55267 55268 55269 55270 55271 55272 55273 55274 55275 55276 55277 55278 55279 55280 55281 55282 55283 55284 55285 55286 55287 55288 55289 55290 55291 55292 55293 55294 55295 55296 55297 55298 55299 55300 55301 55302 55303 55304 55305 55306 55307 55308 55309 55310 55311 55312 55313 55314 55315 55316 55317 55318 55319 55320 55321 55322 55323 55324 55325 55326 55327 55328 55329 55330 55331 55332 55333 55334 55335 55336 55337 55338 55339 55340 55341 55342 55343 55344 55345 55346 55347 55348 55349 55350 55351 55352 55353 55354 55355 55356 55357 55358 55359 55360 55361 55362 55363 55364 55365 55366 55367 55368 55369 55370 55371 55372 55373 55374 55375 55376 55377 55378 55379 55380 55381 55382 55383 55384 55385 55386 55387 55388 55389 55390 55391 55392 55393 55394 55395 55396 55397 55398 55399 55400 55401 55402 55403 55404 55405 55406 55407 55408 55409 55410 55411 55412 55413 55414 55415 55416 55417 55418 55419 55420 55421 55422 55423 55424 55425 55426 55427 55428 55429 55430 55431 55432 55433 55434 55435 55436 55437 55438 55439 55440 55441 55442 55443 55444 55445 55446 55447 55448 55449 55450 55451 55452 55453 55454 55455 55456 55457 55458 55459 55460 55461 55462 55463 55464 55465 55466 55467 55468 55469 55470 55471 55472 55473 55474 55475 55476 55477 55478 55479 55480 55481 55482 55483 55484 55485 55486 55487 55488 55489 55490 55491 55492 55493 55494 55495 55496 55497 55498 55499 55500 55501 55502 55503 55504 55505 55506 55507 55508 55509 55510 55511 55512 55513 55514 55515 55516 55517 55518 55519 55520 55521 55522 55523 55524 55525 55526 55527 55528 55529 55530 55531 55532 55533 55534 55535 55536 55537 55538 55539 55540 55541 55542 55543 55544 55545 55546 55547 55548 55549 55550 55551 55552 55553 55554 55555 55556 55557 55558 55559 55560 55561 55562 55563 55564 55565 55566 55567 55568 55569 55570 55571 55572 55573 55574 55575 55576 55577 55578 55579 55580 55581 55582 55583 55584 55585 55586 55587 55588 55589 55590 55591 55592 55593 55594 55595 55596 55597 55598 55599 55600 55601 55602 55603 55604 55605 55606 55607 55608 55609 55610 55611 55612 55613 55614 55615 55616 55617 55618 55619 55620 55621 55622 55623 55624 55625 55626 55627 55628 55629 55630 55631 55632 55633 55634 55635 55636 55637 55638 55639 55640 55641 55642 55643 55644 55645 55646 55647 55648 55649 55650 55651 55652 55653 55654 55655 55656 55657 55658 55659 55660 55661 55662 55663 55664 55665 55666 55667 55668 55669 55670 55671 55672 55673 55674 55675 55676 55677 55678 55679 55680 55681 55682 55683 55684 55685 55686 55687 55688 55689 55690 55691 55692 55693 55694 55695 55696 55697 55698 55699 55700 55701 55702 55703 55704 55705 55706 55707 55708 55709 55710 55711 55712 55713 55714 55715 55716 55717 55718 55719 55720 55721 55722 55723 55724 55725 55726 55727 55728 55729 55730 55731 55732 55733 55734 55735 55736 55737 55738 55739 55740 55741 55742 55743 55744 55745 55746 55747 55748 55749 55750 55751 55752 55753 55754 55755 55756 55757 55758 55759 55760 55761 55762 55763 55764 55765 55766 55767 55768 55769 55770 55771 55772 55773 55774 55775 55776 55777 55778 55779 55780 55781 55782 55783 55784 55785 55786 55787 55788 55789 55790 55791 55792 55793 55794 55795 55796 55797 55798 55799 55800 55801 55802 55803 55804 55805 55806 55807 55808 55809 55810 55811 55812 55813 55814 55815 55816 55817 55818 55819 55820 55821 55822 55823 55824 55825 55826 55827 55828 55829 55830 55831 55832 55833 55834 55835 55836 55837 55838 55839 55840 55841 55842 55843 55844 55845 55846 55847 55848 55849 55850 55851 55852 55853 55854 55855 55856 55857 55858 55859 55860 55861 55862 55863 55864 55865 55866 55867 55868 55869 55870 55871 55872 55873 55874 55875 55876 55877 55878 55879 55880 55881 55882 55883 55884 55885 55886 55887 55888 55889 55890 55891 55892 55893 55894 55895 55896 55897 55898 55899 55900 55901 55902 55903 55904 55905 55906 55907 55908 55909 55910 55911 55912 55913 55914 55915 55916 55917 55918 55919 55920 55921 55922 55923 55924 55925 55926 55927 55928 55929 55930 55931 55932 55933 55934 55935 55936 55937 55938 55939 55940 55941 55942 55943 55944 55945 55946 55947 55948 55949 55950 55951 55952 55953 55954 55955 55956 55957 55958 55959 55960 55961 55962 55963 55964 55965 55966 55967 55968 55969 55970 55971 55972 55973 55974 55975 55976 55977 55978 55979 55980 55981 55982 55983 55984 55985 55986 55987 55988 55989 55990 55991 55992 55993 55994 55995 55996 55997 55998 55999 56000 56001 56002 56003 56004 56005 56006 56007 56008 56009 56010 56011 56012 56013 56014 56015 56016 56017 56018 56019 56020 56021 56022 56023 56024 56025 56026 56027 56028 56029 56030 56031 56032 56033 56034 56035 56036 56037 56038 56039 56040 56041 56042 56043 56044 56045 56046 56047 56048 56049 56050 56051 56052 56053 56054 56055 56056 56057 56058 56059 56060 56061 56062 56063 56064 56065 56066 56067 56068 56069 56070 56071 56072 56073 56074 56075 56076 56077 56078 56079 56080 56081 56082 56083 56084 56085 56086 56087 56088 56089 56090 56091 56092 56093 56094 56095 56096 56097 56098 56099 56100 56101 56102 56103 56104 56105 56106 56107 56108 56109 56110 56111 56112 56113 56114 56115 56116 56117 56118 56119 56120 56121 56122 56123 56124 56125 56126 56127 56128 56129 56130 56131 56132 56133 56134 56135 56136 56137 56138 56139 56140 56141 56142 56143 56144 56145 56146 56147 56148 56149 56150 56151 56152 56153 56154 56155 56156 56157 56158 56159 56160 56161 56162 56163 56164 56165 56166 56167 56168 56169 56170 56171 56172 56173 56174 56175 56176 56177 56178 56179 56180 56181 56182 56183 56184 56185 56186 56187 56188 56189 56190 56191 56192 56193 56194 56195 56196 56197 56198 56199 56200 56201 56202 56203 56204 56205 56206 56207 56208 56209 56210 56211 56212 56213 56214 56215 56216 56217 56218 56219 56220 56221 56222 56223 56224 56225 56226 56227 56228 56229 56230 56231 56232 56233 56234 56235 56236 56237 56238 56239 56240 56241 56242 56243 56244 56245 56246 56247 56248 56249 56250 56251 56252 56253 56254 56255 56256 56257 56258 56259 56260 56261 56262 56263 56264 56265 56266 56267 56268 56269 56270 56271 56272 56273 56274 56275 56276 56277 56278 56279 56280 56281 56282 56283 56284 56285 56286 56287 56288 56289 56290 56291 56292 56293 56294 56295 56296 56297 56298 56299 56300 56301 56302 56303 56304 56305 56306 56307 56308 56309 56310 56311 56312 56313 56314 56315 56316 56317 56318 56319 56320 56321 56322 56323 56324 56325 56326 56327 56328 56329 56330 56331 56332 56333 56334 56335 56336 56337 56338 56339 56340 56341 56342 56343 56344 56345 56346 56347 56348 56349 56350 56351 56352 56353 56354 56355 56356 56357 56358 56359 56360 56361 56362 56363 56364 56365 56366 56367 56368 56369 56370 56371 56372 56373 56374 56375 56376 56377 56378 56379 56380 56381 56382 56383 56384 56385 56386 56387 56388 56389 56390 56391 56392 56393 56394 56395 56396 56397 56398 56399 56400 56401 56402 56403 56404 56405 56406 56407 56408 56409 56410 56411 56412 56413 56414 56415 56416 56417 56418 56419 56420 56421 56422 56423 56424 56425 56426 56427 56428 56429 56430 56431 56432 56433 56434 56435 56436 56437 56438 56439 56440 56441 56442 56443 56444 56445 56446 56447 56448 56449 56450 56451 56452 56453 56454 56455 56456 56457 56458 56459 56460 56461 56462 56463 56464 56465 56466 56467 56468 56469 56470 56471 56472 56473 56474 56475 56476 56477 56478 56479 56480 56481 56482 56483 56484 56485 56486 56487 56488 56489 56490 56491 56492 56493 56494 56495 56496 56497 56498 56499 56500 56501 56502 56503 56504 56505 56506 56507 56508 56509 56510 56511 56512 56513 56514 56515 56516 56517 56518 56519 56520 56521 56522 56523 56524 56525 56526 56527 56528 56529 56530 56531 56532 56533 56534 56535 56536 56537 56538 56539 56540 56541 56542 56543 56544 56545 56546 56547 56548 56549 56550 56551 56552 56553 56554 56555 56556 56557 56558 56559 56560 56561 56562 56563 56564 56565 56566 56567 56568 56569 56570 56571 56572 56573 56574 56575 56576 56577 56578 56579 56580 56581 56582 56583 56584 56585 56586 56587 56588 56589 56590 56591 56592 56593 56594 56595 56596 56597 56598 56599 56600 56601 56602 56603 56604 56605 56606 56607 56608 56609 56610 56611 56612 56613 56614 56615 56616 56617 56618 56619 56620 56621 56622 56623 56624 56625 56626 56627 56628 56629 56630 56631 56632 56633 56634 56635 56636 56637 56638 56639 56640 56641 56642 56643 56644 56645 56646 56647 56648 56649 56650 56651 56652 56653 56654 56655 56656 56657 56658 56659 56660 56661 56662 56663 56664 56665 56666 56667 56668 56669 56670 56671 56672 56673 56674 56675 56676 56677 56678 56679 56680 56681 56682 56683 56684 56685 56686 56687 56688 56689 56690 56691 56692 56693 56694 56695 56696 56697 56698 56699 56700 56701 56702 56703 56704 56705 56706 56707 56708 56709 56710 56711 56712 56713 56714 56715 56716 56717 56718 56719 56720 56721 56722 56723 56724 56725 56726 56727 56728 56729 56730 56731 56732 56733 56734 56735 56736 56737 56738 56739 56740 56741 56742 56743 56744 56745 56746 56747 56748 56749 56750 56751 56752 56753 56754 56755 56756 56757 56758 56759 56760 56761 56762 56763 56764 56765 56766 56767 56768 56769 56770 56771 56772 56773 56774 56775 56776 56777 56778 56779 56780 56781 56782 56783 56784 56785 56786 56787 56788 56789 56790 56791 56792 56793 56794 56795 56796 56797 56798 56799 56800 56801 56802 56803 56804 56805 56806 56807 56808 56809 56810 56811 56812 56813 56814 56815 56816 56817 56818 56819 56820 56821 56822 56823 56824 56825 56826 56827 56828 56829 56830 56831 56832 56833 56834 56835 56836 56837 56838 56839 56840 56841 56842 56843 56844 56845 56846 56847 56848 56849 56850 56851 56852 56853 56854 56855 56856 56857 56858 56859 56860 56861 56862 56863 56864 56865 56866 56867 56868 56869 56870 56871 56872 56873 56874 56875 56876 56877 56878 56879 56880 56881 56882 56883 56884 56885 56886 56887 56888 56889 56890 56891 56892 56893 56894 56895 56896 56897 56898 56899 56900 56901 56902 56903 56904 56905 56906 56907 56908 56909 56910 56911 56912 56913 56914 56915 56916 56917 56918 56919 56920 56921 56922 56923 56924 56925 56926 56927 56928 56929 56930 56931 56932 56933 56934 56935 56936 56937 56938 56939 56940 56941 56942 56943 56944 56945 56946 56947 56948 56949 56950 56951 56952 56953 56954 56955 56956 56957 56958 56959 56960 56961 56962 56963 56964 56965 56966 56967 56968 56969 56970 56971 56972 56973 56974 56975 56976 56977 56978 56979 56980 56981 56982 56983 56984 56985 56986 56987 56988 56989 56990 56991 56992 56993 56994 56995 56996 56997 56998 56999 57000 57001 57002 57003 57004 57005 57006 57007 57008 57009 57010 57011 57012 57013 57014 57015 57016 57017 57018 57019 57020 57021 57022 57023 57024 57025 57026 57027 57028 57029 57030 57031 57032 57033 57034 57035 57036 57037 57038 57039 57040 57041 57042 57043 57044 57045 57046 57047 57048 57049 57050 57051 57052 57053 57054 57055 57056 57057 57058 57059 57060 57061 57062 57063 57064 57065 57066 57067 57068 57069 57070 57071 57072 57073 57074 57075 57076 57077 57078 57079 57080 57081 57082 57083 57084 57085 57086 57087 57088 57089 57090 57091 57092 57093 57094 57095 57096 57097 57098 57099 57100 57101 57102 57103 57104 57105 57106 57107 57108 57109 57110 57111 57112 57113 57114 57115 57116 57117 57118 57119 57120 57121 57122 57123 57124 57125 57126 57127 57128 57129 57130 57131 57132 57133 57134 57135 57136 57137 57138 57139 57140 57141 57142 57143 57144 57145 57146 57147 57148 57149 57150 57151 57152 57153 57154 57155 57156 57157 57158 57159 57160 57161 57162 57163 57164 57165 57166 57167 57168 57169 57170 57171 57172 57173 57174 57175 57176 57177 57178 57179 57180 57181 57182 57183 57184 57185 57186 57187 57188 57189 57190 57191 57192 57193 57194 57195 57196 57197 57198 57199 57200 57201 57202 57203 57204 57205 57206 57207 57208 57209 57210 57211 57212 57213 57214 57215 57216 57217 57218 57219 57220 57221 57222 57223 57224 57225 57226 57227 57228 57229 57230 57231 57232 57233 57234 57235 57236 57237 57238 57239 57240 57241 57242 57243 57244 57245 57246 57247 57248 57249 57250 57251 57252 57253 57254 57255 57256 57257 57258 57259 57260 57261 57262 57263 57264 57265 57266 57267 57268 57269 57270 57271 57272 57273 57274 57275 57276 57277 57278 57279 57280 57281 57282 57283 57284 57285 57286 57287 57288 57289 57290 57291 57292 57293 57294 57295 57296 57297 57298 57299 57300 57301 57302 57303 57304 57305 57306 57307 57308 57309 57310 57311 57312 57313 57314 57315 57316 57317 57318 57319 57320 57321 57322 57323 57324 57325 57326 57327 57328 57329 57330 57331 57332 57333 57334 57335 57336 57337 57338 57339 57340 57341 57342 57343 57344 57345 57346 57347 57348 57349 57350 57351 57352 57353 57354 57355 57356 57357 57358 57359 57360 57361 57362 57363 57364 57365 57366 57367 57368 57369 57370 57371 57372 57373 57374 57375 57376 57377 57378 57379 57380 57381 57382 57383 57384 57385 57386 57387 57388 57389 57390 57391 57392 57393 57394 57395 57396 57397 57398 57399 57400 57401 57402 57403 57404 57405 57406 57407 57408 57409 57410 57411 57412 57413 57414 57415 57416 57417 57418 57419 57420 57421 57422 57423 57424 57425 57426 57427 57428 57429 57430 57431 57432 57433 57434 57435 57436 57437 57438 57439 57440 57441 57442 57443 57444 57445 57446 57447 57448 57449 57450 57451 57452 57453 57454 57455 57456 57457 57458 57459 57460 57461 57462 57463 57464 57465 57466 57467 57468 57469 57470 57471 57472 57473 57474 57475 57476 57477 57478 57479 57480 57481 57482 57483 57484 57485 57486 57487 57488 57489 57490 57491 57492 57493 57494 57495 57496 57497 57498 57499 57500 57501 57502 57503 57504 57505 57506 57507 57508 57509 57510 57511 57512 57513 57514 57515 57516 57517 57518 57519 57520 57521 57522 57523 57524 57525 57526 57527 57528 57529 57530 57531 57532 57533 57534 57535 57536 57537 57538 57539 57540 57541 57542 57543 57544 57545 57546 57547 57548 57549 57550 57551 57552 57553 57554 57555 57556 57557 57558 57559 57560 57561 57562 57563 57564 57565 57566 57567 57568 57569 57570 57571 57572 57573 57574 57575 57576 57577 57578 57579 57580 57581 57582 57583 57584 57585 57586 57587 57588 57589 57590 57591 57592 57593 57594 57595 57596 57597 57598 57599 57600 57601 57602 57603 57604 57605 57606 57607 57608 57609 57610 57611 57612 57613 57614 57615 57616 57617 57618 57619 57620 57621 57622 57623 57624 57625 57626 57627 57628 57629 57630 57631 57632 57633 57634 57635 57636 57637 57638 57639 57640 57641 57642 57643 57644 57645 57646 57647 57648 57649 57650 57651 57652 57653 57654 57655 57656 57657 57658 57659 57660 57661 57662 57663 57664 57665 57666 57667 57668 57669 57670 57671 57672 57673 57674 57675 57676 57677 57678 57679 57680 57681 57682 57683 57684 57685 57686 57687 57688 57689 57690 57691 57692 57693 57694 57695 57696 57697 57698 57699 57700 57701 57702 57703 57704 57705 57706 57707 57708 57709 57710 57711 57712 57713 57714 57715 57716 57717 57718 57719 57720 57721 57722 57723 57724 57725 57726 57727 57728 57729 57730 57731 57732 57733 57734 57735 57736 57737 57738 57739 57740 57741 57742 57743 57744 57745 57746 57747 57748 57749 57750 57751 57752 57753 57754 57755 57756 57757 57758 57759 57760 57761 57762 57763 57764 57765 57766 57767 57768 57769 57770 57771 57772 57773 57774 57775 57776 57777 57778 57779 57780 57781 57782 57783 57784 57785 57786 57787 57788 57789 57790 57791 57792 57793 57794 57795 57796 57797 57798 57799 57800 57801 57802 57803 57804 57805 57806 57807 57808 57809 57810 57811 57812 57813 57814 57815 57816 57817 57818 57819 57820 57821 57822 57823 57824 57825 57826 57827 57828 57829 57830 57831 57832 57833 57834 57835 57836 57837 57838 57839 57840 57841 57842 57843 57844 57845 57846 57847 57848 57849 57850 57851 57852 57853 57854 57855 57856 57857 57858 57859 57860 57861 57862 57863 57864 57865 57866 57867 57868 57869 57870 57871 57872 57873 57874 57875 57876 57877 57878 57879 57880 57881 57882 57883 57884 57885 57886 57887 57888 57889 57890 57891 57892 57893 57894 57895 57896 57897 57898 57899 57900 57901 57902 57903 57904 57905 57906 57907 57908 57909 57910 57911 57912 57913 57914 57915 57916 57917 57918 57919 57920 57921 57922 57923 57924 57925 57926 57927 57928 57929 57930 57931 57932 57933 57934 57935 57936 57937 57938 57939 57940 57941 57942 57943 57944 57945 57946 57947 57948 57949 57950 57951 57952 57953 57954 57955 57956 57957 57958 57959 57960 57961 57962 57963 57964 57965 57966 57967 57968 57969 57970 57971 57972 57973 57974 57975 57976 57977 57978 57979 57980 57981 57982 57983 57984 57985 57986 57987 57988 57989 57990 57991 57992 57993 57994 57995 57996 57997 57998 57999 58000 58001 58002 58003 58004 58005 58006 58007 58008 58009 58010 58011 58012 58013 58014 58015 58016 58017 58018 58019 58020 58021 58022 58023 58024 58025 58026 58027 58028 58029 58030 58031 58032 58033 58034 58035 58036 58037 58038 58039 58040 58041 58042 58043 58044 58045 58046 58047 58048 58049 58050 58051 58052 58053 58054 58055 58056 58057 58058 58059 58060 58061 58062 58063 58064 58065 58066 58067 58068 58069 58070 58071 58072 58073 58074 58075 58076 58077 58078 58079 58080 58081 58082 58083 58084 58085 58086 58087 58088 58089 58090 58091 58092 58093 58094 58095 58096 58097 58098 58099 58100 58101 58102 58103 58104 58105 58106 58107 58108 58109 58110 58111 58112 58113 58114 58115 58116 58117 58118 58119 58120 58121 58122 58123 58124 58125 58126 58127 58128 58129 58130 58131 58132 58133 58134 58135 58136 58137 58138 58139 58140 58141 58142 58143 58144 58145 58146 58147 58148 58149 58150 58151 58152 58153 58154 58155 58156 58157 58158 58159 58160 58161 58162 58163 58164 58165 58166 58167 58168 58169 58170 58171 58172 58173 58174 58175 58176 58177 58178 58179 58180 58181 58182 58183 58184 58185 58186 58187 58188 58189 58190 58191 58192 58193 58194 58195 58196 58197 58198 58199 58200 58201 58202 58203 58204 58205 58206 58207 58208 58209 58210 58211 58212 58213 58214 58215 58216 58217 58218 58219 58220 58221 58222 58223 58224 58225 58226 58227 58228 58229 58230 58231 58232 58233 58234 58235 58236 58237 58238 58239 58240 58241 58242 58243 58244 58245 58246 58247 58248 58249 58250 58251 58252 58253 58254 58255 58256 58257 58258 58259 58260 58261 58262 58263 58264 58265 58266 58267 58268 58269 58270 58271 58272 58273 58274 58275 58276 58277 58278 58279 58280 58281 58282 58283 58284 58285 58286 58287 58288 58289 58290 58291 58292 58293 58294 58295 58296 58297 58298 58299 58300 58301 58302 58303 58304 58305 58306 58307 58308 58309 58310 58311 58312 58313 58314 58315 58316 58317 58318 58319 58320 58321 58322 58323 58324 58325 58326 58327 58328 58329 58330 58331 58332 58333 58334 58335 58336 58337 58338 58339 58340 58341 58342 58343 58344 58345 58346 58347 58348 58349 58350 58351 58352 58353 58354 58355 58356 58357 58358 58359 58360 58361 58362 58363 58364 58365 58366 58367 58368 58369 58370 58371 58372 58373 58374 58375 58376 58377 58378 58379 58380 58381 58382 58383 58384 58385 58386 58387 58388 58389 58390 58391 58392 58393 58394 58395 58396 58397 58398 58399 58400 58401 58402 58403 58404 58405 58406 58407 58408 58409 58410 58411 58412 58413 58414 58415 58416 58417 58418 58419 58420 58421 58422 58423 58424 58425 58426 58427 58428 58429 58430 58431 58432 58433 58434 58435 58436 58437 58438 58439 58440 58441 58442 58443 58444 58445 58446 58447 58448 58449 58450 58451 58452 58453 58454 58455 58456 58457 58458 58459 58460 58461 58462 58463 58464 58465 58466 58467 58468 58469 58470 58471 58472 58473 58474 58475 58476 58477 58478 58479 58480 58481 58482 58483 58484 58485 58486 58487 58488 58489 58490 58491 58492 58493 58494 58495 58496 58497 58498 58499 58500 58501 58502 58503 58504 58505 58506 58507 58508 58509 58510 58511 58512 58513 58514 58515 58516 58517 58518 58519 58520 58521 58522 58523 58524 58525 58526 58527 58528 58529 58530 58531 58532 58533 58534 58535 58536 58537 58538 58539 58540 58541 58542 58543 58544 58545 58546 58547 58548 58549 58550 58551 58552 58553 58554 58555 58556 58557 58558 58559 58560 58561 58562 58563 58564 58565 58566 58567 58568 58569 58570 58571 58572 58573 58574 58575 58576 58577 58578 58579 58580 58581 58582 58583 58584 58585 58586 58587 58588 58589 58590 58591 58592 58593 58594 58595 58596 58597 58598 58599 58600 58601 58602 58603 58604 58605 58606 58607 58608 58609 58610 58611 58612 58613 58614 58615 58616 58617 58618 58619 58620 58621 58622 58623 58624 58625 58626 58627 58628 58629 58630 58631 58632 58633 58634 58635 58636 58637 58638 58639 58640 58641 58642 58643 58644 58645 58646 58647 58648 58649 58650 58651 58652 58653 58654 58655 58656 58657 58658 58659 58660 58661 58662 58663 58664 58665 58666 58667 58668 58669 58670 58671 58672 58673 58674 58675 58676 58677 58678 58679 58680 58681 58682 58683 58684 58685 58686 58687 58688 58689 58690 58691 58692 58693 58694 58695 58696 58697 58698 58699 58700 58701 58702 58703 58704 58705 58706 58707 58708 58709 58710 58711 58712 58713 58714 58715 58716 58717 58718 58719 58720 58721 58722 58723 58724 58725 58726 58727 58728 58729 58730 58731 58732 58733 58734 58735 58736 58737 58738 58739 58740 58741 58742 58743 58744 58745 58746 58747 58748 58749 58750 58751 58752 58753 58754 58755 58756 58757 58758 58759 58760 58761 58762 58763 58764 58765 58766 58767 58768 58769 58770 58771 58772 58773 58774 58775 58776 58777 58778 58779 58780 58781 58782 58783 58784 58785 58786 58787 58788 58789 58790 58791 58792 58793 58794 58795 58796 58797 58798 58799 58800 58801 58802 58803 58804 58805 58806 58807 58808 58809 58810 58811 58812 58813 58814 58815 58816 58817 58818 58819 58820 58821 58822 58823 58824 58825 58826 58827 58828 58829 58830 58831 58832 58833 58834 58835 58836 58837 58838 58839 58840 58841 58842 58843 58844 58845 58846 58847 58848 58849 58850 58851 58852 58853 58854 58855 58856 58857 58858 58859 58860 58861 58862 58863 58864 58865 58866 58867 58868 58869 58870 58871 58872 58873 58874 58875 58876 58877 58878 58879 58880 58881 58882 58883 58884 58885 58886 58887 58888 58889 58890 58891 58892 58893 58894 58895 58896 58897 58898 58899 58900 58901 58902 58903 58904 58905 58906 58907 58908 58909 58910 58911 58912 58913 58914 58915 58916 58917 58918 58919 58920 58921 58922 58923 58924 58925 58926 58927 58928 58929 58930 58931 58932 58933 58934 58935 58936 58937 58938 58939 58940 58941 58942 58943 58944 58945 58946 58947 58948 58949 58950 58951 58952 58953 58954 58955 58956 58957 58958 58959 58960 58961 58962 58963 58964 58965 58966 58967 58968 58969 58970 58971 58972 58973 58974 58975 58976 58977 58978 58979 58980 58981 58982 58983 58984 58985 58986 58987 58988 58989 58990 58991 58992 58993 58994 58995 58996 58997 58998 58999 59000 59001 59002 59003 59004 59005 59006 59007 59008 59009 59010 59011 59012 59013 59014 59015 59016 59017 59018 59019 59020 59021 59022 59023 59024 59025 59026 59027 59028 59029 59030 59031 59032 59033 59034 59035 59036 59037 59038 59039 59040 59041 59042 59043 59044 59045 59046 59047 59048 59049 59050 59051 59052 59053 59054 59055 59056 59057 59058 59059 59060 59061 59062 59063 59064 59065 59066 59067 59068 59069 59070 59071 59072 59073 59074 59075 59076 59077 59078 59079 59080 59081 59082 59083 59084 59085 59086 59087 59088 59089 59090 59091 59092 59093 59094 59095 59096 59097 59098 59099 59100 59101 59102 59103 59104 59105 59106 59107 59108 59109 59110 59111 59112 59113 59114 59115 59116 59117 59118 59119 59120 59121 59122 59123 59124 59125 59126 59127 59128 59129 59130 59131 59132 59133 59134 59135 59136 59137 59138 59139 59140 59141 59142 59143 59144 59145 59146 59147 59148 59149 59150 59151 59152 59153 59154 59155 59156 59157 59158 59159 59160 59161 59162 59163 59164 59165 59166 59167 59168 59169 59170 59171 59172 59173 59174 59175 59176 59177 59178 59179 59180 59181 59182 59183 59184 59185 59186 59187 59188 59189 59190 59191 59192 59193 59194 59195 59196 59197 59198 59199 59200 59201 59202 59203 59204 59205 59206 59207 59208 59209 59210 59211 59212 59213 59214 59215 59216 59217 59218 59219 59220 59221 59222 59223 59224 59225 59226 59227 59228 59229 59230 59231 59232 59233 59234 59235 59236 59237 59238 59239 59240 59241 59242 59243 59244 59245 59246 59247 59248 59249 59250 59251 59252 59253 59254 59255 59256 59257 59258 59259 59260 59261 59262 59263 59264 59265 59266 59267 59268 59269 59270 59271 59272 59273 59274 59275 59276 59277 59278 59279 59280 59281 59282 59283 59284 59285 59286 59287 59288 59289 59290 59291 59292 59293 59294 59295 59296 59297 59298 59299 59300 59301 59302 59303 59304 59305 59306 59307 59308 59309 59310 59311 59312 59313 59314 59315 59316 59317 59318 59319 59320 59321 59322 59323 59324 59325 59326 59327 59328 59329 59330 59331 59332 59333 59334 59335 59336 59337 59338 59339 59340 59341 59342 59343 59344 59345 59346 59347 59348 59349 59350 59351 59352 59353 59354 59355 59356 59357 59358 59359 59360 59361 59362 59363 59364 59365 59366 59367 59368 59369 59370 59371 59372 59373 59374 59375 59376 59377 59378 59379 59380 59381 59382 59383 59384 59385 59386 59387 59388 59389 59390 59391 59392 59393 59394 59395 59396 59397 59398 59399 59400 59401 59402 59403 59404 59405 59406 59407 59408 59409 59410 59411 59412 59413 59414 59415 59416 59417 59418 59419 59420 59421 59422 59423 59424 59425 59426 59427 59428 59429 59430 59431 59432 59433 59434 59435 59436 59437 59438 59439 59440 59441 59442 59443 59444 59445 59446 59447 59448 59449 59450 59451 59452 59453 59454 59455 59456 59457 59458 59459 59460 59461 59462 59463 59464 59465 59466 59467 59468 59469 59470 59471 59472 59473 59474 59475 59476 59477 59478 59479 59480 59481 59482 59483 59484 59485 59486 59487 59488 59489 59490 59491 59492 59493 59494 59495 59496 59497 59498 59499 59500 59501 59502 59503 59504 59505 59506 59507 59508 59509 59510 59511 59512 59513 59514 59515 59516 59517 59518 59519 59520 59521 59522 59523 59524 59525 59526 59527 59528 59529 59530 59531 59532 59533 59534 59535 59536 59537 59538 59539 59540 59541 59542 59543 59544 59545 59546 59547 59548 59549 59550 59551 59552 59553 59554 59555 59556 59557 59558 59559 59560 59561 59562 59563 59564 59565 59566 59567 59568 59569 59570 59571 59572 59573 59574 59575 59576 59577 59578 59579 59580 59581 59582 59583 59584 59585 59586 59587 59588 59589 59590 59591 59592 59593 59594 59595 59596 59597 59598 59599 59600 59601 59602 59603 59604 59605 59606 59607 59608 59609 59610 59611 59612 59613 59614 59615 59616 59617 59618 59619 59620 59621 59622 59623 59624 59625 59626 59627 59628 59629 59630 59631 59632 59633 59634 59635 59636 59637 59638 59639 59640 59641 59642 59643 59644 59645 59646 59647 59648 59649 59650 59651 59652 59653 59654 59655 59656 59657 59658 59659 59660 59661 59662 59663 59664 59665 59666 59667 59668 59669 59670 59671 59672 59673 59674 59675 59676 59677 59678 59679 59680 59681 59682 59683 59684 59685 59686 59687 59688 59689 59690 59691 59692 59693 59694 59695 59696 59697 59698 59699 59700 59701 59702 59703 59704 59705 59706 59707 59708 59709 59710 59711 59712 59713 59714 59715 59716 59717 59718 59719 59720 59721 59722 59723 59724 59725 59726 59727 59728 59729 59730 59731 59732 59733 59734 59735 59736 59737 59738 59739 59740 59741 59742 59743 59744 59745 59746 59747 59748 59749 59750 59751 59752 59753 59754 59755 59756 59757 59758 59759 59760 59761 59762 59763 59764 59765 59766 59767 59768 59769 59770 59771 59772 59773 59774 59775 59776 59777 59778 59779 59780 59781 59782 59783 59784 59785 59786 59787 59788 59789 59790 59791 59792 59793 59794 59795 59796 59797 59798 59799 59800 59801 59802 59803 59804 59805 59806 59807 59808 59809 59810 59811
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..bc6344b
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,3 @@
+{
+ "postCreateCommand": "bash .devcontainer/setup.sh"
+}
diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh
new file mode 100755
index 0000000..c328bf3
--- /dev/null
+++ b/.devcontainer/setup.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -e
+
+sudo apt-get update
+sudo apt-get -y --no-install-recommends install cmake
+
+mkdir build
+cd build
+cmake ..
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
index 34c5e92..2230fd8 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -15,3 +15,7 @@ indent_size = 2
indent_style = space
indent_size = 4
trim_trailing_whitespace = false
+
+[*.py]
+indent_style = space
+indent_size = 4
diff --git a/.gitattributes b/.gitattributes
index 176a458..3d90b7d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
* text=auto
+tests/resources/** linguist-vendored
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..38b4a04
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,36 @@
+name: "CodeQL"
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: '21 3 * * 1'
+
+env:
+ docker-registry: docker.pkg.github.com
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v1
+ with:
+ languages: 'cpp'
+
+ - name: Build
+ run: |
+ mkdir build
+ cd build
+ cmake .. -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ cmake --build .
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v1
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..572f025
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,303 @@
+# Continuous integration and pull request validation builds for the
+# main and maintenance branches.
+name: CI Build
+
+on:
+ push:
+ branches: [ main, maint/* ]
+ pull_request:
+ branches: [ main, maint/* ]
+ workflow_dispatch:
+
+env:
+ docker-registry: docker.pkg.github.com
+ docker-config-path: source/ci/docker
+
+jobs:
+ # Build the docker container images that we will use for our Linux
+ # builds. This will identify the last commit to the repository that
+ # updated the docker images, and try to download the image tagged with
+ # that sha. If it does not exist, we'll do a docker build and push
+ # the image up to GitHub Packages for the actual CI/CD runs. We tag
+ # with both the sha and "latest" so that the subsequent runs need not
+ # know the sha. Only do this on CI builds (when the event is a "push")
+ # because PR builds from forks lack permission to write packages.
+ build_containers:
+ name: Create docker image
+ strategy:
+ matrix:
+ container:
+ - name: xenial
+ - name: bionic
+ - name: focal
+ - name: docurium
+ - name: bionic-x86
+ dockerfile: bionic
+ base: multiarch/ubuntu-core:x86-bionic
+ qemu: true
+ - name: bionic-arm32
+ dockerfile: bionic
+ base: multiarch/ubuntu-core:armhf-bionic
+ qemu: true
+ - name: bionic-arm64
+ dockerfile: bionic
+ base: multiarch/ubuntu-core:arm64-bionic
+ qemu: true
+ - name: centos7
+ - name: centos8
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ with:
+ path: source
+ fetch-depth: 0
+ if: github.event_name != 'pull_request'
+ - name: Setup QEMU
+ run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
+ if: matrix.container.qemu == true
+ - name: Download existing container
+ run: |
+ "${{ github.workspace }}/source/ci/getcontainer.sh" "${{ matrix.container.name }}" "${{ matrix.container.dockerfile }}"
+ env:
+ DOCKER_REGISTRY: ${{ env.docker-registry }}
+ GITHUB_TOKEN: ${{ secrets.github_token }}
+ working-directory: ${{ env.docker-config-path }}
+ if: github.event_name != 'pull_request'
+ - name: Build and publish image
+ run: |
+ if [ "${{ matrix.container.base }}" != "" ]; then
+ BASE_ARG="--build-arg BASE=${{ matrix.container.base }}"
+ fi
+ docker build -t ${{ env.docker-registry-container-sha }} ${BASE_ARG} -f ${{ env.dockerfile }} .
+ docker tag ${{ env.docker-registry-container-sha }} ${{ env.docker-registry-container-latest }}
+ docker push ${{ env.docker-registry-container-sha }}
+ docker push ${{ env.docker-registry-container-latest }}
+ working-directory: ${{ env.docker-config-path }}
+ if: github.event_name != 'pull_request' && env.docker-container-exists != 'true'
+
+ # Run our CI/CD builds. We build a matrix with the various build targets
+ # and their details. Then we build either in a docker container (Linux)
+ # or on the actual hosts (macOS, Windows).
+ build:
+ name: Build
+ needs: [ build_containers ]
+ strategy:
+ matrix:
+ platform:
+ - # Xenial, GCC, OpenSSL
+ container:
+ name: xenial
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
+ os: ubuntu-latest
+ - # Xenial, GCC, mbedTLS
+ container:
+ name: xenial
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ os: ubuntu-latest
+ - # Xenial, Clang, OpenSSL
+ container:
+ name: xenial
+ env:
+ CC: clang
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ os: ubuntu-latest
+ - # Xenial, Clang, mbedTLS
+ container:
+ name: xenial
+ env:
+ CC: clang
+ CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ CMAKE_GENERATOR: Ninja
+ os: ubuntu-latest
+ - # Focal, Clang 10, mbedTLS, MemorySanitizer
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
+ UBSAN_OPTIONS: print_stacktrace=1
+ os: ubuntu-latest
+ - # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
+ UBSAN_OPTIONS: print_stacktrace=1
+ os: ubuntu-latest
+ - # Focal, Clang 10, OpenSSL, ThreadSanitizer
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
+ UBSAN_OPTIONS: print_stacktrace=1
+ TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1
+ os: ubuntu-latest
+ - # macOS
+ os: macos-10.15
+ env:
+ CC: clang
+ CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
+ PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ setup-script: osx
+ - # Windows amd64 Visual Studio
+ os: windows-2019
+ env:
+ ARCH: amd64
+ CMAKE_GENERATOR: Visual Studio 16 2019
+ CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows x86 Visual Studio
+ os: windows-2019
+ env:
+ ARCH: x86
+ CMAKE_GENERATOR: Visual Studio 16 2019
+ CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows amd64 mingw
+ os: windows-2019
+ setup-script: mingw
+ env:
+ ARCH: amd64
+ CMAKE_GENERATOR: MinGW Makefiles
+ CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
+ BUILD_TEMP: D:\Temp
+ BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows x86 mingw
+ os: windows-2019
+ setup-script: mingw
+ env:
+ ARCH: x86
+ CMAKE_GENERATOR: MinGW Makefiles
+ CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
+ BUILD_TEMP: D:\Temp
+ BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ fail-fast: false
+ env: ${{ matrix.platform.env }}
+ runs-on: ${{ matrix.platform.os }}
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ with:
+ path: source
+ fetch-depth: 0
+ - name: Set up build environment
+ run: source/ci/setup-${{ matrix.platform.setup-script }}.sh
+ shell: bash
+ if: matrix.platform.setup-script != ''
+ - name: Setup QEMU
+ run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
+ if: matrix.platform.container.qemu == true
+ - name: Download container
+ run: |
+ "${{ github.workspace }}/source/ci/getcontainer.sh" "${{ matrix.platform.container.name }}" "${{ matrix.platform.container.dockerfile }}"
+ env:
+ DOCKER_REGISTRY: ${{ env.docker-registry }}
+ GITHUB_TOKEN: ${{ secrets.github_token }}
+ working-directory: ${{ env.docker-config-path }}
+ if: matrix.platform.container.name != ''
+ - name: Create container
+ run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ env.dockerfile }} .
+ working-directory: ${{ env.docker-config-path }}
+ if: matrix.platform.container.name != '' && env.docker-container-exists != 'true'
+ - name: Build and test
+ run: |
+ export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}"
+
+ if [ -n "${{ matrix.platform.container.name }}" ]; then
+ docker run \
+ --rm \
+ --user libgit2:libgit2 \
+ -v "$(pwd)/source:/home/libgit2/source" \
+ -w /home/libgit2 \
+ -e ASAN_SYMBOLIZER_PATH \
+ -e CC \
+ -e CFLAGS \
+ -e CMAKE_GENERATOR \
+ -e CMAKE_OPTIONS \
+ -e GITTEST_NEGOTIATE_PASSWORD \
+ -e PKG_CONFIG_PATH \
+ -e SKIP_NEGOTIATE_TESTS \
+ -e SKIP_SSH_TESTS \
+ -e TSAN_OPTIONS \
+ -e UBSAN_OPTIONS \
+ ${{ env.docker-registry-container-sha }} \
+ /bin/bash -c "mkdir build && cd build && ../source/ci/build.sh && ../source/ci/test.sh"
+ else
+ mkdir build && cd build
+ ../source/ci/build.sh
+ ../source/ci/test.sh
+ fi
+ shell: bash
+
+ # Generate documentation using docurium. We'll upload the documentation
+ # as a build artifact so that it can be reviewed as part of a pull
+ # request or in a forked build. For CI builds in the main repository's
+ # main branch, we'll push the gh-pages branch back up so that it is
+ # published to our documentation site.
+ documentation:
+ name: Generate documentation
+ needs: [build_containers]
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ with:
+ path: source
+ fetch-depth: 0
+ - name: Generate documentation
+ working-directory: source
+ run: |
+ git config user.name 'Documentation Generation'
+ git config user.email 'libgit2@users.noreply.github.com'
+ git branch gh-pages origin/gh-pages
+ docker login https://${{ env.docker-registry }} -u ${{ github.actor }} -p ${{ github.token }}
+ docker run \
+ --rm \
+ -v "$(pwd):/home/libgit2" \
+ -w /home/libgit2 \
+ ${{ env.docker-registry }}/${{ github.repository }}/docurium:latest \
+ cm doc api.docurium
+ git checkout gh-pages
+ zip --exclude .git/\* --exclude .gitignore --exclude .gitattributes -r api-documentation.zip .
+ - uses: actions/upload-artifact@v2
+ name: Upload artifact
+ with:
+ name: api-documentation
+ path: source/api-documentation.zip
+ - name: Push documentation branch
+ working-directory: source
+ run: git push origin gh-pages
+ if: github.event_name != 'pull_request' && github.repository == 'libgit2/libgit2'
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
new file mode 100644
index 0000000..47ebf46
--- /dev/null
+++ b/.github/workflows/nightly.yml
@@ -0,0 +1,339 @@
+# Nightly build for the main branch across multiple targets.
+name: Nightly Build
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: '15 1 * * *'
+
+env:
+ docker-registry: docker.pkg.github.com
+ docker-config-path: source/ci/docker
+
+jobs:
+ # Run our nightly builds. We build a matrix with the various build
+ # targets and their details. Then we build either in a docker container
+ # (Linux) or on the actual hosts (macOS, Windows).
+ build:
+ name: Build
+ strategy:
+ matrix:
+ platform:
+ - # Xenial, GCC, OpenSSL
+ container:
+ name: xenial
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ os: ubuntu-latest
+ - # Xenial, GCC, mbedTLS
+ container:
+ name: xenial
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ os: ubuntu-latest
+ - # Xenial, Clang, OpenSSL
+ container:
+ name: xenial
+ env:
+ CC: clang
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ os: ubuntu-latest
+ - # Xenial, Clang, mbedTLS
+ container:
+ name: xenial
+ env:
+ CC: clang
+ CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ CMAKE_GENERATOR: Ninja
+ os: ubuntu-latest
+ - # Xenial, GCC, thread-free
+ container:
+ name: xenial
+ env:
+ CC: gcc
+ CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ CMAKE_GENERATOR: Ninja
+ os: ubuntu-latest
+ - # Xenial, Clang, OpenSSL (dynamically loaded)
+ container:
+ name: xenial
+ env:
+ CC: clang
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ CMAKE_GENERATOR: Ninja
+ os: ubuntu-latest
+ - # Focal, Clang 10, mbedTLS, MemorySanitizer
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
+ os: ubuntu-latest
+ - # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
+ os: ubuntu-latest
+ - # Focal, Clang 10, OpenSSL, ThreadSanitizer
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
+ TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1
+ os: ubuntu-latest
+ - # Focal, Clang 10, mmap emulation (NO_MMAP)
+ container:
+ name: focal
+ env:
+ CC: clang-10
+ CFLAGS: -DNO_MMAP
+ CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local
+ CMAKE_GENERATOR: Ninja
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ os: ubuntu-latest
+ - # CentOS 7
+ container:
+ name: centos7
+ env:
+ CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
+ SKIP_NEGOTIATE_TESTS: true
+ os: ubuntu-latest
+ - # CentOS 7, OpenSSL (dynamically loaded)
+ container:
+ name: centos7
+ env:
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
+ SKIP_NEGOTIATE_TESTS: true
+ os: ubuntu-latest
+ - # CentOS 8
+ container:
+ name: centos8
+ env:
+ CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
+ SKIP_NEGOTIATE_TESTS: true
+ SKIP_SSH_TESTS: true
+ os: ubuntu-latest
+ - # CentOS 8, OpenSSL (dynamically loaded)
+ container:
+ name: centos8
+ env:
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
+ SKIP_NEGOTIATE_TESTS: true
+ SKIP_SSH_TESTS: true
+ os: ubuntu-latest
+ - # macOS
+ os: macos-10.15
+ env:
+ CC: clang
+ CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
+ PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ setup-script: osx
+ - # Windows amd64 Visual Studio
+ os: windows-2019
+ env:
+ ARCH: amd64
+ CMAKE_GENERATOR: Visual Studio 16 2019
+ CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows amd64 Visual Studio (NO_MMAP)
+ os: windows-2019
+ env:
+ ARCH: amd64
+ CMAKE_GENERATOR: Visual Studio 16 2019
+ CFLAGS: -DNO_MMAP
+ CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows x86 Visual Studio
+ os: windows-2019
+ env:
+ ARCH: x86
+ CMAKE_GENERATOR: Visual Studio 16 2019
+ CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows amd64 mingw
+ os: windows-2019
+ setup-script: mingw
+ env:
+ ARCH: amd64
+ CMAKE_GENERATOR: MinGW Makefiles
+ CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
+ BUILD_TEMP: D:\Temp
+ BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Windows x86 mingw
+ os: windows-2019
+ setup-script: mingw
+ env:
+ ARCH: x86
+ CMAKE_GENERATOR: MinGW Makefiles
+ CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
+ BUILD_TEMP: D:\Temp
+ BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
+ SKIP_SSH_TESTS: true
+ SKIP_NEGOTIATE_TESTS: true
+ - # Bionic, GCC, OpenSSL (dynamically loaded)
+ container:
+ name: bionic
+ dockerfile: bionic
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ RUN_INVASIVE_TESTS: true
+ os: ubuntu-latest
+ - # Bionic, x86, Clang, OpenSSL
+ container:
+ name: bionic-x86
+ dockerfile: bionic
+ qemu: true
+ env:
+ CC: clang
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ RUN_INVASIVE_TESTS: true
+ os: ubuntu-latest
+ - # Bionic, x86, GCC, OpenSSL
+ container:
+ name: bionic-x86
+ dockerfile: bionic
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
+ RUN_INVASIVE_TESTS: true
+ os: ubuntu-latest
+ - # Bionic, arm32, GCC, OpenSSL
+ container:
+ name: bionic-arm32
+ dockerfile: bionic
+ qemu: true
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON
+ RUN_INVASIVE_TESTS: true
+ SKIP_PROXY_TESTS: true
+ os: ubuntu-latest
+ - # Bionic, arm64, GCC, OpenSSL
+ container:
+ name: bionic-arm64
+ dockerfile: bionic
+ qemu: true
+ env:
+ CC: gcc
+ CMAKE_GENERATOR: Ninja
+ CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON
+ RUN_INVASIVE_TESTS: true
+ SKIP_PROXY_TESTS: true
+ os: ubuntu-latest
+ fail-fast: false
+ env: ${{ matrix.platform.env }}
+ runs-on: ${{ matrix.platform.os }}
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ with:
+ path: source
+ fetch-depth: 0
+ - name: Set up build environment
+ run: source/ci/setup-${{ matrix.platform.setup-script }}.sh
+ shell: bash
+ if: matrix.platform.setup-script != ''
+ - name: Setup QEMU
+ run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
+ if: matrix.platform.container.qemu == true
+ - name: Download container
+ run: |
+ "${{ github.workspace }}/source/ci/getcontainer.sh" "${{ matrix.platform.container.name }}" "${{ matrix.platform.container.dockerfile }}"
+ env:
+ DOCKER_REGISTRY: ${{ env.docker-registry }}
+ GITHUB_TOKEN: ${{ secrets.github_token }}
+ working-directory: ${{ env.docker-config-path }}
+ if: matrix.platform.container.name != ''
+ - name: Create container
+ run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ env.dockerfile }} .
+ working-directory: ${{ env.docker-config-path }}
+ if: matrix.platform.container.name != '' && env.docker-container-exists != 'true'
+ - name: Build and test
+ run: |
+ export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}"
+
+ if [ -n "${{ matrix.platform.container.name }}" ]; then
+ docker run \
+ --rm \
+ --user libgit2:libgit2 \
+ -v "$(pwd)/source:/home/libgit2/source" \
+ -w /home/libgit2 \
+ -e ASAN_SYMBOLIZER_PATH \
+ -e CC \
+ -e CFLAGS \
+ -e CMAKE_GENERATOR \
+ -e CMAKE_OPTIONS \
+ -e GITTEST_NEGOTIATE_PASSWORD \
+ -e PKG_CONFIG_PATH \
+ -e SKIP_NEGOTIATE_TESTS \
+ -e SKIP_SSH_TESTS \
+ -e TSAN_OPTIONS \
+ ${{ env.docker-registry-container-sha }} \
+ /bin/bash -c "mkdir build && cd build && ../source/ci/build.sh && ../source/ci/test.sh"
+ else
+ mkdir build && cd build
+ ../source/ci/build.sh
+ ../source/ci/test.sh
+ fi
+ shell: bash
+
+ coverity:
+ name: Coverity
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ with:
+ path: source
+ fetch-depth: 0
+ - name: Download container
+ run: |
+ "${{ github.workspace }}/source/ci/getcontainer.sh" xenial
+ env:
+ DOCKER_REGISTRY: ${{ env.docker-registry }}
+ GITHUB_TOKEN: ${{ secrets.github_token }}
+ working-directory: ${{ env.docker-config-path }}
+ - name: Run Coverity
+ run: source/ci/coverity.sh
+ env:
+ COVERITY_TOKEN: ${{ secrets.coverity_token }}
diff --git a/.gitignore b/.gitignore
index dec3dca..1b482f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,37 +1,8 @@
-/tests/clar.suite
-/tests/clar.suite.rule
-/tests/.clarcache
-/apidocs
-/trash-*.exe
-/libgit2.pc
-/config.mak
-*.o
-*.a
-*.exe
-*.gcda
-*.gcno
-*.gcov
-.lock-wafbuild
-.waf*
-build/
-build-amiga/
-tests/tmp/
-msvc/Debug/
-msvc/Release/
-*.sln
-*.suo
-*.vc*proj*
-*.sdf
-*.opensdf
-*.aps
-*.cmake
-!cmake/Modules/*.cmake
+/build/
.DS_Store
*~
.*.swp
-tags
-mkmf.log
-*.profdata
-*.profraw
+/tags
CMakeSettings.json
.vs
+.idea
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..d47d93a
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,27 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "(gdb) Launch",
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "${workspaceFolder}/build/libgit2_clar",
+ "args": [],
+ "stopAtEntry": false,
+ "cwd": "${fileDirname}",
+ "environment": [],
+ "externalConsole": false,
+ "MIMode": "gdb",
+ "setupCommands": [
+ {
+ "description": "Enable pretty-printing for gdb",
+ "text": "-enable-pretty-printing",
+ "ignoreFailures": true
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..64142d3
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,27 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "Build",
+ "type": "shell",
+ "command": "cd build && cmake --build . --parallel",
+ "group": "build",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ }
+ },
+ {
+ "label": "Run Tests",
+ "type": "shell",
+ "command": "build/libgit2_clar -v",
+ "group": "test",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ }
+ }
+ ]
+ }
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8765a97..fd046eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,21 +11,12 @@
# Install:
# > cmake --build . --target install
-PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
-CMAKE_POLICY(SET CMP0015 NEW)
-IF(POLICY CMP0051)
- CMAKE_POLICY(SET CMP0051 NEW)
-ENDIF()
-IF(POLICY CMP0042)
- CMAKE_POLICY(SET CMP0042 NEW)
-ENDIF()
-IF(POLICY CMP0054)
- CMAKE_POLICY(SET CMP0054 NEW)
-ENDIF()
+
+project(libgit2 VERSION "1.1.0" LANGUAGES C)
# Add find modules to the path
-SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
@@ -36,6 +27,8 @@ INCLUDE(AddCFlagIfSupported)
INCLUDE(FindPkgLibraries)
INCLUDE(FindThreads)
INCLUDE(FindStatNsec)
+INCLUDE(Findfutimens)
+INCLUDE(GNUInstallDirs)
INCLUDE(IdeSplitSources)
INCLUDE(FeatureSummary)
INCLUDE(EnableWarnings)
@@ -48,8 +41,6 @@ OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
-OPTION(TAGS "Generate tags" OFF)
-OPTION(PROFILE "Generate profiling information" OFF)
OPTION(ENABLE_TRACE "Enables tracing support" ON)
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
@@ -58,10 +49,11 @@ OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Gene
OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
-OPTION(VALGRIND "Configure build for valgrind" OFF)
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
+OPTION(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
+OPTION(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
-OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
+OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
@@ -100,20 +92,10 @@ IF(WIN32)
ENDIF()
IF(MSVC)
- # Enable MSVC CRTDBG memory leak reporting when in debug mode.
- OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
+ # Enable leak checking using the debugging C runtime.
+ OPTION(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
ENDIF()
-FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
-
-STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")
-STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}")
-STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
-SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
-
-FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
-STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
-
IF (DEPRECATE_HARD)
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
ENDIF()
@@ -137,6 +119,11 @@ IF (MSVC)
# /Gd - explicitly set cdecl calling convention
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
+ IF (NOT (MSVC_VERSION LESS 1900))
+ # /guard:cf - Enable Control Flow Guard
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
+ ENDIF()
+
IF (STATIC_CRT)
SET(CRT_FLAG_DEBUG "/MTd")
SET(CRT_FLAG_RELEASE "/MT")
@@ -145,8 +132,8 @@ IF (MSVC)
SET(CRT_FLAG_RELEASE "/MD")
ENDIF()
- IF (MSVC_CRTDBG)
- SET(GIT_MSVC_CRTDBG 1)
+ IF (WIN32_LEAKCHECK)
+ SET(GIT_WIN32_LEAKCHECK 1)
SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
ENDIF()
@@ -181,7 +168,12 @@ IF (MSVC)
# /NXCOMPAT - Data execution prevention (DEP)
# /LARGEADDRESSAWARE - >2GB user address space on x86
# /VERSION - Embed version information in PE header
- SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}")
+ SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
+
+ IF (NOT (MSVC_VERSION LESS 1900))
+ # /GUARD:CF - Enable Control Flow Guard
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
+ ENDIF()
# /DEBUG - Create a PDB
# /LTCG - Link time code generation (whole program optimization)
@@ -232,35 +224,29 @@ ELSE ()
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
ENDIF ()
- ENABLE_WARNINGS(documentation)
- DISABLE_WARNINGS(missing-field-initializers)
- ENABLE_WARNINGS(strict-aliasing)
- ENABLE_WARNINGS(strict-prototypes)
- ENABLE_WARNINGS(declaration-after-statement)
- ENABLE_WARNINGS(shift-count-overflow)
- ENABLE_WARNINGS(unused-const-variable)
- ENABLE_WARNINGS(unused-function)
- ENABLE_WARNINGS(int-conversion)
+ enable_warnings(documentation)
+ disable_warnings(documentation-deprecated-sync)
+ disable_warnings(missing-field-initializers)
+ enable_warnings(strict-aliasing)
+ enable_warnings(strict-prototypes)
+ enable_warnings(declaration-after-statement)
+ enable_warnings(shift-count-overflow)
+ enable_warnings(unused-const-variable)
+ enable_warnings(unused-function)
+ enable_warnings(int-conversion)
+ enable_warnings(c11-extensions)
+ enable_warnings(c99-c11-compat)
# MinGW uses gcc, which expects POSIX formatting for printf, but
# uses the Windows C library, which uses its own format specifiers.
# Disable format specifier warnings.
- IF(MINGW)
- DISABLE_WARNINGS(format)
- DISABLE_WARNINGS(format-security)
- ELSE()
- ENABLE_WARNINGS(format)
- ENABLE_WARNINGS(format-security)
- ENDIF()
-
- IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
- DISABLE_WARNINGS(documentation-deprecated-sync)
- ENDIF()
-
- IF (PROFILE)
- SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
- SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
- ENDIF ()
+ if(MINGW)
+ disable_warnings(format)
+ disable_warnings(format-security)
+ else()
+ enable_warnings(format)
+ enable_warnings(format-security)
+ endif()
ENDIF()
# Ensure that MinGW provides the correct header files.
@@ -300,25 +286,6 @@ IF (BUILD_CLAR)
ADD_SUBDIRECTORY(tests)
ENDIF ()
-IF (TAGS)
- FIND_PROGRAM(CTAGS ctags)
- IF (NOT CTAGS)
- MESSAGE(FATAL_ERROR "Could not find ctags command")
- ENDIF ()
-
- FILE(GLOB_RECURSE SRC_ALL *.[ch])
-
- ADD_CUSTOM_COMMAND(
- OUTPUT tags
- COMMAND ${CTAGS} -a ${SRC_ALL}
- DEPENDS ${SRC_ALL}
- )
- ADD_CUSTOM_TARGET(
- do_tags ALL
- DEPENDS tags
- )
-ENDIF ()
-
IF (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF ()
diff --git a/COPYING b/COPYING
index c0f61fb..6bb39b0 100644
--- a/COPYING
+++ b/COPYING
@@ -420,7 +420,7 @@ The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
-
+
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -1019,3 +1019,111 @@ following restrictions are are met:
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+----------------------------------------------------------------------
+
+Portions of the OpenSSL headers are included under the OpenSSL license:
+
+Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+All rights reserved.
+
+This package is an SSL implementation written
+by Eric Young (eay@cryptsoft.com).
+The implementation was written so as to conform with Netscapes SSL.
+
+This library is free for commercial and non-commercial use as long as
+the following conditions are aheared to. The following conditions
+apply to all code found in this distribution, be it the RC4, RSA,
+lhash, DES, etc., code; not just the SSL code. The SSL documentation
+included with this distribution is covered by the same copyright terms
+except that the holder is Tim Hudson (tjh@cryptsoft.com).
+
+Copyright remains Eric Young's, and as such any Copyright notices in
+the code are not to be removed.
+If this package is used in a product, Eric Young should be given attribution
+as the author of the parts of the library used.
+This can be in the form of a textual message at program startup or
+in documentation (online or textual) provided with the package.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. All advertising materials mentioning features or use of this software
+ must display the following acknowledgement:
+ "This product includes cryptographic software written by
+ Eric Young (eay@cryptsoft.com)"
+ The word 'cryptographic' can be left out if the rouines from the library
+ being used are not cryptographic related :-).
+4. If you include any Windows specific code (or a derivative thereof) from
+ the apps directory (application code) you must include an acknowledgement:
+ "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+
+THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+The licence and distribution terms for any publically available version or
+derivative of this code cannot be changed. i.e. this code cannot simply be
+copied and put under another distribution licence
+[including the GNU Public Licence.]
+
+====================================================================
+Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+3. All advertising materials mentioning features or use of this
+ software must display the following acknowledgment:
+ "This product includes software developed by the OpenSSL Project
+ for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+
+4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ endorse or promote products derived from this software without
+ prior written permission. For written permission, please contact
+ openssl-core@openssl.org.
+
+5. Products derived from this software may not be called "OpenSSL"
+ nor may "OpenSSL" appear in their names without prior written
+ permission of the OpenSSL Project.
+
+6. Redistributions of any form whatsoever must retain the following
+ acknowledgment:
+ "This product includes software developed by the OpenSSL Project
+ for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+
+THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/README.md b/README.md
index 9dafffe..c5ef022 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,10 @@ libgit2 - the Git linkable library
| Build Status | |
| ------------ | - |
-| **master** branch CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=master)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=master) |
-| **v0.28 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.28)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.28) |
-| **v0.27 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.27)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.27) |
-| **v0.26 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.26)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.26) |
-| **Nightly** builds | [![Azure Pipelines Build Status](https://libgit2.visualstudio.com/libgit2/_apis/build/status/nightly?branchName=master&label=Full+Build)](https://libgit2.visualstudio.com/libgit2/_build/latest?definitionId=9&branchName=master) [![Coverity Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/coverity?branchName=master&label=Coverity+Build)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=21?branchName=master) [![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) |
+| **main** branch CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush) |
+| **v1.1 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.1&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.1) |
+| **v1.0 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v1.0)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v1.0) |
+| **Nightly** builds | [![Nightly Build](https://github.com/libgit2/libgit2/workflows/Nightly%20Build/badge.svg)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22Nightly+Build%22) [![Coverity Scan Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) |
`libgit2` is a portable, pure C implementation of the Git core methods
provided as a linkable library with a solid API, allowing to build Git
@@ -34,6 +33,7 @@ Additionally, the example code has been released to the public domain (see the
Table of Contents
=================
+* [Using libgit2](#using-libgit2)
* [Quick Start](#quick-start)
* [Getting Help](#getting-help)
* [What It Can Do](#what-it-can-do)
@@ -48,10 +48,33 @@ Table of Contents
* [Compiler and linker options](#compiler-and-linker-options)
* [MacOS X](#macos-x)
* [Android](#android)
+ * [MinGW](#mingw)
* [Language Bindings](#language-bindings)
* [How Can I Contribute?](#how-can-i-contribute)
* [License](#license)
+Using libgit2
+=============
+
+Most of these instructions assume that you're writing an application
+in C and want to use libgit2 directly. If you're _not_ using C,
+and you're writing in a different language or platform like .NET,
+Node.js, or Ruby, then there is probably a
+"[language binding](#language-bindings)" that you can use to take care
+of the messy tasks of calling into native code.
+
+But if you _do_ want to use libgit2 directly - because you're building
+an application in C - then you may be able use an existing binary.
+There are packages for the
+[vcpkg](https://github.com/Microsoft/vcpkg) and
+[conan](https://conan.io/center/libgit2)
+package managers. And libgit2 is available in
+[Homebrew](https://formulae.brew.sh/formula/libgit2) and most Linux
+distributions.
+
+However, these versions _may_ be outdated and we recommend using the
+latest version if possible. Thankfully libgit2 is not hard to compile.
+
Quick Start
===========
@@ -81,7 +104,8 @@ Getting Help
**Chat with us**
-- via IRC: join [#libgit2](https://webchat.freenode.net/#libgit2) on Freenode
+- via IRC: join [#libgit2](https://web.libera.chat/#libgit2) on
+ [libera](https://libera.chat).
- via Slack: visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up,
then join us in `#libgit2`
@@ -201,6 +225,8 @@ On most systems you can build the library using the following commands
Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
+If you're not familiar with CMake, [a more detailed explanation](https://preshing.com/20170511/how-to-build-a-cmake-based-project/) may be helpful.
+
Running Tests
-------------
@@ -219,7 +245,7 @@ run the index tests:
$ ./libgit2_clar -sindex
To run a single test named `index::racy::diff`, which corresponds to the test
-function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23):
+function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/main/tests/index/racy.c#L23):
$ ./libgit2_clar -sindex::racy::diff
@@ -229,7 +255,7 @@ applicable to your platform or is particularly expensive.
**Note:** There should be _no_ failing tests when you build an unmodified
source tree from a [release](https://github.com/libgit2/libgit2/releases),
-or from the [master branch](https://github.com/libgit2/libgit2/tree/master).
+or from the [main branch](https://github.com/libgit2/libgit2/tree/main).
Please contact us or [open an issue](https://github.com/libgit2/libgit2/issues)
if you see test failures.
@@ -248,9 +274,9 @@ For more advanced use or questions about CMake please read <https://cmake.org/Wi
The following CMake variables are declared:
-- `BIN_INSTALL_DIR`: Where to install binaries to.
-- `LIB_INSTALL_DIR`: Where to install libraries to.
-- `INCLUDE_INSTALL_DIR`: Where to install headers to.
+- `CMAKE_INSTALL_BINDIR`: Where to install binaries to.
+- `CMAKE_INSTALL_LIBDIR`: Where to install libraries to.
+- `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
@@ -305,6 +331,20 @@ with full path to the toolchain):
Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command
when configuring.
+MinGW
+-----
+
+If you want to build the library in MinGW environment with SSH support enabled,
+you may need to pass `-DCMAKE_LIBRARY_PATH="${MINGW_PREFIX}/${MINGW_CHOST}/lib/"` flag
+to CMake when configuring. This is because CMake cannot find the Win32 libraries in
+MinGW folders by default and you might see an error message stating that CMake
+could not resolve `ws2_32` library during configuration.
+
+Another option would be to install `msys2-w32api-runtime` package before configuring.
+This package installs the Win32 libraries into `/usr/lib` folder which is by default
+recognized as the library path by CMake. Please note though that this package is meant
+for MSYS subsystem which is different from MinGW.
+
Language Bindings
==================================
@@ -318,6 +358,7 @@ Here are the bindings to libgit2 that are currently available:
* dlibgit <https://github.com/s-ludwig/dlibgit>
* Delphi
* GitForDelphi <https://github.com/libgit2/GitForDelphi>
+ * libgit2-delphi <https://github.com/todaysoftware/libgit2-delphi>
* Erlang
* Geef <https://github.com/carlosmn/geef>
* Go
@@ -330,6 +371,8 @@ Here are the bindings to libgit2 that are currently available:
* hgit2 <https://github.com/jwiegley/gitlib>
* Java
* Jagged <https://github.com/ethomson/jagged>
+* Javascript / WebAssembly ( browser and nodejs )
+ * WASM-git <https://github.com/petersalomonsen/wasm-git>
* Julia
* LibGit2.jl <https://github.com/JuliaLang/julia/tree/master/stdlib/LibGit2>
* Lua
@@ -353,6 +396,7 @@ Here are the bindings to libgit2 that are currently available:
* Python
* pygit2 <https://github.com/libgit2/pygit2>
* R
+ * gert <https://docs.ropensci.org/gert>
* git2r <https://github.com/ropensci/git2r>
* Ruby
* Rugged <https://github.com/libgit2/rugged>
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
deleted file mode 100644
index 2b593dd..0000000
--- a/azure-pipelines.yml
+++ /dev/null
@@ -1,186 +0,0 @@
-resources:
-- repo: self
-
-trigger:
-- master
-- maint/*
-
-jobs:
-- job: linux_amd64_xenial_gcc_openssl
- displayName: 'Linux (amd64; Xenial; GCC; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: azure-pipelines/docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
- GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
-
-- job: linux_amd64_xenial_gcc_mbedtls
- displayName: 'Linux (amd64; Xenial; GCC; mbedTLS)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: azure-pipelines/docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
- GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
-
-- job: linux_amd64_xenial_clang_openssl
- displayName: 'Linux (amd64; Xenial; Clang; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: azure-pipelines/docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=clang
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
- GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
-
-- job: linux_amd64_xenial_clang_mbedtls
- displayName: 'Linux (amd64; Xenial; Clang; mbedTLS)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: azure-pipelines/docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=clang
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
- GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
-
-- job: macos
- displayName: 'macOS'
- pool:
- vmImage: 'macOS 10.13'
- steps:
- - bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh'
- displayName: Setup
- - template: azure-pipelines/bash.yml
- parameters:
- environmentVariables:
- TMPDIR: $(Agent.TempDirectory)
- PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
- CMAKE_GENERATOR: Ninja
- CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
- SKIP_SSH_TESTS: true
- GITTEST_NEGOTIATE_PASSWORD: ${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
-
-- job: windows_vs_amd64
- displayName: 'Windows (amd64; Visual Studio)'
- pool: Hosted
- steps:
- - template: azure-pipelines/bash.yml
- parameters:
- environmentVariables:
- CMAKE_GENERATOR: Visual Studio 12 2013 Win64
- CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
- SKIP_SSH_TESTS: true
- SKIP_NEGOTIATE_TESTS: true
-
-- job: windows_vs_x86
- displayName: 'Windows (x86; Visual Studio)'
- pool: Hosted
- steps:
- - template: azure-pipelines/bash.yml
- parameters:
- environmentVariables:
- CMAKE_GENERATOR: Visual Studio 12 2013
- CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
- SKIP_SSH_TESTS: true
- SKIP_NEGOTIATE_TESTS: true
-
-- job: windows_mingw_amd64
- displayName: 'Windows (amd64; MinGW)'
- pool: Hosted
- steps:
- - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
- displayName: Setup
- env:
- TEMP: $(Agent.TempDirectory)
- ARCH: amd64
- - template: azure-pipelines/bash.yml
- parameters:
- environmentVariables:
- BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
- CMAKE_GENERATOR: MinGW Makefiles
- CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
- SKIP_SSH_TESTS: true
- SKIP_NEGOTIATE_TESTS: true
-
-- job: windows_mingw_x86
- displayName: 'Windows (x86; MinGW)'
- pool: Hosted
- steps:
- - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
- displayName: Setup
- workingDirectory: '$(Build.BinariesDirectory)'
- env:
- TEMP: $(Agent.TempDirectory)
- ARCH: x86
- - template: azure-pipelines/bash.yml
- parameters:
- environmentVariables:
- BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
- CMAKE_GENERATOR: MinGW Makefiles
- CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
- SKIP_SSH_TESTS: true
- SKIP_NEGOTIATE_TESTS: true
-
-- job: documentation
- displayName: 'Generate Documentation'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - script: |
- cd $(Build.SourcesDirectory)/azure-pipelines/docker
- docker build -t libgit2/docurium --build-arg BASE=ubuntu:trusty -f docurium .
- displayName: 'Build Docker image'
- - script: |
- git config user.name 'Documentation Generation'
- git config user.email 'libgit2@users.noreply.github.com'
- git branch gh-pages origin/gh-pages
- docker run --rm -v $(Build.SourcesDirectory):/home/libgit2/source -w /home/libgit2/source libgit2/docurium:latest cm doc api.docurium
- git checkout gh-pages
- cp -R * '$(Build.BinariesDirectory)'
- displayName: 'Generate Documentation'
- - task: archivefiles@2
- displayName: 'Archive Documentation'
- inputs:
- rootFolderOrFile: '$(Build.BinariesDirectory)'
- includeRootFolder: false
- archiveFile: '$(Build.ArtifactStagingDirectory)/api-documentation.zip'
- - task: publishbuildartifacts@1
- displayName: 'Upload Documentation Artifact'
- inputs:
- pathToPublish: '$(Build.ArtifactStagingDirectory)'
- artifactName: 'docs'
- - script: |
- git remote -v
- echo 'machine github.com' > ~/.netrc
- echo 'login $(GITHUB_USERNAME)' >> ~/.netrc
- echo 'password $(GITHUB_PAT)' >> ~/.netrc
- git push origin gh-pages
- displayName: 'Publish Documentation'
- condition: and(eq(variables['Build.Repository.Name'], 'libgit2/libgit2'), eq(variables['Build.Reason'], 'IndividualCI'))
diff --git a/azure-pipelines/bash.yml b/azure-pipelines/bash.yml
deleted file mode 100644
index 33a442b..0000000
--- a/azure-pipelines/bash.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-# These are the steps used for building on machines with bash.
-steps:
-- bash: . '$(Build.SourcesDirectory)/azure-pipelines/build.sh'
- displayName: Build
- workingDirectory: '$(Build.BinariesDirectory)'
- env: ${{ parameters.environmentVariables }}
-- bash: . '$(Build.SourcesDirectory)/azure-pipelines/test.sh'
- displayName: Test
- workingDirectory: '$(Build.BinariesDirectory)'
- env: ${{ parameters.environmentVariables }}
-- task: PublishTestResults@2
- displayName: Publish Test Results
- condition: succeededOrFailed()
- inputs:
- testResultsFiles: 'results_*.xml'
- searchFolder: '$(Build.BinariesDirectory)'
- mergeTestResults: true
diff --git a/azure-pipelines/build.sh b/azure-pipelines/build.sh
deleted file mode 100755
index 27e2f3e..0000000
--- a/azure-pipelines/build.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env bash
-#
-# Environment variables:
-#
-# SOURCE_DIR: Set to the directory of the libgit2 source (optional)
-# If not set, it will be derived relative to this script.
-
-set -e
-
-SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
-BUILD_DIR=$(pwd)
-BUILD_PATH=${BUILD_PATH:=$PATH}
-CMAKE=$(which cmake)
-CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles}
-
-indent() { sed "s/^/ /"; }
-
-echo "Source directory: ${SOURCE_DIR}"
-echo "Build directory: ${BUILD_DIR}"
-echo ""
-
-if [ "$(uname -s)" = "Darwin" ]; then
- echo "macOS version:"
- sw_vers | indent
-fi
-
-if [ -f "/etc/debian_version" ]; then
- echo "Debian version:"
- (source /etc/lsb-release && echo "${DISTRIB_DESCRIPTION}") | indent
-fi
-
-echo "Kernel version:"
-uname -a 2>&1 | indent
-
-echo "CMake version:"
-env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent
-
-if test -n "$CC"; then
- echo "Compiler version:"
- "$CC" --version 2>&1 | indent
-fi
-echo ""
-
-echo "##############################################################################"
-echo "## Configuring build environment"
-echo "##############################################################################"
-
-echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS}
-env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS}
-
-echo ""
-echo "##############################################################################"
-echo "## Building libgit2"
-echo "##############################################################################"
-
-env PATH="$BUILD_PATH" "$CMAKE" --build .
diff --git a/azure-pipelines/coverity.sh b/azure-pipelines/coverity.sh
deleted file mode 100755
index 14faadc..0000000
--- a/azure-pipelines/coverity.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash -e
-
-if test -z "$COVERITY_TOKEN"
-then
- echo "Need to set a coverity token"
- exit 1
-fi
-
-case $(uname -m) in
- i?86)
- BITS=32;;
- amd64|x86_64)
- BITS=64;;
- *)
- echo "Unsupported arch '$(uname -m)'"
- exit 1;;
-esac
-
-SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
-SOURCE_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
-BUILD_DIR=${SOURCE_DIR}/coverity-build
-TOOL_DIR=${BUILD_DIR}/coverity-tools
-
-# Install coverity tools
-if ! test -d "$TOOL_DIR"
-then
- mkdir -p "$TOOL_DIR"
- curl --silent --location --data "project=libgit2&token=$COVERITY_TOKEN" "$SCAN_TOOL" |
- tar -xzC "$TOOL_DIR"
- ln -s "$(find "$TOOL_DIR" -type d -name 'cov-analysis*')" "$TOOL_DIR"/cov-analysis
-fi
-
-cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_DIR"/cov-analysis/config/
-
-# Build libgit2 with Coverity
-mkdir -p "$BUILD_DIR"
-cd "$BUILD_DIR"
-cmake "$SOURCE_DIR"
-COVERITY_UNSUPPORTED=1 \
- "$TOOL_DIR/cov-analysis/bin/cov-build" --dir cov-int \
- cmake --build .
-
-# Upload results
-tar -czf libgit2.tgz cov-int
-REVISION=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
-HTML="$(curl \
- --silent \
- --write-out "\n%{http_code}" \
- --form token="$COVERITY_TOKEN" \
- --form email=libgit2@gmail.com \
- --form file=@libgit2.tgz \
- --form version="$REVISION" \
- --form description="libgit2 build" \
- https://scan.coverity.com/builds?project=libgit2)"
-
-# Status code is the last line
-STATUS_CODE="$(echo "$HTML" | tail -n1)"
-if test "${STATUS_CODE}" != 200 && test "${STATUS_CODE}" != 201
-then
- echo "Received error code ${STATUS_CODE} from Coverity"
- exit 1
-fi
diff --git a/azure-pipelines/coverity.yml b/azure-pipelines/coverity.yml
deleted file mode 100644
index 10450af..0000000
--- a/azure-pipelines/coverity.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-resources:
-- repo: self
-
-jobs:
-- job: coverity
- displayName: 'Coverity'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - script: |
- cd $(Build.SourcesDirectory)/azure-pipelines/docker
- docker build -t libgit2/xenial --build-arg BASE=ubuntu:xenial -f xenial .
- displayName: 'Build Docker image'
- - task: Docker@0
- displayName: Analyze
- inputs:
- action: 'Run an image'
- imageName: libgit2/xenial
- volumes: |
- $(Build.SourcesDirectory):/home/libgit2/source
- $(Build.BinariesDirectory):/home/libgit2/build
- envVars: |
- COVERITY_TOKEN=$(COVERITY_TOKEN)
- workDir: '/home/libgit2/build'
- containerCommand: '/home/libgit2/source/azure-pipelines/coverity.sh'
- detached: false
diff --git a/azure-pipelines/docker.yml b/azure-pipelines/docker.yml
deleted file mode 100644
index 0e1988c..0000000
--- a/azure-pipelines/docker.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-# These are the steps used in a container-based build in VSTS.
-steps:
-- ${{ if eq(parameters.qemu, 'true') }}:
- - script: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- displayName: 'Register Docker QEMU'
-
-- task: cache@2
- displayName: Cache Docker layers
- inputs:
- key: docker
- path: /tmp/dockercache
-- script: |
- if [ -f /tmp/dockercache/${{parameters.docker.image}}.tar ]; then docker load < /tmp/dockercache/${{parameters.docker.image}}.tar; fi
- displayName: 'Load Docker cache'
-- script: |
- cd $(Build.SourcesDirectory)/azure-pipelines/docker
- docker build -t libgit2/${{parameters.docker.image}} --build-arg BASE=${{parameters.docker.base}} -f ${{parameters.docker.image}} .
- if [ ! -d /tmp/dockercache ]; then mkdir /tmp/dockercache; fi
- docker save libgit2/${{parameters.docker.image}} $(docker history -q libgit2/${{parameters.docker.image}} | grep -v '<missing>') > /tmp/dockercache/${{parameters.docker.image}}.tar
- displayName: 'Build Docker image'
-- task: docker@0
- displayName: Build
- inputs:
- action: 'Run an image'
- imageName: libgit2/${{ parameters.docker.image }}
- volumes: |
- $(Build.SourcesDirectory):/home/libgit2/source
- $(Build.BinariesDirectory):/home/libgit2/build
- envVars: ${{ parameters.environmentVariables }}
- workDir: '/home/libgit2/build'
- containerCommand: '/home/libgit2/source/azure-pipelines/build.sh'
- detached: false
-- task: docker@0
- displayName: Test
- inputs:
- action: 'Run an image'
- imageName: libgit2/${{ parameters.docker.image }}
- volumes: |
- $(Build.SourcesDirectory):/home/libgit2/source
- $(Build.BinariesDirectory):/home/libgit2/build
- envVars: ${{ parameters.environmentVariables }}
- workDir: '/home/libgit2/build'
- containerCommand: '/home/libgit2/source/azure-pipelines/test.sh'
- detached: false
-- task: publishtestresults@2
- displayName: Publish Test Results
- condition: succeededOrFailed()
- inputs:
- testResultsFiles: 'results_*.xml'
- searchFolder: '$(Build.BinariesDirectory)'
- mergeTestResults: true
diff --git a/azure-pipelines/docker/bionic b/azure-pipelines/docker/bionic
deleted file mode 100644
index 83d96ab..0000000
--- a/azure-pipelines/docker/bionic
+++ /dev/null
@@ -1,41 +0,0 @@
-ARG BASE
-FROM $BASE
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- clang \
- cmake \
- curl \
- gcc \
- git \
- gosu \
- libcurl4-openssl-dev \
- libpcre3-dev \
- libssh2-1-dev \
- libssl-dev \
- libz-dev \
- ninja-build \
- openjdk-8-jre-headless \
- openssh-server \
- openssl \
- pkgconf \
- python \
- valgrind \
- && \
- rm -rf /var/lib/apt/lists/*
-RUN mkdir /var/run/sshd
-
-RUN cd /tmp && \
- curl -LO https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz && \
- tar -xf mbedtls-2.16.2-apache.tgz && \
- rm -f mbedtls-2.16.2-apache.tgz && \
- cd mbedtls-2.16.2 && \
- scripts/config.pl set MBEDTLS_MD4_C 1 && \
- CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \
- ninja install && \
- cd .. && \
- rm -rf mbedtls-2.16.2
-
-COPY entrypoint.sh /usr/local/bin/entrypoint.sh
-RUN chmod a+x /usr/local/bin/entrypoint.sh
-
-ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
diff --git a/azure-pipelines/docker/docurium b/azure-pipelines/docker/docurium
deleted file mode 100644
index 15d10a7..0000000
--- a/azure-pipelines/docker/docurium
+++ /dev/null
@@ -1,6 +0,0 @@
-FROM debian:jessie-slim
-ARG CACHEBUST=1
-RUN apt-get update
-RUN apt install -y cmake pkg-config ruby ruby-dev llvm libclang-3.5-dev libssl-dev python-pygments
-ARG CACHEBUST=1
-RUN gem install docurium
diff --git a/azure-pipelines/docker/entrypoint.sh b/azure-pipelines/docker/entrypoint.sh
deleted file mode 100644
index 2118a2b..0000000
--- a/azure-pipelines/docker/entrypoint.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-useradd --shell /bin/bash --create-home libgit2
-chown -R $(id -u libgit2) /home/libgit2
-exec gosu libgit2 "$@"
diff --git a/azure-pipelines/docker/xenial b/azure-pipelines/docker/xenial
deleted file mode 100644
index 6e3a469..0000000
--- a/azure-pipelines/docker/xenial
+++ /dev/null
@@ -1,68 +0,0 @@
-ARG BASE
-FROM $BASE AS apt
-RUN apt-get update && \
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
- bzip2 \
- clang \
- cmake \
- curl \
- gcc \
- git \
- gosu \
- krb5-user \
- libcurl4-gnutls-dev \
- libgcrypt20-dev \
- libkrb5-dev \
- libpcre3-dev \
- libssl-dev \
- libz-dev \
- make \
- ninja-build \
- openjdk-8-jre-headless \
- openssh-server \
- openssl \
- pkgconf \
- python \
- valgrind
-
-FROM apt AS mbedtls
-RUN cd /tmp && \
- curl -LO https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz && \
- tar -xf mbedtls-2.16.2-apache.tgz && \
- rm -f mbedtls-2.16.2-apache.tgz && \
- cd mbedtls-2.16.2 && \
- scripts/config.pl set MBEDTLS_MD4_C 1 && \
- CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \
- ninja install && \
- cd .. && \
- rm -rf mbedtls-2.16.2
-
-FROM mbedtls AS libssh2
-RUN cd /tmp && \
- curl -LO https://www.libssh2.org/download/libssh2-1.8.2.tar.gz && \
- tar -xf libssh2-1.8.2.tar.gz && \
- rm -f libssh2-1.8.2.tar.gz && \
- cd libssh2-1.8.2 && \
- CFLAGS=-fPIC cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt . && \
- ninja install && \
- cd .. && \
- rm -rf libssh2-1.8.2
-
-FROM libssh2 AS valgrind
-RUN cd /tmp && \
- curl -LO https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 && \
- tar -xf valgrind-3.15.0.tar.bz2 && \
- rm -f valgrind-3.15.0.tar.bz2 && \
- cd valgrind-3.15.0 && \
- ./configure && \
- make && \
- make install && \
- cd .. && \
- rm -rf valgrind-3.15.0
-
-FROM valgrind AS configure
-COPY entrypoint.sh /usr/local/bin/entrypoint.sh
-RUN chmod a+x /usr/local/bin/entrypoint.sh
-RUN mkdir /var/run/sshd
-
-ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml
deleted file mode 100644
index a193747..0000000
--- a/azure-pipelines/nightly.yml
+++ /dev/null
@@ -1,215 +0,0 @@
-resources:
-- repo: self
-
-jobs:
-- job: linux_amd64_xenial_gcc_openssl
- displayName: 'Linux (amd64; Xenial; GCC; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- RUN_INVASIVE_TESTS=true
-
-- job: linux_amd64_xenial_gcc_mbedtls
- displayName: 'Linux (amd64; Xenial; GCC; mbedTLS)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- RUN_INVASIVE_TESTS=true
-
-- job: linux_amd64_xenial_clang_openssl
- displayName: 'Linux (amd64; Xenial; Clang; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=clang
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- RUN_INVASIVE_TESTS=true
-
-- job: linux_amd64_xenial_clang_mbedtls
- displayName: 'Linux (amd64; Xenial; Clang; mbedTLS)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- docker:
- image: xenial
- base: ubuntu:xenial
- environmentVariables: |
- CC=clang
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- RUN_INVASIVE_TESTS=true
-
-- job: macos
- displayName: 'macOS'
- pool:
- vmImage: 'macOS 10.13'
- steps:
- - bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh'
- displayName: Setup
- - template: bash.yml
- parameters:
- environmentVariables:
- TMPDIR: $(Agent.TempDirectory)
- PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
- CMAKE_GENERATOR: Ninja
- CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
- RUN_INVASIVE_TESTS: true
- SKIP_SSH_TESTS: true
-
-- job: windows_vs_amd64
- displayName: 'Windows (amd64; Visual Studio)'
- pool: Hosted
- steps:
- - template: bash.yml
- parameters:
- environmentVariables:
- CMAKE_GENERATOR: Visual Studio 12 2013 Win64
- CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
- RUN_INVASIVE_TESTS: true
- SKIP_SSH_TESTS: true
-
-- job: windows_vs_x86
- displayName: 'Windows (x86; Visual Studio)'
- pool: Hosted
- steps:
- - template: bash.yml
- parameters:
- environmentVariables:
- CMAKE_GENERATOR: Visual Studio 12 2013
- CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
- RUN_INVASIVE_TESTS: true
- SKIP_SSH_TESTS: true
-
-- job: windows_mingw_amd64
- displayName: 'Windows (amd64; MinGW)'
- pool: Hosted
- steps:
- - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
- displayName: Setup
- env:
- TEMP: $(Agent.TempDirectory)
- ARCH: amd64
- - template: bash.yml
- parameters:
- environmentVariables:
- BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
- CMAKE_GENERATOR: MinGW Makefiles
- CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
- RUN_INVASIVE_TESTS: true
- SKIP_SSH_TESTS: true
-
-- job: windows_mingw_x86
- displayName: 'Windows (x86; MinGW)'
- pool: Hosted
- steps:
- - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
- displayName: Setup
- workingDirectory: '$(Build.BinariesDirectory)'
- env:
- TEMP: $(Agent.TempDirectory)
- ARCH: x86
- - template: bash.yml
- parameters:
- environmentVariables:
- BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
- CMAKE_GENERATOR: MinGW Makefiles
- CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
- RUN_INVASIVE_TESTS: true
- SKIP_SSH_TESTS: true
-
-- job: linux_x86_bionic_gcc_openssl
- displayName: 'Linux (x86; Bionic; GCC; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- qemu: 'true'
- docker:
- image: bionic
- base: multiarch/ubuntu-core:x86-bionic
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- RUN_INVASIVE_TESTS=true
-
-- job: linux_x86_bionic_clang_openssl
- displayName: 'Linux (x86; Bionic; Clang; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- qemu: 'true'
- docker:
- image: bionic
- base: multiarch/ubuntu-core:x86-bionic
- environmentVariables: |
- CC=clang
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
- RUN_INVASIVE_TESTS=true
-
-- job: linux_arm32_bionic_gcc_openssl
- displayName: 'Linux (arm32; Bionic; GCC; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- qemu: 'true'
- docker:
- image: bionic
- base: multiarch/ubuntu-core:armhf-bionic
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
- RUN_INVASIVE_TESTS=true
- SKIP_PROXY_TESTS=true
-
-- job: linux_arm64_bionic_gcc_openssl
- displayName: 'Linux (arm64; Bionic; GCC; OpenSSL)'
- pool:
- vmImage: 'Ubuntu 16.04'
- steps:
- - template: docker.yml
- parameters:
- qemu: 'true'
- docker:
- image: bionic
- base: multiarch/ubuntu-core:arm64-bionic
- environmentVariables: |
- CC=gcc
- CMAKE_GENERATOR=Ninja
- CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
- RUN_INVASIVE_TESTS=true
- SKIP_PROXY_TESTS=true
diff --git a/azure-pipelines/setup-linux.sh b/azure-pipelines/setup-linux.sh
deleted file mode 100755
index c5ecb55..0000000
--- a/azure-pipelines/setup-linux.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-set -e
-set -x
-
-TMPDIR=${TMPDIR:-/tmp}
-
-if [ -z "$SKIP_APT" ]; then
- apt-get update
- apt-get -y install build-essential pkg-config clang cmake openssl libssl-dev libssh2-1-dev libcurl4-gnutls-dev openssh-server
-fi
-
-mkdir -p /var/run/sshd
-
-if [ "$MBEDTLS" ]; then
- MBEDTLS_DIR=${MBEDTLS_DIR:-$(mktemp -d ${TMPDIR}/mbedtls.XXXXXXXX)}
-
- git clone --depth 10 --single-branch --branch mbedtls-2.6.1 https://github.com/ARMmbed/mbedtls.git ${MBEDTLS_DIR}
- cd ${MBEDTLS_DIR}
-
- CFLAGS=-fPIC cmake -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON .
- cmake --build .
-
- if [ -z "$SKIP_MBEDTLS_INSTALL" ]; then
- make install
- fi
-fi
diff --git a/azure-pipelines/setup-mingw.sh b/azure-pipelines/setup-mingw.sh
deleted file mode 100755
index 1172c20..0000000
--- a/azure-pipelines/setup-mingw.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh -e
-
-echo "##############################################################################"
-echo "## Downloading mingw"
-echo "##############################################################################"
-
-case "$ARCH" in
- amd64)
- MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip";;
- x86)
- MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";;
-esac
-
-curl -s -L "$MINGW_URI" -o "$TEMP"/mingw-"$ARCH".zip
-unzip -q "$TEMP"/mingw-"$ARCH".zip -d "$TEMP"
diff --git a/azure-pipelines/setup-osx.sh b/azure-pipelines/setup-osx.sh
deleted file mode 100755
index 2e630ee..0000000
--- a/azure-pipelines/setup-osx.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-set -x
-
-brew update
-brew install pkgconfig zlib curl openssl libssh2 ninja
-
-ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib
diff --git a/azure-pipelines/test.sh b/azure-pipelines/test.sh
deleted file mode 100755
index dfd9960..0000000
--- a/azure-pipelines/test.sh
+++ /dev/null
@@ -1,324 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-if [ -n "$SKIP_TESTS" ]; then
- exit 0
-fi
-
-# Windows doesn't run the NTLM tests properly (yet)
-if [[ "$(uname -s)" == MINGW* ]]; then
- SKIP_NTLM_TESTS=1
-fi
-
-SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
-BUILD_DIR=$(pwd)
-TMPDIR=${TMPDIR:-/tmp}
-USER=${USER:-$(whoami)}
-
-SUCCESS=1
-
-cleanup() {
- echo "Cleaning up..."
-
- if [ ! -z "$GITDAEMON_PID" ]; then
- echo "Stopping git daemon..."
- kill $GITDAEMON_PID
- fi
-
- if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then
- echo "Stopping SSH..."
- kill $(cat "${SSHD_DIR}/pid")
- fi
-
- echo "Done."
-}
-
-run_test() {
- if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then
- ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY
- else
- ATTEMPTS_REMAIN=1
- fi
-
- FAILED=0
- while [[ "$ATTEMPTS_REMAIN" > 0 ]]; do
- if [ "$FAILED" -eq 1 ]; then
- echo ""
- echo "Re-running flaky ${1} tests..."
- echo ""
- fi
-
- RETURN_CODE=0
-
- CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true
-
- if [ "$RETURN_CODE" -eq 0 ]; then
- FAILED=0
- break
- fi
-
- echo "Test exited with code: $RETURN_CODE"
- ATTEMPTS_REMAIN="$(($ATTEMPTS_REMAIN-1))"
- FAILED=1
- done
-
- if [ "$FAILED" -ne 0 ]; then
- SUCCESS=0
- fi
-}
-
-# Configure the test environment; run them early so that we're certain
-# that they're started by the time we need them.
-
-echo "##############################################################################"
-echo "## Configuring test environment"
-echo "##############################################################################"
-
-if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
- echo "Starting git daemon..."
- GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
- git init --bare "${GITDAEMON_DIR}/test.git"
- git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
- GITDAEMON_PID=$!
-fi
-
-if [ -z "$SKIP_PROXY_TESTS" ]; then
- curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar >poxyproxy.jar
-
- echo ""
- echo "Starting HTTP proxy (Basic)..."
- java -jar poxyproxy.jar --address 127.0.0.1 --port 8080 --credentials foo:bar --auth-type basic --quiet &
-
- echo ""
- echo "Starting HTTP proxy (NTLM)..."
- java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
-fi
-
-if [ -z "$SKIP_NTLM_TESTS" ]; then
- curl -L https://github.com/ethomson/poxygit/releases/download/v0.4.0/poxygit-0.4.0.jar >poxygit.jar
-
- echo ""
- echo "Starting HTTP server..."
- NTLM_DIR=`mktemp -d ${TMPDIR}/ntlm.XXXXXXXX`
- git init --bare "${NTLM_DIR}/test.git"
- java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${NTLM_DIR}" &
-fi
-
-if [ -z "$SKIP_SSH_TESTS" ]; then
- echo "Starting ssh daemon..."
- HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
- SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
- git init --bare "${SSHD_DIR}/test.git"
- cat >"${SSHD_DIR}/sshd_config" <<-EOF
- Port 2222
- ListenAddress 0.0.0.0
- Protocol 2
- HostKey ${SSHD_DIR}/id_rsa
- PidFile ${SSHD_DIR}/pid
- AuthorizedKeysFile ${HOME}/.ssh/authorized_keys
- LogLevel DEBUG
- RSAAuthentication yes
- PasswordAuthentication yes
- PubkeyAuthentication yes
- ChallengeResponseAuthentication no
- StrictModes no
- # Required here as sshd will simply close connection otherwise
- UsePAM no
- EOF
- ssh-keygen -t rsa -f "${SSHD_DIR}/id_rsa" -N "" -q
- /usr/sbin/sshd -f "${SSHD_DIR}/sshd_config" -E "${SSHD_DIR}/log"
-
- # Set up keys
- mkdir "${HOME}/.ssh"
- ssh-keygen -t rsa -f "${HOME}/.ssh/id_rsa" -N "" -q
- cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys"
- while read algorithm key comment; do
- echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts"
- done <"${SSHD_DIR}/id_rsa.pub"
-
- # Get the fingerprint for localhost and remove the colons so we can
- # parse it as a hex number. Older versions have a different output
- # format.
- if [[ $(ssh -V 2>&1) == OpenSSH_6* ]]; then
- SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
- else
- SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
- fi
-fi
-
-# Run the tests that do not require network connectivity.
-
-if [ -z "$SKIP_OFFLINE_TESTS" ]; then
- echo ""
- echo "##############################################################################"
- echo "## Running (offline) tests"
- echo "##############################################################################"
-
- run_test offline
-fi
-
-if [ -n "$RUN_INVASIVE_TESTS" ]; then
- echo ""
- echo "Running invasive tests"
- echo ""
-
- export GITTEST_INVASIVE_FS_SIZE=1
- export GITTEST_INVASIVE_MEMORY=1
- export GITTEST_INVASIVE_SPEED=1
- run_test invasive
- unset GITTEST_INVASIVE_FS_SIZE
- unset GITTEST_INVASIVE_MEMORY
- unset GITTEST_INVASIVE_SPEED
-fi
-
-if [ -z "$SKIP_ONLINE_TESTS" ]; then
- # Run the various online tests. The "online" test suite only includes the
- # default online tests that do not require additional configuration. The
- # "proxy" and "ssh" test suites require further setup.
-
- echo ""
- echo "##############################################################################"
- echo "## Running (online) tests"
- echo "##############################################################################"
-
- export GITTEST_FLAKY_RETRY=5
- run_test online
- unset GITTEST_FLAKY_RETRY
-fi
-
-if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
- echo ""
- echo "Running gitdaemon tests"
- echo ""
-
- export GITTEST_REMOTE_URL="git://localhost/test.git"
- run_test gitdaemon
- unset GITTEST_REMOTE_URL
-fi
-
-if [ -z "$SKIP_PROXY_TESTS" ]; then
- echo ""
- echo "Running proxy tests (Basic authentication)"
- echo ""
-
- export GITTEST_REMOTE_PROXY_HOST="localhost:8080"
- export GITTEST_REMOTE_PROXY_USER="foo"
- export GITTEST_REMOTE_PROXY_PASS="bar"
- run_test proxy
- unset GITTEST_REMOTE_PROXY_HOST
- unset GITTEST_REMOTE_PROXY_USER
- unset GITTEST_REMOTE_PROXY_PASS
-
- echo ""
- echo "Running proxy tests (NTLM authentication)"
- echo ""
-
- export GITTEST_REMOTE_PROXY_HOST="localhost:8090"
- export GITTEST_REMOTE_PROXY_USER="foo"
- export GITTEST_REMOTE_PROXY_PASS="bar"
- export GITTEST_FLAKY_RETRY=5
- run_test proxy
- unset GITTEST_FLAKY_RETRY
- unset GITTEST_REMOTE_PROXY_HOST
- unset GITTEST_REMOTE_PROXY_USER
- unset GITTEST_REMOTE_PROXY_PASS
-fi
-
-if [ -z "$SKIP_NTLM_TESTS" ]; then
- echo ""
- echo "Running NTLM tests (IIS emulation)"
- echo ""
-
- export GITTEST_REMOTE_URL="http://localhost:9000/ntlm/test.git"
- export GITTEST_REMOTE_USER="foo"
- export GITTEST_REMOTE_PASS="baz"
- run_test auth_clone_and_push
- unset GITTEST_REMOTE_URL
- unset GITTEST_REMOTE_USER
- unset GITTEST_REMOTE_PASS
-
- echo ""
- echo "Running NTLM tests (Apache emulation)"
- echo ""
-
- export GITTEST_REMOTE_URL="http://localhost:9000/broken-ntlm/test.git"
- export GITTEST_REMOTE_USER="foo"
- export GITTEST_REMOTE_PASS="baz"
- run_test auth_clone_and_push
- unset GITTEST_REMOTE_URL
- unset GITTEST_REMOTE_USER
- unset GITTEST_REMOTE_PASS
-fi
-
-if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
- echo ""
- echo "Running SPNEGO tests"
- echo ""
-
- if [ "$(uname -s)" = "Darwin" ]; then
- KINIT_FLAGS="--password-file=STDIN"
- fi
-
- echo $GITTEST_NEGOTIATE_PASSWORD | kinit $KINIT_FLAGS test@LIBGIT2.ORG
- klist -5f
-
- export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
- export GITTEST_REMOTE_DEFAULT="true"
- run_test auth_clone
- unset GITTEST_REMOTE_URL
- unset GITTEST_REMOTE_DEFAULT
-
- echo ""
- echo "Running SPNEGO tests (expect/continue)"
- echo ""
-
- export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
- export GITTEST_REMOTE_DEFAULT="true"
- export GITTEST_REMOTE_EXPECTCONTINUE="true"
- run_test auth_clone
- unset GITTEST_REMOTE_URL
- unset GITTEST_REMOTE_DEFAULT
- unset GITTEST_REMOTE_EXPECTCONTINUE
-
- kdestroy -A
-fi
-
-if [ -z "$SKIP_SSH_TESTS" ]; then
- echo ""
- echo "Running ssh tests"
- echo ""
-
- export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
- export GITTEST_REMOTE_USER=$USER
- export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa"
- export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub"
- export GITTEST_REMOTE_SSH_PASSPHRASE=""
- export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}"
- run_test ssh
- unset GITTEST_REMOTE_URL
- unset GITTEST_REMOTE_USER
- unset GITTEST_REMOTE_SSH_KEY
- unset GITTEST_REMOTE_SSH_PUBKEY
- unset GITTEST_REMOTE_SSH_PASSPHRASE
- unset GITTEST_REMOTE_SSH_FINGERPRINT
-fi
-
-if [ -z "$SKIP_FUZZERS" ]; then
- echo ""
- echo "##############################################################################"
- echo "## Running fuzzers"
- echo "##############################################################################"
-
- ctest -V -R 'fuzzer'
-fi
-
-cleanup
-
-if [ "$SUCCESS" -ne 1 ]; then
- echo "Some tests failed."
- exit 1
-fi
-
-echo "Success."
-exit 0
diff --git a/ci/build.sh b/ci/build.sh
new file mode 100755
index 0000000..5a51f92
--- /dev/null
+++ b/ci/build.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+#
+# Environment variables:
+#
+# SOURCE_DIR: Set to the directory of the libgit2 source (optional)
+# If not set, it will be derived relative to this script.
+
+set -e
+
+SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
+BUILD_DIR=$(pwd)
+BUILD_PATH=${BUILD_PATH:=$PATH}
+CMAKE=$(which cmake)
+CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles}
+
+if [[ "$(uname -s)" == MINGW* ]]; then
+ BUILD_PATH=$(cygpath "$BUILD_PATH")
+fi
+
+indent() { sed "s/^/ /"; }
+
+echo "Source directory: ${SOURCE_DIR}"
+echo "Build directory: ${BUILD_DIR}"
+echo ""
+
+if [ "$(uname -s)" = "Darwin" ]; then
+ echo "macOS version:"
+ sw_vers | indent
+fi
+
+if [ -f "/etc/debian_version" ]; then
+ echo "Debian version:"
+ (source /etc/lsb-release && echo "${DISTRIB_DESCRIPTION}") | indent
+fi
+
+CORES=$(getconf _NPROCESSORS_ONLN || true)
+echo "Number of cores: ${CORES:-(Unknown)}"
+
+echo "Kernel version:"
+uname -a 2>&1 | indent
+
+echo "CMake version:"
+env PATH="${BUILD_PATH}" "${CMAKE}" --version 2>&1 | indent
+
+if test -n "${CC}"; then
+ echo "Compiler version:"
+ "${CC}" --version 2>&1 | indent
+fi
+echo "Environment:"
+if test -n "${CC}"; then
+ echo "CC=${CC}" | indent
+fi
+if test -n "${CFLAGS}"; then
+ echo "CFLAGS=${CFLAGS}" | indent
+fi
+echo ""
+
+echo "##############################################################################"
+echo "## Configuring build environment"
+echo "##############################################################################"
+
+echo cmake -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\"
+env PATH="${BUILD_PATH}" "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} -S "${SOURCE_DIR}"
+
+echo ""
+echo "##############################################################################"
+echo "## Building libgit2"
+echo "##############################################################################"
+
+# Determine parallelism; newer cmake supports `--build --parallel` but
+# we cannot yet rely on that.
+if [ "${CMAKE_GENERATOR}" = "Unix Makefiles" -a "${CORES}" != "" ]; then
+ BUILDER=(make -j ${CORES})
+else
+ BUILDER=("${CMAKE}" --build .)
+fi
+
+env PATH="${BUILD_PATH}" "${BUILDER[@]}"
diff --git a/ci/coverity.sh b/ci/coverity.sh
new file mode 100755
index 0000000..c68b6f8
--- /dev/null
+++ b/ci/coverity.sh
@@ -0,0 +1,62 @@
+#!/bin/bash -e
+
+if test -z "$COVERITY_TOKEN"
+then
+ echo "Need to set a coverity token"
+ exit 1
+fi
+
+case $(uname -m) in
+ i?86)
+ BITS=32;;
+ amd64|x86_64)
+ BITS=64;;
+ *)
+ echo "Unsupported arch '$(uname -m)'"
+ exit 1;;
+esac
+
+SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
+SOURCE_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
+BUILD_DIR=${SOURCE_DIR}/coverity-build
+TOOL_DIR=${BUILD_DIR}/coverity-tools
+
+# Install coverity tools
+if ! test -d "$TOOL_DIR"
+then
+ mkdir -p "$TOOL_DIR"
+ curl --silent --show-error --location --data "project=libgit2&token=$COVERITY_TOKEN" "$SCAN_TOOL" |
+ tar -xzC "$TOOL_DIR"
+ ln -s "$(find "$TOOL_DIR" -type d -name 'cov-analysis*')" "$TOOL_DIR"/cov-analysis
+fi
+
+cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_DIR"/cov-analysis/config/
+
+# Build libgit2 with Coverity
+mkdir -p "$BUILD_DIR"
+cd "$BUILD_DIR"
+cmake "$SOURCE_DIR"
+COVERITY_UNSUPPORTED=1 \
+ "$TOOL_DIR/cov-analysis/bin/cov-build" --dir cov-int \
+ cmake --build .
+
+# Upload results
+tar -czf libgit2.tgz cov-int
+REVISION=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
+HTML="$(curl \
+ --silent --show-error \
+ --write-out "\n%{http_code}" \
+ --form token="$COVERITY_TOKEN" \
+ --form email=libgit2@gmail.com \
+ --form file=@libgit2.tgz \
+ --form version="$REVISION" \
+ --form description="libgit2 build" \
+ https://scan.coverity.com/builds?project=libgit2)"
+
+# Status code is the last line
+STATUS_CODE="$(echo "$HTML" | tail -n1)"
+if test "${STATUS_CODE}" != 200 && test "${STATUS_CODE}" != 201
+then
+ echo "Received error code ${STATUS_CODE} from Coverity"
+ exit 1
+fi
diff --git a/ci/docker/bionic b/ci/docker/bionic
new file mode 100644
index 0000000..51af5c0
--- /dev/null
+++ b/ci/docker/bionic
@@ -0,0 +1,44 @@
+ARG BASE=ubuntu:bionic
+
+FROM ${BASE} AS apt
+RUN apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
+ clang \
+ cmake \
+ curl \
+ gcc \
+ git \
+ krb5-user \
+ libcurl4-openssl-dev \
+ libkrb5-dev \
+ libpcre3-dev \
+ libssh2-1-dev \
+ libssl-dev \
+ libz-dev \
+ ninja-build \
+ openjdk-8-jre-headless \
+ openssh-server \
+ openssl \
+ pkgconf \
+ python \
+ sudo \
+ valgrind \
+ && \
+ rm -rf /var/lib/apt/lists/*
+
+FROM apt AS mbedtls
+RUN cd /tmp && \
+ curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \
+ tar -xz && \
+ cd mbedtls-2.16.2 && \
+ scripts/config.pl set MBEDTLS_MD4_C 1 && \
+ CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \
+ ninja install && \
+ cd .. && \
+ rm -rf mbedtls-2.16.2
+
+FROM mbedtls AS adduser
+RUN useradd --shell /bin/bash libgit2 --create-home
+
+FROM adduser AS configure
+RUN mkdir /var/run/sshd
diff --git a/ci/docker/centos7 b/ci/docker/centos7
new file mode 100644
index 0000000..098edb2
--- /dev/null
+++ b/ci/docker/centos7
@@ -0,0 +1,55 @@
+ARG BASE=centos:7
+
+FROM ${BASE} AS yum
+RUN yum install -y \
+ which \
+ bzip2 \
+ git \
+ libarchive \
+ gcc \
+ gcc-c++ \
+ make \
+ openssl-devel \
+ openssh-server \
+ git-daemon \
+ java-1.8.0-openjdk-headless \
+ sudo \
+ python
+
+FROM yum AS libssh2
+RUN cd /tmp && \
+ curl https://libssh2.org/download/libssh2-1.8.0.tar.gz | tar -xz && \
+ cd libssh2-1.8.0 && \
+ ./configure && \
+ make && \
+ make install && \
+ cd .. && \
+ rm -rf libssh-1.8.0
+
+FROM libssh2 AS valgrind
+RUN cd /tmp && \
+ curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \
+ tar -xj && \
+ cd valgrind-3.15.0 && \
+ ./configure && \
+ make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \
+ make install && \
+ cd .. && \
+ rm -rf valgrind-3.15.0
+
+FROM valgrind AS cmake
+RUN cd /tmp && \
+ curl -L https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1.tar.gz | tar -xz && \
+ cd cmake-3.21.1 && \
+ ./configure && \
+ make && \
+ make install && \
+ cd .. && \
+ rm -rf cmake-3.21.1
+
+FROM cmake AS adduser
+RUN useradd --shell /bin/bash libgit2 --create-home
+
+FROM adduser AS configure
+ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
+RUN mkdir /var/run/sshd
diff --git a/ci/docker/centos8 b/ci/docker/centos8
new file mode 100644
index 0000000..f471984
--- /dev/null
+++ b/ci/docker/centos8
@@ -0,0 +1,49 @@
+ARG BASE=centos:8
+
+FROM ${BASE} AS yum
+RUN yum install -y \
+ which \
+ bzip2 \
+ git \
+ libarchive \
+ cmake \
+ gcc \
+ make \
+ openssl-devel \
+ openssh-server \
+ git-daemon \
+ java-1.8.0-openjdk-headless \
+ sudo \
+ python39 \
+ krb5-workstation \
+ krb5-libs
+
+FROM yum AS libssh2
+RUN cd /tmp && \
+ curl https://libssh2.org/download/libssh2-1.8.0.tar.gz | tar -xz && \
+ cd libssh2-1.8.0 && \
+ ./configure && \
+ make && \
+ make install && \
+ cd .. && \
+ rm -rf libssh2-1.8.0
+
+FROM libssh2 AS valgrind
+RUN cd /tmp && \
+ curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \
+ tar -xj && \
+ cd valgrind-3.15.0 && \
+ ./configure && \
+ make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \
+ make install && \
+ cd .. && \
+ rm -rf valgrind-3.15.0
+
+FROM valgrind AS adduser
+RUN useradd --shell /bin/bash libgit2 --create-home
+
+FROM adduser AS configure
+ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
+RUN mkdir /var/run/sshd
+RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local && \
+ ldconfig
diff --git a/ci/docker/docurium b/ci/docker/docurium
new file mode 100644
index 0000000..1957bbb
--- /dev/null
+++ b/ci/docker/docurium
@@ -0,0 +1,5 @@
+ARG BASE=ubuntu:bionic
+
+FROM ${BASE}
+RUN apt update && apt install -y cmake pkg-config ruby ruby-dev llvm libclang-dev libssl-dev python-pygments
+RUN gem install docurium
diff --git a/ci/docker/focal b/ci/docker/focal
new file mode 100644
index 0000000..1713876
--- /dev/null
+++ b/ci/docker/focal
@@ -0,0 +1,80 @@
+ARG BASE=ubuntu:focal
+
+FROM ${BASE} AS apt
+RUN apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
+ bzip2 \
+ clang-10 \
+ cmake \
+ curl \
+ gcc-10 \
+ git \
+ krb5-user \
+ libcurl4-gnutls-dev \
+ libgcrypt20-dev \
+ libkrb5-dev \
+ libpcre3-dev \
+ libssl-dev \
+ libz-dev \
+ llvm-10 \
+ make \
+ ninja-build \
+ openjdk-8-jre-headless \
+ openssh-server \
+ openssl \
+ pkgconf \
+ python \
+ sudo \
+ valgrind \
+ && \
+ rm -rf /var/lib/apt/lists/* && \
+ mkdir /usr/local/msan
+
+FROM apt AS mbedtls
+RUN cd /tmp && \
+ curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \
+ tar -xz && \
+ cd mbedtls-2.16.2 && \
+ scripts/config.pl unset MBEDTLS_AESNI_C && \
+ scripts/config.pl set MBEDTLS_MD4_C 1 && \
+ mkdir build build-msan && \
+ cd build && \
+ CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
+ ninja install && \
+ cd ../build-msan && \
+ CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=MemSanDbg -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \
+ ninja install && \
+ cd .. && \
+ rm -rf mbedtls-2.16.2
+
+FROM mbedtls AS libssh2
+RUN cd /tmp && \
+ curl --insecure --location --silent --show-error https://www.libssh2.org/download/libssh2-1.9.0.tar.gz | \
+ tar -xz && \
+ cd libssh2-1.9.0 && \
+ mkdir build build-msan && \
+ cd build && \
+ CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
+ ninja install && \
+ cd ../build-msan && \
+ CC=clang-10 CFLAGS="-fPIC -fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer" LDFLAGS="-fsanitize=memory" cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=mbedTLS -DCMAKE_PREFIX_PATH=/usr/local/msan -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \
+ ninja install && \
+ cd .. && \
+ rm -rf libssh2-1.9.0
+
+FROM libssh2 AS valgrind
+RUN cd /tmp && \
+ curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \
+ tar -xj && \
+ cd valgrind-3.15.0 && \
+ CC=clang-10 ./configure && \
+ make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \
+ make install && \
+ cd .. && \
+ rm -rf valgrind-3.15.0
+
+FROM valgrind AS adduser
+RUN useradd --shell /bin/bash libgit2 --create-home
+
+FROM adduser AS configure
+RUN mkdir /var/run/sshd
diff --git a/ci/docker/xenial b/ci/docker/xenial
new file mode 100644
index 0000000..4c3810a
--- /dev/null
+++ b/ci/docker/xenial
@@ -0,0 +1,67 @@
+ARG BASE=ubuntu:xenial
+
+FROM ${BASE} AS apt
+RUN apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
+ bzip2 \
+ clang \
+ cmake \
+ curl \
+ gcc \
+ git \
+ krb5-user \
+ libcurl4-gnutls-dev \
+ libgcrypt20-dev \
+ libkrb5-dev \
+ libpcre3-dev \
+ libssl-dev \
+ libz-dev \
+ make \
+ ninja-build \
+ openjdk-8-jre-headless \
+ openssh-server \
+ openssl \
+ pkgconf \
+ python \
+ sudo \
+ valgrind \
+ && \
+ rm -rf /var/lib/apt/lists/*
+
+FROM apt AS mbedtls
+RUN cd /tmp && \
+ curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \
+ tar -xz && \
+ cd mbedtls-2.16.2 && \
+ scripts/config.pl set MBEDTLS_MD4_C 1 && \
+ CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \
+ ninja install && \
+ cd .. && \
+ rm -rf mbedtls-2.16.2
+
+FROM mbedtls AS libssh2
+RUN cd /tmp && \
+ curl --insecure --location --silent --show-error https://www.libssh2.org/download/libssh2-1.8.2.tar.gz | \
+ tar -xz && \
+ cd libssh2-1.8.2 && \
+ CFLAGS=-fPIC cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt . && \
+ ninja install && \
+ cd .. && \
+ rm -rf libssh2-1.8.2
+
+FROM libssh2 AS valgrind
+RUN cd /tmp && \
+ curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \
+ tar -xj && \
+ cd valgrind-3.15.0 && \
+ ./configure && \
+ make && \
+ make install && \
+ cd .. && \
+ rm -rf valgrind-3.15.0
+
+FROM valgrind AS adduser
+RUN useradd --shell /bin/bash libgit2 --create-home
+
+FROM adduser AS configure
+RUN mkdir /var/run/sshd
diff --git a/ci/getcontainer.sh b/ci/getcontainer.sh
new file mode 100755
index 0000000..07ef7b8
--- /dev/null
+++ b/ci/getcontainer.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+set -e
+
+IMAGE_NAME=$1
+DOCKERFILE_PATH=$2
+
+if [ "${IMAGE_NAME}" = "" ]; then
+ echo "usage: $0 image_name [dockerfile]"
+ exit 1
+fi
+
+if [ "${DOCKERFILE_PATH}" = "" ]; then
+ DOCKERFILE_PATH="${IMAGE_NAME}"
+fi
+
+if [ "${DOCKER_REGISTRY}" = "" ]; then
+ echo "DOCKER_REGISTRY environment variable is unset."
+ echo "Not running inside GitHub Actions or misconfigured?"
+ exit 1
+fi
+
+DOCKER_CONTAINER="${GITHUB_REPOSITORY}/${IMAGE_NAME}"
+DOCKER_REGISTRY_CONTAINER="${DOCKER_REGISTRY}/${DOCKER_CONTAINER}"
+
+echo "dockerfile=${DOCKERFILE_PATH}" >> $GITHUB_ENV
+echo "docker-container=${DOCKER_CONTAINER}" >> $GITHUB_ENV
+echo "docker-registry-container=${DOCKER_REGISTRY_CONTAINER}" >> $GITHUB_ENV
+
+# Identify the last git commit that touched the Dockerfiles
+# Use this as a hash to identify the resulting docker containers
+DOCKER_SHA=$(git log -1 --pretty=format:"%h" -- "${DOCKERFILE_PATH}")
+echo "docker-sha=${DOCKER_SHA}" >> $GITHUB_ENV
+
+DOCKER_REGISTRY_CONTAINER_SHA="${DOCKER_REGISTRY_CONTAINER}:${DOCKER_SHA}"
+
+echo "docker-registry-container-sha=${DOCKER_REGISTRY_CONTAINER_SHA}" >> $GITHUB_ENV
+echo "docker-registry-container-latest=${DOCKER_REGISTRY_CONTAINER}:latest" >> $GITHUB_ENV
+
+exists="true"
+docker login https://${DOCKER_REGISTRY} -u ${GITHUB_ACTOR} -p ${GITHUB_TOKEN} || exists="false"
+
+if [ "${exists}" != "false" ]; then
+ docker pull ${DOCKER_REGISTRY_CONTAINER_SHA} || exists="false"
+fi
+
+if [ "${exists}" = "true" ]; then
+ echo "docker-container-exists=true" >> $GITHUB_ENV
+else
+ echo "docker-container-exists=false" >> $GITHUB_ENV
+fi
diff --git a/ci/setup-mingw.sh b/ci/setup-mingw.sh
new file mode 100755
index 0000000..f5a882d
--- /dev/null
+++ b/ci/setup-mingw.sh
@@ -0,0 +1,25 @@
+#!/bin/sh -e
+
+echo "##############################################################################"
+echo "## Downloading mingw"
+echo "##############################################################################"
+
+BUILD_TEMP=${BUILD_TEMP:=$TEMP}
+BUILD_TEMP=$(cygpath $BUILD_TEMP)
+
+case "$ARCH" in
+ amd64)
+ MINGW_URI="https://github.com/libgit2/ci-dependencies/releases/download/2021-05-04/mingw-x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";;
+ x86)
+ MINGW_URI="https://github.com/libgit2/ci-dependencies/releases/download/2021-05-04/mingw-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";;
+esac
+
+if [ -z "$MINGW_URI" ]; then
+ echo "No URL"
+ exit 1
+fi
+
+mkdir -p "$BUILD_TEMP"
+
+curl -s -L "$MINGW_URI" -o "$BUILD_TEMP"/mingw-"$ARCH".zip
+unzip -q "$BUILD_TEMP"/mingw-"$ARCH".zip -d "$BUILD_TEMP"
diff --git a/ci/setup-osx.sh b/ci/setup-osx.sh
new file mode 100755
index 0000000..2e630ee
--- /dev/null
+++ b/ci/setup-osx.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -x
+
+brew update
+brew install pkgconfig zlib curl openssl libssh2 ninja
+
+ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib
diff --git a/ci/test.sh b/ci/test.sh
new file mode 100755
index 0000000..2b43ba1
--- /dev/null
+++ b/ci/test.sh
@@ -0,0 +1,325 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [ -n "$SKIP_TESTS" ]; then
+ exit 0
+fi
+
+# Windows doesn't run the NTLM tests properly (yet)
+if [[ "$(uname -s)" == MINGW* ]]; then
+ SKIP_NTLM_TESTS=1
+fi
+
+SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
+BUILD_DIR=$(pwd)
+TMPDIR=${TMPDIR:-/tmp}
+USER=${USER:-$(whoami)}
+
+SUCCESS=1
+
+cleanup() {
+ echo "Cleaning up..."
+
+ if [ ! -z "$GITDAEMON_PID" ]; then
+ echo "Stopping git daemon..."
+ kill $GITDAEMON_PID
+ fi
+
+ if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then
+ echo "Stopping SSH..."
+ kill $(cat "${SSHD_DIR}/pid")
+ fi
+
+ echo "Done."
+}
+
+run_test() {
+ if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then
+ ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY
+ else
+ ATTEMPTS_REMAIN=1
+ fi
+
+ FAILED=0
+ while [[ "$ATTEMPTS_REMAIN" > 0 ]]; do
+ if [ "$FAILED" -eq 1 ]; then
+ echo ""
+ echo "Re-running flaky ${1} tests..."
+ echo ""
+ fi
+
+ RETURN_CODE=0
+
+ CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true
+
+ if [ "$RETURN_CODE" -eq 0 ]; then
+ FAILED=0
+ break
+ fi
+
+ echo "Test exited with code: $RETURN_CODE"
+ ATTEMPTS_REMAIN="$(($ATTEMPTS_REMAIN-1))"
+ FAILED=1
+ done
+
+ if [ "$FAILED" -ne 0 ]; then
+ SUCCESS=0
+ fi
+}
+
+# Configure the test environment; run them early so that we're certain
+# that they're started by the time we need them.
+
+echo "##############################################################################"
+echo "## Configuring test environment"
+echo "##############################################################################"
+
+if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
+ echo "Starting git daemon..."
+ GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
+ git init --bare "${GITDAEMON_DIR}/test.git"
+ git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
+ GITDAEMON_PID=$!
+ disown $GITDAEMON_PID
+fi
+
+if [ -z "$SKIP_PROXY_TESTS" ]; then
+ curl --location --silent --show-error https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar >poxyproxy.jar
+
+ echo ""
+ echo "Starting HTTP proxy (Basic)..."
+ java -jar poxyproxy.jar --address 127.0.0.1 --port 8080 --credentials foo:bar --auth-type basic --quiet &
+
+ echo ""
+ echo "Starting HTTP proxy (NTLM)..."
+ java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
+fi
+
+if [ -z "$SKIP_NTLM_TESTS" ]; then
+ curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.4.0/poxygit-0.4.0.jar >poxygit.jar
+
+ echo ""
+ echo "Starting HTTP server..."
+ NTLM_DIR=`mktemp -d ${TMPDIR}/ntlm.XXXXXXXX`
+ git init --bare "${NTLM_DIR}/test.git"
+ java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${NTLM_DIR}" &
+fi
+
+if [ -z "$SKIP_SSH_TESTS" ]; then
+ echo "Starting ssh daemon..."
+ HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
+ SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
+ git init --bare "${SSHD_DIR}/test.git"
+ cat >"${SSHD_DIR}/sshd_config" <<-EOF
+ Port 2222
+ ListenAddress 0.0.0.0
+ Protocol 2
+ HostKey ${SSHD_DIR}/id_rsa
+ PidFile ${SSHD_DIR}/pid
+ AuthorizedKeysFile ${HOME}/.ssh/authorized_keys
+ LogLevel DEBUG
+ RSAAuthentication yes
+ PasswordAuthentication yes
+ PubkeyAuthentication yes
+ ChallengeResponseAuthentication no
+ StrictModes no
+ # Required here as sshd will simply close connection otherwise
+ UsePAM no
+ EOF
+ ssh-keygen -t rsa -f "${SSHD_DIR}/id_rsa" -N "" -q
+ /usr/sbin/sshd -f "${SSHD_DIR}/sshd_config" -E "${SSHD_DIR}/log"
+
+ # Set up keys
+ mkdir "${HOME}/.ssh"
+ ssh-keygen -t rsa -f "${HOME}/.ssh/id_rsa" -N "" -q
+ cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys"
+ while read algorithm key comment; do
+ echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts"
+ done <"${SSHD_DIR}/id_rsa.pub"
+
+ # Get the fingerprint for localhost and remove the colons so we can
+ # parse it as a hex number. Older versions have a different output
+ # format.
+ if [[ $(ssh -V 2>&1) == OpenSSH_6* ]]; then
+ SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
+ else
+ SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
+ fi
+fi
+
+# Run the tests that do not require network connectivity.
+
+if [ -z "$SKIP_OFFLINE_TESTS" ]; then
+ echo ""
+ echo "##############################################################################"
+ echo "## Running (offline) tests"
+ echo "##############################################################################"
+
+ run_test offline
+fi
+
+if [ -n "$RUN_INVASIVE_TESTS" ]; then
+ echo ""
+ echo "Running invasive tests"
+ echo ""
+
+ export GITTEST_INVASIVE_FS_SIZE=1
+ export GITTEST_INVASIVE_MEMORY=1
+ export GITTEST_INVASIVE_SPEED=1
+ run_test invasive
+ unset GITTEST_INVASIVE_FS_SIZE
+ unset GITTEST_INVASIVE_MEMORY
+ unset GITTEST_INVASIVE_SPEED
+fi
+
+if [ -z "$SKIP_ONLINE_TESTS" ]; then
+ # Run the various online tests. The "online" test suite only includes the
+ # default online tests that do not require additional configuration. The
+ # "proxy" and "ssh" test suites require further setup.
+
+ echo ""
+ echo "##############################################################################"
+ echo "## Running (online) tests"
+ echo "##############################################################################"
+
+ export GITTEST_FLAKY_RETRY=5
+ run_test online
+ unset GITTEST_FLAKY_RETRY
+fi
+
+if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
+ echo ""
+ echo "Running gitdaemon tests"
+ echo ""
+
+ export GITTEST_REMOTE_URL="git://localhost/test.git"
+ run_test gitdaemon
+ unset GITTEST_REMOTE_URL
+fi
+
+if [ -z "$SKIP_PROXY_TESTS" ]; then
+ echo ""
+ echo "Running proxy tests (Basic authentication)"
+ echo ""
+
+ export GITTEST_REMOTE_PROXY_HOST="localhost:8080"
+ export GITTEST_REMOTE_PROXY_USER="foo"
+ export GITTEST_REMOTE_PROXY_PASS="bar"
+ run_test proxy
+ unset GITTEST_REMOTE_PROXY_HOST
+ unset GITTEST_REMOTE_PROXY_USER
+ unset GITTEST_REMOTE_PROXY_PASS
+
+ echo ""
+ echo "Running proxy tests (NTLM authentication)"
+ echo ""
+
+ export GITTEST_REMOTE_PROXY_HOST="localhost:8090"
+ export GITTEST_REMOTE_PROXY_USER="foo"
+ export GITTEST_REMOTE_PROXY_PASS="bar"
+ export GITTEST_FLAKY_RETRY=5
+ run_test proxy
+ unset GITTEST_FLAKY_RETRY
+ unset GITTEST_REMOTE_PROXY_HOST
+ unset GITTEST_REMOTE_PROXY_USER
+ unset GITTEST_REMOTE_PROXY_PASS
+fi
+
+if [ -z "$SKIP_NTLM_TESTS" ]; then
+ echo ""
+ echo "Running NTLM tests (IIS emulation)"
+ echo ""
+
+ export GITTEST_REMOTE_URL="http://localhost:9000/ntlm/test.git"
+ export GITTEST_REMOTE_USER="foo"
+ export GITTEST_REMOTE_PASS="baz"
+ run_test auth_clone_and_push
+ unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_USER
+ unset GITTEST_REMOTE_PASS
+
+ echo ""
+ echo "Running NTLM tests (Apache emulation)"
+ echo ""
+
+ export GITTEST_REMOTE_URL="http://localhost:9000/broken-ntlm/test.git"
+ export GITTEST_REMOTE_USER="foo"
+ export GITTEST_REMOTE_PASS="baz"
+ run_test auth_clone_and_push
+ unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_USER
+ unset GITTEST_REMOTE_PASS
+fi
+
+if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
+ echo ""
+ echo "Running SPNEGO tests"
+ echo ""
+
+ if [ "$(uname -s)" = "Darwin" ]; then
+ KINIT_FLAGS="--password-file=STDIN"
+ fi
+
+ echo $GITTEST_NEGOTIATE_PASSWORD | kinit $KINIT_FLAGS test@LIBGIT2.ORG
+ klist -5f
+
+ export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
+ export GITTEST_REMOTE_DEFAULT="true"
+ run_test auth_clone
+ unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_DEFAULT
+
+ echo ""
+ echo "Running SPNEGO tests (expect/continue)"
+ echo ""
+
+ export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
+ export GITTEST_REMOTE_DEFAULT="true"
+ export GITTEST_REMOTE_EXPECTCONTINUE="true"
+ run_test auth_clone
+ unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_DEFAULT
+ unset GITTEST_REMOTE_EXPECTCONTINUE
+
+ kdestroy -A
+fi
+
+if [ -z "$SKIP_SSH_TESTS" ]; then
+ echo ""
+ echo "Running ssh tests"
+ echo ""
+
+ export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
+ export GITTEST_REMOTE_USER=$USER
+ export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa"
+ export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub"
+ export GITTEST_REMOTE_SSH_PASSPHRASE=""
+ export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}"
+ run_test ssh
+ unset GITTEST_REMOTE_URL
+ unset GITTEST_REMOTE_USER
+ unset GITTEST_REMOTE_SSH_KEY
+ unset GITTEST_REMOTE_SSH_PUBKEY
+ unset GITTEST_REMOTE_SSH_PASSPHRASE
+ unset GITTEST_REMOTE_SSH_FINGERPRINT
+fi
+
+if [ -z "$SKIP_FUZZERS" ]; then
+ echo ""
+ echo "##############################################################################"
+ echo "## Running fuzzers"
+ echo "##############################################################################"
+
+ ctest -V -R 'fuzzer'
+fi
+
+cleanup
+
+if [ "$SUCCESS" -ne 1 ]; then
+ echo "Some tests failed."
+ exit 1
+fi
+
+echo "Success."
+exit 0
diff --git a/cmake/AddCFlagIfSupported.cmake b/cmake/AddCFlagIfSupported.cmake
new file mode 100644
index 0000000..b7aaa79
--- /dev/null
+++ b/cmake/AddCFlagIfSupported.cmake
@@ -0,0 +1,30 @@
+# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
+# ADD_C_FLAG_IF_SUPPORTED(<flag>)
+# <flag> - the compiler flag to test
+# This internally calls the CHECK_C_COMPILER_FLAG macro.
+
+INCLUDE(CheckCCompilerFlag)
+
+MACRO(ADD_C_FLAG _FLAG)
+ STRING(TOUPPER ${_FLAG} UPCASE)
+ STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
+ CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
+
+ IF(IS_${UPCASE_PRETTY}_SUPPORTED)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
+ ENDIF()
+ENDMACRO()
+
+MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
+ STRING(TOUPPER ${_FLAG} UPCASE)
+ STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
+ CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
+
+ IF(IS_${UPCASE_PRETTY}_SUPPORTED)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/EnableWarnings.cmake b/cmake/EnableWarnings.cmake
new file mode 100644
index 0000000..b61ed7e
--- /dev/null
+++ b/cmake/EnableWarnings.cmake
@@ -0,0 +1,15 @@
+MACRO(ENABLE_WARNINGS flag)
+ ADD_C_FLAG_IF_SUPPORTED(-W${flag})
+ENDMACRO()
+
+MACRO(DISABLE_WARNINGS flag)
+ ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
+ENDMACRO()
+
+IF(ENABLE_WERROR)
+ IF(MSVC)
+ ADD_COMPILE_OPTIONS(-WX)
+ ELSE()
+ ADD_C_FLAG_IF_SUPPORTED(-Werror)
+ ENDIF()
+ENDIF()
diff --git a/cmake/FindCoreFoundation.cmake b/cmake/FindCoreFoundation.cmake
new file mode 100644
index 0000000..191aa59
--- /dev/null
+++ b/cmake/FindCoreFoundation.cmake
@@ -0,0 +1,26 @@
+# Find CoreFoundation.framework
+# This will define :
+#
+# COREFOUNDATION_FOUND
+# COREFOUNDATION_LIBRARIES
+# COREFOUNDATION_LDFLAGS
+#
+
+FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
+FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
+IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
+ IF (NOT CoreFoundation_FIND_QUIETLY)
+ MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
+ ENDIF()
+ SET(COREFOUNDATION_FOUND TRUE)
+ SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
+ENDIF ()
+
+IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
+ MESSAGE(FATAL_ERROR "CoreFoundation not found")
+ENDIF()
+
+MARK_AS_ADVANCED(
+ COREFOUNDATION_INCLUDE_DIR
+ COREFOUNDATION_LIBRARIES
+)
diff --git a/cmake/FindGSSAPI.cmake b/cmake/FindGSSAPI.cmake
new file mode 100644
index 0000000..37357c4
--- /dev/null
+++ b/cmake/FindGSSAPI.cmake
@@ -0,0 +1,324 @@
+# - Try to find GSSAPI
+# Once done this will define
+#
+# KRB5_CONFIG - Path to krb5-config
+# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
+#
+# Read-Only variables:
+# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
+# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
+# GSSAPI_FOUND - system has GSSAPI
+# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
+# GSSAPI_LIBRARIES - Link these to use GSSAPI
+# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
+#
+#=============================================================================
+# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+#
+
+find_path(GSSAPI_ROOT_DIR
+ NAMES
+ include/gssapi.h
+ include/gssapi/gssapi.h
+ HINTS
+ ${_GSSAPI_ROOT_HINTS}
+ PATHS
+ ${_GSSAPI_ROOT_PATHS}
+)
+mark_as_advanced(GSSAPI_ROOT_DIR)
+
+if (UNIX)
+ find_program(KRB5_CONFIG
+ NAMES
+ krb5-config
+ PATHS
+ ${GSSAPI_ROOT_DIR}/bin
+ /opt/local/bin)
+ mark_as_advanced(KRB5_CONFIG)
+
+ if (KRB5_CONFIG)
+ # Check if we have MIT KRB5
+ execute_process(
+ COMMAND
+ ${KRB5_CONFIG} --vendor
+ RESULT_VARIABLE
+ _GSSAPI_VENDOR_RESULT
+ OUTPUT_VARIABLE
+ _GSSAPI_VENDOR_STRING)
+
+ if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
+ set(GSSAPI_FLAVOR_MIT TRUE)
+ else()
+ execute_process(
+ COMMAND
+ ${KRB5_CONFIG} --libs gssapi
+ RESULT_VARIABLE
+ _GSSAPI_LIBS_RESULT
+ OUTPUT_VARIABLE
+ _GSSAPI_LIBS_STRING)
+
+ if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
+ set(GSSAPI_FLAVOR_HEIMDAL TRUE)
+ endif()
+ endif()
+
+ # Get the include dir
+ execute_process(
+ COMMAND
+ ${KRB5_CONFIG} --cflags gssapi
+ RESULT_VARIABLE
+ _GSSAPI_INCLUDE_RESULT
+ OUTPUT_VARIABLE
+ _GSSAPI_INCLUDE_STRING)
+ string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
+ string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
+ endif()
+
+ if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
+ # Check for HEIMDAL
+ find_package(PkgConfig)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(_GSSAPI heimdal-gssapi)
+ endif (PKG_CONFIG_FOUND)
+
+ if (_GSSAPI_FOUND)
+ set(GSSAPI_FLAVOR_HEIMDAL TRUE)
+ else()
+ find_path(_GSSAPI_ROKEN
+ NAMES
+ roken.h
+ PATHS
+ ${GSSAPI_ROOT_DIR}/include
+ ${_GSSAPI_INCLUDEDIR})
+ if (_GSSAPI_ROKEN)
+ set(GSSAPI_FLAVOR_HEIMDAL TRUE)
+ endif()
+ endif ()
+ endif()
+endif (UNIX)
+
+find_path(GSSAPI_INCLUDE_DIR
+ NAMES
+ gssapi.h
+ gssapi/gssapi.h
+ PATHS
+ ${GSSAPI_ROOT_DIR}/include
+ ${_GSSAPI_INCLUDEDIR}
+)
+
+if (GSSAPI_FLAVOR_MIT)
+ find_library(GSSAPI_LIBRARY
+ NAMES
+ gssapi_krb5
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(KRB5_LIBRARY
+ NAMES
+ krb5
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(K5CRYPTO_LIBRARY
+ NAMES
+ k5crypto
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(COM_ERR_LIBRARY
+ NAMES
+ com_err
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ if (GSSAPI_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${GSSAPI_LIBRARY}
+ )
+ endif (GSSAPI_LIBRARY)
+
+ if (KRB5_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${KRB5_LIBRARY}
+ )
+ endif (KRB5_LIBRARY)
+
+ if (K5CRYPTO_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${K5CRYPTO_LIBRARY}
+ )
+ endif (K5CRYPTO_LIBRARY)
+
+ if (COM_ERR_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${COM_ERR_LIBRARY}
+ )
+ endif (COM_ERR_LIBRARY)
+endif (GSSAPI_FLAVOR_MIT)
+
+if (GSSAPI_FLAVOR_HEIMDAL)
+ find_library(GSSAPI_LIBRARY
+ NAMES
+ gssapi
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(KRB5_LIBRARY
+ NAMES
+ krb5
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(HCRYPTO_LIBRARY
+ NAMES
+ hcrypto
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(COM_ERR_LIBRARY
+ NAMES
+ com_err
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(HEIMNTLM_LIBRARY
+ NAMES
+ heimntlm
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(HX509_LIBRARY
+ NAMES
+ hx509
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(ASN1_LIBRARY
+ NAMES
+ asn1
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(WIND_LIBRARY
+ NAMES
+ wind
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ find_library(ROKEN_LIBRARY
+ NAMES
+ roken
+ PATHS
+ ${GSSAPI_ROOT_DIR}/lib
+ ${_GSSAPI_LIBDIR}
+ )
+
+ if (GSSAPI_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${GSSAPI_LIBRARY}
+ )
+ endif (GSSAPI_LIBRARY)
+
+ if (KRB5_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${KRB5_LIBRARY}
+ )
+ endif (KRB5_LIBRARY)
+
+ if (HCRYPTO_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${HCRYPTO_LIBRARY}
+ )
+ endif (HCRYPTO_LIBRARY)
+
+ if (COM_ERR_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${COM_ERR_LIBRARY}
+ )
+ endif (COM_ERR_LIBRARY)
+
+ if (HEIMNTLM_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${HEIMNTLM_LIBRARY}
+ )
+ endif (HEIMNTLM_LIBRARY)
+
+ if (HX509_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${HX509_LIBRARY}
+ )
+ endif (HX509_LIBRARY)
+
+ if (ASN1_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${ASN1_LIBRARY}
+ )
+ endif (ASN1_LIBRARY)
+
+ if (WIND_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${WIND_LIBRARY}
+ )
+ endif (WIND_LIBRARY)
+
+ if (ROKEN_LIBRARY)
+ set(GSSAPI_LIBRARIES
+ ${GSSAPI_LIBRARIES}
+ ${WIND_LIBRARY}
+ )
+ endif (ROKEN_LIBRARY)
+endif (GSSAPI_FLAVOR_HEIMDAL)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
+
+if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
+ set(GSSAPI_FOUND TRUE)
+endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
+
+# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
+mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
diff --git a/cmake/FindGSSFramework.cmake b/cmake/FindGSSFramework.cmake
new file mode 100644
index 0000000..dcf7249
--- /dev/null
+++ b/cmake/FindGSSFramework.cmake
@@ -0,0 +1,28 @@
+# Find GSS.framework
+# This will define :
+#
+# GSSFRAMEWORK_FOUND
+# GSSFRAMEWORK_INCLUDE_DIR
+# GSSFRAMEWORK_LIBRARIES
+# GSSFRAMEWORK_LDFLAGS
+#
+
+FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
+FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS)
+IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
+ IF (NOT CoreFoundation_FIND_QUIETLY)
+ MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
+ ENDIF()
+ SET(GSSFRAMEWORK_FOUND TRUE)
+ SET(GSSFRAMEWORK_LDFLAGS "-framework GSS")
+ENDIF ()
+
+IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
+ MESSAGE(FATAL_ERROR "CoreFoundation not found")
+ENDIF()
+
+MARK_AS_ADVANCED(
+ GSSFRAMEWORK_INCLUDE_DIR
+ GSSFRAMEWORK_LIBRARIES
+ GSSFRAMEWORK_LDFLAGS
+)
diff --git a/cmake/FindHTTP_Parser.cmake b/cmake/FindHTTP_Parser.cmake
new file mode 100644
index 0000000..d92bf75
--- /dev/null
+++ b/cmake/FindHTTP_Parser.cmake
@@ -0,0 +1,39 @@
+# - Try to find http-parser
+#
+# Defines the following variables:
+#
+# HTTP_PARSER_FOUND - system has http-parser
+# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
+# HTTP_PARSER_LIBRARIES - Link these to use http-parser
+# HTTP_PARSER_VERSION_MAJOR - major version
+# HTTP_PARSER_VERSION_MINOR - minor version
+# HTTP_PARSER_VERSION_STRING - the version of http-parser found
+
+# Find the header and library
+FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
+FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
+
+# Found the header, read version
+if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
+ FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
+ IF (HTTP_PARSER_H)
+ STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
+ STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
+ SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
+ ENDIF()
+ UNSET(HTTP_PARSER_H)
+ENDIF()
+
+# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
+# to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
+
+# Hide advanced variables
+MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
+
+# Set standard variables
+IF (HTTP_PARSER_FOUND)
+ SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
+ set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
+ENDIF()
diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake
new file mode 100644
index 0000000..3c66cda
--- /dev/null
+++ b/cmake/FindIconv.cmake
@@ -0,0 +1,45 @@
+# - Try to find Iconv
+# Once done this will define
+#
+# ICONV_FOUND - system has Iconv
+# ICONV_INCLUDE_DIR - the Iconv include directory
+# ICONV_LIBRARIES - Link these to use Iconv
+#
+
+IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+ # Already in cache, be silent
+ SET(ICONV_FIND_QUIETLY TRUE)
+ENDIF()
+
+FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
+CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
+FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
+
+IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
+ SET(ICONV_FOUND TRUE)
+ SET(ICONV_LIBRARIES "")
+ IF(NOT ICONV_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Iconv: provided by libc")
+ ENDIF(NOT ICONV_FIND_QUIETLY)
+ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
+ SET(ICONV_FOUND TRUE)
+ #Â split iconv into -L and -l linker options, so we can
+ # set them for pkg-config
+ GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
+ GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
+ STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
+ SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
+
+ IF(NOT ICONV_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
+ ENDIF(NOT ICONV_FIND_QUIETLY)
+ELSE()
+ IF(Iconv_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Iconv")
+ ENDIF(Iconv_FIND_REQUIRED)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ ICONV_INCLUDE_DIR
+ ICONV_LIBRARIES
+)
diff --git a/cmake/FindPCRE.cmake b/cmake/FindPCRE.cmake
new file mode 100644
index 0000000..74ed61e
--- /dev/null
+++ b/cmake/FindPCRE.cmake
@@ -0,0 +1,38 @@
+# Copyright (C) 2007-2009 LuaDist.
+# Created by Peter Kapec <kapecp@gmail.com>
+# Redistribution and use of this file is allowed according to the terms of the MIT license.
+# For details see the COPYRIGHT file distributed with LuaDist.
+# Note:
+# Searching headers and libraries is very simple and is NOT as powerful as scripts
+# distributed with CMake, because LuaDist defines directories to search for.
+# Everyone is encouraged to contact the author with improvements. Maybe this file
+# becomes part of CMake distribution sometimes.
+
+# - Find pcre
+# Find the native PCRE headers and libraries.
+#
+# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
+# PCRE_LIBRARIES - List of libraries when using pcre.
+# PCRE_FOUND - True if pcre found.
+
+# Look for the header file.
+FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
+
+# Look for the library.
+FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
+FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
+
+# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
+
+# Copy the results to the output variables.
+IF(PCRE_FOUND)
+ SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
+ SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
+ELSE(PCRE_FOUND)
+ SET(PCRE_LIBRARIES)
+ SET(PCRE_INCLUDE_DIRS)
+ENDIF(PCRE_FOUND)
+
+MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake
new file mode 100644
index 0000000..f8c5639
--- /dev/null
+++ b/cmake/FindPCRE2.cmake
@@ -0,0 +1,37 @@
+# Copyright (C) 2007-2009 LuaDist.
+# Created by Peter Kapec <kapecp@gmail.com>
+# Redistribution and use of this file is allowed according to the terms of the MIT license.
+# For details see the COPYRIGHT file distributed with LuaDist.
+# Note:
+# Searching headers and libraries is very simple and is NOT as powerful as scripts
+# distributed with CMake, because LuaDist defines directories to search for.
+# Everyone is encouraged to contact the author with improvements. Maybe this file
+# becomes part of CMake distribution sometimes.
+
+# - Find pcre
+# Find the native PCRE2 headers and libraries.
+#
+# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
+# PCRE2_LIBRARIES - List of libraries when using pcre.
+# PCRE2_FOUND - True if pcre found.
+
+# Look for the header file.
+FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
+
+# Look for the library.
+FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
+
+# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
+
+# Copy the results to the output variables.
+IF(PCRE2_FOUND)
+ SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
+ SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
+ELSE(PCRE2_FOUND)
+ SET(PCRE2_LIBRARIES)
+ SET(PCRE2_INCLUDE_DIRS)
+ENDIF(PCRE2_FOUND)
+
+MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
diff --git a/cmake/FindPkgLibraries.cmake b/cmake/FindPkgLibraries.cmake
new file mode 100644
index 0000000..49311c3
--- /dev/null
+++ b/cmake/FindPkgLibraries.cmake
@@ -0,0 +1,28 @@
+INCLUDE(FindPkgConfig)
+
+# This function will find and set up a pkg-config based module.
+# If a pc-file was found, it will resolve library paths to
+# absolute paths. Furthermore, the function will automatically
+# fall back to use static libraries in case no dynamic libraries
+# were found.
+FUNCTION(FIND_PKGLIBRARIES prefix package)
+ PKG_CHECK_MODULES(${prefix} ${package})
+ IF(NOT ${prefix}_FOUND)
+ RETURN()
+ ENDIF()
+
+ FOREACH(LIBRARY ${${prefix}_LIBRARIES})
+ FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
+ IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
+ MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
+ ENDIF()
+ LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
+ ENDFOREACH(LIBRARY)
+
+ SET(${prefix}_FOUND 1 PARENT_SCOPE)
+ SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
+ SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
+ SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
+
+ MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
+ENDFUNCTION()
diff --git a/cmake/FindSecurity.cmake b/cmake/FindSecurity.cmake
new file mode 100644
index 0000000..a538c02
--- /dev/null
+++ b/cmake/FindSecurity.cmake
@@ -0,0 +1,28 @@
+# Find Security.framework
+# This will define :
+#
+# SECURITY_FOUND
+# SECURITY_LIBRARIES
+# SECURITY_LDFLAGS
+# SECURITY_HAS_SSLCREATECONTEXT
+#
+
+FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
+FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
+IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
+ IF (NOT Security_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}")
+ ENDIF()
+ SET(SECURITY_FOUND TRUE)
+ SET(SECURITY_LDFLAGS "-framework Security")
+ CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
+ENDIF ()
+
+IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
+ MESSAGE(FATAL_ERROR "Security not found")
+ENDIF()
+
+MARK_AS_ADVANCED(
+ SECURITY_INCLUDE_DIR
+ SECURITY_LIBRARIES
+)
diff --git a/cmake/FindStatNsec.cmake b/cmake/FindStatNsec.cmake
new file mode 100644
index 0000000..a4a09fa
--- /dev/null
+++ b/cmake/FindStatNsec.cmake
@@ -0,0 +1,26 @@
+INCLUDE(FeatureSummary)
+
+CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
+ HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
+ HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
+ HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
+
+IF (HAVE_STRUCT_STAT_ST_MTIM)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
+ HAVE_STRUCT_STAT_NSEC LANGUAGE C)
+ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
+ HAVE_STRUCT_STAT_NSEC LANGUAGE C)
+ELSE ()
+ SET( HAVE_STRUCT_STAT_NSEC ON )
+ENDIF()
+
+IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
+ OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
+ELSE()
+ SET(USE_NSEC OFF)
+ENDIF()
+
+ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
diff --git a/cmake/Findfutimens.cmake b/cmake/Findfutimens.cmake
new file mode 100644
index 0000000..73b7952
--- /dev/null
+++ b/cmake/Findfutimens.cmake
@@ -0,0 +1,14 @@
+INCLUDE(EnableWarnings)
+
+IF (APPLE)
+ # We cannot simply CHECK_FUNCTION_EXISTS on macOS because
+ # MACOSX_DEPLOYMENT_TARGET may be set to a version in the past
+ # that doesn't have futimens. Instead we need to enable warnings
+ # as errors, then check for the symbol existing in `sys/stat.h`,
+ # then reset warnings as errors.
+ ENABLE_WARNINGS(error)
+ CHECK_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS)
+ DISABLE_WARNINGS(error)
+ELSE ()
+ CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
+ENDIF ()
diff --git a/cmake/FindmbedTLS.cmake b/cmake/FindmbedTLS.cmake
new file mode 100644
index 0000000..9329755
--- /dev/null
+++ b/cmake/FindmbedTLS.cmake
@@ -0,0 +1,93 @@
+# - Try to find mbedTLS
+# Once done this will define
+#
+# Read-Only variables
+# MBEDTLS_FOUND - system has mbedTLS
+# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
+# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
+# MBEDTLS_LIBRARIES - Link these to use mbedTLS
+# MBEDTLS_LIBRARY - path to mbedTLS library
+# MBEDX509_LIBRARY - path to mbedTLS X.509 library
+# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
+#
+# Hint
+# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
+
+SET(_MBEDTLS_ROOT_HINTS
+ ${MBEDTLS_ROOT_DIR}
+ ENV MBEDTLS_ROOT_DIR
+)
+
+SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
+ HINTS ${_MBEDTLS_ROOT_HINTS}
+ PATHS ${_MBEDTLS_ROOT_PATHS}
+)
+
+FIND_PATH(MBEDTLS_INCLUDE_DIR
+ NAMES mbedtls/version.h
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES include
+)
+
+IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
+ # Already in cache, be silent
+ SET(MBEDTLS_FIND_QUIETLY TRUE)
+ENDIF()
+
+FIND_LIBRARY(MBEDTLS_LIBRARY
+ NAMES mbedtls libmbedtls
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES library
+)
+FIND_LIBRARY(MBEDX509_LIBRARY
+ NAMES mbedx509 libmbedx509
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES library
+)
+FIND_LIBRARY(MBEDCRYPTO_LIBRARY
+ NAMES mbedcrypto libmbedcrypto
+ ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
+ PATH_SUFFIXES library
+)
+
+IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
+ SET(MBEDTLS_FOUND TRUE)
+ENDIF()
+
+IF(MBEDTLS_FOUND)
+ #Â split mbedTLS into -L and -l linker options, so we can set them for pkg-config
+ GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
+ GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
+ GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
+ GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
+ STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
+ STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
+ STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
+ SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
+
+ IF(NOT MBEDTLS_FIND_QUIETLY)
+ MESSAGE(STATUS "Found mbedTLS:")
+ FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
+ STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
+ IF (MBEDTLSMATCH)
+ STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
+ MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
+ ENDIF(MBEDTLSMATCH)
+ MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
+ MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
+ MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
+ ENDIF(NOT MBEDTLS_FIND_QUIETLY)
+ELSE(MBEDTLS_FOUND)
+ IF(MBEDTLS_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find mbedTLS")
+ ENDIF(MBEDTLS_FIND_REQUIRED)
+ENDIF(MBEDTLS_FOUND)
+
+MARK_AS_ADVANCED(
+ MBEDTLS_INCLUDE_DIR
+ MBEDTLS_LIBRARY_DIR
+ MBEDTLS_LIBRARIES
+ MBEDTLS_LIBRARY
+ MBEDX509_LIBRARY
+ MBEDCRYPTO_LIBRARY
+)
diff --git a/cmake/IdeSplitSources.cmake b/cmake/IdeSplitSources.cmake
new file mode 100644
index 0000000..e2e09b4
--- /dev/null
+++ b/cmake/IdeSplitSources.cmake
@@ -0,0 +1,22 @@
+# This function splits the sources files up into their appropriate
+# subdirectories. This is especially useful for IDEs like Xcode and
+# Visual Studio, so that you can navigate into the libgit2_clar project,
+# and see the folders within the tests folder (instead of just seeing all
+# source and tests in a single folder.)
+FUNCTION(IDE_SPLIT_SOURCES target)
+ IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
+ GET_TARGET_PROPERTY(sources ${target} SOURCES)
+ FOREACH(source ${sources})
+ IF(source MATCHES ".*/")
+ STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
+ IF(rel)
+ STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
+ IF(rel)
+ STRING(REPLACE "/" "\\\\" rel ${rel})
+ SOURCE_GROUP(${rel} FILES ${source})
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ ENDIF()
+ENDFUNCTION()
diff --git a/cmake/Modules/AddCFlagIfSupported.cmake b/cmake/Modules/AddCFlagIfSupported.cmake
deleted file mode 100644
index b7aaa79..0000000
--- a/cmake/Modules/AddCFlagIfSupported.cmake
+++ /dev/null
@@ -1,30 +0,0 @@
-# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
-# ADD_C_FLAG_IF_SUPPORTED(<flag>)
-# <flag> - the compiler flag to test
-# This internally calls the CHECK_C_COMPILER_FLAG macro.
-
-INCLUDE(CheckCCompilerFlag)
-
-MACRO(ADD_C_FLAG _FLAG)
- STRING(TOUPPER ${_FLAG} UPCASE)
- STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
- STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
- CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
-
- IF(IS_${UPCASE_PRETTY}_SUPPORTED)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
- ELSE()
- MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
- ENDIF()
-ENDMACRO()
-
-MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
- STRING(TOUPPER ${_FLAG} UPCASE)
- STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
- STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
- CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
-
- IF(IS_${UPCASE_PRETTY}_SUPPORTED)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
- ENDIF()
-ENDMACRO()
diff --git a/cmake/Modules/CheckPrototypeDefinition.c.in b/cmake/Modules/CheckPrototypeDefinition.c.in
deleted file mode 100644
index a97344a..0000000
--- a/cmake/Modules/CheckPrototypeDefinition.c.in
+++ /dev/null
@@ -1,29 +0,0 @@
-@CHECK_PROTOTYPE_DEFINITION_HEADER@
-
-static void cmakeRequireSymbol(int dummy, ...) {
- (void) dummy;
-}
-
-static void checkSymbol(void) {
-#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
- cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
-#endif
-}
-
-@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
- return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
-}
-
-#ifdef __CLASSIC_C__
-int main() {
- int ac;
- char*av[];
-#else
-int main(int ac, char *av[]) {
-#endif
- checkSymbol();
- if (ac > 1000) {
- return *av[0];
- }
- return 0;
-}
diff --git a/cmake/Modules/CheckPrototypeDefinition.cmake b/cmake/Modules/CheckPrototypeDefinition.cmake
deleted file mode 100644
index 244b9b5..0000000
--- a/cmake/Modules/CheckPrototypeDefinition.cmake
+++ /dev/null
@@ -1,96 +0,0 @@
-# - Check if the protoype we expect is correct.
-# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
-# FUNCTION - The name of the function (used to check if prototype exists)
-# PROTOTYPE- The prototype to check.
-# RETURN - The return value of the function.
-# HEADER - The header files required.
-# VARIABLE - The variable to store the result.
-# Example:
-# check_prototype_definition(getpwent_r
-# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
-# "NULL"
-# "unistd.h;pwd.h"
-# SOLARIS_GETPWENT_R)
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-
-#=============================================================================
-# Copyright 2005-2009 Kitware, Inc.
-# Copyright 2010-2011 Andreas Schneider <asn@cryptomilk.org>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
-#
-
-get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
-function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
-
- if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
- set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
-
- set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
- if (CMAKE_REQUIRED_LIBRARIES)
- set(CHECK_PROTOTYPE_DEFINITION_LIBS
- "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
- else(CMAKE_REQUIRED_LIBRARIES)
- set(CHECK_PROTOTYPE_DEFINITION_LIBS)
- endif(CMAKE_REQUIRED_LIBRARIES)
- if (CMAKE_REQUIRED_INCLUDES)
- set(CMAKE_SYMBOL_EXISTS_INCLUDES
- "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
- else(CMAKE_REQUIRED_INCLUDES)
- set(CMAKE_SYMBOL_EXISTS_INCLUDES)
- endif(CMAKE_REQUIRED_INCLUDES)
-
- foreach(_FILE ${_HEADER})
- set(CHECK_PROTOTYPE_DEFINITION_HEADER
- "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
- endforeach(_FILE)
-
- set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
- set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
- set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
-
- configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in"
- "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
-
- file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
-
- try_compile(${_VARIABLE}
- ${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
- "${CHECK_PROTOTYPE_DEFINITION_LIBS}"
- "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
- OUTPUT_VARIABLE OUTPUT)
-
- if (${_VARIABLE})
- set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
- message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
- "${OUTPUT}\n\n")
- else (${_VARIABLE})
- message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
- set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
- "${OUTPUT}\n\n${_SOURCE}\n\n")
- endif (${_VARIABLE})
- endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
-
-endfunction(CHECK_PROTOTYPE_DEFINITION)
diff --git a/cmake/Modules/EnableWarnings.cmake b/cmake/Modules/EnableWarnings.cmake
deleted file mode 100644
index b61ed7e..0000000
--- a/cmake/Modules/EnableWarnings.cmake
+++ /dev/null
@@ -1,15 +0,0 @@
-MACRO(ENABLE_WARNINGS flag)
- ADD_C_FLAG_IF_SUPPORTED(-W${flag})
-ENDMACRO()
-
-MACRO(DISABLE_WARNINGS flag)
- ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
-ENDMACRO()
-
-IF(ENABLE_WERROR)
- IF(MSVC)
- ADD_COMPILE_OPTIONS(-WX)
- ELSE()
- ADD_C_FLAG_IF_SUPPORTED(-Werror)
- ENDIF()
-ENDIF()
diff --git a/cmake/Modules/FindCoreFoundation.cmake b/cmake/Modules/FindCoreFoundation.cmake
deleted file mode 100644
index 191aa59..0000000
--- a/cmake/Modules/FindCoreFoundation.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-# Find CoreFoundation.framework
-# This will define :
-#
-# COREFOUNDATION_FOUND
-# COREFOUNDATION_LIBRARIES
-# COREFOUNDATION_LDFLAGS
-#
-
-FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
-FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
-IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
- IF (NOT CoreFoundation_FIND_QUIETLY)
- MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
- ENDIF()
- SET(COREFOUNDATION_FOUND TRUE)
- SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
-ENDIF ()
-
-IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
- MESSAGE(FATAL_ERROR "CoreFoundation not found")
-ENDIF()
-
-MARK_AS_ADVANCED(
- COREFOUNDATION_INCLUDE_DIR
- COREFOUNDATION_LIBRARIES
-)
diff --git a/cmake/Modules/FindGSSAPI.cmake b/cmake/Modules/FindGSSAPI.cmake
deleted file mode 100644
index 37357c4..0000000
--- a/cmake/Modules/FindGSSAPI.cmake
+++ /dev/null
@@ -1,324 +0,0 @@
-# - Try to find GSSAPI
-# Once done this will define
-#
-# KRB5_CONFIG - Path to krb5-config
-# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
-#
-# Read-Only variables:
-# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
-# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
-# GSSAPI_FOUND - system has GSSAPI
-# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
-# GSSAPI_LIBRARIES - Link these to use GSSAPI
-# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
-#
-#=============================================================================
-# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-#
-
-find_path(GSSAPI_ROOT_DIR
- NAMES
- include/gssapi.h
- include/gssapi/gssapi.h
- HINTS
- ${_GSSAPI_ROOT_HINTS}
- PATHS
- ${_GSSAPI_ROOT_PATHS}
-)
-mark_as_advanced(GSSAPI_ROOT_DIR)
-
-if (UNIX)
- find_program(KRB5_CONFIG
- NAMES
- krb5-config
- PATHS
- ${GSSAPI_ROOT_DIR}/bin
- /opt/local/bin)
- mark_as_advanced(KRB5_CONFIG)
-
- if (KRB5_CONFIG)
- # Check if we have MIT KRB5
- execute_process(
- COMMAND
- ${KRB5_CONFIG} --vendor
- RESULT_VARIABLE
- _GSSAPI_VENDOR_RESULT
- OUTPUT_VARIABLE
- _GSSAPI_VENDOR_STRING)
-
- if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
- set(GSSAPI_FLAVOR_MIT TRUE)
- else()
- execute_process(
- COMMAND
- ${KRB5_CONFIG} --libs gssapi
- RESULT_VARIABLE
- _GSSAPI_LIBS_RESULT
- OUTPUT_VARIABLE
- _GSSAPI_LIBS_STRING)
-
- if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
- set(GSSAPI_FLAVOR_HEIMDAL TRUE)
- endif()
- endif()
-
- # Get the include dir
- execute_process(
- COMMAND
- ${KRB5_CONFIG} --cflags gssapi
- RESULT_VARIABLE
- _GSSAPI_INCLUDE_RESULT
- OUTPUT_VARIABLE
- _GSSAPI_INCLUDE_STRING)
- string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
- string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
- endif()
-
- if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
- # Check for HEIMDAL
- find_package(PkgConfig)
- if (PKG_CONFIG_FOUND)
- pkg_check_modules(_GSSAPI heimdal-gssapi)
- endif (PKG_CONFIG_FOUND)
-
- if (_GSSAPI_FOUND)
- set(GSSAPI_FLAVOR_HEIMDAL TRUE)
- else()
- find_path(_GSSAPI_ROKEN
- NAMES
- roken.h
- PATHS
- ${GSSAPI_ROOT_DIR}/include
- ${_GSSAPI_INCLUDEDIR})
- if (_GSSAPI_ROKEN)
- set(GSSAPI_FLAVOR_HEIMDAL TRUE)
- endif()
- endif ()
- endif()
-endif (UNIX)
-
-find_path(GSSAPI_INCLUDE_DIR
- NAMES
- gssapi.h
- gssapi/gssapi.h
- PATHS
- ${GSSAPI_ROOT_DIR}/include
- ${_GSSAPI_INCLUDEDIR}
-)
-
-if (GSSAPI_FLAVOR_MIT)
- find_library(GSSAPI_LIBRARY
- NAMES
- gssapi_krb5
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(KRB5_LIBRARY
- NAMES
- krb5
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(K5CRYPTO_LIBRARY
- NAMES
- k5crypto
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(COM_ERR_LIBRARY
- NAMES
- com_err
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- if (GSSAPI_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${GSSAPI_LIBRARY}
- )
- endif (GSSAPI_LIBRARY)
-
- if (KRB5_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${KRB5_LIBRARY}
- )
- endif (KRB5_LIBRARY)
-
- if (K5CRYPTO_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${K5CRYPTO_LIBRARY}
- )
- endif (K5CRYPTO_LIBRARY)
-
- if (COM_ERR_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${COM_ERR_LIBRARY}
- )
- endif (COM_ERR_LIBRARY)
-endif (GSSAPI_FLAVOR_MIT)
-
-if (GSSAPI_FLAVOR_HEIMDAL)
- find_library(GSSAPI_LIBRARY
- NAMES
- gssapi
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(KRB5_LIBRARY
- NAMES
- krb5
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(HCRYPTO_LIBRARY
- NAMES
- hcrypto
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(COM_ERR_LIBRARY
- NAMES
- com_err
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(HEIMNTLM_LIBRARY
- NAMES
- heimntlm
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(HX509_LIBRARY
- NAMES
- hx509
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(ASN1_LIBRARY
- NAMES
- asn1
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(WIND_LIBRARY
- NAMES
- wind
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- find_library(ROKEN_LIBRARY
- NAMES
- roken
- PATHS
- ${GSSAPI_ROOT_DIR}/lib
- ${_GSSAPI_LIBDIR}
- )
-
- if (GSSAPI_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${GSSAPI_LIBRARY}
- )
- endif (GSSAPI_LIBRARY)
-
- if (KRB5_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${KRB5_LIBRARY}
- )
- endif (KRB5_LIBRARY)
-
- if (HCRYPTO_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${HCRYPTO_LIBRARY}
- )
- endif (HCRYPTO_LIBRARY)
-
- if (COM_ERR_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${COM_ERR_LIBRARY}
- )
- endif (COM_ERR_LIBRARY)
-
- if (HEIMNTLM_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${HEIMNTLM_LIBRARY}
- )
- endif (HEIMNTLM_LIBRARY)
-
- if (HX509_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${HX509_LIBRARY}
- )
- endif (HX509_LIBRARY)
-
- if (ASN1_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${ASN1_LIBRARY}
- )
- endif (ASN1_LIBRARY)
-
- if (WIND_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${WIND_LIBRARY}
- )
- endif (WIND_LIBRARY)
-
- if (ROKEN_LIBRARY)
- set(GSSAPI_LIBRARIES
- ${GSSAPI_LIBRARIES}
- ${WIND_LIBRARY}
- )
- endif (ROKEN_LIBRARY)
-endif (GSSAPI_FLAVOR_HEIMDAL)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
-
-if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
- set(GSSAPI_FOUND TRUE)
-endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
-
-# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
-mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
diff --git a/cmake/Modules/FindGSSFramework.cmake b/cmake/Modules/FindGSSFramework.cmake
deleted file mode 100644
index dcf7249..0000000
--- a/cmake/Modules/FindGSSFramework.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Find GSS.framework
-# This will define :
-#
-# GSSFRAMEWORK_FOUND
-# GSSFRAMEWORK_INCLUDE_DIR
-# GSSFRAMEWORK_LIBRARIES
-# GSSFRAMEWORK_LDFLAGS
-#
-
-FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
-FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS)
-IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
- IF (NOT CoreFoundation_FIND_QUIETLY)
- MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
- ENDIF()
- SET(GSSFRAMEWORK_FOUND TRUE)
- SET(GSSFRAMEWORK_LDFLAGS "-framework GSS")
-ENDIF ()
-
-IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
- MESSAGE(FATAL_ERROR "CoreFoundation not found")
-ENDIF()
-
-MARK_AS_ADVANCED(
- GSSFRAMEWORK_INCLUDE_DIR
- GSSFRAMEWORK_LIBRARIES
- GSSFRAMEWORK_LDFLAGS
-)
diff --git a/cmake/Modules/FindHTTP_Parser.cmake b/cmake/Modules/FindHTTP_Parser.cmake
deleted file mode 100644
index d92bf75..0000000
--- a/cmake/Modules/FindHTTP_Parser.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-# - Try to find http-parser
-#
-# Defines the following variables:
-#
-# HTTP_PARSER_FOUND - system has http-parser
-# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
-# HTTP_PARSER_LIBRARIES - Link these to use http-parser
-# HTTP_PARSER_VERSION_MAJOR - major version
-# HTTP_PARSER_VERSION_MINOR - minor version
-# HTTP_PARSER_VERSION_STRING - the version of http-parser found
-
-# Find the header and library
-FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
-FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
-
-# Found the header, read version
-if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
- FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
- IF (HTTP_PARSER_H)
- STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
- STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
- SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
- ENDIF()
- UNSET(HTTP_PARSER_H)
-ENDIF()
-
-# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
-# to TRUE if all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
-
-# Hide advanced variables
-MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
-
-# Set standard variables
-IF (HTTP_PARSER_FOUND)
- SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
- set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
-ENDIF()
diff --git a/cmake/Modules/FindIconv.cmake b/cmake/Modules/FindIconv.cmake
deleted file mode 100644
index 3c66cda..0000000
--- a/cmake/Modules/FindIconv.cmake
+++ /dev/null
@@ -1,45 +0,0 @@
-# - Try to find Iconv
-# Once done this will define
-#
-# ICONV_FOUND - system has Iconv
-# ICONV_INCLUDE_DIR - the Iconv include directory
-# ICONV_LIBRARIES - Link these to use Iconv
-#
-
-IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
- # Already in cache, be silent
- SET(ICONV_FIND_QUIETLY TRUE)
-ENDIF()
-
-FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
-CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
-FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
-
-IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
- SET(ICONV_FOUND TRUE)
- SET(ICONV_LIBRARIES "")
- IF(NOT ICONV_FIND_QUIETLY)
- MESSAGE(STATUS "Found Iconv: provided by libc")
- ENDIF(NOT ICONV_FIND_QUIETLY)
-ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
- SET(ICONV_FOUND TRUE)
- #Â split iconv into -L and -l linker options, so we can
- # set them for pkg-config
- GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
- GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
- STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
- SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
-
- IF(NOT ICONV_FIND_QUIETLY)
- MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
- ENDIF(NOT ICONV_FIND_QUIETLY)
-ELSE()
- IF(Iconv_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find Iconv")
- ENDIF(Iconv_FIND_REQUIRED)
-ENDIF()
-
-MARK_AS_ADVANCED(
- ICONV_INCLUDE_DIR
- ICONV_LIBRARIES
-)
diff --git a/cmake/Modules/FindPCRE.cmake b/cmake/Modules/FindPCRE.cmake
deleted file mode 100644
index 74ed61e..0000000
--- a/cmake/Modules/FindPCRE.cmake
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2007-2009 LuaDist.
-# Created by Peter Kapec <kapecp@gmail.com>
-# Redistribution and use of this file is allowed according to the terms of the MIT license.
-# For details see the COPYRIGHT file distributed with LuaDist.
-# Note:
-# Searching headers and libraries is very simple and is NOT as powerful as scripts
-# distributed with CMake, because LuaDist defines directories to search for.
-# Everyone is encouraged to contact the author with improvements. Maybe this file
-# becomes part of CMake distribution sometimes.
-
-# - Find pcre
-# Find the native PCRE headers and libraries.
-#
-# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
-# PCRE_LIBRARIES - List of libraries when using pcre.
-# PCRE_FOUND - True if pcre found.
-
-# Look for the header file.
-FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
-
-# Look for the library.
-FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
-FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
-
-# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
-
-# Copy the results to the output variables.
-IF(PCRE_FOUND)
- SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
- SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
-ELSE(PCRE_FOUND)
- SET(PCRE_LIBRARIES)
- SET(PCRE_INCLUDE_DIRS)
-ENDIF(PCRE_FOUND)
-
-MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
diff --git a/cmake/Modules/FindPCRE2.cmake b/cmake/Modules/FindPCRE2.cmake
deleted file mode 100644
index f8c5639..0000000
--- a/cmake/Modules/FindPCRE2.cmake
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2007-2009 LuaDist.
-# Created by Peter Kapec <kapecp@gmail.com>
-# Redistribution and use of this file is allowed according to the terms of the MIT license.
-# For details see the COPYRIGHT file distributed with LuaDist.
-# Note:
-# Searching headers and libraries is very simple and is NOT as powerful as scripts
-# distributed with CMake, because LuaDist defines directories to search for.
-# Everyone is encouraged to contact the author with improvements. Maybe this file
-# becomes part of CMake distribution sometimes.
-
-# - Find pcre
-# Find the native PCRE2 headers and libraries.
-#
-# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
-# PCRE2_LIBRARIES - List of libraries when using pcre.
-# PCRE2_FOUND - True if pcre found.
-
-# Look for the header file.
-FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
-
-# Look for the library.
-FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
-
-# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
-
-# Copy the results to the output variables.
-IF(PCRE2_FOUND)
- SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
- SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
-ELSE(PCRE2_FOUND)
- SET(PCRE2_LIBRARIES)
- SET(PCRE2_INCLUDE_DIRS)
-ENDIF(PCRE2_FOUND)
-
-MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
diff --git a/cmake/Modules/FindPkgLibraries.cmake b/cmake/Modules/FindPkgLibraries.cmake
deleted file mode 100644
index 49311c3..0000000
--- a/cmake/Modules/FindPkgLibraries.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-INCLUDE(FindPkgConfig)
-
-# This function will find and set up a pkg-config based module.
-# If a pc-file was found, it will resolve library paths to
-# absolute paths. Furthermore, the function will automatically
-# fall back to use static libraries in case no dynamic libraries
-# were found.
-FUNCTION(FIND_PKGLIBRARIES prefix package)
- PKG_CHECK_MODULES(${prefix} ${package})
- IF(NOT ${prefix}_FOUND)
- RETURN()
- ENDIF()
-
- FOREACH(LIBRARY ${${prefix}_LIBRARIES})
- FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
- IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
- MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
- ENDIF()
- LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
- ENDFOREACH(LIBRARY)
-
- SET(${prefix}_FOUND 1 PARENT_SCOPE)
- SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
- SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
- SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
-
- MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
-ENDFUNCTION()
diff --git a/cmake/Modules/FindSecurity.cmake b/cmake/Modules/FindSecurity.cmake
deleted file mode 100644
index a538c02..0000000
--- a/cmake/Modules/FindSecurity.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Find Security.framework
-# This will define :
-#
-# SECURITY_FOUND
-# SECURITY_LIBRARIES
-# SECURITY_LDFLAGS
-# SECURITY_HAS_SSLCREATECONTEXT
-#
-
-FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
-FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
-IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
- IF (NOT Security_FIND_QUIETLY)
- MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}")
- ENDIF()
- SET(SECURITY_FOUND TRUE)
- SET(SECURITY_LDFLAGS "-framework Security")
- CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
-ENDIF ()
-
-IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
- MESSAGE(FATAL_ERROR "Security not found")
-ENDIF()
-
-MARK_AS_ADVANCED(
- SECURITY_INCLUDE_DIR
- SECURITY_LIBRARIES
-)
diff --git a/cmake/Modules/FindStatNsec.cmake b/cmake/Modules/FindStatNsec.cmake
deleted file mode 100644
index a4a09fa..0000000
--- a/cmake/Modules/FindStatNsec.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-INCLUDE(FeatureSummary)
-
-CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
- HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
-CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
- HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
-CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
- HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
-
-IF (HAVE_STRUCT_STAT_ST_MTIM)
- CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
- HAVE_STRUCT_STAT_NSEC LANGUAGE C)
-ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
- CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
- HAVE_STRUCT_STAT_NSEC LANGUAGE C)
-ELSE ()
- SET( HAVE_STRUCT_STAT_NSEC ON )
-ENDIF()
-
-IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
- OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
-ELSE()
- SET(USE_NSEC OFF)
-ENDIF()
-
-ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
diff --git a/cmake/Modules/FindmbedTLS.cmake b/cmake/Modules/FindmbedTLS.cmake
deleted file mode 100644
index 9329755..0000000
--- a/cmake/Modules/FindmbedTLS.cmake
+++ /dev/null
@@ -1,93 +0,0 @@
-# - Try to find mbedTLS
-# Once done this will define
-#
-# Read-Only variables
-# MBEDTLS_FOUND - system has mbedTLS
-# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
-# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
-# MBEDTLS_LIBRARIES - Link these to use mbedTLS
-# MBEDTLS_LIBRARY - path to mbedTLS library
-# MBEDX509_LIBRARY - path to mbedTLS X.509 library
-# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
-#
-# Hint
-# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
-
-SET(_MBEDTLS_ROOT_HINTS
- ${MBEDTLS_ROOT_DIR}
- ENV MBEDTLS_ROOT_DIR
-)
-
-SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
- HINTS ${_MBEDTLS_ROOT_HINTS}
- PATHS ${_MBEDTLS_ROOT_PATHS}
-)
-
-FIND_PATH(MBEDTLS_INCLUDE_DIR
- NAMES mbedtls/version.h
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES include
-)
-
-IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
- # Already in cache, be silent
- SET(MBEDTLS_FIND_QUIETLY TRUE)
-ENDIF()
-
-FIND_LIBRARY(MBEDTLS_LIBRARY
- NAMES mbedtls libmbedtls
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES library
-)
-FIND_LIBRARY(MBEDX509_LIBRARY
- NAMES mbedx509 libmbedx509
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES library
-)
-FIND_LIBRARY(MBEDCRYPTO_LIBRARY
- NAMES mbedcrypto libmbedcrypto
- ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
- PATH_SUFFIXES library
-)
-
-IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
- SET(MBEDTLS_FOUND TRUE)
-ENDIF()
-
-IF(MBEDTLS_FOUND)
- #Â split mbedTLS into -L and -l linker options, so we can set them for pkg-config
- GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
- GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
- GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
- GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
- STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
- STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
- STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
- SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
-
- IF(NOT MBEDTLS_FIND_QUIETLY)
- MESSAGE(STATUS "Found mbedTLS:")
- FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
- STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
- IF (MBEDTLSMATCH)
- STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
- MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
- ENDIF(MBEDTLSMATCH)
- MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
- MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
- MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
- ENDIF(NOT MBEDTLS_FIND_QUIETLY)
-ELSE(MBEDTLS_FOUND)
- IF(MBEDTLS_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find mbedTLS")
- ENDIF(MBEDTLS_FIND_REQUIRED)
-ENDIF(MBEDTLS_FOUND)
-
-MARK_AS_ADVANCED(
- MBEDTLS_INCLUDE_DIR
- MBEDTLS_LIBRARY_DIR
- MBEDTLS_LIBRARIES
- MBEDTLS_LIBRARY
- MBEDX509_LIBRARY
- MBEDCRYPTO_LIBRARY
-)
diff --git a/cmake/Modules/IdeSplitSources.cmake b/cmake/Modules/IdeSplitSources.cmake
deleted file mode 100644
index e2e09b4..0000000
--- a/cmake/Modules/IdeSplitSources.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-# This function splits the sources files up into their appropriate
-# subdirectories. This is especially useful for IDEs like Xcode and
-# Visual Studio, so that you can navigate into the libgit2_clar project,
-# and see the folders within the tests folder (instead of just seeing all
-# source and tests in a single folder.)
-FUNCTION(IDE_SPLIT_SOURCES target)
- IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
- GET_TARGET_PROPERTY(sources ${target} SOURCES)
- FOREACH(source ${sources})
- IF(source MATCHES ".*/")
- STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
- IF(rel)
- STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
- IF(rel)
- STRING(REPLACE "/" "\\\\" rel ${rel})
- SOURCE_GROUP(${rel} FILES ${source})
- ENDIF()
- ENDIF()
- ENDIF()
- ENDFOREACH()
- ENDIF()
-ENDFUNCTION()
diff --git a/cmake/Modules/PkgBuildConfig.cmake b/cmake/Modules/PkgBuildConfig.cmake
deleted file mode 100644
index 1c0079e..0000000
--- a/cmake/Modules/PkgBuildConfig.cmake
+++ /dev/null
@@ -1,110 +0,0 @@
-# pkg-config file generation
-#
-# Uses the following globals:
-# - PKG_BUILD_PREFIX: the build location (aka prefix). Defaults to CMAKE_INSTALL_PREFIX
-# - PKG_BUILD_LIBDIR: the libdir location. Defaults to ${prefix}/lib.
-# - PKG_BUILD_INCLUDEDIR: the includedir location. Defaults to ${prefix}/include.
-#
-
-function(pkg_build_config)
- set(options)
- set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
- set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
-
- cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME)
- set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME})
- endif()
- if (NOT DEFINED PKGCONFIG_FILENAME)
- message(FATAL_ERROR "Missing FILENAME argument")
- endif()
- set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc")
-
- if (NOT DEFINED PKGCONFIG_DESCRIPTION)
- message(FATAL_ERROR "Missing DESCRIPTION argument")
- endif()
-
- if (NOT DEFINED PKGCONFIG_VERSION)
- message(FATAL_ERROR "Missing VERSION argument")
- endif()
-
- if (DEFINED PKG_BUILD_PREFIX)
- set(PKGCONFIG_PREFIX "${PKG_BUILD_PREFIX}")
- else()
- set(PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
- endif()
-
- if(DEFINED PKG_BUILD_LIBDIR)
- if (IS_ABSOLUTE ${PKG_BUILD_LIBDIR})
- set(PKGCONFIG_LIBDIR ${PKG_BUILD_LIBDIR})
- else()
- set(PKGCONFIG_LIBDIR "\${prefix}/${PKG_BUILD_LIBDIR}")
- endif()
- else()
- set(PKGCONFIG_LIBDIR "\${prefix}/lib")
- endif()
-
- if(DEFINED PKG_BUILD_INCLUDEDIR)
- if (IS_ABSOLUTE ${PKG_BUILD_INCLUDEDIR})
- set(PKGCONFIG_INCLUDEDIR ${PKG_BUILD_INCLUDEDIR})
- else()
- set(PKGCONFIG_INCLUDEDIR "\${prefix}/${PKG_BUILD_INCLUDEDIR}")
- endif()
- else()
- set(PKGCONFIG_INCLUDEDIR "\${prefix}/include")
- endif()
-
- # Write .pc "header"
- file(WRITE "${PKGCONFIG_FILE}"
- "prefix=\"${PKGCONFIG_PREFIX}\"\n"
- "libdir=\"${PKGCONFIG_LIBDIR}\"\n"
- "includedir=\"${PKGCONFIG_INCLUDEDIR}\"\n"
- "\n"
- "Name: ${PKGCONFIG_NAME}\n"
- "Description: ${PKGCONFIG_DESCRIPTION}\n"
- "Version: ${PKGCONFIG_VERSION}\n"
- )
-
- # Prepare Libs
- if(NOT DEFINED PKGCONFIG_LIBS_SELF)
- set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}")
- endif()
-
- if(NOT DEFINED PKGCONFIG_LIBS)
- set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}")
- else()
- list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}")
- endif()
-
- list(REMOVE_DUPLICATES PKGCONFIG_LIBS)
- string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}")
- file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n")
-
- # Prepare Libs.private
- if(DEFINED PKGCONFIG_PRIVATE_LIBS)
- list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS)
- string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}")
- file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n")
- endif()
-
- # Prepare Requires.private
- if(DEFINED PKGCONFIG_REQUIRES)
- list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES)
- string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")
- file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n")
- endif()
-
- # Prepare Cflags
- if(DEFINED PKGCONFIG_CFLAGS)
- string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}")
- else()
- set(PKGCONFIG_CFLAGS "")
- endif()
- file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
-
- # Install .pc file
- install(FILES "${PKGCONFIG_FILE}"
- DESTINATION "${PKGCONFIG_PREFIX}/${PKGCONFIG_LIBDIR}/pkgconfig"
- )
-endfunction()
diff --git a/cmake/Modules/SelectGSSAPI.cmake b/cmake/Modules/SelectGSSAPI.cmake
deleted file mode 100644
index 857c449..0000000
--- a/cmake/Modules/SelectGSSAPI.cmake
+++ /dev/null
@@ -1,53 +0,0 @@
-# Select the backend to use
-
-# We try to find any packages our backends might use
-
-FIND_PACKAGE(GSSAPI)
-IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- INCLUDE(FindGSSFramework)
-ENDIF()
-
-# Auto-select GSS backend
-IF (USE_GSSAPI STREQUAL ON)
- IF (GSSFRAMEWORK_FOUND)
- SET(GSS_BACKEND "GSS.framework")
- ELSEIF(GSSAPI_FOUND)
- SET(GSS_BACKEND "gssapi")
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
- "Please pass the backend name explicitly (-DUSE_GSS=backend)")
- ENDIF()
-ELSEIF(USE_GSSAPI)
- # Backend was explicitly set
- SET(GSS_BACKEND ${USE_GSSAPI})
-ELSE()
- SET(GSS_BACKEND NO)
-ENDIF()
-
-IF(GSS_BACKEND)
- # Check that we can find what's required for the selected backend
- IF (GSS_BACKEND STREQUAL "GSS.framework")
- IF (NOT GSSFRAMEWORK_FOUND)
- MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
- ENDIF()
-
- LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})
-
- SET(GIT_GSSFRAMEWORK 1)
- ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${GSS_BACKEND})")
- ELSEIF (GSS_BACKEND STREQUAL "gssapi")
- IF (NOT GSSAPI_FOUND)
- MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
- ENDIF()
-
- LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})
-
- SET(GIT_GSSAPI 1)
- ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${GSS_BACKEND})")
- ELSE()
- MESSAGE(FATAL_ERROR "Asked for backend ${GSS_BACKEND} but it wasn't found")
- ENDIF()
-ELSE()
- SET(GIT_GSSAPI 0)
- ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
-ENDIF()
diff --git a/cmake/Modules/SelectHTTPSBackend.cmake b/cmake/Modules/SelectHTTPSBackend.cmake
deleted file mode 100644
index c7f6b8f..0000000
--- a/cmake/Modules/SelectHTTPSBackend.cmake
+++ /dev/null
@@ -1,124 +0,0 @@
-# Select the backend to use
-
-# We try to find any packages our backends might use
-FIND_PACKAGE(OpenSSL)
-FIND_PACKAGE(mbedTLS)
-IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- FIND_PACKAGE(Security)
- FIND_PACKAGE(CoreFoundation)
-ENDIF()
-
-# Auto-select TLS backend
-IF (USE_HTTPS STREQUAL ON)
- IF (SECURITY_FOUND)
- IF (SECURITY_HAS_SSLCREATECONTEXT)
- SET(HTTPS_BACKEND "SecureTransport")
- ELSE()
- MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
- SET(HTTPS_BACKEND "OpenSSL")
- ENDIF()
- ELSEIF (WINHTTP)
- SET(HTTPS_BACKEND "WinHTTP")
- ELSEIF(OPENSSL_FOUND)
- SET(HTTPS_BACKEND "OpenSSL")
- ELSEIF(MBEDTLS_FOUND)
- SET(HTTPS_BACKEND "mbedTLS")
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
- "Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
- ENDIF()
-ELSEIF(USE_HTTPS)
- # HTTPS backend was explicitly set
- SET(HTTPS_BACKEND ${USE_HTTPS})
-ELSE()
- SET(HTTPS_BACKEND NO)
-ENDIF()
-
-IF(HTTPS_BACKEND)
- # Check that we can find what's required for the selected backend
- IF (HTTPS_BACKEND STREQUAL "SecureTransport")
- IF (NOT COREFOUNDATION_FOUND)
- MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
- ENDIF()
- IF (NOT SECURITY_FOUND)
- MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
- ENDIF()
- IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
- MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
- ENDIF()
-
- SET(GIT_SECURE_TRANSPORT 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
- LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
- ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
- IF (NOT OPENSSL_FOUND)
- MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
- ENDIF()
-
- SET(GIT_OPENSSL 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
- LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
- ELSEIF(HTTPS_BACKEND STREQUAL "mbedTLS")
- IF (NOT MBEDTLS_FOUND)
- MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
- ENDIF()
-
- IF(NOT CERT_LOCATION)
- MESSAGE(STATUS "Auto-detecting default certificates location")
- IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
- # Check for an Homebrew installation
- SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
- ELSE()
- SET(OPENSSL_CMD "openssl")
- ENDIF()
- EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
- IF(OPENSSL_DIR)
- STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
-
- SET(OPENSSL_CA_LOCATIONS
- "ca-bundle.pem" # OpenSUSE Leap 42.1
- "cert.pem" # Ubuntu 14.04, FreeBSD
- "certs/ca-certificates.crt" # Ubuntu 16.04
- "certs/ca.pem" # Debian 7
- )
- FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
- SET(LOC "${OPENSSL_DIR}${SUFFIX}")
- IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
- SET(CERT_LOCATION ${LOC})
- ENDIF()
- ENDFOREACH()
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
- ENDIF()
- ENDIF()
-
- IF(CERT_LOCATION)
- IF(NOT EXISTS ${CERT_LOCATION})
- MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
- ENDIF()
- ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
- ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
- ENDIF()
-
- SET(GIT_MBEDTLS 1)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
- # mbedTLS has no pkgconfig file, hence we can't require it
- # https://github.com/ARMmbed/mbedtls/issues/228
- # For now, pass its link flags as our own
- LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
- ELSEIF (HTTPS_BACKEND STREQUAL "WinHTTP")
- # WinHTTP setup was handled in the WinHTTP-specific block above
- ELSE()
- MESSAGE(FATAL_ERROR "Asked for backend ${HTTPS_BACKEND} but it wasn't found")
- ENDIF()
-
- SET(GIT_HTTPS 1)
- ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${HTTPS_BACKEND}")
-ELSE()
- SET(GIT_HTTPS 0)
- ADD_FEATURE_INFO(HTTPS NO "")
-ENDIF()
diff --git a/cmake/Modules/SelectHashes.cmake b/cmake/Modules/SelectHashes.cmake
deleted file mode 100644
index ce28ac2..0000000
--- a/cmake/Modules/SelectHashes.cmake
+++ /dev/null
@@ -1,66 +0,0 @@
-# Select a hash backend
-
-# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
-
-IF(USE_SHA1 STREQUAL ON OR USE_SHA1 STREQUAL "CollisionDetection")
- SET(SHA1_BACKEND "CollisionDetection")
-ELSEIF(USE_SHA1 STREQUAL "HTTPS")
- message(STATUS "Checking HTTPS backend… ${HTTPS_BACKEND}")
- IF(HTTPS_BACKEND STREQUAL "SecureTransport")
- SET(SHA1_BACKEND "CommonCrypto")
- ELSEIF(HTTPS_BACKEND STREQUAL "WinHTTP")
- SET(SHA1_BACKEND "Win32")
- ELSEIF(HTTPS_BACKEND)
- SET(SHA1_BACKEND ${HTTPS_BACKEND})
- ELSE()
- ENDIF()
- IF(NOT HTTPS_BACKEND)
- SET(SHA1_BACKEND "CollisionDetection")
- ENDIF()
- message(STATUS "Using SHA1 backend ${SHA1_BACKEND}")
-ELSEIF(USE_SHA1 STREQUAL "Generic")
- SET(SHA1_BACKEND "Generic")
-# ELSEIF(NOT USE_SHA1)
-ELSE()
- MESSAGE(FATAL_ERROR "Invalid value for USE_SHA1: ${USE_SHA1}")
-ENDIF()
-
-IF(SHA1_BACKEND STREQUAL "CollisionDetection")
- SET(GIT_SHA1_COLLISIONDETECT 1)
- ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
- ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
- ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
- FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
-ELSEIF(SHA1_BACKEND STREQUAL "OpenSSL")
- # OPENSSL_FOUND should already be set, we're checking HTTPS_BACKEND
-
- SET(GIT_SHA1_OPENSSL 1)
- IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
- ELSE()
- LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
- ENDIF()
- FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
-ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto")
- SET(GIT_SHA1_COMMON_CRYPTO 1)
- FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
-ELSEIF(SHA1_BACKEND STREQUAL "mbedTLS")
- SET(GIT_SHA1_MBEDTLS 1)
- FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
- # mbedTLS has no pkgconfig file, hence we can't require it
- # https://github.com/ARMmbed/mbedtls/issues/228
- # For now, pass its link flags as our own
- LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
-ELSEIF(SHA1_BACKEND STREQUAL "Win32")
- SET(GIT_SHA1_WIN32 1)
- FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
-ELSEIF(SHA1_BACKEND STREQUAL "Generic")
- FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
-# ELSEIF(NOT USE_SHA1)
-ELSE()
- MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${SHA1_BACKEND}")
-ENDIF()
-
-ADD_FEATURE_INFO(SHA ON "using ${SHA1_BACKEND}")
diff --git a/cmake/PkgBuildConfig.cmake b/cmake/PkgBuildConfig.cmake
new file mode 100644
index 0000000..54c5e29
--- /dev/null
+++ b/cmake/PkgBuildConfig.cmake
@@ -0,0 +1,77 @@
+# pkg-config file generation
+#
+
+function(pkg_build_config)
+ set(options)
+ set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
+ set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
+
+ cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME)
+ set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME})
+ endif()
+ if (NOT DEFINED PKGCONFIG_FILENAME)
+ message(FATAL_ERROR "Missing FILENAME argument")
+ endif()
+ set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc")
+
+ if (NOT DEFINED PKGCONFIG_DESCRIPTION)
+ message(FATAL_ERROR "Missing DESCRIPTION argument")
+ endif()
+
+ if (NOT DEFINED PKGCONFIG_VERSION)
+ message(FATAL_ERROR "Missing VERSION argument")
+ endif()
+
+ # Write .pc "header"
+ file(WRITE "${PKGCONFIG_FILE}"
+ "prefix=\"${CMAKE_INSTALL_PREFIX}\"\n"
+ "libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n"
+ "includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n"
+ "\n"
+ "Name: ${PKGCONFIG_NAME}\n"
+ "Description: ${PKGCONFIG_DESCRIPTION}\n"
+ "Version: ${PKGCONFIG_VERSION}\n"
+ )
+
+ # Prepare Libs
+ if(NOT DEFINED PKGCONFIG_LIBS_SELF)
+ set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}")
+ endif()
+
+ if(NOT DEFINED PKGCONFIG_LIBS)
+ set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}")
+ else()
+ list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}")
+ endif()
+
+ list(REMOVE_DUPLICATES PKGCONFIG_LIBS)
+ string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}")
+ file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n")
+
+ # Prepare Libs.private
+ if(DEFINED PKGCONFIG_PRIVATE_LIBS)
+ list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS)
+ string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}")
+ file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n")
+ endif()
+
+ # Prepare Requires.private
+ if(DEFINED PKGCONFIG_REQUIRES)
+ list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES)
+ string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")
+ file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n")
+ endif()
+
+ # Prepare Cflags
+ if(DEFINED PKGCONFIG_CFLAGS)
+ string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}")
+ else()
+ set(PKGCONFIG_CFLAGS "")
+ endif()
+ file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
+
+ # Install .pc file
+ install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+endfunction()
diff --git a/cmake/SanitizeBool.cmake b/cmake/SanitizeBool.cmake
new file mode 100644
index 0000000..b5b99a6
--- /dev/null
+++ b/cmake/SanitizeBool.cmake
@@ -0,0 +1,20 @@
+FUNCTION(SanitizeBool VAR)
+ STRING(TOLOWER "${${VAR}}" VALUE)
+ IF(VALUE STREQUAL "on")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "yes")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "true")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "1")
+ SET(${VAR} "ON" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "off")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "no")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "false")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ELSEIF(VALUE STREQUAL "0")
+ SET(${VAR} "OFF" PARENT_SCOPE)
+ ENDIF()
+ENDFUNCTION()
diff --git a/cmake/SelectGSSAPI.cmake b/cmake/SelectGSSAPI.cmake
new file mode 100644
index 0000000..0a42eee
--- /dev/null
+++ b/cmake/SelectGSSAPI.cmake
@@ -0,0 +1,48 @@
+INCLUDE(SanitizeBool)
+
+# We try to find any packages our backends might use
+FIND_PACKAGE(GSSAPI)
+IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ INCLUDE(FindGSSFramework)
+ENDIF()
+
+IF(USE_GSSAPI)
+ # Auto-select GSS backend
+ SanitizeBool(USE_GSSAPI)
+ IF (USE_GSSAPI STREQUAL ON)
+ IF (GSSFRAMEWORK_FOUND)
+ SET(USE_GSSAPI "GSS.framework")
+ ELSEIF(GSSAPI_FOUND)
+ SET(USE_GSSAPI "gssapi")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
+ "Please pass the backend name explicitly (-DUSE_GSS=backend)")
+ ENDIF()
+ ENDIF()
+
+ # Check that we can find what's required for the selected backend
+ IF (USE_GSSAPI STREQUAL "GSS.framework")
+ IF (NOT GSSFRAMEWORK_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
+ ENDIF()
+
+ LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})
+
+ SET(GIT_GSSFRAMEWORK 1)
+ ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
+ ELSEIF (USE_GSSAPI STREQUAL "gssapi")
+ IF (NOT GSSAPI_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
+ ENDIF()
+
+ LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})
+
+ SET(GIT_GSSAPI 1)
+ ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
+ ENDIF()
+ELSE()
+ SET(GIT_GSSAPI 0)
+ ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
+ENDIF()
diff --git a/cmake/SelectHTTPSBackend.cmake b/cmake/SelectHTTPSBackend.cmake
new file mode 100644
index 0000000..4998f0f
--- /dev/null
+++ b/cmake/SelectHTTPSBackend.cmake
@@ -0,0 +1,124 @@
+INCLUDE(SanitizeBool)
+
+# We try to find any packages our backends might use
+FIND_PACKAGE(OpenSSL)
+FIND_PACKAGE(mbedTLS)
+IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ FIND_PACKAGE(Security)
+ FIND_PACKAGE(CoreFoundation)
+ENDIF()
+
+IF(USE_HTTPS)
+ # Auto-select TLS backend
+ SanitizeBool(USE_HTTPS)
+ IF (USE_HTTPS STREQUAL ON)
+ IF (SECURITY_FOUND)
+ IF (SECURITY_HAS_SSLCREATECONTEXT)
+ SET(USE_HTTPS "SecureTransport")
+ ELSE()
+ MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
+ SET(USE_HTTPS "OpenSSL")
+ ENDIF()
+ ELSEIF (WINHTTP)
+ SET(USE_HTTPS "WinHTTP")
+ ELSEIF(OPENSSL_FOUND)
+ SET(USE_HTTPS "OpenSSL")
+ ELSEIF(MBEDTLS_FOUND)
+ SET(USE_HTTPS "mbedTLS")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
+ "Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
+ ENDIF()
+ ENDIF()
+
+ # Check that we can find what's required for the selected backend
+ IF (USE_HTTPS STREQUAL "SecureTransport")
+ IF (NOT COREFOUNDATION_FOUND)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
+ ENDIF()
+ IF (NOT SECURITY_FOUND)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
+ ENDIF()
+ IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
+ ENDIF()
+
+ SET(GIT_SECURE_TRANSPORT 1)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
+ LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
+ ELSEIF (USE_HTTPS STREQUAL "OpenSSL")
+ IF (NOT OPENSSL_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
+ ENDIF()
+
+ SET(GIT_OPENSSL 1)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
+ LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
+ LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
+ ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
+ IF (NOT MBEDTLS_FOUND)
+ MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
+ ENDIF()
+
+ IF(NOT CERT_LOCATION)
+ MESSAGE(STATUS "Auto-detecting default certificates location")
+ IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
+ # Check for an Homebrew installation
+ SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
+ ELSE()
+ SET(OPENSSL_CMD "openssl")
+ ENDIF()
+ EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
+ IF(OPENSSL_DIR)
+ STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
+
+ SET(OPENSSL_CA_LOCATIONS
+ "ca-bundle.pem" # OpenSUSE Leap 42.1
+ "cert.pem" # Ubuntu 14.04, FreeBSD
+ "certs/ca-certificates.crt" # Ubuntu 16.04
+ "certs/ca.pem" # Debian 7
+ )
+ FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
+ SET(LOC "${OPENSSL_DIR}${SUFFIX}")
+ IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
+ SET(CERT_LOCATION ${LOC})
+ ENDIF()
+ ENDFOREACH()
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
+ ENDIF()
+ ENDIF()
+
+ IF(CERT_LOCATION)
+ IF(NOT EXISTS ${CERT_LOCATION})
+ MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
+ ENDIF()
+ ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
+ ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
+ ENDIF()
+
+ SET(GIT_MBEDTLS 1)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
+ # mbedTLS has no pkgconfig file, hence we can't require it
+ # https://github.com/ARMmbed/mbedtls/issues/228
+ # For now, pass its link flags as our own
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
+ ELSEIF (USE_HTTPS STREQUAL "WinHTTP")
+ # WinHTTP setup was handled in the WinHTTP-specific block above
+ ELSEIF (USE_HTTPS STREQUAL "OpenSSL-Dynamic")
+ SET(GIT_OPENSSL 1)
+ SET(GIT_OPENSSL_DYNAMIC 1)
+ LIST(APPEND LIBGIT2_LIBS dl)
+ ELSE()
+ MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
+ ENDIF()
+
+ SET(GIT_HTTPS 1)
+ ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
+ELSE()
+ SET(GIT_HTTPS 0)
+ ADD_FEATURE_INFO(HTTPS NO "")
+ENDIF()
diff --git a/cmake/SelectHashes.cmake b/cmake/SelectHashes.cmake
new file mode 100644
index 0000000..092cdfd
--- /dev/null
+++ b/cmake/SelectHashes.cmake
@@ -0,0 +1,62 @@
+# Select a hash backend
+
+INCLUDE(SanitizeBool)
+
+# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
+
+SanitizeBool(USE_SHA1)
+IF(USE_SHA1 STREQUAL ON)
+ SET(USE_SHA1 "CollisionDetection")
+ELSEIF(USE_SHA1 STREQUAL "HTTPS")
+ IF(USE_HTTPS STREQUAL "SecureTransport")
+ SET(USE_SHA1 "CommonCrypto")
+ ELSEIF(USE_HTTPS STREQUAL "WinHTTP")
+ SET(USE_SHA1 "Win32")
+ ELSEIF(USE_HTTPS)
+ SET(USE_SHA1 ${USE_HTTPS})
+ ELSE()
+ SET(USE_SHA1 "CollisionDetection")
+ ENDIF()
+ENDIF()
+
+IF(USE_SHA1 STREQUAL "CollisionDetection")
+ SET(GIT_SHA1_COLLISIONDETECT 1)
+ ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
+ ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
+ ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
+ FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
+ELSEIF(USE_SHA1 STREQUAL "OpenSSL")
+ # OPENSSL_FOUND should already be set, we're checking USE_HTTPS
+
+ SET(GIT_SHA1_OPENSSL 1)
+ IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
+ ELSE()
+ LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
+ ENDIF()
+ FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
+ELSEIF(USE_SHA1 STREQUAL "CommonCrypto")
+ SET(GIT_SHA1_COMMON_CRYPTO 1)
+ FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
+ELSEIF(USE_SHA1 STREQUAL "mbedTLS")
+ SET(GIT_SHA1_MBEDTLS 1)
+ FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
+ # mbedTLS has no pkgconfig file, hence we can't require it
+ # https://github.com/ARMmbed/mbedtls/issues/228
+ # For now, pass its link flags as our own
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
+ELSEIF(USE_SHA1 STREQUAL "Win32")
+ SET(GIT_SHA1_WIN32 1)
+ FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
+ELSEIF(USE_SHA1 STREQUAL "Generic")
+ FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
+ELSE()
+ MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
+ENDIF()
+
+list(APPEND SRC_SHA1 "hash/sha1.h")
+list(SORT SRC_SHA1)
+
+ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")
diff --git a/deps/chromium-zlib/CMakeLists.txt b/deps/chromium-zlib/CMakeLists.txt
new file mode 100644
index 0000000..bbb35d4
--- /dev/null
+++ b/deps/chromium-zlib/CMakeLists.txt
@@ -0,0 +1,101 @@
+# CMake build script for the bundled Chromium zlib implementation. So far, it
+# is only supported for x86_64 processors with CLMUL, SSE3, SSE4.2.
+#
+# TODO: The Chromium build file (in deps/chromium-zlib/zlib/BUILD.gn) supports
+# more platforms (like ARM with NEON), more can be enabled as needed.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 3.11)
+
+include(FetchContent)
+include(FindGit)
+
+# Ensure that the git binary is present to download the sources.
+find_package(Git)
+IF(NOT Git_FOUND)
+ message(FATAL_ERROR "git is required to download the Chromium zlib sources")
+ENDIF()
+
+FetchContent_Populate(chromium_zlib_src
+ GIT_REPOSITORY https://chromium.googlesource.com/chromium/src/third_party/zlib.git
+ GIT_TAG 2c183c9f93a328bfb3121284da13cf89a0f7e64a
+ QUIET
+)
+
+# The Chromium build globally disables some warnings.
+disable_warnings(implicit-fallthrough)
+disable_warnings(unused-function)
+disable_warnings(unused-parameter)
+disable_warnings(sign-compare)
+disable_warnings(declaration-after-statement)
+disable_warnings(missing-declarations)
+
+# -O3 is also set by the Chromium configuration and has been deemed safe enough
+# for them.
+SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
+SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
+
+# Common definitions.
+add_definitions(
+ -DSTDC
+ -DNO_GZIP
+ -DZLIB_IMPLEMENTATION
+)
+list(APPEND SRC_ZLIB
+ "${chromium_zlib_src_SOURCE_DIR}/adler32.c"
+ "${chromium_zlib_src_SOURCE_DIR}/chromeconf.h"
+ "${chromium_zlib_src_SOURCE_DIR}/compress.c"
+ "${chromium_zlib_src_SOURCE_DIR}/contrib/optimizations/insert_string.h"
+ "${chromium_zlib_src_SOURCE_DIR}/cpu_features.c"
+ "${chromium_zlib_src_SOURCE_DIR}/cpu_features.h"
+ "${chromium_zlib_src_SOURCE_DIR}/crc32.c"
+ "${chromium_zlib_src_SOURCE_DIR}/crc32.h"
+ "${chromium_zlib_src_SOURCE_DIR}/deflate.c"
+ "${chromium_zlib_src_SOURCE_DIR}/deflate.h"
+ "${chromium_zlib_src_SOURCE_DIR}/gzclose.c"
+ "${chromium_zlib_src_SOURCE_DIR}/gzguts.h"
+ "${chromium_zlib_src_SOURCE_DIR}/gzlib.c"
+ "${chromium_zlib_src_SOURCE_DIR}/gzread.c"
+ "${chromium_zlib_src_SOURCE_DIR}/gzwrite.c"
+ "${chromium_zlib_src_SOURCE_DIR}/infback.c"
+ "${chromium_zlib_src_SOURCE_DIR}/inffast.c"
+ "${chromium_zlib_src_SOURCE_DIR}/inffast.h"
+ "${chromium_zlib_src_SOURCE_DIR}/inffixed.h"
+ "${chromium_zlib_src_SOURCE_DIR}/inflate.h"
+ "${chromium_zlib_src_SOURCE_DIR}/inftrees.c"
+ "${chromium_zlib_src_SOURCE_DIR}/inftrees.h"
+ "${chromium_zlib_src_SOURCE_DIR}/trees.c"
+ "${chromium_zlib_src_SOURCE_DIR}/trees.h"
+ "${chromium_zlib_src_SOURCE_DIR}/uncompr.c"
+ "${chromium_zlib_src_SOURCE_DIR}/zconf.h"
+ "${chromium_zlib_src_SOURCE_DIR}/zlib.h"
+ "${chromium_zlib_src_SOURCE_DIR}/zutil.c"
+ "${chromium_zlib_src_SOURCE_DIR}/zutil.h"
+)
+
+# x86_64-specific optimizations
+string(APPEND CMAKE_C_FLAGS " -mssse3 -msse4.2 -mpclmul")
+add_definitions(
+ -DCHROMIUM_ZLIB_NO_CHROMECONF
+ -DX86_NOT_WINDOWS
+ -DADLER32_SIMD_SSSE3
+ -DCRC32_SIMD_SSE42_PCLMUL
+ -DDEFLATE_FILL_WINDOW_SSE2
+ -DINFLATE_CHUNK_READ_64LE
+ -DINFLATE_CHUNK_SIMD_SSE2
+)
+list(APPEND SRC_ZLIB
+ "${chromium_zlib_src_SOURCE_DIR}/adler32_simd.c"
+ "${chromium_zlib_src_SOURCE_DIR}/adler32_simd.h"
+ "${chromium_zlib_src_SOURCE_DIR}/contrib/optimizations/chunkcopy.h"
+ "${chromium_zlib_src_SOURCE_DIR}/contrib/optimizations/inffast_chunk.c"
+ "${chromium_zlib_src_SOURCE_DIR}/contrib/optimizations/inffast_chunk.h"
+ "${chromium_zlib_src_SOURCE_DIR}/contrib/optimizations/inflate.c"
+ "${chromium_zlib_src_SOURCE_DIR}/crc32_simd.c"
+ "${chromium_zlib_src_SOURCE_DIR}/crc32_simd.h"
+ "${chromium_zlib_src_SOURCE_DIR}/crc_folding.c"
+ "${chromium_zlib_src_SOURCE_DIR}/fill_window_sse.c"
+)
+
+list(SORT SRC_ZLIB)
+include_directories("${chromium_zlib_src_SOURCE_DIR}")
+add_library(chromium_zlib OBJECT ${SRC_ZLIB})
diff --git a/deps/http-parser/CMakeLists.txt b/deps/http-parser/CMakeLists.txt
index 4a8bafd..b9da249 100644
--- a/deps/http-parser/CMakeLists.txt
+++ b/deps/http-parser/CMakeLists.txt
@@ -1,5 +1,6 @@
-FILE(GLOB SRC_HTTP "*.c" "*.h")
+file(GLOB SRC_HTTP "*.c" "*.h")
+list(SORT SRC_HTTP)
-ADD_LIBRARY(http-parser OBJECT ${SRC_HTTP})
+add_library(http-parser OBJECT ${SRC_HTTP})
-ENABLE_WARNINGS(implicit-fallthrough=1)
+enable_warnings(implicit-fallthrough=1)
diff --git a/deps/ntlmclient/CMakeLists.txt b/deps/ntlmclient/CMakeLists.txt
index 66e96d6..3e0d2c8 100644
--- a/deps/ntlmclient/CMakeLists.txt
+++ b/deps/ntlmclient/CMakeLists.txt
@@ -1,21 +1,37 @@
-FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "unicode_builtin.c" "util.c")
+FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h")
+LIST(SORT SRC_NTLMCLIENT)
ADD_DEFINITIONS(-DNTLM_STATIC=1)
DISABLE_WARNINGS(implicit-fallthrough)
-IF (HTTPS_BACKEND STREQUAL "SecureTransport")
+IF(USE_ICONV)
+ ADD_DEFINITIONS(-DUNICODE_ICONV=1)
+ FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h")
+ELSE()
+ ADD_DEFINITIONS(-DUNICODE_BUILTIN=1)
+ FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h")
+ENDIF()
+
+IF(USE_HTTPS STREQUAL "SecureTransport")
ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO)
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c")
-ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
+ SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h")
+ # CC_MD4 has been deprecated in macOS 10.15.
+ SET_SOURCE_FILES_PROPERTIES("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
+ELSEIF(USE_HTTPS STREQUAL "OpenSSL")
ADD_DEFINITIONS(-DCRYPT_OPENSSL)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c")
-ELSEIF (HTTPS_BACKEND STREQUAL "mbedTLS")
+ SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
+ELSEIF(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
+ ADD_DEFINITIONS(-DCRYPT_OPENSSL)
+ ADD_DEFINITIONS(-DCRYPT_OPENSSL_DYNAMIC)
+ SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
+ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
ADD_DEFINITIONS(-DCRYPT_MBEDTLS)
- SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c")
-ELSE ()
- MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${HTTPS_BACKEND}) for NTLM crypto")
+ INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIR})
+ SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h")
+ELSE()
+ MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto")
ENDIF()
-ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_CRYPTO})
+ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
diff --git a/deps/ntlmclient/compat.h b/deps/ntlmclient/compat.h
index efdf345..befc7cc 100644
--- a/deps/ntlmclient/compat.h
+++ b/deps/ntlmclient/compat.h
@@ -21,11 +21,6 @@
# include <stdbool.h>
#endif
-#ifdef __linux__
-# include <endian.h>
-# define htonll htobe64
-#endif
-
#ifndef MIN
# define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
diff --git a/deps/ntlmclient/crypt.h b/deps/ntlmclient/crypt.h
index 48be399..4ad543e 100644
--- a/deps/ntlmclient/crypt.h
+++ b/deps/ntlmclient/crypt.h
@@ -9,6 +9,9 @@
#ifndef PRIVATE_CRYPT_COMMON_H__
#define PRIVATE_CRYPT_COMMON_H__
+#include "ntlmclient.h"
+#include "ntlm.h"
+
#if defined(CRYPT_OPENSSL)
# include "crypt_openssl.h"
#elif defined(CRYPT_MBEDTLS)
@@ -25,40 +28,42 @@
typedef unsigned char ntlm_des_block[CRYPT_DES_BLOCKSIZE];
+typedef struct ntlm_crypt_ctx ntlm_crypt_ctx;
+
+extern bool ntlm_crypt_init(ntlm_client *ntlm);
+
extern bool ntlm_random_bytes(
- ntlm_client *ntlm,
unsigned char *out,
+ ntlm_client *ntlm,
size_t len);
extern bool ntlm_des_encrypt(
ntlm_des_block *out,
+ ntlm_client *ntlm,
ntlm_des_block *plaintext,
ntlm_des_block *key);
extern bool ntlm_md4_digest(
unsigned char out[CRYPT_MD4_DIGESTSIZE],
+ ntlm_client *ntlm,
const unsigned char *in,
size_t in_len);
-extern ntlm_hmac_ctx *ntlm_hmac_ctx_init(void);
-
-extern bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx);
-
extern bool ntlm_hmac_md5_init(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *key,
size_t key_len);
extern bool ntlm_hmac_md5_update(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *data,
size_t data_len);
extern bool ntlm_hmac_md5_final(
unsigned char *out,
size_t *out_len,
- ntlm_hmac_ctx *ctx);
+ ntlm_client *ntlm);
-extern void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx);
+extern void ntlm_crypt_shutdown(ntlm_client *ntlm);
#endif /* PRIVATE_CRYPT_COMMON_H__ */
diff --git a/deps/ntlmclient/crypt_commoncrypto.c b/deps/ntlmclient/crypt_commoncrypto.c
index 54a0f09..4ff57ed 100644
--- a/deps/ntlmclient/crypt_commoncrypto.c
+++ b/deps/ntlmclient/crypt_commoncrypto.c
@@ -18,9 +18,15 @@
#include "ntlm.h"
#include "crypt.h"
+bool ntlm_crypt_init(ntlm_client *ntlm)
+{
+ memset(&ntlm->crypt_ctx, 0, sizeof(ntlm_crypt_ctx));
+ return true;
+}
+
bool ntlm_random_bytes(
- ntlm_client *ntlm,
unsigned char *out,
+ ntlm_client *ntlm,
size_t len)
{
int fd, ret;
@@ -49,11 +55,14 @@ bool ntlm_random_bytes(
bool ntlm_des_encrypt(
ntlm_des_block *out,
+ ntlm_client *ntlm,
ntlm_des_block *plaintext,
ntlm_des_block *key)
{
size_t written;
+ NTLM_UNUSED(ntlm);
+
CCCryptorStatus result = CCCrypt(kCCEncrypt,
kCCAlgorithmDES, kCCOptionECBMode,
key, sizeof(ntlm_des_block), NULL,
@@ -65,56 +74,47 @@ bool ntlm_des_encrypt(
bool ntlm_md4_digest(
unsigned char out[CRYPT_MD4_DIGESTSIZE],
+ ntlm_client *ntlm,
const unsigned char *in,
size_t in_len)
{
+ NTLM_UNUSED(ntlm);
return !!CC_MD4(in, in_len, out);
}
-ntlm_hmac_ctx *ntlm_hmac_ctx_init(void)
-{
- return calloc(1, sizeof(ntlm_hmac_ctx));
-}
-
-bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx)
-{
- memset(ctx, 0, sizeof(ntlm_hmac_ctx));
- return true;
-}
-
bool ntlm_hmac_md5_init(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *key,
size_t key_len)
{
- CCHmacInit(&ctx->native, kCCHmacAlgMD5, key, key_len);
+ CCHmacInit(&ntlm->crypt_ctx.hmac, kCCHmacAlgMD5, key, key_len);
return true;
}
bool ntlm_hmac_md5_update(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *data,
size_t data_len)
{
- CCHmacUpdate(&ctx->native, data, data_len);
+ CCHmacUpdate(&ntlm->crypt_ctx.hmac, data, data_len);
return true;
}
bool ntlm_hmac_md5_final(
unsigned char *out,
size_t *out_len,
- ntlm_hmac_ctx *ctx)
+ ntlm_client *ntlm)
{
if (*out_len < CRYPT_MD5_DIGESTSIZE)
return false;
- CCHmacFinal(&ctx->native, out);
+ CCHmacFinal(&ntlm->crypt_ctx.hmac, out);
*out_len = CRYPT_MD5_DIGESTSIZE;
return true;
}
-void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx)
+void ntlm_crypt_shutdown(ntlm_client *ntlm)
{
- free(ctx);
+ NTLM_UNUSED(ntlm);
}
diff --git a/deps/ntlmclient/crypt_commoncrypto.h b/deps/ntlmclient/crypt_commoncrypto.h
index e4075c9..e4df91d 100644
--- a/deps/ntlmclient/crypt_commoncrypto.h
+++ b/deps/ntlmclient/crypt_commoncrypto.h
@@ -11,8 +11,8 @@
#include <CommonCrypto/CommonCrypto.h>
-typedef struct {
- CCHmacContext native;
-} ntlm_hmac_ctx;
+struct ntlm_crypt_ctx {
+ CCHmacContext hmac;
+};
#endif /* PRIVATE_CRYPT_COMMONCRYPTO_H__ */
diff --git a/deps/ntlmclient/crypt_mbedtls.c b/deps/ntlmclient/crypt_mbedtls.c
index bbab02d..6283c3e 100644
--- a/deps/ntlmclient/crypt_mbedtls.c
+++ b/deps/ntlmclient/crypt_mbedtls.c
@@ -17,9 +17,24 @@
#include "ntlm.h"
#include "crypt.h"
+bool ntlm_crypt_init(ntlm_client *ntlm)
+{
+ const mbedtls_md_info_t *info = mbedtls_md_info_from_type(MBEDTLS_MD_MD5);
+
+ mbedtls_md_init(&ntlm->crypt_ctx.hmac);
+
+ if (mbedtls_md_setup(&ntlm->crypt_ctx.hmac, info, 1) != 0) {
+ ntlm_client_set_errmsg(ntlm, "could not setup mbedtls digest");
+ return false;
+ }
+
+ return true;
+}
+
+
bool ntlm_random_bytes(
- ntlm_client *ntlm,
unsigned char *out,
+ ntlm_client *ntlm,
size_t len)
{
mbedtls_ctr_drbg_context ctr_drbg;
@@ -51,6 +66,7 @@ bool ntlm_random_bytes(
bool ntlm_des_encrypt(
ntlm_des_block *out,
+ ntlm_client *ntlm,
ntlm_des_block *plaintext,
ntlm_des_block *key)
{
@@ -60,8 +76,10 @@ bool ntlm_des_encrypt(
mbedtls_des_init(&ctx);
if (mbedtls_des_setkey_enc(&ctx, *key) ||
- mbedtls_des_crypt_ecb(&ctx, *plaintext, *out))
+ mbedtls_des_crypt_ecb(&ctx, *plaintext, *out)) {
+ ntlm_client_set_errmsg(ntlm, "DES encryption failed");
goto done;
+ }
success = true;
@@ -72,11 +90,14 @@ done:
bool ntlm_md4_digest(
unsigned char out[CRYPT_MD4_DIGESTSIZE],
+ ntlm_client *ntlm,
const unsigned char *in,
size_t in_len)
{
mbedtls_md4_context ctx;
+ NTLM_UNUSED(ntlm);
+
mbedtls_md4_init(&ctx);
mbedtls_md4_starts(&ctx);
mbedtls_md4_update(&ctx, in, in_len);
@@ -86,60 +107,40 @@ bool ntlm_md4_digest(
return true;
}
-ntlm_hmac_ctx *ntlm_hmac_ctx_init(void)
-{
- ntlm_hmac_ctx *ctx;
- const mbedtls_md_info_t *info = mbedtls_md_info_from_type(MBEDTLS_MD_MD5);
-
- if ((ctx = calloc(1, sizeof(ntlm_hmac_ctx))) == NULL)
- return NULL;
-
- mbedtls_md_init(&ctx->mbed);
-
- if (mbedtls_md_setup(&ctx->mbed, info, 1) != 0) {
- free(ctx);
- return false;
- }
-
- return ctx;
-}
-
-bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx)
-{
- return !mbedtls_md_hmac_reset(&ctx->mbed);
-}
-
bool ntlm_hmac_md5_init(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *key,
size_t key_len)
{
- return !mbedtls_md_hmac_starts(&ctx->mbed, key, key_len);
+ if (ntlm->crypt_ctx.hmac_initialized) {
+ if (mbedtls_md_hmac_reset(&ntlm->crypt_ctx.hmac))
+ return false;
+ }
+
+ ntlm->crypt_ctx.hmac_initialized = !mbedtls_md_hmac_starts(&ntlm->crypt_ctx.hmac, key, key_len);
+ return ntlm->crypt_ctx.hmac_initialized;
}
bool ntlm_hmac_md5_update(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *in,
size_t in_len)
{
- return !mbedtls_md_hmac_update(&ctx->mbed, in, in_len);
+ return !mbedtls_md_hmac_update(&ntlm->crypt_ctx.hmac, in, in_len);
}
bool ntlm_hmac_md5_final(
unsigned char *out,
size_t *out_len,
- ntlm_hmac_ctx *ctx)
+ ntlm_client *ntlm)
{
if (*out_len < CRYPT_MD5_DIGESTSIZE)
return false;
- return !mbedtls_md_hmac_finish(&ctx->mbed, out);
+ return !mbedtls_md_hmac_finish(&ntlm->crypt_ctx.hmac, out);
}
-void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx)
+void ntlm_crypt_shutdown(ntlm_client *ntlm)
{
- if (ctx) {
- mbedtls_md_free(&ctx->mbed);
- free(ctx);
- }
+ mbedtls_md_free(&ntlm->crypt_ctx.hmac);
}
diff --git a/deps/ntlmclient/crypt_mbedtls.h b/deps/ntlmclient/crypt_mbedtls.h
index eb49a45..2fc8503 100644
--- a/deps/ntlmclient/crypt_mbedtls.h
+++ b/deps/ntlmclient/crypt_mbedtls.h
@@ -11,8 +11,9 @@
#include "mbedtls/md.h"
-typedef struct {
- mbedtls_md_context_t mbed;
-} ntlm_hmac_ctx;
+struct ntlm_crypt_ctx {
+ mbedtls_md_context_t hmac;
+ unsigned int hmac_initialized : 1;
+};
#endif /* PRIVATE_CRYPT_MBEDTLS_H__ */
diff --git a/deps/ntlmclient/crypt_openssl.c b/deps/ntlmclient/crypt_openssl.c
index 785be10..463eae4 100644
--- a/deps/ntlmclient/crypt_openssl.c
+++ b/deps/ntlmclient/crypt_openssl.c
@@ -9,26 +9,166 @@
#include <stdlib.h>
#include <string.h>
-#include <openssl/rand.h>
-#include <openssl/des.h>
-#include <openssl/md4.h>
-#include <openssl/hmac.h>
-#include <openssl/err.h>
+#ifdef CRYPT_OPENSSL_DYNAMIC
+# include <dlfcn.h>
+#else
+# include <openssl/rand.h>
+# include <openssl/des.h>
+# include <openssl/md4.h>
+# include <openssl/hmac.h>
+# include <openssl/err.h>
+#endif
#include "ntlm.h"
#include "compat.h"
#include "util.h"
#include "crypt.h"
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(CRYPT_OPENSSL_DYNAMIC)
+
+static inline HMAC_CTX *HMAC_CTX_new(void)
+{
+ return calloc(1, sizeof(HMAC_CTX));
+}
+
+static inline int HMAC_CTX_reset(HMAC_CTX *ctx)
+{
+ ntlm_memzero(ctx, sizeof(HMAC_CTX));
+ return 1;
+}
+
+static inline void HMAC_CTX_free(HMAC_CTX *ctx)
+{
+ free(ctx);
+}
+
+#endif
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(CRYPT_OPENSSL_DYNAMIC)
+
+static inline void HMAC_CTX_cleanup(HMAC_CTX *ctx)
+{
+ NTLM_UNUSED(ctx);
+}
+
+#endif
+
+
+#ifdef CRYPT_OPENSSL_DYNAMIC
+
+static bool ntlm_crypt_init_functions(ntlm_client *ntlm)
+{
+ void *handle;
+
+ if ((handle = dlopen("libssl.so.1.1", RTLD_NOW)) == NULL &&
+ (handle = dlopen("libssl.1.1.dylib", RTLD_NOW)) == NULL &&
+ (handle = dlopen("libssl.so.1.0.0", RTLD_NOW)) == NULL &&
+ (handle = dlopen("libssl.1.0.0.dylib", RTLD_NOW)) == NULL &&
+ (handle = dlopen("libssl.so.10", RTLD_NOW)) == NULL) {
+ ntlm_client_set_errmsg(ntlm, "could not open libssl");
+ return false;
+ }
+
+ ntlm->crypt_ctx.des_set_key_fn = dlsym(handle, "DES_set_key");
+ ntlm->crypt_ctx.des_ecb_encrypt_fn = dlsym(handle, "DES_ecb_encrypt");
+ ntlm->crypt_ctx.err_get_error_fn = dlsym(handle, "ERR_get_error");
+ ntlm->crypt_ctx.err_lib_error_string_fn = dlsym(handle, "ERR_lib_error_string");
+ ntlm->crypt_ctx.evp_md5_fn = dlsym(handle, "EVP_md5");
+ ntlm->crypt_ctx.hmac_ctx_new_fn = dlsym(handle, "HMAC_CTX_new");
+ ntlm->crypt_ctx.hmac_ctx_free_fn = dlsym(handle, "HMAC_CTX_free");
+ ntlm->crypt_ctx.hmac_ctx_reset_fn = dlsym(handle, "HMAC_CTX_reset");
+ ntlm->crypt_ctx.hmac_init_ex_fn = dlsym(handle, "HMAC_Init_ex");
+ ntlm->crypt_ctx.hmac_update_fn = dlsym(handle, "HMAC_Update");
+ ntlm->crypt_ctx.hmac_final_fn = dlsym(handle, "HMAC_Final");
+ ntlm->crypt_ctx.md4_fn = dlsym(handle, "MD4");
+ ntlm->crypt_ctx.rand_bytes_fn = dlsym(handle, "RAND_bytes");
+
+ if (!ntlm->crypt_ctx.des_set_key_fn ||
+ !ntlm->crypt_ctx.des_ecb_encrypt_fn ||
+ !ntlm->crypt_ctx.err_get_error_fn ||
+ !ntlm->crypt_ctx.err_lib_error_string_fn ||
+ !ntlm->crypt_ctx.evp_md5_fn ||
+ !ntlm->crypt_ctx.hmac_init_ex_fn ||
+ !ntlm->crypt_ctx.hmac_update_fn ||
+ !ntlm->crypt_ctx.hmac_final_fn ||
+ !ntlm->crypt_ctx.md4_fn ||
+ !ntlm->crypt_ctx.rand_bytes_fn) {
+ ntlm_client_set_errmsg(ntlm, "could not load libssl functions");
+ dlclose(handle);
+ return false;
+ }
+
+ /* Toggle legacy HMAC context functions */
+ if (ntlm->crypt_ctx.hmac_ctx_new_fn &&
+ ntlm->crypt_ctx.hmac_ctx_free_fn &&
+ ntlm->crypt_ctx.hmac_ctx_reset_fn) {
+ ntlm->crypt_ctx.hmac_ctx_cleanup_fn = HMAC_CTX_cleanup;
+ } else {
+ ntlm->crypt_ctx.hmac_ctx_cleanup_fn = dlsym(handle, "HMAC_CTX_cleanup");
+
+ if (!ntlm->crypt_ctx.hmac_ctx_cleanup_fn) {
+ ntlm_client_set_errmsg(ntlm, "could not load legacy libssl functions");
+ dlclose(handle);
+ return false;
+ }
+
+ ntlm->crypt_ctx.hmac_ctx_new_fn = HMAC_CTX_new;
+ ntlm->crypt_ctx.hmac_ctx_free_fn = HMAC_CTX_free;
+ ntlm->crypt_ctx.hmac_ctx_reset_fn = HMAC_CTX_reset;
+ }
+
+ ntlm->crypt_ctx.openssl_handle = handle;
+ return true;
+}
+
+#else /* CRYPT_OPENSSL_DYNAMIC */
+
+static bool ntlm_crypt_init_functions(ntlm_client *ntlm)
+{
+ ntlm->crypt_ctx.des_set_key_fn = DES_set_key;
+ ntlm->crypt_ctx.des_ecb_encrypt_fn = DES_ecb_encrypt;
+ ntlm->crypt_ctx.err_get_error_fn = ERR_get_error;
+ ntlm->crypt_ctx.err_lib_error_string_fn = ERR_lib_error_string;
+ ntlm->crypt_ctx.evp_md5_fn = EVP_md5;
+ ntlm->crypt_ctx.hmac_ctx_new_fn = HMAC_CTX_new;
+ ntlm->crypt_ctx.hmac_ctx_free_fn = HMAC_CTX_free;
+ ntlm->crypt_ctx.hmac_ctx_reset_fn = HMAC_CTX_reset;
+ ntlm->crypt_ctx.hmac_ctx_cleanup_fn = HMAC_CTX_cleanup;
+ ntlm->crypt_ctx.hmac_init_ex_fn = HMAC_Init_ex;
+ ntlm->crypt_ctx.hmac_update_fn = HMAC_Update;
+ ntlm->crypt_ctx.hmac_final_fn = HMAC_Final;
+ ntlm->crypt_ctx.md4_fn = MD4;
+ ntlm->crypt_ctx.rand_bytes_fn = RAND_bytes;
+
+ return true;
+}
+
+#endif /* CRYPT_OPENSSL_DYNAMIC */
+
+bool ntlm_crypt_init(ntlm_client *ntlm)
+{
+ if (!ntlm_crypt_init_functions(ntlm))
+ return false;
+
+ ntlm->crypt_ctx.hmac = ntlm->crypt_ctx.hmac_ctx_new_fn();
+
+ if (ntlm->crypt_ctx.hmac == NULL) {
+ ntlm_client_set_errmsg(ntlm, "out of memory");
+ return false;
+ }
+
+ return true;
+}
+
bool ntlm_random_bytes(
- ntlm_client *ntlm,
unsigned char *out,
+ ntlm_client *ntlm,
size_t len)
{
- int rc = RAND_bytes(out, len);
+ int rc = ntlm->crypt_ctx.rand_bytes_fn(out, len);
if (rc != 1) {
- ntlm_client_set_errmsg(ntlm, ERR_lib_error_string(ERR_get_error()));
+ ntlm_client_set_errmsg(ntlm, ntlm->crypt_ctx.err_lib_error_string_fn(ntlm->crypt_ctx.err_get_error_fn()));
return false;
}
@@ -37,94 +177,81 @@ bool ntlm_random_bytes(
bool ntlm_des_encrypt(
ntlm_des_block *out,
+ ntlm_client *ntlm,
ntlm_des_block *plaintext,
ntlm_des_block *key)
{
DES_key_schedule keysched;
+ NTLM_UNUSED(ntlm);
+
memset(out, 0, sizeof(ntlm_des_block));
- DES_set_key(key, &keysched);
- DES_ecb_encrypt(plaintext, out, &keysched, DES_ENCRYPT);
+ ntlm->crypt_ctx.des_set_key_fn(key, &keysched);
+ ntlm->crypt_ctx.des_ecb_encrypt_fn(plaintext, out, &keysched, DES_ENCRYPT);
return true;
}
bool ntlm_md4_digest(
unsigned char out[CRYPT_MD4_DIGESTSIZE],
+ ntlm_client *ntlm,
const unsigned char *in,
size_t in_len)
{
- MD4(in, in_len, out);
+ ntlm->crypt_ctx.md4_fn(in, in_len, out);
return true;
}
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
-static inline void HMAC_CTX_free(HMAC_CTX *ctx)
-{
- if (ctx)
- HMAC_CTX_cleanup(ctx);
-
- free(ctx);
-}
-
-static inline int HMAC_CTX_reset(HMAC_CTX *ctx)
-{
- HMAC_CTX_cleanup(ctx);
- memzero(ctx, sizeof(HMAC_CTX));
- return 1;
-}
-
-static inline HMAC_CTX *HMAC_CTX_new(void)
-{
- return calloc(1, sizeof(HMAC_CTX));
-}
-#endif
-
-ntlm_hmac_ctx *ntlm_hmac_ctx_init(void)
-{
- return HMAC_CTX_new();
-}
-
-bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx)
-{
- return HMAC_CTX_reset(ctx);
-}
-
bool ntlm_hmac_md5_init(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *key,
size_t key_len)
{
- return HMAC_Init_ex(ctx, key, key_len, EVP_md5(), NULL);
+ const EVP_MD *md5 = ntlm->crypt_ctx.evp_md5_fn();
+
+ ntlm->crypt_ctx.hmac_ctx_cleanup_fn(ntlm->crypt_ctx.hmac);
+
+ return ntlm->crypt_ctx.hmac_ctx_reset_fn(ntlm->crypt_ctx.hmac) &&
+ ntlm->crypt_ctx.hmac_init_ex_fn(ntlm->crypt_ctx.hmac, key, key_len, md5, NULL);
}
bool ntlm_hmac_md5_update(
- ntlm_hmac_ctx *ctx,
+ ntlm_client *ntlm,
const unsigned char *in,
size_t in_len)
{
- return HMAC_Update(ctx, in, in_len);
+ return ntlm->crypt_ctx.hmac_update_fn(ntlm->crypt_ctx.hmac, in, in_len);
}
bool ntlm_hmac_md5_final(
unsigned char *out,
size_t *out_len,
- ntlm_hmac_ctx *ctx)
+ ntlm_client *ntlm)
{
unsigned int len;
if (*out_len < CRYPT_MD5_DIGESTSIZE)
return false;
- if (!HMAC_Final(ctx, out, &len))
+ if (!ntlm->crypt_ctx.hmac_final_fn(ntlm->crypt_ctx.hmac, out, &len))
return false;
*out_len = len;
return true;
}
-void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx)
+void ntlm_crypt_shutdown(ntlm_client *ntlm)
{
- HMAC_CTX_free(ctx);
+ if (ntlm->crypt_ctx.hmac) {
+ ntlm->crypt_ctx.hmac_ctx_cleanup_fn(ntlm->crypt_ctx.hmac);
+ ntlm->crypt_ctx.hmac_ctx_free_fn(ntlm->crypt_ctx.hmac);
+ }
+
+#ifdef CRYPT_OPENSSL_DYNAMIC
+ if (ntlm->crypt_ctx.openssl_handle)
+ dlclose(ntlm->crypt_ctx.openssl_handle);
+#endif
+
+ memset(&ntlm->crypt_ctx, 0, sizeof(ntlm_crypt_ctx));
}
diff --git a/deps/ntlmclient/crypt_openssl.h b/deps/ntlmclient/crypt_openssl.h
index 4195db9..8654027 100644
--- a/deps/ntlmclient/crypt_openssl.h
+++ b/deps/ntlmclient/crypt_openssl.h
@@ -9,13 +9,82 @@
#ifndef PRIVATE_CRYPT_OPENSSL_H__
#define PRIVATE_CRYPT_OPENSSL_H__
-#include <openssl/hmac.h>
+#ifndef CRYPT_OPENSSL_DYNAMIC
+# include <openssl/des.h>
+# include <openssl/hmac.h>
+#endif
/* OpenSSL 1.1.0 uses opaque structs, we'll reuse these. */
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
-typedef struct hmac_ctx_st ntlm_hmac_ctx;
-#else
-# define ntlm_hmac_ctx HMAC_CTX
+#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L
+# define HMAC_CTX struct hmac_ctx_st
+#endif
+
+#ifdef CRYPT_OPENSSL_DYNAMIC
+typedef unsigned char DES_cblock[8];
+typedef unsigned char const_DES_cblock[8];
+
+typedef unsigned long DES_LONG;
+
+typedef struct DES_ks {
+ union {
+ DES_cblock cblock;
+ DES_LONG deslong[2];
+ } ks[16];
+} DES_key_schedule;
+
+#define DES_ENCRYPT 1
+
+typedef void EVP_MD;
+typedef void ENGINE;
+typedef void EVP_PKEY_CTX;
+
+#define HMAC_MAX_MD_CBLOCK 128
+
+typedef struct env_md_ctx_st EVP_MD_CTX;
+struct env_md_ctx_st {
+ const EVP_MD *digest;
+ ENGINE *engine;
+ unsigned long flags;
+ void *md_data;
+ EVP_PKEY_CTX *pctx;
+ int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
+};
+
+typedef struct hmac_ctx_st {
+ const EVP_MD *md;
+ EVP_MD_CTX md_ctx;
+ EVP_MD_CTX i_ctx;
+ EVP_MD_CTX o_ctx;
+ unsigned int key_length;
+ unsigned char key[HMAC_MAX_MD_CBLOCK];
+} HMAC_CTX;
#endif
+struct ntlm_crypt_ctx {
+ HMAC_CTX *hmac;
+
+ void *openssl_handle;
+
+ void (*des_ecb_encrypt_fn)(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks, int enc);
+ int (*des_set_key_fn)(const_DES_cblock *key, DES_key_schedule *schedule);
+
+ unsigned long (*err_get_error_fn)(void);
+ const char *(*err_lib_error_string_fn)(unsigned long e);
+
+ const EVP_MD *(*evp_md5_fn)(void);
+
+ HMAC_CTX *(*hmac_ctx_new_fn)(void);
+ int (*hmac_ctx_reset_fn)(HMAC_CTX *ctx);
+ void (*hmac_ctx_free_fn)(HMAC_CTX *ctx);
+ void (*hmac_ctx_cleanup_fn)(HMAC_CTX *ctx);
+
+ int (*hmac_init_ex_fn)(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl);
+ int (*hmac_update_fn)(HMAC_CTX *ctx, const unsigned char *data, size_t len);
+ int (*hmac_final_fn)(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
+
+ unsigned char *(*md4_fn)(const unsigned char *d, size_t n, unsigned char *md);
+
+ int (*rand_bytes_fn)(unsigned char *buf, int num);
+};
+
#endif /* PRIVATE_CRYPT_OPENSSL_H__ */
diff --git a/deps/ntlmclient/ntlm.c b/deps/ntlmclient/ntlm.c
index 24b08f6..3393be9 100644
--- a/deps/ntlmclient/ntlm.c
+++ b/deps/ntlmclient/ntlm.c
@@ -9,7 +9,6 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include <assert.h>
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
@@ -24,6 +23,18 @@
#include "compat.h"
#include "util.h"
+#define NTLM_ASSERT_ARG(expr) do { \
+ if (!(expr)) \
+ return NTLM_CLIENT_ERROR_INVALID_INPUT; \
+ } while(0)
+
+#define NTLM_ASSERT(ntlm, expr) do { \
+ if (!(expr)) { \
+ ntlm_client_set_errmsg(ntlm, "internal error: " #expr); \
+ return -1; \
+ } \
+ } while(0)
+
unsigned char ntlm_client_signature[] = NTLM_SIGNATURE;
static bool supports_unicode(ntlm_client *ntlm)
@@ -47,24 +58,25 @@ ntlm_client *ntlm_client_init(ntlm_client_flags flags)
{
ntlm_client *ntlm = NULL;
- if ((ntlm = malloc(sizeof(ntlm_client))) == NULL)
+ if ((ntlm = calloc(1, sizeof(ntlm_client))) == NULL)
return NULL;
- memset(ntlm, 0, sizeof(ntlm_client));
-
ntlm->flags = flags;
- if ((ntlm->hmac_ctx = ntlm_hmac_ctx_init()) == NULL ||
- (ntlm->unicode_ctx = ntlm_unicode_ctx_init(ntlm)) == NULL) {
- ntlm_hmac_ctx_free(ntlm->hmac_ctx);
- ntlm_unicode_ctx_free(ntlm->unicode_ctx);
- free(ntlm);
- return NULL;
- }
-
return ntlm;
}
+#define ENSURE_INITIALIZED(ntlm) \
+ do { \
+ if (!(ntlm)->unicode_initialized) \
+ (ntlm)->unicode_initialized = ntlm_unicode_init((ntlm)); \
+ if (!(ntlm)->crypt_initialized) \
+ (ntlm)->crypt_initialized = ntlm_crypt_init((ntlm)); \
+ if (!(ntlm)->unicode_initialized || \
+ !(ntlm)->crypt_initialized) \
+ return -1; \
+ } while(0)
+
void ntlm_client_set_errmsg(ntlm_client *ntlm, const char *errmsg)
{
ntlm->state = NTLM_STATE_ERROR;
@@ -73,7 +85,9 @@ void ntlm_client_set_errmsg(ntlm_client *ntlm, const char *errmsg)
const char *ntlm_client_errmsg(ntlm_client *ntlm)
{
- assert(ntlm);
+ if (!ntlm)
+ return "internal error";
+
return ntlm->errmsg ? ntlm->errmsg : "no error";
}
@@ -83,7 +97,7 @@ int ntlm_client_set_version(
uint8_t minor,
uint16_t build)
{
- assert(ntlm);
+ NTLM_ASSERT_ARG(ntlm);
ntlm->host_version.major = major;
ntlm->host_version.minor = minor;
@@ -95,20 +109,25 @@ int ntlm_client_set_version(
return 0;
}
+#define reset(ptr) do { free(ptr); ptr = NULL; } while(0)
+
+static void free_hostname(ntlm_client *ntlm)
+{
+ reset(ntlm->hostname);
+ reset(ntlm->hostdomain);
+ reset(ntlm->hostname_utf16);
+ ntlm->hostname_utf16_len = 0;
+}
+
int ntlm_client_set_hostname(
ntlm_client *ntlm,
const char *hostname,
const char *domain)
{
- assert(ntlm);
+ NTLM_ASSERT_ARG(ntlm);
+ ENSURE_INITIALIZED(ntlm);
- free(ntlm->hostname);
- free(ntlm->hostdomain);
- free(ntlm->hostname_utf16);
-
- ntlm->hostname = NULL;
- ntlm->hostdomain = NULL;
- ntlm->hostname_utf16 = NULL;
+ free_hostname(ntlm);
if (hostname && (ntlm->hostname = strdup(hostname)) == NULL) {
ntlm_client_set_errmsg(ntlm, "out of memory");
@@ -123,7 +142,7 @@ int ntlm_client_set_hostname(
if (hostname && supports_unicode(ntlm) && !ntlm_unicode_utf8_to_16(
&ntlm->hostname_utf16,
&ntlm->hostname_utf16_len,
- ntlm->unicode_ctx,
+ ntlm,
hostname,
strlen(hostname)))
return -1;
@@ -134,30 +153,25 @@ int ntlm_client_set_hostname(
static void free_credentials(ntlm_client *ntlm)
{
if (ntlm->password)
- memzero(ntlm->password, strlen(ntlm->password));
+ ntlm_memzero(ntlm->password, strlen(ntlm->password));
if (ntlm->password_utf16)
- memzero(ntlm->password_utf16, ntlm->password_utf16_len);
-
- free(ntlm->username);
- free(ntlm->username_upper);
- free(ntlm->userdomain);
- free(ntlm->password);
-
- free(ntlm->username_utf16);
- free(ntlm->username_upper_utf16);
- free(ntlm->userdomain_utf16);
- free(ntlm->password_utf16);
-
- ntlm->username = NULL;
- ntlm->username_upper = NULL;
- ntlm->userdomain = NULL;
- ntlm->password = NULL;
-
- ntlm->username_utf16 = NULL;
- ntlm->username_upper_utf16 = NULL;
- ntlm->userdomain_utf16 = NULL;
- ntlm->password_utf16 = NULL;
+ ntlm_memzero(ntlm->password_utf16, ntlm->password_utf16_len);
+
+ reset(ntlm->username);
+ reset(ntlm->username_upper);
+ reset(ntlm->userdomain);
+ reset(ntlm->password);
+
+ reset(ntlm->username_utf16);
+ reset(ntlm->username_upper_utf16);
+ reset(ntlm->userdomain_utf16);
+ reset(ntlm->password_utf16);
+
+ ntlm->username_utf16_len = 0;
+ ntlm->username_upper_utf16_len = 0;
+ ntlm->userdomain_utf16_len = 0;
+ ntlm->password_utf16_len = 0;
}
int ntlm_client_set_credentials(
@@ -166,7 +180,8 @@ int ntlm_client_set_credentials(
const char *domain,
const char *password)
{
- assert(ntlm);
+ NTLM_ASSERT_ARG(ntlm);
+ ENSURE_INITIALIZED(ntlm);
free_credentials(ntlm);
@@ -187,7 +202,7 @@ int ntlm_client_set_credentials(
if (!ntlm_unicode_utf8_to_16(
&ntlm->username_utf16,
&ntlm->username_utf16_len,
- ntlm->unicode_ctx,
+ ntlm,
ntlm->username,
strlen(ntlm->username)))
return -1;
@@ -195,7 +210,7 @@ int ntlm_client_set_credentials(
if (!ntlm_unicode_utf8_to_16(
&ntlm->username_upper_utf16,
&ntlm->username_upper_utf16_len,
- ntlm->unicode_ctx,
+ ntlm,
ntlm->username_upper,
strlen(ntlm->username_upper)))
return -1;
@@ -204,7 +219,7 @@ int ntlm_client_set_credentials(
if (domain && supports_unicode(ntlm) && !ntlm_unicode_utf8_to_16(
&ntlm->userdomain_utf16,
&ntlm->userdomain_utf16_len,
- ntlm->unicode_ctx,
+ ntlm,
ntlm->userdomain,
strlen(ntlm->userdomain)))
return -1;
@@ -214,7 +229,8 @@ int ntlm_client_set_credentials(
int ntlm_client_set_target(ntlm_client *ntlm, const char *target)
{
- assert(ntlm);
+ NTLM_ASSERT_ARG(ntlm);
+ ENSURE_INITIALIZED(ntlm);
free(ntlm->target);
free(ntlm->target_utf16);
@@ -231,7 +247,7 @@ int ntlm_client_set_target(ntlm_client *ntlm, const char *target)
if (supports_unicode(ntlm) && !ntlm_unicode_utf8_to_16(
&ntlm->target_utf16,
&ntlm->target_utf16_len,
- ntlm->unicode_ctx,
+ ntlm,
ntlm->target,
strlen(ntlm->target)))
return -1;
@@ -242,14 +258,16 @@ int ntlm_client_set_target(ntlm_client *ntlm, const char *target)
int ntlm_client_set_nonce(ntlm_client *ntlm, uint64_t nonce)
{
- assert(ntlm);
+ NTLM_ASSERT_ARG(ntlm);
+
ntlm->nonce = nonce;
return 0;
}
int ntlm_client_set_timestamp(ntlm_client *ntlm, uint64_t timestamp)
{
- assert(ntlm);
+ NTLM_ASSERT_ARG(ntlm);
+
ntlm->timestamp = timestamp;
return 0;
}
@@ -260,6 +278,9 @@ static inline bool write_buf(
const unsigned char *buf,
size_t len)
{
+ if (!len)
+ return true;
+
if (out->len - out->pos < len) {
ntlm_client_set_errmsg(ntlm, "out of buffer space");
return false;
@@ -474,7 +495,7 @@ static inline bool read_string_unicode(
size_t out_len;
int ret = ntlm_unicode_utf16_to_8(out,
&out_len,
- ntlm->unicode_ctx,
+ ntlm,
(char *)&message->buf[message->pos],
string_len);
@@ -592,7 +613,9 @@ int ntlm_client_negotiate(
size_t hostname_offset = 0;
uint32_t flags = 0;
- assert(out && out_len && ntlm);
+ NTLM_ASSERT_ARG(out);
+ NTLM_ASSERT_ARG(out_len);
+ NTLM_ASSERT_ARG(ntlm);
*out = NULL;
*out_len = 0;
@@ -648,13 +671,11 @@ int ntlm_client_negotiate(
return -1;
}
- if ((ntlm->negotiate.buf = malloc(ntlm->negotiate.len)) == NULL) {
+ if ((ntlm->negotiate.buf = calloc(1, ntlm->negotiate.len)) == NULL) {
ntlm_client_set_errmsg(ntlm, "out of memory");
return -1;
}
- memset(ntlm->negotiate.buf, 0, ntlm->negotiate.len);
-
if (!write_buf(ntlm, &ntlm->negotiate,
ntlm_client_signature, sizeof(ntlm_client_signature)) ||
!write_int32(ntlm, &ntlm->negotiate, 1) ||
@@ -677,20 +698,22 @@ int ntlm_client_negotiate(
return -1;
if (hostname_len > 0) {
- assert(hostname_offset == ntlm->negotiate.pos);
+ NTLM_ASSERT(ntlm, hostname_offset == ntlm->negotiate.pos);
+
if (!write_buf(ntlm, &ntlm->negotiate,
(const unsigned char *)ntlm->hostname, hostname_len))
return -1;
}
if (domain_len > 0) {
- assert(domain_offset == ntlm->negotiate.pos);
+ NTLM_ASSERT(ntlm, domain_offset == ntlm->negotiate.pos);
+
if (!write_buf(ntlm, &ntlm->negotiate,
(const unsigned char *)ntlm->hostdomain, domain_len))
return -1;
}
- assert(ntlm->negotiate.pos == ntlm->negotiate.len);
+ NTLM_ASSERT(ntlm, ntlm->negotiate.pos == ntlm->negotiate.len);
ntlm->state = NTLM_STATE_CHALLENGE;
@@ -712,7 +735,10 @@ int ntlm_client_set_challenge(
uint32_t name_offset, info_offset = 0;
bool unicode, has_target_info = false;
- assert(ntlm && (challenge_msg || !challenge_msg_len));
+ NTLM_ASSERT_ARG(ntlm);
+ NTLM_ASSERT_ARG(challenge_msg || !challenge_msg_len);
+
+ ENSURE_INITIALIZED(ntlm);
if (ntlm->state != NTLM_STATE_NEGOTIATE &&
ntlm->state != NTLM_STATE_CHALLENGE) {
@@ -941,6 +967,7 @@ static void des_key_from_password(
static inline bool generate_lm_hash(
ntlm_des_block out[2],
+ ntlm_client *ntlm,
const char *password)
{
/* LM encrypts this known plaintext using the password as a key */
@@ -969,8 +996,8 @@ static inline bool generate_lm_hash(
des_key_from_password(&key1, keystr1, keystr1_len);
des_key_from_password(&key2, keystr2, keystr2_len);
- return ntlm_des_encrypt(&out[0], &plaintext, &key1) &&
- ntlm_des_encrypt(&out[1], &plaintext, &key2);
+ return ntlm_des_encrypt(&out[0], ntlm, &plaintext, &key1) &&
+ ntlm_des_encrypt(&out[1], ntlm, &plaintext, &key2);
}
static void des_keys_from_lm_hash(ntlm_des_block out[3], ntlm_des_block lm_hash[2])
@@ -995,16 +1022,16 @@ static bool generate_lm_response(ntlm_client *ntlm)
ntlm_des_block *challenge = (ntlm_des_block *)&ntlm->challenge.nonce;
/* Generate the LM hash from the password */
- if (!generate_lm_hash(lm_hash, ntlm->password))
+ if (!generate_lm_hash(lm_hash, ntlm, ntlm->password))
return false;
/* Convert that LM hash to three DES keys */
des_keys_from_lm_hash(key, lm_hash);
/* Finally, encrypt the challenge with each of these keys */
- if (!ntlm_des_encrypt(&lm_response[0], challenge, &key[0]) ||
- !ntlm_des_encrypt(&lm_response[1], challenge, &key[1]) ||
- !ntlm_des_encrypt(&lm_response[2], challenge, &key[2]))
+ if (!ntlm_des_encrypt(&lm_response[0], ntlm, challenge, &key[0]) ||
+ !ntlm_des_encrypt(&lm_response[1], ntlm, challenge, &key[1]) ||
+ !ntlm_des_encrypt(&lm_response[2], ntlm, challenge, &key[2]))
return false;
memcpy(&ntlm->lm_response[0], lm_response[0], 8);
@@ -1023,12 +1050,13 @@ static bool generate_ntlm_hash(
if (ntlm->password && !ntlm_unicode_utf8_to_16(
&ntlm->password_utf16,
&ntlm->password_utf16_len,
- ntlm->unicode_ctx,
+ ntlm,
ntlm->password,
strlen(ntlm->password)))
return false;
return ntlm_md4_digest(out,
+ ntlm,
(const unsigned char *)ntlm->password_utf16,
ntlm->password_utf16_len);
}
@@ -1049,9 +1077,9 @@ static bool generate_ntlm_response(ntlm_client *ntlm)
des_key_from_password(&key[2], &ntlm_hash[14], 2);
/* Finally, encrypt the challenge with each of these keys */
- if (!ntlm_des_encrypt(&ntlm_response[0], challenge, &key[0]) ||
- !ntlm_des_encrypt(&ntlm_response[1], challenge, &key[1]) ||
- !ntlm_des_encrypt(&ntlm_response[2], challenge, &key[2]))
+ if (!ntlm_des_encrypt(&ntlm_response[0], ntlm, challenge, &key[0]) ||
+ !ntlm_des_encrypt(&ntlm_response[1], ntlm, challenge, &key[1]) ||
+ !ntlm_des_encrypt(&ntlm_response[2], ntlm, challenge, &key[2]))
return false;
memcpy(&ntlm->ntlm_response[0], ntlm_response[0], 8);
@@ -1082,16 +1110,15 @@ static bool generate_ntlm2_hash(
target_len = ntlm->target_utf16_len;
}
- if (!ntlm_hmac_ctx_reset(ntlm->hmac_ctx) ||
- !ntlm_hmac_md5_init(ntlm->hmac_ctx, ntlm_hash, sizeof(ntlm_hash)) ||
- !ntlm_hmac_md5_update(ntlm->hmac_ctx, username, username_len) ||
- !ntlm_hmac_md5_update(ntlm->hmac_ctx, target, target_len) ||
- !ntlm_hmac_md5_final(out, &out_len, ntlm->hmac_ctx)) {
+ if (!ntlm_hmac_md5_init(ntlm, ntlm_hash, sizeof(ntlm_hash)) ||
+ !ntlm_hmac_md5_update(ntlm, username, username_len) ||
+ !ntlm_hmac_md5_update(ntlm, target, target_len) ||
+ !ntlm_hmac_md5_final(out, &out_len, ntlm)) {
ntlm_client_set_errmsg(ntlm, "failed to create HMAC-MD5");
return false;
}
- assert(out_len == NTLM_NTLM2_HASH_LEN);
+ NTLM_ASSERT(ntlm, out_len == NTLM_NTLM2_HASH_LEN);
return true;
}
@@ -1104,43 +1131,36 @@ static bool generate_ntlm2_challengehash(
{
size_t out_len = 16;
- if (!ntlm_hmac_ctx_reset(ntlm->hmac_ctx) ||
- !ntlm_hmac_md5_init(ntlm->hmac_ctx,
- ntlm2_hash, NTLM_NTLM2_HASH_LEN) ||
- !ntlm_hmac_md5_update(ntlm->hmac_ctx,
- (const unsigned char *)&ntlm->challenge.nonce, 8) ||
- !ntlm_hmac_md5_update(ntlm->hmac_ctx, blob, blob_len) ||
- !ntlm_hmac_md5_final(out, &out_len, ntlm->hmac_ctx)) {
+ if (!ntlm_hmac_md5_init(ntlm, ntlm2_hash, NTLM_NTLM2_HASH_LEN) ||
+ !ntlm_hmac_md5_update(ntlm, (const unsigned char *)&ntlm->challenge.nonce, 8) ||
+ !ntlm_hmac_md5_update(ntlm, blob, blob_len) ||
+ !ntlm_hmac_md5_final(out, &out_len, ntlm)) {
ntlm_client_set_errmsg(ntlm, "failed to create HMAC-MD5");
return false;
}
- assert(out_len == 16);
+ NTLM_ASSERT(ntlm, out_len == 16);
return true;
}
static bool generate_lm2_response(ntlm_client *ntlm,
unsigned char ntlm2_hash[NTLM_NTLM2_HASH_LEN])
{
- unsigned char lm2_challengehash[16];
+ unsigned char lm2_challengehash[16] = {0};
size_t lm2_len = 16;
uint64_t local_nonce;
- local_nonce = htonll(ntlm->nonce);
+ local_nonce = ntlm_htonll(ntlm->nonce);
- if (!ntlm_hmac_ctx_reset(ntlm->hmac_ctx) ||
- !ntlm_hmac_md5_init(ntlm->hmac_ctx,
- ntlm2_hash, NTLM_NTLM2_HASH_LEN) ||
- !ntlm_hmac_md5_update(ntlm->hmac_ctx,
- (const unsigned char *)&ntlm->challenge.nonce, 8) ||
- !ntlm_hmac_md5_update(ntlm->hmac_ctx,
- (const unsigned char *)&local_nonce, 8) ||
- !ntlm_hmac_md5_final(lm2_challengehash, &lm2_len, ntlm->hmac_ctx)) {
+ if (!ntlm_hmac_md5_init(ntlm, ntlm2_hash, NTLM_NTLM2_HASH_LEN) ||
+ !ntlm_hmac_md5_update(ntlm, (const unsigned char *)&ntlm->challenge.nonce, 8) ||
+ !ntlm_hmac_md5_update(ntlm, (const unsigned char *)&local_nonce, 8) ||
+ !ntlm_hmac_md5_final(lm2_challengehash, &lm2_len, ntlm)) {
ntlm_client_set_errmsg(ntlm, "failed to create HMAC-MD5");
return false;
}
- assert(lm2_len == 16);
+ NTLM_ASSERT(ntlm, lm2_len == 16);
memcpy(&ntlm->lm_response[0], lm2_challengehash, 16);
memcpy(&ntlm->lm_response[16], &local_nonce, 8);
@@ -1164,7 +1184,7 @@ static bool generate_nonce(ntlm_client *ntlm)
if (ntlm->nonce)
return true;
- if (!ntlm_random_bytes(ntlm, buf, 8))
+ if (!ntlm_random_bytes(buf, ntlm, 8))
return false;
memcpy(&ntlm->nonce, buf, sizeof(uint64_t));
@@ -1177,7 +1197,7 @@ static bool generate_ntlm2_response(ntlm_client *ntlm)
uint32_t signature;
uint64_t timestamp, nonce;
unsigned char ntlm2_hash[NTLM_NTLM2_HASH_LEN];
- unsigned char challengehash[16];
+ unsigned char challengehash[16] = {0};
unsigned char *blob;
if (!generate_timestamp(ntlm) ||
@@ -1198,8 +1218,8 @@ static bool generate_ntlm2_response(ntlm_client *ntlm)
/* the blob's integer values are in network byte order */
signature = htonl(0x01010000);
- timestamp = htonll(ntlm->timestamp);
- nonce = htonll(ntlm->nonce);
+ timestamp = ntlm_htonll(ntlm->timestamp);
+ nonce = ntlm_htonll(ntlm->nonce);
/* construct the blob */
memcpy(&blob[0], &signature, 4);
@@ -1234,7 +1254,11 @@ int ntlm_client_response(
uint32_t flags = 0;
bool unicode;
- assert(out && out_len && ntlm);
+ NTLM_ASSERT_ARG(out);
+ NTLM_ASSERT_ARG(out_len);
+ NTLM_ASSERT_ARG(ntlm);
+
+ ENSURE_INITIALIZED(ntlm);
*out = NULL;
*out_len = 0;
@@ -1334,13 +1358,11 @@ int ntlm_client_response(
return -1;
}
- if ((ntlm->response.buf = malloc(ntlm->response.len)) == NULL) {
+ if ((ntlm->response.buf = calloc(1, ntlm->response.len)) == NULL) {
ntlm_client_set_errmsg(ntlm, "out of memory");
return -1;
}
- memset(ntlm->response.buf, 0, ntlm->response.len);
-
if (!write_buf(ntlm, &ntlm->response,
ntlm_client_signature, sizeof(ntlm_client_signature)) ||
!write_int32(ntlm, &ntlm->response, 3) ||
@@ -1359,7 +1381,7 @@ int ntlm_client_response(
!write_buf(ntlm, &ntlm->response, session, session_len))
return -1;
- assert(ntlm->response.pos == ntlm->response.len);
+ NTLM_ASSERT(ntlm, ntlm->response.pos == ntlm->response.len);
ntlm->state = NTLM_STATE_COMPLETE;
@@ -1371,41 +1393,48 @@ int ntlm_client_response(
void ntlm_client_reset(ntlm_client *ntlm)
{
- ntlm_client_flags flags;
- ntlm_hmac_ctx *hmac_ctx;
- ntlm_unicode_ctx *unicode_ctx;
-
- assert(ntlm);
+ if (!ntlm)
+ return;
- free(ntlm->negotiate.buf);
- free(ntlm->challenge.target_info);
- free(ntlm->challenge.target);
- free(ntlm->challenge.target_domain);
- free(ntlm->challenge.target_domain_dns);
- free(ntlm->challenge.target_server);
- free(ntlm->challenge.target_server_dns);
- free(ntlm->response.buf);
+ ntlm->state = NTLM_STATE_NEGOTIATE;
- free(ntlm->hostname);
- free(ntlm->hostname_utf16);
- free(ntlm->hostdomain);
+ free_hostname(ntlm);
- free(ntlm->target);
- free(ntlm->target_utf16);
+ memset(&ntlm->host_version, 0, sizeof(ntlm_version));
- free(ntlm->ntlm2_response);
+ reset(ntlm->target);
+ reset(ntlm->target_utf16);
+ ntlm->target_utf16_len = 0;
free_credentials(ntlm);
- flags = ntlm->flags;
- hmac_ctx = ntlm->hmac_ctx;
- unicode_ctx = ntlm->unicode_ctx;
+ ntlm->nonce = 0;
+ ntlm->timestamp = 0;
- memset(ntlm, 0, sizeof(struct ntlm_client));
+ memset(ntlm->lm_response, 0, NTLM_LM_RESPONSE_LEN);
+ ntlm->lm_response_len = 0;
- ntlm->flags = flags;
- ntlm->hmac_ctx = hmac_ctx;
- ntlm->unicode_ctx = unicode_ctx;
+ memset(ntlm->ntlm_response, 0, NTLM_NTLM_RESPONSE_LEN);
+ ntlm->ntlm_response_len = 0;
+
+ reset(ntlm->ntlm2_response);
+ ntlm->ntlm2_response_len = 0;
+
+ reset(ntlm->negotiate.buf);
+ ntlm->negotiate.pos = 0;
+ ntlm->negotiate.len = 0;
+
+ reset(ntlm->response.buf);
+ ntlm->response.pos = 0;
+ ntlm->response.len = 0;
+
+ free(ntlm->challenge.target_info);
+ free(ntlm->challenge.target);
+ free(ntlm->challenge.target_domain);
+ free(ntlm->challenge.target_domain_dns);
+ free(ntlm->challenge.target_server);
+ free(ntlm->challenge.target_server_dns);
+ memset(&ntlm->challenge, 0, sizeof(ntlm_challenge));
}
void ntlm_client_free(ntlm_client *ntlm)
@@ -1413,10 +1442,10 @@ void ntlm_client_free(ntlm_client *ntlm)
if (!ntlm)
return;
- ntlm_client_reset(ntlm);
+ ntlm_crypt_shutdown(ntlm);
+ ntlm_unicode_shutdown(ntlm);
- ntlm_hmac_ctx_free(ntlm->hmac_ctx);
- ntlm_unicode_ctx_free(ntlm->unicode_ctx);
+ ntlm_client_reset(ntlm);
free(ntlm);
}
diff --git a/deps/ntlmclient/ntlm.h b/deps/ntlmclient/ntlm.h
index 0dad91e..227f5bc 100644
--- a/deps/ntlmclient/ntlm.h
+++ b/deps/ntlmclient/ntlm.h
@@ -14,6 +14,8 @@
#include "crypt.h"
#include "compat.h"
+#define NTLM_UNUSED(x) ((void)(x))
+
#define NTLM_LM_RESPONSE_LEN 24
#define NTLM_NTLM_RESPONSE_LEN 24
#define NTLM_NTLM_HASH_LEN 16
@@ -66,9 +68,11 @@ struct ntlm_client {
ntlm_state state;
- /* crypto contexts */
- ntlm_hmac_ctx *hmac_ctx;
- ntlm_unicode_ctx *unicode_ctx;
+ /* subsystem contexts */
+ ntlm_crypt_ctx crypt_ctx;
+ ntlm_unicode_ctx unicode_ctx;
+ int crypt_initialized : 1,
+ unicode_initialized : 1;
/* error message as set by the library */
const char *errmsg;
@@ -85,24 +89,24 @@ struct ntlm_client {
char *password;
/* strings as converted to utf16 */
+ char *hostname_utf16;
char *target_utf16;
char *username_utf16;
char *username_upper_utf16;
char *userdomain_utf16;
- char *hostname_utf16;
char *password_utf16;
- /* timestamp and nonce; only for debugging */
- uint64_t nonce;
- uint64_t timestamp;
-
+ size_t hostname_utf16_len;
size_t username_utf16_len;
size_t username_upper_utf16_len;
size_t userdomain_utf16_len;
- size_t hostname_utf16_len;
size_t password_utf16_len;
size_t target_utf16_len;
+ /* timestamp and nonce; only for debugging */
+ uint64_t nonce;
+ uint64_t timestamp;
+
unsigned char lm_response[NTLM_LM_RESPONSE_LEN];
size_t lm_response_len;
diff --git a/deps/ntlmclient/ntlmclient.h b/deps/ntlmclient/ntlmclient.h
index d109a5c..bf57b17 100644
--- a/deps/ntlmclient/ntlmclient.h
+++ b/deps/ntlmclient/ntlmclient.h
@@ -15,13 +15,26 @@
extern "C" {
#endif
-#define NTLM_CLIENT_VERSION "0.0.1"
+#define NTLM_CLIENT_VERSION "0.9.0"
#define NTLM_CLIENT_VERSION_MAJOR 0
-#define NTLM_CLIENT_VERSION_MINOR 0
-#define NTLM_CLIENT_VERSION_TEENY 1
+#define NTLM_CLIENT_VERSION_MINOR 9
+#define NTLM_CLIENT_VERSION_TEENY 0
typedef struct ntlm_client ntlm_client;
+typedef enum {
+ /**
+ * An error occurred; more details are available by querying
+ * `ntlm_client_errmsg`.
+ */
+ NTLM_CLIENT_ERROR = -1,
+
+ /**
+ * The input provided to the function is missing or invalid.
+ */
+ NTLM_CLIENT_ERROR_INVALID_INPUT = -2,
+} ntlm_error_code;
+
/*
* Flags for initializing the `ntlm_client` context. A combination of
* these flags can be provided to `ntlm_client_init`.
diff --git a/deps/ntlmclient/unicode.h b/deps/ntlmclient/unicode.h
index e3b17bc..b7c63f2 100644
--- a/deps/ntlmclient/unicode.h
+++ b/deps/ntlmclient/unicode.h
@@ -11,26 +11,32 @@
#include "compat.h"
+#ifdef UNICODE_ICONV
+# include "unicode_iconv.h"
+#elif UNICODE_BUILTIN
+# include "unicode_builtin.h"
+#endif
+
#define NTLM_UNICODE_MAX_LEN 2048
typedef struct ntlm_unicode_ctx ntlm_unicode_ctx;
-extern ntlm_unicode_ctx *ntlm_unicode_ctx_init(ntlm_client *ntlm);
+extern bool ntlm_unicode_init(ntlm_client *ntlm);
bool ntlm_unicode_utf8_to_16(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *ntlm,
const char *string,
size_t string_len);
bool ntlm_unicode_utf16_to_8(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *ntlm,
const char *string,
size_t string_len);
-extern void ntlm_unicode_ctx_free(ntlm_unicode_ctx *ctx);
+extern void ntlm_unicode_shutdown(ntlm_client *ntlm);
#endif /* PRIVATE_UNICODE_H__ */
diff --git a/deps/ntlmclient/unicode_builtin.c b/deps/ntlmclient/unicode_builtin.c
index e1856cc..e2ee0ab 100644
--- a/deps/ntlmclient/unicode_builtin.c
+++ b/deps/ntlmclient/unicode_builtin.c
@@ -13,10 +13,6 @@
#include "unicode.h"
#include "compat.h"
-struct ntlm_unicode_ctx {
- ntlm_client *ntlm;
-};
-
typedef unsigned int UTF32; /* at least 32 bits */
typedef unsigned short UTF16; /* at least 16 bits */
typedef unsigned char UTF8; /* typically 8 bits */
@@ -281,15 +277,10 @@ static ConversionResult ConvertUTF8toUTF16 (
}
-ntlm_unicode_ctx *ntlm_unicode_ctx_init(ntlm_client *ntlm)
+bool ntlm_unicode_init(ntlm_client *ntlm)
{
- ntlm_unicode_ctx *ctx;
-
- if ((ctx = malloc(sizeof(ntlm_unicode_ctx))) == NULL)
- return NULL;
-
- ctx->ntlm = ntlm;
- return ctx;
+ NTLM_UNUSED(ntlm);
+ return true;
}
typedef enum {
@@ -300,7 +291,7 @@ typedef enum {
static inline bool unicode_builtin_encoding_convert(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *ntlm,
const char *string,
size_t string_len,
unicode_builtin_encoding_direction direction)
@@ -332,7 +323,7 @@ static inline bool unicode_builtin_encoding_convert(
out_size = (out_size + 7) & ~7;
if ((out = malloc(out_size)) == NULL) {
- ntlm_client_set_errmsg(ctx->ntlm, "out of memory");
+ ntlm_client_set_errmsg(ntlm, "out of memory");
return false;
}
@@ -358,17 +349,17 @@ static inline bool unicode_builtin_encoding_convert(
success = true;
goto done;
case sourceExhausted:
- ntlm_client_set_errmsg(ctx->ntlm,
+ ntlm_client_set_errmsg(ntlm,
"invalid unicode string; trailing data remains");
goto done;
case targetExhausted:
break;
case sourceIllegal:
- ntlm_client_set_errmsg(ctx->ntlm,
+ ntlm_client_set_errmsg(ntlm,
"invalid unicode string; trailing data remains");
goto done;
default:
- ntlm_client_set_errmsg(ctx->ntlm,
+ ntlm_client_set_errmsg(ntlm,
"unknown unicode conversion failure");
goto done;
}
@@ -377,13 +368,12 @@ static inline bool unicode_builtin_encoding_convert(
out_size = ((((out_size << 1) - (out_size >> 1)) + 7) & ~7);
if (out_size > NTLM_UNICODE_MAX_LEN) {
- ntlm_client_set_errmsg(ctx->ntlm,
- "unicode conversion too large");
+ ntlm_client_set_errmsg(ntlm, "unicode conversion too large");
goto done;
}
if ((new_out = realloc(out, out_size)) == NULL) {
- ntlm_client_set_errmsg(ctx->ntlm, "out of memory");
+ ntlm_client_set_errmsg(ntlm, "out of memory");
goto done;
}
@@ -419,27 +409,26 @@ done:
bool ntlm_unicode_utf8_to_16(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *client,
const char *string,
size_t string_len)
{
return unicode_builtin_encoding_convert(converted, converted_len,
- ctx, string, string_len, unicode_builtin_utf8_to_16);
+ client, string, string_len, unicode_builtin_utf8_to_16);
}
bool ntlm_unicode_utf16_to_8(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *client,
const char *string,
size_t string_len)
{
return unicode_builtin_encoding_convert(converted, converted_len,
- ctx, string, string_len, unicode_builtin_utf16_to_8);
+ client, string, string_len, unicode_builtin_utf16_to_8);
}
-void ntlm_unicode_ctx_free(ntlm_unicode_ctx *ctx)
+void ntlm_unicode_shutdown(ntlm_client *ntlm)
{
- if (ctx)
- free(ctx);
+ NTLM_UNUSED(ntlm);
}
diff --git a/deps/ntlmclient/unicode_builtin.h b/deps/ntlmclient/unicode_builtin.h
new file mode 100644
index 0000000..eabec40
--- /dev/null
+++ b/deps/ntlmclient/unicode_builtin.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) Edward Thomson. All rights reserved.
+ *
+ * This file is part of ntlmclient, distributed under the MIT license.
+ * For full terms and copyright information, and for third-party
+ * copyright information, see the included LICENSE.txt file.
+ */
+
+#ifndef PRIVATE_UNICODE_BUILTIN_H__
+#define PRIVATE_UNICODE_BUILTIN_H__
+
+#include <locale.h>
+#include <iconv.h>
+
+#include "ntlmclient.h"
+
+struct ntlm_unicode_ctx {
+};
+
+#endif /* PRIVATE_UNICODE_BUILTIN_H__ */
diff --git a/deps/ntlmclient/unicode_iconv.c b/deps/ntlmclient/unicode_iconv.c
index d1fe07e..e14da21 100644
--- a/deps/ntlmclient/unicode_iconv.c
+++ b/deps/ntlmclient/unicode_iconv.c
@@ -16,43 +16,23 @@
#include "ntlm.h"
#include "compat.h"
-struct ntlm_unicode_ctx {
- ntlm_client *ntlm;
- iconv_t utf8_to_16;
- iconv_t utf16_to_8;
-};
-
-ntlm_unicode_ctx *ntlm_unicode_ctx_init(ntlm_client *ntlm)
-{
- ntlm_unicode_ctx *ctx;
-
- if ((ctx = calloc(1, sizeof(ntlm_unicode_ctx))) == NULL)
- return NULL;
-
- ctx->ntlm = ntlm;
- ctx->utf8_to_16 = (iconv_t)-1;
- ctx->utf16_to_8 = (iconv_t)-1;
-
- return ctx;
-}
-
typedef enum {
unicode_iconv_utf8_to_16,
unicode_iconv_utf16_to_8
} unicode_iconv_encoding_direction;
-static inline bool unicode_iconv_init(ntlm_unicode_ctx *ctx)
+bool ntlm_unicode_init(ntlm_client *ntlm)
{
- if (ctx->utf8_to_16 != (iconv_t)-1 || ctx->utf16_to_8 != (iconv_t)-1)
- return true;
+ ntlm->unicode_ctx.utf8_to_16 = iconv_open("UTF-16LE", "UTF-8");
+ ntlm->unicode_ctx.utf16_to_8 = iconv_open("UTF-8", "UTF-16LE");
- if ((ctx->utf8_to_16 = iconv_open("UTF-16LE", "UTF-8")) == (iconv_t)-1 ||
- (ctx->utf16_to_8 = iconv_open("UTF-8", "UTF-16LE")) == (iconv_t)-1) {
+ if (ntlm->unicode_ctx.utf8_to_16 == (iconv_t)-1 ||
+ ntlm->unicode_ctx.utf16_to_8 == (iconv_t)-1) {
if (errno == EINVAL)
- ntlm_client_set_errmsg(ctx->ntlm,
+ ntlm_client_set_errmsg(ntlm,
"iconv does not support UTF8 <-> UTF16 conversion");
else
- ntlm_client_set_errmsg(ctx->ntlm, strerror(errno));
+ ntlm_client_set_errmsg(ntlm, strerror(errno));
return false;
}
@@ -63,7 +43,7 @@ static inline bool unicode_iconv_init(ntlm_unicode_ctx *ctx)
static inline bool unicode_iconv_encoding_convert(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *ntlm,
const char *string,
size_t string_len,
unicode_iconv_encoding_direction direction)
@@ -75,9 +55,6 @@ static inline bool unicode_iconv_encoding_convert(
*converted = NULL;
*converted_len = 0;
- if (!unicode_iconv_init(ctx))
- return false;
-
/*
* When translating UTF8 to UTF16, these strings are only used
* internally, and we obey the given length, so we can simply
@@ -86,11 +63,11 @@ static inline bool unicode_iconv_encoding_convert(
* terminate and expect an extra byte for UTF8, two for UTF16.
*/
if (direction == unicode_iconv_utf8_to_16) {
- converter = ctx->utf8_to_16;
+ converter = ntlm->unicode_ctx.utf8_to_16;
out_size = (string_len * 2) + 2;
nul_size = 2;
} else {
- converter = ctx->utf16_to_8;
+ converter = ntlm->unicode_ctx.utf16_to_8;
out_size = (string_len / 2) + 1;
nul_size = 1;
}
@@ -99,7 +76,7 @@ static inline bool unicode_iconv_encoding_convert(
out_size = (out_size + 7) & ~7;
if ((out = malloc(out_size)) == NULL) {
- ntlm_client_set_errmsg(ctx->ntlm, "out of memory");
+ ntlm_client_set_errmsg(ntlm, "out of memory");
return false;
}
@@ -117,7 +94,7 @@ static inline bool unicode_iconv_encoding_convert(
break;
if (ret == (size_t)-1 && errno != E2BIG) {
- ntlm_client_set_errmsg(ctx->ntlm, strerror(errno));
+ ntlm_client_set_errmsg(ntlm, strerror(errno));
goto on_error;
}
@@ -125,13 +102,12 @@ static inline bool unicode_iconv_encoding_convert(
out_size = ((((out_size << 1) - (out_size >> 1)) + 7) & ~7);
if (out_size > NTLM_UNICODE_MAX_LEN) {
- ntlm_client_set_errmsg(ctx->ntlm,
- "unicode conversion too large");
+ ntlm_client_set_errmsg(ntlm, "unicode conversion too large");
goto on_error;
}
if ((new_out = realloc(out, out_size)) == NULL) {
- ntlm_client_set_errmsg(ctx->ntlm, "out of memory");
+ ntlm_client_set_errmsg(ntlm, "out of memory");
goto on_error;
}
@@ -139,7 +115,7 @@ static inline bool unicode_iconv_encoding_convert(
}
if (in_start_len != 0) {
- ntlm_client_set_errmsg(ctx->ntlm,
+ ntlm_client_set_errmsg(ntlm,
"invalid unicode string; trailing data remains");
goto on_error;
}
@@ -165,37 +141,37 @@ on_error:
bool ntlm_unicode_utf8_to_16(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *ntlm,
const char *string,
size_t string_len)
{
return unicode_iconv_encoding_convert(
- converted, converted_len, ctx, string, string_len,
+ converted, converted_len, ntlm, string, string_len,
unicode_iconv_utf8_to_16);
}
bool ntlm_unicode_utf16_to_8(
char **converted,
size_t *converted_len,
- ntlm_unicode_ctx *ctx,
+ ntlm_client *ntlm,
const char *string,
size_t string_len)
{
return unicode_iconv_encoding_convert(
- converted, converted_len, ctx, string, string_len,
+ converted, converted_len, ntlm, string, string_len,
unicode_iconv_utf16_to_8);
}
-void ntlm_unicode_ctx_free(ntlm_unicode_ctx *ctx)
+void ntlm_unicode_shutdown(ntlm_client *ntlm)
{
- if (!ctx)
- return;
-
- if (ctx->utf16_to_8 != (iconv_t)-1)
- iconv_close(ctx->utf16_to_8);
+ if (ntlm->unicode_ctx.utf16_to_8 != (iconv_t)0 &&
+ ntlm->unicode_ctx.utf16_to_8 != (iconv_t)-1)
+ iconv_close(ntlm->unicode_ctx.utf16_to_8);
- if (ctx->utf8_to_16 != (iconv_t)-1)
- iconv_close(ctx->utf8_to_16);
+ if (ntlm->unicode_ctx.utf8_to_16 != (iconv_t)0 &&
+ ntlm->unicode_ctx.utf8_to_16 != (iconv_t)-1)
+ iconv_close(ntlm->unicode_ctx.utf8_to_16);
- free(ctx);
+ ntlm->unicode_ctx.utf8_to_16 = (iconv_t)-1;
+ ntlm->unicode_ctx.utf16_to_8 = (iconv_t)-1;
}
diff --git a/deps/ntlmclient/unicode_iconv.h b/deps/ntlmclient/unicode_iconv.h
new file mode 100644
index 0000000..87a96a6
--- /dev/null
+++ b/deps/ntlmclient/unicode_iconv.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) Edward Thomson. All rights reserved.
+ *
+ * This file is part of ntlmclient, distributed under the MIT license.
+ * For full terms and copyright information, and for third-party
+ * copyright information, see the included LICENSE.txt file.
+ */
+
+#ifndef PRIVATE_UNICODE_ICONV_H__
+#define PRIVATE_UNICODE_ICONV_H__
+
+#include <locale.h>
+#include <iconv.h>
+
+#include "ntlmclient.h"
+
+struct ntlm_unicode_ctx {
+ iconv_t utf8_to_16;
+ iconv_t utf16_to_8;
+};
+
+#endif /* PRIVATE_UNICODE_ICONV_H__ */
diff --git a/deps/ntlmclient/util.c b/deps/ntlmclient/util.c
index d0e3e53..07d10f6 100644
--- a/deps/ntlmclient/util.c
+++ b/deps/ntlmclient/util.c
@@ -8,14 +8,28 @@
#include <stdlib.h>
#include <stdint.h>
+#include <arpa/inet.h>
#include "compat.h"
#include "util.h"
-void memzero(void *data, size_t size)
+void ntlm_memzero(void *data, size_t size)
{
volatile uint8_t *scan = (volatile uint8_t *)data;
while (size--)
*scan++ = 0x0;
}
+
+uint64_t ntlm_htonll(uint64_t value)
+{
+ static union {
+ uint32_t i;
+ char c[8];
+ } test = { 0x01020304 };
+
+ if (test.c[0] == 0x01)
+ return value;
+ else
+ return ((uint64_t)htonl(value) << 32) | htonl((uint64_t)value >> 32);
+}
diff --git a/deps/ntlmclient/util.h b/deps/ntlmclient/util.h
index 1c1806b..d4bb472 100644
--- a/deps/ntlmclient/util.h
+++ b/deps/ntlmclient/util.h
@@ -9,6 +9,7 @@
#ifndef PRIVATE_UTIL_H__
#define PRIVATE_UTIL_H__
-extern void memzero(void *data, size_t size);
+extern void ntlm_memzero(void *data, size_t size);
+extern uint64_t ntlm_htonll(uint64_t value);
#endif /* PRIVATE_UTIL_H__ */
diff --git a/deps/pcre/LICENCE b/deps/pcre/LICENCE
new file mode 100644
index 0000000..57a5448
--- /dev/null
+++ b/deps/pcre/LICENCE
@@ -0,0 +1,93 @@
+PCRE LICENCE
+------------
+
+PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
+specified below. The documentation for PCRE, supplied in the "doc"
+directory, is distributed under the same terms as the software itself. The data
+in the testdata directory is not copyrighted and is in the public domain.
+
+The basic library functions are written in C and are freestanding. Also
+included in the distribution is a set of C++ wrapper functions, and a
+just-in-time compiler that can be used to optimize pattern matching. These
+are both optional features that can be omitted when the library is built.
+
+
+THE BASIC LIBRARY FUNCTIONS
+---------------------------
+
+Written by: Philip Hazel
+Email local part: ph10
+Email domain: cam.ac.uk
+
+University of Cambridge Computing Service,
+Cambridge, England.
+
+Copyright (c) 1997-2020 University of Cambridge
+All rights reserved.
+
+
+PCRE JUST-IN-TIME COMPILATION SUPPORT
+-------------------------------------
+
+Written by: Zoltan Herczeg
+Email local part: hzmester
+Email domain: freemail.hu
+
+Copyright(c) 2010-2020 Zoltan Herczeg
+All rights reserved.
+
+
+STACK-LESS JUST-IN-TIME COMPILER
+--------------------------------
+
+Written by: Zoltan Herczeg
+Email local part: hzmester
+Email domain: freemail.hu
+
+Copyright(c) 2009-2020 Zoltan Herczeg
+All rights reserved.
+
+
+THE C++ WRAPPER FUNCTIONS
+-------------------------
+
+Contributed by: Google Inc.
+
+Copyright (c) 2007-2012, Google Inc.
+All rights reserved.
+
+
+THE "BSD" LICENCE
+-----------------
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the University of Cambridge nor the name of Google
+ Inc. nor the names of their contributors may be used to endorse or
+ promote products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+End
diff --git a/deps/pcre/pcre.h b/deps/pcre/pcre.h
index 15592b9..5b147b9 100644
--- a/deps/pcre/pcre.h
+++ b/deps/pcre/pcre.h
@@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
/* The current PCRE version information. */
#define PCRE_MAJOR 8
-#define PCRE_MINOR 42
+#define PCRE_MINOR 44
#define PCRE_PRERELEASE
-#define PCRE_DATE 2018-03-20
+#define PCRE_DATE 2020-02-12
#define PCRE_EXP_DECL extern
diff --git a/deps/pcre/pcre_compile.c b/deps/pcre/pcre_compile.c
index 02de494..a3f20fd 100644
--- a/deps/pcre/pcre_compile.c
+++ b/deps/pcre/pcre_compile.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2016 University of Cambridge
+ Copyright (c) 1997-2020 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@ COMPILE_PCREx macro will already be appropriately set. */
/* Macro for setting individual bits in class bitmaps. */
-#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
+#define SETBIT(a,b) a[(b)/8] |= (1U << ((b)&7))
/* Maximum length value to check against when making sure that the integer that
holds the compiled pattern length does not overflow. We make it a bit less than
@@ -129,8 +129,8 @@ overrun before it actually does run off the end of the data block. */
/* Private flags added to firstchar and reqchar. */
-#define REQ_CASELESS (1 << 0) /* Indicates caselessness */
-#define REQ_VARY (1 << 1) /* Reqchar followed non-literal item */
+#define REQ_CASELESS (1U << 0) /* Indicates caselessness */
+#define REQ_VARY (1U << 1) /* Reqchar followed non-literal item */
/* Negative values for the firstchar and reqchar flags */
#define REQ_UNSET (-2)
#define REQ_NONE (-1)
@@ -3299,7 +3299,7 @@ for(;;)
if ((*xclass_flags & XCL_MAP) == 0)
{
/* No bits are set for characters < 256. */
- if (list[1] == 0) return TRUE;
+ if (list[1] == 0) return (*xclass_flags & XCL_NOT) == 0;
/* Might be an empty repeat. */
continue;
}
@@ -3611,7 +3611,7 @@ for(;;)
if (chr > 255) break;
class_bitset = (pcre_uint8 *)
((list_ptr == list ? code : base_end) - list_ptr[2]);
- if ((class_bitset[chr >> 3] & (1 << (chr & 7))) != 0) return FALSE;
+ if ((class_bitset[chr >> 3] & (1U << (chr & 7))) != 0) return FALSE;
break;
#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
@@ -7135,17 +7135,19 @@ for (;; ptr++)
int n = 0;
ptr++;
while(IS_DIGIT(*ptr))
+ {
n = n * 10 + *ptr++ - CHAR_0;
+ if (n > 255)
+ {
+ *errorcodeptr = ERR38;
+ goto FAILED;
+ }
+ }
if (*ptr != CHAR_RIGHT_PARENTHESIS)
{
*errorcodeptr = ERR39;
goto FAILED;
}
- if (n > 255)
- {
- *errorcodeptr = ERR38;
- goto FAILED;
- }
*code++ = n;
PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
PUT(code, LINK_SIZE, 0); /* Default length */
@@ -7461,7 +7463,7 @@ for (;; ptr++)
{
open_capitem *oc;
recno = GET2(slot, 0);
- cd->backref_map |= (recno < 32)? (1 << recno) : 1;
+ cd->backref_map |= (recno < 32)? (1U << recno) : 1;
if (recno > cd->top_backref) cd->top_backref = recno;
/* Check to see if this back reference is recursive, that it, it
@@ -7647,6 +7649,8 @@ for (;; ptr++)
/* Can't determine a first byte now */
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
+ zerofirstchar = firstchar;
+ zerofirstcharflags = firstcharflags;
continue;
@@ -8070,7 +8074,7 @@ for (;; ptr++)
item_hwm_offset = cd->hwm - cd->start_workspace;
*code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
PUT2INC(code, 0, recno);
- cd->backref_map |= (recno < 32)? (1 << recno) : 1;
+ cd->backref_map |= (recno < 32)? (1U << recno) : 1;
if (recno > cd->top_backref) cd->top_backref = recno;
/* Check to see if this back reference is recursive, that it, it
@@ -8683,14 +8687,22 @@ do {
op == OP_SCBRA || op == OP_SCBRAPOS)
{
int n = GET2(scode, 1+LINK_SIZE);
- int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+ int new_map = bracket_map | ((n < 32)? (1U << n) : 1);
if (!is_anchored(scode, new_map, cd, atomcount)) return FALSE;
}
- /* Positive forward assertions and conditions */
+ /* Positive forward assertion */
+
+ else if (op == OP_ASSERT)
+ {
+ if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
+ }
+
+ /* Condition; not anchored if no second branch */
- else if (op == OP_ASSERT || op == OP_COND)
+ else if (op == OP_COND)
{
+ if (scode[GET(scode,1)] != OP_ALT) return FALSE;
if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
}
@@ -8803,7 +8815,7 @@ do {
op == OP_SCBRA || op == OP_SCBRAPOS)
{
int n = GET2(scode, 1+LINK_SIZE);
- int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+ int new_map = bracket_map | ((n < 32)? (1U << n) : 1);
if (!is_startline(scode, new_map, cd, atomcount, inassert)) return FALSE;
}
diff --git a/deps/pcre/pcre_jit_compile.c b/deps/pcre/pcre_jit_compile.c
index 2bad74b..4dcf8fc 100644
--- a/deps/pcre/pcre_jit_compile.c
+++ b/deps/pcre/pcre_jit_compile.c
@@ -3938,10 +3938,10 @@ static sljit_s32 character_to_int32(pcre_uchar chr)
sljit_s32 value = (sljit_s32)chr;
#if defined COMPILE_PCRE8
#define SSE2_COMPARE_TYPE_INDEX 0
-return (value << 24) | (value << 16) | (value << 8) | value;
+return ((unsigned int)value << 24) | ((unsigned int)value << 16) | ((unsigned int)value << 8) | (unsigned int)value;
#elif defined COMPILE_PCRE16
#define SSE2_COMPARE_TYPE_INDEX 1
-return (value << 16) | value;
+return ((unsigned int)value << 16) | value;
#elif defined COMPILE_PCRE32
#define SSE2_COMPARE_TYPE_INDEX 2
return value;
@@ -8507,7 +8507,7 @@ if (opcode == OP_ONCE)
/* We temporarily encode the needs_control_head in the lowest bit.
Note: on the target architectures of SLJIT the ((x << 1) >> 1) returns
the same value for small signed numbers (including negative numbers). */
- BACKTRACK_AS(bracket_backtrack)->u.framesize = (BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
+ BACKTRACK_AS(bracket_backtrack)->u.framesize = ((unsigned int)BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
}
return cc + repeat_length;
}
@@ -9002,7 +9002,7 @@ if (exact > 1)
#ifdef SUPPORT_UTF
&& !common->utf
#endif
- )
+ && type != OP_ANYNL && type != OP_EXTUNI)
{
OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(exact));
add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER, TMP1, 0, STR_END, 0));
diff --git a/deps/pcre/pcreposix.c b/deps/pcre/pcreposix.c
index 77dbddb..f9e423b 100644
--- a/deps/pcre/pcreposix.c
+++ b/deps/pcre/pcreposix.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2018 University of Cambridge
+ Copyright (c) 1997-2020 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -287,6 +287,7 @@ if (preg->re_pcre == NULL)
(void)pcre_fullinfo((const pcre *)preg->re_pcre, NULL, PCRE_INFO_CAPTURECOUNT,
&re_nsub);
preg->re_nsub = (size_t)re_nsub;
+preg->re_erroffset = (size_t)(-1); /* No meaning after successful compile */
return 0;
}
@@ -324,8 +325,6 @@ if ((eflags & PCRE_REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
if ((eflags & PCRE_REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
if ((eflags & PCRE_REG_NOTEMPTY) != 0) options |= PCRE_NOTEMPTY;
-((pcre_regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
-
/* When no string data is being returned, or no vector has been passed in which
to put it, ensure that nmatch is zero. Otherwise, ensure the vector for holding
the return data is large enough. */
diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt
index afa5a19..435877d 100644
--- a/deps/zlib/CMakeLists.txt
+++ b/deps/zlib/CMakeLists.txt
@@ -1,5 +1,6 @@
-DISABLE_WARNINGS(implicit-fallthrough)
-ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
-FILE(GLOB SRC_ZLIB "*.c" "*.h")
-INCLUDE_DIRECTORIES(".")
-ADD_LIBRARY(zlib OBJECT ${SRC_ZLIB})
+disable_warnings(implicit-fallthrough)
+add_definitions(-DNO_VIZ -DSTDC -DNO_GZIP)
+file(GLOB SRC_ZLIB "*.c" "*.h")
+list(SORT SRC_ZLIB)
+include_directories(".")
+add_library(zlib OBJECT ${SRC_ZLIB})
diff --git a/deps/zlib/deflate.c b/deps/zlib/deflate.c
index 1ec7614..8d44869 100644
--- a/deps/zlib/deflate.c
+++ b/deps/zlib/deflate.c
@@ -320,6 +320,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
+ memset(s->prev, 0, s->w_size * sizeof(Pos));
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
s->high_water = 0; /* nothing written to s->window yet */
diff --git a/docs/changelog.md b/docs/changelog.md
index af80d48..1bbbe60 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -1,5 +1,448 @@
-v0.28 + 1
----------
+vNext
+-----
+
+### Changes or improvements
+
+* Branch and tag name validation functions have been introduced:
+ `git_branch_name_is_valid` will check if a branch name is valid,
+ and `git_tag_name_is_valid` will check if a tag name is valid.
+
+* Some remote and reference validity checking functions have been
+ introduced with error reporting semantics. `git_remote_name_is_valid`
+ replaces `git_remote_is_valid_name`. `git_reference_name_is_valid`
+ replaces `git_reference_is_valid_name`. Tthe former functions are
+ deprecated.
+
+### Breaking CMake configuration changes
+
+The `MVSC_CRTDBG` configuration option is now `WIN32_LEAKCHECK`.
+
+v1.1
+----
+
+This is release v1.1, "Fernweh".
+
+### Changes or improvements
+
+* Our bundled PCRE dependency has been updated to 8.44.
+
+* The `refs/remotes/origin/HEAD` file will be created at clone time to
+ point to the origin's default branch.
+
+* libgit2 now uses the `__atomic_` intrinsics instead of `__sync_`
+ intrinsics on supported gcc and clang versions.
+
+* The `init.defaultBranch` setting is now respected and `master` is
+ no longer the hardcoded as the default branch name.
+
+* Patch files that do not contain an `index` line can now be parsed.
+
+* Configuration files with multi-line values can now contain quotes
+ split across multiple lines.
+
+* Windows clients now attempt to use TLS1.3 when available.
+
+* Servers that request an upgrade to a newer HTTP version are
+ silently ignored instead of erroneously failing.
+
+* Users can pass `NULL` to the options argument to
+ `git_describe_commit`.
+
+* Clones and fetches of very large packfiles now succeeds on 32-bit
+ platforms.
+
+* Custom reference database backends can now handle the repository's
+ `HEAD` correctly.
+
+* Repositories with a large number of packfiles no longer exhaust the
+ number of file descriptors.
+
+* The test framework now supports TAP output when the `-t` flag is
+ specified.
+
+* The test framework can now specify an exact match to a test
+ function using a trailing `$`.
+
+* All checkout types support `GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH`.
+
+* `git_blame` now can ignore whitespace changes using the option
+ `GIT_BLAME_IGNORE_WHITESPACE`.
+
+* Several new examples have been created, including an examples for
+ commit, add and push.
+
+* Mode changes during rename are now supported in patch application.
+
+* `git_checkout_head` now correctly removes untracked files in a
+ subdirectory when the `FORCE | REMOVE_UNTRACKED` options are specified.
+
+v1.0.1
+------
+
+This is a bugfix release with the following changes:
+
+- Calculating information about renamed files during merges is more
+ efficient because dissimilarity about files is now being cached and
+ no longer needs to be recomputed.
+
+- The `git_worktree_prune_init_options` has been correctly restored for
+ backward compatibility. In v1.0 it was incorrectly deprecated with a
+ typo.
+
+- The optional ntlmclient dependency now supports NetBSD.
+
+- A bug where attempting to stash on a bare repository may have failed
+ has been fixed.
+
+- Configuration files that are unreadable due to permissions are now
+ silently ignored, and treated as if they do not exist. This matches
+ git's behavior; previously this case would have been an error.
+
+- v4 index files are now correctly written; previously we would read
+ them correctly but would not write the prefix-compression accurately,
+ causing corruption.
+
+- A bug where the smart HTTP transport could not read large data packets
+ has been fixed. Previously, fetching from servers like Gerrit, that
+ sent large data packets, would error.
+
+v1.0
+----
+
+This is release v1.0 "Luftschloss", which is the first stabe release of
+libgit2. The API will stay compatible across all releases of the same major
+version. This release includes bugfixes only and supersedes v0.99, which will
+stop being maintained. Both v0.27 and v0.28 stay supported in accordance with
+our release policy.
+
+### Changes or improvements
+
+- CMake was converted to make use of the GNUInstallDirs module for both our
+ pkgconfig and install targets in favor of our custom build options
+ `BIN_INSTALL_DIR`, `LIB_INSTALL_DIR` and `INCLUDE_INSTALL_DIR`. Instead, you
+ can now use CMakes standard variables `CMAKE_INSTALL_BINDIR`,
+ `CMAKE_INSTALL_LIBDIR` and `CMAKE_INSTALL_INCLUDEDIR`.
+
+- Some CMake build options accepted either a specific value or a boolean value
+ to disable the option altogether or use automatic detection. We only accepted
+ "ON" or "OFF", but none of the other values CMake recognizes as boolean. This
+ was aligned with CMake's understanding of booleans.
+
+- The installed pkgconfig file contained incorrect values for both `libdir` and
+ `includedir` variables.
+
+- If using pcre2 for regular expressions, then we incorrectly added "pcre2"
+ instead of "pcre2-8" to our pkgconfig dependencies, which was corrected.
+
+- Fixed building the bundled ntlmclient dependency on FreeBSD, OpenBSD and
+ SunOS.
+
+- When writing symlinks on Windows, we incorrectly handled relative symlink
+ targets, which was corrected.
+
+- When using the HTTP protocol via macOS' SecureTransport implementation, reads
+ could stall at the end of the session and only continue after a timeout of 60
+ seconds was reached.
+
+- The filesystem-based reference callback didn't corectly initialize the backend
+ version.
+
+- A segmentation fault was fixed when calling `git_blame_buffer()` for files
+ that were modified and added to the index.
+
+- A backwards-incompatible change was introduced when we moved some structures
+ from "git2/credentials.h" into "git2/sys/credentials.h". This was fixed in the
+ case where you do not use hard deprecation.
+
+- Improved error handling in various places.
+
+
+v0.99
+-----
+
+This is v0.99 "Torschlusspanik". This will be the last minor release
+before libgit2 v1.0. We expect to only respond to bugs in this release,
+to stabilize it for next major release.
+
+It contains significant refactorings, but is expected to be API-compatible
+with v0.28.0.
+
+### Changes or improvements
+
+* When fetching from an anonymous remote using a URL with authentication
+ information provided in the URL (eg `https://foo:bar@example.com/repo`),
+ we would erroneously include the literal URL in the FETCH_HEAD file.
+ We now remove that to match git's behavior.
+
+* Some credential structures, enums and values have been renamed:
+ `git_cred` is now `git_credential`. `git_credtype_t` is now
+ `git_credential_t`. Functions and types beginning with
+ `git_cred_` now begin with `git_credential`, and constants beginning
+ with `GIT_CREDTYPE` now begin with `GIT_CREDENTIAL`. The former names
+ are deprecated.
+
+* Several function signatures have been changed to return an `int` to
+ indicate error conditions. We encourage you to check them for errors
+ in the standard way.
+
+ * `git_attr_cache_flush`
+ * `git_error_set_str`
+ * `git_index_name_clear`
+ * `git_index_reuc_clear`
+ * `git_libgit2_version`
+ * `git_mempack_reset`
+ * `git_oid_cpy`
+ * `git_oid_fmt`
+ * `git_oid_fromraw`
+ * `git_oid_nfmt`
+ * `git_oid_pathfmt`
+ * `git_remote_stop`
+ * `git_remote_disconnect`
+ * `git_repository__cleanup`
+ * `git_repository_set_config`
+ * `git_repository_set_index`
+ * `git_repository_set_odb`
+ * `git_repository_set_refdb`
+ * `git_revwalk_reset`
+ * `git_revwalk_simplify_first_parent`
+ * `git_revwalk_sorting`
+ * `git_treebuilder_clear`
+ * `git_treebuilder_filter`
+
+* The NTLM and Negotiate authentication mechanisms are now supported when
+ talking to git implementations hosted on Apache or nginx servers.
+
+* The `HEAD` symbolic reference can no longer be deleted.
+
+* `git_merge_driver_source_repo` no longer returns a `const git_repository *`,
+ it now returns a non-`const` `git_repository *`.
+
+* Relative symbolic links are now supported on Windows when `core.symlinks`
+ is enabled.
+
+* Servers that provide query parameters with a redirect are now supported.
+
+* `git_submodule_sync` will now resolve relative URLs.
+
+* When creating git endpoint URLs, double-slashes are no longer used when
+ the given git URL has a trailing slash.
+
+* On Windows, a `DllMain` function is no longer included and thread-local
+ storage has moved to fiber-local storage in order to prevent race
+ conditions during shutdown.
+
+* The tracing mechanism (`GIT_TRACE`) is now enabled by default and does
+ not need to be explicitly enabled in CMake.
+
+* The size of Git objects is now represented by `git_object_size_t`
+ instead of `off_t`.
+
+* Binary patches without data can now be parsed.
+
+* A configuration snapshot can now be created from another configuration
+ snapshot, not just a "true" configuration object.
+
+* The `git_commit_with_signature` API will now ensure that referenced
+ objects exist in the object database.
+
+* Stash messages containing newlines will now be replaced with spaces;
+ they will no longer be (erroneously) written to the repository.
+
+* `git_commit_create_with_signature` now verifies the commit information
+ to ensure that it points to a valid tree and valid parents.
+
+* `git_apply` has an option `GIT_APPLY_CHECK` that will only do a dry-run.
+ The index and working directory will remain unmodified, and application
+ will report if it would have worked.
+
+* Patches produced by Mercurial (those that lack some git extended headers)
+ can now be parsed and applied.
+
+* Reference locks are obeyed correctly on POSIX platforms, instead of
+ being removed.
+
+* Patches with empty new files can now be read and applied.
+
+* `git_apply_to_tree` can now correctly apply patches that add new files.
+
+* The program data configuration on Windows (`C:\ProgramData\Git\config`)
+ must be owned by an administrator, a system account or the current user
+ to be read.
+
+* `git_blob_filtered_content` is now deprecated in favor of `git_blob_filter`.
+
+* Configuration files can now be included conditionally using the
+ `onbranch` conditional.
+
+* Checkout can now properly create and remove symbolic links to directories
+ on Windows.
+
+* Stash no longer recomputes trees when committing a worktree, for
+ improved performance.
+
+* Repository templates can now include a `HEAD` file to default the
+ initial default branch.
+
+* Some configuration structures, enums and values have been renamed:
+ `git_cvar_map` is now `git_configmap`, `git_cvar_t` is now
+ `git_configmap_t`, `GIT_CVAR_FALSE` is now `GIT_CONFIGMAP_FALSE`,
+ `GIT_CVAR_TRUE` is now `GIT_CONFIGMAP_TRUE`, `GIT_CVAR_INT32` is now
+ `GIT_CONFIGMAP_INT32`, and `GIT_CVAR_STRING` is now `GIT_CONFIGMAP_STRING`.
+ The former names are deprecated.
+
+* Repositories can now be created at the root of a Windows drive.
+
+* Configuration lookups are now more efficiently cached.
+
+* `git_commit_create_with_signature` now supports a `NULL` signature,
+ which will create a commit without adding a signature.
+
+* When a repository lacks an `info` "common directory", we will no
+ longer erroneously return `GIT_ENOTFOUND` for all attribute lookups.
+
+* Several attribute macros have been renamed: `GIT_ATTR_TRUE` is now
+ `GIT_ATTR_IS_TRUE`, `GIT_ATTR_FALSE` is now `GIT_ATTR_IS_FALSE`,
+ `GIT_ATTR_UNSPECIFIED` is now `GIT_ATTR_IS_UNSPECIFIED`. The
+ attribute enum `git_attr_t` is now `git_attr_value_t` and its
+ values have been renamed: `GIT_ATTR_UNSPECIFIED_T` is now
+ `GIT_ATTR_VALUE_UNSPECIFIED`, `GIT_ATTR_TRUE_T` is now
+ `GIT_ATTR_VALUE_TRUE`, `GIT_ATTR_FALSE_T` is now `GIT_ATTR_VALUE_FALSE`,
+ and `GIT_ATTR_VALUE_T` is now `GIT_ATTR_VALUE_STRING`. The
+ former names are deprecated.
+
+* `git_object__size` is now `git_object_size`. The former name is
+ deprecated.
+
+* `git_tag_create_frombuffer` is now `git_tag_create_from_buffer`. The
+ former name is deprecated.
+
+* Several blob creation functions have been renamed:
+ `git_blob_create_frombuffer` is now named `git_blob_create_from_buffer`,
+ `git_blob_create_fromdisk` is now named `git_blob_create_from_disk`,
+ `git_blob_create_fromworkdir` is now named `git_blob_create_from_workdir`,
+ `git_blob_create_fromstream` is now named `git_blob_create_from_stream`,
+ and `git_blob_create_fromstream_commit` is now named
+ `git_blob_create_from_stream_commit`. The former names are deprecated.
+
+* The function `git_oid_iszero` is now named `git_oid_is_zero`. The
+ former name is deprecated.
+
+* Pattern matching is now done using `wildmatch` instead of `fnmatch`
+ for compatibility with git.
+
+* The option initialization functions suffixed by `init_options` are now
+ suffixed with `options_init`. (For example, `git_checkout_init_options`
+ is now `git_checkout_options_init`.) The former names are deprecated.
+
+* NTLM2 authentication is now supported on non-Windows platforms.
+
+* The `git_cred_sign_callback` callback is now named `git_cred_sign_cb`.
+ The `git_cred_ssh_interactive_callback` callback is now named
+ `git_cred_ssh_interactive_cb`.
+
+* Ignore files now:
+
+ * honor escaped trailing whitespace.
+ * do not incorrectly negate sibling paths of a negated pattern.
+ * honor rules that stop ignoring files after a wildcard
+
+* Attribute files now:
+
+ * honor leading and trailing whitespace.
+ * treat paths beginning with `\` as absolute only on Windows.
+ * properly handle escaped characters.
+ * stop reading macros defined in subdirectories
+
+* The C locale is now correctly used when parsing regular expressions.
+
+* The system PCRE2 or PCRE regular expression libraries are now used
+ when `regcomp_l` is not available on the system. If none of these
+ are available on the system, an included version of PCRE is used.
+
+* Wildcards in reference specifications are now supported beyond simply
+ a bare wildcard (`*`) for compatibility with git.
+
+* When `git_ignore_path_is_ignored` is provided a path with a trailing
+ slash (eg, `dir/`), it will now treat it as a directory for the
+ purposes of ignore matching.
+
+* Patches that add or remove a file with a space in the path can now
+ be correctly parsed.
+
+* The `git_remote_completion_type` type is now `git_remote_completion_t`.
+ The former name is deprecated.
+
+* The `git_odb_backend_malloc` is now `git_odb_backend_data_alloc`. The
+ former name is deprecated.
+
+* The `git_transfer_progress_cb` callback is now `git_indexer_progress_cb`
+ and the `git_transfer_progress` structure is now `git_indexer_progress`.
+ The former names are deprecated.
+
+* The example projects are now contained in a single `lg2` executable
+ for ease of use.
+
+* libgit2 now correctly handles more URLs, such as
+ `http://example.com:/repo.git` (colon but no port),
+ `http://example.com` (no path),
+ and `http://example.com:8080/` (path is /, nonstandard port).
+
+* A carefully constructed commit object with a very large number
+ of parents may lead to potential out-of-bounds writes or
+ potential denial of service.
+
+* The ProgramData configuration file is always read for compatibility
+ with Git for Windows and Portable Git installations. The ProgramData
+ location is not necessarily writable only by administrators, so we
+ now ensure that the configuration file is owned by the administrator
+ or the current user.
+
+### API additions
+
+* The SSH host key now supports SHA-256 when `GIT_CERT_SSH_SHA256` is set.
+
+* The diff format option `GIT_DIFF_FORMAT_PATCH_ID` can now be used to
+ emit an output like `git patch-id`.
+
+* The `git_apply_options_init` function will initialize a
+ `git_apply_options` structure.
+
+* The remote callbacks structure adds a `git_url_resolve_cb` callback
+ that is invoked when connecting to a server, so that applications
+ may edit or replace the URL before connection.
+
+* The information about the original `HEAD` in a rebase operation is
+ available with `git_rebase_orig_head_name`. Its ID is available with
+ `git_rebase_orig_head_id`. The `onto` reference name is available with
+ `git_rebase_onto_name` and its ID is available with `git_rebase_onto_id`.
+
+* ODB backends can now free backend data when an error occurs during its
+ backend data creation using `git_odb_backend_data_free`.
+
+* Options may be specified to `git_repository_foreach_head` to control
+ its behavior: `GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO` will not skip
+ the main repository's HEAD reference, while
+ `GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES` will now skip the
+ worktree HEAD references.
+
+* The `GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS` option can be specified to
+ `git_libgit2_opts()` to avoid looking for `.keep` files that correspond
+ to packfiles. This setting can improve performance when packfiles are
+ stored on high-latency filesystems like network filesystems.
+
+* Blobs can now be filtered with `git_blob_filter`, which allows for
+ options to be set with `git_blob_filter_options`, including
+ `GIT_FILTER_NO_SYSTEM_ATTRIBUTES` to disable filtering with system-level
+ attributes in `/etc/gitattributes` and `GIT_ATTR_CHECK_INCLUDE_HEAD` to
+ enable filtering with `.gitattributes` files in the HEAD revision.
+
+### API removals
+
+* The unused `git_headlist_cb` function declaration was removed.
+
+* The unused `git_time_monotonic` API is removed.
+
+* The erroneously exported `inttypes.h` header was removed.
# Security Fixes
@@ -85,22 +528,62 @@ v0.28 + 1
"CollisionDetection". If you were using `SHA1_BACKEND` previously, you'll
need to check the value you've used, or switch to the autodetection.
-### Changes or improvements
-
-* libgit2 now correctly handles more URLs, such as
- `http://example.com:/repo.git` (colon but no port),
- `http://example.com` (no path),
- and `http://example.com:8080/` (path is /, nonstandard port).
-
-* A carefully constructed commit object with a very large number
- of parents may lead to potential out-of-bounds writes or
- potential denial of service.
-
-* The ProgramData configuration file is always read for compatibility
- with Git for Windows and Portable Git installations. The ProgramData
- location is not necessarily writable only by administrators, so we
- now ensure that the configuration file is owned by the administrator
- or the current user.
+### Authors
+
+The following individuals provided changes that were included in this
+release:
+
+* Aaron Patterson
+* Alberto Fanjul
+* Anders Borum
+* Augie Fackler
+* Augustin Fabre
+* Ayush Shridhar
+* brian m. carlson
+* buddyspike
+* Carlos MartÃn Nieto
+* cheese1
+* Dan Skorupski
+* Daniel Cohen Gindi
+* Dave Lee
+* David Brooks
+* David Turner
+* Denis Laxalde
+* Dhruva Krishnamurthy
+* Dominik Ritter
+* Drew DeVault
+* Edward Thomson
+* Eric Huss
+* Erik Aigner
+* Etienne Samson
+* Gregory Herrero
+* Heiko Voigt
+* Ian Hattendorf
+* Jacques Germishuys
+* Janardhan Pulivarthi
+* Jason Haslam
+* Johannes Schindelin
+* Jordan Wallet
+* Josh Bleecher Snyder
+* kas
+* kdj0c
+* Laurence McGlashan
+* lhchavez
+* Lukas Berk
+* Max Kostyukevich
+* Patrick Steinhardt
+* pcpthm
+* Remy Suen
+* Robert Coup
+* romkatv
+* Scott Furry
+* Sebastian Henke
+* Stefan Widgren
+* Steve King Jr
+* Sven Strickroth
+* Tobias Nießen
+* Tyler Ang-Wanek
+* Tyler Wanek
v0.28
-----
diff --git a/docs/coding-style.md b/docs/coding-style.md
new file mode 100644
index 0000000..b8b94d6
--- /dev/null
+++ b/docs/coding-style.md
@@ -0,0 +1,364 @@
+# libgit2 Coding Style
+
+This documentation describes the preferred coding style for the libgit2 project.
+While not all parts of our code base conform to this coding style, the outlined
+rules are what we aim for.
+
+Note that in no case do we accept changes that convert huge parts of the code
+base to use our coding style. Instead, it is encouraged to modernize small parts
+of code you're going to modify anyway for a given change you want to introduce.
+A good rule to follow is the Boy Scout Rule: "Leave the campground cleaner than
+you found it."
+
+## C Coding Style
+
+The following sections define the coding style for all code files and headers.
+
+### Indentation and Alignment
+
+Code is indented by tabs, where a tab is 8 spaces. Each opening scope increases
+the indentation level.
+
+```c
+int foobar(int void)
+{
+ if (condition)
+ doit();
+ /* Body */
+}
+```
+
+Switch statements have their `case`s aligned with the `switch` keyword. Case
+bodies are indented by an additional level. Case bodies should not open their
+own scope to declare variables.
+
+```c
+switch (c) {
+case 'a':
+case 'b':
+ return 0;
+default:
+ return -1;
+}
+```
+
+Multi-line conditions should be aligned with the opening brace of the current
+statement:
+
+```c
+if (one_very_long_condition(c) &&
+ another_very_long_condition(c))
+ doit();
+```
+
+### Spaces
+
+There must be no space between the function and its arguments, arguments must be
+separated by a space:
+
+```c
+int doit(int first_arg, int second_arg);
+doit(1, 2);
+```
+
+For any binary or ternary operators, the arguments and separator must be
+separated by a space:
+
+```c
+1 + 2;
+x ? x : NULL;
+```
+
+Unary operators do not have a space between them and the argument they refer to:
+
+```c
+*c
+&c
+```
+
+The `sizeof` operator always must not have a space and must use braces around
+the type:
+
+```
+sizeof(int)
+```
+
+There must be a space after the keywords `if`, `switch`, `case`, `do` and
+`while`.
+
+### Braces
+
+Functions must have their opening brace on the following line:
+
+```c
+void foobar(void)
+{
+ doit();
+}
+```
+
+For conditions, braces should be placed on the same line as the condition:
+
+```c
+if (condition(c)) {
+ doit();
+ dothat();
+}
+
+while (true) {
+ doit();
+}
+```
+
+In case a condition's body has a single line, only, it's allowed to omit braces,
+except if any of its `else if` or `else` branches has more than one line:
+
+```c
+if (condition(c))
+ doit();
+
+if (condition(c))
+ doit();
+else if (other_condition(c))
+ doit();
+
+/* This example must use braces as the `else if` requires them. */
+if (condition(c)) {
+ doit();
+} else if (other_condition(c)) {
+ doit();
+ dothat();
+} else {
+ abort();
+}
+```
+
+### Comments
+
+Comments must use C-style `/* */` comments. C++-style `// `comments are not
+allowed in our codebase. This is a strict requirement as libgit2 tries to be
+compliant with the ISO C90 standard, which only allows C-style comments.
+
+Single-line comments may have their opening and closing tag on the same line:
+
+```c
+/* This is a short comment. */
+```
+
+For multi-line comments, the opening and closing tag should be empty:
+
+```c
+/*
+ * This is a rather long and potentially really unwiedly but informative
+ * multiline comment that helps quite a lot.
+ */
+```
+
+Public functions must have documentation that explain their usage, internal
+functions should have a comment. We use Docurium to generate documentation
+derived from these comments, which uses syntax similar to Doxygen. The first
+line should be a short summary of what the function does. More in-depth
+explanation should be separated from that first line by an empty line.
+Parameters and return values should be documented via `@return` and `@param`
+tags:
+
+```c
+/*
+ * Froznicate the string.
+ *
+ * Froznicate the string by foobaring its internal structure into a more obvious
+ * translation. Note that the returned string is a newly allocated string that
+ * shall be `free`d by the caller.
+ *
+ * @param s String to froznicate
+ * @return A newly allocated string or `NULL` in case an error occurred.
+ */
+char *froznicate(const char *s);
+```
+
+### Variables
+
+Variables must be declared at the beginning of their scope. This is a strict
+requirement as libgit2 tries to be compliant with the ISO C90 standard, which
+forbids mixed declarations and code:
+
+```c
+void foobar(void)
+{
+ char *c = NULL;
+ int a, b;
+
+ a = 0;
+ b = 1;
+
+ return c;
+}
+```
+
+### Naming
+
+Variables must have all-lowercase names. In case a variable name has multiple
+words, words should be separated by an underscore `_` character. While
+recommended to use descriptive naming, common variable names like `i` for
+indices are allowed.
+
+All public functions must have a `git` prefix as well as a prefix indicating
+their respective subsystem. E.g. a function that opens a repository should be
+called `git_repository_open()`. Functions that are not public but declared in
+an internal header file for use by other subsystems should follow the same
+naming pattern. File-local static functions must not have a `git` prefix, but
+should have a prefix indicating their respective subsystem.
+
+All structures declared in the libgit2 project must have a `typedef`, we do not
+use `struct type` variables. Type names follow the same schema as functions.
+
+### Error Handling
+
+The libgit2 project mostly uses error codes to indicate errors. Error codes are
+always of type `int`, where `0` indicates success and a negative error code
+indicates an error case. In some cases, positive error codes may be used to
+indicate special cases. Returned values that are not an error code should be
+returned via an out parameter. Out parameters must always come first in the list
+of arguments.
+
+```c
+int doit(const char **out, int arg)
+{
+ if (!arg)
+ return -1;
+ *out = "Got an argument";
+ return 0;
+}
+```
+
+To avoid repetitive and fragile error handling in case a function has resources
+that need to be free'd, we use `goto out`s:
+
+```c
+int doit(char **out, int arg)
+{
+ int error = 0;
+ char *c;
+
+ c = malloc(strlen("Got an argument") + 1);
+ if (!c) {
+ error = -1;
+ goto out;
+ }
+
+ if (!arg) {
+ error = -1;
+ goto out;
+ }
+
+ strcpy(c, "Got an argument")
+ *out = c;
+
+out:
+ if (error)
+ free(c);
+ return error;
+}
+```
+
+When calling functions that return an error code, you should assign the error
+code to an `error` variable and, in case an error case is indicated and no
+custom error handling is required, return that error code:
+
+```c
+int foobar(void)
+{
+ int error;
+
+ if ((error = doit()) < 0)
+ return error;
+
+ return 0;
+}
+```
+
+When doing multiple function calls where all of the functions return an error
+code, it's common practice to chain these calls together:
+
+```c
+int doit(void)
+{
+ int error;
+
+ if ((error = dothis()) < 0 ||
+ (error = dothat()) < 0)
+ return error;
+
+ return 0;
+}
+```
+
+## CMake Coding Style
+
+The following section defines the coding style for our CMake build system.
+
+### Indentation
+
+Code is indented by tabs, where a tab is 8 spaces. Each opening scope increases
+the indentation level.
+
+```cmake
+if(CONDITION)
+ doit()
+endif()
+```
+
+### Spaces
+
+There must be no space between keywords and their opening brace. While this is
+the same as in our C codebase for function calls, this also applies to
+conditional keywords. This is done to avoid the awkward-looking `else ()`
+statement.
+
+```cmake
+if(CONDITION)
+ doit()
+else()
+ dothat()
+endif()
+```
+
+### Case
+
+While CMake is completely case-insensitive when it comes to function calls, we
+want to agree on a common coding style for this. To reduce the danger of
+repetitive strain injuries, all function calls should be lower-case (NB: this is
+not currently the case yet, but introduced as a new coding style by this
+document).
+
+Variables are written all-uppercase. In contrast to functions, variables are
+case-sensitive in CMake. As CMake itself uses upper-case variables in all
+places, we should follow suit and do the same.
+
+Control flow keywords must be all lowercase. In contrast to that, test keywords
+must be all uppercase:
+
+```cmake
+if(NOT CONDITION)
+ doit()
+elseif(FOO AND BAR)
+ dothat()
+endif()
+```
+
+### Targets
+
+CMake code should not use functions that modify the global scope but prefer
+their targeted equivalents, instead. E.g. instead of using
+`include_directories()`, you must use `target_include_directories()`. An
+exception to this rule is setting up global compiler flags like warnings or
+flags required to set up the build type.
+
+### Dependencies
+
+Dependencies should not be discovered or set up in the main "CMakeLists.txt"
+module. Instead, they should either have their own module in our top-level
+"cmake/" directory or have a "CMakeLists.txt" in their respective "deps/"
+directory in case it is a vendored library. All dependencies should expose
+interface library targets that can be linked against with
+`target_link_libraries()`.
diff --git a/docs/contributing.md b/docs/contributing.md
index 21e42b1..f3e559c 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -18,7 +18,7 @@ The bundled dependencies in the `deps` directories are governed
by the following licenses:
- http-parser is licensed under [MIT license](../deps/http-parser/COPYING)
-- regex is governed by [LGPL v2.1+ license](../deps/regex/COPYING)
+- pcre is governed by [BSD license](../deps/pcre/LICENCE)
- winhttp is governed by [LGPL v2.1+](../deps/winhttp/COPYING.LGPL) and [GPL v2 with linking exception](../deps/winhttp/COPYING.GPL)
- zlib is governed by [zlib license](../deps/zlib/COPYING)
@@ -35,7 +35,7 @@ easily accessible permanent record of the conversation.
## Libgit2 Versions
-The `master` branch is the main branch where development happens.
+The `main` branch is the main branch where development happens.
Releases are tagged
(e.g. [v0.21.0](https://github.com/libgit2/libgit2/releases/tag/v0.21.0) )
and when a critical bug fix needs to be backported, it will be done on a
@@ -51,7 +51,7 @@ commit SHA
Using [`git describe`](http://git-scm.com/docs/git-describe) is a
great way to tell us what version you're working with.
-If you're not running against the latest `master` branch version,
+If you're not running against the latest `main` branch version,
please compile and test against that to avoid re-reporting an issue that's
already been fixed.
@@ -68,11 +68,11 @@ flow](https://guides.github.com/introduction/flow/index.html), where
contributors fork the [libgit2 repository](https://github.com/libgit2/libgit2),
make their changes on branch, and submit a
[Pull Request](https://help.github.com/articles/using-pull-requests)
-(a.k.a. "PR"). Pull requests should usually be targeted at the `master`
+(a.k.a. "PR"). Pull requests should usually be targeted at the `main`
branch.
Life will be a lot easier for you (and us) if you follow this pattern
-(i.e. fork, named branch, submit PR). If you use your fork's `master`
+(i.e. fork, named branch, submit PR). If you use your fork's `main`
branch directly, things can get messy.
Please include a nice description of your changes when you submit your PR;
diff --git a/docs/fuzzing.md b/docs/fuzzing.md
index cd82576..25b32cb 100644
--- a/docs/fuzzing.md
+++ b/docs/fuzzing.md
@@ -3,7 +3,7 @@
libgit2 is currently using [libFuzzer](https://libfuzzer.info) to perform
automated fuzz testing. libFuzzer only works with clang.
-## Prerequisites** for building fuzz targets:
+## Prerequisites for building fuzz targets:
1. All the prerequisites for [building libgit2](https://github.com/libgit2/libgit2).
2. A recent version of clang. 6.0 is preferred. [pre-build Debian/Ubuntu
@@ -27,14 +27,15 @@ automated fuzz testing. libFuzzer only works with clang.
## Run the fuzz targets
-1. `ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolize-6.0
+1. `ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolize
LSAN_OPTIONS=allocator_may_return_null=1
- ASAN_OPTIONS=allocator_may_return_null=1 ./build/fuzz/fuzz_packfile_raw
- fuzz/corpora/fuzz_packfile_raw/`
+ ASAN_OPTIONS=allocator_may_return_null=1 ./build/fuzzers/packfile_fuzzer
+ fuzzers/corpora/packfile/`
The `LSAN_OPTIONS` and `ASAN_OPTIONS` are there to allow `malloc(3)` to return
-`NULL`. The `LLVM_PROFILE_FILE` is there to override the path where libFuzzer
-will write the coverage report.
+`NULL`, which is expected if a huge chunk of memory is allocated. The
+`LLVM_PROFILE_FILE` environment string can also be added to override the path
+where libFuzzer will write the coverage report.
## Get coverage
diff --git a/docs/release.md b/docs/release.md
index 22b35ed..3200c44 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -1,6 +1,6 @@
# Releasing the library
-We have three kinds of releases: "full" releases, maintenance releases and security releases. Full ones release the state of the `master` branch whereas maintenance releases provide bugfixes building on top of the currently released series. Security releases are also for the current series but only contain security fixes on top of the previous release.
+We have three kinds of releases: "full" releases, maintenance releases and security releases. Full ones release the state of the `main` branch whereas maintenance releases provide bugfixes building on top of the currently released series. Security releases are also for the current series but only contain security fixes on top of the previous release.
## Full release
@@ -40,7 +40,7 @@ followed by the three sections in the changelog. For release candidates we can a
During the freeze, and certainly after the first release candidate, any bindings the core team work with should be updated in order to discover any issues that might come up with the multitude of approaches to memory management, embedding or linking.
-Create a branch `maint/v0.X` at the current state of `master` after you've created the tag. This will be used for maintenance releases and lets our dependents track the latest state of the series.
+Create a branch `maint/v0.X` at the current state of `main` after you've created the tag. This will be used for maintenance releases and lets our dependents track the latest state of the series.
## Maintenance release
@@ -76,7 +76,7 @@ We use docurium to generate our documentation. It is a tool written in ruby whic
gem install docurium
-and run it against our description file with the tip of master checked out.
+and run it against our description file with the tip of `main` checked out.
cm doc api.docurium
diff --git a/docs/win32-longpaths.md b/docs/win32-longpaths.md
new file mode 100644
index 0000000..a18152f
--- /dev/null
+++ b/docs/win32-longpaths.md
@@ -0,0 +1,36 @@
+core.longpaths support
+======================
+
+Historically, Windows has limited absolute path lengths to `MAX_PATH`
+(260) characters.
+
+Unfortunately, 260 characters is a punishing small maximum. This is
+especially true for developers where dependencies may have dependencies
+in a folder, each dependency themselves having dependencies in a
+sub-folder, ad (seemingly) infinitum.
+
+So although the Windows APIs _by default_ honor this 260 character
+maximum, you can get around this by using separate APIs. Git honors a
+`core.longpaths` configuration option that allows some paths on Windows
+to exceed these 260 character limits.
+
+And because they've gone and done it, that means that libgit2 has to
+honor this value, too.
+
+Since `core.longpaths` is a _configuration option_ that means that we
+need to be able to resolve a configuration - including in _the repository
+itself_ in order to know whether long paths should be supported.
+
+Therefore, in libgit2, `core.longpaths` affects paths in working
+directories _only_. Paths to the repository, and to items inside the
+`.git` folder, must be no longer than 260 characters.
+
+This definition is required to avoid a paradoxical setting: if you
+had a repository in a folder that was 280 characters long, how would
+you know whether `core.longpaths` support should be enabled? Even if
+`core.longpaths` was set to true in a system configuration file, the
+repository itself may set `core.longpaths` to false in _its_ configuration
+file, which you could only read if `core.longpaths` were set to true.
+
+Thus, `core.longpaths` must _only_ apply to working directory items,
+and cannot apply to the `.git` folder or its contents.
diff --git a/examples/add.c b/examples/add.c
index 6e3c239..542360e 100644
--- a/examples/add.c
+++ b/examples/add.c
@@ -48,9 +48,11 @@ int lg2_add(git_repository *repo, int argc, char **argv)
git_index_matched_path_cb matched_cb = NULL;
git_index *index;
git_strarray array = {0};
- struct index_options options;
+ struct index_options options = {0};
struct args_info args = ARGS_INFO_INIT;
+ options.mode = INDEX_ADD;
+
/* Parse the options & arguments. */
parse_opts(NULL, &options, &args);
strarray_from_args(&array, &args);
diff --git a/examples/blame.c b/examples/blame.c
index 49350fc..954c97b 100644
--- a/examples/blame.c
+++ b/examples/blame.c
@@ -54,7 +54,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
*/
if (o.commitspec) {
check_lg2(git_revparse(&revspec, repo, o.commitspec), "Couldn't parse commit spec", NULL);
- if (revspec.flags & GIT_REVPARSE_SINGLE) {
+ if (revspec.flags & GIT_REVSPEC_SINGLE) {
git_oid_cpy(&blameopts.newest_commit, git_object_id(revspec.from));
git_object_free(revspec.from);
} else {
diff --git a/examples/checkout.c b/examples/checkout.c
index 897c42f..ac7b742 100644
--- a/examples/checkout.c
+++ b/examples/checkout.c
@@ -14,7 +14,7 @@
#include "common.h"
-/* Define the printf format specifer to use for size_t output */
+/* Define the printf format specifier to use for size_t output */
#if defined(_MSC_VER) || defined(__MINGW32__)
# define PRIuZ "Iu"
# define PRIxZ "Ix"
@@ -239,7 +239,7 @@ next:
out:
git_reference_free(remote_ref);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
return error;
}
diff --git a/examples/commit.c b/examples/commit.c
new file mode 100644
index 0000000..cd9782d
--- /dev/null
+++ b/examples/commit.c
@@ -0,0 +1,84 @@
+/*
+ * libgit2 "commit" example - shows how to create a git commit
+ *
+ * Written by the libgit2 contributors
+ *
+ * To the extent possible under law, the author(s) have dedicated all copyright
+ * and related and neighboring rights to this software to the public domain
+ * worldwide. This software is distributed without any warranty.
+ *
+ * You should have received a copy of the CC0 Public Domain Dedication along
+ * with this software. If not, see
+ * <http://creativecommons.org/publicdomain/zero/1.0/>.
+ */
+
+#include "common.h"
+
+/**
+ * This example demonstrates the libgit2 commit APIs to roughly
+ * simulate `git commit` with the commit message argument.
+ *
+ * This does not have:
+ *
+ * - Robust error handling
+ * - Most of the `git commit` options
+ *
+ * This does have:
+ *
+ * - Example of performing a git commit with a comment
+ *
+ */
+int lg2_commit(git_repository *repo, int argc, char **argv)
+{
+ const char *opt = argv[1];
+ const char *comment = argv[2];
+ int error;
+
+ git_oid commit_oid,tree_oid;
+ git_tree *tree;
+ git_index *index;
+ git_object *parent = NULL;
+ git_reference *ref = NULL;
+ git_signature *signature;
+
+ /* Validate args */
+ if (argc < 3 || strcmp(opt, "-m") != 0) {
+ printf ("USAGE: %s -m <comment>\n", argv[0]);
+ return -1;
+ }
+
+ error = git_revparse_ext(&parent, &ref, repo, "HEAD");
+ if (error == GIT_ENOTFOUND) {
+ printf("HEAD not found. Creating first commit\n");
+ error = 0;
+ } else if (error != 0) {
+ const git_error *err = git_error_last();
+ if (err) printf("ERROR %d: %s\n", err->klass, err->message);
+ else printf("ERROR %d: no detailed info\n", error);
+ }
+
+ check_lg2(git_repository_index(&index, repo), "Could not open repository index", NULL);
+ check_lg2(git_index_write_tree(&tree_oid, index), "Could not write tree", NULL);;
+ check_lg2(git_index_write(index), "Could not write index", NULL);;
+
+ check_lg2(git_tree_lookup(&tree, repo, &tree_oid), "Error looking up tree", NULL);
+
+ check_lg2(git_signature_default(&signature, repo), "Error creating signature", NULL);
+
+ check_lg2(git_commit_create_v(
+ &commit_oid,
+ repo,
+ "HEAD",
+ signature,
+ signature,
+ NULL,
+ comment,
+ tree,
+ parent ? 1 : 0, parent), "Error creating commit", NULL);
+
+ git_index_free(index);
+ git_signature_free(signature);
+ git_tree_free(tree);
+
+ return error;
+}
diff --git a/examples/common.h b/examples/common.h
index c01561b..f86e92c 100644
--- a/examples/common.h
+++ b/examples/common.h
@@ -36,7 +36,7 @@
#endif
#ifndef PRIuZ
-/* Define the printf format specifer to use for size_t output */
+/* Define the printf format specifier to use for size_t output */
#if defined(_MSC_VER) || defined(__MINGW32__)
# define PRIuZ "Iu"
#else
@@ -59,6 +59,7 @@ extern int lg2_blame(git_repository *repo, int argc, char **argv);
extern int lg2_cat_file(git_repository *repo, int argc, char **argv);
extern int lg2_checkout(git_repository *repo, int argc, char **argv);
extern int lg2_clone(git_repository *repo, int argc, char **argv);
+extern int lg2_commit(git_repository *repo, int argc, char **argv);
extern int lg2_config(git_repository *repo, int argc, char **argv);
extern int lg2_describe(git_repository *repo, int argc, char **argv);
extern int lg2_diff(git_repository *repo, int argc, char **argv);
@@ -71,6 +72,7 @@ extern int lg2_log(git_repository *repo, int argc, char **argv);
extern int lg2_ls_files(git_repository *repo, int argc, char **argv);
extern int lg2_ls_remote(git_repository *repo, int argc, char **argv);
extern int lg2_merge(git_repository *repo, int argc, char **argv);
+extern int lg2_push(git_repository *repo, int argc, char **argv);
extern int lg2_remote(git_repository *repo, int argc, char **argv);
extern int lg2_rev_list(git_repository *repo, int argc, char **argv);
extern int lg2_rev_parse(git_repository *repo, int argc, char **argv);
diff --git a/examples/general.c b/examples/general.c
index ddc53c3..2127ec0 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -158,11 +158,6 @@ static void oid_parsing(git_oid *oid)
* If you have a oid, you can easily get the hex value of the SHA as well.
*/
git_oid_fmt(out, oid);
-
- /**
- * If you have a oid, you can easily get the hex value of the SHA as well.
- */
- git_oid_fmt(out, oid);
printf("SHA hex string: %s\n", out);
}
@@ -707,13 +702,13 @@ static void reference_listing(git_repository *repo)
git_reference_free(ref);
}
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
/**
* ### Config Files
*
- * The [config API][config] allows you to list and updatee config values
+ * The [config API][config] allows you to list and update config values
* in any of the accessible config file locations (system, global, local).
*
* [config]: http://libgit2.github.com/libgit2/#HEAD/group/config
diff --git a/examples/lg2.c b/examples/lg2.c
index a3987c3..7946bc2 100644
--- a/examples/lg2.c
+++ b/examples/lg2.c
@@ -15,6 +15,7 @@ struct {
{ "cat-file", lg2_cat_file, 1 },
{ "checkout", lg2_checkout, 1 },
{ "clone", lg2_clone, 0 },
+ { "commit", lg2_commit, 1 },
{ "config", lg2_config, 1 },
{ "describe", lg2_describe, 1 },
{ "diff", lg2_diff, 1 },
@@ -27,6 +28,7 @@ struct {
{ "ls-files", lg2_ls_files, 1 },
{ "ls-remote", lg2_ls_remote, 1 },
{ "merge", lg2_merge, 1 },
+ { "push", lg2_push, 1 },
{ "remote", lg2_remote, 1 },
{ "rev-list", lg2_rev_list, 1 },
{ "rev-parse", lg2_rev_parse, 1 },
diff --git a/examples/log.c b/examples/log.c
index 3eee7d4..9060f3f 100644
--- a/examples/log.c
+++ b/examples/log.c
@@ -245,7 +245,7 @@ static int add_revision(struct log_state *s, const char *revstr)
}
if (*revstr == '^') {
- revs.flags = GIT_REVPARSE_SINGLE;
+ revs.flags = GIT_REVSPEC_SINGLE;
hide = !hide;
if (git_revparse_single(&revs.from, s->repo, revstr + 1) < 0)
@@ -253,12 +253,12 @@ static int add_revision(struct log_state *s, const char *revstr)
} else if (git_revparse(&revs, s->repo, revstr) < 0)
return -1;
- if ((revs.flags & GIT_REVPARSE_SINGLE) != 0)
+ if ((revs.flags & GIT_REVSPEC_SINGLE) != 0)
push_rev(s, revs.from, hide);
else {
push_rev(s, revs.to, hide);
- if ((revs.flags & GIT_REVPARSE_MERGE_BASE) != 0) {
+ if ((revs.flags & GIT_REVSPEC_MERGE_BASE) != 0) {
git_oid base;
check_lg2(git_merge_base(&base, s->repo,
git_object_id(revs.from), git_object_id(revs.to)),
@@ -434,21 +434,28 @@ static int parse_options(
else if (!strcmp(a, "--reverse"))
set_sorting(s, GIT_SORT_REVERSE);
else if (match_str_arg(&opt->author, &args, "--author"))
- /** Found valid --author */;
+ /** Found valid --author */
+ ;
else if (match_str_arg(&opt->committer, &args, "--committer"))
- /** Found valid --committer */;
+ /** Found valid --committer */
+ ;
else if (match_str_arg(&opt->grep, &args, "--grep"))
- /** Found valid --grep */;
+ /** Found valid --grep */
+ ;
else if (match_str_arg(&s->repodir, &args, "--git-dir"))
- /** Found git-dir. */;
+ /** Found git-dir. */
+ ;
else if (match_int_arg(&opt->skip, &args, "--skip", 0))
- /** Found valid --skip. */;
+ /** Found valid --skip. */
+ ;
else if (match_int_arg(&opt->limit, &args, "--max-count", 0))
- /** Found valid --max-count. */;
+ /** Found valid --max-count. */
+ ;
else if (a[1] >= '0' && a[1] <= '9')
is_integer(&opt->limit, a + 1, 0);
else if (match_int_arg(&opt->limit, &args, "-n", 0))
- /** Found valid -n. */;
+ /** Found valid -n. */
+ ;
else if (!strcmp(a, "--merges"))
opt->min_parents = 2;
else if (!strcmp(a, "--no-merges"))
@@ -458,9 +465,11 @@ static int parse_options(
else if (!strcmp(a, "--no-max-parents"))
opt->max_parents = -1;
else if (match_int_arg(&opt->max_parents, &args, "--max-parents=", 1))
- /** Found valid --max-parents. */;
+ /** Found valid --max-parents. */
+ ;
else if (match_int_arg(&opt->min_parents, &args, "--min-parents=", 0))
- /** Found valid --min_parents. */;
+ /** Found valid --min_parents. */
+ ;
else if (!strcmp(a, "-p") || !strcmp(a, "-u") || !strcmp(a, "--patch"))
opt->show_diff = 1;
else if (!strcmp(a, "--log-size"))
diff --git a/examples/push.c b/examples/push.c
new file mode 100644
index 0000000..bcf3076
--- /dev/null
+++ b/examples/push.c
@@ -0,0 +1,56 @@
+/*
+ * libgit2 "push" example - shows how to push to remote
+ *
+ * Written by the libgit2 contributors
+ *
+ * To the extent possible under law, the author(s) have dedicated all copyright
+ * and related and neighboring rights to this software to the public domain
+ * worldwide. This software is distributed without any warranty.
+ *
+ * You should have received a copy of the CC0 Public Domain Dedication along
+ * with this software. If not, see
+ * <http://creativecommons.org/publicdomain/zero/1.0/>.
+ */
+
+#include "common.h"
+
+/**
+ * This example demonstrates the libgit2 push API to roughly
+ * simulate `git push`.
+ *
+ * This does not have:
+ *
+ * - Robust error handling
+ * - Any of the `git push` options
+ *
+ * This does have:
+ *
+ * - Example of push to origin/master
+ *
+ */
+
+/** Entry point for this command */
+int lg2_push(git_repository *repo, int argc, char **argv) {
+ git_push_options options;
+ git_remote* remote = NULL;
+ char *refspec = "refs/heads/master";
+ const git_strarray refspecs = {
+ &refspec,
+ 1
+ };
+
+ /* Validate args */
+ if (argc > 1) {
+ printf ("USAGE: %s\n\nsorry, no arguments supported yet\n", argv[0]);
+ return -1;
+ }
+
+ check_lg2(git_remote_lookup(&remote, repo, "origin" ), "Unable to lookup remote", NULL);
+
+ check_lg2(git_push_options_init(&options, GIT_PUSH_OPTIONS_VERSION ), "Error initializing push", NULL);
+
+ check_lg2(git_remote_push(remote, &refspecs, &options), "Error pushing", NULL);
+
+ printf("pushed\n");
+ return 0;
+}
diff --git a/examples/remote.c b/examples/remote.c
index 34d8865..57f758c 100644
--- a/examples/remote.c
+++ b/examples/remote.c
@@ -129,7 +129,7 @@ static int cmd_rename(git_repository *repo, struct remote_opts *o)
puts(problems.strings[0]);
}
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
return retval;
}
@@ -207,7 +207,7 @@ static int cmd_show(git_repository *repo, struct remote_opts *o)
git_remote_free(remote);
}
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
return 0;
}
diff --git a/examples/rev-list.c b/examples/rev-list.c
index 75fb19e..d10f166 100644
--- a/examples/rev-list.c
+++ b/examples/rev-list.c
@@ -73,7 +73,7 @@ static int push_range(git_repository *repo, git_revwalk *walk, const char *range
if ((error = git_revparse(&revspec, repo, range)))
return error;
- if (revspec.flags & GIT_REVPARSE_MERGE_BASE) {
+ if (revspec.flags & GIT_REVSPEC_MERGE_BASE) {
/* TODO: support "<commit>...<commit>" */
return GIT_EINVALIDSPEC;
}
diff --git a/examples/rev-parse.c b/examples/rev-parse.c
index 7d6e998..90258c1 100644
--- a/examples/rev-parse.c
+++ b/examples/rev-parse.c
@@ -69,17 +69,17 @@ static int parse_revision(git_repository *repo, struct parse_state *ps)
check_lg2(git_revparse(&rs, repo, ps->spec), "Could not parse", ps->spec);
- if ((rs.flags & GIT_REVPARSE_SINGLE) != 0) {
+ if ((rs.flags & GIT_REVSPEC_SINGLE) != 0) {
git_oid_tostr(str, sizeof(str), git_object_id(rs.from));
printf("%s\n", str);
git_object_free(rs.from);
}
- else if ((rs.flags & GIT_REVPARSE_RANGE) != 0) {
+ else if ((rs.flags & GIT_REVSPEC_RANGE) != 0) {
git_oid_tostr(str, sizeof(str), git_object_id(rs.to));
printf("%s\n", str);
git_object_free(rs.to);
- if ((rs.flags & GIT_REVPARSE_MERGE_BASE) != 0) {
+ if ((rs.flags & GIT_REVSPEC_MERGE_BASE) != 0) {
git_oid base;
check_lg2(git_merge_base(&base, repo,
git_object_id(rs.from), git_object_id(rs.to)),
diff --git a/examples/tag.c b/examples/tag.c
index 4408294..e4f71ae 100644
--- a/examples/tag.c
+++ b/examples/tag.c
@@ -162,7 +162,7 @@ static void action_list_tags(tag_state *state)
each_tag(tag_names.strings[i], state);
}
- git_strarray_free(&tag_names);
+ git_strarray_dispose(&tag_names);
}
static void action_delete_tag(tag_state *state)
@@ -188,7 +188,7 @@ static void action_delete_tag(tag_state *state)
git_object_free(obj);
}
-static void action_create_lighweight_tag(tag_state *state)
+static void action_create_lightweight_tag(tag_state *state)
{
git_repository *repo = state->repo;
struct tag_options *opts = state->opts;
@@ -260,7 +260,7 @@ static void parse_options(tag_action *action, struct tag_options *opts, int argc
print_usage();
if (*action != &action_create_tag)
- *action = &action_create_lighweight_tag;
+ *action = &action_create_lightweight_tag;
} else if (!strcmp(curr, "-n")) {
opts->num_lines = 1;
*action = &action_list_tags;
diff --git a/fuzzers/commit_graph_fuzzer.c b/fuzzers/commit_graph_fuzzer.c
new file mode 100644
index 0000000..b41816e
--- /dev/null
+++ b/fuzzers/commit_graph_fuzzer.c
@@ -0,0 +1,80 @@
+/*
+ * libgit2 commit-graph fuzzer target.
+ *
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include <stdio.h>
+
+#include "git2.h"
+
+#include "buffer.h"
+#include "common.h"
+#include "futils.h"
+#include "hash.h"
+#include "commit_graph.h"
+
+int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ GIT_UNUSED(argc);
+ GIT_UNUSED(argv);
+
+ if (git_libgit2_init() < 0) {
+ fprintf(stderr, "Failed to initialize libgit2\n");
+ abort();
+ }
+ return 0;
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ git_commit_graph_file file = {{0}};
+ git_commit_graph_entry e;
+ git_buf commit_graph_buf = GIT_BUF_INIT;
+ git_oid oid = {{0}};
+ bool append_hash = false;
+
+ if (size < 4)
+ return 0;
+
+ /*
+ * If the first byte in the stream has the high bit set, append the
+ * SHA1 hash so that the file is somewhat valid.
+ */
+ append_hash = *data & 0x80;
+ /* Keep a 4-byte alignment to avoid unaligned accesses. */
+ data += 4;
+ size -= 4;
+
+ if (append_hash) {
+ if (git_buf_init(&commit_graph_buf, size + sizeof(oid)) < 0)
+ goto cleanup;
+ if (git_hash_buf(&oid, data, size) < 0) {
+ fprintf(stderr, "Failed to compute the SHA1 hash\n");
+ abort();
+ }
+ memcpy(commit_graph_buf.ptr, data, size);
+ memcpy(commit_graph_buf.ptr + size, &oid, sizeof(oid));
+ } else {
+ git_buf_attach_notowned(&commit_graph_buf, (char *)data, size);
+ }
+
+ if (git_commit_graph_file_parse(
+ &file,
+ (const unsigned char *)git_buf_cstr(&commit_graph_buf),
+ git_buf_len(&commit_graph_buf))
+ < 0)
+ goto cleanup;
+
+ /* Search for any oid, just to exercise that codepath. */
+ if (git_commit_graph_entry_find(&e, &file, &oid, GIT_OID_HEXSZ) < 0)
+ goto cleanup;
+
+cleanup:
+ git_commit_graph_file_close(&file);
+ git_buf_dispose(&commit_graph_buf);
+ return 0;
+}
diff --git a/fuzzers/corpora/commit_graph/005682ce1cb5b20c20fccf4be5dbd47ca399e53e b/fuzzers/corpora/commit_graph/005682ce1cb5b20c20fccf4be5dbd47ca399e53e
new file mode 100644
index 0000000..15d0d28
Binary files /dev/null and b/fuzzers/corpora/commit_graph/005682ce1cb5b20c20fccf4be5dbd47ca399e53e differ
diff --git a/fuzzers/corpora/commit_graph/00574fc29fd1323e93d18d625cde80d3ea20e8cc b/fuzzers/corpora/commit_graph/00574fc29fd1323e93d18d625cde80d3ea20e8cc
new file mode 100644
index 0000000..4eabd00
Binary files /dev/null and b/fuzzers/corpora/commit_graph/00574fc29fd1323e93d18d625cde80d3ea20e8cc differ
diff --git a/fuzzers/corpora/commit_graph/00916ec21ddbd3c622bde6e4dc824250176b9e88 b/fuzzers/corpora/commit_graph/00916ec21ddbd3c622bde6e4dc824250176b9e88
new file mode 100644
index 0000000..d069fb5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/00916ec21ddbd3c622bde6e4dc824250176b9e88 differ
diff --git a/fuzzers/corpora/commit_graph/00b6dde4b8d5e68a5ec40d88c39134cf2f1f8bc3 b/fuzzers/corpora/commit_graph/00b6dde4b8d5e68a5ec40d88c39134cf2f1f8bc3
new file mode 100644
index 0000000..98f2d0e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/00b6dde4b8d5e68a5ec40d88c39134cf2f1f8bc3 differ
diff --git a/fuzzers/corpora/commit_graph/020f0e77e42d8b3810019050f4c5ceadd205b37c b/fuzzers/corpora/commit_graph/020f0e77e42d8b3810019050f4c5ceadd205b37c
new file mode 100644
index 0000000..d09327d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/020f0e77e42d8b3810019050f4c5ceadd205b37c differ
diff --git a/fuzzers/corpora/commit_graph/02739c05abc1715fac1ce995b532e482abc8d4dc b/fuzzers/corpora/commit_graph/02739c05abc1715fac1ce995b532e482abc8d4dc
new file mode 100644
index 0000000..b9de08e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/02739c05abc1715fac1ce995b532e482abc8d4dc differ
diff --git a/fuzzers/corpora/commit_graph/02a276faa5dc8c7df5b82a57ab6cd195a13e4ae0 b/fuzzers/corpora/commit_graph/02a276faa5dc8c7df5b82a57ab6cd195a13e4ae0
new file mode 100644
index 0000000..891d3ef
Binary files /dev/null and b/fuzzers/corpora/commit_graph/02a276faa5dc8c7df5b82a57ab6cd195a13e4ae0 differ
diff --git a/fuzzers/corpora/commit_graph/02de15987d68a97db3d9fd964cfd785bcbd54d3a b/fuzzers/corpora/commit_graph/02de15987d68a97db3d9fd964cfd785bcbd54d3a
new file mode 100644
index 0000000..b8bd4ce
Binary files /dev/null and b/fuzzers/corpora/commit_graph/02de15987d68a97db3d9fd964cfd785bcbd54d3a differ
diff --git a/fuzzers/corpora/commit_graph/02e106f97a91b1d3aef4dd2d31368ae5077bd42b b/fuzzers/corpora/commit_graph/02e106f97a91b1d3aef4dd2d31368ae5077bd42b
new file mode 100644
index 0000000..f127739
Binary files /dev/null and b/fuzzers/corpora/commit_graph/02e106f97a91b1d3aef4dd2d31368ae5077bd42b differ
diff --git a/fuzzers/corpora/commit_graph/038555bcb4cc2daf764840f79ebce4023bdb7670 b/fuzzers/corpora/commit_graph/038555bcb4cc2daf764840f79ebce4023bdb7670
new file mode 100644
index 0000000..239f4e6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/038555bcb4cc2daf764840f79ebce4023bdb7670 differ
diff --git a/fuzzers/corpora/commit_graph/04c159a04b0732e04ac4c59ed3356860af8dffce b/fuzzers/corpora/commit_graph/04c159a04b0732e04ac4c59ed3356860af8dffce
new file mode 100644
index 0000000..856af0f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/04c159a04b0732e04ac4c59ed3356860af8dffce differ
diff --git a/fuzzers/corpora/commit_graph/0560ec993882ffbd8d46dcab0ed430089c4f2aa1 b/fuzzers/corpora/commit_graph/0560ec993882ffbd8d46dcab0ed430089c4f2aa1
new file mode 100644
index 0000000..a236d1a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/0560ec993882ffbd8d46dcab0ed430089c4f2aa1 differ
diff --git a/fuzzers/corpora/commit_graph/059b3aab3fde6b4c9404aff83fed638596f594bb b/fuzzers/corpora/commit_graph/059b3aab3fde6b4c9404aff83fed638596f594bb
new file mode 100644
index 0000000..4900105
Binary files /dev/null and b/fuzzers/corpora/commit_graph/059b3aab3fde6b4c9404aff83fed638596f594bb differ
diff --git a/fuzzers/corpora/commit_graph/06168e726aa0260f520165be4ea0c88244831049 b/fuzzers/corpora/commit_graph/06168e726aa0260f520165be4ea0c88244831049
new file mode 100644
index 0000000..4c9e9df
Binary files /dev/null and b/fuzzers/corpora/commit_graph/06168e726aa0260f520165be4ea0c88244831049 differ
diff --git a/fuzzers/corpora/commit_graph/066d1ec700a526b97009cedd0305b6a47242faba b/fuzzers/corpora/commit_graph/066d1ec700a526b97009cedd0305b6a47242faba
new file mode 100644
index 0000000..f5b1761
Binary files /dev/null and b/fuzzers/corpora/commit_graph/066d1ec700a526b97009cedd0305b6a47242faba differ
diff --git a/fuzzers/corpora/commit_graph/086a5f8cbfa9f058b5c938a6eb724c9e4c5f84f3 b/fuzzers/corpora/commit_graph/086a5f8cbfa9f058b5c938a6eb724c9e4c5f84f3
new file mode 100644
index 0000000..aa9cdca
Binary files /dev/null and b/fuzzers/corpora/commit_graph/086a5f8cbfa9f058b5c938a6eb724c9e4c5f84f3 differ
diff --git a/fuzzers/corpora/commit_graph/089313c698f3e351433e9a45af2ace1d85b9673e b/fuzzers/corpora/commit_graph/089313c698f3e351433e9a45af2ace1d85b9673e
new file mode 100644
index 0000000..14fd3bb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/089313c698f3e351433e9a45af2ace1d85b9673e differ
diff --git a/fuzzers/corpora/commit_graph/092eb973a771fa14cf0b567d65bd2c99130f543e b/fuzzers/corpora/commit_graph/092eb973a771fa14cf0b567d65bd2c99130f543e
new file mode 100644
index 0000000..3092a2b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/092eb973a771fa14cf0b567d65bd2c99130f543e differ
diff --git a/fuzzers/corpora/commit_graph/094b8cd1aa3e40b1f9ff83680892d52e246df0f8 b/fuzzers/corpora/commit_graph/094b8cd1aa3e40b1f9ff83680892d52e246df0f8
new file mode 100644
index 0000000..ed62ec9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/094b8cd1aa3e40b1f9ff83680892d52e246df0f8 differ
diff --git a/fuzzers/corpora/commit_graph/0ce990c9c2ec121b8c78ba2bdf84679e04c0bdae b/fuzzers/corpora/commit_graph/0ce990c9c2ec121b8c78ba2bdf84679e04c0bdae
new file mode 100644
index 0000000..d708b68
Binary files /dev/null and b/fuzzers/corpora/commit_graph/0ce990c9c2ec121b8c78ba2bdf84679e04c0bdae differ
diff --git a/fuzzers/corpora/commit_graph/0dd0770c34fcf6b1f13219450190616d344db021 b/fuzzers/corpora/commit_graph/0dd0770c34fcf6b1f13219450190616d344db021
new file mode 100644
index 0000000..aea94b2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/0dd0770c34fcf6b1f13219450190616d344db021 differ
diff --git a/fuzzers/corpora/commit_graph/0e2b2e6a32733b8a625bc7e812e2ea508d69a5e4 b/fuzzers/corpora/commit_graph/0e2b2e6a32733b8a625bc7e812e2ea508d69a5e4
new file mode 100644
index 0000000..58e8801
Binary files /dev/null and b/fuzzers/corpora/commit_graph/0e2b2e6a32733b8a625bc7e812e2ea508d69a5e4 differ
diff --git a/fuzzers/corpora/commit_graph/0e8d0bd07c543d708aecaca377106492b7a74fa3 b/fuzzers/corpora/commit_graph/0e8d0bd07c543d708aecaca377106492b7a74fa3
new file mode 100644
index 0000000..98a9230
Binary files /dev/null and b/fuzzers/corpora/commit_graph/0e8d0bd07c543d708aecaca377106492b7a74fa3 differ
diff --git a/fuzzers/corpora/commit_graph/0f0d16e1b8c8671dbe1074115c1d86aa9b359e7e b/fuzzers/corpora/commit_graph/0f0d16e1b8c8671dbe1074115c1d86aa9b359e7e
new file mode 100644
index 0000000..bc322de
Binary files /dev/null and b/fuzzers/corpora/commit_graph/0f0d16e1b8c8671dbe1074115c1d86aa9b359e7e differ
diff --git a/fuzzers/corpora/commit_graph/102ef78036de5a30927e7f751377b05441c41a08 b/fuzzers/corpora/commit_graph/102ef78036de5a30927e7f751377b05441c41a08
new file mode 100644
index 0000000..3b14c35
Binary files /dev/null and b/fuzzers/corpora/commit_graph/102ef78036de5a30927e7f751377b05441c41a08 differ
diff --git a/fuzzers/corpora/commit_graph/10494e7cc9cb8dff289c431d7560bcee0d1b14ed b/fuzzers/corpora/commit_graph/10494e7cc9cb8dff289c431d7560bcee0d1b14ed
new file mode 100644
index 0000000..293c49d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/10494e7cc9cb8dff289c431d7560bcee0d1b14ed differ
diff --git a/fuzzers/corpora/commit_graph/107b11d86381345f50aa19b8485477a870ff399f b/fuzzers/corpora/commit_graph/107b11d86381345f50aa19b8485477a870ff399f
new file mode 100644
index 0000000..53bb34e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/107b11d86381345f50aa19b8485477a870ff399f differ
diff --git a/fuzzers/corpora/commit_graph/10bb37e18fb3c0897dabacf9c464b4d324007dc3 b/fuzzers/corpora/commit_graph/10bb37e18fb3c0897dabacf9c464b4d324007dc3
new file mode 100644
index 0000000..e75a9c5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/10bb37e18fb3c0897dabacf9c464b4d324007dc3 differ
diff --git a/fuzzers/corpora/commit_graph/10ee715f64b08549c3e8261204276694728eb841 b/fuzzers/corpora/commit_graph/10ee715f64b08549c3e8261204276694728eb841
new file mode 100644
index 0000000..104eda6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/10ee715f64b08549c3e8261204276694728eb841 differ
diff --git a/fuzzers/corpora/commit_graph/123e4eeb7a731f48d06e336b4d29af717f8b6550 b/fuzzers/corpora/commit_graph/123e4eeb7a731f48d06e336b4d29af717f8b6550
new file mode 100644
index 0000000..22d1482
Binary files /dev/null and b/fuzzers/corpora/commit_graph/123e4eeb7a731f48d06e336b4d29af717f8b6550 differ
diff --git a/fuzzers/corpora/commit_graph/125a228afb923970e0a6d4412f7257ba998594a1 b/fuzzers/corpora/commit_graph/125a228afb923970e0a6d4412f7257ba998594a1
new file mode 100644
index 0000000..3de2c87
Binary files /dev/null and b/fuzzers/corpora/commit_graph/125a228afb923970e0a6d4412f7257ba998594a1 differ
diff --git a/fuzzers/corpora/commit_graph/130d96c16fba06dcbe7e2a661ab959a3274a4bd9 b/fuzzers/corpora/commit_graph/130d96c16fba06dcbe7e2a661ab959a3274a4bd9
new file mode 100644
index 0000000..66a4097
Binary files /dev/null and b/fuzzers/corpora/commit_graph/130d96c16fba06dcbe7e2a661ab959a3274a4bd9 differ
diff --git a/fuzzers/corpora/commit_graph/131c5a2fec55cb0d63f7dc055d6fad5f3dc3c974 b/fuzzers/corpora/commit_graph/131c5a2fec55cb0d63f7dc055d6fad5f3dc3c974
new file mode 100644
index 0000000..b54bfad
Binary files /dev/null and b/fuzzers/corpora/commit_graph/131c5a2fec55cb0d63f7dc055d6fad5f3dc3c974 differ
diff --git a/fuzzers/corpora/commit_graph/13e562d61acb3aa36260a819a00b07ff16450335 b/fuzzers/corpora/commit_graph/13e562d61acb3aa36260a819a00b07ff16450335
new file mode 100644
index 0000000..6682c84
Binary files /dev/null and b/fuzzers/corpora/commit_graph/13e562d61acb3aa36260a819a00b07ff16450335 differ
diff --git a/fuzzers/corpora/commit_graph/1414e6e8ab6bad1b5c51fed807c514a9d6575e66 b/fuzzers/corpora/commit_graph/1414e6e8ab6bad1b5c51fed807c514a9d6575e66
new file mode 100644
index 0000000..c7f2386
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1414e6e8ab6bad1b5c51fed807c514a9d6575e66 differ
diff --git a/fuzzers/corpora/commit_graph/1432d191846ae2d0e381813efcfacff2f1dba0e4 b/fuzzers/corpora/commit_graph/1432d191846ae2d0e381813efcfacff2f1dba0e4
new file mode 100644
index 0000000..cf5b990
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1432d191846ae2d0e381813efcfacff2f1dba0e4 differ
diff --git a/fuzzers/corpora/commit_graph/14a84cdc6f8d432be4cd3d3eafce92ae385e472f b/fuzzers/corpora/commit_graph/14a84cdc6f8d432be4cd3d3eafce92ae385e472f
new file mode 100644
index 0000000..8f86651
Binary files /dev/null and b/fuzzers/corpora/commit_graph/14a84cdc6f8d432be4cd3d3eafce92ae385e472f differ
diff --git a/fuzzers/corpora/commit_graph/14e3e735dba88791f2cadd6e0dc5d662a104a6d7 b/fuzzers/corpora/commit_graph/14e3e735dba88791f2cadd6e0dc5d662a104a6d7
new file mode 100644
index 0000000..32fb993
Binary files /dev/null and b/fuzzers/corpora/commit_graph/14e3e735dba88791f2cadd6e0dc5d662a104a6d7 differ
diff --git a/fuzzers/corpora/commit_graph/1574abb020203103ea629d677edd21c967fc0f4c b/fuzzers/corpora/commit_graph/1574abb020203103ea629d677edd21c967fc0f4c
new file mode 100644
index 0000000..b3da74c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1574abb020203103ea629d677edd21c967fc0f4c differ
diff --git a/fuzzers/corpora/commit_graph/169cc492ba94948a6206765436881a1a0c601780 b/fuzzers/corpora/commit_graph/169cc492ba94948a6206765436881a1a0c601780
new file mode 100644
index 0000000..2ce25f6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/169cc492ba94948a6206765436881a1a0c601780 differ
diff --git a/fuzzers/corpora/commit_graph/16a2130c1d75129f3bae3bf8f2c2de41fb3533c0 b/fuzzers/corpora/commit_graph/16a2130c1d75129f3bae3bf8f2c2de41fb3533c0
new file mode 100644
index 0000000..0b66385
Binary files /dev/null and b/fuzzers/corpora/commit_graph/16a2130c1d75129f3bae3bf8f2c2de41fb3533c0 differ
diff --git a/fuzzers/corpora/commit_graph/16ba602eadfc9a3f74c0845394eda0de42b61571 b/fuzzers/corpora/commit_graph/16ba602eadfc9a3f74c0845394eda0de42b61571
new file mode 100644
index 0000000..c44bd06
Binary files /dev/null and b/fuzzers/corpora/commit_graph/16ba602eadfc9a3f74c0845394eda0de42b61571 differ
diff --git a/fuzzers/corpora/commit_graph/17555fb2dfc444d171ba686667d72e388bd6c041 b/fuzzers/corpora/commit_graph/17555fb2dfc444d171ba686667d72e388bd6c041
new file mode 100644
index 0000000..3d00026
Binary files /dev/null and b/fuzzers/corpora/commit_graph/17555fb2dfc444d171ba686667d72e388bd6c041 differ
diff --git a/fuzzers/corpora/commit_graph/1a10450d99c1e53d9b7f97b8014cb7fc01906ef2 b/fuzzers/corpora/commit_graph/1a10450d99c1e53d9b7f97b8014cb7fc01906ef2
new file mode 100644
index 0000000..f1fec60
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1a10450d99c1e53d9b7f97b8014cb7fc01906ef2 differ
diff --git a/fuzzers/corpora/commit_graph/1af670b5515231fc04b2be9038ee30a7e066b09b b/fuzzers/corpora/commit_graph/1af670b5515231fc04b2be9038ee30a7e066b09b
new file mode 100644
index 0000000..3bf7345
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1af670b5515231fc04b2be9038ee30a7e066b09b differ
diff --git a/fuzzers/corpora/commit_graph/1b72cfa68259e3f3b3802906902a0a29368f86b5 b/fuzzers/corpora/commit_graph/1b72cfa68259e3f3b3802906902a0a29368f86b5
new file mode 100644
index 0000000..e6509d1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1b72cfa68259e3f3b3802906902a0a29368f86b5 differ
diff --git a/fuzzers/corpora/commit_graph/1c62ac5d632aa9e449a4335b675941107d8825ae b/fuzzers/corpora/commit_graph/1c62ac5d632aa9e449a4335b675941107d8825ae
new file mode 100644
index 0000000..10c9e74
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1c62ac5d632aa9e449a4335b675941107d8825ae differ
diff --git a/fuzzers/corpora/commit_graph/1d95b5db2f802011b33d10212a66fbe40827dfd4 b/fuzzers/corpora/commit_graph/1d95b5db2f802011b33d10212a66fbe40827dfd4
new file mode 100644
index 0000000..2353450
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1d95b5db2f802011b33d10212a66fbe40827dfd4 differ
diff --git a/fuzzers/corpora/commit_graph/1e068537ce1211a325aab42ae1263a109131c9f9 b/fuzzers/corpora/commit_graph/1e068537ce1211a325aab42ae1263a109131c9f9
new file mode 100644
index 0000000..0351738
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1e068537ce1211a325aab42ae1263a109131c9f9 differ
diff --git a/fuzzers/corpora/commit_graph/1e9c882c9d33304a5791ef6c98eee65e142bd7fd b/fuzzers/corpora/commit_graph/1e9c882c9d33304a5791ef6c98eee65e142bd7fd
new file mode 100644
index 0000000..d5b9da4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1e9c882c9d33304a5791ef6c98eee65e142bd7fd differ
diff --git a/fuzzers/corpora/commit_graph/1f54935df929403a29e77591c97f767d94871aea b/fuzzers/corpora/commit_graph/1f54935df929403a29e77591c97f767d94871aea
new file mode 100644
index 0000000..6f9b0a0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/1f54935df929403a29e77591c97f767d94871aea differ
diff --git a/fuzzers/corpora/commit_graph/206015659641771bb0d668728c2fdc4209e65dda b/fuzzers/corpora/commit_graph/206015659641771bb0d668728c2fdc4209e65dda
new file mode 100644
index 0000000..086ab64
Binary files /dev/null and b/fuzzers/corpora/commit_graph/206015659641771bb0d668728c2fdc4209e65dda differ
diff --git a/fuzzers/corpora/commit_graph/2096493a2bcc2d15b7ae5bf3112fe49c39976ad8 b/fuzzers/corpora/commit_graph/2096493a2bcc2d15b7ae5bf3112fe49c39976ad8
new file mode 100644
index 0000000..7b33d38
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2096493a2bcc2d15b7ae5bf3112fe49c39976ad8 differ
diff --git a/fuzzers/corpora/commit_graph/209b74e08abe8c787b7c5ba81e51cb69c57ecded b/fuzzers/corpora/commit_graph/209b74e08abe8c787b7c5ba81e51cb69c57ecded
new file mode 100644
index 0000000..55dca76
Binary files /dev/null and b/fuzzers/corpora/commit_graph/209b74e08abe8c787b7c5ba81e51cb69c57ecded differ
diff --git a/fuzzers/corpora/commit_graph/21137876575fbca357fc0c96db1de73c6737e1ae b/fuzzers/corpora/commit_graph/21137876575fbca357fc0c96db1de73c6737e1ae
new file mode 100644
index 0000000..fea1ac1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/21137876575fbca357fc0c96db1de73c6737e1ae differ
diff --git a/fuzzers/corpora/commit_graph/2143d9db9802f076c72a71184cd9d0cb4581e9e7 b/fuzzers/corpora/commit_graph/2143d9db9802f076c72a71184cd9d0cb4581e9e7
new file mode 100644
index 0000000..bacbe88
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2143d9db9802f076c72a71184cd9d0cb4581e9e7 differ
diff --git a/fuzzers/corpora/commit_graph/21a52a5282145407d951ac73c2ff27876783899d b/fuzzers/corpora/commit_graph/21a52a5282145407d951ac73c2ff27876783899d
new file mode 100644
index 0000000..1b5d2f0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/21a52a5282145407d951ac73c2ff27876783899d differ
diff --git a/fuzzers/corpora/commit_graph/21d5c8c8ac3a09bcba5388c472df32795986a5cb b/fuzzers/corpora/commit_graph/21d5c8c8ac3a09bcba5388c472df32795986a5cb
new file mode 100644
index 0000000..b148c6f
--- /dev/null
+++ b/fuzzers/corpora/commit_graph/21d5c8c8ac3a09bcba5388c472df32795986a5cb
@@ -0,0 +1 @@
+ÿúÿ¦
\ No newline at end of file
diff --git a/fuzzers/corpora/commit_graph/22170d1110a1c18009b7feb21a470681f55e85fb b/fuzzers/corpora/commit_graph/22170d1110a1c18009b7feb21a470681f55e85fb
new file mode 100644
index 0000000..6c16354
Binary files /dev/null and b/fuzzers/corpora/commit_graph/22170d1110a1c18009b7feb21a470681f55e85fb differ
diff --git a/fuzzers/corpora/commit_graph/22f55dff94785f24252d7a070f713840f59b0870 b/fuzzers/corpora/commit_graph/22f55dff94785f24252d7a070f713840f59b0870
new file mode 100644
index 0000000..b45c99a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/22f55dff94785f24252d7a070f713840f59b0870 differ
diff --git a/fuzzers/corpora/commit_graph/23d10ee9694e1c66bedc7060990f19a2ac3eaee3 b/fuzzers/corpora/commit_graph/23d10ee9694e1c66bedc7060990f19a2ac3eaee3
new file mode 100644
index 0000000..8790bfd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/23d10ee9694e1c66bedc7060990f19a2ac3eaee3 differ
diff --git a/fuzzers/corpora/commit_graph/2435430ca19502c3b0ec4987508d4a8fbdbc898c b/fuzzers/corpora/commit_graph/2435430ca19502c3b0ec4987508d4a8fbdbc898c
new file mode 100644
index 0000000..e1d58bd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2435430ca19502c3b0ec4987508d4a8fbdbc898c differ
diff --git a/fuzzers/corpora/commit_graph/244d2ea0c5c3117000b599cfab37680ba8f04513 b/fuzzers/corpora/commit_graph/244d2ea0c5c3117000b599cfab37680ba8f04513
new file mode 100644
index 0000000..5eedc85
Binary files /dev/null and b/fuzzers/corpora/commit_graph/244d2ea0c5c3117000b599cfab37680ba8f04513 differ
diff --git a/fuzzers/corpora/commit_graph/248bf94143d150da2459cfdca099c30c6daff00a b/fuzzers/corpora/commit_graph/248bf94143d150da2459cfdca099c30c6daff00a
new file mode 100644
index 0000000..8b5f81b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/248bf94143d150da2459cfdca099c30c6daff00a differ
diff --git a/fuzzers/corpora/commit_graph/25bc53498129bb3717671f00c355d2637a91c86a b/fuzzers/corpora/commit_graph/25bc53498129bb3717671f00c355d2637a91c86a
new file mode 100644
index 0000000..d86bb32
Binary files /dev/null and b/fuzzers/corpora/commit_graph/25bc53498129bb3717671f00c355d2637a91c86a differ
diff --git a/fuzzers/corpora/commit_graph/2614f60da2d7e291501397238366d27513bff773 b/fuzzers/corpora/commit_graph/2614f60da2d7e291501397238366d27513bff773
new file mode 100644
index 0000000..57cd70a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2614f60da2d7e291501397238366d27513bff773 differ
diff --git a/fuzzers/corpora/commit_graph/2651b3d5a8b4616b1faa81dabe27ab2712a27561 b/fuzzers/corpora/commit_graph/2651b3d5a8b4616b1faa81dabe27ab2712a27561
new file mode 100644
index 0000000..5f838de
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2651b3d5a8b4616b1faa81dabe27ab2712a27561 differ
diff --git a/fuzzers/corpora/commit_graph/270257a2872b33dd13c4fd466cbc1ae67d613f9b b/fuzzers/corpora/commit_graph/270257a2872b33dd13c4fd466cbc1ae67d613f9b
new file mode 100644
index 0000000..3090496
Binary files /dev/null and b/fuzzers/corpora/commit_graph/270257a2872b33dd13c4fd466cbc1ae67d613f9b differ
diff --git a/fuzzers/corpora/commit_graph/2830c6244c74656f6c5649c8226953905a582a38 b/fuzzers/corpora/commit_graph/2830c6244c74656f6c5649c8226953905a582a38
new file mode 100644
index 0000000..895a8ef
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2830c6244c74656f6c5649c8226953905a582a38 differ
diff --git a/fuzzers/corpora/commit_graph/2889a85c07c20551ff0b97fc640e3c91b33aa4a1 b/fuzzers/corpora/commit_graph/2889a85c07c20551ff0b97fc640e3c91b33aa4a1
new file mode 100644
index 0000000..349ff15
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2889a85c07c20551ff0b97fc640e3c91b33aa4a1 differ
diff --git a/fuzzers/corpora/commit_graph/295ce43fdd56def8948d1ba2bfa7fdf0c47b5318 b/fuzzers/corpora/commit_graph/295ce43fdd56def8948d1ba2bfa7fdf0c47b5318
new file mode 100644
index 0000000..4a3ce80
Binary files /dev/null and b/fuzzers/corpora/commit_graph/295ce43fdd56def8948d1ba2bfa7fdf0c47b5318 differ
diff --git a/fuzzers/corpora/commit_graph/296cbb94c4e68ab86972a174405308ee34d0c40f b/fuzzers/corpora/commit_graph/296cbb94c4e68ab86972a174405308ee34d0c40f
new file mode 100644
index 0000000..45c218e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/296cbb94c4e68ab86972a174405308ee34d0c40f differ
diff --git a/fuzzers/corpora/commit_graph/2975adf222cad108ec90d8225fd655e30e3bf253 b/fuzzers/corpora/commit_graph/2975adf222cad108ec90d8225fd655e30e3bf253
new file mode 100644
index 0000000..6a16429
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2975adf222cad108ec90d8225fd655e30e3bf253 differ
diff --git a/fuzzers/corpora/commit_graph/29f5d27760c9254ab4db661a6cd0323dd11c34ca b/fuzzers/corpora/commit_graph/29f5d27760c9254ab4db661a6cd0323dd11c34ca
new file mode 100644
index 0000000..a9d81e1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/29f5d27760c9254ab4db661a6cd0323dd11c34ca differ
diff --git a/fuzzers/corpora/commit_graph/2a359fb09eaad968e57d353453908027645873d1 b/fuzzers/corpora/commit_graph/2a359fb09eaad968e57d353453908027645873d1
new file mode 100644
index 0000000..a17910b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2a359fb09eaad968e57d353453908027645873d1 differ
diff --git a/fuzzers/corpora/commit_graph/2a6b65a8d6c28febaa081d220a4433f8366d02bc b/fuzzers/corpora/commit_graph/2a6b65a8d6c28febaa081d220a4433f8366d02bc
new file mode 100644
index 0000000..597f363
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2a6b65a8d6c28febaa081d220a4433f8366d02bc differ
diff --git a/fuzzers/corpora/commit_graph/2b14dcade4d0919b0a17830fe353738015f492a6 b/fuzzers/corpora/commit_graph/2b14dcade4d0919b0a17830fe353738015f492a6
new file mode 100644
index 0000000..33f4e6e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2b14dcade4d0919b0a17830fe353738015f492a6 differ
diff --git a/fuzzers/corpora/commit_graph/2b298a13abbd9829e965424a1486baa13d4166c4 b/fuzzers/corpora/commit_graph/2b298a13abbd9829e965424a1486baa13d4166c4
new file mode 100644
index 0000000..837e45f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2b298a13abbd9829e965424a1486baa13d4166c4 differ
diff --git a/fuzzers/corpora/commit_graph/2b44d8cd8e70e25172b4c740ebe38ef411c965b3 b/fuzzers/corpora/commit_graph/2b44d8cd8e70e25172b4c740ebe38ef411c965b3
new file mode 100644
index 0000000..8059ce4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2b44d8cd8e70e25172b4c740ebe38ef411c965b3 differ
diff --git a/fuzzers/corpora/commit_graph/2b590c4e61fdfcf21c017b29440747a1894b1534 b/fuzzers/corpora/commit_graph/2b590c4e61fdfcf21c017b29440747a1894b1534
new file mode 100644
index 0000000..c3ea729
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2b590c4e61fdfcf21c017b29440747a1894b1534 differ
diff --git a/fuzzers/corpora/commit_graph/2becb18a971ae30e1a8f6680982fd7305708caa0 b/fuzzers/corpora/commit_graph/2becb18a971ae30e1a8f6680982fd7305708caa0
new file mode 100644
index 0000000..4b133a7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2becb18a971ae30e1a8f6680982fd7305708caa0 differ
diff --git a/fuzzers/corpora/commit_graph/2bf78b02099a1fe4ce50d065254e843ca55e280f b/fuzzers/corpora/commit_graph/2bf78b02099a1fe4ce50d065254e843ca55e280f
new file mode 100644
index 0000000..9b459e2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2bf78b02099a1fe4ce50d065254e843ca55e280f differ
diff --git a/fuzzers/corpora/commit_graph/2c1541ecd01aa7b9e99bccfe9804198b3e79f118 b/fuzzers/corpora/commit_graph/2c1541ecd01aa7b9e99bccfe9804198b3e79f118
new file mode 100644
index 0000000..92daa0a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2c1541ecd01aa7b9e99bccfe9804198b3e79f118 differ
diff --git a/fuzzers/corpora/commit_graph/2c6798057af5894c27631ff63e845fe1e4bdc9ee b/fuzzers/corpora/commit_graph/2c6798057af5894c27631ff63e845fe1e4bdc9ee
new file mode 100644
index 0000000..06a7d31
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2c6798057af5894c27631ff63e845fe1e4bdc9ee differ
diff --git a/fuzzers/corpora/commit_graph/2cf7eb7fe489e5acd64df755e820c871784c2ba1 b/fuzzers/corpora/commit_graph/2cf7eb7fe489e5acd64df755e820c871784c2ba1
new file mode 100644
index 0000000..5614c74
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2cf7eb7fe489e5acd64df755e820c871784c2ba1 differ
diff --git a/fuzzers/corpora/commit_graph/2d49ba35ca404baa0d593925f36a81ce53943c8d b/fuzzers/corpora/commit_graph/2d49ba35ca404baa0d593925f36a81ce53943c8d
new file mode 100644
index 0000000..36d6b85
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2d49ba35ca404baa0d593925f36a81ce53943c8d differ
diff --git a/fuzzers/corpora/commit_graph/2d507d42ca43ffc2f3c8892826e1db74144ec096 b/fuzzers/corpora/commit_graph/2d507d42ca43ffc2f3c8892826e1db74144ec096
new file mode 100644
index 0000000..35c28f4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2d507d42ca43ffc2f3c8892826e1db74144ec096 differ
diff --git a/fuzzers/corpora/commit_graph/2e4da693e3e336d2b1a40311a7ccf94def035b6b b/fuzzers/corpora/commit_graph/2e4da693e3e336d2b1a40311a7ccf94def035b6b
new file mode 100644
index 0000000..42727e9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2e4da693e3e336d2b1a40311a7ccf94def035b6b differ
diff --git a/fuzzers/corpora/commit_graph/2e71ff86128b5618f0f067c407a76ff645ae2019 b/fuzzers/corpora/commit_graph/2e71ff86128b5618f0f067c407a76ff645ae2019
new file mode 100644
index 0000000..32f02fc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2e71ff86128b5618f0f067c407a76ff645ae2019 differ
diff --git a/fuzzers/corpora/commit_graph/2eb777c6d7e6ee9bd7a44e37372595043aad596b b/fuzzers/corpora/commit_graph/2eb777c6d7e6ee9bd7a44e37372595043aad596b
new file mode 100644
index 0000000..7203c91
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2eb777c6d7e6ee9bd7a44e37372595043aad596b differ
diff --git a/fuzzers/corpora/commit_graph/2ec3ebffba165b9dd49e755a9e77e23aed796628 b/fuzzers/corpora/commit_graph/2ec3ebffba165b9dd49e755a9e77e23aed796628
new file mode 100644
index 0000000..d4018de
Binary files /dev/null and b/fuzzers/corpora/commit_graph/2ec3ebffba165b9dd49e755a9e77e23aed796628 differ
diff --git a/fuzzers/corpora/commit_graph/302703e3b0d74219868aca39ee7593944c0b2400 b/fuzzers/corpora/commit_graph/302703e3b0d74219868aca39ee7593944c0b2400
new file mode 100644
index 0000000..6b692e1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/302703e3b0d74219868aca39ee7593944c0b2400 differ
diff --git a/fuzzers/corpora/commit_graph/3048c6908dc3176707fa8bcb0196824e3358357a b/fuzzers/corpora/commit_graph/3048c6908dc3176707fa8bcb0196824e3358357a
new file mode 100644
index 0000000..c58805f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3048c6908dc3176707fa8bcb0196824e3358357a differ
diff --git a/fuzzers/corpora/commit_graph/30616cb39d3ad6060324fada03709d611ad28d5c b/fuzzers/corpora/commit_graph/30616cb39d3ad6060324fada03709d611ad28d5c
new file mode 100644
index 0000000..1fd655e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/30616cb39d3ad6060324fada03709d611ad28d5c differ
diff --git a/fuzzers/corpora/commit_graph/306beadd9b3135a00037323760eb5377c88a403e b/fuzzers/corpora/commit_graph/306beadd9b3135a00037323760eb5377c88a403e
new file mode 100644
index 0000000..86c8672
Binary files /dev/null and b/fuzzers/corpora/commit_graph/306beadd9b3135a00037323760eb5377c88a403e differ
diff --git a/fuzzers/corpora/commit_graph/31464a6fbad023923a7e4700fc11564e811bcbd2 b/fuzzers/corpora/commit_graph/31464a6fbad023923a7e4700fc11564e811bcbd2
new file mode 100644
index 0000000..102de5c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/31464a6fbad023923a7e4700fc11564e811bcbd2 differ
diff --git a/fuzzers/corpora/commit_graph/317f4bcfecf066961ef1982d551cd14e63c9f008 b/fuzzers/corpora/commit_graph/317f4bcfecf066961ef1982d551cd14e63c9f008
new file mode 100644
index 0000000..5c2a5d7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/317f4bcfecf066961ef1982d551cd14e63c9f008 differ
diff --git a/fuzzers/corpora/commit_graph/31b2248faaabbec69a06098c8cb0f69c5d0aa208 b/fuzzers/corpora/commit_graph/31b2248faaabbec69a06098c8cb0f69c5d0aa208
new file mode 100644
index 0000000..555c7b1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/31b2248faaabbec69a06098c8cb0f69c5d0aa208 differ
diff --git a/fuzzers/corpora/commit_graph/31d1c3d1147385d58dbe6f82898a5523320fbcac b/fuzzers/corpora/commit_graph/31d1c3d1147385d58dbe6f82898a5523320fbcac
new file mode 100644
index 0000000..1c5ef07
Binary files /dev/null and b/fuzzers/corpora/commit_graph/31d1c3d1147385d58dbe6f82898a5523320fbcac differ
diff --git a/fuzzers/corpora/commit_graph/32c9bc1616a78a230a3724abc02150db1cc40aa0 b/fuzzers/corpora/commit_graph/32c9bc1616a78a230a3724abc02150db1cc40aa0
new file mode 100644
index 0000000..cfc45a1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/32c9bc1616a78a230a3724abc02150db1cc40aa0 differ
diff --git a/fuzzers/corpora/commit_graph/331e2866416b091252f0299e98d32cfb29237029 b/fuzzers/corpora/commit_graph/331e2866416b091252f0299e98d32cfb29237029
new file mode 100644
index 0000000..241e719
Binary files /dev/null and b/fuzzers/corpora/commit_graph/331e2866416b091252f0299e98d32cfb29237029 differ
diff --git a/fuzzers/corpora/commit_graph/331eb3876dd2f3f0bd51f380ac431d86d6e3bb5e b/fuzzers/corpora/commit_graph/331eb3876dd2f3f0bd51f380ac431d86d6e3bb5e
new file mode 100644
index 0000000..a52780f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/331eb3876dd2f3f0bd51f380ac431d86d6e3bb5e differ
diff --git a/fuzzers/corpora/commit_graph/346bd6eaeadeafcb840ff9441614b309330db63e b/fuzzers/corpora/commit_graph/346bd6eaeadeafcb840ff9441614b309330db63e
new file mode 100644
index 0000000..50b7f93
Binary files /dev/null and b/fuzzers/corpora/commit_graph/346bd6eaeadeafcb840ff9441614b309330db63e differ
diff --git a/fuzzers/corpora/commit_graph/349931f447981f21476481448576e805c093a25b b/fuzzers/corpora/commit_graph/349931f447981f21476481448576e805c093a25b
new file mode 100644
index 0000000..ae5b758
Binary files /dev/null and b/fuzzers/corpora/commit_graph/349931f447981f21476481448576e805c093a25b differ
diff --git a/fuzzers/corpora/commit_graph/34a2da1e9adaac1b4be1d40b1ece81fe00643d49 b/fuzzers/corpora/commit_graph/34a2da1e9adaac1b4be1d40b1ece81fe00643d49
new file mode 100644
index 0000000..f5d660f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/34a2da1e9adaac1b4be1d40b1ece81fe00643d49 differ
diff --git a/fuzzers/corpora/commit_graph/34bb8f475e7384a8a39618fd15fdc5fb1b12c1a1 b/fuzzers/corpora/commit_graph/34bb8f475e7384a8a39618fd15fdc5fb1b12c1a1
new file mode 100644
index 0000000..f940f66
Binary files /dev/null and b/fuzzers/corpora/commit_graph/34bb8f475e7384a8a39618fd15fdc5fb1b12c1a1 differ
diff --git a/fuzzers/corpora/commit_graph/351a036c6eb95db9364706b861f7e75ad26194e8 b/fuzzers/corpora/commit_graph/351a036c6eb95db9364706b861f7e75ad26194e8
new file mode 100644
index 0000000..197bee1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/351a036c6eb95db9364706b861f7e75ad26194e8 differ
diff --git a/fuzzers/corpora/commit_graph/355452c1da8e7689d816d67cdde040b5df7eabd7 b/fuzzers/corpora/commit_graph/355452c1da8e7689d816d67cdde040b5df7eabd7
new file mode 100644
index 0000000..f135872
Binary files /dev/null and b/fuzzers/corpora/commit_graph/355452c1da8e7689d816d67cdde040b5df7eabd7 differ
diff --git a/fuzzers/corpora/commit_graph/35c157ad2b100b4f334cddcf3dea6ef2d85462be b/fuzzers/corpora/commit_graph/35c157ad2b100b4f334cddcf3dea6ef2d85462be
new file mode 100644
index 0000000..7d73ba7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/35c157ad2b100b4f334cddcf3dea6ef2d85462be differ
diff --git a/fuzzers/corpora/commit_graph/36a81a45eabfcf53e1ae0361aa234791e2fdb750 b/fuzzers/corpora/commit_graph/36a81a45eabfcf53e1ae0361aa234791e2fdb750
new file mode 100644
index 0000000..fc1b8dd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/36a81a45eabfcf53e1ae0361aa234791e2fdb750 differ
diff --git a/fuzzers/corpora/commit_graph/36ee20f6dbeb3a34e91eafbbe2e379f9ac6cfa43 b/fuzzers/corpora/commit_graph/36ee20f6dbeb3a34e91eafbbe2e379f9ac6cfa43
new file mode 100644
index 0000000..769017a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/36ee20f6dbeb3a34e91eafbbe2e379f9ac6cfa43 differ
diff --git a/fuzzers/corpora/commit_graph/377627c19bcac6adc880202048a9eac07b5417d4 b/fuzzers/corpora/commit_graph/377627c19bcac6adc880202048a9eac07b5417d4
new file mode 100644
index 0000000..d4ef66b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/377627c19bcac6adc880202048a9eac07b5417d4 differ
diff --git a/fuzzers/corpora/commit_graph/38747e7c8bec2f9c923739d50ba54ff88ba6503f b/fuzzers/corpora/commit_graph/38747e7c8bec2f9c923739d50ba54ff88ba6503f
new file mode 100644
index 0000000..6d94b57
Binary files /dev/null and b/fuzzers/corpora/commit_graph/38747e7c8bec2f9c923739d50ba54ff88ba6503f differ
diff --git a/fuzzers/corpora/commit_graph/3945843a6fab2ec71030f09b237c125b97cd3ea5 b/fuzzers/corpora/commit_graph/3945843a6fab2ec71030f09b237c125b97cd3ea5
new file mode 100644
index 0000000..76191ca
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3945843a6fab2ec71030f09b237c125b97cd3ea5 differ
diff --git a/fuzzers/corpora/commit_graph/396321d39b82ffaccbc64115117df7e822b0f515 b/fuzzers/corpora/commit_graph/396321d39b82ffaccbc64115117df7e822b0f515
new file mode 100644
index 0000000..74715a9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/396321d39b82ffaccbc64115117df7e822b0f515 differ
diff --git a/fuzzers/corpora/commit_graph/396e78eb9b54e2cefb52cd76a22137c8abd6cbcf b/fuzzers/corpora/commit_graph/396e78eb9b54e2cefb52cd76a22137c8abd6cbcf
new file mode 100644
index 0000000..b5648c4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/396e78eb9b54e2cefb52cd76a22137c8abd6cbcf differ
diff --git a/fuzzers/corpora/commit_graph/39c1ab66035adc104cd06a6d98b77668172d21af b/fuzzers/corpora/commit_graph/39c1ab66035adc104cd06a6d98b77668172d21af
new file mode 100644
index 0000000..f9649f7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/39c1ab66035adc104cd06a6d98b77668172d21af differ
diff --git a/fuzzers/corpora/commit_graph/3a1078c35f5401ce09b5ba921fc348dde37530bb b/fuzzers/corpora/commit_graph/3a1078c35f5401ce09b5ba921fc348dde37530bb
new file mode 100644
index 0000000..7e519f8
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3a1078c35f5401ce09b5ba921fc348dde37530bb differ
diff --git a/fuzzers/corpora/commit_graph/3aa3d8f40392d1c863d23799b8ec0aedc7191302 b/fuzzers/corpora/commit_graph/3aa3d8f40392d1c863d23799b8ec0aedc7191302
new file mode 100644
index 0000000..3cbeaaf
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3aa3d8f40392d1c863d23799b8ec0aedc7191302 differ
diff --git a/fuzzers/corpora/commit_graph/3b08c505601271cb92345ec7f0ff0b28daf90a9c b/fuzzers/corpora/commit_graph/3b08c505601271cb92345ec7f0ff0b28daf90a9c
new file mode 100644
index 0000000..69b9bab
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3b08c505601271cb92345ec7f0ff0b28daf90a9c differ
diff --git a/fuzzers/corpora/commit_graph/3b41702587be45f678b36823ad2f7e5002337dc4 b/fuzzers/corpora/commit_graph/3b41702587be45f678b36823ad2f7e5002337dc4
new file mode 100644
index 0000000..29069ab
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3b41702587be45f678b36823ad2f7e5002337dc4 differ
diff --git a/fuzzers/corpora/commit_graph/3b69108cc919aba0248f9b864d4e71c5f6d1931e b/fuzzers/corpora/commit_graph/3b69108cc919aba0248f9b864d4e71c5f6d1931e
new file mode 100644
index 0000000..207df24
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3b69108cc919aba0248f9b864d4e71c5f6d1931e differ
diff --git a/fuzzers/corpora/commit_graph/3b90507501bb3bcfe0094f9c92cc2869f1a7dda5 b/fuzzers/corpora/commit_graph/3b90507501bb3bcfe0094f9c92cc2869f1a7dda5
new file mode 100644
index 0000000..5727232
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3b90507501bb3bcfe0094f9c92cc2869f1a7dda5 differ
diff --git a/fuzzers/corpora/commit_graph/3bc7fe44c3a1464dd35a4d22b482f46cdeda0405 b/fuzzers/corpora/commit_graph/3bc7fe44c3a1464dd35a4d22b482f46cdeda0405
new file mode 100644
index 0000000..e1a8bd3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3bc7fe44c3a1464dd35a4d22b482f46cdeda0405 differ
diff --git a/fuzzers/corpora/commit_graph/3ce99994986efb6df3f3568423e0077b53c7ef78 b/fuzzers/corpora/commit_graph/3ce99994986efb6df3f3568423e0077b53c7ef78
new file mode 100644
index 0000000..21f9ab8
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3ce99994986efb6df3f3568423e0077b53c7ef78 differ
diff --git a/fuzzers/corpora/commit_graph/3d6cb3ba21181c9f0ab08b2608eab773f36773f2 b/fuzzers/corpora/commit_graph/3d6cb3ba21181c9f0ab08b2608eab773f36773f2
new file mode 100644
index 0000000..548a129
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3d6cb3ba21181c9f0ab08b2608eab773f36773f2 differ
diff --git a/fuzzers/corpora/commit_graph/3d8ec41450b943d5dea73fb1e393960b03d7c3b9 b/fuzzers/corpora/commit_graph/3d8ec41450b943d5dea73fb1e393960b03d7c3b9
new file mode 100644
index 0000000..150ed2c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3d8ec41450b943d5dea73fb1e393960b03d7c3b9 differ
diff --git a/fuzzers/corpora/commit_graph/3e29e8baaac0f6c7e4cf3d5adca2ab3a2c491ac7 b/fuzzers/corpora/commit_graph/3e29e8baaac0f6c7e4cf3d5adca2ab3a2c491ac7
new file mode 100644
index 0000000..bc9597d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3e29e8baaac0f6c7e4cf3d5adca2ab3a2c491ac7 differ
diff --git a/fuzzers/corpora/commit_graph/3e9469b3c68ba334671aacda7a7669b0e97b74d6 b/fuzzers/corpora/commit_graph/3e9469b3c68ba334671aacda7a7669b0e97b74d6
new file mode 100644
index 0000000..cb20df0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3e9469b3c68ba334671aacda7a7669b0e97b74d6 differ
diff --git a/fuzzers/corpora/commit_graph/3eeda3bfa7abef69911c94520c009a08c49b9942 b/fuzzers/corpora/commit_graph/3eeda3bfa7abef69911c94520c009a08c49b9942
new file mode 100644
index 0000000..dbf559f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3eeda3bfa7abef69911c94520c009a08c49b9942 differ
diff --git a/fuzzers/corpora/commit_graph/3f0f5021016451b57f673d0603cd9e4830c2198d b/fuzzers/corpora/commit_graph/3f0f5021016451b57f673d0603cd9e4830c2198d
new file mode 100644
index 0000000..2f4c523
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3f0f5021016451b57f673d0603cd9e4830c2198d differ
diff --git a/fuzzers/corpora/commit_graph/3f46540fbd94bf0337c1d0d7437ec992a3568f09 b/fuzzers/corpora/commit_graph/3f46540fbd94bf0337c1d0d7437ec992a3568f09
new file mode 100644
index 0000000..7fbf350
Binary files /dev/null and b/fuzzers/corpora/commit_graph/3f46540fbd94bf0337c1d0d7437ec992a3568f09 differ
diff --git a/fuzzers/corpora/commit_graph/402d9c25d5833d42630882ab5c57833266bef785 b/fuzzers/corpora/commit_graph/402d9c25d5833d42630882ab5c57833266bef785
new file mode 100644
index 0000000..6600281
Binary files /dev/null and b/fuzzers/corpora/commit_graph/402d9c25d5833d42630882ab5c57833266bef785 differ
diff --git a/fuzzers/corpora/commit_graph/4048bb3c26d67c345630ff9e86db551a3add6549 b/fuzzers/corpora/commit_graph/4048bb3c26d67c345630ff9e86db551a3add6549
new file mode 100644
index 0000000..a07e195
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4048bb3c26d67c345630ff9e86db551a3add6549 differ
diff --git a/fuzzers/corpora/commit_graph/40792f23c1281842dab671e8b213fc408d1ec39f b/fuzzers/corpora/commit_graph/40792f23c1281842dab671e8b213fc408d1ec39f
new file mode 100644
index 0000000..9a0f9c2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/40792f23c1281842dab671e8b213fc408d1ec39f differ
diff --git a/fuzzers/corpora/commit_graph/41cd0b5d9a9540947b7b1841a55e4c11bd4346a2 b/fuzzers/corpora/commit_graph/41cd0b5d9a9540947b7b1841a55e4c11bd4346a2
new file mode 100644
index 0000000..a1b3a07
Binary files /dev/null and b/fuzzers/corpora/commit_graph/41cd0b5d9a9540947b7b1841a55e4c11bd4346a2 differ
diff --git a/fuzzers/corpora/commit_graph/41d86e5ea3df4a0de60d42aeb16e2a5599aedeae b/fuzzers/corpora/commit_graph/41d86e5ea3df4a0de60d42aeb16e2a5599aedeae
new file mode 100644
index 0000000..d749cf6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/41d86e5ea3df4a0de60d42aeb16e2a5599aedeae differ
diff --git a/fuzzers/corpora/commit_graph/42b4e5430b2b1b17a361067fb9dd33ab74e52232 b/fuzzers/corpora/commit_graph/42b4e5430b2b1b17a361067fb9dd33ab74e52232
new file mode 100644
index 0000000..6adf001
Binary files /dev/null and b/fuzzers/corpora/commit_graph/42b4e5430b2b1b17a361067fb9dd33ab74e52232 differ
diff --git a/fuzzers/corpora/commit_graph/42ef1c9d234b90acaf1651d930fc52d5f8f158f2 b/fuzzers/corpora/commit_graph/42ef1c9d234b90acaf1651d930fc52d5f8f158f2
new file mode 100644
index 0000000..0514ae8
Binary files /dev/null and b/fuzzers/corpora/commit_graph/42ef1c9d234b90acaf1651d930fc52d5f8f158f2 differ
diff --git a/fuzzers/corpora/commit_graph/4570c8ff26d7f31afe73b3d9a35a29bc1274d68a b/fuzzers/corpora/commit_graph/4570c8ff26d7f31afe73b3d9a35a29bc1274d68a
new file mode 100644
index 0000000..834d62b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4570c8ff26d7f31afe73b3d9a35a29bc1274d68a differ
diff --git a/fuzzers/corpora/commit_graph/45cf4751a5929930a7c30ec10134434b9ee13c3d b/fuzzers/corpora/commit_graph/45cf4751a5929930a7c30ec10134434b9ee13c3d
new file mode 100644
index 0000000..b761279
Binary files /dev/null and b/fuzzers/corpora/commit_graph/45cf4751a5929930a7c30ec10134434b9ee13c3d differ
diff --git a/fuzzers/corpora/commit_graph/46e9d351dd5bb71f7d4d8f15b3fad312c781452e b/fuzzers/corpora/commit_graph/46e9d351dd5bb71f7d4d8f15b3fad312c781452e
new file mode 100644
index 0000000..ce26235
Binary files /dev/null and b/fuzzers/corpora/commit_graph/46e9d351dd5bb71f7d4d8f15b3fad312c781452e differ
diff --git a/fuzzers/corpora/commit_graph/472421633b984556b96bc20f1fcf7a98c25736f3 b/fuzzers/corpora/commit_graph/472421633b984556b96bc20f1fcf7a98c25736f3
new file mode 100644
index 0000000..4a2faa1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/472421633b984556b96bc20f1fcf7a98c25736f3 differ
diff --git a/fuzzers/corpora/commit_graph/47f35b91699caee098cacdde0161ffab21bdfc57 b/fuzzers/corpora/commit_graph/47f35b91699caee098cacdde0161ffab21bdfc57
new file mode 100644
index 0000000..a0f24ef
Binary files /dev/null and b/fuzzers/corpora/commit_graph/47f35b91699caee098cacdde0161ffab21bdfc57 differ
diff --git a/fuzzers/corpora/commit_graph/48b9da327218f9409287687a43b7eead4789a588 b/fuzzers/corpora/commit_graph/48b9da327218f9409287687a43b7eead4789a588
new file mode 100644
index 0000000..c6f2b79
Binary files /dev/null and b/fuzzers/corpora/commit_graph/48b9da327218f9409287687a43b7eead4789a588 differ
diff --git a/fuzzers/corpora/commit_graph/48d14fca326d5d591d18d34c2821a457277819a2 b/fuzzers/corpora/commit_graph/48d14fca326d5d591d18d34c2821a457277819a2
new file mode 100644
index 0000000..d223341
Binary files /dev/null and b/fuzzers/corpora/commit_graph/48d14fca326d5d591d18d34c2821a457277819a2 differ
diff --git a/fuzzers/corpora/commit_graph/48f3a33e2a027f5735d0a333ec4acd5a2aa57118 b/fuzzers/corpora/commit_graph/48f3a33e2a027f5735d0a333ec4acd5a2aa57118
new file mode 100644
index 0000000..0604edb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/48f3a33e2a027f5735d0a333ec4acd5a2aa57118 differ
diff --git a/fuzzers/corpora/commit_graph/49e0eee24eab094a9c62f6b37b6ba01f8aece4e4 b/fuzzers/corpora/commit_graph/49e0eee24eab094a9c62f6b37b6ba01f8aece4e4
new file mode 100644
index 0000000..78f9425
Binary files /dev/null and b/fuzzers/corpora/commit_graph/49e0eee24eab094a9c62f6b37b6ba01f8aece4e4 differ
diff --git a/fuzzers/corpora/commit_graph/4b45bcb707d2a0bc23b415e9bc3d7eb1f7f0e188 b/fuzzers/corpora/commit_graph/4b45bcb707d2a0bc23b415e9bc3d7eb1f7f0e188
new file mode 100644
index 0000000..3a1fdd7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4b45bcb707d2a0bc23b415e9bc3d7eb1f7f0e188 differ
diff --git a/fuzzers/corpora/commit_graph/4c428300fe4866fe81cff02ad4bc14b6848f7f73 b/fuzzers/corpora/commit_graph/4c428300fe4866fe81cff02ad4bc14b6848f7f73
new file mode 100644
index 0000000..d7f09e3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4c428300fe4866fe81cff02ad4bc14b6848f7f73 differ
diff --git a/fuzzers/corpora/commit_graph/4d69c567df2e858c5f248b3fc8e4a9c04f02481c b/fuzzers/corpora/commit_graph/4d69c567df2e858c5f248b3fc8e4a9c04f02481c
new file mode 100644
index 0000000..26ba525
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4d69c567df2e858c5f248b3fc8e4a9c04f02481c differ
diff --git a/fuzzers/corpora/commit_graph/4d88b6c9b513d5db2e07313a39b43d112d3d4562 b/fuzzers/corpora/commit_graph/4d88b6c9b513d5db2e07313a39b43d112d3d4562
new file mode 100644
index 0000000..bfe64c9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4d88b6c9b513d5db2e07313a39b43d112d3d4562 differ
diff --git a/fuzzers/corpora/commit_graph/4da73370cf854ef8bd08c7f79b92a187cdbff278 b/fuzzers/corpora/commit_graph/4da73370cf854ef8bd08c7f79b92a187cdbff278
new file mode 100644
index 0000000..da1801e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4da73370cf854ef8bd08c7f79b92a187cdbff278 differ
diff --git a/fuzzers/corpora/commit_graph/4e4b2827351bbfd414b718052a8f950a9e3eb7ee b/fuzzers/corpora/commit_graph/4e4b2827351bbfd414b718052a8f950a9e3eb7ee
new file mode 100644
index 0000000..77d2e78
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4e4b2827351bbfd414b718052a8f950a9e3eb7ee differ
diff --git a/fuzzers/corpora/commit_graph/4ed43f7d3c0305461edcbc86f62e0c6ad56df01e b/fuzzers/corpora/commit_graph/4ed43f7d3c0305461edcbc86f62e0c6ad56df01e
new file mode 100644
index 0000000..cfef7a1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4ed43f7d3c0305461edcbc86f62e0c6ad56df01e differ
diff --git a/fuzzers/corpora/commit_graph/4f011529809e88205421fa8ce39dcc025293bcb8 b/fuzzers/corpora/commit_graph/4f011529809e88205421fa8ce39dcc025293bcb8
new file mode 100644
index 0000000..2331acf
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4f011529809e88205421fa8ce39dcc025293bcb8 differ
diff --git a/fuzzers/corpora/commit_graph/4f1928b6376369ab6acf8a282284366cc3bf71ef b/fuzzers/corpora/commit_graph/4f1928b6376369ab6acf8a282284366cc3bf71ef
new file mode 100644
index 0000000..ad3d173
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4f1928b6376369ab6acf8a282284366cc3bf71ef differ
diff --git a/fuzzers/corpora/commit_graph/4f669eca3416c44f0d003ef2720d03e697e2230e b/fuzzers/corpora/commit_graph/4f669eca3416c44f0d003ef2720d03e697e2230e
new file mode 100644
index 0000000..6a143b3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4f669eca3416c44f0d003ef2720d03e697e2230e differ
diff --git a/fuzzers/corpora/commit_graph/4f750f24ecb5080bea2845061cfd3ce4529d30ee b/fuzzers/corpora/commit_graph/4f750f24ecb5080bea2845061cfd3ce4529d30ee
new file mode 100644
index 0000000..ea36bdc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4f750f24ecb5080bea2845061cfd3ce4529d30ee differ
diff --git a/fuzzers/corpora/commit_graph/4fab9bb2bacf562e65f4a8681c429e6ea92aaed7 b/fuzzers/corpora/commit_graph/4fab9bb2bacf562e65f4a8681c429e6ea92aaed7
new file mode 100644
index 0000000..d00a794
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4fab9bb2bacf562e65f4a8681c429e6ea92aaed7 differ
diff --git a/fuzzers/corpora/commit_graph/4fd757c7251c17413b3005fb38aee0fd029d89ec b/fuzzers/corpora/commit_graph/4fd757c7251c17413b3005fb38aee0fd029d89ec
new file mode 100644
index 0000000..4f4db7d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/4fd757c7251c17413b3005fb38aee0fd029d89ec differ
diff --git a/fuzzers/corpora/commit_graph/506092de91dcf93254cdd5ad9e02a953a38099ea b/fuzzers/corpora/commit_graph/506092de91dcf93254cdd5ad9e02a953a38099ea
new file mode 100644
index 0000000..64c5405
Binary files /dev/null and b/fuzzers/corpora/commit_graph/506092de91dcf93254cdd5ad9e02a953a38099ea differ
diff --git a/fuzzers/corpora/commit_graph/50e934fb52d9bc5cd2a531adced1cad7f102a112 b/fuzzers/corpora/commit_graph/50e934fb52d9bc5cd2a531adced1cad7f102a112
new file mode 100644
index 0000000..b630179
Binary files /dev/null and b/fuzzers/corpora/commit_graph/50e934fb52d9bc5cd2a531adced1cad7f102a112 differ
diff --git a/fuzzers/corpora/commit_graph/512e49a9e789656964988950009e6534907e6317 b/fuzzers/corpora/commit_graph/512e49a9e789656964988950009e6534907e6317
new file mode 100644
index 0000000..7cf8e31
Binary files /dev/null and b/fuzzers/corpora/commit_graph/512e49a9e789656964988950009e6534907e6317 differ
diff --git a/fuzzers/corpora/commit_graph/51404149f1ea30ee6959fafe81a52acabed97e9e b/fuzzers/corpora/commit_graph/51404149f1ea30ee6959fafe81a52acabed97e9e
new file mode 100644
index 0000000..394e4bf
Binary files /dev/null and b/fuzzers/corpora/commit_graph/51404149f1ea30ee6959fafe81a52acabed97e9e differ
diff --git a/fuzzers/corpora/commit_graph/5150f8a67399ee16178a2b08198cf91a90c0e53e b/fuzzers/corpora/commit_graph/5150f8a67399ee16178a2b08198cf91a90c0e53e
new file mode 100644
index 0000000..c0867a0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5150f8a67399ee16178a2b08198cf91a90c0e53e differ
diff --git a/fuzzers/corpora/commit_graph/51a1fd23dfe5a8062cd4601d235509247f3bc2dc b/fuzzers/corpora/commit_graph/51a1fd23dfe5a8062cd4601d235509247f3bc2dc
new file mode 100644
index 0000000..c448928
Binary files /dev/null and b/fuzzers/corpora/commit_graph/51a1fd23dfe5a8062cd4601d235509247f3bc2dc differ
diff --git a/fuzzers/corpora/commit_graph/51a963486f041a60c422f0dd6da3b69c52f12fb7 b/fuzzers/corpora/commit_graph/51a963486f041a60c422f0dd6da3b69c52f12fb7
new file mode 100644
index 0000000..f8a1c56
Binary files /dev/null and b/fuzzers/corpora/commit_graph/51a963486f041a60c422f0dd6da3b69c52f12fb7 differ
diff --git a/fuzzers/corpora/commit_graph/51fbf57a2a35ec33164838fa254fe605a3c868e9 b/fuzzers/corpora/commit_graph/51fbf57a2a35ec33164838fa254fe605a3c868e9
new file mode 100644
index 0000000..d0c77cd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/51fbf57a2a35ec33164838fa254fe605a3c868e9 differ
diff --git a/fuzzers/corpora/commit_graph/53068b9f9cb54bb52d076e9602ccd55f169ef39a b/fuzzers/corpora/commit_graph/53068b9f9cb54bb52d076e9602ccd55f169ef39a
new file mode 100644
index 0000000..bed0af6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/53068b9f9cb54bb52d076e9602ccd55f169ef39a differ
diff --git a/fuzzers/corpora/commit_graph/5314619e15fa5ee67df44481b8213a53786d39c5 b/fuzzers/corpora/commit_graph/5314619e15fa5ee67df44481b8213a53786d39c5
new file mode 100644
index 0000000..a00e14d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5314619e15fa5ee67df44481b8213a53786d39c5 differ
diff --git a/fuzzers/corpora/commit_graph/533f5f00275968129846522fe01e2819746272eb b/fuzzers/corpora/commit_graph/533f5f00275968129846522fe01e2819746272eb
new file mode 100644
index 0000000..0830b01
Binary files /dev/null and b/fuzzers/corpora/commit_graph/533f5f00275968129846522fe01e2819746272eb differ
diff --git a/fuzzers/corpora/commit_graph/53a62799135c282435a17e032deda03eaf9daf0f b/fuzzers/corpora/commit_graph/53a62799135c282435a17e032deda03eaf9daf0f
new file mode 100644
index 0000000..f6bfddb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/53a62799135c282435a17e032deda03eaf9daf0f differ
diff --git a/fuzzers/corpora/commit_graph/53c9d5cd849977e523d92dd2d639e9b0e721be50 b/fuzzers/corpora/commit_graph/53c9d5cd849977e523d92dd2d639e9b0e721be50
new file mode 100644
index 0000000..ed30c5e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/53c9d5cd849977e523d92dd2d639e9b0e721be50 differ
diff --git a/fuzzers/corpora/commit_graph/54767a0bb3b96d39f5b2004ce3f274465f1a927e b/fuzzers/corpora/commit_graph/54767a0bb3b96d39f5b2004ce3f274465f1a927e
new file mode 100644
index 0000000..fd9a0ac
Binary files /dev/null and b/fuzzers/corpora/commit_graph/54767a0bb3b96d39f5b2004ce3f274465f1a927e differ
diff --git a/fuzzers/corpora/commit_graph/548de37dbe6a3829b73d976996ec9838cf608554 b/fuzzers/corpora/commit_graph/548de37dbe6a3829b73d976996ec9838cf608554
new file mode 100644
index 0000000..89772e2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/548de37dbe6a3829b73d976996ec9838cf608554 differ
diff --git a/fuzzers/corpora/commit_graph/5522cefa54b798ea4aba8ef2a42ad248a7fb02ee b/fuzzers/corpora/commit_graph/5522cefa54b798ea4aba8ef2a42ad248a7fb02ee
new file mode 100644
index 0000000..6a4da78
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5522cefa54b798ea4aba8ef2a42ad248a7fb02ee differ
diff --git a/fuzzers/corpora/commit_graph/554fab3eef5d8709f06d1d4319efe5c0c437421b b/fuzzers/corpora/commit_graph/554fab3eef5d8709f06d1d4319efe5c0c437421b
new file mode 100644
index 0000000..7a54bd0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/554fab3eef5d8709f06d1d4319efe5c0c437421b differ
diff --git a/fuzzers/corpora/commit_graph/567fe73919dae39b0bcb78b03d655643a71714a8 b/fuzzers/corpora/commit_graph/567fe73919dae39b0bcb78b03d655643a71714a8
new file mode 100644
index 0000000..56b1e14
Binary files /dev/null and b/fuzzers/corpora/commit_graph/567fe73919dae39b0bcb78b03d655643a71714a8 differ
diff --git a/fuzzers/corpora/commit_graph/5717a281aa722ee4a32dfa1cc72fc5d6081f6755 b/fuzzers/corpora/commit_graph/5717a281aa722ee4a32dfa1cc72fc5d6081f6755
new file mode 100644
index 0000000..77f0e51
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5717a281aa722ee4a32dfa1cc72fc5d6081f6755 differ
diff --git a/fuzzers/corpora/commit_graph/577d814e0be43df9321c5b27119c398bd00a00c5 b/fuzzers/corpora/commit_graph/577d814e0be43df9321c5b27119c398bd00a00c5
new file mode 100644
index 0000000..c892728
Binary files /dev/null and b/fuzzers/corpora/commit_graph/577d814e0be43df9321c5b27119c398bd00a00c5 differ
diff --git a/fuzzers/corpora/commit_graph/58680611707c6188f9f067f8747b699cd2fe82d3 b/fuzzers/corpora/commit_graph/58680611707c6188f9f067f8747b699cd2fe82d3
new file mode 100644
index 0000000..81efaf3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/58680611707c6188f9f067f8747b699cd2fe82d3 differ
diff --git a/fuzzers/corpora/commit_graph/5915b7f91dd43ec37a4718061c90cbec2686b916 b/fuzzers/corpora/commit_graph/5915b7f91dd43ec37a4718061c90cbec2686b916
new file mode 100644
index 0000000..f22d2aa
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5915b7f91dd43ec37a4718061c90cbec2686b916 differ
diff --git a/fuzzers/corpora/commit_graph/599516e368ff621dd06d8450837350f4e9558c38 b/fuzzers/corpora/commit_graph/599516e368ff621dd06d8450837350f4e9558c38
new file mode 100644
index 0000000..6aff8ee
Binary files /dev/null and b/fuzzers/corpora/commit_graph/599516e368ff621dd06d8450837350f4e9558c38 differ
diff --git a/fuzzers/corpora/commit_graph/5a2d01d141e4d523e718c30e20cb07c3ad98f33d b/fuzzers/corpora/commit_graph/5a2d01d141e4d523e718c30e20cb07c3ad98f33d
new file mode 100644
index 0000000..fb20c58
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5a2d01d141e4d523e718c30e20cb07c3ad98f33d differ
diff --git a/fuzzers/corpora/commit_graph/5a9803ef8cd88d1e8f1d6e5920b8afd170cafb11 b/fuzzers/corpora/commit_graph/5a9803ef8cd88d1e8f1d6e5920b8afd170cafb11
new file mode 100644
index 0000000..38c2c08
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5a9803ef8cd88d1e8f1d6e5920b8afd170cafb11 differ
diff --git a/fuzzers/corpora/commit_graph/5ba93c9db0cff93f52b521d7420e43f6eda2784f b/fuzzers/corpora/commit_graph/5ba93c9db0cff93f52b521d7420e43f6eda2784f
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5ba93c9db0cff93f52b521d7420e43f6eda2784f differ
diff --git a/fuzzers/corpora/commit_graph/5bf0ca772092e6fa34b6822f61a1b1c3d7f2c6e3 b/fuzzers/corpora/commit_graph/5bf0ca772092e6fa34b6822f61a1b1c3d7f2c6e3
new file mode 100644
index 0000000..06dd1e1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5bf0ca772092e6fa34b6822f61a1b1c3d7f2c6e3 differ
diff --git a/fuzzers/corpora/commit_graph/5cfbfb3e12b629dc9f74baf0a8741345ec288795 b/fuzzers/corpora/commit_graph/5cfbfb3e12b629dc9f74baf0a8741345ec288795
new file mode 100644
index 0000000..73e257d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5cfbfb3e12b629dc9f74baf0a8741345ec288795 differ
diff --git a/fuzzers/corpora/commit_graph/5d8cc97b739c39820b761b6551d34dd647da6816 b/fuzzers/corpora/commit_graph/5d8cc97b739c39820b761b6551d34dd647da6816
new file mode 100644
index 0000000..7a241f3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5d8cc97b739c39820b761b6551d34dd647da6816 differ
diff --git a/fuzzers/corpora/commit_graph/5dcbb3e1c2fc9a191dd3f3443b86f6bc38c39e37 b/fuzzers/corpora/commit_graph/5dcbb3e1c2fc9a191dd3f3443b86f6bc38c39e37
new file mode 100644
index 0000000..04a1639
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5dcbb3e1c2fc9a191dd3f3443b86f6bc38c39e37 differ
diff --git a/fuzzers/corpora/commit_graph/5ec17d081aef9872f746e88ad8b03553719f9c36 b/fuzzers/corpora/commit_graph/5ec17d081aef9872f746e88ad8b03553719f9c36
new file mode 100644
index 0000000..84fa131
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5ec17d081aef9872f746e88ad8b03553719f9c36 differ
diff --git a/fuzzers/corpora/commit_graph/5f88e3ba60c11be25c47a842763d8870d23cc7f2 b/fuzzers/corpora/commit_graph/5f88e3ba60c11be25c47a842763d8870d23cc7f2
new file mode 100644
index 0000000..3669387
Binary files /dev/null and b/fuzzers/corpora/commit_graph/5f88e3ba60c11be25c47a842763d8870d23cc7f2 differ
diff --git a/fuzzers/corpora/commit_graph/6045e4d2bf85013c78a32e71b014ba3d4a4b7c61 b/fuzzers/corpora/commit_graph/6045e4d2bf85013c78a32e71b014ba3d4a4b7c61
new file mode 100644
index 0000000..5ebec5a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6045e4d2bf85013c78a32e71b014ba3d4a4b7c61 differ
diff --git a/fuzzers/corpora/commit_graph/615c7ba7ffbce955ffd964682e2a0f7ef3c767e4 b/fuzzers/corpora/commit_graph/615c7ba7ffbce955ffd964682e2a0f7ef3c767e4
new file mode 100644
index 0000000..8360672
Binary files /dev/null and b/fuzzers/corpora/commit_graph/615c7ba7ffbce955ffd964682e2a0f7ef3c767e4 differ
diff --git a/fuzzers/corpora/commit_graph/6189f29cbbe88ac6cb32fdefecda1bd6194332a6 b/fuzzers/corpora/commit_graph/6189f29cbbe88ac6cb32fdefecda1bd6194332a6
new file mode 100644
index 0000000..40ec5b1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6189f29cbbe88ac6cb32fdefecda1bd6194332a6 differ
diff --git a/fuzzers/corpora/commit_graph/627224cb8484c62992dcbc4cdebdbfa48a3c021a b/fuzzers/corpora/commit_graph/627224cb8484c62992dcbc4cdebdbfa48a3c021a
new file mode 100644
index 0000000..f73b59d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/627224cb8484c62992dcbc4cdebdbfa48a3c021a differ
diff --git a/fuzzers/corpora/commit_graph/629fff0962d298a7283a3d1e1d1b940dfef9b315 b/fuzzers/corpora/commit_graph/629fff0962d298a7283a3d1e1d1b940dfef9b315
new file mode 100644
index 0000000..1c0c2c4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/629fff0962d298a7283a3d1e1d1b940dfef9b315 differ
diff --git a/fuzzers/corpora/commit_graph/6322594cff2a99d0abb1139e6a43b06df76d539a b/fuzzers/corpora/commit_graph/6322594cff2a99d0abb1139e6a43b06df76d539a
new file mode 100644
index 0000000..4dabbce
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6322594cff2a99d0abb1139e6a43b06df76d539a differ
diff --git a/fuzzers/corpora/commit_graph/63de5e8e042222d53bf05640c87da376aefb76cc b/fuzzers/corpora/commit_graph/63de5e8e042222d53bf05640c87da376aefb76cc
new file mode 100644
index 0000000..2fd95a3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/63de5e8e042222d53bf05640c87da376aefb76cc differ
diff --git a/fuzzers/corpora/commit_graph/647dbb1d05fe0fab685bfe126bd9ac3a12b6bccf b/fuzzers/corpora/commit_graph/647dbb1d05fe0fab685bfe126bd9ac3a12b6bccf
new file mode 100644
index 0000000..245d46b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/647dbb1d05fe0fab685bfe126bd9ac3a12b6bccf differ
diff --git a/fuzzers/corpora/commit_graph/647e5e265d8d1079784fc2a3da25f7ba58126acd b/fuzzers/corpora/commit_graph/647e5e265d8d1079784fc2a3da25f7ba58126acd
new file mode 100644
index 0000000..633a2a3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/647e5e265d8d1079784fc2a3da25f7ba58126acd differ
diff --git a/fuzzers/corpora/commit_graph/653bd480dfd1e5f4bdca702aba3dfd8da0c204b7 b/fuzzers/corpora/commit_graph/653bd480dfd1e5f4bdca702aba3dfd8da0c204b7
new file mode 100644
index 0000000..d123602
Binary files /dev/null and b/fuzzers/corpora/commit_graph/653bd480dfd1e5f4bdca702aba3dfd8da0c204b7 differ
diff --git a/fuzzers/corpora/commit_graph/65485740a465377213c80fa68028727f281299fb b/fuzzers/corpora/commit_graph/65485740a465377213c80fa68028727f281299fb
new file mode 100644
index 0000000..c100bdb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/65485740a465377213c80fa68028727f281299fb differ
diff --git a/fuzzers/corpora/commit_graph/6551f8c8c3028006d0cc4997943df8a86ee3f598 b/fuzzers/corpora/commit_graph/6551f8c8c3028006d0cc4997943df8a86ee3f598
new file mode 100644
index 0000000..0ff4dda
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6551f8c8c3028006d0cc4997943df8a86ee3f598 differ
diff --git a/fuzzers/corpora/commit_graph/67799e79d33883510f85ae9705ab3932862128a2 b/fuzzers/corpora/commit_graph/67799e79d33883510f85ae9705ab3932862128a2
new file mode 100644
index 0000000..2782b4f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/67799e79d33883510f85ae9705ab3932862128a2 differ
diff --git a/fuzzers/corpora/commit_graph/67b475481e5a21351b49789874adbc988aefd64c b/fuzzers/corpora/commit_graph/67b475481e5a21351b49789874adbc988aefd64c
new file mode 100644
index 0000000..263753a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/67b475481e5a21351b49789874adbc988aefd64c differ
diff --git a/fuzzers/corpora/commit_graph/67e5a649967dee002d1c181e079748c404e29767 b/fuzzers/corpora/commit_graph/67e5a649967dee002d1c181e079748c404e29767
new file mode 100644
index 0000000..3bb8714
Binary files /dev/null and b/fuzzers/corpora/commit_graph/67e5a649967dee002d1c181e079748c404e29767 differ
diff --git a/fuzzers/corpora/commit_graph/687424a4a31a66a78d1637c680c9c10746741007 b/fuzzers/corpora/commit_graph/687424a4a31a66a78d1637c680c9c10746741007
new file mode 100644
index 0000000..6b26c19
Binary files /dev/null and b/fuzzers/corpora/commit_graph/687424a4a31a66a78d1637c680c9c10746741007 differ
diff --git a/fuzzers/corpora/commit_graph/68fa6dd52832657cb8dd7e1485d6fbafd4e93903 b/fuzzers/corpora/commit_graph/68fa6dd52832657cb8dd7e1485d6fbafd4e93903
new file mode 100644
index 0000000..fb966ff
Binary files /dev/null and b/fuzzers/corpora/commit_graph/68fa6dd52832657cb8dd7e1485d6fbafd4e93903 differ
diff --git a/fuzzers/corpora/commit_graph/691696af1c042115f4d9f9b8e24f7b8c06ed189b b/fuzzers/corpora/commit_graph/691696af1c042115f4d9f9b8e24f7b8c06ed189b
new file mode 100644
index 0000000..e407bd3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/691696af1c042115f4d9f9b8e24f7b8c06ed189b differ
diff --git a/fuzzers/corpora/commit_graph/6a80152f9b1afa3a3080bf3f6aa48e84c2e18497 b/fuzzers/corpora/commit_graph/6a80152f9b1afa3a3080bf3f6aa48e84c2e18497
new file mode 100644
index 0000000..a706cb0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6a80152f9b1afa3a3080bf3f6aa48e84c2e18497 differ
diff --git a/fuzzers/corpora/commit_graph/6af27e4cf4c7bcce128a5949ee27fc73ab2cc71e b/fuzzers/corpora/commit_graph/6af27e4cf4c7bcce128a5949ee27fc73ab2cc71e
new file mode 100644
index 0000000..d0b2fd2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6af27e4cf4c7bcce128a5949ee27fc73ab2cc71e differ
diff --git a/fuzzers/corpora/commit_graph/6afd8f82d5639b774de0dfd418ae85322f4168dd b/fuzzers/corpora/commit_graph/6afd8f82d5639b774de0dfd418ae85322f4168dd
new file mode 100644
index 0000000..7840c31
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6afd8f82d5639b774de0dfd418ae85322f4168dd differ
diff --git a/fuzzers/corpora/commit_graph/6c64a9e26e0e1480bb5e60b7044ca6ce17104a80 b/fuzzers/corpora/commit_graph/6c64a9e26e0e1480bb5e60b7044ca6ce17104a80
new file mode 100644
index 0000000..752046b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6c64a9e26e0e1480bb5e60b7044ca6ce17104a80 differ
diff --git a/fuzzers/corpora/commit_graph/6c850c17db130ca0152f7c75562fa191f7ef89de b/fuzzers/corpora/commit_graph/6c850c17db130ca0152f7c75562fa191f7ef89de
new file mode 100644
index 0000000..a7f693b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6c850c17db130ca0152f7c75562fa191f7ef89de differ
diff --git a/fuzzers/corpora/commit_graph/6c9afe4527371a2baf33c5e220e4ca21a3207f94 b/fuzzers/corpora/commit_graph/6c9afe4527371a2baf33c5e220e4ca21a3207f94
new file mode 100644
index 0000000..d7b8ffc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6c9afe4527371a2baf33c5e220e4ca21a3207f94 differ
diff --git a/fuzzers/corpora/commit_graph/6ce3d40b0225923a7f4123a919b1c5d70841fad7 b/fuzzers/corpora/commit_graph/6ce3d40b0225923a7f4123a919b1c5d70841fad7
new file mode 100644
index 0000000..3a2836b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6ce3d40b0225923a7f4123a919b1c5d70841fad7 differ
diff --git a/fuzzers/corpora/commit_graph/6cfd064aa6197813eb18f38df967ae4cdba9c6da b/fuzzers/corpora/commit_graph/6cfd064aa6197813eb18f38df967ae4cdba9c6da
new file mode 100644
index 0000000..51778d5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6cfd064aa6197813eb18f38df967ae4cdba9c6da differ
diff --git a/fuzzers/corpora/commit_graph/6e6675676c53bcddc870e06605d2432e3429f224 b/fuzzers/corpora/commit_graph/6e6675676c53bcddc870e06605d2432e3429f224
new file mode 100644
index 0000000..1ddebef
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6e6675676c53bcddc870e06605d2432e3429f224 differ
diff --git a/fuzzers/corpora/commit_graph/6e6e82579b7abae2b43d90448d3f2ead4dfcba78 b/fuzzers/corpora/commit_graph/6e6e82579b7abae2b43d90448d3f2ead4dfcba78
new file mode 100644
index 0000000..a528901
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6e6e82579b7abae2b43d90448d3f2ead4dfcba78 differ
diff --git a/fuzzers/corpora/commit_graph/6f13d23c75a562eddefafe85e208e602832294e2 b/fuzzers/corpora/commit_graph/6f13d23c75a562eddefafe85e208e602832294e2
new file mode 100644
index 0000000..49a5393
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6f13d23c75a562eddefafe85e208e602832294e2 differ
diff --git a/fuzzers/corpora/commit_graph/6fed59b0472927f5d2396d0ee4d7fd13579377ce b/fuzzers/corpora/commit_graph/6fed59b0472927f5d2396d0ee4d7fd13579377ce
new file mode 100644
index 0000000..6b3970f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/6fed59b0472927f5d2396d0ee4d7fd13579377ce differ
diff --git a/fuzzers/corpora/commit_graph/71f7724196f9f8fcfe3ee0161a84893bb9c4ab11 b/fuzzers/corpora/commit_graph/71f7724196f9f8fcfe3ee0161a84893bb9c4ab11
new file mode 100644
index 0000000..9e5c8dd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/71f7724196f9f8fcfe3ee0161a84893bb9c4ab11 differ
diff --git a/fuzzers/corpora/commit_graph/7335ecb1d41e713bf3909adf5802b90e22bc1581 b/fuzzers/corpora/commit_graph/7335ecb1d41e713bf3909adf5802b90e22bc1581
new file mode 100644
index 0000000..02e2fa6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7335ecb1d41e713bf3909adf5802b90e22bc1581 differ
diff --git a/fuzzers/corpora/commit_graph/73afaa73175f461e1d19d5138e055c1649926dfe b/fuzzers/corpora/commit_graph/73afaa73175f461e1d19d5138e055c1649926dfe
new file mode 100644
index 0000000..0f45e0b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/73afaa73175f461e1d19d5138e055c1649926dfe differ
diff --git a/fuzzers/corpora/commit_graph/73e2fcb45c4df90d19091056b235e7a317631a62 b/fuzzers/corpora/commit_graph/73e2fcb45c4df90d19091056b235e7a317631a62
new file mode 100644
index 0000000..549eeb3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/73e2fcb45c4df90d19091056b235e7a317631a62 differ
diff --git a/fuzzers/corpora/commit_graph/741cb2d5ae11b0a9e0608b58ec7284d75129a1f2 b/fuzzers/corpora/commit_graph/741cb2d5ae11b0a9e0608b58ec7284d75129a1f2
new file mode 100644
index 0000000..a16738d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/741cb2d5ae11b0a9e0608b58ec7284d75129a1f2 differ
diff --git a/fuzzers/corpora/commit_graph/7431bb0097a9bb52e1ceaaa8674a13cd3486a387 b/fuzzers/corpora/commit_graph/7431bb0097a9bb52e1ceaaa8674a13cd3486a387
new file mode 100644
index 0000000..d681b26
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7431bb0097a9bb52e1ceaaa8674a13cd3486a387 differ
diff --git a/fuzzers/corpora/commit_graph/7455b805995d0c96ac12f8a1c1264caaffcfac1c b/fuzzers/corpora/commit_graph/7455b805995d0c96ac12f8a1c1264caaffcfac1c
new file mode 100644
index 0000000..b3d2620
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7455b805995d0c96ac12f8a1c1264caaffcfac1c differ
diff --git a/fuzzers/corpora/commit_graph/74e39b8a82fc06f9ed8f83ea30545ddf6df66811 b/fuzzers/corpora/commit_graph/74e39b8a82fc06f9ed8f83ea30545ddf6df66811
new file mode 100644
index 0000000..3cc9deb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/74e39b8a82fc06f9ed8f83ea30545ddf6df66811 differ
diff --git a/fuzzers/corpora/commit_graph/75d51e413d3e916560dc0c2ee5092d2f4972aec1 b/fuzzers/corpora/commit_graph/75d51e413d3e916560dc0c2ee5092d2f4972aec1
new file mode 100644
index 0000000..68f34e7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/75d51e413d3e916560dc0c2ee5092d2f4972aec1 differ
diff --git a/fuzzers/corpora/commit_graph/75e068964ea6beb7310a154d763de74a70071f48 b/fuzzers/corpora/commit_graph/75e068964ea6beb7310a154d763de74a70071f48
new file mode 100644
index 0000000..a08ee58
Binary files /dev/null and b/fuzzers/corpora/commit_graph/75e068964ea6beb7310a154d763de74a70071f48 differ
diff --git a/fuzzers/corpora/commit_graph/763bf498dd847bd2b4af7b611199619bd428bea6 b/fuzzers/corpora/commit_graph/763bf498dd847bd2b4af7b611199619bd428bea6
new file mode 100644
index 0000000..4c28935
Binary files /dev/null and b/fuzzers/corpora/commit_graph/763bf498dd847bd2b4af7b611199619bd428bea6 differ
diff --git a/fuzzers/corpora/commit_graph/77064ae04581a3c6d2a77158ef1a0b1e60db414a b/fuzzers/corpora/commit_graph/77064ae04581a3c6d2a77158ef1a0b1e60db414a
new file mode 100644
index 0000000..fbd0ca7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/77064ae04581a3c6d2a77158ef1a0b1e60db414a differ
diff --git a/fuzzers/corpora/commit_graph/783bb14d68021061f592601607f40fe232ad17c4 b/fuzzers/corpora/commit_graph/783bb14d68021061f592601607f40fe232ad17c4
new file mode 100644
index 0000000..3cfa562
Binary files /dev/null and b/fuzzers/corpora/commit_graph/783bb14d68021061f592601607f40fe232ad17c4 differ
diff --git a/fuzzers/corpora/commit_graph/7862814cb684310b54ef920b35403515efaba13c b/fuzzers/corpora/commit_graph/7862814cb684310b54ef920b35403515efaba13c
new file mode 100644
index 0000000..3066626
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7862814cb684310b54ef920b35403515efaba13c differ
diff --git a/fuzzers/corpora/commit_graph/791fd85b6ffb2429e9fa5ba29eebdce214ad88c7 b/fuzzers/corpora/commit_graph/791fd85b6ffb2429e9fa5ba29eebdce214ad88c7
new file mode 100644
index 0000000..2c4739b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/791fd85b6ffb2429e9fa5ba29eebdce214ad88c7 differ
diff --git a/fuzzers/corpora/commit_graph/79396d4f6142a53e26e14aa6ccb4afb4fd8fc580 b/fuzzers/corpora/commit_graph/79396d4f6142a53e26e14aa6ccb4afb4fd8fc580
new file mode 100644
index 0000000..ef54342
Binary files /dev/null and b/fuzzers/corpora/commit_graph/79396d4f6142a53e26e14aa6ccb4afb4fd8fc580 differ
diff --git a/fuzzers/corpora/commit_graph/79661b8e529e2182d5c612faba9f26e32a122b78 b/fuzzers/corpora/commit_graph/79661b8e529e2182d5c612faba9f26e32a122b78
new file mode 100644
index 0000000..75ebe29
Binary files /dev/null and b/fuzzers/corpora/commit_graph/79661b8e529e2182d5c612faba9f26e32a122b78 differ
diff --git a/fuzzers/corpora/commit_graph/7969143acb3334bffac46c6dfd96362c81644191 b/fuzzers/corpora/commit_graph/7969143acb3334bffac46c6dfd96362c81644191
new file mode 100644
index 0000000..6ea2e66
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7969143acb3334bffac46c6dfd96362c81644191 differ
diff --git a/fuzzers/corpora/commit_graph/79d84866dc8c067508c02516b65c0e48cf689b56 b/fuzzers/corpora/commit_graph/79d84866dc8c067508c02516b65c0e48cf689b56
new file mode 100644
index 0000000..3080da7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/79d84866dc8c067508c02516b65c0e48cf689b56 differ
diff --git a/fuzzers/corpora/commit_graph/7b61f8f4a96e309bbe64ed82637fc81492a9652f b/fuzzers/corpora/commit_graph/7b61f8f4a96e309bbe64ed82637fc81492a9652f
new file mode 100644
index 0000000..28d93b7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7b61f8f4a96e309bbe64ed82637fc81492a9652f differ
diff --git a/fuzzers/corpora/commit_graph/7b8123f973edfb0f3cab027c0cd6b8efc7b11d6b b/fuzzers/corpora/commit_graph/7b8123f973edfb0f3cab027c0cd6b8efc7b11d6b
new file mode 100644
index 0000000..1c6699b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7b8123f973edfb0f3cab027c0cd6b8efc7b11d6b differ
diff --git a/fuzzers/corpora/commit_graph/7b8dd3093efba07f7a4d3bab4b90b8f6e4f28bfb b/fuzzers/corpora/commit_graph/7b8dd3093efba07f7a4d3bab4b90b8f6e4f28bfb
new file mode 100644
index 0000000..3e686e9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7b8dd3093efba07f7a4d3bab4b90b8f6e4f28bfb differ
diff --git a/fuzzers/corpora/commit_graph/7cc771aab0f3be7730881a46d952ae0a06958201 b/fuzzers/corpora/commit_graph/7cc771aab0f3be7730881a46d952ae0a06958201
new file mode 100644
index 0000000..ba94bfe
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7cc771aab0f3be7730881a46d952ae0a06958201 differ
diff --git a/fuzzers/corpora/commit_graph/7d177f4207de78d50df2493a3bc07f2cd578b363 b/fuzzers/corpora/commit_graph/7d177f4207de78d50df2493a3bc07f2cd578b363
new file mode 100644
index 0000000..a936354
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7d177f4207de78d50df2493a3bc07f2cd578b363 differ
diff --git a/fuzzers/corpora/commit_graph/7d2df075f3e73ea9809c31586c37ece0f568b7fa b/fuzzers/corpora/commit_graph/7d2df075f3e73ea9809c31586c37ece0f568b7fa
new file mode 100644
index 0000000..897276b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7d2df075f3e73ea9809c31586c37ece0f568b7fa differ
diff --git a/fuzzers/corpora/commit_graph/7d386e68e4c733a1fb11c0117f379fb4b9955fbb b/fuzzers/corpora/commit_graph/7d386e68e4c733a1fb11c0117f379fb4b9955fbb
new file mode 100644
index 0000000..f4f4d75
--- /dev/null
+++ b/fuzzers/corpora/commit_graph/7d386e68e4c733a1fb11c0117f379fb4b9955fbb
@@ -0,0 +1 @@
+Øúö
\ No newline at end of file
diff --git a/fuzzers/corpora/commit_graph/7e4260830352479d29310bd6e1022e19a68ffe76 b/fuzzers/corpora/commit_graph/7e4260830352479d29310bd6e1022e19a68ffe76
new file mode 100644
index 0000000..f478389
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7e4260830352479d29310bd6e1022e19a68ffe76 differ
diff --git a/fuzzers/corpora/commit_graph/7e4dfdae52be18cf95555c2eb1f54af7f69c6dde b/fuzzers/corpora/commit_graph/7e4dfdae52be18cf95555c2eb1f54af7f69c6dde
new file mode 100644
index 0000000..0f6d976
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7e4dfdae52be18cf95555c2eb1f54af7f69c6dde differ
diff --git a/fuzzers/corpora/commit_graph/7eafedf7e7f20e86ecdf9ba51febf8492bdbc1f1 b/fuzzers/corpora/commit_graph/7eafedf7e7f20e86ecdf9ba51febf8492bdbc1f1
new file mode 100644
index 0000000..ae5f7c5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7eafedf7e7f20e86ecdf9ba51febf8492bdbc1f1 differ
diff --git a/fuzzers/corpora/commit_graph/7ef1829a378d66b1dd70a767729127a0dc5edcae b/fuzzers/corpora/commit_graph/7ef1829a378d66b1dd70a767729127a0dc5edcae
new file mode 100644
index 0000000..e5d7355
Binary files /dev/null and b/fuzzers/corpora/commit_graph/7ef1829a378d66b1dd70a767729127a0dc5edcae differ
diff --git a/fuzzers/corpora/commit_graph/80b7d2b9d7e8c8fd7ae239b8d307b592f97ee000 b/fuzzers/corpora/commit_graph/80b7d2b9d7e8c8fd7ae239b8d307b592f97ee000
new file mode 100644
index 0000000..58ddc12
Binary files /dev/null and b/fuzzers/corpora/commit_graph/80b7d2b9d7e8c8fd7ae239b8d307b592f97ee000 differ
diff --git a/fuzzers/corpora/commit_graph/810f577ff5c1af7807a26226af912687558158cd b/fuzzers/corpora/commit_graph/810f577ff5c1af7807a26226af912687558158cd
new file mode 100644
index 0000000..be8be9c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/810f577ff5c1af7807a26226af912687558158cd differ
diff --git a/fuzzers/corpora/commit_graph/81603f1fe8d8e29005418d0fc9a9b33972366038 b/fuzzers/corpora/commit_graph/81603f1fe8d8e29005418d0fc9a9b33972366038
new file mode 100644
index 0000000..d9cb488
Binary files /dev/null and b/fuzzers/corpora/commit_graph/81603f1fe8d8e29005418d0fc9a9b33972366038 differ
diff --git a/fuzzers/corpora/commit_graph/81c8b4d6884f954935fa4a8e828c4637db04b61a b/fuzzers/corpora/commit_graph/81c8b4d6884f954935fa4a8e828c4637db04b61a
new file mode 100644
index 0000000..47ae17b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/81c8b4d6884f954935fa4a8e828c4637db04b61a differ
diff --git a/fuzzers/corpora/commit_graph/8226846e9b092561f85cc2956ab89d8cc1ae61e0 b/fuzzers/corpora/commit_graph/8226846e9b092561f85cc2956ab89d8cc1ae61e0
new file mode 100644
index 0000000..80d1cd9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8226846e9b092561f85cc2956ab89d8cc1ae61e0 differ
diff --git a/fuzzers/corpora/commit_graph/825cfceea434e2392cce161356e3cb5f81ec2b3a b/fuzzers/corpora/commit_graph/825cfceea434e2392cce161356e3cb5f81ec2b3a
new file mode 100644
index 0000000..01f87ed
Binary files /dev/null and b/fuzzers/corpora/commit_graph/825cfceea434e2392cce161356e3cb5f81ec2b3a differ
diff --git a/fuzzers/corpora/commit_graph/82603febce83d95adf68b85cabf15d43ca0c4ee9 b/fuzzers/corpora/commit_graph/82603febce83d95adf68b85cabf15d43ca0c4ee9
new file mode 100644
index 0000000..d828b05
Binary files /dev/null and b/fuzzers/corpora/commit_graph/82603febce83d95adf68b85cabf15d43ca0c4ee9 differ
diff --git a/fuzzers/corpora/commit_graph/827f0826cc4156e19b4c4938bec74e38de62fe9c b/fuzzers/corpora/commit_graph/827f0826cc4156e19b4c4938bec74e38de62fe9c
new file mode 100644
index 0000000..a391d62
Binary files /dev/null and b/fuzzers/corpora/commit_graph/827f0826cc4156e19b4c4938bec74e38de62fe9c differ
diff --git a/fuzzers/corpora/commit_graph/8486397ff8d1156249676c19b419a7758ff53f9a b/fuzzers/corpora/commit_graph/8486397ff8d1156249676c19b419a7758ff53f9a
new file mode 100644
index 0000000..dac9bbe
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8486397ff8d1156249676c19b419a7758ff53f9a differ
diff --git a/fuzzers/corpora/commit_graph/84d99ee359bec1b8ee0f59e9bd96f1da062030b7 b/fuzzers/corpora/commit_graph/84d99ee359bec1b8ee0f59e9bd96f1da062030b7
new file mode 100644
index 0000000..a2e7cf3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/84d99ee359bec1b8ee0f59e9bd96f1da062030b7 differ
diff --git a/fuzzers/corpora/commit_graph/84e629bc7416039f1feb81fa9168d7c1ee3141c2 b/fuzzers/corpora/commit_graph/84e629bc7416039f1feb81fa9168d7c1ee3141c2
new file mode 100644
index 0000000..8ae4e39
Binary files /dev/null and b/fuzzers/corpora/commit_graph/84e629bc7416039f1feb81fa9168d7c1ee3141c2 differ
diff --git a/fuzzers/corpora/commit_graph/84e885752179076fb38739ca7bc4345716bee56a b/fuzzers/corpora/commit_graph/84e885752179076fb38739ca7bc4345716bee56a
new file mode 100644
index 0000000..dd0c426
Binary files /dev/null and b/fuzzers/corpora/commit_graph/84e885752179076fb38739ca7bc4345716bee56a differ
diff --git a/fuzzers/corpora/commit_graph/859ef05494c8070057810b5c20df00fc81f81cf5 b/fuzzers/corpora/commit_graph/859ef05494c8070057810b5c20df00fc81f81cf5
new file mode 100644
index 0000000..2e3f299
Binary files /dev/null and b/fuzzers/corpora/commit_graph/859ef05494c8070057810b5c20df00fc81f81cf5 differ
diff --git a/fuzzers/corpora/commit_graph/859fe592f33abc1d959c0e73ecd6cd4bffe23a97 b/fuzzers/corpora/commit_graph/859fe592f33abc1d959c0e73ecd6cd4bffe23a97
new file mode 100644
index 0000000..5289c8e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/859fe592f33abc1d959c0e73ecd6cd4bffe23a97 differ
diff --git a/fuzzers/corpora/commit_graph/860da5e8a468805b76a44b9ac99b4575be16ea15 b/fuzzers/corpora/commit_graph/860da5e8a468805b76a44b9ac99b4575be16ea15
new file mode 100644
index 0000000..c8b03da
Binary files /dev/null and b/fuzzers/corpora/commit_graph/860da5e8a468805b76a44b9ac99b4575be16ea15 differ
diff --git a/fuzzers/corpora/commit_graph/865e415745cead02a826f058a5ee49099bdf9562 b/fuzzers/corpora/commit_graph/865e415745cead02a826f058a5ee49099bdf9562
new file mode 100644
index 0000000..a4ce658
Binary files /dev/null and b/fuzzers/corpora/commit_graph/865e415745cead02a826f058a5ee49099bdf9562 differ
diff --git a/fuzzers/corpora/commit_graph/878bfce051a9c7462847d4e99b7e926dc821b7b8 b/fuzzers/corpora/commit_graph/878bfce051a9c7462847d4e99b7e926dc821b7b8
new file mode 100644
index 0000000..efb0bc5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/878bfce051a9c7462847d4e99b7e926dc821b7b8 differ
diff --git a/fuzzers/corpora/commit_graph/880492e4dc7259577c227bb4f075d7165e875c29 b/fuzzers/corpora/commit_graph/880492e4dc7259577c227bb4f075d7165e875c29
new file mode 100644
index 0000000..c977dff
Binary files /dev/null and b/fuzzers/corpora/commit_graph/880492e4dc7259577c227bb4f075d7165e875c29 differ
diff --git a/fuzzers/corpora/commit_graph/88b7de1bd1c96454a1350286d115c0ee368511f9 b/fuzzers/corpora/commit_graph/88b7de1bd1c96454a1350286d115c0ee368511f9
new file mode 100644
index 0000000..7261eec
Binary files /dev/null and b/fuzzers/corpora/commit_graph/88b7de1bd1c96454a1350286d115c0ee368511f9 differ
diff --git a/fuzzers/corpora/commit_graph/896268e4a5775b7ce33923ac6daeb0810420c55b b/fuzzers/corpora/commit_graph/896268e4a5775b7ce33923ac6daeb0810420c55b
new file mode 100644
index 0000000..0897bda
Binary files /dev/null and b/fuzzers/corpora/commit_graph/896268e4a5775b7ce33923ac6daeb0810420c55b differ
diff --git a/fuzzers/corpora/commit_graph/8978f8da89f9652878edabad164f5513ef508f27 b/fuzzers/corpora/commit_graph/8978f8da89f9652878edabad164f5513ef508f27
new file mode 100644
index 0000000..0dd9ba4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8978f8da89f9652878edabad164f5513ef508f27 differ
diff --git a/fuzzers/corpora/commit_graph/89a6525b7db0e6ec211a484efd2880abef928d4e b/fuzzers/corpora/commit_graph/89a6525b7db0e6ec211a484efd2880abef928d4e
new file mode 100644
index 0000000..e5dd1cd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/89a6525b7db0e6ec211a484efd2880abef928d4e differ
diff --git a/fuzzers/corpora/commit_graph/8ae86cba2bba6664fc5eb97be8e9777b8825d823 b/fuzzers/corpora/commit_graph/8ae86cba2bba6664fc5eb97be8e9777b8825d823
new file mode 100644
index 0000000..04a4aa5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8ae86cba2bba6664fc5eb97be8e9777b8825d823 differ
diff --git a/fuzzers/corpora/commit_graph/8b845fbd2aa14e4f83c4dbc8b4b0b54d06482acd b/fuzzers/corpora/commit_graph/8b845fbd2aa14e4f83c4dbc8b4b0b54d06482acd
new file mode 100644
index 0000000..c711793
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8b845fbd2aa14e4f83c4dbc8b4b0b54d06482acd differ
diff --git a/fuzzers/corpora/commit_graph/8c4121e6ce5956cfa408b980f16d276f456374dc b/fuzzers/corpora/commit_graph/8c4121e6ce5956cfa408b980f16d276f456374dc
new file mode 100644
index 0000000..1ba1891
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8c4121e6ce5956cfa408b980f16d276f456374dc differ
diff --git a/fuzzers/corpora/commit_graph/8cb6a5b8ab41e3d27668d5735b5c09ff1f2eab65 b/fuzzers/corpora/commit_graph/8cb6a5b8ab41e3d27668d5735b5c09ff1f2eab65
new file mode 100644
index 0000000..e23d112
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8cb6a5b8ab41e3d27668d5735b5c09ff1f2eab65 differ
diff --git a/fuzzers/corpora/commit_graph/8d80a70ffd362a89b88663e27f11e8ab69b70c1b b/fuzzers/corpora/commit_graph/8d80a70ffd362a89b88663e27f11e8ab69b70c1b
new file mode 100644
index 0000000..02f765e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8d80a70ffd362a89b88663e27f11e8ab69b70c1b differ
diff --git a/fuzzers/corpora/commit_graph/8db603c1720b3680047f831f2ea9862567a7cdc4 b/fuzzers/corpora/commit_graph/8db603c1720b3680047f831f2ea9862567a7cdc4
new file mode 100644
index 0000000..d02cb03
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8db603c1720b3680047f831f2ea9862567a7cdc4 differ
diff --git a/fuzzers/corpora/commit_graph/8dd40b2d27c7dd4b986c35d87f826da287c09c4c b/fuzzers/corpora/commit_graph/8dd40b2d27c7dd4b986c35d87f826da287c09c4c
new file mode 100644
index 0000000..11aa235
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8dd40b2d27c7dd4b986c35d87f826da287c09c4c differ
diff --git a/fuzzers/corpora/commit_graph/8e9d6e6408e5f708a1924e8370e687e2c202a4c4 b/fuzzers/corpora/commit_graph/8e9d6e6408e5f708a1924e8370e687e2c202a4c4
new file mode 100644
index 0000000..cbeb46b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8e9d6e6408e5f708a1924e8370e687e2c202a4c4 differ
diff --git a/fuzzers/corpora/commit_graph/8f2dff1a30ee28e5985cb9379828aea5658d5849 b/fuzzers/corpora/commit_graph/8f2dff1a30ee28e5985cb9379828aea5658d5849
new file mode 100644
index 0000000..b7220c3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8f2dff1a30ee28e5985cb9379828aea5658d5849 differ
diff --git a/fuzzers/corpora/commit_graph/8f7d18cdd6e605b85784ada14571fd5e5a184f2a b/fuzzers/corpora/commit_graph/8f7d18cdd6e605b85784ada14571fd5e5a184f2a
new file mode 100644
index 0000000..80fe175
Binary files /dev/null and b/fuzzers/corpora/commit_graph/8f7d18cdd6e605b85784ada14571fd5e5a184f2a differ
diff --git a/fuzzers/corpora/commit_graph/903ae52f0ac9af8348038b12f9259741b0de42f1 b/fuzzers/corpora/commit_graph/903ae52f0ac9af8348038b12f9259741b0de42f1
new file mode 100644
index 0000000..da8c220
Binary files /dev/null and b/fuzzers/corpora/commit_graph/903ae52f0ac9af8348038b12f9259741b0de42f1 differ
diff --git a/fuzzers/corpora/commit_graph/9119e331f59e9337d419739c324f49d1bd62c8bf b/fuzzers/corpora/commit_graph/9119e331f59e9337d419739c324f49d1bd62c8bf
new file mode 100644
index 0000000..fc3a696
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9119e331f59e9337d419739c324f49d1bd62c8bf differ
diff --git a/fuzzers/corpora/commit_graph/91d54d03b0917314ea1d67a70690df9247dd08d2 b/fuzzers/corpora/commit_graph/91d54d03b0917314ea1d67a70690df9247dd08d2
new file mode 100644
index 0000000..290da4d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/91d54d03b0917314ea1d67a70690df9247dd08d2 differ
diff --git a/fuzzers/corpora/commit_graph/922da3b96725bfd0e3f6ce119f1e2249d53f9086 b/fuzzers/corpora/commit_graph/922da3b96725bfd0e3f6ce119f1e2249d53f9086
new file mode 100644
index 0000000..c3bb009
Binary files /dev/null and b/fuzzers/corpora/commit_graph/922da3b96725bfd0e3f6ce119f1e2249d53f9086 differ
diff --git a/fuzzers/corpora/commit_graph/9277561e0524cccba2f851970b0d88ec4f4d3f5e b/fuzzers/corpora/commit_graph/9277561e0524cccba2f851970b0d88ec4f4d3f5e
new file mode 100644
index 0000000..07d1da1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9277561e0524cccba2f851970b0d88ec4f4d3f5e differ
diff --git a/fuzzers/corpora/commit_graph/92a4d571804026b7bbe957396185e079e756b894 b/fuzzers/corpora/commit_graph/92a4d571804026b7bbe957396185e079e756b894
new file mode 100644
index 0000000..63b98b3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/92a4d571804026b7bbe957396185e079e756b894 differ
diff --git a/fuzzers/corpora/commit_graph/931224cc80168fd362a360d99bab813ed7bbf8ce b/fuzzers/corpora/commit_graph/931224cc80168fd362a360d99bab813ed7bbf8ce
new file mode 100644
index 0000000..df27b36
Binary files /dev/null and b/fuzzers/corpora/commit_graph/931224cc80168fd362a360d99bab813ed7bbf8ce differ
diff --git a/fuzzers/corpora/commit_graph/936ea5dad3bf023c552aa0bbeea8f7f66a11612c b/fuzzers/corpora/commit_graph/936ea5dad3bf023c552aa0bbeea8f7f66a11612c
new file mode 100644
index 0000000..847b537
Binary files /dev/null and b/fuzzers/corpora/commit_graph/936ea5dad3bf023c552aa0bbeea8f7f66a11612c differ
diff --git a/fuzzers/corpora/commit_graph/93aa4e0b1864933dce0abc0df69fe3d261f117f2 b/fuzzers/corpora/commit_graph/93aa4e0b1864933dce0abc0df69fe3d261f117f2
new file mode 100644
index 0000000..ac830ca
Binary files /dev/null and b/fuzzers/corpora/commit_graph/93aa4e0b1864933dce0abc0df69fe3d261f117f2 differ
diff --git a/fuzzers/corpora/commit_graph/93d5b084965cf1b09085c4079a972e25207b3659 b/fuzzers/corpora/commit_graph/93d5b084965cf1b09085c4079a972e25207b3659
new file mode 100644
index 0000000..02a711a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/93d5b084965cf1b09085c4079a972e25207b3659 differ
diff --git a/fuzzers/corpora/commit_graph/9443fd3468bcc0bc3ff8dfe765225f045ab43d0a b/fuzzers/corpora/commit_graph/9443fd3468bcc0bc3ff8dfe765225f045ab43d0a
new file mode 100644
index 0000000..d1667ca
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9443fd3468bcc0bc3ff8dfe765225f045ab43d0a differ
diff --git a/fuzzers/corpora/commit_graph/9624c26cefb5804b7906147d262e81ee4000b6d6 b/fuzzers/corpora/commit_graph/9624c26cefb5804b7906147d262e81ee4000b6d6
new file mode 100644
index 0000000..4c18831
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9624c26cefb5804b7906147d262e81ee4000b6d6 differ
diff --git a/fuzzers/corpora/commit_graph/9890933a73f39208627bd36e2fe88a6d54343a74 b/fuzzers/corpora/commit_graph/9890933a73f39208627bd36e2fe88a6d54343a74
new file mode 100644
index 0000000..dfbb39d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9890933a73f39208627bd36e2fe88a6d54343a74 differ
diff --git a/fuzzers/corpora/commit_graph/989dad0448e79af10040d5080f74eba2b8a401ba b/fuzzers/corpora/commit_graph/989dad0448e79af10040d5080f74eba2b8a401ba
new file mode 100644
index 0000000..202bbd6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/989dad0448e79af10040d5080f74eba2b8a401ba differ
diff --git a/fuzzers/corpora/commit_graph/98ed4808b4a8da66a91fcea1be63be6371a7c7ac b/fuzzers/corpora/commit_graph/98ed4808b4a8da66a91fcea1be63be6371a7c7ac
new file mode 100644
index 0000000..b06a167
Binary files /dev/null and b/fuzzers/corpora/commit_graph/98ed4808b4a8da66a91fcea1be63be6371a7c7ac differ
diff --git a/fuzzers/corpora/commit_graph/9928e516b85e22fbad58d562d3b7e814d9ce812d b/fuzzers/corpora/commit_graph/9928e516b85e22fbad58d562d3b7e814d9ce812d
new file mode 100644
index 0000000..d1e5a04
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9928e516b85e22fbad58d562d3b7e814d9ce812d differ
diff --git a/fuzzers/corpora/commit_graph/994c7cc5599252b5628d89cd0ba4b5574d32bf00 b/fuzzers/corpora/commit_graph/994c7cc5599252b5628d89cd0ba4b5574d32bf00
new file mode 100644
index 0000000..d51d00d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/994c7cc5599252b5628d89cd0ba4b5574d32bf00 differ
diff --git a/fuzzers/corpora/commit_graph/99c8557c2a02ea030de42869af42c1f7c77114db b/fuzzers/corpora/commit_graph/99c8557c2a02ea030de42869af42c1f7c77114db
new file mode 100644
index 0000000..18f5349
Binary files /dev/null and b/fuzzers/corpora/commit_graph/99c8557c2a02ea030de42869af42c1f7c77114db differ
diff --git a/fuzzers/corpora/commit_graph/9a14c867272f102b84efdba73662d318c3e51cfe b/fuzzers/corpora/commit_graph/9a14c867272f102b84efdba73662d318c3e51cfe
new file mode 100644
index 0000000..fc473b2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9a14c867272f102b84efdba73662d318c3e51cfe differ
diff --git a/fuzzers/corpora/commit_graph/9a6f158c176d4a1982d541be2bc27a8afba4ea57 b/fuzzers/corpora/commit_graph/9a6f158c176d4a1982d541be2bc27a8afba4ea57
new file mode 100644
index 0000000..b99bc20
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9a6f158c176d4a1982d541be2bc27a8afba4ea57 differ
diff --git a/fuzzers/corpora/commit_graph/9aa4af603192823a2fdc53d95ed36896bc3309b2 b/fuzzers/corpora/commit_graph/9aa4af603192823a2fdc53d95ed36896bc3309b2
new file mode 100644
index 0000000..c36e298
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9aa4af603192823a2fdc53d95ed36896bc3309b2 differ
diff --git a/fuzzers/corpora/commit_graph/9b40c2190123cec66af3b37212f6c567869efda3 b/fuzzers/corpora/commit_graph/9b40c2190123cec66af3b37212f6c567869efda3
new file mode 100644
index 0000000..1662324
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9b40c2190123cec66af3b37212f6c567869efda3 differ
diff --git a/fuzzers/corpora/commit_graph/9b6268c11d78c35db5164f1346905e602b6a49fe b/fuzzers/corpora/commit_graph/9b6268c11d78c35db5164f1346905e602b6a49fe
new file mode 100644
index 0000000..4106e20
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9b6268c11d78c35db5164f1346905e602b6a49fe differ
diff --git a/fuzzers/corpora/commit_graph/9c6883ba5cedb7d711b12733d66ef1a1156dd0af b/fuzzers/corpora/commit_graph/9c6883ba5cedb7d711b12733d66ef1a1156dd0af
new file mode 100644
index 0000000..84a193c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9c6883ba5cedb7d711b12733d66ef1a1156dd0af differ
diff --git a/fuzzers/corpora/commit_graph/9c85c90f44b454ce0d52882c447f5ecb8d303634 b/fuzzers/corpora/commit_graph/9c85c90f44b454ce0d52882c447f5ecb8d303634
new file mode 100644
index 0000000..e17438b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9c85c90f44b454ce0d52882c447f5ecb8d303634 differ
diff --git a/fuzzers/corpora/commit_graph/9cb7a2e89ec636da3fd41ecc49ebe25e5344e2c6 b/fuzzers/corpora/commit_graph/9cb7a2e89ec636da3fd41ecc49ebe25e5344e2c6
new file mode 100644
index 0000000..55f76fd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9cb7a2e89ec636da3fd41ecc49ebe25e5344e2c6 differ
diff --git a/fuzzers/corpora/commit_graph/9d912dc5a3497e4b5b40b37202fc0ffbf5263666 b/fuzzers/corpora/commit_graph/9d912dc5a3497e4b5b40b37202fc0ffbf5263666
new file mode 100644
index 0000000..c71c31a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9d912dc5a3497e4b5b40b37202fc0ffbf5263666 differ
diff --git a/fuzzers/corpora/commit_graph/9dcbafe8c5345194ee0ce7eb4f6efaeb55543626 b/fuzzers/corpora/commit_graph/9dcbafe8c5345194ee0ce7eb4f6efaeb55543626
new file mode 100644
index 0000000..42c5e7d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9dcbafe8c5345194ee0ce7eb4f6efaeb55543626 differ
diff --git a/fuzzers/corpora/commit_graph/9f4b0f3d2d25e6405ba6093f24d0605327711573 b/fuzzers/corpora/commit_graph/9f4b0f3d2d25e6405ba6093f24d0605327711573
new file mode 100644
index 0000000..0dc94be
Binary files /dev/null and b/fuzzers/corpora/commit_graph/9f4b0f3d2d25e6405ba6093f24d0605327711573 differ
diff --git a/fuzzers/corpora/commit_graph/a047bf683239fa208dbac09424b105820ac23f43 b/fuzzers/corpora/commit_graph/a047bf683239fa208dbac09424b105820ac23f43
new file mode 100644
index 0000000..925c86c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a047bf683239fa208dbac09424b105820ac23f43 differ
diff --git a/fuzzers/corpora/commit_graph/a1379dcd89ef5e73eabbfcc395113e3636e0ae09 b/fuzzers/corpora/commit_graph/a1379dcd89ef5e73eabbfcc395113e3636e0ae09
new file mode 100644
index 0000000..43d31b6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a1379dcd89ef5e73eabbfcc395113e3636e0ae09 differ
diff --git a/fuzzers/corpora/commit_graph/a38c7ef56adabd0916abac514154b1f362d40434 b/fuzzers/corpora/commit_graph/a38c7ef56adabd0916abac514154b1f362d40434
new file mode 100644
index 0000000..944b4ea
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a38c7ef56adabd0916abac514154b1f362d40434 differ
diff --git a/fuzzers/corpora/commit_graph/a38ec6ad4a8466b4feb88e67b16524e8f3feac64 b/fuzzers/corpora/commit_graph/a38ec6ad4a8466b4feb88e67b16524e8f3feac64
new file mode 100644
index 0000000..a9d1adb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a38ec6ad4a8466b4feb88e67b16524e8f3feac64 differ
diff --git a/fuzzers/corpora/commit_graph/a3fdea21020268b3b2409c1115d50697d9ae8f8c b/fuzzers/corpora/commit_graph/a3fdea21020268b3b2409c1115d50697d9ae8f8c
new file mode 100644
index 0000000..8d4f934
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a3fdea21020268b3b2409c1115d50697d9ae8f8c differ
diff --git a/fuzzers/corpora/commit_graph/a45f1987a444b2c27e90fc1477e8b0815f75383f b/fuzzers/corpora/commit_graph/a45f1987a444b2c27e90fc1477e8b0815f75383f
new file mode 100644
index 0000000..d211a8b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a45f1987a444b2c27e90fc1477e8b0815f75383f differ
diff --git a/fuzzers/corpora/commit_graph/a4682958fb7029384c0a01a4a1356ac6f2f44fe1 b/fuzzers/corpora/commit_graph/a4682958fb7029384c0a01a4a1356ac6f2f44fe1
new file mode 100644
index 0000000..e8f66dc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a4682958fb7029384c0a01a4a1356ac6f2f44fe1 differ
diff --git a/fuzzers/corpora/commit_graph/a4de41561725960d6f48f210a4fb74d527f7b0c2 b/fuzzers/corpora/commit_graph/a4de41561725960d6f48f210a4fb74d527f7b0c2
new file mode 100644
index 0000000..ac4c41c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a4de41561725960d6f48f210a4fb74d527f7b0c2 differ
diff --git a/fuzzers/corpora/commit_graph/a5935f34435ecdd6587ad4f77b20d479d3387dbe b/fuzzers/corpora/commit_graph/a5935f34435ecdd6587ad4f77b20d479d3387dbe
new file mode 100644
index 0000000..2e00f59
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a5935f34435ecdd6587ad4f77b20d479d3387dbe differ
diff --git a/fuzzers/corpora/commit_graph/a5b394beb2b1d463ad80924a8c8c70584bf5c629 b/fuzzers/corpora/commit_graph/a5b394beb2b1d463ad80924a8c8c70584bf5c629
new file mode 100644
index 0000000..eb8f700
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a5b394beb2b1d463ad80924a8c8c70584bf5c629 differ
diff --git a/fuzzers/corpora/commit_graph/a62bc806f8c98ba7986243c2185a0548a8dd57ef b/fuzzers/corpora/commit_graph/a62bc806f8c98ba7986243c2185a0548a8dd57ef
new file mode 100644
index 0000000..fb30d9e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a62bc806f8c98ba7986243c2185a0548a8dd57ef differ
diff --git a/fuzzers/corpora/commit_graph/a7013e97948893e0118c686c06e332cc611bea7e b/fuzzers/corpora/commit_graph/a7013e97948893e0118c686c06e332cc611bea7e
new file mode 100644
index 0000000..ab50113
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a7013e97948893e0118c686c06e332cc611bea7e differ
diff --git a/fuzzers/corpora/commit_graph/a74f5df8c7f25c37c15c0f74ed50019d17338225 b/fuzzers/corpora/commit_graph/a74f5df8c7f25c37c15c0f74ed50019d17338225
new file mode 100644
index 0000000..b234c15
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a74f5df8c7f25c37c15c0f74ed50019d17338225 differ
diff --git a/fuzzers/corpora/commit_graph/a7ab3559fb3da3f027e67091116253f3bdfd7828 b/fuzzers/corpora/commit_graph/a7ab3559fb3da3f027e67091116253f3bdfd7828
new file mode 100644
index 0000000..838337a
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a7ab3559fb3da3f027e67091116253f3bdfd7828 differ
diff --git a/fuzzers/corpora/commit_graph/a845c8258a02022d447ea9249788b345f5504648 b/fuzzers/corpora/commit_graph/a845c8258a02022d447ea9249788b345f5504648
new file mode 100644
index 0000000..78311d9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a845c8258a02022d447ea9249788b345f5504648 differ
diff --git a/fuzzers/corpora/commit_graph/a8d3e026e2393587eb170afb32e94ff0e1f8a8be b/fuzzers/corpora/commit_graph/a8d3e026e2393587eb170afb32e94ff0e1f8a8be
new file mode 100644
index 0000000..54457f3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a8d3e026e2393587eb170afb32e94ff0e1f8a8be differ
diff --git a/fuzzers/corpora/commit_graph/a8d547e41ee21e163e65cf0a186d469dfa50ec19 b/fuzzers/corpora/commit_graph/a8d547e41ee21e163e65cf0a186d469dfa50ec19
new file mode 100644
index 0000000..52d265b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a8d547e41ee21e163e65cf0a186d469dfa50ec19 differ
diff --git a/fuzzers/corpora/commit_graph/a8fa22521dd6813e595cc0a9586ee71fff305fe2 b/fuzzers/corpora/commit_graph/a8fa22521dd6813e595cc0a9586ee71fff305fe2
new file mode 100644
index 0000000..5f90995
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a8fa22521dd6813e595cc0a9586ee71fff305fe2 differ
diff --git a/fuzzers/corpora/commit_graph/a9969442d585d9a53259c71c73b095701280eac5 b/fuzzers/corpora/commit_graph/a9969442d585d9a53259c71c73b095701280eac5
new file mode 100644
index 0000000..f757928
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a9969442d585d9a53259c71c73b095701280eac5 differ
diff --git a/fuzzers/corpora/commit_graph/a99789d0ce2d7b937aaa8afa3cfc0f4ccd7be95f b/fuzzers/corpora/commit_graph/a99789d0ce2d7b937aaa8afa3cfc0f4ccd7be95f
new file mode 100644
index 0000000..471add5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/a99789d0ce2d7b937aaa8afa3cfc0f4ccd7be95f differ
diff --git a/fuzzers/corpora/commit_graph/aaca30ee3ab38edfa2b061fcbcbca0c0ea657f15 b/fuzzers/corpora/commit_graph/aaca30ee3ab38edfa2b061fcbcbca0c0ea657f15
new file mode 100644
index 0000000..cc981c1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/aaca30ee3ab38edfa2b061fcbcbca0c0ea657f15 differ
diff --git a/fuzzers/corpora/commit_graph/aacdec3f05e98eb6eedddb9c6edb968e1a63c551 b/fuzzers/corpora/commit_graph/aacdec3f05e98eb6eedddb9c6edb968e1a63c551
new file mode 100644
index 0000000..622c247
Binary files /dev/null and b/fuzzers/corpora/commit_graph/aacdec3f05e98eb6eedddb9c6edb968e1a63c551 differ
diff --git a/fuzzers/corpora/commit_graph/aadd85127241b94a41d02d9e9699e3e9773de1c9 b/fuzzers/corpora/commit_graph/aadd85127241b94a41d02d9e9699e3e9773de1c9
new file mode 100644
index 0000000..b84e5f1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/aadd85127241b94a41d02d9e9699e3e9773de1c9 differ
diff --git a/fuzzers/corpora/commit_graph/ab8ad126702803d21dbafc85713bbee7f25f36e5 b/fuzzers/corpora/commit_graph/ab8ad126702803d21dbafc85713bbee7f25f36e5
new file mode 100644
index 0000000..9a19eda
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ab8ad126702803d21dbafc85713bbee7f25f36e5 differ
diff --git a/fuzzers/corpora/commit_graph/ac26f9afd599ff6f33396c2e02130654f3e2390c b/fuzzers/corpora/commit_graph/ac26f9afd599ff6f33396c2e02130654f3e2390c
new file mode 100644
index 0000000..843eaa2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ac26f9afd599ff6f33396c2e02130654f3e2390c differ
diff --git a/fuzzers/corpora/commit_graph/ac8b129e4756fda0c50c9dd0eb13e34c7b41ce8e b/fuzzers/corpora/commit_graph/ac8b129e4756fda0c50c9dd0eb13e34c7b41ce8e
new file mode 100644
index 0000000..4b41d07
--- /dev/null
+++ b/fuzzers/corpora/commit_graph/ac8b129e4756fda0c50c9dd0eb13e34c7b41ce8e
@@ -0,0 +1 @@
+ïïïœïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï@ïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïë
\ No newline at end of file
diff --git a/fuzzers/corpora/commit_graph/aceaf3b72c2627dd3dd065974b854150681c093f b/fuzzers/corpora/commit_graph/aceaf3b72c2627dd3dd065974b854150681c093f
new file mode 100644
index 0000000..d490782
Binary files /dev/null and b/fuzzers/corpora/commit_graph/aceaf3b72c2627dd3dd065974b854150681c093f differ
diff --git a/fuzzers/corpora/commit_graph/ad1fcdc3bf806392e754a902eba9edd3b344c31f b/fuzzers/corpora/commit_graph/ad1fcdc3bf806392e754a902eba9edd3b344c31f
new file mode 100644
index 0000000..1379b75
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ad1fcdc3bf806392e754a902eba9edd3b344c31f differ
diff --git a/fuzzers/corpora/commit_graph/ad8c80e532482f9dfbfbb7c0d447f1f4e592bf72 b/fuzzers/corpora/commit_graph/ad8c80e532482f9dfbfbb7c0d447f1f4e592bf72
new file mode 100644
index 0000000..bfe3911
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ad8c80e532482f9dfbfbb7c0d447f1f4e592bf72 differ
diff --git a/fuzzers/corpora/commit_graph/add92b71bf897da2f71f691e6abcb6d02cb8e99f b/fuzzers/corpora/commit_graph/add92b71bf897da2f71f691e6abcb6d02cb8e99f
new file mode 100644
index 0000000..1676dbf
Binary files /dev/null and b/fuzzers/corpora/commit_graph/add92b71bf897da2f71f691e6abcb6d02cb8e99f differ
diff --git a/fuzzers/corpora/commit_graph/aeb8ccf6d82be9236c9e689e1580d043bd701eb0 b/fuzzers/corpora/commit_graph/aeb8ccf6d82be9236c9e689e1580d043bd701eb0
new file mode 100644
index 0000000..10688e3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/aeb8ccf6d82be9236c9e689e1580d043bd701eb0 differ
diff --git a/fuzzers/corpora/commit_graph/af1a827aedbf674fff2bdeb5589554eec62787ab b/fuzzers/corpora/commit_graph/af1a827aedbf674fff2bdeb5589554eec62787ab
new file mode 100644
index 0000000..6f08ae5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/af1a827aedbf674fff2bdeb5589554eec62787ab differ
diff --git a/fuzzers/corpora/commit_graph/afaab9a75414d231176ad4582b6f8d81b5dbedb3 b/fuzzers/corpora/commit_graph/afaab9a75414d231176ad4582b6f8d81b5dbedb3
new file mode 100644
index 0000000..8701780
Binary files /dev/null and b/fuzzers/corpora/commit_graph/afaab9a75414d231176ad4582b6f8d81b5dbedb3 differ
diff --git a/fuzzers/corpora/commit_graph/afc12c4ebed1f3ab962d7dcef110b5328b1e24c3 b/fuzzers/corpora/commit_graph/afc12c4ebed1f3ab962d7dcef110b5328b1e24c3
new file mode 100644
index 0000000..0e10f77
Binary files /dev/null and b/fuzzers/corpora/commit_graph/afc12c4ebed1f3ab962d7dcef110b5328b1e24c3 differ
diff --git a/fuzzers/corpora/commit_graph/b0044f3744cf019658d668a33f8d1e53ef8bd6ce b/fuzzers/corpora/commit_graph/b0044f3744cf019658d668a33f8d1e53ef8bd6ce
new file mode 100644
index 0000000..ede7bfe
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b0044f3744cf019658d668a33f8d1e53ef8bd6ce differ
diff --git a/fuzzers/corpora/commit_graph/b06adc81a4e1cdcda3786970ca07ed9dee0b6401 b/fuzzers/corpora/commit_graph/b06adc81a4e1cdcda3786970ca07ed9dee0b6401
new file mode 100644
index 0000000..b5f08b2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b06adc81a4e1cdcda3786970ca07ed9dee0b6401 differ
diff --git a/fuzzers/corpora/commit_graph/b139802a1cc90fd5b86cae044c221361892c688d b/fuzzers/corpora/commit_graph/b139802a1cc90fd5b86cae044c221361892c688d
new file mode 100644
index 0000000..c21f39e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b139802a1cc90fd5b86cae044c221361892c688d differ
diff --git a/fuzzers/corpora/commit_graph/b1b8f251542db01bdb01be3b6d5b117b07db1834 b/fuzzers/corpora/commit_graph/b1b8f251542db01bdb01be3b6d5b117b07db1834
new file mode 100644
index 0000000..b42f726
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b1b8f251542db01bdb01be3b6d5b117b07db1834 differ
diff --git a/fuzzers/corpora/commit_graph/b1b9af93f84ed6861b9c0ade39980e89ef828c8f b/fuzzers/corpora/commit_graph/b1b9af93f84ed6861b9c0ade39980e89ef828c8f
new file mode 100644
index 0000000..b367b87
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b1b9af93f84ed6861b9c0ade39980e89ef828c8f differ
diff --git a/fuzzers/corpora/commit_graph/b2eae68035cafd4077f6a4c3e4e961fdc1e8122b b/fuzzers/corpora/commit_graph/b2eae68035cafd4077f6a4c3e4e961fdc1e8122b
new file mode 100644
index 0000000..1c62898
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b2eae68035cafd4077f6a4c3e4e961fdc1e8122b differ
diff --git a/fuzzers/corpora/commit_graph/b32897a6aedaa8c5a6e656dd808bafabc4ee5608 b/fuzzers/corpora/commit_graph/b32897a6aedaa8c5a6e656dd808bafabc4ee5608
new file mode 100644
index 0000000..b3fbb81
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b32897a6aedaa8c5a6e656dd808bafabc4ee5608 differ
diff --git a/fuzzers/corpora/commit_graph/b376e4fc517297f92ac1713803ae3b60d5ebbe43 b/fuzzers/corpora/commit_graph/b376e4fc517297f92ac1713803ae3b60d5ebbe43
new file mode 100644
index 0000000..637eafd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b376e4fc517297f92ac1713803ae3b60d5ebbe43 differ
diff --git a/fuzzers/corpora/commit_graph/b3fd100b139cfbffaad68aacf7d462861e9dca35 b/fuzzers/corpora/commit_graph/b3fd100b139cfbffaad68aacf7d462861e9dca35
new file mode 100644
index 0000000..da105f5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b3fd100b139cfbffaad68aacf7d462861e9dca35 differ
diff --git a/fuzzers/corpora/commit_graph/b40808ca955faab4829811bced1cccb2ab58ea58 b/fuzzers/corpora/commit_graph/b40808ca955faab4829811bced1cccb2ab58ea58
new file mode 100644
index 0000000..4daa741
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b40808ca955faab4829811bced1cccb2ab58ea58 differ
diff --git a/fuzzers/corpora/commit_graph/b43daf9f87a514bce74af3e5a39284c69c4e7011 b/fuzzers/corpora/commit_graph/b43daf9f87a514bce74af3e5a39284c69c4e7011
new file mode 100644
index 0000000..5c8129d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b43daf9f87a514bce74af3e5a39284c69c4e7011 differ
diff --git a/fuzzers/corpora/commit_graph/b477da07f3e5796ff4a98c8a5bdb0e4a634954bf b/fuzzers/corpora/commit_graph/b477da07f3e5796ff4a98c8a5bdb0e4a634954bf
new file mode 100644
index 0000000..dbe8abe
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b477da07f3e5796ff4a98c8a5bdb0e4a634954bf differ
diff --git a/fuzzers/corpora/commit_graph/b4a2ef09cf59ca5ccf810a6f001cce710cc02f6b b/fuzzers/corpora/commit_graph/b4a2ef09cf59ca5ccf810a6f001cce710cc02f6b
new file mode 100644
index 0000000..3a58173
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b4a2ef09cf59ca5ccf810a6f001cce710cc02f6b differ
diff --git a/fuzzers/corpora/commit_graph/b4b75e588cb83430c502a34ec3dcfaf774a00359 b/fuzzers/corpora/commit_graph/b4b75e588cb83430c502a34ec3dcfaf774a00359
new file mode 100644
index 0000000..4afd452
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b4b75e588cb83430c502a34ec3dcfaf774a00359 differ
diff --git a/fuzzers/corpora/commit_graph/b4ce98acd2b288b6cfc00461e2e15e0f8004030c b/fuzzers/corpora/commit_graph/b4ce98acd2b288b6cfc00461e2e15e0f8004030c
new file mode 100644
index 0000000..a707426
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b4ce98acd2b288b6cfc00461e2e15e0f8004030c differ
diff --git a/fuzzers/corpora/commit_graph/b75563f30f7e4fb369d2449b723ee8b282d03eff b/fuzzers/corpora/commit_graph/b75563f30f7e4fb369d2449b723ee8b282d03eff
new file mode 100644
index 0000000..a101bca
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b75563f30f7e4fb369d2449b723ee8b282d03eff differ
diff --git a/fuzzers/corpora/commit_graph/b7a0a820afa7057081de186728d0d887131d9314 b/fuzzers/corpora/commit_graph/b7a0a820afa7057081de186728d0d887131d9314
new file mode 100644
index 0000000..915cc26
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b7a0a820afa7057081de186728d0d887131d9314 differ
diff --git a/fuzzers/corpora/commit_graph/b7e880446146c735a3f820fb93969c8c172c2fb5 b/fuzzers/corpora/commit_graph/b7e880446146c735a3f820fb93969c8c172c2fb5
new file mode 100644
index 0000000..cd26631
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b7e880446146c735a3f820fb93969c8c172c2fb5 differ
diff --git a/fuzzers/corpora/commit_graph/b833073d3006e7cbac03c494603a9b75e7b2a723 b/fuzzers/corpora/commit_graph/b833073d3006e7cbac03c494603a9b75e7b2a723
new file mode 100644
index 0000000..0798037
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b833073d3006e7cbac03c494603a9b75e7b2a723 differ
diff --git a/fuzzers/corpora/commit_graph/b89459c1fb6fc918db4c81a32a75ee66217f9ab8 b/fuzzers/corpora/commit_graph/b89459c1fb6fc918db4c81a32a75ee66217f9ab8
new file mode 100644
index 0000000..bdc6de6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b89459c1fb6fc918db4c81a32a75ee66217f9ab8 differ
diff --git a/fuzzers/corpora/commit_graph/b8aab6c9b2c706f8df0ff695ff94969171f9c807 b/fuzzers/corpora/commit_graph/b8aab6c9b2c706f8df0ff695ff94969171f9c807
new file mode 100644
index 0000000..810a305
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b8aab6c9b2c706f8df0ff695ff94969171f9c807 differ
diff --git a/fuzzers/corpora/commit_graph/b9751182a36acb79b77585e1e379857a530e95c8 b/fuzzers/corpora/commit_graph/b9751182a36acb79b77585e1e379857a530e95c8
new file mode 100644
index 0000000..eeb1ed0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b9751182a36acb79b77585e1e379857a530e95c8 differ
diff --git a/fuzzers/corpora/commit_graph/b9ddb239b5a2c1348d972ec70a08507c35ba4432 b/fuzzers/corpora/commit_graph/b9ddb239b5a2c1348d972ec70a08507c35ba4432
new file mode 100644
index 0000000..0d746e5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/b9ddb239b5a2c1348d972ec70a08507c35ba4432 differ
diff --git a/fuzzers/corpora/commit_graph/ba8f573256a0fbb95c5626f399ebc3ef50bbd826 b/fuzzers/corpora/commit_graph/ba8f573256a0fbb95c5626f399ebc3ef50bbd826
new file mode 100644
index 0000000..330229e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ba8f573256a0fbb95c5626f399ebc3ef50bbd826 differ
diff --git a/fuzzers/corpora/commit_graph/bc165749042d5425c5d6d4e29b17769a2315a80d b/fuzzers/corpora/commit_graph/bc165749042d5425c5d6d4e29b17769a2315a80d
new file mode 100644
index 0000000..af0d232
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bc165749042d5425c5d6d4e29b17769a2315a80d differ
diff --git a/fuzzers/corpora/commit_graph/bc910bd349319e1ed44d7c7266e3ac99cc29ecc6 b/fuzzers/corpora/commit_graph/bc910bd349319e1ed44d7c7266e3ac99cc29ecc6
new file mode 100644
index 0000000..a38abe5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bc910bd349319e1ed44d7c7266e3ac99cc29ecc6 differ
diff --git a/fuzzers/corpora/commit_graph/bc97b1d4f57eb7770bc3983e2d57c8c01b21d29e b/fuzzers/corpora/commit_graph/bc97b1d4f57eb7770bc3983e2d57c8c01b21d29e
new file mode 100644
index 0000000..631754c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bc97b1d4f57eb7770bc3983e2d57c8c01b21d29e differ
diff --git a/fuzzers/corpora/commit_graph/bd06f768e35ded4437cb88e2bc0ddd0bea3fa84c b/fuzzers/corpora/commit_graph/bd06f768e35ded4437cb88e2bc0ddd0bea3fa84c
new file mode 100644
index 0000000..954e73d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bd06f768e35ded4437cb88e2bc0ddd0bea3fa84c differ
diff --git a/fuzzers/corpora/commit_graph/bd702faff9725a7a1957fd0f85cc52799f37b682 b/fuzzers/corpora/commit_graph/bd702faff9725a7a1957fd0f85cc52799f37b682
new file mode 100644
index 0000000..928fe58
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bd702faff9725a7a1957fd0f85cc52799f37b682 differ
diff --git a/fuzzers/corpora/commit_graph/bee4464861e1cae3cfdd5fbcb340efbf02e8d8ca b/fuzzers/corpora/commit_graph/bee4464861e1cae3cfdd5fbcb340efbf02e8d8ca
new file mode 100644
index 0000000..8f636ce
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bee4464861e1cae3cfdd5fbcb340efbf02e8d8ca differ
diff --git a/fuzzers/corpora/commit_graph/bf7ad994b098ec85d62683a16e067635e21a8af5 b/fuzzers/corpora/commit_graph/bf7ad994b098ec85d62683a16e067635e21a8af5
new file mode 100644
index 0000000..71ca107
Binary files /dev/null and b/fuzzers/corpora/commit_graph/bf7ad994b098ec85d62683a16e067635e21a8af5 differ
diff --git a/fuzzers/corpora/commit_graph/c054fc89ed72101dec861668ff1738ef85b728b9 b/fuzzers/corpora/commit_graph/c054fc89ed72101dec861668ff1738ef85b728b9
new file mode 100644
index 0000000..988ab6b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c054fc89ed72101dec861668ff1738ef85b728b9 differ
diff --git a/fuzzers/corpora/commit_graph/c06752415ac037fefe5172dc7245cd7c49ca7fca b/fuzzers/corpora/commit_graph/c06752415ac037fefe5172dc7245cd7c49ca7fca
new file mode 100644
index 0000000..d03fcac
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c06752415ac037fefe5172dc7245cd7c49ca7fca differ
diff --git a/fuzzers/corpora/commit_graph/c0c8b54354d172a0be751e3e9b80be961bb15ddb b/fuzzers/corpora/commit_graph/c0c8b54354d172a0be751e3e9b80be961bb15ddb
new file mode 100644
index 0000000..233aa4e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c0c8b54354d172a0be751e3e9b80be961bb15ddb differ
diff --git a/fuzzers/corpora/commit_graph/c0e7ca9b5b4d0e72d23d7dc9e9d1f2463a17a20d b/fuzzers/corpora/commit_graph/c0e7ca9b5b4d0e72d23d7dc9e9d1f2463a17a20d
new file mode 100644
index 0000000..c36f7c1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c0e7ca9b5b4d0e72d23d7dc9e9d1f2463a17a20d differ
diff --git a/fuzzers/corpora/commit_graph/c13576a29c98bee02aa47f646f5f170f9b7d83f9 b/fuzzers/corpora/commit_graph/c13576a29c98bee02aa47f646f5f170f9b7d83f9
new file mode 100644
index 0000000..95bdcb9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c13576a29c98bee02aa47f646f5f170f9b7d83f9 differ
diff --git a/fuzzers/corpora/commit_graph/c14edf1d34f40b3cc74772c81ebe5d72172cc662 b/fuzzers/corpora/commit_graph/c14edf1d34f40b3cc74772c81ebe5d72172cc662
new file mode 100644
index 0000000..63b1e39
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c14edf1d34f40b3cc74772c81ebe5d72172cc662 differ
diff --git a/fuzzers/corpora/commit_graph/c2789364cb35d111f08f924d0d7550ea9785c61e b/fuzzers/corpora/commit_graph/c2789364cb35d111f08f924d0d7550ea9785c61e
new file mode 100644
index 0000000..0044eb5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c2789364cb35d111f08f924d0d7550ea9785c61e differ
diff --git a/fuzzers/corpora/commit_graph/c2d8b07acb13e43a89b6c4afb3ecb9817dd4a8e9 b/fuzzers/corpora/commit_graph/c2d8b07acb13e43a89b6c4afb3ecb9817dd4a8e9
new file mode 100644
index 0000000..8cf6a91
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c2d8b07acb13e43a89b6c4afb3ecb9817dd4a8e9 differ
diff --git a/fuzzers/corpora/commit_graph/c36ed796c1bf839668db8fc3475a2ffb32ad8ceb b/fuzzers/corpora/commit_graph/c36ed796c1bf839668db8fc3475a2ffb32ad8ceb
new file mode 100644
index 0000000..77dd76b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c36ed796c1bf839668db8fc3475a2ffb32ad8ceb differ
diff --git a/fuzzers/corpora/commit_graph/c41ec9dd94427423e4704721e7f21eae0c44ef20 b/fuzzers/corpora/commit_graph/c41ec9dd94427423e4704721e7f21eae0c44ef20
new file mode 100644
index 0000000..9b828b8
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c41ec9dd94427423e4704721e7f21eae0c44ef20 differ
diff --git a/fuzzers/corpora/commit_graph/c42c544fa9dbb1264b39bf920b40985384db1d16 b/fuzzers/corpora/commit_graph/c42c544fa9dbb1264b39bf920b40985384db1d16
new file mode 100644
index 0000000..6088980
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c42c544fa9dbb1264b39bf920b40985384db1d16 differ
diff --git a/fuzzers/corpora/commit_graph/c45ec3f594abc15de0a8cc3ad748ba23cb34ec64 b/fuzzers/corpora/commit_graph/c45ec3f594abc15de0a8cc3ad748ba23cb34ec64
new file mode 100644
index 0000000..6a711ba
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c45ec3f594abc15de0a8cc3ad748ba23cb34ec64 differ
diff --git a/fuzzers/corpora/commit_graph/c49004d980961f288616a4eb9ebf68123fd68ffa b/fuzzers/corpora/commit_graph/c49004d980961f288616a4eb9ebf68123fd68ffa
new file mode 100644
index 0000000..0b5a6bc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c49004d980961f288616a4eb9ebf68123fd68ffa differ
diff --git a/fuzzers/corpora/commit_graph/c4c3c3c8df24adf505127627b3090116de78d9a6 b/fuzzers/corpora/commit_graph/c4c3c3c8df24adf505127627b3090116de78d9a6
new file mode 100644
index 0000000..528725c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c4c3c3c8df24adf505127627b3090116de78d9a6 differ
diff --git a/fuzzers/corpora/commit_graph/c5c1921293af4a5953cb386092694042715fcfb3 b/fuzzers/corpora/commit_graph/c5c1921293af4a5953cb386092694042715fcfb3
new file mode 100644
index 0000000..2256d19
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c5c1921293af4a5953cb386092694042715fcfb3 differ
diff --git a/fuzzers/corpora/commit_graph/c615caad21cd8a754fcb2008420234c5511c62b7 b/fuzzers/corpora/commit_graph/c615caad21cd8a754fcb2008420234c5511c62b7
new file mode 100644
index 0000000..fa4c9cc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c615caad21cd8a754fcb2008420234c5511c62b7 differ
diff --git a/fuzzers/corpora/commit_graph/c6a9ee3f8fdc42566c4799db3912a83c8c438d7f b/fuzzers/corpora/commit_graph/c6a9ee3f8fdc42566c4799db3912a83c8c438d7f
new file mode 100644
index 0000000..c3c69fc
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c6a9ee3f8fdc42566c4799db3912a83c8c438d7f differ
diff --git a/fuzzers/corpora/commit_graph/c6b661e976282051285b913b3728383f36103ef8 b/fuzzers/corpora/commit_graph/c6b661e976282051285b913b3728383f36103ef8
new file mode 100644
index 0000000..6a156d2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c6b661e976282051285b913b3728383f36103ef8 differ
diff --git a/fuzzers/corpora/commit_graph/c716ba47f810c238fe7bda1fbdc7b1ccc34e9848 b/fuzzers/corpora/commit_graph/c716ba47f810c238fe7bda1fbdc7b1ccc34e9848
new file mode 100644
index 0000000..271ec76
--- /dev/null
+++ b/fuzzers/corpora/commit_graph/c716ba47f810c238fe7bda1fbdc7b1ccc34e9848
@@ -0,0 +1 @@
+ïïïœïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï@ïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï
\ No newline at end of file
diff --git a/fuzzers/corpora/commit_graph/c85b2fa4421302e2fa333a9e33d59a882aa04f4f b/fuzzers/corpora/commit_graph/c85b2fa4421302e2fa333a9e33d59a882aa04f4f
new file mode 100644
index 0000000..eba46a6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c85b2fa4421302e2fa333a9e33d59a882aa04f4f differ
diff --git a/fuzzers/corpora/commit_graph/c871d135f2d3117b326688355bc0fa6f26d56cd6 b/fuzzers/corpora/commit_graph/c871d135f2d3117b326688355bc0fa6f26d56cd6
new file mode 100644
index 0000000..6ead612
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c871d135f2d3117b326688355bc0fa6f26d56cd6 differ
diff --git a/fuzzers/corpora/commit_graph/c915b02265a27d185a8b028305f082ddb3ebd704 b/fuzzers/corpora/commit_graph/c915b02265a27d185a8b028305f082ddb3ebd704
new file mode 100644
index 0000000..1960dfb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c915b02265a27d185a8b028305f082ddb3ebd704 differ
diff --git a/fuzzers/corpora/commit_graph/c952d38b3e642db4795d7f954b85f4f6d2a041aa b/fuzzers/corpora/commit_graph/c952d38b3e642db4795d7f954b85f4f6d2a041aa
new file mode 100644
index 0000000..b8ee305
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c952d38b3e642db4795d7f954b85f4f6d2a041aa differ
diff --git a/fuzzers/corpora/commit_graph/c98ee52065736c4172f6ee0c31977bf1b560d685 b/fuzzers/corpora/commit_graph/c98ee52065736c4172f6ee0c31977bf1b560d685
new file mode 100644
index 0000000..f8d7a23
Binary files /dev/null and b/fuzzers/corpora/commit_graph/c98ee52065736c4172f6ee0c31977bf1b560d685 differ
diff --git a/fuzzers/corpora/commit_graph/c99b183a2cd0dd8a4c1a141cc6eebb0311501fa5 b/fuzzers/corpora/commit_graph/c99b183a2cd0dd8a4c1a141cc6eebb0311501fa5
new file mode 100644
index 0000000..9cd1ad4
--- /dev/null
+++ b/fuzzers/corpora/commit_graph/c99b183a2cd0dd8a4c1a141cc6eebb0311501fa5
@@ -0,0 +1 @@
+Ëó@ÿ~
\ No newline at end of file
diff --git a/fuzzers/corpora/commit_graph/ca0cd26baff2f2c0759e619800ebbe7314d2bb95 b/fuzzers/corpora/commit_graph/ca0cd26baff2f2c0759e619800ebbe7314d2bb95
new file mode 100644
index 0000000..78a357b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ca0cd26baff2f2c0759e619800ebbe7314d2bb95 differ
diff --git a/fuzzers/corpora/commit_graph/ca3e0d745c35d7cceb0f6e3f8a709eb658b7e5a8 b/fuzzers/corpora/commit_graph/ca3e0d745c35d7cceb0f6e3f8a709eb658b7e5a8
new file mode 100644
index 0000000..174863d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ca3e0d745c35d7cceb0f6e3f8a709eb658b7e5a8 differ
diff --git a/fuzzers/corpora/commit_graph/cac667320e99e93a796bb89842de4675735eb4a4 b/fuzzers/corpora/commit_graph/cac667320e99e93a796bb89842de4675735eb4a4
new file mode 100644
index 0000000..20e9db9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cac667320e99e93a796bb89842de4675735eb4a4 differ
diff --git a/fuzzers/corpora/commit_graph/cb41b00e9db33a07e27b3ee05d3bbecaf853b963 b/fuzzers/corpora/commit_graph/cb41b00e9db33a07e27b3ee05d3bbecaf853b963
new file mode 100644
index 0000000..612843d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cb41b00e9db33a07e27b3ee05d3bbecaf853b963 differ
diff --git a/fuzzers/corpora/commit_graph/cbdbd3f320eee627097778f15b9fb2c1dc2bd15f b/fuzzers/corpora/commit_graph/cbdbd3f320eee627097778f15b9fb2c1dc2bd15f
new file mode 100644
index 0000000..a922018
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cbdbd3f320eee627097778f15b9fb2c1dc2bd15f differ
diff --git a/fuzzers/corpora/commit_graph/cc7f114000c83abb2ab17f0deab6dcfc2acde7f5 b/fuzzers/corpora/commit_graph/cc7f114000c83abb2ab17f0deab6dcfc2acde7f5
new file mode 100644
index 0000000..7c9f84c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cc7f114000c83abb2ab17f0deab6dcfc2acde7f5 differ
diff --git a/fuzzers/corpora/commit_graph/cc9bb93a6b7a1362a15f04898845dbe1447ec382 b/fuzzers/corpora/commit_graph/cc9bb93a6b7a1362a15f04898845dbe1447ec382
new file mode 100644
index 0000000..5dde225
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cc9bb93a6b7a1362a15f04898845dbe1447ec382 differ
diff --git a/fuzzers/corpora/commit_graph/cce7355f826bbcf3955394596d358abc7df6fe6f b/fuzzers/corpora/commit_graph/cce7355f826bbcf3955394596d358abc7df6fe6f
new file mode 100644
index 0000000..9b78038
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cce7355f826bbcf3955394596d358abc7df6fe6f differ
diff --git a/fuzzers/corpora/commit_graph/cceff2878a558166fb5bf2a0354c1be31dcc4e21 b/fuzzers/corpora/commit_graph/cceff2878a558166fb5bf2a0354c1be31dcc4e21
new file mode 100644
index 0000000..94fec1b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cceff2878a558166fb5bf2a0354c1be31dcc4e21 differ
diff --git a/fuzzers/corpora/commit_graph/cd96909f3ded7aa54bb2ffd2f2f47f8acc6f99e2 b/fuzzers/corpora/commit_graph/cd96909f3ded7aa54bb2ffd2f2f47f8acc6f99e2
new file mode 100644
index 0000000..22bbade
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cd96909f3ded7aa54bb2ffd2f2f47f8acc6f99e2 differ
diff --git a/fuzzers/corpora/commit_graph/cee9f69d7d1a227833fba127a529ea2a10341da3 b/fuzzers/corpora/commit_graph/cee9f69d7d1a227833fba127a529ea2a10341da3
new file mode 100644
index 0000000..2fff45e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/cee9f69d7d1a227833fba127a529ea2a10341da3 differ
diff --git a/fuzzers/corpora/commit_graph/d064f27a3109afde629165432f78f389da73ff07 b/fuzzers/corpora/commit_graph/d064f27a3109afde629165432f78f389da73ff07
new file mode 100644
index 0000000..e6d98c0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d064f27a3109afde629165432f78f389da73ff07 differ
diff --git a/fuzzers/corpora/commit_graph/d07e3094f02b0c0e3bab370684c2d8c5634224d5 b/fuzzers/corpora/commit_graph/d07e3094f02b0c0e3bab370684c2d8c5634224d5
new file mode 100644
index 0000000..29d86aa
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d07e3094f02b0c0e3bab370684c2d8c5634224d5 differ
diff --git a/fuzzers/corpora/commit_graph/d0ba3413d5706de17de64824d78233d48c6efbec b/fuzzers/corpora/commit_graph/d0ba3413d5706de17de64824d78233d48c6efbec
new file mode 100644
index 0000000..96c8207
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d0ba3413d5706de17de64824d78233d48c6efbec differ
diff --git a/fuzzers/corpora/commit_graph/d136511364a74973b009f2be9b021d4122f71a6c b/fuzzers/corpora/commit_graph/d136511364a74973b009f2be9b021d4122f71a6c
new file mode 100644
index 0000000..a663ab9
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d136511364a74973b009f2be9b021d4122f71a6c differ
diff --git a/fuzzers/corpora/commit_graph/d1d215c40bcc8dd4ce02b0c0621e90b183b40b3e b/fuzzers/corpora/commit_graph/d1d215c40bcc8dd4ce02b0c0621e90b183b40b3e
new file mode 100644
index 0000000..a328d3e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d1d215c40bcc8dd4ce02b0c0621e90b183b40b3e differ
diff --git a/fuzzers/corpora/commit_graph/d1e35b137b2027b61def408f3f3c8cf9bcab274e b/fuzzers/corpora/commit_graph/d1e35b137b2027b61def408f3f3c8cf9bcab274e
new file mode 100644
index 0000000..79c43fd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d1e35b137b2027b61def408f3f3c8cf9bcab274e differ
diff --git a/fuzzers/corpora/commit_graph/d349d137e57fb1a60ab8babd20e2acedc7a9042e b/fuzzers/corpora/commit_graph/d349d137e57fb1a60ab8babd20e2acedc7a9042e
new file mode 100644
index 0000000..981aaf6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d349d137e57fb1a60ab8babd20e2acedc7a9042e differ
diff --git a/fuzzers/corpora/commit_graph/d3714ec4d3acc6262295b0fc99c6ba699f5bfe65 b/fuzzers/corpora/commit_graph/d3714ec4d3acc6262295b0fc99c6ba699f5bfe65
new file mode 100644
index 0000000..7f6e309
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d3714ec4d3acc6262295b0fc99c6ba699f5bfe65 differ
diff --git a/fuzzers/corpora/commit_graph/d419df696512216074f1c6b17ea1dfc81c0e6e20 b/fuzzers/corpora/commit_graph/d419df696512216074f1c6b17ea1dfc81c0e6e20
new file mode 100644
index 0000000..47c7019
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d419df696512216074f1c6b17ea1dfc81c0e6e20 differ
diff --git a/fuzzers/corpora/commit_graph/d49ad4fdafac251ceec32481826228c1698360aa b/fuzzers/corpora/commit_graph/d49ad4fdafac251ceec32481826228c1698360aa
new file mode 100644
index 0000000..9d4756c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d49ad4fdafac251ceec32481826228c1698360aa differ
diff --git a/fuzzers/corpora/commit_graph/d4f85ba549c87ccaba59971a25da7e07b57c9f4e b/fuzzers/corpora/commit_graph/d4f85ba549c87ccaba59971a25da7e07b57c9f4e
new file mode 100644
index 0000000..e6d72e7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d4f85ba549c87ccaba59971a25da7e07b57c9f4e differ
diff --git a/fuzzers/corpora/commit_graph/d51ade0715bcea7decee2a045934599a10c1b07a b/fuzzers/corpora/commit_graph/d51ade0715bcea7decee2a045934599a10c1b07a
new file mode 100644
index 0000000..2403b35
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d51ade0715bcea7decee2a045934599a10c1b07a differ
diff --git a/fuzzers/corpora/commit_graph/d5447fb72c97462a3f47c8b2d55deb0afaa225f8 b/fuzzers/corpora/commit_graph/d5447fb72c97462a3f47c8b2d55deb0afaa225f8
new file mode 100644
index 0000000..07e14a4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d5447fb72c97462a3f47c8b2d55deb0afaa225f8 differ
diff --git a/fuzzers/corpora/commit_graph/d6611a91c29291872ed2932455cb15ddb3801323 b/fuzzers/corpora/commit_graph/d6611a91c29291872ed2932455cb15ddb3801323
new file mode 100644
index 0000000..361431c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d6611a91c29291872ed2932455cb15ddb3801323 differ
diff --git a/fuzzers/corpora/commit_graph/d676f5e7efd6de6f2e1773231479471d2bba7261 b/fuzzers/corpora/commit_graph/d676f5e7efd6de6f2e1773231479471d2bba7261
new file mode 100644
index 0000000..f9756ab
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d676f5e7efd6de6f2e1773231479471d2bba7261 differ
diff --git a/fuzzers/corpora/commit_graph/d6a21eaa08a957d8f428192e193c2508fca2c218 b/fuzzers/corpora/commit_graph/d6a21eaa08a957d8f428192e193c2508fca2c218
new file mode 100644
index 0000000..f845fbb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d6a21eaa08a957d8f428192e193c2508fca2c218 differ
diff --git a/fuzzers/corpora/commit_graph/d778052a29539344a9e3144e262e68df9628ebde b/fuzzers/corpora/commit_graph/d778052a29539344a9e3144e262e68df9628ebde
new file mode 100644
index 0000000..beace90
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d778052a29539344a9e3144e262e68df9628ebde differ
diff --git a/fuzzers/corpora/commit_graph/d884f6944adfff7cb41728062bf91cac5cdacfc9 b/fuzzers/corpora/commit_graph/d884f6944adfff7cb41728062bf91cac5cdacfc9
new file mode 100644
index 0000000..f6de651
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d884f6944adfff7cb41728062bf91cac5cdacfc9 differ
diff --git a/fuzzers/corpora/commit_graph/d89aae18d8e320bbae55eaae6a0514d7e005a883 b/fuzzers/corpora/commit_graph/d89aae18d8e320bbae55eaae6a0514d7e005a883
new file mode 100644
index 0000000..1f0bbf3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d89aae18d8e320bbae55eaae6a0514d7e005a883 differ
diff --git a/fuzzers/corpora/commit_graph/d926fde818c63f7b34f38c9f018bc833bc0bf7e1 b/fuzzers/corpora/commit_graph/d926fde818c63f7b34f38c9f018bc833bc0bf7e1
new file mode 100644
index 0000000..fe1e274
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d926fde818c63f7b34f38c9f018bc833bc0bf7e1 differ
diff --git a/fuzzers/corpora/commit_graph/d9d542d7c56774143cb6362e5a63739055469349 b/fuzzers/corpora/commit_graph/d9d542d7c56774143cb6362e5a63739055469349
new file mode 100644
index 0000000..946106f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/d9d542d7c56774143cb6362e5a63739055469349 differ
diff --git a/fuzzers/corpora/commit_graph/da99bc9ce5b831f132dfb2eb11b8537e5cccfcd4 b/fuzzers/corpora/commit_graph/da99bc9ce5b831f132dfb2eb11b8537e5cccfcd4
new file mode 100644
index 0000000..91ed5b2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/da99bc9ce5b831f132dfb2eb11b8537e5cccfcd4 differ
diff --git a/fuzzers/corpora/commit_graph/dabff2729fa69ab507fb00b7392aee1262056a29 b/fuzzers/corpora/commit_graph/dabff2729fa69ab507fb00b7392aee1262056a29
new file mode 100644
index 0000000..9318cec
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dabff2729fa69ab507fb00b7392aee1262056a29 differ
diff --git a/fuzzers/corpora/commit_graph/dac4f4b91e33847bcedf7c66ef6e4ad0181e8ad8 b/fuzzers/corpora/commit_graph/dac4f4b91e33847bcedf7c66ef6e4ad0181e8ad8
new file mode 100644
index 0000000..9587c53
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dac4f4b91e33847bcedf7c66ef6e4ad0181e8ad8 differ
diff --git a/fuzzers/corpora/commit_graph/db10ff6d01c7a66aa1823b9f99193590ddce99c6 b/fuzzers/corpora/commit_graph/db10ff6d01c7a66aa1823b9f99193590ddce99c6
new file mode 100644
index 0000000..2d8d099
Binary files /dev/null and b/fuzzers/corpora/commit_graph/db10ff6d01c7a66aa1823b9f99193590ddce99c6 differ
diff --git a/fuzzers/corpora/commit_graph/dbbda2208fa688a5275dda0d304630db01ca081d b/fuzzers/corpora/commit_graph/dbbda2208fa688a5275dda0d304630db01ca081d
new file mode 100644
index 0000000..7edfc3b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dbbda2208fa688a5275dda0d304630db01ca081d differ
diff --git a/fuzzers/corpora/commit_graph/dc47c5037be68a2747ff8a9fa450e1078a5ac5a5 b/fuzzers/corpora/commit_graph/dc47c5037be68a2747ff8a9fa450e1078a5ac5a5
new file mode 100644
index 0000000..e4ac972
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dc47c5037be68a2747ff8a9fa450e1078a5ac5a5 differ
diff --git a/fuzzers/corpora/commit_graph/dc760f136b123e38677aec72853e3365f08010fc b/fuzzers/corpora/commit_graph/dc760f136b123e38677aec72853e3365f08010fc
new file mode 100644
index 0000000..855c7b3
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dc760f136b123e38677aec72853e3365f08010fc differ
diff --git a/fuzzers/corpora/commit_graph/dca41b901bf1612d4197e6a450366a00ac036ec3 b/fuzzers/corpora/commit_graph/dca41b901bf1612d4197e6a450366a00ac036ec3
new file mode 100644
index 0000000..9eec273
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dca41b901bf1612d4197e6a450366a00ac036ec3 differ
diff --git a/fuzzers/corpora/commit_graph/dca62f21fce50d1c8c51b82e0d7eeedc6746e652 b/fuzzers/corpora/commit_graph/dca62f21fce50d1c8c51b82e0d7eeedc6746e652
new file mode 100644
index 0000000..f8188c6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dca62f21fce50d1c8c51b82e0d7eeedc6746e652 differ
diff --git a/fuzzers/corpora/commit_graph/dcc7e6c444f95b10d634b1137413824e2cd68f62 b/fuzzers/corpora/commit_graph/dcc7e6c444f95b10d634b1137413824e2cd68f62
new file mode 100644
index 0000000..247d648
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dcc7e6c444f95b10d634b1137413824e2cd68f62 differ
diff --git a/fuzzers/corpora/commit_graph/dcf4b6addda69040f792c9b860ade2af0b77a14c b/fuzzers/corpora/commit_graph/dcf4b6addda69040f792c9b860ade2af0b77a14c
new file mode 100644
index 0000000..6cbb0b7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dcf4b6addda69040f792c9b860ade2af0b77a14c differ
diff --git a/fuzzers/corpora/commit_graph/dd6178166ac1eed82d132fea491bcda0d953227c b/fuzzers/corpora/commit_graph/dd6178166ac1eed82d132fea491bcda0d953227c
new file mode 100644
index 0000000..4c13f99
Binary files /dev/null and b/fuzzers/corpora/commit_graph/dd6178166ac1eed82d132fea491bcda0d953227c differ
diff --git a/fuzzers/corpora/commit_graph/ddbd5d3074323ccd7cd70bf5de5a2f30de977d99 b/fuzzers/corpora/commit_graph/ddbd5d3074323ccd7cd70bf5de5a2f30de977d99
new file mode 100644
index 0000000..646febd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ddbd5d3074323ccd7cd70bf5de5a2f30de977d99 differ
diff --git a/fuzzers/corpora/commit_graph/ddd8ec5632bf1b8153d03a4537d3d76517c497d5 b/fuzzers/corpora/commit_graph/ddd8ec5632bf1b8153d03a4537d3d76517c497d5
new file mode 100644
index 0000000..e948534
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ddd8ec5632bf1b8153d03a4537d3d76517c497d5 differ
diff --git a/fuzzers/corpora/commit_graph/de7a56f36e10d7b9ff43160b1cea3e76b24386d1 b/fuzzers/corpora/commit_graph/de7a56f36e10d7b9ff43160b1cea3e76b24386d1
new file mode 100644
index 0000000..6cae1f2
Binary files /dev/null and b/fuzzers/corpora/commit_graph/de7a56f36e10d7b9ff43160b1cea3e76b24386d1 differ
diff --git a/fuzzers/corpora/commit_graph/defa60aa46ea5a47c09b6962b4e4296ef1bcad92 b/fuzzers/corpora/commit_graph/defa60aa46ea5a47c09b6962b4e4296ef1bcad92
new file mode 100644
index 0000000..2978755
Binary files /dev/null and b/fuzzers/corpora/commit_graph/defa60aa46ea5a47c09b6962b4e4296ef1bcad92 differ
diff --git a/fuzzers/corpora/commit_graph/e0ae419425207832518d66c0ef35d11cbdc20361 b/fuzzers/corpora/commit_graph/e0ae419425207832518d66c0ef35d11cbdc20361
new file mode 100644
index 0000000..89404f4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e0ae419425207832518d66c0ef35d11cbdc20361 differ
diff --git a/fuzzers/corpora/commit_graph/e0f519accbf15bc57a1bf1d7cc46d2a0b07a67f5 b/fuzzers/corpora/commit_graph/e0f519accbf15bc57a1bf1d7cc46d2a0b07a67f5
new file mode 100644
index 0000000..af59e9d
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e0f519accbf15bc57a1bf1d7cc46d2a0b07a67f5 differ
diff --git a/fuzzers/corpora/commit_graph/e128eff8ca7572d9bb0bfc84f64d79c52afc2c67 b/fuzzers/corpora/commit_graph/e128eff8ca7572d9bb0bfc84f64d79c52afc2c67
new file mode 100644
index 0000000..d963f77
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e128eff8ca7572d9bb0bfc84f64d79c52afc2c67 differ
diff --git a/fuzzers/corpora/commit_graph/e17fdc21ae03243bd1d31bb6301b4187cab6fe47 b/fuzzers/corpora/commit_graph/e17fdc21ae03243bd1d31bb6301b4187cab6fe47
new file mode 100644
index 0000000..381f8e1
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e17fdc21ae03243bd1d31bb6301b4187cab6fe47 differ
diff --git a/fuzzers/corpora/commit_graph/e340ace35a2db7f89d6aa21cc1300766a74be4e1 b/fuzzers/corpora/commit_graph/e340ace35a2db7f89d6aa21cc1300766a74be4e1
new file mode 100644
index 0000000..00cb20b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e340ace35a2db7f89d6aa21cc1300766a74be4e1 differ
diff --git a/fuzzers/corpora/commit_graph/e36dfc11bcaab1e42df13924a2d7da024684db2e b/fuzzers/corpora/commit_graph/e36dfc11bcaab1e42df13924a2d7da024684db2e
new file mode 100644
index 0000000..25dd8ea
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e36dfc11bcaab1e42df13924a2d7da024684db2e differ
diff --git a/fuzzers/corpora/commit_graph/e39e0c87ac5ce0b78c89ae2df84226baba666372 b/fuzzers/corpora/commit_graph/e39e0c87ac5ce0b78c89ae2df84226baba666372
new file mode 100644
index 0000000..acfc881
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e39e0c87ac5ce0b78c89ae2df84226baba666372 differ
diff --git a/fuzzers/corpora/commit_graph/e46b4666c6bfcd6f589ec3617a48cce9c968e833 b/fuzzers/corpora/commit_graph/e46b4666c6bfcd6f589ec3617a48cce9c968e833
new file mode 100644
index 0000000..92bca77
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e46b4666c6bfcd6f589ec3617a48cce9c968e833 differ
diff --git a/fuzzers/corpora/commit_graph/e57219555e11f9221d3166d5029ed2ad92300608 b/fuzzers/corpora/commit_graph/e57219555e11f9221d3166d5029ed2ad92300608
new file mode 100644
index 0000000..6f9d153
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e57219555e11f9221d3166d5029ed2ad92300608 differ
diff --git a/fuzzers/corpora/commit_graph/e58ce590c2454e7ebe18e0a31a943b0b754fbd13 b/fuzzers/corpora/commit_graph/e58ce590c2454e7ebe18e0a31a943b0b754fbd13
new file mode 100644
index 0000000..89d4790
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e58ce590c2454e7ebe18e0a31a943b0b754fbd13 differ
diff --git a/fuzzers/corpora/commit_graph/e595f8fef5c8014cb0867978c6580301078ca0d9 b/fuzzers/corpora/commit_graph/e595f8fef5c8014cb0867978c6580301078ca0d9
new file mode 100644
index 0000000..339b09e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e595f8fef5c8014cb0867978c6580301078ca0d9 differ
diff --git a/fuzzers/corpora/commit_graph/e5b76398f60628e879328d7009b9fa89feea14cb b/fuzzers/corpora/commit_graph/e5b76398f60628e879328d7009b9fa89feea14cb
new file mode 100644
index 0000000..6ed637f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e5b76398f60628e879328d7009b9fa89feea14cb differ
diff --git a/fuzzers/corpora/commit_graph/e5cec0217eea93b18a59d76b0aed6b46b13fa6a9 b/fuzzers/corpora/commit_graph/e5cec0217eea93b18a59d76b0aed6b46b13fa6a9
new file mode 100644
index 0000000..7ae3eb4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e5cec0217eea93b18a59d76b0aed6b46b13fa6a9 differ
diff --git a/fuzzers/corpora/commit_graph/e637b4e0b47d0d6cd870502e6a2d6a53bf917f73 b/fuzzers/corpora/commit_graph/e637b4e0b47d0d6cd870502e6a2d6a53bf917f73
new file mode 100644
index 0000000..f84ee8c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e637b4e0b47d0d6cd870502e6a2d6a53bf917f73 differ
diff --git a/fuzzers/corpora/commit_graph/e7a6cb6e5a1552837fdbee9025fc48a9373f8564 b/fuzzers/corpora/commit_graph/e7a6cb6e5a1552837fdbee9025fc48a9373f8564
new file mode 100644
index 0000000..a5ae268
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e7a6cb6e5a1552837fdbee9025fc48a9373f8564 differ
diff --git a/fuzzers/corpora/commit_graph/e7f57c48016e1180c9af95acd34470881f10bd06 b/fuzzers/corpora/commit_graph/e7f57c48016e1180c9af95acd34470881f10bd06
new file mode 100644
index 0000000..07bbb9c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e7f57c48016e1180c9af95acd34470881f10bd06 differ
diff --git a/fuzzers/corpora/commit_graph/e8253c668bfe37df5c5ada3226860cee74fb33a2 b/fuzzers/corpora/commit_graph/e8253c668bfe37df5c5ada3226860cee74fb33a2
new file mode 100644
index 0000000..0cb7581
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e8253c668bfe37df5c5ada3226860cee74fb33a2 differ
diff --git a/fuzzers/corpora/commit_graph/e8f9981443c34ece02bca3c66130f3429d7b3375 b/fuzzers/corpora/commit_graph/e8f9981443c34ece02bca3c66130f3429d7b3375
new file mode 100644
index 0000000..09fe9dd
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e8f9981443c34ece02bca3c66130f3429d7b3375 differ
diff --git a/fuzzers/corpora/commit_graph/e91ed5416bbcd1b03803197b99c08f42c9869139 b/fuzzers/corpora/commit_graph/e91ed5416bbcd1b03803197b99c08f42c9869139
new file mode 100644
index 0000000..3267ebb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e91ed5416bbcd1b03803197b99c08f42c9869139 differ
diff --git a/fuzzers/corpora/commit_graph/e94201cfa88df7b198abd3abae9007a6780b52a7 b/fuzzers/corpora/commit_graph/e94201cfa88df7b198abd3abae9007a6780b52a7
new file mode 100644
index 0000000..0279a3c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e94201cfa88df7b198abd3abae9007a6780b52a7 differ
diff --git a/fuzzers/corpora/commit_graph/e967bbd6a0d251ae62c9c38b784271d707f792c0 b/fuzzers/corpora/commit_graph/e967bbd6a0d251ae62c9c38b784271d707f792c0
new file mode 100644
index 0000000..2baf050
Binary files /dev/null and b/fuzzers/corpora/commit_graph/e967bbd6a0d251ae62c9c38b784271d707f792c0 differ
diff --git a/fuzzers/corpora/commit_graph/ea01737ceed783b3e0f66d9d0c409cb496c1d526 b/fuzzers/corpora/commit_graph/ea01737ceed783b3e0f66d9d0c409cb496c1d526
new file mode 100644
index 0000000..75c988e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ea01737ceed783b3e0f66d9d0c409cb496c1d526 differ
diff --git a/fuzzers/corpora/commit_graph/ea40f7879a58d1e52a46404c761f76a949e14a31 b/fuzzers/corpora/commit_graph/ea40f7879a58d1e52a46404c761f76a949e14a31
new file mode 100644
index 0000000..0fe4b30
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ea40f7879a58d1e52a46404c761f76a949e14a31 differ
diff --git a/fuzzers/corpora/commit_graph/ea5ad04a54f95963baea1f47845847626e08dd55 b/fuzzers/corpora/commit_graph/ea5ad04a54f95963baea1f47845847626e08dd55
new file mode 100644
index 0000000..79a1c4f
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ea5ad04a54f95963baea1f47845847626e08dd55 differ
diff --git a/fuzzers/corpora/commit_graph/ea608a401f54b0ca70e42b897f0c8ce6efdbc0ef b/fuzzers/corpora/commit_graph/ea608a401f54b0ca70e42b897f0c8ce6efdbc0ef
new file mode 100644
index 0000000..26c55fe
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ea608a401f54b0ca70e42b897f0c8ce6efdbc0ef differ
diff --git a/fuzzers/corpora/commit_graph/eb8700d6b3728e6e70c2a0fe504543771639f2b6 b/fuzzers/corpora/commit_graph/eb8700d6b3728e6e70c2a0fe504543771639f2b6
new file mode 100644
index 0000000..cf35936
Binary files /dev/null and b/fuzzers/corpora/commit_graph/eb8700d6b3728e6e70c2a0fe504543771639f2b6 differ
diff --git a/fuzzers/corpora/commit_graph/ec1f271b04c322353865f4819153d46df7def873 b/fuzzers/corpora/commit_graph/ec1f271b04c322353865f4819153d46df7def873
new file mode 100644
index 0000000..95cfa61
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ec1f271b04c322353865f4819153d46df7def873 differ
diff --git a/fuzzers/corpora/commit_graph/ee215536e7f0cfbd07b53dd65c5af9a604a01830 b/fuzzers/corpora/commit_graph/ee215536e7f0cfbd07b53dd65c5af9a604a01830
new file mode 100644
index 0000000..82241f0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ee215536e7f0cfbd07b53dd65c5af9a604a01830 differ
diff --git a/fuzzers/corpora/commit_graph/ee4d4393d7d79b755f85ef5bf8f6e3d743bfa258 b/fuzzers/corpora/commit_graph/ee4d4393d7d79b755f85ef5bf8f6e3d743bfa258
new file mode 100644
index 0000000..3d0d7d4
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ee4d4393d7d79b755f85ef5bf8f6e3d743bfa258 differ
diff --git a/fuzzers/corpora/commit_graph/ee8099331b2c392e7e036ffcd4a9b36ec2c2082d b/fuzzers/corpora/commit_graph/ee8099331b2c392e7e036ffcd4a9b36ec2c2082d
new file mode 100644
index 0000000..4e8f26b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ee8099331b2c392e7e036ffcd4a9b36ec2c2082d differ
diff --git a/fuzzers/corpora/commit_graph/eede9da76db25513f8347f972e170102831de91a b/fuzzers/corpora/commit_graph/eede9da76db25513f8347f972e170102831de91a
new file mode 100644
index 0000000..d364605
Binary files /dev/null and b/fuzzers/corpora/commit_graph/eede9da76db25513f8347f972e170102831de91a differ
diff --git a/fuzzers/corpora/commit_graph/ef707cdeaa9548b6c820f769c1d8ad607b3c4514 b/fuzzers/corpora/commit_graph/ef707cdeaa9548b6c820f769c1d8ad607b3c4514
new file mode 100644
index 0000000..31daa3b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ef707cdeaa9548b6c820f769c1d8ad607b3c4514 differ
diff --git a/fuzzers/corpora/commit_graph/ef98609d8196dc158365dfcbbc47e3d1699c50c2 b/fuzzers/corpora/commit_graph/ef98609d8196dc158365dfcbbc47e3d1699c50c2
new file mode 100644
index 0000000..6cac849
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ef98609d8196dc158365dfcbbc47e3d1699c50c2 differ
diff --git a/fuzzers/corpora/commit_graph/efa38b4269f978f3714b44b501831bea678244e0 b/fuzzers/corpora/commit_graph/efa38b4269f978f3714b44b501831bea678244e0
new file mode 100644
index 0000000..923b8c5
Binary files /dev/null and b/fuzzers/corpora/commit_graph/efa38b4269f978f3714b44b501831bea678244e0 differ
diff --git a/fuzzers/corpora/commit_graph/efba428e29811d233720ccaaf41966a309312a29 b/fuzzers/corpora/commit_graph/efba428e29811d233720ccaaf41966a309312a29
new file mode 100644
index 0000000..b803c2e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/efba428e29811d233720ccaaf41966a309312a29 differ
diff --git a/fuzzers/corpora/commit_graph/efd514f056d8d83498b4724249c4623560e0390d b/fuzzers/corpora/commit_graph/efd514f056d8d83498b4724249c4623560e0390d
new file mode 100644
index 0000000..d0e1a33
Binary files /dev/null and b/fuzzers/corpora/commit_graph/efd514f056d8d83498b4724249c4623560e0390d differ
diff --git a/fuzzers/corpora/commit_graph/f00e449ba67ef15e7f29df1e6948c28155d72baa b/fuzzers/corpora/commit_graph/f00e449ba67ef15e7f29df1e6948c28155d72baa
new file mode 100644
index 0000000..32153f7
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f00e449ba67ef15e7f29df1e6948c28155d72baa differ
diff --git a/fuzzers/corpora/commit_graph/f0a83929d588466051dced6eae0c387db307d646 b/fuzzers/corpora/commit_graph/f0a83929d588466051dced6eae0c387db307d646
new file mode 100644
index 0000000..fc53a85
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f0a83929d588466051dced6eae0c387db307d646 differ
diff --git a/fuzzers/corpora/commit_graph/f0e53b72e5d69467e7c014474028ea734f4fcb26 b/fuzzers/corpora/commit_graph/f0e53b72e5d69467e7c014474028ea734f4fcb26
new file mode 100644
index 0000000..bad38e8
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f0e53b72e5d69467e7c014474028ea734f4fcb26 differ
diff --git a/fuzzers/corpora/commit_graph/f186265b3f10f4383f4174e9fb74f0a0cdfa3fca b/fuzzers/corpora/commit_graph/f186265b3f10f4383f4174e9fb74f0a0cdfa3fca
new file mode 100644
index 0000000..2cc2dd0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f186265b3f10f4383f4174e9fb74f0a0cdfa3fca differ
diff --git a/fuzzers/corpora/commit_graph/f18932fcce5a9db5d6c8f59d622eabc25e255e12 b/fuzzers/corpora/commit_graph/f18932fcce5a9db5d6c8f59d622eabc25e255e12
new file mode 100644
index 0000000..85c6e0e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f18932fcce5a9db5d6c8f59d622eabc25e255e12 differ
diff --git a/fuzzers/corpora/commit_graph/f2ea163bddb95d67597e2a747779ebf4651cb2a9 b/fuzzers/corpora/commit_graph/f2ea163bddb95d67597e2a747779ebf4651cb2a9
new file mode 100644
index 0000000..f974087
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f2ea163bddb95d67597e2a747779ebf4651cb2a9 differ
diff --git a/fuzzers/corpora/commit_graph/f2f7d48a6d86143ecb4969808d634163576065b1 b/fuzzers/corpora/commit_graph/f2f7d48a6d86143ecb4969808d634163576065b1
new file mode 100644
index 0000000..f2ad4a6
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f2f7d48a6d86143ecb4969808d634163576065b1 differ
diff --git a/fuzzers/corpora/commit_graph/f34a833faf2b0dcbae8aaad142c76c7c7e534e99 b/fuzzers/corpora/commit_graph/f34a833faf2b0dcbae8aaad142c76c7c7e534e99
new file mode 100644
index 0000000..2eaa521
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f34a833faf2b0dcbae8aaad142c76c7c7e534e99 differ
diff --git a/fuzzers/corpora/commit_graph/f5c044ce01645c069334698fb8c4750e44835912 b/fuzzers/corpora/commit_graph/f5c044ce01645c069334698fb8c4750e44835912
new file mode 100644
index 0000000..a67affa
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f5c044ce01645c069334698fb8c4750e44835912 differ
diff --git a/fuzzers/corpora/commit_graph/f680112645c2502f0612e9d017bbb50cb28affbf b/fuzzers/corpora/commit_graph/f680112645c2502f0612e9d017bbb50cb28affbf
new file mode 100644
index 0000000..dec09a8
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f680112645c2502f0612e9d017bbb50cb28affbf differ
diff --git a/fuzzers/corpora/commit_graph/f6b778d1b34415a7715905f54968c8b6eb057912 b/fuzzers/corpora/commit_graph/f6b778d1b34415a7715905f54968c8b6eb057912
new file mode 100644
index 0000000..a93cb66
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f6b778d1b34415a7715905f54968c8b6eb057912 differ
diff --git a/fuzzers/corpora/commit_graph/f6ca6a62dc885c6b2a4b40c4aa1a7cb8118e30bb b/fuzzers/corpora/commit_graph/f6ca6a62dc885c6b2a4b40c4aa1a7cb8118e30bb
new file mode 100644
index 0000000..29ed04c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f6ca6a62dc885c6b2a4b40c4aa1a7cb8118e30bb differ
diff --git a/fuzzers/corpora/commit_graph/f733a8770c23fde182d2fef7e0d96e67244274d5 b/fuzzers/corpora/commit_graph/f733a8770c23fde182d2fef7e0d96e67244274d5
new file mode 100644
index 0000000..c6aa758
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f733a8770c23fde182d2fef7e0d96e67244274d5 differ
diff --git a/fuzzers/corpora/commit_graph/f8529ddf17d4505c0932c3d40abe33cbfd8c6f22 b/fuzzers/corpora/commit_graph/f8529ddf17d4505c0932c3d40abe33cbfd8c6f22
new file mode 100644
index 0000000..f004ecb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f8529ddf17d4505c0932c3d40abe33cbfd8c6f22 differ
diff --git a/fuzzers/corpora/commit_graph/f96f8419a3fc3719ae86d64e1147e7b7f66a2470 b/fuzzers/corpora/commit_graph/f96f8419a3fc3719ae86d64e1147e7b7f66a2470
new file mode 100644
index 0000000..5dee3ca
Binary files /dev/null and b/fuzzers/corpora/commit_graph/f96f8419a3fc3719ae86d64e1147e7b7f66a2470 differ
diff --git a/fuzzers/corpora/commit_graph/fae241a6c87af37781a3b49e534b7ddb6636eda8 b/fuzzers/corpora/commit_graph/fae241a6c87af37781a3b49e534b7ddb6636eda8
new file mode 100644
index 0000000..fc4e26b
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fae241a6c87af37781a3b49e534b7ddb6636eda8 differ
diff --git a/fuzzers/corpora/commit_graph/faf8817a04b77c6a976ab0a3d1e905f79bb7f799 b/fuzzers/corpora/commit_graph/faf8817a04b77c6a976ab0a3d1e905f79bb7f799
new file mode 100644
index 0000000..5164ecb
Binary files /dev/null and b/fuzzers/corpora/commit_graph/faf8817a04b77c6a976ab0a3d1e905f79bb7f799 differ
diff --git a/fuzzers/corpora/commit_graph/fb3e769019fb25d384d4be9d38e4cbce00a6adbc b/fuzzers/corpora/commit_graph/fb3e769019fb25d384d4be9d38e4cbce00a6adbc
new file mode 100644
index 0000000..008337c
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fb3e769019fb25d384d4be9d38e4cbce00a6adbc differ
diff --git a/fuzzers/corpora/commit_graph/fb9b4b2a46f1c65076340a7bd03b076eb101b760 b/fuzzers/corpora/commit_graph/fb9b4b2a46f1c65076340a7bd03b076eb101b760
new file mode 100644
index 0000000..8d0c735
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fb9b4b2a46f1c65076340a7bd03b076eb101b760 differ
diff --git a/fuzzers/corpora/commit_graph/fca9b0a398832c9ba02cdc811f625b97d5beb18e b/fuzzers/corpora/commit_graph/fca9b0a398832c9ba02cdc811f625b97d5beb18e
new file mode 100644
index 0000000..b2681f0
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fca9b0a398832c9ba02cdc811f625b97d5beb18e differ
diff --git a/fuzzers/corpora/commit_graph/fcb1b42c706e61245d5e86f708be777ae63f2772 b/fuzzers/corpora/commit_graph/fcb1b42c706e61245d5e86f708be777ae63f2772
new file mode 100644
index 0000000..a98b661
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fcb1b42c706e61245d5e86f708be777ae63f2772 differ
diff --git a/fuzzers/corpora/commit_graph/fd6c463e7c30b0e51198c0d1ebbea25f20145e3f b/fuzzers/corpora/commit_graph/fd6c463e7c30b0e51198c0d1ebbea25f20145e3f
new file mode 100644
index 0000000..b253321
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fd6c463e7c30b0e51198c0d1ebbea25f20145e3f differ
diff --git a/fuzzers/corpora/commit_graph/fdcbaa49097ad120c6d7709b29d5b65b8cf8e719 b/fuzzers/corpora/commit_graph/fdcbaa49097ad120c6d7709b29d5b65b8cf8e719
new file mode 100644
index 0000000..2167806
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fdcbaa49097ad120c6d7709b29d5b65b8cf8e719 differ
diff --git a/fuzzers/corpora/commit_graph/fe46775b28a2923b8770b44381552a8a1560d875 b/fuzzers/corpora/commit_graph/fe46775b28a2923b8770b44381552a8a1560d875
new file mode 100644
index 0000000..0acef6e
Binary files /dev/null and b/fuzzers/corpora/commit_graph/fe46775b28a2923b8770b44381552a8a1560d875 differ
diff --git a/fuzzers/corpora/commit_graph/ff04441135ef3308fec2687cf688069c6df8aa31 b/fuzzers/corpora/commit_graph/ff04441135ef3308fec2687cf688069c6df8aa31
new file mode 100644
index 0000000..33afa05
Binary files /dev/null and b/fuzzers/corpora/commit_graph/ff04441135ef3308fec2687cf688069c6df8aa31 differ
diff --git a/fuzzers/corpora/midx/037cbbe0dc03807dd9d9e8629f1712d7df34ee18 b/fuzzers/corpora/midx/037cbbe0dc03807dd9d9e8629f1712d7df34ee18
new file mode 100644
index 0000000..2e5bda8
Binary files /dev/null and b/fuzzers/corpora/midx/037cbbe0dc03807dd9d9e8629f1712d7df34ee18 differ
diff --git a/fuzzers/corpora/midx/039ee34fef8f323ed618a10abc0109df123d0cb5 b/fuzzers/corpora/midx/039ee34fef8f323ed618a10abc0109df123d0cb5
new file mode 100644
index 0000000..0c97a38
Binary files /dev/null and b/fuzzers/corpora/midx/039ee34fef8f323ed618a10abc0109df123d0cb5 differ
diff --git a/fuzzers/corpora/midx/054ee2c82bdb6a170106eb5d35f21bde2119d584 b/fuzzers/corpora/midx/054ee2c82bdb6a170106eb5d35f21bde2119d584
new file mode 100644
index 0000000..f7711e4
--- /dev/null
+++ b/fuzzers/corpora/midx/054ee2c82bdb6a170106eb5d35f21bde2119d584
@@ -0,0 +1 @@
+ãMÿãa
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/055ca4cbc961ebf5fd5c922b4f73880d3fbfe39d b/fuzzers/corpora/midx/055ca4cbc961ebf5fd5c922b4f73880d3fbfe39d
new file mode 100644
index 0000000..adb91f9
Binary files /dev/null and b/fuzzers/corpora/midx/055ca4cbc961ebf5fd5c922b4f73880d3fbfe39d differ
diff --git a/fuzzers/corpora/midx/05c4e5eb1b97bc9b6973921fcb30d4c5e2eb79e4 b/fuzzers/corpora/midx/05c4e5eb1b97bc9b6973921fcb30d4c5e2eb79e4
new file mode 100644
index 0000000..1a53734
Binary files /dev/null and b/fuzzers/corpora/midx/05c4e5eb1b97bc9b6973921fcb30d4c5e2eb79e4 differ
diff --git a/fuzzers/corpora/midx/0672eeda541a191cfc68d521a3c7ac0aac4057a6 b/fuzzers/corpora/midx/0672eeda541a191cfc68d521a3c7ac0aac4057a6
new file mode 100644
index 0000000..5b64955
Binary files /dev/null and b/fuzzers/corpora/midx/0672eeda541a191cfc68d521a3c7ac0aac4057a6 differ
diff --git a/fuzzers/corpora/midx/06a58d1bd5562a668ebf01ef297fd774e0e587a6 b/fuzzers/corpora/midx/06a58d1bd5562a668ebf01ef297fd774e0e587a6
new file mode 100644
index 0000000..30e454a
Binary files /dev/null and b/fuzzers/corpora/midx/06a58d1bd5562a668ebf01ef297fd774e0e587a6 differ
diff --git a/fuzzers/corpora/midx/06bf7c2461ae1049030f31b83ae76babfcc20c83 b/fuzzers/corpora/midx/06bf7c2461ae1049030f31b83ae76babfcc20c83
new file mode 100644
index 0000000..10751dc
Binary files /dev/null and b/fuzzers/corpora/midx/06bf7c2461ae1049030f31b83ae76babfcc20c83 differ
diff --git a/fuzzers/corpora/midx/06c2db67ea65758d971346bfd6beaa61ed12f22c b/fuzzers/corpora/midx/06c2db67ea65758d971346bfd6beaa61ed12f22c
new file mode 100644
index 0000000..5641570
Binary files /dev/null and b/fuzzers/corpora/midx/06c2db67ea65758d971346bfd6beaa61ed12f22c differ
diff --git a/fuzzers/corpora/midx/07f88eefaf12609b7370fe78b82be2955f1b41fd b/fuzzers/corpora/midx/07f88eefaf12609b7370fe78b82be2955f1b41fd
new file mode 100644
index 0000000..8e09bb4
Binary files /dev/null and b/fuzzers/corpora/midx/07f88eefaf12609b7370fe78b82be2955f1b41fd differ
diff --git a/fuzzers/corpora/midx/08495c5f3828a56c167de870d385c46ffdce03c5 b/fuzzers/corpora/midx/08495c5f3828a56c167de870d385c46ffdce03c5
new file mode 100644
index 0000000..b4f5697
Binary files /dev/null and b/fuzzers/corpora/midx/08495c5f3828a56c167de870d385c46ffdce03c5 differ
diff --git a/fuzzers/corpora/midx/08ec8594e5b35fb9e8e0726584f720154f0b2b5d b/fuzzers/corpora/midx/08ec8594e5b35fb9e8e0726584f720154f0b2b5d
new file mode 100644
index 0000000..772b4fd
Binary files /dev/null and b/fuzzers/corpora/midx/08ec8594e5b35fb9e8e0726584f720154f0b2b5d differ
diff --git a/fuzzers/corpora/midx/0903e378a493c596298074d6bff8de7f9ac25aa7 b/fuzzers/corpora/midx/0903e378a493c596298074d6bff8de7f9ac25aa7
new file mode 100644
index 0000000..34f5f3b
--- /dev/null
+++ b/fuzzers/corpora/midx/0903e378a493c596298074d6bff8de7f9ac25aa7
@@ -0,0 +1 @@
+ãü7
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/09144a846f90f894049ef8a0ed0cc7ab4588dc6c b/fuzzers/corpora/midx/09144a846f90f894049ef8a0ed0cc7ab4588dc6c
new file mode 100644
index 0000000..ce7a43d
--- /dev/null
+++ b/fuzzers/corpora/midx/09144a846f90f894049ef8a0ed0cc7ab4588dc6c
@@ -0,0 +1 @@
+ÃØseed
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/09b40dd618373bfe4d3f2838f686a70f645e640b b/fuzzers/corpora/midx/09b40dd618373bfe4d3f2838f686a70f645e640b
new file mode 100644
index 0000000..09473b7
Binary files /dev/null and b/fuzzers/corpora/midx/09b40dd618373bfe4d3f2838f686a70f645e640b differ
diff --git a/fuzzers/corpora/midx/0a00ef44d234c18d365ec41724dbf4f21b09d0c5 b/fuzzers/corpora/midx/0a00ef44d234c18d365ec41724dbf4f21b09d0c5
new file mode 100644
index 0000000..861a986
Binary files /dev/null and b/fuzzers/corpora/midx/0a00ef44d234c18d365ec41724dbf4f21b09d0c5 differ
diff --git a/fuzzers/corpora/midx/0a94e9f4a9b8cf56d52a9e3e7f2fa9a0a5c80d30 b/fuzzers/corpora/midx/0a94e9f4a9b8cf56d52a9e3e7f2fa9a0a5c80d30
new file mode 100644
index 0000000..11f08c0
Binary files /dev/null and b/fuzzers/corpora/midx/0a94e9f4a9b8cf56d52a9e3e7f2fa9a0a5c80d30 differ
diff --git a/fuzzers/corpora/midx/0b35a123104b7872a7f15a710a23ef3594ace04d b/fuzzers/corpora/midx/0b35a123104b7872a7f15a710a23ef3594ace04d
new file mode 100644
index 0000000..eac151b
Binary files /dev/null and b/fuzzers/corpora/midx/0b35a123104b7872a7f15a710a23ef3594ace04d differ
diff --git a/fuzzers/corpora/midx/0c3d7e6be32c014ea873440b0f095961d391af1a b/fuzzers/corpora/midx/0c3d7e6be32c014ea873440b0f095961d391af1a
new file mode 100644
index 0000000..e9c6621
Binary files /dev/null and b/fuzzers/corpora/midx/0c3d7e6be32c014ea873440b0f095961d391af1a differ
diff --git a/fuzzers/corpora/midx/0c65de477b89afc312a7e89cde06f8a17f65bd54 b/fuzzers/corpora/midx/0c65de477b89afc312a7e89cde06f8a17f65bd54
new file mode 100644
index 0000000..8f4b25c
Binary files /dev/null and b/fuzzers/corpora/midx/0c65de477b89afc312a7e89cde06f8a17f65bd54 differ
diff --git a/fuzzers/corpora/midx/0c81d0f368e979d2a0eb4598cbf1c9283936ba0c b/fuzzers/corpora/midx/0c81d0f368e979d2a0eb4598cbf1c9283936ba0c
new file mode 100644
index 0000000..a2dd163
Binary files /dev/null and b/fuzzers/corpora/midx/0c81d0f368e979d2a0eb4598cbf1c9283936ba0c differ
diff --git a/fuzzers/corpora/midx/0c95a44ae995070a5279a2991c36de2251081460 b/fuzzers/corpora/midx/0c95a44ae995070a5279a2991c36de2251081460
new file mode 100644
index 0000000..821b07b
Binary files /dev/null and b/fuzzers/corpora/midx/0c95a44ae995070a5279a2991c36de2251081460 differ
diff --git a/fuzzers/corpora/midx/0de38e2cb13167df7d5a882570633596f64bc4f4 b/fuzzers/corpora/midx/0de38e2cb13167df7d5a882570633596f64bc4f4
new file mode 100644
index 0000000..80a27f6
Binary files /dev/null and b/fuzzers/corpora/midx/0de38e2cb13167df7d5a882570633596f64bc4f4 differ
diff --git a/fuzzers/corpora/midx/0de96aa193045315457ade63c2614610c503db9e b/fuzzers/corpora/midx/0de96aa193045315457ade63c2614610c503db9e
new file mode 100644
index 0000000..342c6c9
Binary files /dev/null and b/fuzzers/corpora/midx/0de96aa193045315457ade63c2614610c503db9e differ
diff --git a/fuzzers/corpora/midx/0e02deca2b16d71f8637933bd56dc8592ed9fdff b/fuzzers/corpora/midx/0e02deca2b16d71f8637933bd56dc8592ed9fdff
new file mode 100644
index 0000000..d3b5fe2
--- /dev/null
+++ b/fuzzers/corpora/midx/0e02deca2b16d71f8637933bd56dc8592ed9fdff
@@ -0,0 +1 @@
+ãH
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/0e44fc9176fe2c1bae4209369da5bc057f54b2d2 b/fuzzers/corpora/midx/0e44fc9176fe2c1bae4209369da5bc057f54b2d2
new file mode 100644
index 0000000..7469002
Binary files /dev/null and b/fuzzers/corpora/midx/0e44fc9176fe2c1bae4209369da5bc057f54b2d2 differ
diff --git a/fuzzers/corpora/midx/0f6c5fc9b6a68835364bbef8937560ee5a481938 b/fuzzers/corpora/midx/0f6c5fc9b6a68835364bbef8937560ee5a481938
new file mode 100644
index 0000000..309e2d8
--- /dev/null
+++ b/fuzzers/corpora/midx/0f6c5fc9b6a68835364bbef8937560ee5a481938
@@ -0,0 +1 @@
+©*
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/10d542d5c7da060a5f0664e21478a0d598e29844 b/fuzzers/corpora/midx/10d542d5c7da060a5f0664e21478a0d598e29844
new file mode 100644
index 0000000..777d32a
Binary files /dev/null and b/fuzzers/corpora/midx/10d542d5c7da060a5f0664e21478a0d598e29844 differ
diff --git a/fuzzers/corpora/midx/118735f7786ae6b4c2f6b36314ab1f2cafe9c3c8 b/fuzzers/corpora/midx/118735f7786ae6b4c2f6b36314ab1f2cafe9c3c8
new file mode 100644
index 0000000..a91dbc9
--- /dev/null
+++ b/fuzzers/corpora/midx/118735f7786ae6b4c2f6b36314ab1f2cafe9c3c8
@@ -0,0 +1 @@
+ãÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛŠÛÛÛÛÛÛÛÛÛÛËÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛËÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/119b58eb353aa344264005016297fb911510ea0d b/fuzzers/corpora/midx/119b58eb353aa344264005016297fb911510ea0d
new file mode 100644
index 0000000..b4883c2
Binary files /dev/null and b/fuzzers/corpora/midx/119b58eb353aa344264005016297fb911510ea0d differ
diff --git a/fuzzers/corpora/midx/127626832c30d6d94bb29384c0fde7ac6bca75ec b/fuzzers/corpora/midx/127626832c30d6d94bb29384c0fde7ac6bca75ec
new file mode 100644
index 0000000..3a0fe06
Binary files /dev/null and b/fuzzers/corpora/midx/127626832c30d6d94bb29384c0fde7ac6bca75ec differ
diff --git a/fuzzers/corpora/midx/1284f1a162588d4de87ca17149474644a0863b27 b/fuzzers/corpora/midx/1284f1a162588d4de87ca17149474644a0863b27
new file mode 100644
index 0000000..03a9f97
Binary files /dev/null and b/fuzzers/corpora/midx/1284f1a162588d4de87ca17149474644a0863b27 differ
diff --git a/fuzzers/corpora/midx/1458599f19f1a967c787562bf8ec3e67677da9c8 b/fuzzers/corpora/midx/1458599f19f1a967c787562bf8ec3e67677da9c8
new file mode 100644
index 0000000..e9dc36e
Binary files /dev/null and b/fuzzers/corpora/midx/1458599f19f1a967c787562bf8ec3e67677da9c8 differ
diff --git a/fuzzers/corpora/midx/14ba6c1ddd05b22c6f2eae5f894721cd3efcbb16 b/fuzzers/corpora/midx/14ba6c1ddd05b22c6f2eae5f894721cd3efcbb16
new file mode 100644
index 0000000..e0f281c
Binary files /dev/null and b/fuzzers/corpora/midx/14ba6c1ddd05b22c6f2eae5f894721cd3efcbb16 differ
diff --git a/fuzzers/corpora/midx/158cdc0a5aa005f167a8588d0beed9eee4aa36f2 b/fuzzers/corpora/midx/158cdc0a5aa005f167a8588d0beed9eee4aa36f2
new file mode 100644
index 0000000..98de253
Binary files /dev/null and b/fuzzers/corpora/midx/158cdc0a5aa005f167a8588d0beed9eee4aa36f2 differ
diff --git a/fuzzers/corpora/midx/15dafc6fa800327f694b5eb2fc4ebf007be9c117 b/fuzzers/corpora/midx/15dafc6fa800327f694b5eb2fc4ebf007be9c117
new file mode 100644
index 0000000..ff07ca2
Binary files /dev/null and b/fuzzers/corpora/midx/15dafc6fa800327f694b5eb2fc4ebf007be9c117 differ
diff --git a/fuzzers/corpora/midx/1613ed4b2e909871f8897fd6354ff80a4ac12f87 b/fuzzers/corpora/midx/1613ed4b2e909871f8897fd6354ff80a4ac12f87
new file mode 100644
index 0000000..1afb32e
Binary files /dev/null and b/fuzzers/corpora/midx/1613ed4b2e909871f8897fd6354ff80a4ac12f87 differ
diff --git a/fuzzers/corpora/midx/16daf4cb967bb47cf4566e9be7d96d3125bd2e12 b/fuzzers/corpora/midx/16daf4cb967bb47cf4566e9be7d96d3125bd2e12
new file mode 100644
index 0000000..729b22a
Binary files /dev/null and b/fuzzers/corpora/midx/16daf4cb967bb47cf4566e9be7d96d3125bd2e12 differ
diff --git a/fuzzers/corpora/midx/177783dce78efee878f6d6020fd87ab107bb11a1 b/fuzzers/corpora/midx/177783dce78efee878f6d6020fd87ab107bb11a1
new file mode 100644
index 0000000..cc1810e
Binary files /dev/null and b/fuzzers/corpora/midx/177783dce78efee878f6d6020fd87ab107bb11a1 differ
diff --git a/fuzzers/corpora/midx/17a5090400a1fedc45070e4b530a26f320a89097 b/fuzzers/corpora/midx/17a5090400a1fedc45070e4b530a26f320a89097
new file mode 100644
index 0000000..7255c85
Binary files /dev/null and b/fuzzers/corpora/midx/17a5090400a1fedc45070e4b530a26f320a89097 differ
diff --git a/fuzzers/corpora/midx/17dea5cfa498f4d54384289a1daed0d15a85e7cc b/fuzzers/corpora/midx/17dea5cfa498f4d54384289a1daed0d15a85e7cc
new file mode 100644
index 0000000..00572bb
Binary files /dev/null and b/fuzzers/corpora/midx/17dea5cfa498f4d54384289a1daed0d15a85e7cc differ
diff --git a/fuzzers/corpora/midx/17e76ae5b54316679981113f52c27edc87dbcdea b/fuzzers/corpora/midx/17e76ae5b54316679981113f52c27edc87dbcdea
new file mode 100644
index 0000000..5f0e0d5
Binary files /dev/null and b/fuzzers/corpora/midx/17e76ae5b54316679981113f52c27edc87dbcdea differ
diff --git a/fuzzers/corpora/midx/191ed5e9334693c53fc843f692dbc3c2c63e8241 b/fuzzers/corpora/midx/191ed5e9334693c53fc843f692dbc3c2c63e8241
new file mode 100644
index 0000000..17fddd8
Binary files /dev/null and b/fuzzers/corpora/midx/191ed5e9334693c53fc843f692dbc3c2c63e8241 differ
diff --git a/fuzzers/corpora/midx/196a0ba4edb5bbfd66c1cda669abf0496573cf0e b/fuzzers/corpora/midx/196a0ba4edb5bbfd66c1cda669abf0496573cf0e
new file mode 100644
index 0000000..4d68586
Binary files /dev/null and b/fuzzers/corpora/midx/196a0ba4edb5bbfd66c1cda669abf0496573cf0e differ
diff --git a/fuzzers/corpora/midx/19742b6cee79fa5bf9b27dcbe367c82d0a399904 b/fuzzers/corpora/midx/19742b6cee79fa5bf9b27dcbe367c82d0a399904
new file mode 100644
index 0000000..39e7054
Binary files /dev/null and b/fuzzers/corpora/midx/19742b6cee79fa5bf9b27dcbe367c82d0a399904 differ
diff --git a/fuzzers/corpora/midx/1a21d7581d3b0a8d67934d48e91d45bd818836e8 b/fuzzers/corpora/midx/1a21d7581d3b0a8d67934d48e91d45bd818836e8
new file mode 100644
index 0000000..616b808
Binary files /dev/null and b/fuzzers/corpora/midx/1a21d7581d3b0a8d67934d48e91d45bd818836e8 differ
diff --git a/fuzzers/corpora/midx/1b2f96c5d75c7ca09b1012be4e6c3a7b248ed924 b/fuzzers/corpora/midx/1b2f96c5d75c7ca09b1012be4e6c3a7b248ed924
new file mode 100644
index 0000000..148aad9
Binary files /dev/null and b/fuzzers/corpora/midx/1b2f96c5d75c7ca09b1012be4e6c3a7b248ed924 differ
diff --git a/fuzzers/corpora/midx/1b604ff0683d0e23dc7945431f6514ba30d6ca0d b/fuzzers/corpora/midx/1b604ff0683d0e23dc7945431f6514ba30d6ca0d
new file mode 100644
index 0000000..1456048
Binary files /dev/null and b/fuzzers/corpora/midx/1b604ff0683d0e23dc7945431f6514ba30d6ca0d differ
diff --git a/fuzzers/corpora/midx/1b771dd5bd3ae2b1c42c4efe6c896c83b88a4f91 b/fuzzers/corpora/midx/1b771dd5bd3ae2b1c42c4efe6c896c83b88a4f91
new file mode 100644
index 0000000..92f6376
Binary files /dev/null and b/fuzzers/corpora/midx/1b771dd5bd3ae2b1c42c4efe6c896c83b88a4f91 differ
diff --git a/fuzzers/corpora/midx/1b793a4ee73fa8bf423da70fca5f39ef32a8d288 b/fuzzers/corpora/midx/1b793a4ee73fa8bf423da70fca5f39ef32a8d288
new file mode 100644
index 0000000..8c4478c
Binary files /dev/null and b/fuzzers/corpora/midx/1b793a4ee73fa8bf423da70fca5f39ef32a8d288 differ
diff --git a/fuzzers/corpora/midx/1c9599ce00978780519272be279f508c402e3268 b/fuzzers/corpora/midx/1c9599ce00978780519272be279f508c402e3268
new file mode 100644
index 0000000..c70f128
--- /dev/null
+++ b/fuzzers/corpora/midx/1c9599ce00978780519272be279f508c402e3268
@@ -0,0 +1 @@
+ãÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/1cc0068f9f63b12dc8fdd38f9ebfb96c42664e95 b/fuzzers/corpora/midx/1cc0068f9f63b12dc8fdd38f9ebfb96c42664e95
new file mode 100644
index 0000000..c41e6a8
Binary files /dev/null and b/fuzzers/corpora/midx/1cc0068f9f63b12dc8fdd38f9ebfb96c42664e95 differ
diff --git a/fuzzers/corpora/midx/1de6e1f5579da6e5c40f4ee23ac62e29e4f90541 b/fuzzers/corpora/midx/1de6e1f5579da6e5c40f4ee23ac62e29e4f90541
new file mode 100644
index 0000000..d8c3fbf
Binary files /dev/null and b/fuzzers/corpora/midx/1de6e1f5579da6e5c40f4ee23ac62e29e4f90541 differ
diff --git a/fuzzers/corpora/midx/1eec93083260ebfab5f4c6d13119cf27c374b7e9 b/fuzzers/corpora/midx/1eec93083260ebfab5f4c6d13119cf27c374b7e9
new file mode 100644
index 0000000..5f9c27f
Binary files /dev/null and b/fuzzers/corpora/midx/1eec93083260ebfab5f4c6d13119cf27c374b7e9 differ
diff --git a/fuzzers/corpora/midx/1f0f574addd363d1fed131289f301c5c033aaa8f b/fuzzers/corpora/midx/1f0f574addd363d1fed131289f301c5c033aaa8f
new file mode 100644
index 0000000..12cbb60
Binary files /dev/null and b/fuzzers/corpora/midx/1f0f574addd363d1fed131289f301c5c033aaa8f differ
diff --git a/fuzzers/corpora/midx/1f3e85cffdb545c1ba7c8bbe1ca18ec13e341038 b/fuzzers/corpora/midx/1f3e85cffdb545c1ba7c8bbe1ca18ec13e341038
new file mode 100644
index 0000000..36b2d5e
Binary files /dev/null and b/fuzzers/corpora/midx/1f3e85cffdb545c1ba7c8bbe1ca18ec13e341038 differ
diff --git a/fuzzers/corpora/midx/1f6a66a92d5f083a73a82280a0a1ae0800e56ae5 b/fuzzers/corpora/midx/1f6a66a92d5f083a73a82280a0a1ae0800e56ae5
new file mode 100644
index 0000000..ea50ac7
Binary files /dev/null and b/fuzzers/corpora/midx/1f6a66a92d5f083a73a82280a0a1ae0800e56ae5 differ
diff --git a/fuzzers/corpora/midx/208e422322052efcdaeb1a09bbf06c5f476b8efc b/fuzzers/corpora/midx/208e422322052efcdaeb1a09bbf06c5f476b8efc
new file mode 100644
index 0000000..ce98394
Binary files /dev/null and b/fuzzers/corpora/midx/208e422322052efcdaeb1a09bbf06c5f476b8efc differ
diff --git a/fuzzers/corpora/midx/22d75b2c3937957b14eded621b638283ce7fe1fe b/fuzzers/corpora/midx/22d75b2c3937957b14eded621b638283ce7fe1fe
new file mode 100644
index 0000000..0aa34c4
Binary files /dev/null and b/fuzzers/corpora/midx/22d75b2c3937957b14eded621b638283ce7fe1fe differ
diff --git a/fuzzers/corpora/midx/22f90ff68166a409acf8f89bf60a31ad2c64ab37 b/fuzzers/corpora/midx/22f90ff68166a409acf8f89bf60a31ad2c64ab37
new file mode 100644
index 0000000..cdecbb6
Binary files /dev/null and b/fuzzers/corpora/midx/22f90ff68166a409acf8f89bf60a31ad2c64ab37 differ
diff --git a/fuzzers/corpora/midx/236ebad449d432b039d6ace1f250ef1fa2aa364d b/fuzzers/corpora/midx/236ebad449d432b039d6ace1f250ef1fa2aa364d
new file mode 100644
index 0000000..0e213a1
Binary files /dev/null and b/fuzzers/corpora/midx/236ebad449d432b039d6ace1f250ef1fa2aa364d differ
diff --git a/fuzzers/corpora/midx/252a4e4bf7fb21792ec2f305fd88fa7c9168505f b/fuzzers/corpora/midx/252a4e4bf7fb21792ec2f305fd88fa7c9168505f
new file mode 100644
index 0000000..b23555c
Binary files /dev/null and b/fuzzers/corpora/midx/252a4e4bf7fb21792ec2f305fd88fa7c9168505f differ
diff --git a/fuzzers/corpora/midx/259e1faf7b7f12250062d36ded1193a9dbcae0f5 b/fuzzers/corpora/midx/259e1faf7b7f12250062d36ded1193a9dbcae0f5
new file mode 100644
index 0000000..f2f1de5
Binary files /dev/null and b/fuzzers/corpora/midx/259e1faf7b7f12250062d36ded1193a9dbcae0f5 differ
diff --git a/fuzzers/corpora/midx/25ad3dfb655ab4c853d0d277872310d9579c8e83 b/fuzzers/corpora/midx/25ad3dfb655ab4c853d0d277872310d9579c8e83
new file mode 100644
index 0000000..325c385
Binary files /dev/null and b/fuzzers/corpora/midx/25ad3dfb655ab4c853d0d277872310d9579c8e83 differ
diff --git a/fuzzers/corpora/midx/26210f5b8fdbf81b312feea48659ec6e2e083c0b b/fuzzers/corpora/midx/26210f5b8fdbf81b312feea48659ec6e2e083c0b
new file mode 100644
index 0000000..479a291
Binary files /dev/null and b/fuzzers/corpora/midx/26210f5b8fdbf81b312feea48659ec6e2e083c0b differ
diff --git a/fuzzers/corpora/midx/263a2a0915be36d8cb2bc30774e37e0344262347 b/fuzzers/corpora/midx/263a2a0915be36d8cb2bc30774e37e0344262347
new file mode 100644
index 0000000..8a90761
Binary files /dev/null and b/fuzzers/corpora/midx/263a2a0915be36d8cb2bc30774e37e0344262347 differ
diff --git a/fuzzers/corpora/midx/2679bfbc2f4f7c10a304245da4e156e235377b63 b/fuzzers/corpora/midx/2679bfbc2f4f7c10a304245da4e156e235377b63
new file mode 100644
index 0000000..dbf598d
Binary files /dev/null and b/fuzzers/corpora/midx/2679bfbc2f4f7c10a304245da4e156e235377b63 differ
diff --git a/fuzzers/corpora/midx/270b7b567a63dd94bb2a90448bbbc2e2bbc4a261 b/fuzzers/corpora/midx/270b7b567a63dd94bb2a90448bbbc2e2bbc4a261
new file mode 100644
index 0000000..0c08b8c
Binary files /dev/null and b/fuzzers/corpora/midx/270b7b567a63dd94bb2a90448bbbc2e2bbc4a261 differ
diff --git a/fuzzers/corpora/midx/271cd5c5e254a293d115588ee130040ef26b59e8 b/fuzzers/corpora/midx/271cd5c5e254a293d115588ee130040ef26b59e8
new file mode 100644
index 0000000..89309dc
Binary files /dev/null and b/fuzzers/corpora/midx/271cd5c5e254a293d115588ee130040ef26b59e8 differ
diff --git a/fuzzers/corpora/midx/27839a8035b48f8c19ab073808a03a95b6a90cc3 b/fuzzers/corpora/midx/27839a8035b48f8c19ab073808a03a95b6a90cc3
new file mode 100644
index 0000000..4595069
Binary files /dev/null and b/fuzzers/corpora/midx/27839a8035b48f8c19ab073808a03a95b6a90cc3 differ
diff --git a/fuzzers/corpora/midx/2810c385c9285cbdb65bcdab5175999fe547cbad b/fuzzers/corpora/midx/2810c385c9285cbdb65bcdab5175999fe547cbad
new file mode 100644
index 0000000..0d3fc30
Binary files /dev/null and b/fuzzers/corpora/midx/2810c385c9285cbdb65bcdab5175999fe547cbad differ
diff --git a/fuzzers/corpora/midx/28afaf4ab4b092ccf987661e58009f96126bba63 b/fuzzers/corpora/midx/28afaf4ab4b092ccf987661e58009f96126bba63
new file mode 100644
index 0000000..6a29fb1
Binary files /dev/null and b/fuzzers/corpora/midx/28afaf4ab4b092ccf987661e58009f96126bba63 differ
diff --git a/fuzzers/corpora/midx/29f842e86a891cff9f0b44c8aec19f7e23a47000 b/fuzzers/corpora/midx/29f842e86a891cff9f0b44c8aec19f7e23a47000
new file mode 100644
index 0000000..5644eb8
Binary files /dev/null and b/fuzzers/corpora/midx/29f842e86a891cff9f0b44c8aec19f7e23a47000 differ
diff --git a/fuzzers/corpora/midx/2aa2549f617f19402d1feac61d4ca1af3545cc8a b/fuzzers/corpora/midx/2aa2549f617f19402d1feac61d4ca1af3545cc8a
new file mode 100644
index 0000000..7704585
Binary files /dev/null and b/fuzzers/corpora/midx/2aa2549f617f19402d1feac61d4ca1af3545cc8a differ
diff --git a/fuzzers/corpora/midx/2b73c2902eda6da41321493601003b29c3445713 b/fuzzers/corpora/midx/2b73c2902eda6da41321493601003b29c3445713
new file mode 100644
index 0000000..402d066
Binary files /dev/null and b/fuzzers/corpora/midx/2b73c2902eda6da41321493601003b29c3445713 differ
diff --git a/fuzzers/corpora/midx/2bcec1274c5e7b2d7a581d851c016ef5b553fabe b/fuzzers/corpora/midx/2bcec1274c5e7b2d7a581d851c016ef5b553fabe
new file mode 100644
index 0000000..43e18c8
Binary files /dev/null and b/fuzzers/corpora/midx/2bcec1274c5e7b2d7a581d851c016ef5b553fabe differ
diff --git a/fuzzers/corpora/midx/2dd9a328b6d4e29e42684347be5c4b7cd7dc1a66 b/fuzzers/corpora/midx/2dd9a328b6d4e29e42684347be5c4b7cd7dc1a66
new file mode 100644
index 0000000..a3e6da5
Binary files /dev/null and b/fuzzers/corpora/midx/2dd9a328b6d4e29e42684347be5c4b7cd7dc1a66 differ
diff --git a/fuzzers/corpora/midx/2ddc17ee7ee89bb7dbc673328d5f3e55c76e686e b/fuzzers/corpora/midx/2ddc17ee7ee89bb7dbc673328d5f3e55c76e686e
new file mode 100644
index 0000000..7b789f3
Binary files /dev/null and b/fuzzers/corpora/midx/2ddc17ee7ee89bb7dbc673328d5f3e55c76e686e differ
diff --git a/fuzzers/corpora/midx/2f71d5e99dc93618ed99fdb7c244a8f5e4a7eb4a b/fuzzers/corpora/midx/2f71d5e99dc93618ed99fdb7c244a8f5e4a7eb4a
new file mode 100644
index 0000000..7d2f004
Binary files /dev/null and b/fuzzers/corpora/midx/2f71d5e99dc93618ed99fdb7c244a8f5e4a7eb4a differ
diff --git a/fuzzers/corpora/midx/2f7cd0154d71a83e7b104670b2a77fbd285ffde2 b/fuzzers/corpora/midx/2f7cd0154d71a83e7b104670b2a77fbd285ffde2
new file mode 100644
index 0000000..645a39b
Binary files /dev/null and b/fuzzers/corpora/midx/2f7cd0154d71a83e7b104670b2a77fbd285ffde2 differ
diff --git a/fuzzers/corpora/midx/2f9d40ef790f5213234e95d123dce942b2d1d389 b/fuzzers/corpora/midx/2f9d40ef790f5213234e95d123dce942b2d1d389
new file mode 100644
index 0000000..bca2348
Binary files /dev/null and b/fuzzers/corpora/midx/2f9d40ef790f5213234e95d123dce942b2d1d389 differ
diff --git a/fuzzers/corpora/midx/31577bacbca7017308d2a0c9ebfdd4fce513bbe4 b/fuzzers/corpora/midx/31577bacbca7017308d2a0c9ebfdd4fce513bbe4
new file mode 100644
index 0000000..72972b1
Binary files /dev/null and b/fuzzers/corpora/midx/31577bacbca7017308d2a0c9ebfdd4fce513bbe4 differ
diff --git a/fuzzers/corpora/midx/3278f1bab88b80597d0066812d49f8bd3c7b1dcf b/fuzzers/corpora/midx/3278f1bab88b80597d0066812d49f8bd3c7b1dcf
new file mode 100644
index 0000000..4177feb
Binary files /dev/null and b/fuzzers/corpora/midx/3278f1bab88b80597d0066812d49f8bd3c7b1dcf differ
diff --git a/fuzzers/corpora/midx/328160cae6235605ff70951a2f6ac669ba7bb397 b/fuzzers/corpora/midx/328160cae6235605ff70951a2f6ac669ba7bb397
new file mode 100644
index 0000000..1585907
Binary files /dev/null and b/fuzzers/corpora/midx/328160cae6235605ff70951a2f6ac669ba7bb397 differ
diff --git a/fuzzers/corpora/midx/337ed1bf91701a4c8926840259077e55938c6efc b/fuzzers/corpora/midx/337ed1bf91701a4c8926840259077e55938c6efc
new file mode 100644
index 0000000..915128f
Binary files /dev/null and b/fuzzers/corpora/midx/337ed1bf91701a4c8926840259077e55938c6efc differ
diff --git a/fuzzers/corpora/midx/33a97d83ff7a774797b1751ea4bffbb4a22c58d9 b/fuzzers/corpora/midx/33a97d83ff7a774797b1751ea4bffbb4a22c58d9
new file mode 100644
index 0000000..852d8dc
Binary files /dev/null and b/fuzzers/corpora/midx/33a97d83ff7a774797b1751ea4bffbb4a22c58d9 differ
diff --git a/fuzzers/corpora/midx/341021da9516401cf364ed2b7dfdda346db04f2f b/fuzzers/corpora/midx/341021da9516401cf364ed2b7dfdda346db04f2f
new file mode 100644
index 0000000..13c21ab
Binary files /dev/null and b/fuzzers/corpora/midx/341021da9516401cf364ed2b7dfdda346db04f2f differ
diff --git a/fuzzers/corpora/midx/341773a439cdecc58f55fb205ac584cd93ffe0f2 b/fuzzers/corpora/midx/341773a439cdecc58f55fb205ac584cd93ffe0f2
new file mode 100644
index 0000000..0446a88
--- /dev/null
+++ b/fuzzers/corpora/midx/341773a439cdecc58f55fb205ac584cd93ffe0f2
@@ -0,0 +1 @@
+ãyyyyyššyyyyyyyyÅÅ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/366091157510e40bca08fc2102b9018ccf4697de b/fuzzers/corpora/midx/366091157510e40bca08fc2102b9018ccf4697de
new file mode 100644
index 0000000..f2148a1
Binary files /dev/null and b/fuzzers/corpora/midx/366091157510e40bca08fc2102b9018ccf4697de differ
diff --git a/fuzzers/corpora/midx/37096157e2f9f2ec8e0b97b21d335bd653f3edbd b/fuzzers/corpora/midx/37096157e2f9f2ec8e0b97b21d335bd653f3edbd
new file mode 100644
index 0000000..03600aa
Binary files /dev/null and b/fuzzers/corpora/midx/37096157e2f9f2ec8e0b97b21d335bd653f3edbd differ
diff --git a/fuzzers/corpora/midx/373a74b8613d09babcb567f91047e7b556a8de90 b/fuzzers/corpora/midx/373a74b8613d09babcb567f91047e7b556a8de90
new file mode 100644
index 0000000..9427eb0
Binary files /dev/null and b/fuzzers/corpora/midx/373a74b8613d09babcb567f91047e7b556a8de90 differ
diff --git a/fuzzers/corpora/midx/3748b07ee7bec7bdd202ee14222cefca182417d1 b/fuzzers/corpora/midx/3748b07ee7bec7bdd202ee14222cefca182417d1
new file mode 100644
index 0000000..9699411
Binary files /dev/null and b/fuzzers/corpora/midx/3748b07ee7bec7bdd202ee14222cefca182417d1 differ
diff --git a/fuzzers/corpora/midx/38b7906b9f956dca01dc92d0a901388ec1cbc8b1 b/fuzzers/corpora/midx/38b7906b9f956dca01dc92d0a901388ec1cbc8b1
new file mode 100644
index 0000000..d7b26a3
Binary files /dev/null and b/fuzzers/corpora/midx/38b7906b9f956dca01dc92d0a901388ec1cbc8b1 differ
diff --git a/fuzzers/corpora/midx/38ddf3424559f1a6e7687eff8469a358184b833b b/fuzzers/corpora/midx/38ddf3424559f1a6e7687eff8469a358184b833b
new file mode 100644
index 0000000..972dd75
--- /dev/null
+++ b/fuzzers/corpora/midx/38ddf3424559f1a6e7687eff8469a358184b833b
@@ -0,0 +1 @@
+ðã½D
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/38e31d0a7dcc3835ce1a4afeeda8446fb3d7ed73 b/fuzzers/corpora/midx/38e31d0a7dcc3835ce1a4afeeda8446fb3d7ed73
new file mode 100644
index 0000000..2afdc8f
Binary files /dev/null and b/fuzzers/corpora/midx/38e31d0a7dcc3835ce1a4afeeda8446fb3d7ed73 differ
diff --git a/fuzzers/corpora/midx/3955ec4497b226391ef9eb40f38af6dee4fa26b7 b/fuzzers/corpora/midx/3955ec4497b226391ef9eb40f38af6dee4fa26b7
new file mode 100644
index 0000000..cff10d8
Binary files /dev/null and b/fuzzers/corpora/midx/3955ec4497b226391ef9eb40f38af6dee4fa26b7 differ
diff --git a/fuzzers/corpora/midx/3b6b424342133feb0f587f22bcd8f21595c004e5 b/fuzzers/corpora/midx/3b6b424342133feb0f587f22bcd8f21595c004e5
new file mode 100644
index 0000000..9f2bea4
Binary files /dev/null and b/fuzzers/corpora/midx/3b6b424342133feb0f587f22bcd8f21595c004e5 differ
diff --git a/fuzzers/corpora/midx/3bb71f41200e0ebf8d19532e7d6e384c48aa2d03 b/fuzzers/corpora/midx/3bb71f41200e0ebf8d19532e7d6e384c48aa2d03
new file mode 100644
index 0000000..28fa133
Binary files /dev/null and b/fuzzers/corpora/midx/3bb71f41200e0ebf8d19532e7d6e384c48aa2d03 differ
diff --git a/fuzzers/corpora/midx/3c5a6063797aba9ffe5ea9903bbfcf87193652d3 b/fuzzers/corpora/midx/3c5a6063797aba9ffe5ea9903bbfcf87193652d3
new file mode 100644
index 0000000..4a5725e
Binary files /dev/null and b/fuzzers/corpora/midx/3c5a6063797aba9ffe5ea9903bbfcf87193652d3 differ
diff --git a/fuzzers/corpora/midx/3dfb9927d959f2462f6944a32d080b60a265abfe b/fuzzers/corpora/midx/3dfb9927d959f2462f6944a32d080b60a265abfe
new file mode 100644
index 0000000..c234cd1
Binary files /dev/null and b/fuzzers/corpora/midx/3dfb9927d959f2462f6944a32d080b60a265abfe differ
diff --git a/fuzzers/corpora/midx/3e19242a63ec92a0c3f7138ebbc31bfe7cbd40cd b/fuzzers/corpora/midx/3e19242a63ec92a0c3f7138ebbc31bfe7cbd40cd
new file mode 100644
index 0000000..c0e1b1d
Binary files /dev/null and b/fuzzers/corpora/midx/3e19242a63ec92a0c3f7138ebbc31bfe7cbd40cd differ
diff --git a/fuzzers/corpora/midx/3ec53ce4ea1f41f040a3c2beed929572af95dd43 b/fuzzers/corpora/midx/3ec53ce4ea1f41f040a3c2beed929572af95dd43
new file mode 100644
index 0000000..9a7ec6f
Binary files /dev/null and b/fuzzers/corpora/midx/3ec53ce4ea1f41f040a3c2beed929572af95dd43 differ
diff --git a/fuzzers/corpora/midx/3f0762fdf49a58c0d8fd6683964a85caddee391b b/fuzzers/corpora/midx/3f0762fdf49a58c0d8fd6683964a85caddee391b
new file mode 100644
index 0000000..aec9b3d
Binary files /dev/null and b/fuzzers/corpora/midx/3f0762fdf49a58c0d8fd6683964a85caddee391b differ
diff --git a/fuzzers/corpora/midx/3f71ae863c4e9bac98e49a554b8ec4d78b17492d b/fuzzers/corpora/midx/3f71ae863c4e9bac98e49a554b8ec4d78b17492d
new file mode 100644
index 0000000..a9e06c7
--- /dev/null
+++ b/fuzzers/corpora/midx/3f71ae863c4e9bac98e49a554b8ec4d78b17492d
@@ -0,0 +1 @@
+ãïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï*ïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïéïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/3f9df30bfb66a28fbe6f1951ef7ae4ca9f19fdf2 b/fuzzers/corpora/midx/3f9df30bfb66a28fbe6f1951ef7ae4ca9f19fdf2
new file mode 100644
index 0000000..ebb1cde
Binary files /dev/null and b/fuzzers/corpora/midx/3f9df30bfb66a28fbe6f1951ef7ae4ca9f19fdf2 differ
diff --git a/fuzzers/corpora/midx/3fabb14670c008c22094c1d7cd7b1e23b4c48b3d b/fuzzers/corpora/midx/3fabb14670c008c22094c1d7cd7b1e23b4c48b3d
new file mode 100644
index 0000000..1d2d082
Binary files /dev/null and b/fuzzers/corpora/midx/3fabb14670c008c22094c1d7cd7b1e23b4c48b3d differ
diff --git a/fuzzers/corpora/midx/408fba9c66c5d1deb31e4c69f1dd0677844dbc1b b/fuzzers/corpora/midx/408fba9c66c5d1deb31e4c69f1dd0677844dbc1b
new file mode 100644
index 0000000..1cded07
Binary files /dev/null and b/fuzzers/corpora/midx/408fba9c66c5d1deb31e4c69f1dd0677844dbc1b differ
diff --git a/fuzzers/corpora/midx/40ca8645081087e950ad61bccf8d43450366356e b/fuzzers/corpora/midx/40ca8645081087e950ad61bccf8d43450366356e
new file mode 100644
index 0000000..834daf8
Binary files /dev/null and b/fuzzers/corpora/midx/40ca8645081087e950ad61bccf8d43450366356e differ
diff --git a/fuzzers/corpora/midx/412faec949b9d04498de939561664ee559a583a7 b/fuzzers/corpora/midx/412faec949b9d04498de939561664ee559a583a7
new file mode 100644
index 0000000..f15b10e
--- /dev/null
+++ b/fuzzers/corpora/midx/412faec949b9d04498de939561664ee559a583a7
@@ -0,0 +1 @@
+ïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïñïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïçïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïÿÿÿÿ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/4148bd5336f89e73b2a5416c67d491c0ec4a2b7d b/fuzzers/corpora/midx/4148bd5336f89e73b2a5416c67d491c0ec4a2b7d
new file mode 100644
index 0000000..894ac62
Binary files /dev/null and b/fuzzers/corpora/midx/4148bd5336f89e73b2a5416c67d491c0ec4a2b7d differ
diff --git a/fuzzers/corpora/midx/41933e61fa20fbe2b190f9ae7ceae4a4b1220021 b/fuzzers/corpora/midx/41933e61fa20fbe2b190f9ae7ceae4a4b1220021
new file mode 100644
index 0000000..727789d
Binary files /dev/null and b/fuzzers/corpora/midx/41933e61fa20fbe2b190f9ae7ceae4a4b1220021 differ
diff --git a/fuzzers/corpora/midx/423d90f3fc7ddc146095ec5a4b4f455aa876b69b b/fuzzers/corpora/midx/423d90f3fc7ddc146095ec5a4b4f455aa876b69b
new file mode 100644
index 0000000..fc73bd0
Binary files /dev/null and b/fuzzers/corpora/midx/423d90f3fc7ddc146095ec5a4b4f455aa876b69b differ
diff --git a/fuzzers/corpora/midx/42a6c52249aa12cfef1db1bf302a483a01c972f3 b/fuzzers/corpora/midx/42a6c52249aa12cfef1db1bf302a483a01c972f3
new file mode 100644
index 0000000..e35ab98
Binary files /dev/null and b/fuzzers/corpora/midx/42a6c52249aa12cfef1db1bf302a483a01c972f3 differ
diff --git a/fuzzers/corpora/midx/42a82726f0e70da9b87b6c52bc1b3415576025f2 b/fuzzers/corpora/midx/42a82726f0e70da9b87b6c52bc1b3415576025f2
new file mode 100644
index 0000000..46117b4
Binary files /dev/null and b/fuzzers/corpora/midx/42a82726f0e70da9b87b6c52bc1b3415576025f2 differ
diff --git a/fuzzers/corpora/midx/4458e19f99e38c61ad9792b0b3bf8ac79f8236f1 b/fuzzers/corpora/midx/4458e19f99e38c61ad9792b0b3bf8ac79f8236f1
new file mode 100644
index 0000000..80407ab
--- /dev/null
+++ b/fuzzers/corpora/midx/4458e19f99e38c61ad9792b0b3bf8ac79f8236f1
@@ -0,0 +1 @@
+ã]]ÿÿÿÿÿÿs4
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/44a4411a8d6ed67ee3ea61d91d2afafe89295b0f b/fuzzers/corpora/midx/44a4411a8d6ed67ee3ea61d91d2afafe89295b0f
new file mode 100644
index 0000000..e9933b1
Binary files /dev/null and b/fuzzers/corpora/midx/44a4411a8d6ed67ee3ea61d91d2afafe89295b0f differ
diff --git a/fuzzers/corpora/midx/44e04754d1b6c0c045e05509dd7033d19a926b10 b/fuzzers/corpora/midx/44e04754d1b6c0c045e05509dd7033d19a926b10
new file mode 100644
index 0000000..5fe8e2e
Binary files /dev/null and b/fuzzers/corpora/midx/44e04754d1b6c0c045e05509dd7033d19a926b10 differ
diff --git a/fuzzers/corpora/midx/45259e9f0a2cc7739a94eccaafb37c1570f73884 b/fuzzers/corpora/midx/45259e9f0a2cc7739a94eccaafb37c1570f73884
new file mode 100644
index 0000000..90134d1
Binary files /dev/null and b/fuzzers/corpora/midx/45259e9f0a2cc7739a94eccaafb37c1570f73884 differ
diff --git a/fuzzers/corpora/midx/46c0d7e952200cabc08b9cd776a9f6759f4208c3 b/fuzzers/corpora/midx/46c0d7e952200cabc08b9cd776a9f6759f4208c3
new file mode 100644
index 0000000..e3a7a83
Binary files /dev/null and b/fuzzers/corpora/midx/46c0d7e952200cabc08b9cd776a9f6759f4208c3 differ
diff --git a/fuzzers/corpora/midx/46deac8631633ea3c32005124e20a2bc2bbabade b/fuzzers/corpora/midx/46deac8631633ea3c32005124e20a2bc2bbabade
new file mode 100644
index 0000000..5f54eac
Binary files /dev/null and b/fuzzers/corpora/midx/46deac8631633ea3c32005124e20a2bc2bbabade differ
diff --git a/fuzzers/corpora/midx/46e7edf6e9d6cbcdabde3b48f1c4efd93be40348 b/fuzzers/corpora/midx/46e7edf6e9d6cbcdabde3b48f1c4efd93be40348
new file mode 100644
index 0000000..0314f2c
Binary files /dev/null and b/fuzzers/corpora/midx/46e7edf6e9d6cbcdabde3b48f1c4efd93be40348 differ
diff --git a/fuzzers/corpora/midx/46fe9556c28c94f7321baa2519a3cbeabbd54d09 b/fuzzers/corpora/midx/46fe9556c28c94f7321baa2519a3cbeabbd54d09
new file mode 100644
index 0000000..75e8e6f
Binary files /dev/null and b/fuzzers/corpora/midx/46fe9556c28c94f7321baa2519a3cbeabbd54d09 differ
diff --git a/fuzzers/corpora/midx/49223681729e73b48b26a2262e4a66b2ba00e176 b/fuzzers/corpora/midx/49223681729e73b48b26a2262e4a66b2ba00e176
new file mode 100644
index 0000000..3068c35
Binary files /dev/null and b/fuzzers/corpora/midx/49223681729e73b48b26a2262e4a66b2ba00e176 differ
diff --git a/fuzzers/corpora/midx/499e61b689f6cc7e4efb0631684739c2a6f97c7d b/fuzzers/corpora/midx/499e61b689f6cc7e4efb0631684739c2a6f97c7d
new file mode 100644
index 0000000..d3c735b
Binary files /dev/null and b/fuzzers/corpora/midx/499e61b689f6cc7e4efb0631684739c2a6f97c7d differ
diff --git a/fuzzers/corpora/midx/4a06ad8c4d717bd048a7a1315a3d609d70f0162d b/fuzzers/corpora/midx/4a06ad8c4d717bd048a7a1315a3d609d70f0162d
new file mode 100644
index 0000000..caef168
Binary files /dev/null and b/fuzzers/corpora/midx/4a06ad8c4d717bd048a7a1315a3d609d70f0162d differ
diff --git a/fuzzers/corpora/midx/4adb7d4791a4c6370478dff2eb987d715554bf09 b/fuzzers/corpora/midx/4adb7d4791a4c6370478dff2eb987d715554bf09
new file mode 100644
index 0000000..ced1477
Binary files /dev/null and b/fuzzers/corpora/midx/4adb7d4791a4c6370478dff2eb987d715554bf09 differ
diff --git a/fuzzers/corpora/midx/4b01c479cdc9b750a31d5e7ac5004309222d218d b/fuzzers/corpora/midx/4b01c479cdc9b750a31d5e7ac5004309222d218d
new file mode 100644
index 0000000..4ea5a88
Binary files /dev/null and b/fuzzers/corpora/midx/4b01c479cdc9b750a31d5e7ac5004309222d218d differ
diff --git a/fuzzers/corpora/midx/4bce7460a6becba6d26984bb438d7d3aa4e4fc56 b/fuzzers/corpora/midx/4bce7460a6becba6d26984bb438d7d3aa4e4fc56
new file mode 100644
index 0000000..41c7c3a
Binary files /dev/null and b/fuzzers/corpora/midx/4bce7460a6becba6d26984bb438d7d3aa4e4fc56 differ
diff --git a/fuzzers/corpora/midx/4cc96483b6800dda296f00887b12a35154115090 b/fuzzers/corpora/midx/4cc96483b6800dda296f00887b12a35154115090
new file mode 100644
index 0000000..4f0179d
Binary files /dev/null and b/fuzzers/corpora/midx/4cc96483b6800dda296f00887b12a35154115090 differ
diff --git a/fuzzers/corpora/midx/4f3aa59bae0619c9a06b631d9cb7767591810ab0 b/fuzzers/corpora/midx/4f3aa59bae0619c9a06b631d9cb7767591810ab0
new file mode 100644
index 0000000..0a67723
Binary files /dev/null and b/fuzzers/corpora/midx/4f3aa59bae0619c9a06b631d9cb7767591810ab0 differ
diff --git a/fuzzers/corpora/midx/501840d963cedd2945018de59e0202444d7ebf4b b/fuzzers/corpora/midx/501840d963cedd2945018de59e0202444d7ebf4b
new file mode 100644
index 0000000..cd26169
Binary files /dev/null and b/fuzzers/corpora/midx/501840d963cedd2945018de59e0202444d7ebf4b differ
diff --git a/fuzzers/corpora/midx/50479958c030d1addceb1ca8c27f24447e555e65 b/fuzzers/corpora/midx/50479958c030d1addceb1ca8c27f24447e555e65
new file mode 100644
index 0000000..22159a4
Binary files /dev/null and b/fuzzers/corpora/midx/50479958c030d1addceb1ca8c27f24447e555e65 differ
diff --git a/fuzzers/corpora/midx/508ba8ef164a809f739834a39d690e700101a7a1 b/fuzzers/corpora/midx/508ba8ef164a809f739834a39d690e700101a7a1
new file mode 100644
index 0000000..7cf01e1
Binary files /dev/null and b/fuzzers/corpora/midx/508ba8ef164a809f739834a39d690e700101a7a1 differ
diff --git a/fuzzers/corpora/midx/521d345313812e54bc6c944485e19dbb39a87768 b/fuzzers/corpora/midx/521d345313812e54bc6c944485e19dbb39a87768
new file mode 100644
index 0000000..6e9550f
Binary files /dev/null and b/fuzzers/corpora/midx/521d345313812e54bc6c944485e19dbb39a87768 differ
diff --git a/fuzzers/corpora/midx/5369d74ac157f85b597c1b28bbd6768105e9327b b/fuzzers/corpora/midx/5369d74ac157f85b597c1b28bbd6768105e9327b
new file mode 100644
index 0000000..bda1f8c
Binary files /dev/null and b/fuzzers/corpora/midx/5369d74ac157f85b597c1b28bbd6768105e9327b differ
diff --git a/fuzzers/corpora/midx/53997b0146ff49bfe464be203b130a67ea93fd26 b/fuzzers/corpora/midx/53997b0146ff49bfe464be203b130a67ea93fd26
new file mode 100644
index 0000000..12ea4cd
Binary files /dev/null and b/fuzzers/corpora/midx/53997b0146ff49bfe464be203b130a67ea93fd26 differ
diff --git a/fuzzers/corpora/midx/560ea8bd7d11b00e0d21631b6d9ec7e63f0a5286 b/fuzzers/corpora/midx/560ea8bd7d11b00e0d21631b6d9ec7e63f0a5286
new file mode 100644
index 0000000..0c984e1
Binary files /dev/null and b/fuzzers/corpora/midx/560ea8bd7d11b00e0d21631b6d9ec7e63f0a5286 differ
diff --git a/fuzzers/corpora/midx/5682ebc6878e247ce9bc636d34ada6ad338fcaf0 b/fuzzers/corpora/midx/5682ebc6878e247ce9bc636d34ada6ad338fcaf0
new file mode 100644
index 0000000..1b88140
Binary files /dev/null and b/fuzzers/corpora/midx/5682ebc6878e247ce9bc636d34ada6ad338fcaf0 differ
diff --git a/fuzzers/corpora/midx/5762abb5234edd913754b69e1ab03274c711ee68 b/fuzzers/corpora/midx/5762abb5234edd913754b69e1ab03274c711ee68
new file mode 100644
index 0000000..6685722
Binary files /dev/null and b/fuzzers/corpora/midx/5762abb5234edd913754b69e1ab03274c711ee68 differ
diff --git a/fuzzers/corpora/midx/579406f055070559bda3c6120107feb3e637c481 b/fuzzers/corpora/midx/579406f055070559bda3c6120107feb3e637c481
new file mode 100644
index 0000000..be7a59b
--- /dev/null
+++ b/fuzzers/corpora/midx/579406f055070559bda3c6120107feb3e637c481
@@ -0,0 +1,2 @@
+ÿ&ã
+ÿÿ)Å
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/5837d16af4a9c1f2616467cc4aa9ec8836e05c58 b/fuzzers/corpora/midx/5837d16af4a9c1f2616467cc4aa9ec8836e05c58
new file mode 100644
index 0000000..69bf0eb
Binary files /dev/null and b/fuzzers/corpora/midx/5837d16af4a9c1f2616467cc4aa9ec8836e05c58 differ
diff --git a/fuzzers/corpora/midx/58901e865fe20b9fa136cca4b253d3ae73c2b78e b/fuzzers/corpora/midx/58901e865fe20b9fa136cca4b253d3ae73c2b78e
new file mode 100644
index 0000000..c360520
Binary files /dev/null and b/fuzzers/corpora/midx/58901e865fe20b9fa136cca4b253d3ae73c2b78e differ
diff --git a/fuzzers/corpora/midx/58a87098a14572e46b53c87340083f999d8fcfc2 b/fuzzers/corpora/midx/58a87098a14572e46b53c87340083f999d8fcfc2
new file mode 100644
index 0000000..f3711cd
Binary files /dev/null and b/fuzzers/corpora/midx/58a87098a14572e46b53c87340083f999d8fcfc2 differ
diff --git a/fuzzers/corpora/midx/59ae139a21448e0eb7371ddc6ef57f0c9dfe9c85 b/fuzzers/corpora/midx/59ae139a21448e0eb7371ddc6ef57f0c9dfe9c85
new file mode 100644
index 0000000..953072c
Binary files /dev/null and b/fuzzers/corpora/midx/59ae139a21448e0eb7371ddc6ef57f0c9dfe9c85 differ
diff --git a/fuzzers/corpora/midx/5a7e81419f895168c555ac9b4e75a1ad4f04b34a b/fuzzers/corpora/midx/5a7e81419f895168c555ac9b4e75a1ad4f04b34a
new file mode 100644
index 0000000..c6b2c58
Binary files /dev/null and b/fuzzers/corpora/midx/5a7e81419f895168c555ac9b4e75a1ad4f04b34a differ
diff --git a/fuzzers/corpora/midx/5b848c1f56a150d64020e9b0bb398a286dca4096 b/fuzzers/corpora/midx/5b848c1f56a150d64020e9b0bb398a286dca4096
new file mode 100644
index 0000000..17e91c1
Binary files /dev/null and b/fuzzers/corpora/midx/5b848c1f56a150d64020e9b0bb398a286dca4096 differ
diff --git a/fuzzers/corpora/midx/5bd311bd846336149b2815666052fdb7e8bf2ea6 b/fuzzers/corpora/midx/5bd311bd846336149b2815666052fdb7e8bf2ea6
new file mode 100644
index 0000000..ccfa796
Binary files /dev/null and b/fuzzers/corpora/midx/5bd311bd846336149b2815666052fdb7e8bf2ea6 differ
diff --git a/fuzzers/corpora/midx/5ce77eb98473a2e01d04909939edf7aabef5762c b/fuzzers/corpora/midx/5ce77eb98473a2e01d04909939edf7aabef5762c
new file mode 100644
index 0000000..b8ed8ee
Binary files /dev/null and b/fuzzers/corpora/midx/5ce77eb98473a2e01d04909939edf7aabef5762c differ
diff --git a/fuzzers/corpora/midx/5e5cd5819811507ac69bd8abad27433ccd6b7521 b/fuzzers/corpora/midx/5e5cd5819811507ac69bd8abad27433ccd6b7521
new file mode 100644
index 0000000..9069e16
Binary files /dev/null and b/fuzzers/corpora/midx/5e5cd5819811507ac69bd8abad27433ccd6b7521 differ
diff --git a/fuzzers/corpora/midx/5ea114ae3dbb140364000c416152b0f32ce3de23 b/fuzzers/corpora/midx/5ea114ae3dbb140364000c416152b0f32ce3de23
new file mode 100644
index 0000000..2c03944
Binary files /dev/null and b/fuzzers/corpora/midx/5ea114ae3dbb140364000c416152b0f32ce3de23 differ
diff --git a/fuzzers/corpora/midx/5f181bb0a79603c84534a9b8e37ecdeb1d2aeeb5 b/fuzzers/corpora/midx/5f181bb0a79603c84534a9b8e37ecdeb1d2aeeb5
new file mode 100644
index 0000000..c1a826f
--- /dev/null
+++ b/fuzzers/corpora/midx/5f181bb0a79603c84534a9b8e37ecdeb1d2aeeb5
@@ -0,0 +1 @@
+ãÂë®<™“ V¨Ý`oÓ¤Ük@rÜshuffleéDHE-PSK-ARÿÿÿÿÿÿÿ'MIDÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛßÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛàÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÙÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÙÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ[ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/5f428ce1169e28353cedb8be3e2f6edd0ef354e4 b/fuzzers/corpora/midx/5f428ce1169e28353cedb8be3e2f6edd0ef354e4
new file mode 100644
index 0000000..e2b0852
Binary files /dev/null and b/fuzzers/corpora/midx/5f428ce1169e28353cedb8be3e2f6edd0ef354e4 differ
diff --git a/fuzzers/corpora/midx/5f9bc7729dc331e3c4d8e52df0688abad6d4aee8 b/fuzzers/corpora/midx/5f9bc7729dc331e3c4d8e52df0688abad6d4aee8
new file mode 100644
index 0000000..31b96f9
Binary files /dev/null and b/fuzzers/corpora/midx/5f9bc7729dc331e3c4d8e52df0688abad6d4aee8 differ
diff --git a/fuzzers/corpora/midx/619527e1d650cd1c26e9bc61e424c9fdc04b17b9 b/fuzzers/corpora/midx/619527e1d650cd1c26e9bc61e424c9fdc04b17b9
new file mode 100644
index 0000000..87c36d7
Binary files /dev/null and b/fuzzers/corpora/midx/619527e1d650cd1c26e9bc61e424c9fdc04b17b9 differ
diff --git a/fuzzers/corpora/midx/625d3676de25188865e05db2a3933c38508406fc b/fuzzers/corpora/midx/625d3676de25188865e05db2a3933c38508406fc
new file mode 100644
index 0000000..95c2db2
Binary files /dev/null and b/fuzzers/corpora/midx/625d3676de25188865e05db2a3933c38508406fc differ
diff --git a/fuzzers/corpora/midx/6368569cfde7fbe369a0ee4695fa4d5a7d7887a6 b/fuzzers/corpora/midx/6368569cfde7fbe369a0ee4695fa4d5a7d7887a6
new file mode 100644
index 0000000..47ffb54
Binary files /dev/null and b/fuzzers/corpora/midx/6368569cfde7fbe369a0ee4695fa4d5a7d7887a6 differ
diff --git a/fuzzers/corpora/midx/6388fe4d630064ea1ea33aa85381d9c82e328e95 b/fuzzers/corpora/midx/6388fe4d630064ea1ea33aa85381d9c82e328e95
new file mode 100644
index 0000000..85cf1e1
Binary files /dev/null and b/fuzzers/corpora/midx/6388fe4d630064ea1ea33aa85381d9c82e328e95 differ
diff --git a/fuzzers/corpora/midx/64cff4e110f0bcb3ea833c1afda6e27a57dac0bc b/fuzzers/corpora/midx/64cff4e110f0bcb3ea833c1afda6e27a57dac0bc
new file mode 100644
index 0000000..29ac450
Binary files /dev/null and b/fuzzers/corpora/midx/64cff4e110f0bcb3ea833c1afda6e27a57dac0bc differ
diff --git a/fuzzers/corpora/midx/66449b87ce47b681c6326f337bebf03366a0ee99 b/fuzzers/corpora/midx/66449b87ce47b681c6326f337bebf03366a0ee99
new file mode 100644
index 0000000..a2b3b25
Binary files /dev/null and b/fuzzers/corpora/midx/66449b87ce47b681c6326f337bebf03366a0ee99 differ
diff --git a/fuzzers/corpora/midx/66ae3584497a1823a955c33e5bc53f7434c13e49 b/fuzzers/corpora/midx/66ae3584497a1823a955c33e5bc53f7434c13e49
new file mode 100644
index 0000000..0d5dcff
Binary files /dev/null and b/fuzzers/corpora/midx/66ae3584497a1823a955c33e5bc53f7434c13e49 differ
diff --git a/fuzzers/corpora/midx/66e238a6ad70fb30c82171ff1b73ea71b4379355 b/fuzzers/corpora/midx/66e238a6ad70fb30c82171ff1b73ea71b4379355
new file mode 100644
index 0000000..6f28e8d
Binary files /dev/null and b/fuzzers/corpora/midx/66e238a6ad70fb30c82171ff1b73ea71b4379355 differ
diff --git a/fuzzers/corpora/midx/66f345dc060ac5a1fe8bcf0828102d072deb1111 b/fuzzers/corpora/midx/66f345dc060ac5a1fe8bcf0828102d072deb1111
new file mode 100644
index 0000000..6d3181f
Binary files /dev/null and b/fuzzers/corpora/midx/66f345dc060ac5a1fe8bcf0828102d072deb1111 differ
diff --git a/fuzzers/corpora/midx/66f839146ef46deed25fd2cd169a4f1a2a3533fa b/fuzzers/corpora/midx/66f839146ef46deed25fd2cd169a4f1a2a3533fa
new file mode 100644
index 0000000..5a6223d
Binary files /dev/null and b/fuzzers/corpora/midx/66f839146ef46deed25fd2cd169a4f1a2a3533fa differ
diff --git a/fuzzers/corpora/midx/671720ee2b7ba45920b41b8016eb5206b88168ee b/fuzzers/corpora/midx/671720ee2b7ba45920b41b8016eb5206b88168ee
new file mode 100644
index 0000000..564ff2b
Binary files /dev/null and b/fuzzers/corpora/midx/671720ee2b7ba45920b41b8016eb5206b88168ee differ
diff --git a/fuzzers/corpora/midx/679c7140ad60ed32aeb7ee464499dd52b0fc212f b/fuzzers/corpora/midx/679c7140ad60ed32aeb7ee464499dd52b0fc212f
new file mode 100644
index 0000000..1891323
Binary files /dev/null and b/fuzzers/corpora/midx/679c7140ad60ed32aeb7ee464499dd52b0fc212f differ
diff --git a/fuzzers/corpora/midx/67c5e6ce7bb47cefe54d749374f3288a2c915936 b/fuzzers/corpora/midx/67c5e6ce7bb47cefe54d749374f3288a2c915936
new file mode 100644
index 0000000..7e3303a
Binary files /dev/null and b/fuzzers/corpora/midx/67c5e6ce7bb47cefe54d749374f3288a2c915936 differ
diff --git a/fuzzers/corpora/midx/69592399b45f2f83e0cc823c5f0e3865ac3fa611 b/fuzzers/corpora/midx/69592399b45f2f83e0cc823c5f0e3865ac3fa611
new file mode 100644
index 0000000..272619c
Binary files /dev/null and b/fuzzers/corpora/midx/69592399b45f2f83e0cc823c5f0e3865ac3fa611 differ
diff --git a/fuzzers/corpora/midx/6abf97508f0ed808b7fe0d9bb2439981153badd2 b/fuzzers/corpora/midx/6abf97508f0ed808b7fe0d9bb2439981153badd2
new file mode 100644
index 0000000..8003633
Binary files /dev/null and b/fuzzers/corpora/midx/6abf97508f0ed808b7fe0d9bb2439981153badd2 differ
diff --git a/fuzzers/corpora/midx/6b2dfb51b35b78680cb02ff54e06f0c983c04866 b/fuzzers/corpora/midx/6b2dfb51b35b78680cb02ff54e06f0c983c04866
new file mode 100644
index 0000000..2909a34
Binary files /dev/null and b/fuzzers/corpora/midx/6b2dfb51b35b78680cb02ff54e06f0c983c04866 differ
diff --git a/fuzzers/corpora/midx/6bbf6ab605fedd41ed6c7581ec9f87c75403e9c3 b/fuzzers/corpora/midx/6bbf6ab605fedd41ed6c7581ec9f87c75403e9c3
new file mode 100644
index 0000000..d41ae61
Binary files /dev/null and b/fuzzers/corpora/midx/6bbf6ab605fedd41ed6c7581ec9f87c75403e9c3 differ
diff --git a/fuzzers/corpora/midx/6c0656104902e1323f3a19c46df7cffecae94f1c b/fuzzers/corpora/midx/6c0656104902e1323f3a19c46df7cffecae94f1c
new file mode 100644
index 0000000..a47781b
Binary files /dev/null and b/fuzzers/corpora/midx/6c0656104902e1323f3a19c46df7cffecae94f1c differ
diff --git a/fuzzers/corpora/midx/6c0ce8006b3ebd8202e61fe5f4cc2285248bd1ba b/fuzzers/corpora/midx/6c0ce8006b3ebd8202e61fe5f4cc2285248bd1ba
new file mode 100644
index 0000000..ca2e6fb
Binary files /dev/null and b/fuzzers/corpora/midx/6c0ce8006b3ebd8202e61fe5f4cc2285248bd1ba differ
diff --git a/fuzzers/corpora/midx/6cc635e6dd4e430ed4fb68a9f5add38aa02ae14f b/fuzzers/corpora/midx/6cc635e6dd4e430ed4fb68a9f5add38aa02ae14f
new file mode 100644
index 0000000..8f04f86
Binary files /dev/null and b/fuzzers/corpora/midx/6cc635e6dd4e430ed4fb68a9f5add38aa02ae14f differ
diff --git a/fuzzers/corpora/midx/6d1b281d7bdd9887e53505fd5d040731db18ba48 b/fuzzers/corpora/midx/6d1b281d7bdd9887e53505fd5d040731db18ba48
new file mode 100644
index 0000000..93f359a
Binary files /dev/null and b/fuzzers/corpora/midx/6d1b281d7bdd9887e53505fd5d040731db18ba48 differ
diff --git a/fuzzers/corpora/midx/6d5c35f9d87253b2fbe383bfde3775a9f737da12 b/fuzzers/corpora/midx/6d5c35f9d87253b2fbe383bfde3775a9f737da12
new file mode 100644
index 0000000..fe238cd
--- /dev/null
+++ b/fuzzers/corpora/midx/6d5c35f9d87253b2fbe383bfde3775a9f737da12
@@ -0,0 +1 @@
+ãÿÿÿÿÿÿÿïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïÿÿÿÿÿÿÓïïïïïïïïïïïïïïïïïïïï÷ïïïïïïïïïïïÿ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/6d95355018cadedd97bed65c45a44a7ff6f065f7 b/fuzzers/corpora/midx/6d95355018cadedd97bed65c45a44a7ff6f065f7
new file mode 100644
index 0000000..1c1a354
Binary files /dev/null and b/fuzzers/corpora/midx/6d95355018cadedd97bed65c45a44a7ff6f065f7 differ
diff --git a/fuzzers/corpora/midx/6dd70e887ab94db3327d9aaa0335914a1f4986b7 b/fuzzers/corpora/midx/6dd70e887ab94db3327d9aaa0335914a1f4986b7
new file mode 100644
index 0000000..c1edd0b
Binary files /dev/null and b/fuzzers/corpora/midx/6dd70e887ab94db3327d9aaa0335914a1f4986b7 differ
diff --git a/fuzzers/corpora/midx/6ed51a953a8b6671de417406e340d8d0a211aa12 b/fuzzers/corpora/midx/6ed51a953a8b6671de417406e340d8d0a211aa12
new file mode 100644
index 0000000..d21f30c
Binary files /dev/null and b/fuzzers/corpora/midx/6ed51a953a8b6671de417406e340d8d0a211aa12 differ
diff --git a/fuzzers/corpora/midx/6f911f19652a4457c93ef92b594bc1dc2ca900f8 b/fuzzers/corpora/midx/6f911f19652a4457c93ef92b594bc1dc2ca900f8
new file mode 100644
index 0000000..8c537dc
Binary files /dev/null and b/fuzzers/corpora/midx/6f911f19652a4457c93ef92b594bc1dc2ca900f8 differ
diff --git a/fuzzers/corpora/midx/6fa76cbaeb3cf0417c7a372132167bcd737db66b b/fuzzers/corpora/midx/6fa76cbaeb3cf0417c7a372132167bcd737db66b
new file mode 100644
index 0000000..a506334
Binary files /dev/null and b/fuzzers/corpora/midx/6fa76cbaeb3cf0417c7a372132167bcd737db66b differ
diff --git a/fuzzers/corpora/midx/71f66d3f7da318d69681a22ebbceb1a2bb290658 b/fuzzers/corpora/midx/71f66d3f7da318d69681a22ebbceb1a2bb290658
new file mode 100644
index 0000000..317820a
Binary files /dev/null and b/fuzzers/corpora/midx/71f66d3f7da318d69681a22ebbceb1a2bb290658 differ
diff --git a/fuzzers/corpora/midx/7227a2dc335af13e7225536c49969f46a800750a b/fuzzers/corpora/midx/7227a2dc335af13e7225536c49969f46a800750a
new file mode 100644
index 0000000..d7b9d6f
--- /dev/null
+++ b/fuzzers/corpora/midx/7227a2dc335af13e7225536c49969f46a800750a
@@ -0,0 +1 @@
+ãj
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/72fce27bbccf582f2023f5e168853251e576592a b/fuzzers/corpora/midx/72fce27bbccf582f2023f5e168853251e576592a
new file mode 100644
index 0000000..646d858
Binary files /dev/null and b/fuzzers/corpora/midx/72fce27bbccf582f2023f5e168853251e576592a differ
diff --git a/fuzzers/corpora/midx/738e5543ae005a6de85dfcd960eb8e3e6faa8947 b/fuzzers/corpora/midx/738e5543ae005a6de85dfcd960eb8e3e6faa8947
new file mode 100644
index 0000000..33dd640
Binary files /dev/null and b/fuzzers/corpora/midx/738e5543ae005a6de85dfcd960eb8e3e6faa8947 differ
diff --git a/fuzzers/corpora/midx/739d9c8868445202305d0a4e5766df1c68932688 b/fuzzers/corpora/midx/739d9c8868445202305d0a4e5766df1c68932688
new file mode 100644
index 0000000..58450d9
Binary files /dev/null and b/fuzzers/corpora/midx/739d9c8868445202305d0a4e5766df1c68932688 differ
diff --git a/fuzzers/corpora/midx/7438b07314917c84d348e7d9629e3712190c7da7 b/fuzzers/corpora/midx/7438b07314917c84d348e7d9629e3712190c7da7
new file mode 100644
index 0000000..197006e
Binary files /dev/null and b/fuzzers/corpora/midx/7438b07314917c84d348e7d9629e3712190c7da7 differ
diff --git a/fuzzers/corpora/midx/7490f00d660f5d8dedfa606cca241bd07be86a4f b/fuzzers/corpora/midx/7490f00d660f5d8dedfa606cca241bd07be86a4f
new file mode 100644
index 0000000..9f056b2
Binary files /dev/null and b/fuzzers/corpora/midx/7490f00d660f5d8dedfa606cca241bd07be86a4f differ
diff --git a/fuzzers/corpora/midx/75c64e8b61af41b28516c2c0fe902362d55a24f3 b/fuzzers/corpora/midx/75c64e8b61af41b28516c2c0fe902362d55a24f3
new file mode 100644
index 0000000..7832dbc
Binary files /dev/null and b/fuzzers/corpora/midx/75c64e8b61af41b28516c2c0fe902362d55a24f3 differ
diff --git a/fuzzers/corpora/midx/75e94b59a41e7f086b6f7ab3bca801251744ae3d b/fuzzers/corpora/midx/75e94b59a41e7f086b6f7ab3bca801251744ae3d
new file mode 100644
index 0000000..573a589
Binary files /dev/null and b/fuzzers/corpora/midx/75e94b59a41e7f086b6f7ab3bca801251744ae3d differ
diff --git a/fuzzers/corpora/midx/7612ceb3a989f97a7bb19f57c7f9c61366953642 b/fuzzers/corpora/midx/7612ceb3a989f97a7bb19f57c7f9c61366953642
new file mode 100644
index 0000000..1dddb9d
Binary files /dev/null and b/fuzzers/corpora/midx/7612ceb3a989f97a7bb19f57c7f9c61366953642 differ
diff --git a/fuzzers/corpora/midx/76ac2328e1c979bca648b4082b8bfe6f2e2e73ea b/fuzzers/corpora/midx/76ac2328e1c979bca648b4082b8bfe6f2e2e73ea
new file mode 100644
index 0000000..fa3ab13
Binary files /dev/null and b/fuzzers/corpora/midx/76ac2328e1c979bca648b4082b8bfe6f2e2e73ea differ
diff --git a/fuzzers/corpora/midx/76f296039ba4d666c9147ad234d43b55050808e3 b/fuzzers/corpora/midx/76f296039ba4d666c9147ad234d43b55050808e3
new file mode 100644
index 0000000..114e764
Binary files /dev/null and b/fuzzers/corpora/midx/76f296039ba4d666c9147ad234d43b55050808e3 differ
diff --git a/fuzzers/corpora/midx/777f248eea53e3dd2b726e1e0de5eeda43b6d323 b/fuzzers/corpora/midx/777f248eea53e3dd2b726e1e0de5eeda43b6d323
new file mode 100644
index 0000000..120ffd6
--- /dev/null
+++ b/fuzzers/corpora/midx/777f248eea53e3dd2b726e1e0de5eeda43b6d323
@@ -0,0 +1 @@
+›
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/792fcd0075bd8031a98a68ce04d6a9f23feef7b4 b/fuzzers/corpora/midx/792fcd0075bd8031a98a68ce04d6a9f23feef7b4
new file mode 100644
index 0000000..ca5572e
Binary files /dev/null and b/fuzzers/corpora/midx/792fcd0075bd8031a98a68ce04d6a9f23feef7b4 differ
diff --git a/fuzzers/corpora/midx/7a936c3e69013b2c71dcb72f0eccd99c93367533 b/fuzzers/corpora/midx/7a936c3e69013b2c71dcb72f0eccd99c93367533
new file mode 100644
index 0000000..8c3d729
Binary files /dev/null and b/fuzzers/corpora/midx/7a936c3e69013b2c71dcb72f0eccd99c93367533 differ
diff --git a/fuzzers/corpora/midx/7b30d0cd07108f2e45ce1a3fab3f971b25dcf5cd b/fuzzers/corpora/midx/7b30d0cd07108f2e45ce1a3fab3f971b25dcf5cd
new file mode 100644
index 0000000..08ddd34
Binary files /dev/null and b/fuzzers/corpora/midx/7b30d0cd07108f2e45ce1a3fab3f971b25dcf5cd differ
diff --git a/fuzzers/corpora/midx/7b87f367b5fa3bf29bae19031814e5d0120a15ba b/fuzzers/corpora/midx/7b87f367b5fa3bf29bae19031814e5d0120a15ba
new file mode 100644
index 0000000..146d3ee
Binary files /dev/null and b/fuzzers/corpora/midx/7b87f367b5fa3bf29bae19031814e5d0120a15ba differ
diff --git a/fuzzers/corpora/midx/7c12e4bca60858eae13c47a66e54cd9e96a50909 b/fuzzers/corpora/midx/7c12e4bca60858eae13c47a66e54cd9e96a50909
new file mode 100644
index 0000000..a3cb4ab
Binary files /dev/null and b/fuzzers/corpora/midx/7c12e4bca60858eae13c47a66e54cd9e96a50909 differ
diff --git a/fuzzers/corpora/midx/7c59f95e649b3be6344f4f835afd0d9a894c1144 b/fuzzers/corpora/midx/7c59f95e649b3be6344f4f835afd0d9a894c1144
new file mode 100644
index 0000000..4a9c07c
Binary files /dev/null and b/fuzzers/corpora/midx/7c59f95e649b3be6344f4f835afd0d9a894c1144 differ
diff --git a/fuzzers/corpora/midx/7dcb6494c3614a8690dc496309f90e0f23634c37 b/fuzzers/corpora/midx/7dcb6494c3614a8690dc496309f90e0f23634c37
new file mode 100644
index 0000000..ef09d98
Binary files /dev/null and b/fuzzers/corpora/midx/7dcb6494c3614a8690dc496309f90e0f23634c37 differ
diff --git a/fuzzers/corpora/midx/7e64b86827ea98f0a4eb54736c460a59b0c30420 b/fuzzers/corpora/midx/7e64b86827ea98f0a4eb54736c460a59b0c30420
new file mode 100644
index 0000000..6062c8d
Binary files /dev/null and b/fuzzers/corpora/midx/7e64b86827ea98f0a4eb54736c460a59b0c30420 differ
diff --git a/fuzzers/corpora/midx/8125d9eaa09b3d2283fea73223866cb36877c4a4 b/fuzzers/corpora/midx/8125d9eaa09b3d2283fea73223866cb36877c4a4
new file mode 100644
index 0000000..d91f4eb
Binary files /dev/null and b/fuzzers/corpora/midx/8125d9eaa09b3d2283fea73223866cb36877c4a4 differ
diff --git a/fuzzers/corpora/midx/81c7fc514fa9a07b5b87b94cf9c00df2b1325a74 b/fuzzers/corpora/midx/81c7fc514fa9a07b5b87b94cf9c00df2b1325a74
new file mode 100644
index 0000000..2c19a2a
Binary files /dev/null and b/fuzzers/corpora/midx/81c7fc514fa9a07b5b87b94cf9c00df2b1325a74 differ
diff --git a/fuzzers/corpora/midx/81f9df0493052d980ca13918637bc6ce565615b3 b/fuzzers/corpora/midx/81f9df0493052d980ca13918637bc6ce565615b3
new file mode 100644
index 0000000..1030a4b
Binary files /dev/null and b/fuzzers/corpora/midx/81f9df0493052d980ca13918637bc6ce565615b3 differ
diff --git a/fuzzers/corpora/midx/82556b9345134dd689cb9d0d08d3dc8459454181 b/fuzzers/corpora/midx/82556b9345134dd689cb9d0d08d3dc8459454181
new file mode 100644
index 0000000..e8a113f
Binary files /dev/null and b/fuzzers/corpora/midx/82556b9345134dd689cb9d0d08d3dc8459454181 differ
diff --git a/fuzzers/corpora/midx/82d35a7a6ffb333b02d0d597e88ffdd481237a8b b/fuzzers/corpora/midx/82d35a7a6ffb333b02d0d597e88ffdd481237a8b
new file mode 100644
index 0000000..1f2de8a
Binary files /dev/null and b/fuzzers/corpora/midx/82d35a7a6ffb333b02d0d597e88ffdd481237a8b differ
diff --git a/fuzzers/corpora/midx/82e931da372a2c69c0f10274342173c2be091f1c b/fuzzers/corpora/midx/82e931da372a2c69c0f10274342173c2be091f1c
new file mode 100644
index 0000000..34a1c15
Binary files /dev/null and b/fuzzers/corpora/midx/82e931da372a2c69c0f10274342173c2be091f1c differ
diff --git a/fuzzers/corpora/midx/83e2b53f22afe8f7ee21d30fae2619ad0d6a71e3 b/fuzzers/corpora/midx/83e2b53f22afe8f7ee21d30fae2619ad0d6a71e3
new file mode 100644
index 0000000..8815c9b
Binary files /dev/null and b/fuzzers/corpora/midx/83e2b53f22afe8f7ee21d30fae2619ad0d6a71e3 differ
diff --git a/fuzzers/corpora/midx/83f4d70189dbc0d3aaf5025977c53d4d34fc5893 b/fuzzers/corpora/midx/83f4d70189dbc0d3aaf5025977c53d4d34fc5893
new file mode 100644
index 0000000..78b1f7c
Binary files /dev/null and b/fuzzers/corpora/midx/83f4d70189dbc0d3aaf5025977c53d4d34fc5893 differ
diff --git a/fuzzers/corpora/midx/85e17cceba7850be893afdc04c8233bea1ef6e72 b/fuzzers/corpora/midx/85e17cceba7850be893afdc04c8233bea1ef6e72
new file mode 100644
index 0000000..0e157c9
Binary files /dev/null and b/fuzzers/corpora/midx/85e17cceba7850be893afdc04c8233bea1ef6e72 differ
diff --git a/fuzzers/corpora/midx/874d4abdcd7db751eb930928231669afe90589f5 b/fuzzers/corpora/midx/874d4abdcd7db751eb930928231669afe90589f5
new file mode 100644
index 0000000..238ca42
Binary files /dev/null and b/fuzzers/corpora/midx/874d4abdcd7db751eb930928231669afe90589f5 differ
diff --git a/fuzzers/corpora/midx/87894ec663568153d7837f49b80f6d2e99818bd7 b/fuzzers/corpora/midx/87894ec663568153d7837f49b80f6d2e99818bd7
new file mode 100644
index 0000000..d2775fd
Binary files /dev/null and b/fuzzers/corpora/midx/87894ec663568153d7837f49b80f6d2e99818bd7 differ
diff --git a/fuzzers/corpora/midx/88052b76108b4ede342f3dd87bb6835b2f71ea83 b/fuzzers/corpora/midx/88052b76108b4ede342f3dd87bb6835b2f71ea83
new file mode 100644
index 0000000..c0a6a32
Binary files /dev/null and b/fuzzers/corpora/midx/88052b76108b4ede342f3dd87bb6835b2f71ea83 differ
diff --git a/fuzzers/corpora/midx/884c54256c0ec2cf1c5fa08a0b3d9c2fea021300 b/fuzzers/corpora/midx/884c54256c0ec2cf1c5fa08a0b3d9c2fea021300
new file mode 100644
index 0000000..e0980ee
Binary files /dev/null and b/fuzzers/corpora/midx/884c54256c0ec2cf1c5fa08a0b3d9c2fea021300 differ
diff --git a/fuzzers/corpora/midx/8858f36373db5fd6b805a768af55c21019c664b2 b/fuzzers/corpora/midx/8858f36373db5fd6b805a768af55c21019c664b2
new file mode 100644
index 0000000..50c738d
Binary files /dev/null and b/fuzzers/corpora/midx/8858f36373db5fd6b805a768af55c21019c664b2 differ
diff --git a/fuzzers/corpora/midx/88fe8b6767c1bd32308208b22e0b00697e5eddf7 b/fuzzers/corpora/midx/88fe8b6767c1bd32308208b22e0b00697e5eddf7
new file mode 100644
index 0000000..da39bf1
Binary files /dev/null and b/fuzzers/corpora/midx/88fe8b6767c1bd32308208b22e0b00697e5eddf7 differ
diff --git a/fuzzers/corpora/midx/898cac1610f2f2fb67eb092cd053f0006c3070e3 b/fuzzers/corpora/midx/898cac1610f2f2fb67eb092cd053f0006c3070e3
new file mode 100644
index 0000000..babd31d
Binary files /dev/null and b/fuzzers/corpora/midx/898cac1610f2f2fb67eb092cd053f0006c3070e3 differ
diff --git a/fuzzers/corpora/midx/89d0f5573ae1b524e7e9bdb1fb54ea4ce99e3ef0 b/fuzzers/corpora/midx/89d0f5573ae1b524e7e9bdb1fb54ea4ce99e3ef0
new file mode 100644
index 0000000..43858e2
Binary files /dev/null and b/fuzzers/corpora/midx/89d0f5573ae1b524e7e9bdb1fb54ea4ce99e3ef0 differ
diff --git a/fuzzers/corpora/midx/8a55300e400efd56be5e12258ebf575c4f3b55ed b/fuzzers/corpora/midx/8a55300e400efd56be5e12258ebf575c4f3b55ed
new file mode 100644
index 0000000..bf76c1a
Binary files /dev/null and b/fuzzers/corpora/midx/8a55300e400efd56be5e12258ebf575c4f3b55ed differ
diff --git a/fuzzers/corpora/midx/8bf7b464aaa2c2b536aa1d76a1297c19155f5603 b/fuzzers/corpora/midx/8bf7b464aaa2c2b536aa1d76a1297c19155f5603
new file mode 100644
index 0000000..6b10f95
--- /dev/null
+++ b/fuzzers/corpora/midx/8bf7b464aaa2c2b536aa1d76a1297c19155f5603
@@ -0,0 +1 @@
+Ã
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/8c05e8ef26302a79c89670ad3aa4e8d0bc921923 b/fuzzers/corpora/midx/8c05e8ef26302a79c89670ad3aa4e8d0bc921923
new file mode 100644
index 0000000..9f142f0
Binary files /dev/null and b/fuzzers/corpora/midx/8c05e8ef26302a79c89670ad3aa4e8d0bc921923 differ
diff --git a/fuzzers/corpora/midx/8c15f5a268ded9663197d66e8d7d4098e0ae9bf5 b/fuzzers/corpora/midx/8c15f5a268ded9663197d66e8d7d4098e0ae9bf5
new file mode 100644
index 0000000..9b1b882
Binary files /dev/null and b/fuzzers/corpora/midx/8c15f5a268ded9663197d66e8d7d4098e0ae9bf5 differ
diff --git a/fuzzers/corpora/midx/8ca9e85a9e628f0016ea4e6413945b3830730c24 b/fuzzers/corpora/midx/8ca9e85a9e628f0016ea4e6413945b3830730c24
new file mode 100644
index 0000000..e64a7c9
Binary files /dev/null and b/fuzzers/corpora/midx/8ca9e85a9e628f0016ea4e6413945b3830730c24 differ
diff --git a/fuzzers/corpora/midx/8e74126a239927900a8f655c813a4b230191a5ba b/fuzzers/corpora/midx/8e74126a239927900a8f655c813a4b230191a5ba
new file mode 100644
index 0000000..32005e3
Binary files /dev/null and b/fuzzers/corpora/midx/8e74126a239927900a8f655c813a4b230191a5ba differ
diff --git a/fuzzers/corpora/midx/8ee63e791c004427dd033b468b2ed7446ee6e2e0 b/fuzzers/corpora/midx/8ee63e791c004427dd033b468b2ed7446ee6e2e0
new file mode 100644
index 0000000..a9d264a
Binary files /dev/null and b/fuzzers/corpora/midx/8ee63e791c004427dd033b468b2ed7446ee6e2e0 differ
diff --git a/fuzzers/corpora/midx/9028113aa78b649e13ff259027a4e450d469e5da b/fuzzers/corpora/midx/9028113aa78b649e13ff259027a4e450d469e5da
new file mode 100644
index 0000000..12c09a3
Binary files /dev/null and b/fuzzers/corpora/midx/9028113aa78b649e13ff259027a4e450d469e5da differ
diff --git a/fuzzers/corpora/midx/90db2115b8262ebecbefbe8f0a07c451e39bca07 b/fuzzers/corpora/midx/90db2115b8262ebecbefbe8f0a07c451e39bca07
new file mode 100644
index 0000000..38fc26c
Binary files /dev/null and b/fuzzers/corpora/midx/90db2115b8262ebecbefbe8f0a07c451e39bca07 differ
diff --git a/fuzzers/corpora/midx/923f28a4d1917e20ee0736b90695c2123c0c987c b/fuzzers/corpora/midx/923f28a4d1917e20ee0736b90695c2123c0c987c
new file mode 100644
index 0000000..8961e95
Binary files /dev/null and b/fuzzers/corpora/midx/923f28a4d1917e20ee0736b90695c2123c0c987c differ
diff --git a/fuzzers/corpora/midx/92a5c74e0506d65d1a12686496452870367b169a b/fuzzers/corpora/midx/92a5c74e0506d65d1a12686496452870367b169a
new file mode 100644
index 0000000..4e08402
Binary files /dev/null and b/fuzzers/corpora/midx/92a5c74e0506d65d1a12686496452870367b169a differ
diff --git a/fuzzers/corpora/midx/92dcf94eb2f92b4e1a232eab3b3f808f4236f118 b/fuzzers/corpora/midx/92dcf94eb2f92b4e1a232eab3b3f808f4236f118
new file mode 100644
index 0000000..0999c8a
Binary files /dev/null and b/fuzzers/corpora/midx/92dcf94eb2f92b4e1a232eab3b3f808f4236f118 differ
diff --git a/fuzzers/corpora/midx/9414502aedbef5e307897683625418dd4ac575ac b/fuzzers/corpora/midx/9414502aedbef5e307897683625418dd4ac575ac
new file mode 100644
index 0000000..98260fb
Binary files /dev/null and b/fuzzers/corpora/midx/9414502aedbef5e307897683625418dd4ac575ac differ
diff --git a/fuzzers/corpora/midx/9422e25bec5fec9f84603a85673b54b1a5e77a40 b/fuzzers/corpora/midx/9422e25bec5fec9f84603a85673b54b1a5e77a40
new file mode 100644
index 0000000..e0d9ca7
Binary files /dev/null and b/fuzzers/corpora/midx/9422e25bec5fec9f84603a85673b54b1a5e77a40 differ
diff --git a/fuzzers/corpora/midx/943754e865888063e0684aec838222522390d43e b/fuzzers/corpora/midx/943754e865888063e0684aec838222522390d43e
new file mode 100644
index 0000000..2a6ba4e
Binary files /dev/null and b/fuzzers/corpora/midx/943754e865888063e0684aec838222522390d43e differ
diff --git a/fuzzers/corpora/midx/943e067806ae069afbc029ea7a612410e5395687 b/fuzzers/corpora/midx/943e067806ae069afbc029ea7a612410e5395687
new file mode 100644
index 0000000..d51ab5f
Binary files /dev/null and b/fuzzers/corpora/midx/943e067806ae069afbc029ea7a612410e5395687 differ
diff --git a/fuzzers/corpora/midx/9547646cc1a5d260df099b00ea7ee2b95567aee1 b/fuzzers/corpora/midx/9547646cc1a5d260df099b00ea7ee2b95567aee1
new file mode 100644
index 0000000..92426bc
Binary files /dev/null and b/fuzzers/corpora/midx/9547646cc1a5d260df099b00ea7ee2b95567aee1 differ
diff --git a/fuzzers/corpora/midx/968f7027ec9fbf75a519069ea5189e85a81448b2 b/fuzzers/corpora/midx/968f7027ec9fbf75a519069ea5189e85a81448b2
new file mode 100644
index 0000000..56dfbcd
Binary files /dev/null and b/fuzzers/corpora/midx/968f7027ec9fbf75a519069ea5189e85a81448b2 differ
diff --git a/fuzzers/corpora/midx/9691046a2f8b31319a6fdfde0506c9a72aed839a b/fuzzers/corpora/midx/9691046a2f8b31319a6fdfde0506c9a72aed839a
new file mode 100644
index 0000000..e3cfcb0
Binary files /dev/null and b/fuzzers/corpora/midx/9691046a2f8b31319a6fdfde0506c9a72aed839a differ
diff --git a/fuzzers/corpora/midx/96a8cd5c33986cc26cc00eb2de627149f5259e33 b/fuzzers/corpora/midx/96a8cd5c33986cc26cc00eb2de627149f5259e33
new file mode 100644
index 0000000..85fb8fa
Binary files /dev/null and b/fuzzers/corpora/midx/96a8cd5c33986cc26cc00eb2de627149f5259e33 differ
diff --git a/fuzzers/corpora/midx/972466bbc33d2d7d7c21be21c7594b51e78675c5 b/fuzzers/corpora/midx/972466bbc33d2d7d7c21be21c7594b51e78675c5
new file mode 100644
index 0000000..b8fd7b3
Binary files /dev/null and b/fuzzers/corpora/midx/972466bbc33d2d7d7c21be21c7594b51e78675c5 differ
diff --git a/fuzzers/corpora/midx/980f21a3609762154030f7cf0fe98a892d20f220 b/fuzzers/corpora/midx/980f21a3609762154030f7cf0fe98a892d20f220
new file mode 100644
index 0000000..d89f9cd
Binary files /dev/null and b/fuzzers/corpora/midx/980f21a3609762154030f7cf0fe98a892d20f220 differ
diff --git a/fuzzers/corpora/midx/9865f12189ef977418d8410fceebb6830c74d820 b/fuzzers/corpora/midx/9865f12189ef977418d8410fceebb6830c74d820
new file mode 100644
index 0000000..c4d3f67
Binary files /dev/null and b/fuzzers/corpora/midx/9865f12189ef977418d8410fceebb6830c74d820 differ
diff --git a/fuzzers/corpora/midx/98a1096d609545083878d5126743bbc5985786a9 b/fuzzers/corpora/midx/98a1096d609545083878d5126743bbc5985786a9
new file mode 100644
index 0000000..6cf168e
Binary files /dev/null and b/fuzzers/corpora/midx/98a1096d609545083878d5126743bbc5985786a9 differ
diff --git a/fuzzers/corpora/midx/98c3b6bbf5dc19bc4aad894087277a36d7c79669 b/fuzzers/corpora/midx/98c3b6bbf5dc19bc4aad894087277a36d7c79669
new file mode 100644
index 0000000..7a11bb5
Binary files /dev/null and b/fuzzers/corpora/midx/98c3b6bbf5dc19bc4aad894087277a36d7c79669 differ
diff --git a/fuzzers/corpora/midx/98f9cd44400b592f809596004125267acf848435 b/fuzzers/corpora/midx/98f9cd44400b592f809596004125267acf848435
new file mode 100644
index 0000000..d4e6332
Binary files /dev/null and b/fuzzers/corpora/midx/98f9cd44400b592f809596004125267acf848435 differ
diff --git a/fuzzers/corpora/midx/9a97260f04ecfe0918499ede95cf4bcb3dbc2b51 b/fuzzers/corpora/midx/9a97260f04ecfe0918499ede95cf4bcb3dbc2b51
new file mode 100644
index 0000000..ba3011b
Binary files /dev/null and b/fuzzers/corpora/midx/9a97260f04ecfe0918499ede95cf4bcb3dbc2b51 differ
diff --git a/fuzzers/corpora/midx/9ba0dba2ca4405d04113086309882dac6182e6b8 b/fuzzers/corpora/midx/9ba0dba2ca4405d04113086309882dac6182e6b8
new file mode 100644
index 0000000..4513cd9
Binary files /dev/null and b/fuzzers/corpora/midx/9ba0dba2ca4405d04113086309882dac6182e6b8 differ
diff --git a/fuzzers/corpora/midx/9c329ee4b02f2d26ee1a399c873b0452aedca3c0 b/fuzzers/corpora/midx/9c329ee4b02f2d26ee1a399c873b0452aedca3c0
new file mode 100644
index 0000000..ac164f4
Binary files /dev/null and b/fuzzers/corpora/midx/9c329ee4b02f2d26ee1a399c873b0452aedca3c0 differ
diff --git a/fuzzers/corpora/midx/9e8e638837e202d83ff606a22dd0e310150fa260 b/fuzzers/corpora/midx/9e8e638837e202d83ff606a22dd0e310150fa260
new file mode 100644
index 0000000..93f205f
Binary files /dev/null and b/fuzzers/corpora/midx/9e8e638837e202d83ff606a22dd0e310150fa260 differ
diff --git a/fuzzers/corpora/midx/9ee03d17e070df72547e423a412da0b6a60ad565 b/fuzzers/corpora/midx/9ee03d17e070df72547e423a412da0b6a60ad565
new file mode 100644
index 0000000..874ce8f
Binary files /dev/null and b/fuzzers/corpora/midx/9ee03d17e070df72547e423a412da0b6a60ad565 differ
diff --git a/fuzzers/corpora/midx/9fad6bd2b07d65e607039bb2bcda0816410cf983 b/fuzzers/corpora/midx/9fad6bd2b07d65e607039bb2bcda0816410cf983
new file mode 100644
index 0000000..160c9ab
Binary files /dev/null and b/fuzzers/corpora/midx/9fad6bd2b07d65e607039bb2bcda0816410cf983 differ
diff --git a/fuzzers/corpora/midx/9fcbd21f4dd194a623d832422384a1519742f0bb b/fuzzers/corpora/midx/9fcbd21f4dd194a623d832422384a1519742f0bb
new file mode 100644
index 0000000..cce3746
Binary files /dev/null and b/fuzzers/corpora/midx/9fcbd21f4dd194a623d832422384a1519742f0bb differ
diff --git a/fuzzers/corpora/midx/a019fb7f17aa36a9743c530e1f11d5613b8b1158 b/fuzzers/corpora/midx/a019fb7f17aa36a9743c530e1f11d5613b8b1158
new file mode 100644
index 0000000..e6a45fa
Binary files /dev/null and b/fuzzers/corpora/midx/a019fb7f17aa36a9743c530e1f11d5613b8b1158 differ
diff --git a/fuzzers/corpora/midx/a0b8c6ef20198377b19f59e41f08f4cf2107f460 b/fuzzers/corpora/midx/a0b8c6ef20198377b19f59e41f08f4cf2107f460
new file mode 100644
index 0000000..f10d52c
Binary files /dev/null and b/fuzzers/corpora/midx/a0b8c6ef20198377b19f59e41f08f4cf2107f460 differ
diff --git a/fuzzers/corpora/midx/a14079a3e8cbc2112da4fa747ef20cdfd580e068 b/fuzzers/corpora/midx/a14079a3e8cbc2112da4fa747ef20cdfd580e068
new file mode 100644
index 0000000..1d17566
Binary files /dev/null and b/fuzzers/corpora/midx/a14079a3e8cbc2112da4fa747ef20cdfd580e068 differ
diff --git a/fuzzers/corpora/midx/a14d61ba0c609665d37e6c6da929cb53c5b70545 b/fuzzers/corpora/midx/a14d61ba0c609665d37e6c6da929cb53c5b70545
new file mode 100644
index 0000000..d70d19e
Binary files /dev/null and b/fuzzers/corpora/midx/a14d61ba0c609665d37e6c6da929cb53c5b70545 differ
diff --git a/fuzzers/corpora/midx/a15cf2a13e408cb76af0091a0c286af7ffce58e1 b/fuzzers/corpora/midx/a15cf2a13e408cb76af0091a0c286af7ffce58e1
new file mode 100644
index 0000000..23b70ad
Binary files /dev/null and b/fuzzers/corpora/midx/a15cf2a13e408cb76af0091a0c286af7ffce58e1 differ
diff --git a/fuzzers/corpora/midx/a1ddedbdd05eac99b8b31322635771cd9c999f8a b/fuzzers/corpora/midx/a1ddedbdd05eac99b8b31322635771cd9c999f8a
new file mode 100644
index 0000000..066e405
Binary files /dev/null and b/fuzzers/corpora/midx/a1ddedbdd05eac99b8b31322635771cd9c999f8a differ
diff --git a/fuzzers/corpora/midx/a235661c3f8b0174a1658e9c435a69577c49256a b/fuzzers/corpora/midx/a235661c3f8b0174a1658e9c435a69577c49256a
new file mode 100644
index 0000000..ca719f2
Binary files /dev/null and b/fuzzers/corpora/midx/a235661c3f8b0174a1658e9c435a69577c49256a differ
diff --git a/fuzzers/corpora/midx/a261397a4db5ac196c72d73ba6999e9fd4fc5c1f b/fuzzers/corpora/midx/a261397a4db5ac196c72d73ba6999e9fd4fc5c1f
new file mode 100644
index 0000000..ae0d042
Binary files /dev/null and b/fuzzers/corpora/midx/a261397a4db5ac196c72d73ba6999e9fd4fc5c1f differ
diff --git a/fuzzers/corpora/midx/a3a803fd6a56d31269717983bbdf2fceebb626c3 b/fuzzers/corpora/midx/a3a803fd6a56d31269717983bbdf2fceebb626c3
new file mode 100644
index 0000000..f813f25
Binary files /dev/null and b/fuzzers/corpora/midx/a3a803fd6a56d31269717983bbdf2fceebb626c3 differ
diff --git a/fuzzers/corpora/midx/a3d5b0b21d977e8f94d401250de1bbd4fa1d0ee0 b/fuzzers/corpora/midx/a3d5b0b21d977e8f94d401250de1bbd4fa1d0ee0
new file mode 100644
index 0000000..151c74b
Binary files /dev/null and b/fuzzers/corpora/midx/a3d5b0b21d977e8f94d401250de1bbd4fa1d0ee0 differ
diff --git a/fuzzers/corpora/midx/a42f2900ca519bd15b8d6f507449d1a07de2ef75 b/fuzzers/corpora/midx/a42f2900ca519bd15b8d6f507449d1a07de2ef75
new file mode 100644
index 0000000..efd2d87
Binary files /dev/null and b/fuzzers/corpora/midx/a42f2900ca519bd15b8d6f507449d1a07de2ef75 differ
diff --git a/fuzzers/corpora/midx/a4884775b414eaf9643224564f3be405519cf99a b/fuzzers/corpora/midx/a4884775b414eaf9643224564f3be405519cf99a
new file mode 100644
index 0000000..7e6260b
Binary files /dev/null and b/fuzzers/corpora/midx/a4884775b414eaf9643224564f3be405519cf99a differ
diff --git a/fuzzers/corpora/midx/a48da63e9a5709c24cb66f598a7a964cbc7ccfc7 b/fuzzers/corpora/midx/a48da63e9a5709c24cb66f598a7a964cbc7ccfc7
new file mode 100644
index 0000000..2e553bf
Binary files /dev/null and b/fuzzers/corpora/midx/a48da63e9a5709c24cb66f598a7a964cbc7ccfc7 differ
diff --git a/fuzzers/corpora/midx/a5789fd83dff18079ea7ba41c999f57bee4db41b b/fuzzers/corpora/midx/a5789fd83dff18079ea7ba41c999f57bee4db41b
new file mode 100644
index 0000000..5d0a926
Binary files /dev/null and b/fuzzers/corpora/midx/a5789fd83dff18079ea7ba41c999f57bee4db41b differ
diff --git a/fuzzers/corpora/midx/a5bb1c60191742df4a91afb622e9b22a2f0b7765 b/fuzzers/corpora/midx/a5bb1c60191742df4a91afb622e9b22a2f0b7765
new file mode 100644
index 0000000..967cd25
Binary files /dev/null and b/fuzzers/corpora/midx/a5bb1c60191742df4a91afb622e9b22a2f0b7765 differ
diff --git a/fuzzers/corpora/midx/a5fdfade1cef5e7e494dd6e3791bca5a663d7012 b/fuzzers/corpora/midx/a5fdfade1cef5e7e494dd6e3791bca5a663d7012
new file mode 100644
index 0000000..0739dd6
Binary files /dev/null and b/fuzzers/corpora/midx/a5fdfade1cef5e7e494dd6e3791bca5a663d7012 differ
diff --git a/fuzzers/corpora/midx/a6c66f79f5aaf2c1a26ff16754fe1a8c22627e0c b/fuzzers/corpora/midx/a6c66f79f5aaf2c1a26ff16754fe1a8c22627e0c
new file mode 100644
index 0000000..8d22577
Binary files /dev/null and b/fuzzers/corpora/midx/a6c66f79f5aaf2c1a26ff16754fe1a8c22627e0c differ
diff --git a/fuzzers/corpora/midx/a7478a05a1fc04a9e035be5593bfb6a281ec460f b/fuzzers/corpora/midx/a7478a05a1fc04a9e035be5593bfb6a281ec460f
new file mode 100644
index 0000000..f25cd8e
Binary files /dev/null and b/fuzzers/corpora/midx/a7478a05a1fc04a9e035be5593bfb6a281ec460f differ
diff --git a/fuzzers/corpora/midx/a75193dd600661d2b417d4e29b23faa7d721c214 b/fuzzers/corpora/midx/a75193dd600661d2b417d4e29b23faa7d721c214
new file mode 100644
index 0000000..765d7f1
Binary files /dev/null and b/fuzzers/corpora/midx/a75193dd600661d2b417d4e29b23faa7d721c214 differ
diff --git a/fuzzers/corpora/midx/a7ccae74c641ffcdda0042e6c04438d5b32c4cf3 b/fuzzers/corpora/midx/a7ccae74c641ffcdda0042e6c04438d5b32c4cf3
new file mode 100644
index 0000000..c180cfa
Binary files /dev/null and b/fuzzers/corpora/midx/a7ccae74c641ffcdda0042e6c04438d5b32c4cf3 differ
diff --git a/fuzzers/corpora/midx/a94aa5881abdea5374775b8155812121673f89c3 b/fuzzers/corpora/midx/a94aa5881abdea5374775b8155812121673f89c3
new file mode 100644
index 0000000..3e2266b
Binary files /dev/null and b/fuzzers/corpora/midx/a94aa5881abdea5374775b8155812121673f89c3 differ
diff --git a/fuzzers/corpora/midx/a98d794f0f24be7a36917826121fc14a24120893 b/fuzzers/corpora/midx/a98d794f0f24be7a36917826121fc14a24120893
new file mode 100644
index 0000000..2529c4e
--- /dev/null
+++ b/fuzzers/corpora/midx/a98d794f0f24be7a36917826121fc14a24120893
@@ -0,0 +1 @@
+Ñã
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/a993077e321bc4e1831bb5a8ac7511d90d32ae27 b/fuzzers/corpora/midx/a993077e321bc4e1831bb5a8ac7511d90d32ae27
new file mode 100644
index 0000000..c0d4c9b
Binary files /dev/null and b/fuzzers/corpora/midx/a993077e321bc4e1831bb5a8ac7511d90d32ae27 differ
diff --git a/fuzzers/corpora/midx/aa3bc67656945e43f9342d3aaaef247584d96cfa b/fuzzers/corpora/midx/aa3bc67656945e43f9342d3aaaef247584d96cfa
new file mode 100644
index 0000000..a6e20c9
Binary files /dev/null and b/fuzzers/corpora/midx/aa3bc67656945e43f9342d3aaaef247584d96cfa differ
diff --git a/fuzzers/corpora/midx/ab111c4d72e3d6796e3d7391e9f35b4e6fefc04a b/fuzzers/corpora/midx/ab111c4d72e3d6796e3d7391e9f35b4e6fefc04a
new file mode 100644
index 0000000..4b65b4d
Binary files /dev/null and b/fuzzers/corpora/midx/ab111c4d72e3d6796e3d7391e9f35b4e6fefc04a differ
diff --git a/fuzzers/corpora/midx/ab248c42f77952d5d17d6f5203adaa5925c05c64 b/fuzzers/corpora/midx/ab248c42f77952d5d17d6f5203adaa5925c05c64
new file mode 100644
index 0000000..87bc327
Binary files /dev/null and b/fuzzers/corpora/midx/ab248c42f77952d5d17d6f5203adaa5925c05c64 differ
diff --git a/fuzzers/corpora/midx/ab8451fadf805e5087837d9f6d91ef7eb6fa5edb b/fuzzers/corpora/midx/ab8451fadf805e5087837d9f6d91ef7eb6fa5edb
new file mode 100644
index 0000000..ad08d1c
Binary files /dev/null and b/fuzzers/corpora/midx/ab8451fadf805e5087837d9f6d91ef7eb6fa5edb differ
diff --git a/fuzzers/corpora/midx/abbee3b37aff879b1cef47390001b89b0f6ebc0a b/fuzzers/corpora/midx/abbee3b37aff879b1cef47390001b89b0f6ebc0a
new file mode 100644
index 0000000..0cfebbd
Binary files /dev/null and b/fuzzers/corpora/midx/abbee3b37aff879b1cef47390001b89b0f6ebc0a differ
diff --git a/fuzzers/corpora/midx/ac15b23f03af8be6dbbb3bbb8d3877a1f9e074a3 b/fuzzers/corpora/midx/ac15b23f03af8be6dbbb3bbb8d3877a1f9e074a3
new file mode 100644
index 0000000..15ed803
Binary files /dev/null and b/fuzzers/corpora/midx/ac15b23f03af8be6dbbb3bbb8d3877a1f9e074a3 differ
diff --git a/fuzzers/corpora/midx/ac47bda12269c06d773f5f3c6517f78513a54a08 b/fuzzers/corpora/midx/ac47bda12269c06d773f5f3c6517f78513a54a08
new file mode 100644
index 0000000..7ba9b56
Binary files /dev/null and b/fuzzers/corpora/midx/ac47bda12269c06d773f5f3c6517f78513a54a08 differ
diff --git a/fuzzers/corpora/midx/ad1f4fb57f481a00a9bb231517a3155ef0d0877f b/fuzzers/corpora/midx/ad1f4fb57f481a00a9bb231517a3155ef0d0877f
new file mode 100644
index 0000000..7ae9220
Binary files /dev/null and b/fuzzers/corpora/midx/ad1f4fb57f481a00a9bb231517a3155ef0d0877f differ
diff --git a/fuzzers/corpora/midx/ad25e7ffabedd94833d2529886af4d459529ec9d b/fuzzers/corpora/midx/ad25e7ffabedd94833d2529886af4d459529ec9d
new file mode 100644
index 0000000..a1de604
Binary files /dev/null and b/fuzzers/corpora/midx/ad25e7ffabedd94833d2529886af4d459529ec9d differ
diff --git a/fuzzers/corpora/midx/ad796ebb423f58187806c4a7ee7b787394353ce6 b/fuzzers/corpora/midx/ad796ebb423f58187806c4a7ee7b787394353ce6
new file mode 100644
index 0000000..17e5905
Binary files /dev/null and b/fuzzers/corpora/midx/ad796ebb423f58187806c4a7ee7b787394353ce6 differ
diff --git a/fuzzers/corpora/midx/adc83b19e793491b1c6ea0fd8b46cd9f32e592fc b/fuzzers/corpora/midx/adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/fuzzers/corpora/midx/adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
@@ -0,0 +1 @@
+
diff --git a/fuzzers/corpora/midx/ae14b80f26f5cee2d85d5154c2cef1eefafa8cc9 b/fuzzers/corpora/midx/ae14b80f26f5cee2d85d5154c2cef1eefafa8cc9
new file mode 100644
index 0000000..d0309c3
Binary files /dev/null and b/fuzzers/corpora/midx/ae14b80f26f5cee2d85d5154c2cef1eefafa8cc9 differ
diff --git a/fuzzers/corpora/midx/ae3ba892de543801b3c1dfbce370eb2c80a6fb27 b/fuzzers/corpora/midx/ae3ba892de543801b3c1dfbce370eb2c80a6fb27
new file mode 100644
index 0000000..7f0f42d
Binary files /dev/null and b/fuzzers/corpora/midx/ae3ba892de543801b3c1dfbce370eb2c80a6fb27 differ
diff --git a/fuzzers/corpora/midx/aecc0c7f08810803da234e26e7c6fa7a9f1c0593 b/fuzzers/corpora/midx/aecc0c7f08810803da234e26e7c6fa7a9f1c0593
new file mode 100644
index 0000000..8edc209
Binary files /dev/null and b/fuzzers/corpora/midx/aecc0c7f08810803da234e26e7c6fa7a9f1c0593 differ
diff --git a/fuzzers/corpora/midx/aed2e85d5d39d25e738a34f30a722680bde30368 b/fuzzers/corpora/midx/aed2e85d5d39d25e738a34f30a722680bde30368
new file mode 100644
index 0000000..006970c
Binary files /dev/null and b/fuzzers/corpora/midx/aed2e85d5d39d25e738a34f30a722680bde30368 differ
diff --git a/fuzzers/corpora/midx/b00a75de1987c6f549bf73a63e8f23a2de6641b3 b/fuzzers/corpora/midx/b00a75de1987c6f549bf73a63e8f23a2de6641b3
new file mode 100644
index 0000000..6b7abb0
Binary files /dev/null and b/fuzzers/corpora/midx/b00a75de1987c6f549bf73a63e8f23a2de6641b3 differ
diff --git a/fuzzers/corpora/midx/b02e9f951ce9f10a8eb80f1fc61cd3d2832dd7f4 b/fuzzers/corpora/midx/b02e9f951ce9f10a8eb80f1fc61cd3d2832dd7f4
new file mode 100644
index 0000000..1bc7029
Binary files /dev/null and b/fuzzers/corpora/midx/b02e9f951ce9f10a8eb80f1fc61cd3d2832dd7f4 differ
diff --git a/fuzzers/corpora/midx/b04aff8ab2e133d45bf44565bd4bf9e33b795a97 b/fuzzers/corpora/midx/b04aff8ab2e133d45bf44565bd4bf9e33b795a97
new file mode 100644
index 0000000..fbba220
Binary files /dev/null and b/fuzzers/corpora/midx/b04aff8ab2e133d45bf44565bd4bf9e33b795a97 differ
diff --git a/fuzzers/corpora/midx/b12097ed83db761f7bb79411a59e2474de9b1199 b/fuzzers/corpora/midx/b12097ed83db761f7bb79411a59e2474de9b1199
new file mode 100644
index 0000000..75c7855
Binary files /dev/null and b/fuzzers/corpora/midx/b12097ed83db761f7bb79411a59e2474de9b1199 differ
diff --git a/fuzzers/corpora/midx/b1beb2f462b4cb30a09d534b9f49f2e08d76363c b/fuzzers/corpora/midx/b1beb2f462b4cb30a09d534b9f49f2e08d76363c
new file mode 100644
index 0000000..1f4bc7b
--- /dev/null
+++ b/fuzzers/corpora/midx/b1beb2f462b4cb30a09d534b9f49f2e08d76363c
@@ -0,0 +1 @@
+ãðc½D
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/b201733b6165f4544578bd6aad3f55aeafd9a194 b/fuzzers/corpora/midx/b201733b6165f4544578bd6aad3f55aeafd9a194
new file mode 100644
index 0000000..51e0787
Binary files /dev/null and b/fuzzers/corpora/midx/b201733b6165f4544578bd6aad3f55aeafd9a194 differ
diff --git a/fuzzers/corpora/midx/b2699f25c21ffe453dcce20e31b3093e0f9b2abf b/fuzzers/corpora/midx/b2699f25c21ffe453dcce20e31b3093e0f9b2abf
new file mode 100644
index 0000000..19e656b
--- /dev/null
+++ b/fuzzers/corpora/midx/b2699f25c21ffe453dcce20e31b3093e0f9b2abf
@@ -0,0 +1 @@
+Åç
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/b34a5760a1036f909e0243cd857fcef65e40d752 b/fuzzers/corpora/midx/b34a5760a1036f909e0243cd857fcef65e40d752
new file mode 100644
index 0000000..1a9d7ce
Binary files /dev/null and b/fuzzers/corpora/midx/b34a5760a1036f909e0243cd857fcef65e40d752 differ
diff --git a/fuzzers/corpora/midx/b3fdacd639073cc1954bcb1f31046d094e2d2296 b/fuzzers/corpora/midx/b3fdacd639073cc1954bcb1f31046d094e2d2296
new file mode 100644
index 0000000..f393c68
Binary files /dev/null and b/fuzzers/corpora/midx/b3fdacd639073cc1954bcb1f31046d094e2d2296 differ
diff --git a/fuzzers/corpora/midx/b40a6dbe32c8e6a9b777331e7fd97f0d94ceca1c b/fuzzers/corpora/midx/b40a6dbe32c8e6a9b777331e7fd97f0d94ceca1c
new file mode 100644
index 0000000..c8ea5fc
Binary files /dev/null and b/fuzzers/corpora/midx/b40a6dbe32c8e6a9b777331e7fd97f0d94ceca1c differ
diff --git a/fuzzers/corpora/midx/b52ff2010f22ae6758cde5d529fd19de2a7d5fc5 b/fuzzers/corpora/midx/b52ff2010f22ae6758cde5d529fd19de2a7d5fc5
new file mode 100644
index 0000000..ffe4138
Binary files /dev/null and b/fuzzers/corpora/midx/b52ff2010f22ae6758cde5d529fd19de2a7d5fc5 differ
diff --git a/fuzzers/corpora/midx/b53a7a2afd9dfc55c328b4e06a36882c53126e95 b/fuzzers/corpora/midx/b53a7a2afd9dfc55c328b4e06a36882c53126e95
new file mode 100644
index 0000000..1624d98
Binary files /dev/null and b/fuzzers/corpora/midx/b53a7a2afd9dfc55c328b4e06a36882c53126e95 differ
diff --git a/fuzzers/corpora/midx/b548ae8a77a62b7f375b8b48e7184ceed59bc8f8 b/fuzzers/corpora/midx/b548ae8a77a62b7f375b8b48e7184ceed59bc8f8
new file mode 100644
index 0000000..2905356
Binary files /dev/null and b/fuzzers/corpora/midx/b548ae8a77a62b7f375b8b48e7184ceed59bc8f8 differ
diff --git a/fuzzers/corpora/midx/b66eaf0b689495cc7c194ab1fca7d36ae9da9758 b/fuzzers/corpora/midx/b66eaf0b689495cc7c194ab1fca7d36ae9da9758
new file mode 100644
index 0000000..c02a240
Binary files /dev/null and b/fuzzers/corpora/midx/b66eaf0b689495cc7c194ab1fca7d36ae9da9758 differ
diff --git a/fuzzers/corpora/midx/b680bf23da22b8b7e77d847169fe9b6968d79e8b b/fuzzers/corpora/midx/b680bf23da22b8b7e77d847169fe9b6968d79e8b
new file mode 100644
index 0000000..e75d39a
--- /dev/null
+++ b/fuzzers/corpora/midx/b680bf23da22b8b7e77d847169fe9b6968d79e8b
@@ -0,0 +1 @@
+ãoÙ¬ÿÿ
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/b70d6e7d230fb1393b8f665adcd5658cad7059fe b/fuzzers/corpora/midx/b70d6e7d230fb1393b8f665adcd5658cad7059fe
new file mode 100644
index 0000000..54a8486
Binary files /dev/null and b/fuzzers/corpora/midx/b70d6e7d230fb1393b8f665adcd5658cad7059fe differ
diff --git a/fuzzers/corpora/midx/b87a59f78adb3ef18b0176a8e7fe7e90c2ab4ef7 b/fuzzers/corpora/midx/b87a59f78adb3ef18b0176a8e7fe7e90c2ab4ef7
new file mode 100644
index 0000000..0b9db19
Binary files /dev/null and b/fuzzers/corpora/midx/b87a59f78adb3ef18b0176a8e7fe7e90c2ab4ef7 differ
diff --git a/fuzzers/corpora/midx/b88c5233090e859e923acbdfa9b168f95d7fc14b b/fuzzers/corpora/midx/b88c5233090e859e923acbdfa9b168f95d7fc14b
new file mode 100644
index 0000000..a3841a8
Binary files /dev/null and b/fuzzers/corpora/midx/b88c5233090e859e923acbdfa9b168f95d7fc14b differ
diff --git a/fuzzers/corpora/midx/ba1923ea69eec8fe765e8d1222eccb928ca6c3c2 b/fuzzers/corpora/midx/ba1923ea69eec8fe765e8d1222eccb928ca6c3c2
new file mode 100644
index 0000000..e5534a2
Binary files /dev/null and b/fuzzers/corpora/midx/ba1923ea69eec8fe765e8d1222eccb928ca6c3c2 differ
diff --git a/fuzzers/corpora/midx/ba4d695c1eb02c702bd99a3db27838c7ba617d79 b/fuzzers/corpora/midx/ba4d695c1eb02c702bd99a3db27838c7ba617d79
new file mode 100644
index 0000000..2a60fe9
Binary files /dev/null and b/fuzzers/corpora/midx/ba4d695c1eb02c702bd99a3db27838c7ba617d79 differ
diff --git a/fuzzers/corpora/midx/ba7e4f999dc22d223c7f75db36646bfa05848572 b/fuzzers/corpora/midx/ba7e4f999dc22d223c7f75db36646bfa05848572
new file mode 100644
index 0000000..b942686
Binary files /dev/null and b/fuzzers/corpora/midx/ba7e4f999dc22d223c7f75db36646bfa05848572 differ
diff --git a/fuzzers/corpora/midx/bc5f0cd338d1d17a230378390aa810bc7b103cda b/fuzzers/corpora/midx/bc5f0cd338d1d17a230378390aa810bc7b103cda
new file mode 100644
index 0000000..9b147c4
Binary files /dev/null and b/fuzzers/corpora/midx/bc5f0cd338d1d17a230378390aa810bc7b103cda differ
diff --git a/fuzzers/corpora/midx/bcbb4cf10018a177dd9a6c642d887e0de3d8e522 b/fuzzers/corpora/midx/bcbb4cf10018a177dd9a6c642d887e0de3d8e522
new file mode 100644
index 0000000..400d7bb
Binary files /dev/null and b/fuzzers/corpora/midx/bcbb4cf10018a177dd9a6c642d887e0de3d8e522 differ
diff --git a/fuzzers/corpora/midx/bcfeb114df6d5c6e0c85cbe1081631bc321ff65b b/fuzzers/corpora/midx/bcfeb114df6d5c6e0c85cbe1081631bc321ff65b
new file mode 100644
index 0000000..200a997
Binary files /dev/null and b/fuzzers/corpora/midx/bcfeb114df6d5c6e0c85cbe1081631bc321ff65b differ
diff --git a/fuzzers/corpora/midx/bd582237a9293e2a53d8222722a69e7d215822bf b/fuzzers/corpora/midx/bd582237a9293e2a53d8222722a69e7d215822bf
new file mode 100644
index 0000000..9b34fbc
Binary files /dev/null and b/fuzzers/corpora/midx/bd582237a9293e2a53d8222722a69e7d215822bf differ
diff --git a/fuzzers/corpora/midx/bdc83a415da40f74825379203538a2e4d27cffa7 b/fuzzers/corpora/midx/bdc83a415da40f74825379203538a2e4d27cffa7
new file mode 100644
index 0000000..af4b9e3
Binary files /dev/null and b/fuzzers/corpora/midx/bdc83a415da40f74825379203538a2e4d27cffa7 differ
diff --git a/fuzzers/corpora/midx/be160536594c87dc07554a71c7d24cd1d718aecc b/fuzzers/corpora/midx/be160536594c87dc07554a71c7d24cd1d718aecc
new file mode 100644
index 0000000..2207941
Binary files /dev/null and b/fuzzers/corpora/midx/be160536594c87dc07554a71c7d24cd1d718aecc differ
diff --git a/fuzzers/corpora/midx/be8f3c744a23f67fb316a39609ca11ddac025b58 b/fuzzers/corpora/midx/be8f3c744a23f67fb316a39609ca11ddac025b58
new file mode 100644
index 0000000..e903036
Binary files /dev/null and b/fuzzers/corpora/midx/be8f3c744a23f67fb316a39609ca11ddac025b58 differ
diff --git a/fuzzers/corpora/midx/bf873b027b48f3fd7b727473c832486d99ddb196 b/fuzzers/corpora/midx/bf873b027b48f3fd7b727473c832486d99ddb196
new file mode 100644
index 0000000..f96da4c
Binary files /dev/null and b/fuzzers/corpora/midx/bf873b027b48f3fd7b727473c832486d99ddb196 differ
diff --git a/fuzzers/corpora/midx/bf8e20ef6b79131ef9bab8c9c1bb7dbecbead6a5 b/fuzzers/corpora/midx/bf8e20ef6b79131ef9bab8c9c1bb7dbecbead6a5
new file mode 100644
index 0000000..199ed39
Binary files /dev/null and b/fuzzers/corpora/midx/bf8e20ef6b79131ef9bab8c9c1bb7dbecbead6a5 differ
diff --git a/fuzzers/corpora/midx/bf90507b8f7c7eebb89edeaabf6a432d86e7df4a b/fuzzers/corpora/midx/bf90507b8f7c7eebb89edeaabf6a432d86e7df4a
new file mode 100644
index 0000000..428e567
Binary files /dev/null and b/fuzzers/corpora/midx/bf90507b8f7c7eebb89edeaabf6a432d86e7df4a differ
diff --git a/fuzzers/corpora/midx/bfa7a5ce666899fb3e2a7216dbf59886da672658 b/fuzzers/corpora/midx/bfa7a5ce666899fb3e2a7216dbf59886da672658
new file mode 100644
index 0000000..45cf661
Binary files /dev/null and b/fuzzers/corpora/midx/bfa7a5ce666899fb3e2a7216dbf59886da672658 differ
diff --git a/fuzzers/corpora/midx/bfeaa454d8db33efabba88f146bee6c803369ba0 b/fuzzers/corpora/midx/bfeaa454d8db33efabba88f146bee6c803369ba0
new file mode 100644
index 0000000..82b09f3
Binary files /dev/null and b/fuzzers/corpora/midx/bfeaa454d8db33efabba88f146bee6c803369ba0 differ
diff --git a/fuzzers/corpora/midx/c0388910e8d88dcd2e65848ba2cef465caa6b258 b/fuzzers/corpora/midx/c0388910e8d88dcd2e65848ba2cef465caa6b258
new file mode 100644
index 0000000..01e4b89
Binary files /dev/null and b/fuzzers/corpora/midx/c0388910e8d88dcd2e65848ba2cef465caa6b258 differ
diff --git a/fuzzers/corpora/midx/c0db293f75bb44668bcbb79286ebed87df141a85 b/fuzzers/corpora/midx/c0db293f75bb44668bcbb79286ebed87df141a85
new file mode 100644
index 0000000..bb56c14
Binary files /dev/null and b/fuzzers/corpora/midx/c0db293f75bb44668bcbb79286ebed87df141a85 differ
diff --git a/fuzzers/corpora/midx/c1234da1441255244aba15ecad2a4fa7fd47115e b/fuzzers/corpora/midx/c1234da1441255244aba15ecad2a4fa7fd47115e
new file mode 100644
index 0000000..e79db44
Binary files /dev/null and b/fuzzers/corpora/midx/c1234da1441255244aba15ecad2a4fa7fd47115e differ
diff --git a/fuzzers/corpora/midx/c2206ac3c289a759ee0e9d0d31cc336f0802f7bc b/fuzzers/corpora/midx/c2206ac3c289a759ee0e9d0d31cc336f0802f7bc
new file mode 100644
index 0000000..66a47b9
--- /dev/null
+++ b/fuzzers/corpora/midx/c2206ac3c289a759ee0e9d0d31cc336f0802f7bc
@@ -0,0 +1 @@
+ãïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï;ïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/c22340ab36e5cff088a58272f63cf69e54a1a9f4 b/fuzzers/corpora/midx/c22340ab36e5cff088a58272f63cf69e54a1a9f4
new file mode 100644
index 0000000..5f2f36c
Binary files /dev/null and b/fuzzers/corpora/midx/c22340ab36e5cff088a58272f63cf69e54a1a9f4 differ
diff --git a/fuzzers/corpora/midx/c242c9336c4c22b316e0e56d616b2d45b3318ca4 b/fuzzers/corpora/midx/c242c9336c4c22b316e0e56d616b2d45b3318ca4
new file mode 100644
index 0000000..b4824b4
Binary files /dev/null and b/fuzzers/corpora/midx/c242c9336c4c22b316e0e56d616b2d45b3318ca4 differ
diff --git a/fuzzers/corpora/midx/c25a51d8dfaf58d5b609729bb156a80e3b0d892f b/fuzzers/corpora/midx/c25a51d8dfaf58d5b609729bb156a80e3b0d892f
new file mode 100644
index 0000000..1209373
Binary files /dev/null and b/fuzzers/corpora/midx/c25a51d8dfaf58d5b609729bb156a80e3b0d892f differ
diff --git a/fuzzers/corpora/midx/c3419450240d06982b0d828911b188a903355216 b/fuzzers/corpora/midx/c3419450240d06982b0d828911b188a903355216
new file mode 100644
index 0000000..b0ac7f4
Binary files /dev/null and b/fuzzers/corpora/midx/c3419450240d06982b0d828911b188a903355216 differ
diff --git a/fuzzers/corpora/midx/c36ea7651f76ae817d8d60cae580e47638741372 b/fuzzers/corpora/midx/c36ea7651f76ae817d8d60cae580e47638741372
new file mode 100644
index 0000000..92ef972
Binary files /dev/null and b/fuzzers/corpora/midx/c36ea7651f76ae817d8d60cae580e47638741372 differ
diff --git a/fuzzers/corpora/midx/c42300c021bfd35702f564e917839503922cbe9a b/fuzzers/corpora/midx/c42300c021bfd35702f564e917839503922cbe9a
new file mode 100644
index 0000000..553b6ee
Binary files /dev/null and b/fuzzers/corpora/midx/c42300c021bfd35702f564e917839503922cbe9a differ
diff --git a/fuzzers/corpora/midx/c45d82ddade99ef857b563e435f2efe89e58b0be b/fuzzers/corpora/midx/c45d82ddade99ef857b563e435f2efe89e58b0be
new file mode 100644
index 0000000..a45b45e
Binary files /dev/null and b/fuzzers/corpora/midx/c45d82ddade99ef857b563e435f2efe89e58b0be differ
diff --git a/fuzzers/corpora/midx/c4d1e9187de1e13353b3beb3c1ab16dd62cda571 b/fuzzers/corpora/midx/c4d1e9187de1e13353b3beb3c1ab16dd62cda571
new file mode 100644
index 0000000..12fdcbd
Binary files /dev/null and b/fuzzers/corpora/midx/c4d1e9187de1e13353b3beb3c1ab16dd62cda571 differ
diff --git a/fuzzers/corpora/midx/c4e98278a25011c54734494d4534a97489cf4c24 b/fuzzers/corpora/midx/c4e98278a25011c54734494d4534a97489cf4c24
new file mode 100644
index 0000000..4cef0a1
Binary files /dev/null and b/fuzzers/corpora/midx/c4e98278a25011c54734494d4534a97489cf4c24 differ
diff --git a/fuzzers/corpora/midx/c4f996ab08f56ce2e9fec7a0428ded510dd6a04a b/fuzzers/corpora/midx/c4f996ab08f56ce2e9fec7a0428ded510dd6a04a
new file mode 100644
index 0000000..78d9033
Binary files /dev/null and b/fuzzers/corpora/midx/c4f996ab08f56ce2e9fec7a0428ded510dd6a04a differ
diff --git a/fuzzers/corpora/midx/c544850a7325e7226583895204f99de730525803 b/fuzzers/corpora/midx/c544850a7325e7226583895204f99de730525803
new file mode 100644
index 0000000..cd87f9b
Binary files /dev/null and b/fuzzers/corpora/midx/c544850a7325e7226583895204f99de730525803 differ
diff --git a/fuzzers/corpora/midx/c56629528d5bebdb94f85522caf0f36bbcb19106 b/fuzzers/corpora/midx/c56629528d5bebdb94f85522caf0f36bbcb19106
new file mode 100644
index 0000000..6416cd6
Binary files /dev/null and b/fuzzers/corpora/midx/c56629528d5bebdb94f85522caf0f36bbcb19106 differ
diff --git a/fuzzers/corpora/midx/c5c75b58883ccf41b20b140740e2ce763c6086cd b/fuzzers/corpora/midx/c5c75b58883ccf41b20b140740e2ce763c6086cd
new file mode 100644
index 0000000..9f9a51a
Binary files /dev/null and b/fuzzers/corpora/midx/c5c75b58883ccf41b20b140740e2ce763c6086cd differ
diff --git a/fuzzers/corpora/midx/c62da85dca0d4dfb1d7af5d0520eb74993a1e3b0 b/fuzzers/corpora/midx/c62da85dca0d4dfb1d7af5d0520eb74993a1e3b0
new file mode 100644
index 0000000..8f9050c
Binary files /dev/null and b/fuzzers/corpora/midx/c62da85dca0d4dfb1d7af5d0520eb74993a1e3b0 differ
diff --git a/fuzzers/corpora/midx/c6379aaaecd282b8ed6d0b4291d0d9fdc763160a b/fuzzers/corpora/midx/c6379aaaecd282b8ed6d0b4291d0d9fdc763160a
new file mode 100644
index 0000000..2478f35
Binary files /dev/null and b/fuzzers/corpora/midx/c6379aaaecd282b8ed6d0b4291d0d9fdc763160a differ
diff --git a/fuzzers/corpora/midx/c6431921184e3edf4fd3e47384c69654cdac0189 b/fuzzers/corpora/midx/c6431921184e3edf4fd3e47384c69654cdac0189
new file mode 100644
index 0000000..2acd685
Binary files /dev/null and b/fuzzers/corpora/midx/c6431921184e3edf4fd3e47384c69654cdac0189 differ
diff --git a/fuzzers/corpora/midx/c6f2ca17c6d313a35676cbacd094eb40fd74b23e b/fuzzers/corpora/midx/c6f2ca17c6d313a35676cbacd094eb40fd74b23e
new file mode 100644
index 0000000..d1c63b9
Binary files /dev/null and b/fuzzers/corpora/midx/c6f2ca17c6d313a35676cbacd094eb40fd74b23e differ
diff --git a/fuzzers/corpora/midx/c83e04d58e04fccac37b9dd313eab72011fe8ea1 b/fuzzers/corpora/midx/c83e04d58e04fccac37b9dd313eab72011fe8ea1
new file mode 100644
index 0000000..d11f86a
Binary files /dev/null and b/fuzzers/corpora/midx/c83e04d58e04fccac37b9dd313eab72011fe8ea1 differ
diff --git a/fuzzers/corpora/midx/c88dc350b98a5c5ae0503683318c1f30443906a8 b/fuzzers/corpora/midx/c88dc350b98a5c5ae0503683318c1f30443906a8
new file mode 100644
index 0000000..528a69e
--- /dev/null
+++ b/fuzzers/corpora/midx/c88dc350b98a5c5ae0503683318c1f30443906a8
@@ -0,0 +1 @@
+ãp
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/c89ee2e9e30a474b5f9532ec61d7aad78377baa0 b/fuzzers/corpora/midx/c89ee2e9e30a474b5f9532ec61d7aad78377baa0
new file mode 100644
index 0000000..6280ce2
Binary files /dev/null and b/fuzzers/corpora/midx/c89ee2e9e30a474b5f9532ec61d7aad78377baa0 differ
diff --git a/fuzzers/corpora/midx/c921be4abeb44d1ff07f76f632a16e86526bc4be b/fuzzers/corpora/midx/c921be4abeb44d1ff07f76f632a16e86526bc4be
new file mode 100644
index 0000000..6f53b9d
Binary files /dev/null and b/fuzzers/corpora/midx/c921be4abeb44d1ff07f76f632a16e86526bc4be differ
diff --git a/fuzzers/corpora/midx/c98bdc0431aaece1e8a721aff0ea511cfb8062a6 b/fuzzers/corpora/midx/c98bdc0431aaece1e8a721aff0ea511cfb8062a6
new file mode 100644
index 0000000..cc0580c
Binary files /dev/null and b/fuzzers/corpora/midx/c98bdc0431aaece1e8a721aff0ea511cfb8062a6 differ
diff --git a/fuzzers/corpora/midx/c9c456fd3e35a942ef4ab756e04e725cf1f71167 b/fuzzers/corpora/midx/c9c456fd3e35a942ef4ab756e04e725cf1f71167
new file mode 100644
index 0000000..6a7c367
Binary files /dev/null and b/fuzzers/corpora/midx/c9c456fd3e35a942ef4ab756e04e725cf1f71167 differ
diff --git a/fuzzers/corpora/midx/cd1f1a31b79af77e1e764102942ba7a79dcd24cf b/fuzzers/corpora/midx/cd1f1a31b79af77e1e764102942ba7a79dcd24cf
new file mode 100644
index 0000000..883c745
Binary files /dev/null and b/fuzzers/corpora/midx/cd1f1a31b79af77e1e764102942ba7a79dcd24cf differ
diff --git a/fuzzers/corpora/midx/cd57e5904254c2278e9ecf28ed7414d7aed8eef1 b/fuzzers/corpora/midx/cd57e5904254c2278e9ecf28ed7414d7aed8eef1
new file mode 100644
index 0000000..709c1a4
Binary files /dev/null and b/fuzzers/corpora/midx/cd57e5904254c2278e9ecf28ed7414d7aed8eef1 differ
diff --git a/fuzzers/corpora/midx/cd665cdc2bd6a26eb68c9af6d1728a7d4f6eb309 b/fuzzers/corpora/midx/cd665cdc2bd6a26eb68c9af6d1728a7d4f6eb309
new file mode 100644
index 0000000..094e31b
Binary files /dev/null and b/fuzzers/corpora/midx/cd665cdc2bd6a26eb68c9af6d1728a7d4f6eb309 differ
diff --git a/fuzzers/corpora/midx/ce72111c4314b22c4c7824bc8ea340ebd6d3fa84 b/fuzzers/corpora/midx/ce72111c4314b22c4c7824bc8ea340ebd6d3fa84
new file mode 100644
index 0000000..9bf4135
Binary files /dev/null and b/fuzzers/corpora/midx/ce72111c4314b22c4c7824bc8ea340ebd6d3fa84 differ
diff --git a/fuzzers/corpora/midx/ceacc7ace2f4be962b0db2eeeea3fe6a00ca9dd6 b/fuzzers/corpora/midx/ceacc7ace2f4be962b0db2eeeea3fe6a00ca9dd6
new file mode 100644
index 0000000..6ddf30d
Binary files /dev/null and b/fuzzers/corpora/midx/ceacc7ace2f4be962b0db2eeeea3fe6a00ca9dd6 differ
diff --git a/fuzzers/corpora/midx/cf40769d8b4fcbac1b10ced2e0c3c1294f23fcdd b/fuzzers/corpora/midx/cf40769d8b4fcbac1b10ced2e0c3c1294f23fcdd
new file mode 100644
index 0000000..18327c9
Binary files /dev/null and b/fuzzers/corpora/midx/cf40769d8b4fcbac1b10ced2e0c3c1294f23fcdd differ
diff --git a/fuzzers/corpora/midx/d120111a77a3e3d1d504a04bbfc5f53effa14eb0 b/fuzzers/corpora/midx/d120111a77a3e3d1d504a04bbfc5f53effa14eb0
new file mode 100644
index 0000000..84043fe
Binary files /dev/null and b/fuzzers/corpora/midx/d120111a77a3e3d1d504a04bbfc5f53effa14eb0 differ
diff --git a/fuzzers/corpora/midx/d1ce81240a32aec2de1b0d779aa29a62c36f291f b/fuzzers/corpora/midx/d1ce81240a32aec2de1b0d779aa29a62c36f291f
new file mode 100644
index 0000000..f49192c
Binary files /dev/null and b/fuzzers/corpora/midx/d1ce81240a32aec2de1b0d779aa29a62c36f291f differ
diff --git a/fuzzers/corpora/midx/d21869b290cd2b448e7b8103dced97e62fefffcc b/fuzzers/corpora/midx/d21869b290cd2b448e7b8103dced97e62fefffcc
new file mode 100644
index 0000000..1b98c7f
Binary files /dev/null and b/fuzzers/corpora/midx/d21869b290cd2b448e7b8103dced97e62fefffcc differ
diff --git a/fuzzers/corpora/midx/d2bffcd01e87ce9860007b244ff1e79ecd3d4d0f b/fuzzers/corpora/midx/d2bffcd01e87ce9860007b244ff1e79ecd3d4d0f
new file mode 100644
index 0000000..a7ef0a4
Binary files /dev/null and b/fuzzers/corpora/midx/d2bffcd01e87ce9860007b244ff1e79ecd3d4d0f differ
diff --git a/fuzzers/corpora/midx/d2d668b6e28fca83da5146021879c2b006406fa4 b/fuzzers/corpora/midx/d2d668b6e28fca83da5146021879c2b006406fa4
new file mode 100644
index 0000000..b469259
Binary files /dev/null and b/fuzzers/corpora/midx/d2d668b6e28fca83da5146021879c2b006406fa4 differ
diff --git a/fuzzers/corpora/midx/d37abe0d299b8ad1e90f5b7af302c24f411a7ed1 b/fuzzers/corpora/midx/d37abe0d299b8ad1e90f5b7af302c24f411a7ed1
new file mode 100644
index 0000000..81365c3
Binary files /dev/null and b/fuzzers/corpora/midx/d37abe0d299b8ad1e90f5b7af302c24f411a7ed1 differ
diff --git a/fuzzers/corpora/midx/d3d689a12ab3808313d5ba0044e8c67ecb4337e4 b/fuzzers/corpora/midx/d3d689a12ab3808313d5ba0044e8c67ecb4337e4
new file mode 100644
index 0000000..4afea5e
Binary files /dev/null and b/fuzzers/corpora/midx/d3d689a12ab3808313d5ba0044e8c67ecb4337e4 differ
diff --git a/fuzzers/corpora/midx/d48eb559213edf05aa2850a14194885ae2086ba4 b/fuzzers/corpora/midx/d48eb559213edf05aa2850a14194885ae2086ba4
new file mode 100644
index 0000000..0b91a6f
Binary files /dev/null and b/fuzzers/corpora/midx/d48eb559213edf05aa2850a14194885ae2086ba4 differ
diff --git a/fuzzers/corpora/midx/d490f365693e49ebdeaf658b3f549311a399c6a8 b/fuzzers/corpora/midx/d490f365693e49ebdeaf658b3f549311a399c6a8
new file mode 100644
index 0000000..7ed6c91
Binary files /dev/null and b/fuzzers/corpora/midx/d490f365693e49ebdeaf658b3f549311a399c6a8 differ
diff --git a/fuzzers/corpora/midx/d54821b652a8611c486bedd8645081d3a4b1c8d1 b/fuzzers/corpora/midx/d54821b652a8611c486bedd8645081d3a4b1c8d1
new file mode 100644
index 0000000..eda0c25
Binary files /dev/null and b/fuzzers/corpora/midx/d54821b652a8611c486bedd8645081d3a4b1c8d1 differ
diff --git a/fuzzers/corpora/midx/d5586a91f9a879e8a67ec7b09a48038909918ad9 b/fuzzers/corpora/midx/d5586a91f9a879e8a67ec7b09a48038909918ad9
new file mode 100644
index 0000000..0abb218
Binary files /dev/null and b/fuzzers/corpora/midx/d5586a91f9a879e8a67ec7b09a48038909918ad9 differ
diff --git a/fuzzers/corpora/midx/d696362920a2fad8e280293e8d1c92b18c87e4ae b/fuzzers/corpora/midx/d696362920a2fad8e280293e8d1c92b18c87e4ae
new file mode 100644
index 0000000..b72ac49
Binary files /dev/null and b/fuzzers/corpora/midx/d696362920a2fad8e280293e8d1c92b18c87e4ae differ
diff --git a/fuzzers/corpora/midx/d6b546a2b1bc1c8f80028e4be10c45a06014b32d b/fuzzers/corpora/midx/d6b546a2b1bc1c8f80028e4be10c45a06014b32d
new file mode 100644
index 0000000..75ee6a9
Binary files /dev/null and b/fuzzers/corpora/midx/d6b546a2b1bc1c8f80028e4be10c45a06014b32d differ
diff --git a/fuzzers/corpora/midx/d7f04cbca92b2122e0f437ed4dd8fd1782d40f7f b/fuzzers/corpora/midx/d7f04cbca92b2122e0f437ed4dd8fd1782d40f7f
new file mode 100644
index 0000000..3b0ada6
Binary files /dev/null and b/fuzzers/corpora/midx/d7f04cbca92b2122e0f437ed4dd8fd1782d40f7f differ
diff --git a/fuzzers/corpora/midx/d81944a0c1ed56d11129533d9a3d0d038113d53d b/fuzzers/corpora/midx/d81944a0c1ed56d11129533d9a3d0d038113d53d
new file mode 100644
index 0000000..fa170d1
Binary files /dev/null and b/fuzzers/corpora/midx/d81944a0c1ed56d11129533d9a3d0d038113d53d differ
diff --git a/fuzzers/corpora/midx/d8524e83ea63c9b365c2e93af75a8100a08b1b69 b/fuzzers/corpora/midx/d8524e83ea63c9b365c2e93af75a8100a08b1b69
new file mode 100644
index 0000000..68f680b
Binary files /dev/null and b/fuzzers/corpora/midx/d8524e83ea63c9b365c2e93af75a8100a08b1b69 differ
diff --git a/fuzzers/corpora/midx/d8d9a2d06763cf6feb433cef92a80ef14baab31a b/fuzzers/corpora/midx/d8d9a2d06763cf6feb433cef92a80ef14baab31a
new file mode 100644
index 0000000..2f47818
Binary files /dev/null and b/fuzzers/corpora/midx/d8d9a2d06763cf6feb433cef92a80ef14baab31a differ
diff --git a/fuzzers/corpora/midx/d917fbd641cc40786246387456a636899d56b5a6 b/fuzzers/corpora/midx/d917fbd641cc40786246387456a636899d56b5a6
new file mode 100644
index 0000000..e2d6948
Binary files /dev/null and b/fuzzers/corpora/midx/d917fbd641cc40786246387456a636899d56b5a6 differ
diff --git a/fuzzers/corpora/midx/d99f9ec8b504029457185ac03ea8ba21c2611737 b/fuzzers/corpora/midx/d99f9ec8b504029457185ac03ea8ba21c2611737
new file mode 100644
index 0000000..c3e992a
Binary files /dev/null and b/fuzzers/corpora/midx/d99f9ec8b504029457185ac03ea8ba21c2611737 differ
diff --git a/fuzzers/corpora/midx/d9c9c90c1bbc55beb81875838e9067c473d0fa92 b/fuzzers/corpora/midx/d9c9c90c1bbc55beb81875838e9067c473d0fa92
new file mode 100644
index 0000000..b149456
Binary files /dev/null and b/fuzzers/corpora/midx/d9c9c90c1bbc55beb81875838e9067c473d0fa92 differ
diff --git a/fuzzers/corpora/midx/d9e908317a6ef08a7528924672836a550d34cb5f b/fuzzers/corpora/midx/d9e908317a6ef08a7528924672836a550d34cb5f
new file mode 100644
index 0000000..1c5b0c8
Binary files /dev/null and b/fuzzers/corpora/midx/d9e908317a6ef08a7528924672836a550d34cb5f differ
diff --git a/fuzzers/corpora/midx/d9ef71deb57fa6f40e027be2c84fa37d288e1cc5 b/fuzzers/corpora/midx/d9ef71deb57fa6f40e027be2c84fa37d288e1cc5
new file mode 100644
index 0000000..87ef310
Binary files /dev/null and b/fuzzers/corpora/midx/d9ef71deb57fa6f40e027be2c84fa37d288e1cc5 differ
diff --git a/fuzzers/corpora/midx/da8841b9d04382d62d4aeb3fde4dc78466f31543 b/fuzzers/corpora/midx/da8841b9d04382d62d4aeb3fde4dc78466f31543
new file mode 100644
index 0000000..10eae46
Binary files /dev/null and b/fuzzers/corpora/midx/da8841b9d04382d62d4aeb3fde4dc78466f31543 differ
diff --git a/fuzzers/corpora/midx/db3fbb74c9c9c4185f91eca85f14c3d2c3d9f487 b/fuzzers/corpora/midx/db3fbb74c9c9c4185f91eca85f14c3d2c3d9f487
new file mode 100644
index 0000000..a6344ce
Binary files /dev/null and b/fuzzers/corpora/midx/db3fbb74c9c9c4185f91eca85f14c3d2c3d9f487 differ
diff --git a/fuzzers/corpora/midx/db7a31de22258d4dc17d44a27d9340946e9c9ee9 b/fuzzers/corpora/midx/db7a31de22258d4dc17d44a27d9340946e9c9ee9
new file mode 100644
index 0000000..32c8a8e
Binary files /dev/null and b/fuzzers/corpora/midx/db7a31de22258d4dc17d44a27d9340946e9c9ee9 differ
diff --git a/fuzzers/corpora/midx/dbbe57fc653930b4ff43f168565ba84ef25f60c2 b/fuzzers/corpora/midx/dbbe57fc653930b4ff43f168565ba84ef25f60c2
new file mode 100644
index 0000000..9219ff3
Binary files /dev/null and b/fuzzers/corpora/midx/dbbe57fc653930b4ff43f168565ba84ef25f60c2 differ
diff --git a/fuzzers/corpora/midx/dbe74c0d9e7b62c1fd87d5e3ea73ee04f0337154 b/fuzzers/corpora/midx/dbe74c0d9e7b62c1fd87d5e3ea73ee04f0337154
new file mode 100644
index 0000000..4ebae47
Binary files /dev/null and b/fuzzers/corpora/midx/dbe74c0d9e7b62c1fd87d5e3ea73ee04f0337154 differ
diff --git a/fuzzers/corpora/midx/dbebf36a6b91568ac059142c3ca3211226da12a8 b/fuzzers/corpora/midx/dbebf36a6b91568ac059142c3ca3211226da12a8
new file mode 100644
index 0000000..d180a9b
Binary files /dev/null and b/fuzzers/corpora/midx/dbebf36a6b91568ac059142c3ca3211226da12a8 differ
diff --git a/fuzzers/corpora/midx/ddacbb379242b31a00d62fdff5777dffc1e899c2 b/fuzzers/corpora/midx/ddacbb379242b31a00d62fdff5777dffc1e899c2
new file mode 100644
index 0000000..999ece9
Binary files /dev/null and b/fuzzers/corpora/midx/ddacbb379242b31a00d62fdff5777dffc1e899c2 differ
diff --git a/fuzzers/corpora/midx/decd2cd9cef352610ac9e5cc461df1829543f9f0 b/fuzzers/corpora/midx/decd2cd9cef352610ac9e5cc461df1829543f9f0
new file mode 100644
index 0000000..28af13b
--- /dev/null
+++ b/fuzzers/corpora/midx/decd2cd9cef352610ac9e5cc461df1829543f9f0
@@ -0,0 +1,3 @@
+ã
+yã
+y
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/deeae69363db06972798b296a0c5c99e02cb2b4c b/fuzzers/corpora/midx/deeae69363db06972798b296a0c5c99e02cb2b4c
new file mode 100644
index 0000000..63cffc8
Binary files /dev/null and b/fuzzers/corpora/midx/deeae69363db06972798b296a0c5c99e02cb2b4c differ
diff --git a/fuzzers/corpora/midx/e03e105323e6e7b2af90ad876b5c547af90d8f6b b/fuzzers/corpora/midx/e03e105323e6e7b2af90ad876b5c547af90d8f6b
new file mode 100644
index 0000000..020fa17
Binary files /dev/null and b/fuzzers/corpora/midx/e03e105323e6e7b2af90ad876b5c547af90d8f6b differ
diff --git a/fuzzers/corpora/midx/e3133215848c9cde428338c9d51424c8a81b96f5 b/fuzzers/corpora/midx/e3133215848c9cde428338c9d51424c8a81b96f5
new file mode 100644
index 0000000..460d608
Binary files /dev/null and b/fuzzers/corpora/midx/e3133215848c9cde428338c9d51424c8a81b96f5 differ
diff --git a/fuzzers/corpora/midx/e32a25f0347b0e95d4bea16c27a1f374847683bd b/fuzzers/corpora/midx/e32a25f0347b0e95d4bea16c27a1f374847683bd
new file mode 100644
index 0000000..3329d61
Binary files /dev/null and b/fuzzers/corpora/midx/e32a25f0347b0e95d4bea16c27a1f374847683bd differ
diff --git a/fuzzers/corpora/midx/e45ce97522194abcdd7ff9beb931e20b86c97a79 b/fuzzers/corpora/midx/e45ce97522194abcdd7ff9beb931e20b86c97a79
new file mode 100644
index 0000000..137a820
Binary files /dev/null and b/fuzzers/corpora/midx/e45ce97522194abcdd7ff9beb931e20b86c97a79 differ
diff --git a/fuzzers/corpora/midx/e484023d50fc1036e46a437053b965c527700d42 b/fuzzers/corpora/midx/e484023d50fc1036e46a437053b965c527700d42
new file mode 100644
index 0000000..996f1e6
Binary files /dev/null and b/fuzzers/corpora/midx/e484023d50fc1036e46a437053b965c527700d42 differ
diff --git a/fuzzers/corpora/midx/e4e60e77fe3a050940d0afcc7dbab7ef06b04ba3 b/fuzzers/corpora/midx/e4e60e77fe3a050940d0afcc7dbab7ef06b04ba3
new file mode 100644
index 0000000..31520a8
Binary files /dev/null and b/fuzzers/corpora/midx/e4e60e77fe3a050940d0afcc7dbab7ef06b04ba3 differ
diff --git a/fuzzers/corpora/midx/e51629784092d9cf811ea1bd894297f062ed7ec4 b/fuzzers/corpora/midx/e51629784092d9cf811ea1bd894297f062ed7ec4
new file mode 100644
index 0000000..1f4127c
Binary files /dev/null and b/fuzzers/corpora/midx/e51629784092d9cf811ea1bd894297f062ed7ec4 differ
diff --git a/fuzzers/corpora/midx/e5a7e837029178b3fb6a26d77ea4574ffeaa219d b/fuzzers/corpora/midx/e5a7e837029178b3fb6a26d77ea4574ffeaa219d
new file mode 100644
index 0000000..7607ce3
Binary files /dev/null and b/fuzzers/corpora/midx/e5a7e837029178b3fb6a26d77ea4574ffeaa219d differ
diff --git a/fuzzers/corpora/midx/e5c616e9efdd9c80181f9210d0e3a81c08fe9b4d b/fuzzers/corpora/midx/e5c616e9efdd9c80181f9210d0e3a81c08fe9b4d
new file mode 100644
index 0000000..476b4fd
Binary files /dev/null and b/fuzzers/corpora/midx/e5c616e9efdd9c80181f9210d0e3a81c08fe9b4d differ
diff --git a/fuzzers/corpora/midx/e5e6e84e2c7770537c744bcfdbe8303afe39ef92 b/fuzzers/corpora/midx/e5e6e84e2c7770537c744bcfdbe8303afe39ef92
new file mode 100644
index 0000000..79045de
Binary files /dev/null and b/fuzzers/corpora/midx/e5e6e84e2c7770537c744bcfdbe8303afe39ef92 differ
diff --git a/fuzzers/corpora/midx/e5fb20928feec1ee3114597317edc0e06c413749 b/fuzzers/corpora/midx/e5fb20928feec1ee3114597317edc0e06c413749
new file mode 100644
index 0000000..d6758cf
Binary files /dev/null and b/fuzzers/corpora/midx/e5fb20928feec1ee3114597317edc0e06c413749 differ
diff --git a/fuzzers/corpora/midx/e789319791fe704e5a8ffd7cb570c8d2722ac35f b/fuzzers/corpora/midx/e789319791fe704e5a8ffd7cb570c8d2722ac35f
new file mode 100644
index 0000000..19fdbe7
Binary files /dev/null and b/fuzzers/corpora/midx/e789319791fe704e5a8ffd7cb570c8d2722ac35f differ
diff --git a/fuzzers/corpora/midx/e9fdb9f08f225b4231f01dda9c7b61e7b78bf7d3 b/fuzzers/corpora/midx/e9fdb9f08f225b4231f01dda9c7b61e7b78bf7d3
new file mode 100644
index 0000000..576a1f8
Binary files /dev/null and b/fuzzers/corpora/midx/e9fdb9f08f225b4231f01dda9c7b61e7b78bf7d3 differ
diff --git a/fuzzers/corpora/midx/ea6780324dca9a06db28598dfb590436d846d99f b/fuzzers/corpora/midx/ea6780324dca9a06db28598dfb590436d846d99f
new file mode 100644
index 0000000..d8b617c
Binary files /dev/null and b/fuzzers/corpora/midx/ea6780324dca9a06db28598dfb590436d846d99f differ
diff --git a/fuzzers/corpora/midx/ea6afcc92b8a6c9e14cc053d351909ad5b0a3fdf b/fuzzers/corpora/midx/ea6afcc92b8a6c9e14cc053d351909ad5b0a3fdf
new file mode 100644
index 0000000..8393e36
Binary files /dev/null and b/fuzzers/corpora/midx/ea6afcc92b8a6c9e14cc053d351909ad5b0a3fdf differ
diff --git a/fuzzers/corpora/midx/ea8c569029c0cacc4ae75e95b2f4e84abb6867f4 b/fuzzers/corpora/midx/ea8c569029c0cacc4ae75e95b2f4e84abb6867f4
new file mode 100644
index 0000000..2a86dc5
Binary files /dev/null and b/fuzzers/corpora/midx/ea8c569029c0cacc4ae75e95b2f4e84abb6867f4 differ
diff --git a/fuzzers/corpora/midx/eb3e80c3ea9cfe9e08b2eef117aaa522a51a619c b/fuzzers/corpora/midx/eb3e80c3ea9cfe9e08b2eef117aaa522a51a619c
new file mode 100644
index 0000000..d1fb999
Binary files /dev/null and b/fuzzers/corpora/midx/eb3e80c3ea9cfe9e08b2eef117aaa522a51a619c differ
diff --git a/fuzzers/corpora/midx/ec55b30741fe8fffeec584176c8d20f6a679cfa1 b/fuzzers/corpora/midx/ec55b30741fe8fffeec584176c8d20f6a679cfa1
new file mode 100644
index 0000000..69efa4a
Binary files /dev/null and b/fuzzers/corpora/midx/ec55b30741fe8fffeec584176c8d20f6a679cfa1 differ
diff --git a/fuzzers/corpora/midx/ed0724a6c3804a3ab20a980b5ca48671689a602f b/fuzzers/corpora/midx/ed0724a6c3804a3ab20a980b5ca48671689a602f
new file mode 100644
index 0000000..85ec5a6
Binary files /dev/null and b/fuzzers/corpora/midx/ed0724a6c3804a3ab20a980b5ca48671689a602f differ
diff --git a/fuzzers/corpora/midx/edeb545d1cf852dc9582fa764010fe844a5e3515 b/fuzzers/corpora/midx/edeb545d1cf852dc9582fa764010fe844a5e3515
new file mode 100644
index 0000000..3187fc7
Binary files /dev/null and b/fuzzers/corpora/midx/edeb545d1cf852dc9582fa764010fe844a5e3515 differ
diff --git a/fuzzers/corpora/midx/ee70b920de91f1be6b4448070ee2d1bd9e08286d b/fuzzers/corpora/midx/ee70b920de91f1be6b4448070ee2d1bd9e08286d
new file mode 100644
index 0000000..6d1f0a2
Binary files /dev/null and b/fuzzers/corpora/midx/ee70b920de91f1be6b4448070ee2d1bd9e08286d differ
diff --git a/fuzzers/corpora/midx/ef004af4e947d25b4d1d1dd16502260d4c7a99cd b/fuzzers/corpora/midx/ef004af4e947d25b4d1d1dd16502260d4c7a99cd
new file mode 100644
index 0000000..ac39a8e
Binary files /dev/null and b/fuzzers/corpora/midx/ef004af4e947d25b4d1d1dd16502260d4c7a99cd differ
diff --git a/fuzzers/corpora/midx/f009d226503b73aed0f1fd952ef8725433d158be b/fuzzers/corpora/midx/f009d226503b73aed0f1fd952ef8725433d158be
new file mode 100644
index 0000000..55470ad
Binary files /dev/null and b/fuzzers/corpora/midx/f009d226503b73aed0f1fd952ef8725433d158be differ
diff --git a/fuzzers/corpora/midx/f0a821dffe21afd357932febaf6e8ee331f53197 b/fuzzers/corpora/midx/f0a821dffe21afd357932febaf6e8ee331f53197
new file mode 100644
index 0000000..c4464b1
Binary files /dev/null and b/fuzzers/corpora/midx/f0a821dffe21afd357932febaf6e8ee331f53197 differ
diff --git a/fuzzers/corpora/midx/f101a2fe93dfaaed1c596022b4e509cf3a591c8a b/fuzzers/corpora/midx/f101a2fe93dfaaed1c596022b4e509cf3a591c8a
new file mode 100644
index 0000000..5576bd0
Binary files /dev/null and b/fuzzers/corpora/midx/f101a2fe93dfaaed1c596022b4e509cf3a591c8a differ
diff --git a/fuzzers/corpora/midx/f1101f71657385174f8cb920026a761404b4395d b/fuzzers/corpora/midx/f1101f71657385174f8cb920026a761404b4395d
new file mode 100644
index 0000000..59bd02e
Binary files /dev/null and b/fuzzers/corpora/midx/f1101f71657385174f8cb920026a761404b4395d differ
diff --git a/fuzzers/corpora/midx/f138c84e42d3cc61a219c4be9db791750f0541c8 b/fuzzers/corpora/midx/f138c84e42d3cc61a219c4be9db791750f0541c8
new file mode 100644
index 0000000..ab2d713
--- /dev/null
+++ b/fuzzers/corpora/midx/f138c84e42d3cc61a219c4be9db791750f0541c8
@@ -0,0 +1 @@
+ã]]ÿÿÿÿÿs5e
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/f1da273522bfff4a4971b4ffc31e365f60fdbbfe b/fuzzers/corpora/midx/f1da273522bfff4a4971b4ffc31e365f60fdbbfe
new file mode 100644
index 0000000..7417bb7
Binary files /dev/null and b/fuzzers/corpora/midx/f1da273522bfff4a4971b4ffc31e365f60fdbbfe differ
diff --git a/fuzzers/corpora/midx/f2fe69d30ec47e78a9e92f1423698a52270672b2 b/fuzzers/corpora/midx/f2fe69d30ec47e78a9e92f1423698a52270672b2
new file mode 100644
index 0000000..6eb21da
Binary files /dev/null and b/fuzzers/corpora/midx/f2fe69d30ec47e78a9e92f1423698a52270672b2 differ
diff --git a/fuzzers/corpora/midx/f368bb6f633587a7bb271de7e20695f178c89686 b/fuzzers/corpora/midx/f368bb6f633587a7bb271de7e20695f178c89686
new file mode 100644
index 0000000..0c0cac9
Binary files /dev/null and b/fuzzers/corpora/midx/f368bb6f633587a7bb271de7e20695f178c89686 differ
diff --git a/fuzzers/corpora/midx/f38ced5a16edaceb5f527ebc35e7870f42586c90 b/fuzzers/corpora/midx/f38ced5a16edaceb5f527ebc35e7870f42586c90
new file mode 100644
index 0000000..adc467a
Binary files /dev/null and b/fuzzers/corpora/midx/f38ced5a16edaceb5f527ebc35e7870f42586c90 differ
diff --git a/fuzzers/corpora/midx/f404371362ae68ffb2837ce1766346ebb645d173 b/fuzzers/corpora/midx/f404371362ae68ffb2837ce1766346ebb645d173
new file mode 100644
index 0000000..a0b47bc
Binary files /dev/null and b/fuzzers/corpora/midx/f404371362ae68ffb2837ce1766346ebb645d173 differ
diff --git a/fuzzers/corpora/midx/f473b5e1cf51502345f5c1840ec3948d308dd314 b/fuzzers/corpora/midx/f473b5e1cf51502345f5c1840ec3948d308dd314
new file mode 100644
index 0000000..301811d
Binary files /dev/null and b/fuzzers/corpora/midx/f473b5e1cf51502345f5c1840ec3948d308dd314 differ
diff --git a/fuzzers/corpora/midx/f4ad43d6f913c3be6243dfc439e4b6f5b2e814b9 b/fuzzers/corpora/midx/f4ad43d6f913c3be6243dfc439e4b6f5b2e814b9
new file mode 100644
index 0000000..9e3bc98
Binary files /dev/null and b/fuzzers/corpora/midx/f4ad43d6f913c3be6243dfc439e4b6f5b2e814b9 differ
diff --git a/fuzzers/corpora/midx/f4cde4083a974d755a38bf5ea3820f78b576754a b/fuzzers/corpora/midx/f4cde4083a974d755a38bf5ea3820f78b576754a
new file mode 100644
index 0000000..0699a32
Binary files /dev/null and b/fuzzers/corpora/midx/f4cde4083a974d755a38bf5ea3820f78b576754a differ
diff --git a/fuzzers/corpora/midx/f5888d0dcacda196d73772aabc18fe2ad6e1dfa2 b/fuzzers/corpora/midx/f5888d0dcacda196d73772aabc18fe2ad6e1dfa2
new file mode 100644
index 0000000..488911f
Binary files /dev/null and b/fuzzers/corpora/midx/f5888d0dcacda196d73772aabc18fe2ad6e1dfa2 differ
diff --git a/fuzzers/corpora/midx/f5c3577a62d401f071d5edaa77c54ae98d6a0318 b/fuzzers/corpora/midx/f5c3577a62d401f071d5edaa77c54ae98d6a0318
new file mode 100644
index 0000000..bfec007
--- /dev/null
+++ b/fuzzers/corpora/midx/f5c3577a62d401f071d5edaa77c54ae98d6a0318
@@ -0,0 +1 @@
+Ïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïïï
\ No newline at end of file
diff --git a/fuzzers/corpora/midx/f5dee0d9da0d6950069ac36b1880090a20f50f3e b/fuzzers/corpora/midx/f5dee0d9da0d6950069ac36b1880090a20f50f3e
new file mode 100644
index 0000000..9330af7
Binary files /dev/null and b/fuzzers/corpora/midx/f5dee0d9da0d6950069ac36b1880090a20f50f3e differ
diff --git a/fuzzers/corpora/midx/f605fff495fef2719585c706c05c350812402a35 b/fuzzers/corpora/midx/f605fff495fef2719585c706c05c350812402a35
new file mode 100644
index 0000000..7cae730
Binary files /dev/null and b/fuzzers/corpora/midx/f605fff495fef2719585c706c05c350812402a35 differ
diff --git a/fuzzers/corpora/midx/f6fdaf4e77e29c780b9e0b91637777575bebfab4 b/fuzzers/corpora/midx/f6fdaf4e77e29c780b9e0b91637777575bebfab4
new file mode 100644
index 0000000..0b2545e
Binary files /dev/null and b/fuzzers/corpora/midx/f6fdaf4e77e29c780b9e0b91637777575bebfab4 differ
diff --git a/fuzzers/corpora/midx/f72700bd65fa86c588607ec50d60a9c684c86f43 b/fuzzers/corpora/midx/f72700bd65fa86c588607ec50d60a9c684c86f43
new file mode 100644
index 0000000..3dfa423
Binary files /dev/null and b/fuzzers/corpora/midx/f72700bd65fa86c588607ec50d60a9c684c86f43 differ
diff --git a/fuzzers/corpora/midx/f777db12ef18f002febd5af13e2b948c95d964c3 b/fuzzers/corpora/midx/f777db12ef18f002febd5af13e2b948c95d964c3
new file mode 100644
index 0000000..1869c3d
Binary files /dev/null and b/fuzzers/corpora/midx/f777db12ef18f002febd5af13e2b948c95d964c3 differ
diff --git a/fuzzers/corpora/midx/f777e9274d508e7ac1069e2a04bedc042942491c b/fuzzers/corpora/midx/f777e9274d508e7ac1069e2a04bedc042942491c
new file mode 100644
index 0000000..cb62442
Binary files /dev/null and b/fuzzers/corpora/midx/f777e9274d508e7ac1069e2a04bedc042942491c differ
diff --git a/fuzzers/corpora/midx/f81306f8ceaec3d06d5d34afa9769d15f0d209eb b/fuzzers/corpora/midx/f81306f8ceaec3d06d5d34afa9769d15f0d209eb
new file mode 100644
index 0000000..4a36e1f
Binary files /dev/null and b/fuzzers/corpora/midx/f81306f8ceaec3d06d5d34afa9769d15f0d209eb differ
diff --git a/fuzzers/corpora/midx/f84c2b36689f22809d9bda00febab557c381ffa4 b/fuzzers/corpora/midx/f84c2b36689f22809d9bda00febab557c381ffa4
new file mode 100644
index 0000000..de7f301
Binary files /dev/null and b/fuzzers/corpora/midx/f84c2b36689f22809d9bda00febab557c381ffa4 differ
diff --git a/fuzzers/corpora/midx/f98168fa74c26b17ad0c3002f2263beb0af7c0ce b/fuzzers/corpora/midx/f98168fa74c26b17ad0c3002f2263beb0af7c0ce
new file mode 100644
index 0000000..c1c2043
Binary files /dev/null and b/fuzzers/corpora/midx/f98168fa74c26b17ad0c3002f2263beb0af7c0ce differ
diff --git a/fuzzers/corpora/midx/fa6759d6a2807bbad83ba21761772c0119122c35 b/fuzzers/corpora/midx/fa6759d6a2807bbad83ba21761772c0119122c35
new file mode 100644
index 0000000..79b7fe1
Binary files /dev/null and b/fuzzers/corpora/midx/fa6759d6a2807bbad83ba21761772c0119122c35 differ
diff --git a/fuzzers/corpora/midx/fa8b927b25a67fa3d60b12c53ac365366cc2b52d b/fuzzers/corpora/midx/fa8b927b25a67fa3d60b12c53ac365366cc2b52d
new file mode 100644
index 0000000..22522c2
Binary files /dev/null and b/fuzzers/corpora/midx/fa8b927b25a67fa3d60b12c53ac365366cc2b52d differ
diff --git a/fuzzers/corpora/midx/fc5e4b78e59daebed1118389b57a386981f2430e b/fuzzers/corpora/midx/fc5e4b78e59daebed1118389b57a386981f2430e
new file mode 100644
index 0000000..5c6a22d
Binary files /dev/null and b/fuzzers/corpora/midx/fc5e4b78e59daebed1118389b57a386981f2430e differ
diff --git a/fuzzers/corpora/midx/fdaf408880429153cfcf5d978727cd7b84c3d60e b/fuzzers/corpora/midx/fdaf408880429153cfcf5d978727cd7b84c3d60e
new file mode 100644
index 0000000..76f7c52
Binary files /dev/null and b/fuzzers/corpora/midx/fdaf408880429153cfcf5d978727cd7b84c3d60e differ
diff --git a/fuzzers/corpora/midx/fe50e7564a28683b24c57f8bcdcb3fbfa61f5c6a b/fuzzers/corpora/midx/fe50e7564a28683b24c57f8bcdcb3fbfa61f5c6a
new file mode 100644
index 0000000..f203720
Binary files /dev/null and b/fuzzers/corpora/midx/fe50e7564a28683b24c57f8bcdcb3fbfa61f5c6a differ
diff --git a/fuzzers/corpora/midx/fe64b998872d3ad87df2019173ddc52686841d7d b/fuzzers/corpora/midx/fe64b998872d3ad87df2019173ddc52686841d7d
new file mode 100644
index 0000000..1b4e28e
Binary files /dev/null and b/fuzzers/corpora/midx/fe64b998872d3ad87df2019173ddc52686841d7d differ
diff --git a/fuzzers/corpora/midx/fec56c7cc86871aaa9c7a947c4084307cac2778d b/fuzzers/corpora/midx/fec56c7cc86871aaa9c7a947c4084307cac2778d
new file mode 100644
index 0000000..c57cd18
Binary files /dev/null and b/fuzzers/corpora/midx/fec56c7cc86871aaa9c7a947c4084307cac2778d differ
diff --git a/fuzzers/corpora/midx/ff164dfc56dd28709488130dc6dfc17406bf9e9d b/fuzzers/corpora/midx/ff164dfc56dd28709488130dc6dfc17406bf9e9d
new file mode 100644
index 0000000..ceda10e
Binary files /dev/null and b/fuzzers/corpora/midx/ff164dfc56dd28709488130dc6dfc17406bf9e9d differ
diff --git a/fuzzers/corpora/midx/ff7035b3c055718728a6025b3cdf55c34c4c744b b/fuzzers/corpora/midx/ff7035b3c055718728a6025b3cdf55c34c4c744b
new file mode 100644
index 0000000..8c963ab
Binary files /dev/null and b/fuzzers/corpora/midx/ff7035b3c055718728a6025b3cdf55c34c4c744b differ
diff --git a/fuzzers/midx_fuzzer.c b/fuzzers/midx_fuzzer.c
new file mode 100644
index 0000000..e67873f
--- /dev/null
+++ b/fuzzers/midx_fuzzer.c
@@ -0,0 +1,76 @@
+/*
+ * libgit2 multi-pack-index fuzzer target.
+ *
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include <stdio.h>
+
+#include "git2.h"
+
+#include "buffer.h"
+#include "common.h"
+#include "futils.h"
+#include "hash.h"
+#include "midx.h"
+
+int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ GIT_UNUSED(argc);
+ GIT_UNUSED(argv);
+
+ if (git_libgit2_init() < 0) {
+ fprintf(stderr, "Failed to initialize libgit2\n");
+ abort();
+ }
+ return 0;
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ git_midx_file idx = {{0}};
+ git_midx_entry e;
+ git_buf midx_buf = GIT_BUF_INIT;
+ git_oid oid = {{0}};
+ bool append_hash = false;
+
+ if (size < 4)
+ return 0;
+
+ /*
+ * If the first byte in the stream has the high bit set, append the
+ * SHA1 hash so that the packfile is somewhat valid.
+ */
+ append_hash = *data & 0x80;
+ /* Keep a 4-byte alignment to avoid unaligned accesses. */
+ data += 4;
+ size -= 4;
+
+ if (append_hash) {
+ if (git_buf_init(&midx_buf, size + sizeof(oid)) < 0)
+ goto cleanup;
+ if (git_hash_buf(&oid, data, size) < 0) {
+ fprintf(stderr, "Failed to compute the SHA1 hash\n");
+ abort();
+ }
+ memcpy(midx_buf.ptr, data, size);
+ memcpy(midx_buf.ptr + size, &oid, sizeof(oid));
+ } else {
+ git_buf_attach_notowned(&midx_buf, (char *)data, size);
+ }
+
+ if (git_midx_parse(&idx, (const unsigned char *)git_buf_cstr(&midx_buf), git_buf_len(&midx_buf)) < 0)
+ goto cleanup;
+
+ /* Search for any oid, just to exercise that codepath. */
+ if (git_midx_entry_find(&e, &idx, &oid, GIT_OID_HEXSZ) < 0)
+ goto cleanup;
+
+cleanup:
+ git_midx_close(&idx);
+ git_buf_dispose(&midx_buf);
+ return 0;
+}
diff --git a/git.git-authors b/git.git-authors
index 905bdd2..d9a9114 100644
--- a/git.git-authors
+++ b/git.git-authors
@@ -25,9 +25,9 @@
# contributed code (possibly with some exceptions)
# "no" means the author does not consent
# "ask" means that the contributor wants to give/withhold
-# his/her consent on a patch-by-patch basis.
+# their consent on a patch-by-patch basis.
# "???" means the person is a prominent contributor who has
-# not yet made his/her standpoint clear.
+# not yet made their standpoint clear.
#
# Please try to keep the list alphabetically ordered. It will
# help in case we get all 600-ish git.git authors on it.
diff --git a/include/git2/annotated_commit.h b/include/git2/annotated_commit.h
index fa795bf..3b7103f 100644
--- a/include/git2/annotated_commit.h
+++ b/include/git2/annotated_commit.h
@@ -78,7 +78,7 @@ GIT_EXTERN(int) git_annotated_commit_lookup(
const git_oid *id);
/**
- * Creates a `git_annotated_comit` from a revision string.
+ * Creates a `git_annotated_commit` from a revision string.
*
* See `man gitrevisions`, or
* http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
diff --git a/include/git2/apply.h b/include/git2/apply.h
index b248eaa..bc637df 100644
--- a/include/git2/apply.h
+++ b/include/git2/apply.h
@@ -100,6 +100,7 @@ GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int ver
* @param preimage the tree to apply the diff to
* @param diff the diff to apply
* @param options the options for the apply (or null for defaults)
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_apply_to_tree(
git_index **out,
@@ -137,6 +138,7 @@ typedef enum {
* @param diff the diff to apply
* @param location the location to apply (workdir, index or both)
* @param options the options for the apply (or null for defaults)
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_apply(
git_repository *repo,
diff --git a/include/git2/attr.h b/include/git2/attr.h
index a3ab5a7..62c2ed6 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -130,9 +130,32 @@ GIT_EXTERN(git_attr_value_t) git_attr_value(const char *attr);
*
* Passing the `GIT_ATTR_CHECK_INCLUDE_HEAD` flag will use attributes
* from a `.gitattributes` file in the repository at the HEAD revision.
+ *
+ * Passing the `GIT_ATTR_CHECK_INCLUDE_COMMIT` flag will use attributes
+ * from a `.gitattributes` file in a specific commit.
*/
#define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2)
#define GIT_ATTR_CHECK_INCLUDE_HEAD (1 << 3)
+#define GIT_ATTR_CHECK_INCLUDE_COMMIT (1 << 4)
+
+/**
+* An options structure for querying attributes.
+*/
+typedef struct {
+ unsigned int version;
+
+ /** A combination of GIT_ATTR_CHECK flags */
+ unsigned int flags;
+
+ /**
+ * The commit to load attributes from, when
+ * `GIT_ATTR_CHECK_INCLUDE_COMMIT` is specified.
+ */
+ git_oid *commit_id;
+} git_attr_options;
+
+#define GIT_ATTR_OPTIONS_VERSION 1
+#define GIT_ATTR_OPTIONS_INIT {GIT_ATTR_OPTIONS_VERSION}
/**
* Look up the value of one git attribute for path.
@@ -157,6 +180,28 @@ GIT_EXTERN(int) git_attr_get(
const char *name);
/**
+ * Look up the value of one git attribute for path with extended options.
+ *
+ * @param value_out Output of the value of the attribute. Use the GIT_ATTR_...
+ * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just
+ * use the string value for attributes set to a value. You
+ * should NOT modify or free this value.
+ * @param repo The repository containing the path.
+ * @param opts The `git_attr_options` to use when querying these attributes.
+ * @param path The path to check for attributes. Relative paths are
+ * interpreted relative to the repo root. The file does
+ * not have to exist, but if it does not, then it will be
+ * treated as a plain file (not a directory).
+ * @param name The name of the attribute to look up.
+ */
+GIT_EXTERN(int) git_attr_get_ext(
+ const char **value_out,
+ git_repository *repo,
+ git_attr_options *opts,
+ const char *path,
+ const char *name);
+
+/**
* Look up a list of git attributes for path.
*
* Use this if you have a known list of attributes that you want to
@@ -194,6 +239,30 @@ GIT_EXTERN(int) git_attr_get_many(
const char **names);
/**
+ * Look up a list of git attributes for path with extended options.
+ *
+ * @param values_out An array of num_attr entries that will have string
+ * pointers written into it for the values of the attributes.
+ * You should not modify or free the values that are written
+ * into this array (although of course, you should free the
+ * array itself if you allocated it).
+ * @param repo The repository containing the path.
+ * @param opts The `git_attr_options` to use when querying these attributes.
+ * @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 num_attr The number of attributes being looked up
+ * @param names An array of num_attr strings containing attribute names.
+ */
+GIT_EXTERN(int) git_attr_get_many_ext(
+ const char **values_out,
+ git_repository *repo,
+ git_attr_options *opts,
+ const char *path,
+ size_t num_attr,
+ const char **names);
+
+/**
* The callback used with git_attr_foreach.
*
* This callback will be invoked only once per attribute name, even if there
@@ -232,6 +301,26 @@ GIT_EXTERN(int) git_attr_foreach(
void *payload);
/**
+ * Loop over all the git attributes for a path with extended options.
+ *
+ * @param repo The repository containing the path.
+ * @param opts The `git_attr_options` to use when querying these attributes.
+ * @param path 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 callback Function to invoke on each attribute name and value.
+ * See git_attr_foreach_cb.
+ * @param payload Passed on as extra parameter to callback function.
+ * @return 0 on success, non-zero callback return value, or error code
+ */
+GIT_EXTERN(int) git_attr_foreach_ext(
+ git_repository *repo,
+ git_attr_options *opts,
+ const char *path,
+ git_attr_foreach_cb callback,
+ void *payload);
+
+/**
* Flush the gitattributes cache.
*
* Call this if you have reason to believe that the attributes files on
diff --git a/include/git2/blame.h b/include/git2/blame.h
index 73f6cf9..d193ce1 100644
--- a/include/git2/blame.h
+++ b/include/git2/blame.h
@@ -26,27 +26,54 @@ GIT_BEGIN_DECL
typedef enum {
/** Normal blame, the default */
GIT_BLAME_NORMAL = 0,
- /** Track lines that have moved within a file (like `git blame -M`).
- * NOT IMPLEMENTED. */
+
+ /**
+ * Track lines that have moved within a file (like `git blame -M`).
+ *
+ * This is not yet implemented and reserved for future use.
+ */
GIT_BLAME_TRACK_COPIES_SAME_FILE = (1<<0),
- /** Track lines that have moved across files in the same commit (like `git blame -C`).
- * NOT IMPLEMENTED. */
+
+ /**
+ * Track lines that have moved across files in the same commit
+ * (like `git blame -C`).
+ *
+ * This is not yet implemented and reserved for future use.
+ */
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = (1<<1),
- /** Track lines that have been copied from another file that exists in the
- * same commit (like `git blame -CC`). Implies SAME_FILE.
- * NOT IMPLEMENTED. */
+
+ /**
+ * Track lines that have been copied from another file that exists
+ * in the same commit (like `git blame -CC`). Implies SAME_FILE.
+ *
+ * This is not yet implemented and reserved for future use.
+ */
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = (1<<2),
- /** Track lines that have been copied from another file that exists in *any*
- * commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES.
- * NOT IMPLEMENTED. */
+
+ /**
+ * Track lines that have been copied from another file that exists in
+ * *any* commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES.
+ *
+ * This is not yet implemented and reserved for future use.
+ */
GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = (1<<3),
- /** Restrict the search of commits to those reachable following only the
- * first parents. */
+
+ /**
+ * Restrict the search of commits to those reachable following only
+ * the first parents.
+ */
GIT_BLAME_FIRST_PARENT = (1<<4),
- /** Use mailmap file to map author and committer names and email addresses
- * to canonical real names and email addresses. The mailmap will be read
- * from the working directory, or HEAD in a bare repository. */
+
+ /**
+ * Use mailmap file to map author and committer names and email
+ * addresses to canonical real names and email addresses. The
+ * mailmap will be read from the working directory, or HEAD in a
+ * bare repository.
+ */
GIT_BLAME_USE_MAILMAP = (1<<5),
+
+ /** Ignore whitespace differences */
+ GIT_BLAME_IGNORE_WHITESPACE = (1<<6),
} git_blame_flag_t;
/**
@@ -61,25 +88,33 @@ typedef struct git_blame_options {
/** A combination of `git_blame_flag_t` */
uint32_t flags;
- /** The lower bound on the number of alphanumeric
- * characters that must be detected as moving/copying within a file for it to
- * associate those lines with the parent commit. The default value is 20.
- * This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*`
- * flags are specified.
+
+ /**
+ * The lower bound on the number of alphanumeric characters that
+ * must be detected as moving/copying within a file for it to
+ * associate those lines with the parent commit. The default value
+ * is 20.
+ *
+ * This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*`
+ * flags are specified.
*/
uint16_t min_match_characters;
+
/** The id of the newest commit to consider. The default is HEAD. */
git_oid newest_commit;
+
/**
* The id of the oldest commit to consider.
* The default is the first commit encountered with a NULL parent.
*/
git_oid oldest_commit;
+
/**
* The first line in the file to blame.
* The default is 1 (line numbers start with 1).
*/
size_t min_line;
+
/**
* The last line in the file to blame.
* The default is the last line of the file.
@@ -106,41 +141,59 @@ GIT_EXTERN(int) git_blame_options_init(
/**
* Structure that represents a blame hunk.
- *
- * - `lines_in_hunk` is the number of lines in this hunk
- * - `final_commit_id` is the OID of the commit where this line was last
- * changed.
- * - `final_start_line_number` is the 1-based line number where this hunk
- * begins, in the final version of the file
- * - `final_signature` is the author of `final_commit_id`. If
- * `GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical
- * real name and email address.
- * - `orig_commit_id` is the OID of the commit where this hunk was found. This
- * will usually be the same as `final_commit_id`, except when
- * `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified.
- * - `orig_path` is the path to the file where this hunk originated, as of the
- * commit specified by `orig_commit_id`.
- * - `orig_start_line_number` is the 1-based line number where this hunk begins
- * in the file named by `orig_path` in the commit specified by
- * `orig_commit_id`.
- * - `orig_signature` is the author of `orig_commit_id`. If
- * `GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical
- * real name and email address.
- * - `boundary` is 1 iff the hunk has been tracked to a boundary commit (the
- * root, or the commit specified in git_blame_options.oldest_commit)
*/
typedef struct git_blame_hunk {
+ /**
+ * The number of lines in this hunk.
+ */
size_t lines_in_hunk;
+ /**
+ * The OID of the commit where this line was last changed.
+ */
git_oid final_commit_id;
+
+ /**
+ * The 1-based line number where this hunk begins, in the final version
+ * of the file.
+ */
size_t final_start_line_number;
+
+ /**
+ * The author of `final_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been
+ * specified, it will contain the canonical real name and email address.
+ */
git_signature *final_signature;
+ /**
+ * The OID of the commit where this hunk was found.
+ * This will usually be the same as `final_commit_id`, except when
+ * `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified.
+ */
git_oid orig_commit_id;
+
+ /**
+ * The path to the file where this hunk originated, as of the commit
+ * specified by `orig_commit_id`.
+ */
const char *orig_path;
+
+ /**
+ * The 1-based line number where this hunk begins in the file named by
+ * `orig_path` in the commit specified by `orig_commit_id`.
+ */
size_t orig_start_line_number;
+
+ /**
+ * The author of `orig_commit_id`. If `GIT_BLAME_USE_MAILMAP` has been
+ * specified, it will contain the canonical real name and email address.
+ */
git_signature *orig_signature;
+ /**
+ * The 1 iff the hunk has been tracked to a boundary commit (the root,
+ * or the commit specified in git_blame_options.oldest_commit)
+ */
char boundary;
} git_blame_hunk;
diff --git a/include/git2/blob.h b/include/git2/blob.h
index 7e2a745..fceb5c7 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -84,7 +84,7 @@ GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob);
* time.
*
* @param blob pointer to the blob
- * @return the pointer
+ * @return the pointer, or NULL on error
*/
GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob);
@@ -113,23 +113,51 @@ typedef enum {
* When set, filters will be loaded from a `.gitattributes` file
* in the HEAD commit.
*/
- GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = (1 << 2),
+ GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD = (1 << 2),
+
+ /**
+ * When set, filters will be loaded from a `.gitattributes` file
+ * in the specified commit.
+ */
+ GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3),
} git_blob_filter_flag_t;
/**
* The options used when applying filter options to a file.
+ *
+ * Initialize with `GIT_BLOB_FILTER_OPTIONS_INIT`. Alternatively, you can
+ * use `git_blob_filter_options_init`.
+ *
*/
typedef struct {
int version;
/** Flags to control the filtering process, see `git_blob_filter_flag_t` above */
uint32_t flags;
+
+ /**
+ * The commit to load attributes from, when
+ * `GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT` is specified.
+ */
+ git_oid *commit_id;
} git_blob_filter_options;
#define GIT_BLOB_FILTER_OPTIONS_VERSION 1
#define GIT_BLOB_FILTER_OPTIONS_INIT {GIT_BLOB_FILTER_OPTIONS_VERSION, GIT_BLOB_FILTER_CHECK_FOR_BINARY}
/**
+ * Initialize git_blob_filter_options structure
+ *
+ * Initializes a `git_blob_filter_options` with default values. Equivalent
+ * to creating an instance with `GIT_BLOB_FILTER_OPTIONS_INIT`.
+ *
+ * @param opts The `git_blob_filter_options` struct to initialize.
+ * @param version The struct version; pass `GIT_BLOB_FILTER_OPTIONS_VERSION`.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_blob_filter_options_init(git_blob_filter_options *opts, unsigned int version);
+
+/**
* Get a buffer with the filtered content of a blob.
*
* This applies filters as if the blob was being checked out to the
@@ -229,7 +257,7 @@ GIT_EXTERN(int) git_blob_create_from_stream_commit(
* Write an in-memory buffer to the ODB as a blob
*
* @param id return the id of the written blob
- * @param repo repository where to blob will be written
+ * @param repo repository where the blob will be written
* @param buffer data to be written into the blob
* @param len length of the data
* @return 0 or an error code
diff --git a/include/git2/branch.h b/include/git2/branch.h
index ba62359..24ea7f7 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -304,6 +304,31 @@ GIT_EXTERN(int) git_branch_remote_name(
*/
GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname);
+/**
+ * Retrieve the upstream merge of a local branch
+ *
+ * This will return the currently configured "branch.*.merge" for a given
+ * branch. This branch must be local.
+ *
+ * @param buf the buffer into which to write the name
+ * @param repo the repository in which to look
+ * @param refname the full name of the branch
+ * @return 0 or an error code
+ */
+ GIT_EXTERN(int) git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname);
+
+/**
+ * Determine whether a branch name is valid, meaning that (when prefixed
+ * with `refs/heads/`) that it is a valid reference name, and that any
+ * additional branch name restrictions are imposed (eg, it cannot start
+ * with a `-`).
+ *
+ * @param valid output pointer to set with validity of given branch name
+ * @param name a branch name to test
+ * @return 0 on success or an error code
+ */
+GIT_EXTERN(int) git_branch_name_is_valid(int *valid, const char *name);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/cert.h b/include/git2/cert.h
index e8cd2d1..0ed38ff 100644
--- a/include/git2/cert.h
+++ b/include/git2/cert.h
@@ -8,6 +8,7 @@
#define INCLUDE_git_cert_h__
#include "common.h"
+#include "types.h"
/**
* @file git2/cert.h
@@ -80,8 +81,27 @@ typedef enum {
GIT_CERT_SSH_SHA1 = (1 << 1),
/** SHA-256 is available */
GIT_CERT_SSH_SHA256 = (1 << 2),
+ /** Raw hostkey is available */
+ GIT_CERT_SSH_RAW = (1 << 3),
} git_cert_ssh_t;
+typedef enum {
+ /** The raw key is of an unknown type. */
+ GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0,
+ /** The raw key is an RSA key. */
+ GIT_CERT_SSH_RAW_TYPE_RSA = 1,
+ /** The raw key is a DSS key. */
+ GIT_CERT_SSH_RAW_TYPE_DSS = 2,
+ /** The raw key is a ECDSA 256 key. */
+ GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3,
+ /** The raw key is a ECDSA 384 key. */
+ GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4,
+ /** The raw key is a ECDSA 521 key. */
+ GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5,
+ /** The raw key is a ED25519 key. */
+ GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6
+} git_cert_ssh_raw_type_t;
+
/**
* Hostkey information taken from libssh2
*/
@@ -89,28 +109,45 @@ typedef struct {
git_cert parent; /**< The parent cert */
/**
- * A hostkey type from libssh2, either
- * `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1`
+ * A bitmask containing the available fields.
*/
git_cert_ssh_t type;
/**
- * Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will
+ * Hostkey hash. If `type` has `GIT_CERT_SSH_MD5` set, this will
* have the MD5 hash of the hostkey.
*/
unsigned char hash_md5[16];
/**
- * Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will
+ * Hostkey hash. If `type` has `GIT_CERT_SSH_SHA1` set, this will
* have the SHA-1 hash of the hostkey.
*/
unsigned char hash_sha1[20];
/**
- * Hostkey hash. If type has `GIT_CERT_SSH_SHA256` set, this will
+ * Hostkey hash. If `type` has `GIT_CERT_SSH_SHA256` set, this will
* have the SHA-256 hash of the hostkey.
*/
unsigned char hash_sha256[32];
+
+ /**
+ * Raw hostkey type. If `type` has `GIT_CERT_SSH_RAW` set, this will
+ * have the type of the raw hostkey.
+ */
+ git_cert_ssh_raw_type_t raw_type;
+
+ /**
+ * Pointer to the raw hostkey. If `type` has `GIT_CERT_SSH_RAW` set,
+ * this will have the raw contents of the hostkey.
+ */
+ const char *hostkey;
+
+ /**
+ * Raw hostkey length. If `type` has `GIT_CERT_SSH_RAW` set, this will
+ * have the length of the raw contents of the hostkey.
+ */
+ size_t hostkey_len;
} git_cert_hostkey;
/**
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index 3c87001..ca6f17a 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -194,18 +194,6 @@ typedef enum {
* Checkout will invoke an options notification callback (`notify_cb`) for
* certain cases - you pick which ones via `notify_flags`:
*
- * - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths.
- *
- * - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that
- * do not need an update but no longer match the baseline. Core git
- * displays these files when checkout runs, but won't stop the checkout.
- *
- * - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed.
- *
- * - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files.
- *
- * - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files.
- *
* Returning a non-zero value from this callback will cancel the checkout.
* The non-zero return value will be propagated back and returned by the
* git_checkout_... call.
@@ -216,10 +204,32 @@ typedef enum {
*/
typedef enum {
GIT_CHECKOUT_NOTIFY_NONE = 0,
+
+ /**
+ * Invokes checkout on conflicting paths.
+ */
GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0),
+
+ /**
+ * Notifies about "dirty" files, i.e. those that do not need an update
+ * but no longer match the baseline. Core git displays these files when
+ * checkout runs, but won't stop the checkout.
+ */
GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1),
+
+ /**
+ * Sends notification for any file changed.
+ */
GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2),
+
+ /**
+ * Notifies about untracked files.
+ */
GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3),
+
+ /**
+ * Notifies about ignored files.
+ */
GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4),
GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu
diff --git a/include/git2/common.h b/include/git2/common.h
index d669606..d278c01 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -91,10 +91,10 @@ GIT_BEGIN_DECL
/**
* The separator used in path list strings (ie like in the PATH
- * environment variable). A semi-colon ";" is used on Windows, and
- * a colon ":" for all other systems.
+ * environment variable). A semi-colon ";" is used on Windows and
+ * AmigaOS, and a colon ":" for all other systems.
*/
-#ifdef GIT_WIN32
+#if defined(GIT_WIN32) || defined(AMIGA)
#define GIT_PATH_LIST_SEPARATOR ';'
#else
#define GIT_PATH_LIST_SEPARATOR ':'
@@ -205,7 +205,11 @@ typedef enum {
GIT_OPT_GET_PACK_MAX_OBJECTS,
GIT_OPT_SET_PACK_MAX_OBJECTS,
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
- GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE
+ GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE,
+ GIT_OPT_GET_MWINDOW_FILE_LIMIT,
+ GIT_OPT_SET_MWINDOW_FILE_LIMIT,
+ GIT_OPT_SET_ODB_PACKED_PRIORITY,
+ GIT_OPT_SET_ODB_LOOSE_PRIORITY
} git_libgit2_opt_t;
/**
@@ -227,8 +231,18 @@ typedef enum {
*
* * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
*
- * >Set the maximum amount of memory that can be mapped at any time
- * by the library
+ * > Set the maximum amount of memory that can be mapped at any time
+ * > by the library
+ *
+ * * opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, size_t *):
+ *
+ * > Get the maximum number of files that will be mapped at any time by the
+ * > library
+ *
+ * * opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, size_t):
+ *
+ * > Set the maximum number of files that can be mapped at any time
+ * > by the library. The default (0) is unlimited.
*
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
*
@@ -344,6 +358,11 @@ typedef enum {
* >
* > - `ciphers` is the list of ciphers that are eanbled.
*
+ * * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
+ *
+ * > Get the value of the User-Agent header.
+ * > The User-Agent is written to the `out` buffer.
+ *
* * opts(GIT_OPT_ENABLE_OFS_DELTA, int enabled)
*
* > Enable or disable the use of "offset deltas" when creating packfiles,
@@ -404,6 +423,14 @@ typedef enum {
* > authentication, use expect/continue when POSTing data.
* > This option is not available on Windows.
*
+ * opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, int priority)
+ * > Override the default priority of the packed ODB backend which
+ * > is added when default backends are assigned to a repository
+ *
+ * opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, int priority)
+ * > Override the default priority of the loose ODB backend which
+ * > is added when default backends are assigned to a repository
+ *
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
diff --git a/include/git2/config.h b/include/git2/config.h
index abf5bbb..7c8e388 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -263,7 +263,7 @@ GIT_EXTERN(int) git_config_open_level(
*
* Git allows you to store your global configuration at
* `$HOME/.gitconfig` or `$XDG_CONFIG_HOME/git/config`. For backwards
- * compatability, the XDG file shouldn't be used unless the use has
+ * compatibility, the XDG file shouldn't be used unless the use has
* created it explicitly. With this function you'll open the correct
* one to write to.
*
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index 61d0115..ac60488 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -18,6 +18,7 @@
#include "describe.h"
#include "diff.h"
#include "errors.h"
+#include "filter.h"
#include "index.h"
#include "indexer.h"
#include "merge.h"
@@ -29,6 +30,7 @@
#include "trace.h"
#include "repository.h"
#include "revert.h"
+#include "revparse.h"
#include "stash.h"
#include "status.h"
#include "submodule.h"
@@ -41,6 +43,13 @@
*/
#ifndef GIT_DEPRECATE_HARD
+/*
+ * The credential structures are now opaque by default, and their
+ * definition has moved into the `sys/credential.h` header; include
+ * them here for backward compatibility.
+ */
+#include "sys/credential.h"
+
/**
* @file git2/deprecated.h
* @brief libgit2 deprecated functions and values
@@ -73,16 +82,19 @@ typedef git_attr_value_t git_attr_t;
/**@}*/
-/** @name Deprecated Blob Functions
+/** @name Deprecated Blob Functions and Constants
*
- * These functions are retained for backward compatibility. The newer
- * versions of these functions should be preferred in all new code.
+ * These functions and enumeration values are retained for backward
+ * compatibility. The newer versions of these functions and values
+ * should be preferred in all new code.
*
* There is no plan to remove these backward compatibility values at
* this time.
*/
/**@{*/
+#define GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD
+
GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path);
GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
GIT_EXTERN(int) git_blob_create_fromstream(
@@ -95,7 +107,11 @@ GIT_EXTERN(int) git_blob_create_fromstream_commit(
GIT_EXTERN(int) git_blob_create_frombuffer(
git_oid *id, git_repository *repo, const void *buffer, size_t len);
-/** Deprecated in favor of @see git_blob_filter */
+/** Deprecated in favor of `git_blob_filter`.
+ *
+ * @deprecated Use git_blob_filter
+ * @see git_blob_filter
+ */
GIT_EXTERN(int) git_blob_filtered_content(
git_buf *out,
git_blob *blob,
@@ -104,6 +120,66 @@ GIT_EXTERN(int) git_blob_filtered_content(
/**@}*/
+/** @name Deprecated Filter Functions
+ *
+ * These functions are retained for backward compatibility. The
+ * newer versions of these functions should be preferred in all
+ * new code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+/** Deprecated in favor of `git_filter_list_stream_buffer`.
+ *
+ * @deprecated Use git_filter_list_stream_buffer
+ * @see Use git_filter_list_stream_buffer
+ */
+GIT_EXTERN(int) git_filter_list_stream_data(
+ git_filter_list *filters,
+ git_buf *data,
+ git_writestream *target);
+
+/** Deprecated in favor of `git_filter_list_apply_to_buffer`.
+ *
+ * @deprecated Use git_filter_list_apply_to_buffer
+ * @see Use git_filter_list_apply_to_buffer
+ */
+GIT_EXTERN(int) git_filter_list_apply_to_data(
+ git_buf *out,
+ git_filter_list *filters,
+ git_buf *in);
+
+/**@}*/
+
+/** @name Deprecated Tree Functions
+ *
+ * These functions are retained for backward compatibility. The
+ * newer versions of these functions and values should be preferred
+ * in all new code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+/**
+ * Write the contents of the tree builder as a tree object.
+ * This is an alias of `git_treebuilder_write` and is preserved
+ * for backward compatibility.
+ *
+ * This function is deprecated, but there is no plan to remove this
+ * function at this time.
+ *
+ * @deprecated Use git_treebuilder_write
+ * @see git_treebuilder_write
+ */
+GIT_EXTERN(int) git_treebuilder_write_with_buffer(
+ git_oid *oid, git_treebuilder *bld, git_buf *tree);
+
+/**@}*/
+
/** @name Deprecated Buffer Functions
*
* These functions and enumeration values are retained for backward
@@ -226,7 +302,7 @@ GIT_EXTERN(void) giterr_clear(void);
GIT_EXTERN(void) giterr_set_str(int error_class, const char *string);
/**
- * Indicates that an out-of-memory situation occured. This is an alias
+ * Indicates that an out-of-memory situation occurred. This is an alias
* of `git_error_set_oom` and is preserved for backward compatibility.
*
* This function is deprecated, but there is no plan to remove this
@@ -329,10 +405,32 @@ GIT_EXTERN(size_t) git_object__size(git_object_t type);
/**@}*/
-/** @name Deprecated Reference Constants
+/** @name Deprecated Remote Functions
*
- * These enumeration values are retained for backward compatibility. The
- * newer versions of these values should be preferred in all new code.
+ * These functions are retained for backward compatibility. The newer
+ * versions of these functions should be preferred in all new code.
+ *
+ * There is no plan to remove these backward compatibility functions at
+ * this time.
+ */
+/**@{*/
+
+/**
+ * Ensure the remote name is well-formed.
+ *
+ * @deprecated Use git_remote_name_is_valid
+ * @param remote_name name to be checked.
+ * @return 1 if the reference name is acceptable; 0 if it isn't
+ */
+GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
+
+/**@}*/
+
+/** @name Deprecated Reference Functions and Constants
+ *
+ * These functions and enumeration values are retained for backward
+ * compatibility. The newer versions of these values should be
+ * preferred in all new code.
*
* There is no plan to remove these backward compatibility values at
* this time.
@@ -353,6 +451,23 @@ GIT_EXTERN(size_t) git_object__size(git_object_t type);
#define GIT_REF_FORMAT_REFSPEC_PATTERN GIT_REFERENCE_FORMAT_REFSPEC_PATTERN
#define GIT_REF_FORMAT_REFSPEC_SHORTHAND GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND
+/**
+ * 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.
+ *
+ * @deprecated Use git_reference_name_is_valid
+ * @param refname name to be checked.
+ * @return 1 if the reference name is acceptable; 0 if it isn't
+ */
+GIT_EXTERN(int) git_reference_is_valid_name(const char *refname);
+
GIT_EXTERN(int) git_tag_create_frombuffer(
git_oid *oid,
git_repository *repo,
@@ -361,6 +476,25 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
/**@}*/
+/** @name Deprecated Revspec Constants
+ *
+ * These enumeration values are retained for backward compatibility.
+ * The newer versions of these values should be preferred in all new
+ * code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+typedef git_revspec_t git_revparse_mode_t;
+
+#define GIT_REVPARSE_SINGLE GIT_REVSPEC_SINGLE
+#define GIT_REVPARSE_RANGE GIT_REVSPEC_RANGE
+#define GIT_REVPARSE_MERGE_BASE GIT_REVSPEC_MERGE_BASE
+
+/**@}*/
+
/** @name Deprecated Credential Types
*
* These types are retained for backward compatibility. The newer
@@ -369,6 +503,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
* There is no plan to remove these backward compatibility values at
* this time.
*/
+/**@{*/
typedef git_credential git_cred;
typedef git_credential_userpass_plaintext git_cred_userpass_plaintext;
@@ -517,6 +652,42 @@ typedef int GIT_CALLBACK(git_headlist_cb)(git_remote_head *rhead, void *payload)
/**@}*/
+/** @name Deprecated String Array Functions
+ *
+ * These types are retained for backward compatibility. The newer
+ * versions of these values should be preferred in all new code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+/**
+ * Copy a string array object from source to target.
+ *
+ * This function is deprecated, but there is no plan to remove this
+ * function at this time.
+ *
+ * @param tgt target
+ * @param src source
+ * @return 0 on success, < 0 on allocation failure
+ */
+GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
+
+/**
+ * Free the memory referred to by the git_strarray. This is an alias of
+ * `git_strarray_dispose` and is preserved for backward compatibility.
+ *
+ * This function is deprecated, but there is no plan to remove this
+ * function at this time.
+ *
+ * @deprecated Use git_strarray_dispose
+ * @see git_strarray_dispose
+ */
+GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+
+/**@}*/
+
/** @name Deprecated Options Initialization Functions
*
* These functions are retained for backward compatibility. The newer
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 3976ab1..9497793 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -168,6 +168,10 @@ typedef enum {
* can apply given diff information to binary files.
*/
GIT_DIFF_SHOW_BINARY = (1u << 30),
+
+ /** Ignore blank lines */
+ GIT_DIFF_IGNORE_BLANK_LINES = (1u << 31),
+
} git_diff_option_t;
/**
@@ -237,32 +241,43 @@ typedef enum {
* Although this is called a "file", it could 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).
- *
- * The `id` is the `git_oid` of the item. If the entry represents an
- * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta),
- * then the oid will be zeroes.
- *
- * `path` is the NUL-terminated path to the entry relative to the working
- * directory of the repository.
- *
- * `size` is the size of the entry in bytes.
- *
- * `flags` is a combination of the `git_diff_flag_t` types
- *
- * `mode` is, roughly, the stat() `st_mode` value for the item. This will
- * be restricted to one of the `git_filemode_t` values.
- *
- * The `id_abbrev` represents the known length of the `id` field, when
- * converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this
- * delta was created from reading a patch file, in which case it may be
- * abbreviated to something reasonable, like 7 characters.
*/
typedef struct {
+ /**
+ * The `git_oid` of the item. If the entry represents an
+ * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta),
+ * then the oid will be zeroes.
+ */
git_oid id;
+
+ /**
+ * The NUL-terminated path to the entry relative to the working
+ * directory of the repository.
+ */
const char *path;
+
+ /**
+ * The size of the entry in bytes.
+ */
git_object_size_t size;
+
+ /**
+ * A combination of the `git_diff_flag_t` types
+ */
uint32_t flags;
+
+ /**
+ * Roughly, the stat() `st_mode` value for the item. This will
+ * be restricted to one of the `git_filemode_t` values.
+ */
uint16_t mode;
+
+ /**
+ * Represents the known length of the `id` field, when
+ * converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this
+ * delta was created from reading a patch file, in which case it may be
+ * abbreviated to something reasonable, like 7 characters.
+ */
uint16_t id_abbrev;
} git_diff_file;
@@ -998,7 +1013,7 @@ GIT_EXTERN(size_t) git_diff_num_deltas(const git_diff *diff);
/**
* Query how many diff deltas are there in a diff filtered by type.
*
- * This works just like `git_diff_entrycount()` with an extra parameter
+ * This works just like `git_diff_num_deltas()` with an extra parameter
* that is a `git_delta_t` and returns just the count of how many deltas
* match that particular type.
*
diff --git a/include/git2/errors.h b/include/git2/errors.h
index b4cb87f..de51582 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -107,7 +107,8 @@ typedef enum {
GIT_ERROR_PATCH,
GIT_ERROR_WORKTREE,
GIT_ERROR_SHA1,
- GIT_ERROR_HTTP
+ GIT_ERROR_HTTP,
+ GIT_ERROR_INTERNAL
} git_error_t;
/**
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 8860590..044c3b8 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -49,9 +49,34 @@ typedef enum {
/** Load attributes from `.gitattributes` in the root of HEAD */
GIT_FILTER_ATTRIBUTES_FROM_HEAD = (1u << 2),
+
+ /**
+ * Load attributes from `.gitattributes` in a given commit.
+ * This can only be specified in a `git_filter_options`.
+ */
+ GIT_FILTER_ATTRIBUTES_FROM_COMMIT = (1u << 3),
} git_filter_flag_t;
/**
+ * Filtering options
+ */
+typedef struct {
+ unsigned int version;
+
+ /** See `git_filter_flag_t` above */
+ uint32_t flags;
+
+ /**
+ * The commit to load attributes from, when
+ * `GIT_FILTER_ATTRIBUTES_FROM_COMMIT` is specified.
+ */
+ git_oid *commit_id;
+} git_filter_options;
+
+ #define GIT_FILTER_OPTIONS_VERSION 1
+ #define GIT_FILTER_OPTIONS_INIT {GIT_FILTER_OPTIONS_VERSION}
+
+/**
* A filter that can transform file data
*
* This represents a filter that can be used to transform or even replace
@@ -104,6 +129,29 @@ GIT_EXTERN(int) git_filter_list_load(
uint32_t flags);
/**
+ * Load the filter list for a given path.
+ *
+ * This will return 0 (success) but set the output git_filter_list to NULL
+ * if no filters are requested for the given file.
+ *
+ * @param filters Output newly created git_filter_list (or NULL)
+ * @param repo Repository object that contains `path`
+ * @param blob The blob to which the filter will be applied (if known)
+ * @param path Relative path of the file to be filtered
+ * @param mode Filtering direction (WT->ODB or ODB->WT)
+ * @param opts The `git_filter_options` to use when loading filters
+ * @return 0 on success (which could still return NULL if no filters are
+ * needed for the requested file), <0 on error
+ */
+GIT_EXTERN(int) git_filter_list_load_ext(
+ git_filter_list **filters,
+ git_repository *repo,
+ git_blob *blob,
+ const char *path,
+ git_filter_mode_t mode,
+ git_filter_options *opts);
+
+/**
* Query the filter list to see if a given filter (by name) will run.
* The built-in filters "crlf" and "ident" can be queried, otherwise this
* is the name of the filter specified by the filter attribute.
@@ -122,27 +170,17 @@ GIT_EXTERN(int) git_filter_list_contains(
/**
* Apply filter list to a data buffer.
*
- * See `git2/buffer.h` for background on `git_buf` objects.
- *
- * If the `in` buffer holds data allocated by libgit2 (i.e. `in->asize` is
- * not zero), then it will be overwritten when applying the filters. If
- * not, then it will be left untouched.
- *
- * If there are no filters to apply (or `filters` is NULL), then the `out`
- * buffer will reference the `in` buffer data (with `asize` set to zero)
- * instead of allocating data. This keeps allocations to a minimum, but
- * it means you have to be careful about freeing the `in` data since `out`
- * may be pointing to it!
- *
* @param out Buffer to store the result of the filtering
* @param filters A loaded git_filter_list (or NULL)
* @param in Buffer containing the data to filter
+ * @param in_len The length of the input buffer
* @return 0 on success, an error code otherwise
*/
-GIT_EXTERN(int) git_filter_list_apply_to_data(
+GIT_EXTERN(int) git_filter_list_apply_to_buffer(
git_buf *out,
git_filter_list *filters,
- git_buf *in);
+ const char *in,
+ size_t in_len);
/**
* Apply a filter list to the contents of a file on disk
@@ -175,12 +213,14 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob(
* Apply a filter list to an arbitrary buffer as a stream
*
* @param filters the list of filters to apply
- * @param data the buffer to filter
+ * @param buffer the buffer to filter
+ * @param len the size of the buffer
* @param target the stream into which the data will be written
*/
-GIT_EXTERN(int) git_filter_list_stream_data(
+GIT_EXTERN(int) git_filter_list_stream_buffer(
git_filter_list *filters,
- git_buf *data,
+ const char *buffer,
+ size_t len,
git_writestream *target);
/**
diff --git a/include/git2/graph.h b/include/git2/graph.h
index 213ae97..712ae47 100644
--- a/include/git2/graph.h
+++ b/include/git2/graph.h
@@ -43,8 +43,9 @@ GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_reposi
* Note that a commit is not considered a descendant of itself, in contrast
* to `git merge-base --is-ancestor`.
*
- * @param commit a previously loaded commit.
- * @param ancestor a potential ancestor commit.
+ * @param repo the repository where the commits exist
+ * @param commit a previously loaded commit
+ * @param ancestor a potential ancestor commit
* @return 1 if the given commit is a descendant of the potential ancestor,
* 0 if not, error code otherwise.
*/
@@ -53,6 +54,23 @@ GIT_EXTERN(int) git_graph_descendant_of(
const git_oid *commit,
const git_oid *ancestor);
+/**
+ * Determine if a commit is reachable from any of a list of commits by
+ * following parent edges.
+ *
+ * @param repo the repository where the commits exist
+ * @param commit a previously loaded commit
+ * @param length the number of commits in the provided `descendant_array`
+ * @param descendant_array oids of the commits
+ * @return 1 if the given commit is an ancestor of any of the given potential
+ * descendants, 0 if not, error code otherwise.
+ */
+GIT_EXTERN(int) git_graph_reachable_from_any(
+ git_repository *repo,
+ const git_oid *commit,
+ const git_oid descendant_array[],
+ size_t length);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/index.h b/include/git2/index.h
index 8723aa6..532a520 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -349,7 +349,7 @@ GIT_EXTERN(int) git_index_write_tree(git_oid *out, git_index *index);
*
* The index must not contain any file in conflict.
*
- * @param out Pointer where to store OID of the the written tree
+ * @param out Pointer where to store OID of the written tree
* @param index Index to write
* @param repo Repository where to write the tree
* @return 0 on success, GIT_EUNMERGED when the index is not clean
@@ -555,8 +555,7 @@ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
*
* If a previous index entry exists that has the same path as the
* given 'entry', it will be replaced. Otherwise, the 'entry' will be
- * added. The `id` and the `file_size` of the 'entry' are updated with the
- * real value of the blob.
+ * added.
*
* This forces the file to be added to the index, not looking
* at gitignore rules. Those rules can be evaluated through
@@ -703,7 +702,7 @@ GIT_EXTERN(int) git_index_update_all(
* @param at_pos the address to which the position of the index entry is written (optional)
* @param index an existing index object
* @param path path to search
- * @return a zero-based position in the index if found; GIT_ENOTFOUND otherwise
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *path);
@@ -714,7 +713,7 @@ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *pat
* @param at_pos the address to which the position of the index entry is written (optional)
* @param index an existing index object
* @param prefix the prefix to search for
- * @return 0 with valid value in at_pos; an error code otherwise
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix);
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index 8059e4d..a434d24 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -51,7 +51,7 @@ typedef struct git_indexer_progress {
* Type for progress callbacks during indexing. Return a value less
* than zero to cancel the indexing or download.
*
- * @param stats Structure containing information about the state of the tran sfer
+ * @param stats Structure containing information about the state of the transfer
* @param payload Payload provided by caller
*/
typedef int GIT_CALLBACK(git_indexer_progress_cb)(const git_indexer_progress *stats, void *payload);
@@ -64,6 +64,7 @@ typedef struct git_indexer_options {
/** progress_cb function to call with progress information */
git_indexer_progress_cb progress_cb;
+
/** progress_cb_payload payload for the progress callback */
void *progress_cb_payload;
diff --git a/include/git2/odb.h b/include/git2/odb.h
index c4bfa52..702e1bd 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -70,7 +70,7 @@ GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
*
* @param odb database to add the backend to
* @param path path to the objects folder for the alternate
- * @return 0 on success; error code otherwise
+ * @return 0 on success, error code otherwise
*/
GIT_EXTERN(int) git_odb_add_disk_alternate(git_odb *odb, const char *path);
@@ -94,9 +94,8 @@ GIT_EXTERN(void) git_odb_free(git_odb *db);
* @param out pointer where to store the read object
* @param db database to search for the object in.
* @param id identity of the object to read.
- * @return
- * - 0 if the object was read;
- * - GIT_ENOTFOUND if the object is not in the database.
+ * @return 0 if the object was read, GIT_ENOTFOUND if the object is
+ * not in the database.
*/
GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
@@ -122,10 +121,9 @@ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *i
* @param db database to search for the object in.
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
- * @return
- * - 0 if the object was read;
- * - GIT_ENOTFOUND if the object is not in the database.
- * - GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
+ * @return 0 if the object was read, GIT_ENOTFOUND if the object is not in the
+ * database. GIT_EAMBIGUOUS if the prefix is ambiguous
+ * (several objects match the prefix)
*/
GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len);
@@ -143,9 +141,8 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
* @param type_out pointer where to store the type
* @param db database to search for the object in.
* @param id identity of the object to read.
- * @return
- * - 0 if the object was read;
- * - GIT_ENOTFOUND if the object is not in the database.
+ * @return 0 if the object was read, GIT_ENOTFOUND if the object is not
+ * in the database.
*/
GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git_odb *db, const git_oid *id);
@@ -154,9 +151,7 @@ GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git
*
* @param db database to be searched for the given object.
* @param id the object to search for.
- * @return
- * - 1, if the object was found
- * - 0, otherwise
+ * @return 1 if the object was found, 0 otherwise
*/
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
@@ -305,7 +300,7 @@ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_obje
* @param stream the stream
* @param buffer the data to write
* @param len the buffer's length
- * @return 0 if the write succeeded; error code otherwise
+ * @return 0 if the write succeeded, error code otherwise
*/
GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len);
@@ -320,7 +315,7 @@ GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer,
*
* @param out pointer to store the resulting object's id
* @param stream the stream
- * @return 0 on success; an error code otherwise
+ * @return 0 on success, an error code otherwise
*/
GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream);
@@ -362,7 +357,7 @@ GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream);
* @param type pointer where to store the type of the object
* @param db object database where the stream will read from
* @param oid oid of the object the stream will read from
- * @return 0 if the stream was created; error code otherwise
+ * @return 0 if the stream was created, error code otherwise
*/
GIT_EXTERN(int) git_odb_open_rstream(
git_odb_stream **out,
@@ -501,7 +496,7 @@ GIT_EXTERN(git_object_t) git_odb_object_type(git_odb_object *object);
* @param odb database to add the backend to
* @param backend pointer to a git_odb_backend instance
* @param priority Value for ordering the backends queue
- * @return 0 on success; error code otherwise
+ * @return 0 on success, error code otherwise
*/
GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
@@ -522,7 +517,7 @@ GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int
* @param odb database to add the backend to
* @param backend pointer to a git_odb_backend instance
* @param priority Value for ordering the backends queue
- * @return 0 on success; error code otherwise
+ * @return 0 on success, error code otherwise
*/
GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
@@ -540,10 +535,25 @@ GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb);
* @param out output pointer to ODB backend at pos
* @param odb object database
* @param pos index into object database backend list
- * @return 0 on success; GIT_ENOTFOUND if pos is invalid; other errors < 0
+ * @return 0 on success, GIT_ENOTFOUND if pos is invalid, other errors < 0
*/
GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos);
+/**
+ * Set the git commit-graph for the ODB.
+ *
+ * After a successfull call, the ownership of the cgraph parameter will be
+ * transferred to libgit2, and the caller should not free it.
+ *
+ * The commit-graph can also be unset by explicitly passing NULL as the cgraph
+ * parameter.
+ *
+ * @param odb object database
+ * @param cgraph the git commit-graph
+ * @return 0 on success; error code otherwise
+ */
+GIT_EXTERN(int) git_odb_set_commit_graph(git_odb *odb, git_commit_graph *cgraph);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/pack.h b/include/git2/pack.h
index 922a3cd..3b9beb6 100644
--- a/include/git2/pack.h
+++ b/include/git2/pack.h
@@ -155,7 +155,7 @@ GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
* Write the new pack and corresponding index file to path.
*
* @param pb The packbuilder
- * @param path to the directory where the packfile and index should be stored
+ * @param path Path to the directory where the packfile and index should be stored, or NULL for default location
* @param mode permissions to use creating a packfile or 0 for defaults
* @param progress_cb function to call with progress information from the indexer (optional)
* @param progress_cb_payload payload for the progress callback (optional)
diff --git a/include/git2/patch.h b/include/git2/patch.h
index b177798..fde9659 100644
--- a/include/git2/patch.h
+++ b/include/git2/patch.h
@@ -29,6 +29,14 @@ GIT_BEGIN_DECL
typedef struct git_patch git_patch;
/**
+ * Get the repository associated with this patch. May be NULL.
+ *
+ * @param patch the patch
+ * @return a pointer to the repository
+ */
+GIT_EXTERN(git_repository *) git_patch_owner(const git_patch *patch);
+
+/**
* Return a patch for an entry in the diff list.
*
* The `git_patch` is a newly created object contains the text diffs
diff --git a/include/git2/refs.h b/include/git2/refs.h
index c9cce22..7ebb209 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -97,6 +97,9 @@ GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, co
* of updating does not match the one passed through `current_value`
* (i.e. if the ref has changed since the user read it).
*
+ * If `current_value` is all zeros, this function will return GIT_EMODIFIED
+ * if the ref already exists.
+ *
* @param out Pointer to the newly created reference
* @param repo Repository where that reference will live
* @param name The name of the reference
@@ -169,7 +172,7 @@ GIT_EXTERN(int) git_reference_symbolic_create(git_reference **out, git_repositor
*
* The message for the reflog will be ignored if the reference does
* not belong in the standard set (HEAD, branches and remote-tracking
- * branches) and and it does not have a reflog.
+ * branches) and it does not have a reflog.
*
* @param out Pointer to the newly created reference
* @param repo Repository where that reference will live
@@ -206,7 +209,7 @@ GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo,
*
* The message for the reflog will be ignored if the reference does
* not belong in the standard set (HEAD, branches and remote-tracking
- * branches) and and it does not have a reflog.
+ * branches) and it does not have a reflog.
*
* It will return GIT_EMODIFIED if the reference's value at the time
* of updating does not match the one passed through `current_id`
@@ -318,7 +321,7 @@ GIT_EXTERN(git_repository *) git_reference_owner(const git_reference *ref);
*
* The message for the reflog will be ignored if the reference does
* not belong in the standard set (HEAD, branches and remote-tracking
- * branches) and and it does not have a reflog.
+ * branches) and it does not have a reflog.
*
* @param out Pointer to the newly created reference
* @param ref The reference
@@ -743,10 +746,11 @@ GIT_EXTERN(int) git_reference_peel(
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
* sequences ".." and "@{" which have special meaning to revparse.
*
+ * @param valid output pointer to set with validity of given reference name
* @param refname name to be checked.
- * @return 1 if the reference name is acceptable; 0 if it isn't
+ * @return 0 on success or an error code
*/
-GIT_EXTERN(int) git_reference_is_valid_name(const char *refname);
+GIT_EXTERN(int) git_reference_name_is_valid(int *valid, const char *refname);
/**
* Get the reference's short name
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 51d9c72..5d7a536 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -253,6 +253,7 @@ GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, con
* @param repo the repository in which to perform the change
* @param remote the remote's name
* @param url the url to set
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url);
@@ -876,8 +877,10 @@ GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *rem
* @param repo the repository in which to make the change
* @param remote the name of the remote
* @param value the new value to take.
+ * @return 0, or an error code.
*/
GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value);
+
/**
* Retrieve the ref-prune setting
*
@@ -915,10 +918,11 @@ GIT_EXTERN(int) git_remote_rename(
/**
* Ensure the remote name is well-formed.
*
+ * @param valid output pointer to set with validity of given remote name
* @param remote_name name to be checked.
- * @return 1 if the reference name is acceptable; 0 if it isn't
+ * @return 0 on success or an error code
*/
-GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
+int git_remote_name_is_valid(int *valid, const char *remote_name);
/**
* Delete an existing persisted remote.
@@ -943,7 +947,7 @@ GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name);
*
* This function must only be called after connecting.
*
- * @param out the buffern in which to store the reference name
+ * @param out the buffer in which to store the reference name
* @param remote the remote
* @return 0, GIT_ENOTFOUND if the remote does not have any references
* or none of them point to HEAD's commit, or an error message.
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 45d7962..45becc7 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -219,36 +219,54 @@ GIT_EXTERN(int) git_repository_init(
*
* These flags configure extra behaviors to `git_repository_init_ext`.
* In every case, the default behavior is the zero value (i.e. flag is
- * not set). Just OR the flag values together for the `flags` parameter
- * when initializing a new repo. Details of individual values are:
- *
- * * BARE - Create a bare repository with no working directory.
- * * NO_REINIT - Return an GIT_EEXISTS error if the repo_path appears to
- * already be an git repository.
- * * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo
- * path for non-bare repos (if it is not already there), but
- * passing this flag prevents that behavior.
- * * MKDIR - Make the repo_path (and workdir_path) as needed. Init is
- * always willing to create the ".git" directory even without this
- * flag. This flag tells init to create the trailing component of
- * the repo and workdir paths as needed.
- * * MKPATH - Recursively make all components of the repo and workdir
- * paths as necessary.
- * * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to
- * initialize a new repo. This flags enables external templates,
- * looking the "template_path" from the options if set, or the
- * `init.templatedir` global config if not, or falling back on
- * "/usr/share/git-core/templates" if it exists.
- * * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is
- * specified, use relative paths for the gitdir and core.worktree.
+ * not set). Just OR the flag values together for the `flags` parameter
+ * when initializing a new repo.
*/
typedef enum {
+ /**
+ * Create a bare repository with no working directory.
+ */
GIT_REPOSITORY_INIT_BARE = (1u << 0),
+
+ /**
+ * Return an GIT_EEXISTS error if the repo_path appears to already be
+ * an git repository.
+ */
GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1),
+
+ /**
+ * Normally a "/.git/" will be appended to the repo path for
+ * non-bare repos (if it is not already there), but passing this flag
+ * prevents that behavior.
+ */
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2),
+
+ /**
+ * Make the repo_path (and workdir_path) as needed. Init is always willing
+ * to create the ".git" directory even without this flag. This flag tells
+ * init to create the trailing component of the repo and workdir paths
+ * as needed.
+ */
GIT_REPOSITORY_INIT_MKDIR = (1u << 3),
+
+ /**
+ * Recursively make all components of the repo and workdir paths as
+ * necessary.
+ */
GIT_REPOSITORY_INIT_MKPATH = (1u << 4),
+
+ /**
+ * libgit2 normally uses internal templates to initialize a new repo.
+ * This flags enables external templates, looking the "template_path" from
+ * the options if set, or the `init.templatedir` global config if not,
+ * or falling back on "/usr/share/git-core/templates" if it exists.
+ */
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
+
+ /**
+ * If an alternate workdir is specified, use relative paths for the gitdir
+ * and core.worktree.
+ */
GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6),
} git_repository_init_flag_t;
@@ -257,17 +275,23 @@ typedef enum {
*
* Set the mode field of the `git_repository_init_options` structure
* either to the custom mode that you would like, or to one of the
- * following modes:
- *
- * * SHARED_UMASK - Use permissions configured by umask - the default.
- * * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo
- * to be group writable and "g+sx" for sticky group assignment.
- * * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
- * * Anything else - Set to custom value.
+ * defined modes.
*/
typedef enum {
+ /**
+ * Use permissions configured by umask - the default.
+ */
GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
+
+ /**
+ * Use "--shared=group" behavior, chmod'ing the new repo to be group
+ * writable and "g+sx" for sticky group assignment.
+ */
GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
+
+ /**
+ * Use "--shared=all" behavior, adding world readability.
+ */
GIT_REPOSITORY_INIT_SHARED_ALL = 0002777,
} git_repository_init_mode_t;
@@ -275,38 +299,57 @@ typedef enum {
* Extended options structure for `git_repository_init_ext`.
*
* This contains extra options for `git_repository_init_ext` that enable
- * additional initialization features. The fields are:
- *
- * * flags - Combination of GIT_REPOSITORY_INIT flags above.
- * * mode - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_...
- * constants above, or to a custom value that you would like.
- * * workdir_path - The path to the working dir or NULL for default (i.e.
- * repo_path parent on non-bare repos). IF THIS IS RELATIVE PATH,
- * IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH. If this is not
- * the "natural" working directory, a .git gitlink file will be
- * created here linking to the repo_path.
- * * description - If set, this will be used to initialize the "description"
- * file in the repository, instead of using the template content.
- * * template_path - When GIT_REPOSITORY_INIT_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.
- * * initial_head - 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.
- * * origin_url - 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.
+ * additional initialization features.
*/
typedef struct {
unsigned int version;
+
+ /**
+ * Combination of GIT_REPOSITORY_INIT flags above.
+ */
uint32_t flags;
+
+ /**
+ * Set to one of the standard GIT_REPOSITORY_INIT_SHARED_... constants
+ * above, or to a custom value that you would like.
+ */
uint32_t mode;
+
+ /**
+ * The path to the working dir or NULL for default (i.e. repo_path parent
+ * on non-bare repos). IF THIS IS RELATIVE PATH, IT WILL BE EVALUATED
+ * RELATIVE TO THE REPO_PATH. If this is not the "natural" working
+ * directory, a .git gitlink file will be created here linking to the
+ * repo_path.
+ */
const char *workdir_path;
+
+ /**
+ * If set, this will be used to initialize the "description" file in the
+ * repository, instead of using the template content.
+ */
const char *description;
+
+ /**
+ * When GIT_REPOSITORY_INIT_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.
+ */
const char *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.
+ */
const char *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.
+ */
const char *origin_url;
} git_repository_init_options;
@@ -481,10 +524,11 @@ GIT_EXTERN(const char *) git_repository_path(const git_repository *repo);
GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
/**
- * Get the path of the shared common directory for this repository
- *
- * If the repository is bare is not a worktree, the git directory
- * path is returned.
+ * Get the path of the shared common directory for this repository.
+ *
+ * If the repository is bare, it is the root directory for the repository.
+ * If the repository is a worktree, it is the parent repo's gitdir.
+ * Otherwise, it is the gitdir.
*
* @param repo A repository object
* @return the path to the common dir
diff --git a/include/git2/revparse.h b/include/git2/revparse.h
index d170e16..e14ddee 100644
--- a/include/git2/revparse.h
+++ b/include/git2/revparse.h
@@ -70,12 +70,12 @@ GIT_EXTERN(int) git_revparse_ext(
*/
typedef enum {
/** The spec targeted a single object. */
- GIT_REVPARSE_SINGLE = 1 << 0,
+ GIT_REVSPEC_SINGLE = 1 << 0,
/** The spec targeted a range of commits. */
- GIT_REVPARSE_RANGE = 1 << 1,
+ GIT_REVSPEC_RANGE = 1 << 1,
/** The spec used the '...' operator, which invokes special semantics. */
- GIT_REVPARSE_MERGE_BASE = 1 << 2,
-} git_revparse_mode_t;
+ GIT_REVSPEC_MERGE_BASE = 1 << 2,
+} git_revspec_t;
/**
* Git Revision Spec: output of a `git_revparse` operation
@@ -85,7 +85,7 @@ typedef struct {
git_object *from;
/** The right element of the revspec; must be freed by the user */
git_object *to;
- /** The intent of the revspec (i.e. `git_revparse_mode_t` flags) */
+ /** The intent of the revspec (i.e. `git_revspec_mode_t` flags) */
unsigned int flags;
} git_revspec;
diff --git a/include/git2/status.h b/include/git2/status.h
index 9693cc4..543e3fa 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -69,89 +69,141 @@ typedef int GIT_CALLBACK(git_status_cb)(
* With `git_status_foreach_ext`, this will control which changes get
* callbacks. With `git_status_list_new`, these will control which
* changes are included in the list.
- *
- * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This roughly
- * matches `git status --porcelain` regarding which files are
- * included and in what order.
- * - GIT_STATUS_SHOW_INDEX_ONLY only gives status based on HEAD to index
- * comparison, not looking at working directory changes.
- * - GIT_STATUS_SHOW_WORKDIR_ONLY only gives status based on index to
- * working directory comparison, not comparing the index to the HEAD.
*/
typedef enum {
+ /**
+ * The default. This roughly matches `git status --porcelain` regarding
+ * which files are included and in what order.
+ */
GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0,
+
+ /**
+ * Only gives status based on HEAD to index comparison, not looking at
+ * working directory changes.
+ */
GIT_STATUS_SHOW_INDEX_ONLY = 1,
+
+ /**
+ * Only gives status based on index to working directory comparison,
+ * not comparing the index to the HEAD.
+ */
GIT_STATUS_SHOW_WORKDIR_ONLY = 2,
} git_status_show_t;
/**
* Flags to control status callbacks
*
- * - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should be made
- * on untracked files. These will only be made if the workdir files are
- * included in the status "show" option.
- * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files get callbacks.
- * Again, these callbacks will only be made if the workdir files are
- * included in the status "show" option.
- * - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback should be
- * made even on unmodified files.
- * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that submodules should be
- * skipped. This only applies if there are no pending typechanges to
- * the submodule (either from or to another type).
- * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that all files in
- * untracked directories should be included. Normally if an entire
- * directory is new, then just the top-level directory is included (with
- * a trailing slash on the entry name). This flag says to include all
- * of the individual files in the directory instead.
- * - GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH indicates that the given path
- * should be treated as a literal path, and not as a pathspec pattern.
- * - GIT_STATUS_OPT_RECURSE_IGNORED_DIRS indicates that the contents of
- * ignored directories should be included in the status. This is like
- * doing `git ls-files -o -i --exclude-standard` with core git.
- * - GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX indicates that rename detection
- * should be processed between the head and the index and enables
- * the GIT_STATUS_INDEX_RENAMED as a possible status flag.
- * - GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR indicates that rename
- * detection should be run between the index and the working directory
- * and enabled GIT_STATUS_WT_RENAMED as a possible status flag.
- * - GIT_STATUS_OPT_SORT_CASE_SENSITIVELY overrides the native case
- * sensitivity for the file system and forces the output to be in
- * case-sensitive order
- * - GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY overrides the native case
- * sensitivity for the file system and forces the output to be in
- * case-insensitive order
- * - GIT_STATUS_OPT_RENAMES_FROM_REWRITES indicates that rename detection
- * should include rewritten files
- * - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of
- * doing a "soft" index reload (i.e. reloading the index data if the
- * file on disk has been modified outside libgit2).
- * - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache
- * in the index for files that are unchanged but have out of date stat
- * information in the index. It will result in less work being done on
- * subsequent calls to get status. This is mutually exclusive with the
- * NO_REFRESH option.
- *
* Calling `git_status_foreach()` is like calling the extended version
* with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED,
* and GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS. Those options are bundled
* together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline.
*/
typedef enum {
+ /**
+ * Says that callbacks should be made on untracked files.
+ * These will only be made if the workdir files are included in the status
+ * "show" option.
+ */
GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0),
+
+ /**
+ * Says that ignored files get callbacks.
+ * Again, these callbacks will only be made if the workdir files are
+ * included in the status "show" option.
+ */
GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1),
+
+ /**
+ * Indicates that callback should be made even on unmodified files.
+ */
GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2),
+
+ /**
+ * Indicates that submodules should be skipped.
+ * This only applies if there are no pending typechanges to the submodule
+ * (either from or to another type).
+ */
GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3),
+
+ /**
+ * Indicates that all files in untracked directories should be included.
+ * Normally if an entire directory is new, then just the top-level
+ * directory is included (with a trailing slash on the entry name).
+ * This flag says to include all of the individual files in the directory
+ * instead.
+ */
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4),
+
+ /**
+ * Indicates that the given path should be treated as a literal path,
+ * and not as a pathspec pattern.
+ */
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5),
+
+ /**
+ * Indicates that the contents of ignored directories should be included
+ * in the status. This is like doing `git ls-files -o -i --exclude-standard`
+ * with core git.
+ */
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6),
+
+ /**
+ * Indicates that rename detection should be processed between the head and
+ * the index and enables the GIT_STATUS_INDEX_RENAMED as a possible status
+ * flag.
+ */
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1u << 7),
+
+ /**
+ * Indicates that rename detection should be run between the index and the
+ * working directory and enabled GIT_STATUS_WT_RENAMED as a possible status
+ * flag.
+ */
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1u << 8),
+
+ /**
+ * Overrides the native case sensitivity for the file system and forces
+ * the output to be in case-sensitive order.
+ */
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1u << 9),
+
+ /**
+ * Overrides the native case sensitivity for the file system and forces
+ * the output to be in case-insensitive order.
+ */
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10),
+
+ /**
+ * Iindicates that rename detection should include rewritten files.
+ */
GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1u << 11),
+
+ /**
+ * Bypasses the default status behavior of doing a "soft" index reload
+ * (i.e. reloading the index data if the file on disk has been modified
+ * outside libgit2).
+ */
GIT_STATUS_OPT_NO_REFRESH = (1u << 12),
+
+ /**
+ * Tells libgit2 to refresh the stat cache in the index for files that are
+ * unchanged but have out of date stat einformation in the index.
+ * It will result in less work being done on subsequent calls to get status.
+ * This is mutually exclusive with the NO_REFRESH option.
+ */
GIT_STATUS_OPT_UPDATE_INDEX = (1u << 13),
+
+ /**
+ * Normally files that cannot be opened or read are ignored as
+ * these are often transient files; this option will return
+ * unreadable files as `GIT_STATUS_WT_UNREADABLE`.
+ */
GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1u << 14),
+
+ /**
+ * Unreadable files will be detected and given the status
+ * untracked instead of unreadable.
+ */
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15),
} git_status_opt_t;
@@ -168,7 +220,10 @@ typedef enum {
*
*/
typedef struct {
- unsigned int version; /**< The version */
+ /**
+ * The struct version; pass `GIT_STATUS_OPTIONS_VERSION`.
+ */
+ unsigned int version;
/**
* The `show` value is one of the `git_status_show_t` constants that
@@ -177,21 +232,22 @@ typedef struct {
git_status_show_t show;
/**
- * The `flags` value is an OR'ed combination of the `git_status_opt_t`
- * values above.
+ * The `flags` value is an OR'ed combination of the
+ * `git_status_opt_t` values above.
*/
unsigned int flags;
/**
* The `pathspec` is an array of path patterns to match (using
- * fnmatch-style matching), or just an array of paths to match exactly if
- * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
+ * fnmatch-style matching), or just an array of paths to match
+ * exactly if `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified
+ * in the flags.
*/
git_strarray pathspec;
/**
- * The `baseline` is the tree to be used for comparison to the working directory
- * and index; defaults to HEAD.
+ * The `baseline` is the tree to be used for comparison to the
+ * working directory and index; defaults to HEAD.
*/
git_tree *baseline;
} git_status_options;
diff --git a/include/git2/strarray.h b/include/git2/strarray.h
index 86fa25f..0f657e6 100644
--- a/include/git2/strarray.h
+++ b/include/git2/strarray.h
@@ -25,20 +25,16 @@ typedef struct git_strarray {
} git_strarray;
/**
- * Close a string array object
- *
- * This method should be called on `git_strarray` objects where the strings
- * array is allocated and contains allocated strings, such as what you
- * would get from `git_strarray_copy()`. Not doing so, will result in a
- * memory leak.
+ * Free the strings contained in a string array. This method should
+ * be called on `git_strarray` objects that were provided by the
+ * library. Not doing so, will result in a memory leak.
*
* This does not free the `git_strarray` itself, since the library will
- * never allocate that object directly itself (it is more commonly embedded
- * inside another struct or created on the stack).
+ * never allocate that object directly itself.
*
- * @param array git_strarray from which to free string data
+ * @param array The git_strarray that contains strings to free
*/
-GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+GIT_EXTERN(void) git_strarray_dispose(git_strarray *array);
/**
* Copy a string array object from source to target.
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index bedd76d..29d8bc1 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -224,6 +224,15 @@ GIT_EXTERN(int) git_submodule_lookup(
const char *name);
/**
+ * Create an in-memory copy of a submodule. The copy must be explicitly
+ * free'd or it will leak.
+ *
+ * @param out Pointer to store the copy of the submodule.
+ * @param source Original submodule to copy.
+ */
+GIT_EXTERN(int) git_submodule_dup(git_submodule **out, git_submodule *source);
+
+/**
* Release a submodule
*
* @param submodule Submodule object
diff --git a/include/git2/sys/commit_graph.h b/include/git2/sys/commit_graph.h
new file mode 100644
index 0000000..038c9b7
--- /dev/null
+++ b/include/git2/sys/commit_graph.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_commit_graph_h__
+#define INCLUDE_sys_git_commit_graph_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+
+/**
+ * @file git2/sys/commit_graph.h
+ * @brief Git commit-graph
+ * @defgroup git_commit_graph Git commit-graph APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Opens a `git_commit_graph` from a path to an objects directory.
+ *
+ * This finds, opens, and validates the `commit-graph` file.
+ *
+ * @param cgraph_out the `git_commit_graph` struct to initialize.
+ * @param objects_dir the path to a git objects directory.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_commit_graph_open(git_commit_graph **cgraph_out, const char *objects_dir);
+
+/**
+ * Frees commit-graph data. This should only be called when memory allocated
+ * using `git_commit_graph_open` is not returned to libgit2 because it was not
+ * associated with the ODB through a successful call to
+ * `git_odb_set_commit_graph`.
+ *
+ * @param cgraph the commit-graph object to free. If NULL, no action is taken.
+ */
+GIT_EXTERN(void) git_commit_graph_free(git_commit_graph *cgraph);
+
+GIT_END_DECL
+
+#endif
diff --git a/include/git2/sys/refdb_backend.h b/include/git2/sys/refdb_backend.h
index 8e22c4f..c31e26d 100644
--- a/include/git2/sys/refdb_backend.h
+++ b/include/git2/sys/refdb_backend.h
@@ -64,6 +64,12 @@ struct git_refdb_backend {
* Queries the refdb backend for the existence of a reference.
*
* A refdb implementation must provide this function.
+ *
+ * @arg exists The implementation shall set this to `0` if a ref does
+ * not exist, otherwise to `1`.
+ * @arg ref_name The reference's name that should be checked for
+ * existence.
+ * @return `0` on success, a negative error value code.
*/
int GIT_CALLBACK(exists)(
int *exists,
@@ -74,6 +80,13 @@ struct git_refdb_backend {
* Queries the refdb backend for a given reference.
*
* A refdb implementation must provide this function.
+ *
+ * @arg out The implementation shall set this to the allocated
+ * reference, if it could be found, otherwise to `NULL`.
+ * @arg ref_name The reference's name that should be checked for
+ * existence.
+ * @return `0` on success, `GIT_ENOTFOUND` if the reference does
+ * exist, otherwise a negative error code.
*/
int GIT_CALLBACK(lookup)(
git_reference **out,
@@ -84,6 +97,16 @@ struct git_refdb_backend {
* Allocate an iterator object for the backend.
*
* A refdb implementation must provide this function.
+ *
+ * @arg out The implementation shall set this to the allocated
+ * reference iterator. A custom structure may be used with an
+ * embedded `git_reference_iterator` structure. Both `next`
+ * and `next_name` functions of `git_reference_iterator` need
+ * to be populated.
+ * @arg glob A pattern to filter references by. If given, the iterator
+ * shall only return references that match the glob when
+ * passed to `wildmatch`.
+ * @return `0` on success, otherwise a negative error code.
*/
int GIT_CALLBACK(iterator)(
git_reference_iterator **iter,
@@ -94,6 +117,27 @@ struct git_refdb_backend {
* Writes the given reference to the refdb.
*
* A refdb implementation must provide this function.
+ *
+ * @arg ref The reference to persist. May either be a symbolic or
+ * direct reference.
+ * @arg force Whether to write the reference if a reference with the
+ * same name already exists.
+ * @arg who The person updating the reference. Shall be used to create
+ * a reflog entry.
+ * @arg message The message detailing what kind of reference update is
+ * performed. Shall be used to create a reflog entry.
+ * @arg old If not `NULL` and `force` is not set, then the
+ * implementation needs to ensure that the reference is currently at
+ * the given OID before writing the new value. If both `old`
+ * and `old_target` are `NULL`, then the reference should not
+ * exist at the point of writing.
+ * @arg old_target If not `NULL` and `force` is not set, then the
+ * implementation needs to ensure that the symbolic
+ * reference is currently at the given target before
+ * writing the new value. If both `old` and
+ * `old_target` are `NULL`, then the reference should
+ * not exist at the point of writing.
+ * @return `0` on success, otherwise a negative error code.
*/
int GIT_CALLBACK(write)(git_refdb_backend *backend,
const git_reference *ref, int force,
@@ -104,6 +148,18 @@ struct git_refdb_backend {
* Rename a reference in the refdb.
*
* A refdb implementation must provide this function.
+ *
+ * @arg out The implementation shall set this to the newly created
+ * reference or `NULL` on error.
+ * @arg old_name The current name of the reference that is to be renamed.
+ * @arg new_name The new name that the old reference shall be renamed to.
+ * @arg force Whether to write the reference if a reference with the
+ * target name already exists.
+ * @arg who The person updating the reference. Shall be used to create
+ * a reflog entry.
+ * @arg message The message detailing what kind of reference update is
+ * performed. Shall be used to create a reflog entry.
+ * @return `0` on success, otherwise a negative error code.
*/
int GIT_CALLBACK(rename)(
git_reference **out, git_refdb_backend *backend,
@@ -116,6 +172,16 @@ struct git_refdb_backend {
* If it exists, its reflog should be deleted as well.
*
* A refdb implementation must provide this function.
+ *
+ * @arg ref_name The name of the reference name that shall be deleted.
+ * @arg old_id If not `NULL` and `force` is not set, then the
+ * implementation needs to ensure that the reference is currently at
+ * the given OID before writing the new value.
+ * @arg old_target If not `NULL` and `force` is not set, then the
+ * implementation needs to ensure that the symbolic
+ * reference is currently at the given target before
+ * writing the new value.
+ * @return `0` on success, otherwise a negative error code.
*/
int GIT_CALLBACK(del)(git_refdb_backend *backend, const char *ref_name, const git_oid *old_id, const char *old_target);
@@ -127,13 +193,21 @@ struct git_refdb_backend {
*
* A refdb implementation may provide this function; if it is not
* provided, nothing will be done.
+ *
+ * @return `0` on success a negative error code otherwise
*/
int GIT_CALLBACK(compress)(git_refdb_backend *backend);
/**
* Query whether a particular reference has a log (may be empty)
*
+ * Shall return 1 if it has a reflog, 0 it it doesn't and negative in
+ * case an error occurred.
+ *
* A refdb implementation must provide this function.
+ *
+ * @return `0` on success, `1` if the reflog for the given reference
+ * exists, a negative error code otherwise
*/
int GIT_CALLBACK(has_log)(git_refdb_backend *backend, const char *refname);
@@ -142,6 +216,8 @@ struct git_refdb_backend {
* will be appended to on writes.
*
* A refdb implementation must provide this function.
+ *
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(ensure_log)(git_refdb_backend *backend, const char *refname);
@@ -157,6 +233,8 @@ struct git_refdb_backend {
* Read the reflog for the given reference name.
*
* A refdb implementation must provide this function.
+ *
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(reflog_read)(git_reflog **out, git_refdb_backend *backend, const char *name);
@@ -164,6 +242,11 @@ struct git_refdb_backend {
* Write a reflog to disk.
*
* A refdb implementation must provide this function.
+ *
+ * @arg reflog The complete reference log for a given reference. Note
+ * that this may contain entries that have already been
+ * written to disk.
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(reflog_write)(git_refdb_backend *backend, git_reflog *reflog);
@@ -171,6 +254,10 @@ struct git_refdb_backend {
* Rename a reflog.
*
* A refdb implementation must provide this function.
+ *
+ * @arg old_name The name of old reference whose reflog shall be renamed from.
+ * @arg new_name The name of new reference whose reflog shall be renamed to.
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(reflog_rename)(git_refdb_backend *_backend, const char *old_name, const char *new_name);
@@ -178,16 +265,22 @@ struct git_refdb_backend {
* Remove a reflog.
*
* A refdb implementation must provide this function.
+ *
+ * @arg name The name of the reference whose reflog shall be deleted.
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(reflog_delete)(git_refdb_backend *backend, const char *name);
/**
* Lock a reference.
*
- * The opaque parameter will be passed to the unlock function.
- *
* A refdb implementation may provide this function; if it is not
* provided, the transaction API will fail to work.
+ *
+ * @arg payload_out Opaque parameter that will be passed verbosely to
+ * `unlock`.
+ * @arg refname Reference that shall be locked.
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(lock)(void **payload_out, git_refdb_backend *backend, const char *refname);
@@ -200,6 +293,20 @@ struct git_refdb_backend {
*
* A refdb implementation must provide this function if a `lock`
* implementation is provided.
+ *
+ * @arg payload The payload returned by `lock`.
+ * @arg success `1` if a reference should be updated, `2` if
+ * a reference should be deleted, `0` if the lock must be
+ * discarded.
+ * @arg update_reflog `1` in case the reflog should be updated, `0`
+ * otherwise.
+ * @arg ref The reference which should be unlocked.
+ * @arg who The person updating the reference. Shall be used to create
+ * a reflog entry in case `update_reflog` is set.
+ * @arg message The message detailing what kind of reference update is
+ * performed. Shall be used to create a reflog entry in
+ * case `update_reflog` is set.
+ * @return `0` on success, a negative error code otherwise
*/
int GIT_CALLBACK(unlock)(git_refdb_backend *backend, void *payload, int success, int update_reflog,
const git_reference *ref, const git_signature *sig, const char *message);
diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h
index 6cee42f..fee3454 100644
--- a/include/git2/sys/transport.h
+++ b/include/git2/sys/transport.h
@@ -9,6 +9,7 @@
#define INCLUDE_sys_git_transport_h
#include "git2/net.h"
+#include "git2/transport.h"
#include "git2/types.h"
#include "git2/strarray.h"
#include "git2/proxy.h"
diff --git a/include/git2/tag.h b/include/git2/tag.h
index 4e5fe1d..a392136 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -365,6 +365,18 @@ GIT_EXTERN(int) git_tag_peel(
*/
GIT_EXTERN(int) git_tag_dup(git_tag **out, git_tag *source);
+/**
+ * Determine whether a tag name is valid, meaning that (when prefixed
+ * with `refs/tags/`) that it is a valid reference name, and that any
+ * additional tag name restrictions are imposed (eg, it cannot start
+ * with a `-`).
+ *
+ * @param valid output pointer to set with validity of given tag name
+ * @param name a tag name to test
+ * @return 0 on success or an error code
+ */
+GIT_EXTERN(int) git_tag_name_is_valid(int *valid, const char *name);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/transport.h b/include/git2/transport.h
index fc99ce8..5a27de9 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -23,7 +23,7 @@
GIT_BEGIN_DECL
/**
- * Callback for messages recieved by the transport.
+ * Callback for messages received by the transport.
*
* Return a negative value to cancel the network operation.
*
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 1a8e155..f2289fc 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -334,6 +334,7 @@ GIT_EXTERN(int) git_treebuilder_insert(
*
* @param bld Tree builder
* @param filename Filename of the entry to remove
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_treebuilder_remove(
git_treebuilder *bld, const char *filename);
@@ -378,20 +379,6 @@ GIT_EXTERN(int) git_treebuilder_filter(
GIT_EXTERN(int) git_treebuilder_write(
git_oid *id, git_treebuilder *bld);
-/**
- * Write the contents of the tree builder as a tree object
- * using a shared git_buf.
- *
- * @see git_treebuilder_write
- *
- * @param oid Pointer to store the OID of the newly written tree
- * @param bld Tree builder to write
- * @param tree Shared buffer for writing the tree. Will be grown as necessary.
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_treebuilder_write_with_buffer(
- git_oid *oid, git_treebuilder *bld, git_buf *tree);
-
/** Callback for the tree traversal method */
typedef int GIT_CALLBACK(git_treewalk_cb)(
const char *root, const git_tree_entry *entry, void *payload);
@@ -477,6 +464,7 @@ typedef struct {
* @param baseline the tree to base these changes on
* @param nupdates the number of elements in the update list
* @param updates the list of updates to perform
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseline, size_t nupdates, const git_tree_update *updates);
diff --git a/include/git2/types.h b/include/git2/types.h
index ade0c7d..562eb8e 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -102,6 +102,9 @@ typedef struct git_refdb git_refdb;
/** A custom backend for refs */
typedef struct git_refdb_backend git_refdb_backend;
+/** A git commit-graph */
+typedef struct git_commit_graph git_commit_graph;
+
/**
* Representation of an existing git repository,
* including all its object contents
diff --git a/include/git2/version.h b/include/git2/version.h
index 148808c..c1020bb 100644
--- a/include/git2/version.h
+++ b/include/git2/version.h
@@ -7,12 +7,12 @@
#ifndef INCLUDE_git_version_h__
#define INCLUDE_git_version_h__
-#define LIBGIT2_VERSION "0.28.0"
-#define LIBGIT2_VER_MAJOR 0
-#define LIBGIT2_VER_MINOR 28
+#define LIBGIT2_VERSION "1.1.0"
+#define LIBGIT2_VER_MAJOR 1
+#define LIBGIT2_VER_MINOR 1
#define LIBGIT2_VER_REVISION 0
#define LIBGIT2_VER_PATCH 0
-#define LIBGIT2_SOVERSION 28
+#define LIBGIT2_SOVERSION "1.1"
#endif
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index 049511d..23084d8 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -198,6 +198,7 @@ typedef enum {
typedef struct git_worktree_prune_options {
unsigned int version;
+ /** A combination of `git_worktree_prune_t` */
uint32_t flags;
} git_worktree_prune_options;
diff --git a/package.json b/package.json
index d33f31c..5e74f3b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "libgit2",
- "version": "0.27.0",
+ "version": "1.1.0",
"repo": "https://github.com/libgit2/libgit2",
"description": " A cross-platform, linkable library implementation of Git that you can use in your application.",
"install": "mkdir build && cd build && cmake .. && cmake --build ."
diff --git a/script/release.py b/script/release.py
new file mode 100755
index 0000000..1a240de
--- /dev/null
+++ b/script/release.py
@@ -0,0 +1,191 @@
+#!/usr/bin/env python
+
+from collections import namedtuple
+
+import argparse
+import base64
+import copy
+import json
+import subprocess
+import sys
+import urllib.parse
+import urllib.request
+import urllib.error
+
+class Error(Exception):
+ pass
+
+class Version(object):
+ def __init__(self, version):
+ versions = version.split(sep='.')
+ if len(versions) < 2 or len(versions) > 3:
+ raise Error("Invalid version string '{}'".format(version))
+ self.major = int(versions[0])
+ self.minor = int(versions[1])
+ self.revision = int(versions[2]) if len(versions) == 3 else 0
+
+ def __str__(self):
+ return '{}.{}.{}'.format(self.major, self.minor, self.revision)
+
+ def __eq__(self, other):
+ return self.major == other.major and self.minor == other.minor and self.revision == other.revision
+
+def verify_version(version):
+ expected = {
+ 'VERSION': [ '"{}"'.format(version), None ],
+ 'VER_MAJOR': [ str(version.major), None ],
+ 'VER_MINOR': [ str(version.minor), None ],
+ 'VER_REVISION': [ str(version.revision), None ],
+ 'VER_PATCH': [ '0', None ],
+ 'SOVERSION': [ '"{}.{}"'.format(version.major, version.minor), None ],
+ }
+
+ # Parse CMakeLists
+ with open('CMakeLists.txt') as f:
+ for line in f.readlines():
+ if line.startswith('project(libgit2 VERSION "{}"'.format(version)):
+ break
+ else:
+ raise Error("cmake: invalid project definition")
+
+ # Parse version.h
+ with open('include/git2/version.h') as f:
+ lines = f.readlines()
+
+ for key in expected.keys():
+ define = '#define LIBGIT2_{} '.format(key)
+ for line in lines:
+ if line.startswith(define):
+ expected[key][1] = line[len(define):].strip()
+ break
+ else:
+ raise Error("version.h: missing define for '{}'".format(key))
+
+ for k, v in expected.items():
+ if v[0] != v[1]:
+ raise Error("version.h: define '{}' does not match (got '{}', expected '{}')".format(k, v[0], v[1]))
+
+ with open('package.json') as f:
+ pkg = json.load(f)
+
+ try:
+ pkg_version = Version(pkg["version"])
+ except KeyError as err:
+ raise Error("package.json: missing the field {}".format(err))
+
+ if pkg_version != version:
+ raise Error("package.json: version does not match (got '{}', expected '{}')".format(pkg_version, version))
+
+def generate_relnotes(tree, version):
+ with open('docs/changelog.md') as f:
+ lines = f.readlines()
+
+ if not lines[0].startswith('v'):
+ raise Error("changelog.md: missing section for v{}".format(version))
+ try:
+ v = Version(lines[0][1:].strip())
+ except:
+ raise Error("changelog.md: invalid version string {}".format(lines[0].strip()))
+ if v != version:
+ raise Error("changelog.md: changelog version doesn't match (got {}, expected {})".format(v, version))
+ if not lines[1].startswith('----'):
+ raise Error("changelog.md: missing version header")
+ if lines[2] != '\n':
+ raise Error("changelog.md: missing newline after version header")
+
+ for i, line in enumerate(lines[3:]):
+ if not line.startswith('v'):
+ continue
+ try:
+ Version(line[1:].strip())
+ break
+ except:
+ continue
+ else:
+ raise Error("changelog.md: cannot find section header of preceding release")
+
+ return ''.join(lines[3:i + 3]).strip()
+
+def git(*args):
+ process = subprocess.run([ 'git', *args ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if process.returncode != 0:
+ raise Error('Failed executing git {}: {}'.format(' '.join(args), process.stderr.decode()))
+ return process.stdout
+
+def post(url, data, contenttype, user, password):
+ request = urllib.request.Request(url, data=data)
+ request.add_header('Accept', 'application/json')
+ request.add_header('Content-Type', contenttype)
+ request.add_header('Content-Length', len(data))
+ request.add_header('Authorization', 'Basic ' + base64.b64encode('{}:{}'.format(user, password).encode()).decode())
+
+ try:
+ response = urllib.request.urlopen(request)
+ if response.getcode() != 201:
+ raise Error("POST to '{}' failed: {}".format(url, response.reason))
+ except urllib.error.URLError as e:
+ raise Error("POST to '{}' failed: {}".format(url, e))
+ data = json.load(response)
+
+ return data
+
+def generate_asset(version, tree, archive_format):
+ Asset = namedtuple('Asset', ['name', 'label', 'mimetype', 'data'])
+ mimetype = 'application/{}'.format('gzip' if archive_format == 'tar.gz' else 'zip')
+ return Asset(
+ "libgit2-{}.{}".format(version, archive_format), "Release sources: libgit2-{}.{}".format(version, archive_format), mimetype,
+ git('archive', '--format', archive_format, '--prefix', 'libgit2-{}/'.format(version), tree)
+ )
+
+def release(args):
+ params = {
+ "tag_name": 'v' + str(args.version),
+ "name": 'libgit2 v' + str(args.version),
+ "target_commitish": git('rev-parse', args.tree).decode().strip(),
+ "body": generate_relnotes(args.tree, args.version),
+ }
+ assets = [
+ generate_asset(args.version, args.tree, 'tar.gz'),
+ generate_asset(args.version, args.tree, 'zip'),
+ ]
+
+ if args.dryrun:
+ for k, v in params.items():
+ print('{}: {}'.format(k, v))
+ for asset in assets:
+ print('asset: name={}, label={}, mimetype={}, bytes={}'.format(asset.name, asset.label, asset.mimetype, len(asset.data)))
+ return
+
+ try:
+ url = 'https://api.github.com/repos/{}/releases'.format(args.repository)
+ response = post(url, json.dumps(params).encode(), 'application/json', args.user, args.password)
+ except Error as e:
+ raise Error('Could not create release: ' + str(e))
+
+ for asset in assets:
+ try:
+ url = list(urllib.parse.urlparse(response['upload_url'].split('{?')[0]))
+ url[4] = urllib.parse.urlencode({ 'name': asset.name, 'label': asset.label })
+ post(urllib.parse.urlunparse(url), asset.data, asset.mimetype, args.user, args.password)
+ except Error as e:
+ raise Error('Could not upload asset: ' + str(e))
+
+def main():
+ parser = argparse.ArgumentParser(description='Create a libgit2 release')
+ parser.add_argument('--tree', default='HEAD', help='tree to create release for (default: HEAD)')
+ parser.add_argument('--dryrun', action='store_true', help='generate release, but do not post it')
+ parser.add_argument('--repository', default='libgit2/libgit2', help='GitHub repository to create repository in')
+ parser.add_argument('--user', help='user to authenticate as')
+ parser.add_argument('--password', help='password to authenticate with')
+ parser.add_argument('version', type=Version, help='version of the new release')
+ args = parser.parse_args()
+
+ verify_version(args.version)
+ release(args)
+
+if __name__ == '__main__':
+ try:
+ main()
+ except Error as e:
+ print(e)
+ sys.exit(1)
diff --git a/script/sanitizers.supp b/script/sanitizers.supp
new file mode 100644
index 0000000..4e0e9be
--- /dev/null
+++ b/script/sanitizers.supp
@@ -0,0 +1,4 @@
+[undefined]
+# This library allows unaligned access on Intel-like processors. Prevent UBSan
+# from complaining about that.
+fun:sha1_compression_states
diff --git a/script/thread-sanitizer.supp b/script/thread-sanitizer.supp
new file mode 100644
index 0000000..97d2304
--- /dev/null
+++ b/script/thread-sanitizer.supp
@@ -0,0 +1,26 @@
+# In attr_file_free, the locks are acquired in the opposite order in which they
+# are normally acquired. This is probably something worth fixing to have a
+# consistent lock hierarchy that is easy to understand.
+deadlock:attr_cache_lock
+
+# git_mwindow_file_register has the possibility of evicting some files from the
+# global cache. In order to avoid races and closing files that are currently
+# being accessed, before evicting any file it will attempt to acquire that
+# file's lock. Finally, git_mwindow_file_register is typically called with a
+# file lock held, because the caller will use the fd in the mwf immediately
+# after registering it. This causes ThreadSanitizer to observe different orders
+# of acquisition of the mutex (which implies a possibility of a deadlock),
+# _but_ since the files are added to the cache after other files have been
+# evicted, there cannot be a case where mwf A is trying to be registered while
+# evicting mwf B concurrently and viceversa: at most one of them can be present
+# in the cache.
+deadlock:git_mwindow_file_register
+
+# When invoking the time/timezone functions from git_signature_now(), they
+# access libc methods that need to be instrumented to correctly analyze the
+# data races.
+called_from_lib:libc.so.6
+
+# TODO(#5592): Investigate and fix this. It can be triggered by the `thread`
+# test suite.
+race:git_filter_list__load_ext
diff --git a/script/valgrind.supp b/script/valgrind.supp
index d938aa9..8c4549f 100644
--- a/script/valgrind.supp
+++ b/script/valgrind.supp
@@ -42,6 +42,38 @@
}
{
+ ignore-openssl-init-leak
+ Memcheck:Leak
+ ...
+ fun:git_openssl_stream_global_init
+ ...
+}
+
+{
+ ignore-openssl-legacy-init-leak
+ Memcheck:Leak
+ ...
+ fun:OPENSSL_init_ssl__legacy
+ ...
+}
+
+{
+ ignore-openssl-malloc-leak
+ Memcheck:Leak
+ ...
+ fun:git_openssl_malloc
+ ...
+}
+
+{
+ ignore-openssl-realloc-leak
+ Memcheck:Leak
+ ...
+ fun:git_openssl_realloc
+ ...
+}
+
+{
ignore-glibc-getaddrinfo-cache
Memcheck:Leak
...
@@ -65,6 +97,22 @@
}
{
+ ignore-libssh2-session-create
+ Memcheck:Leak
+ ...
+ fun:_git_ssh_session_create
+ ...
+}
+
+{
+ ignore-libssh2-setup-conn
+ Memcheck:Leak
+ ...
+ fun:_git_ssh_setup_conn
+ ...
+}
+
+{
ignore-libssh2-gcrypt-control-leak
Memcheck:Leak
...
@@ -178,3 +226,19 @@
obj:*libcrypto.so*
...
}
+
+{
+ ignore-dlopen-leak
+ Memcheck:Leak
+ ...
+ fun:dlopen
+ ...
+}
+
+{
+ ignore-dlopen-leak
+ Memcheck:Leak
+ ...
+ fun:_dlerror_run
+ ...
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9e4a41a..45dec27 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,9 +1,23 @@
+add_library(git2internal OBJECT)
+set_target_properties(git2internal PROPERTIES C_STANDARD 90)
+
IF(DEBUG_POOL)
SET(GIT_DEBUG_POOL 1)
ENDIF()
ADD_FEATURE_INFO(debugpool GIT_DEBUG_POOL "debug pool allocator")
+IF(DEBUG_STRICT_ALLOC)
+ SET(GIT_DEBUG_STRICT_ALLOC 1)
+ENDIF()
+ADD_FEATURE_INFO(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators")
+
+IF(DEBUG_STRICT_OPEN)
+ SET(GIT_DEBUG_STRICT_OPEN 1)
+ENDIF()
+ADD_FEATURE_INFO(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open")
+
INCLUDE(PkgBuildConfig)
+INCLUDE(SanitizeBool)
# This variable will contain the libraries we need to put into
# libgit2.pc's Requires.private. That is, what we're linking to or
@@ -21,40 +35,36 @@ SET(LIBGIT2_INCLUDES
SET(LIBGIT2_SYSTEM_INCLUDES "")
SET(LIBGIT2_LIBS "")
-# Installation paths
-#
-SET(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.")
-SET(LIB_INSTALL_DIR lib CACHE PATH "Where to install libraries to.")
-SET(INCLUDE_INSTALL_DIR include CACHE PATH "Where to install headers to.")
+enable_warnings(missing-declarations)
# Enable tracing
-IF (ENABLE_TRACE STREQUAL "ON")
+IF(ENABLE_TRACE)
SET(GIT_TRACE 1)
ENDIF()
ADD_FEATURE_INFO(tracing GIT_TRACE "tracing support")
-CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
IF (HAVE_FUTIMENS)
SET(GIT_USE_FUTIMENS 1)
ENDIF ()
+ADD_FEATURE_INFO(futimens GIT_USE_FUTIMENS "futimens support")
CHECK_PROTOTYPE_DEFINITION(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
"" "stdlib.h" HAVE_QSORT_R_BSD)
IF (HAVE_QSORT_R_BSD)
- ADD_DEFINITIONS(-DHAVE_QSORT_R_BSD)
+ target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
ENDIF()
CHECK_PROTOTYPE_DEFINITION(qsort_r
"void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
"" "stdlib.h" HAVE_QSORT_R_GNU)
IF (HAVE_QSORT_R_GNU)
- ADD_DEFINITIONS(-DHAVE_QSORT_R_GNU)
+ target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
ENDIF()
CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S)
IF (HAVE_QSORT_S)
- ADD_DEFINITIONS(-DHAVE_QSORT_S)
+ target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
ENDIF ()
# Find required dependencies
@@ -82,12 +92,15 @@ ENDIF()
ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
-IF (WIN32 AND EMBED_SSH_PATH)
- FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
- FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
- SET(GIT_SSH 1)
-ENDIF()
+if(WIN32 AND EMBED_SSH_PATH)
+ file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
+ list(SORT SRC_SSH)
+ target_sources(git2internal PRIVATE ${SRC_SSH})
+
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
+ file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
+ set(GIT_SSH 1)
+endif()
IF (WIN32 AND WINHTTP)
SET(GIT_WINHTTP 1)
@@ -107,8 +120,9 @@ IF (WIN32 AND WINHTTP)
LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
ENDIF()
-Include(SelectHTTPSBackend)
-Include(SelectHashes)
+include(SelectHTTPSBackend)
+include(SelectHashes)
+target_sources(git2internal PRIVATE ${SRC_SHA1})
# Specify regular expression implementation
FIND_PACKAGE(PCRE)
@@ -140,7 +154,7 @@ ELSEIF(REGEX_BACKEND STREQUAL "pcre2")
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_REQUIRES "libpcre2")
+ LIST(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
ELSEIF(REGEX_BACKEND STREQUAL "pcre")
ADD_FEATURE_INFO(regex ON "using system PCRE")
SET(GIT_REGEX_PCRE 1)
@@ -183,7 +197,12 @@ ELSE()
ENDIF()
# Optional external dependency: zlib
-IF(NOT USE_BUNDLED_ZLIB)
+SanitizeBool(USE_BUNDLED_ZLIB)
+IF(USE_BUNDLED_ZLIB STREQUAL ON)
+ SET(USE_BUNDLED_ZLIB "Bundled")
+ENDIF()
+
+IF(USE_BUNDLED_ZLIB STREQUAL "OFF")
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
@@ -198,7 +217,12 @@ IF(NOT USE_BUNDLED_ZLIB)
MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
ENDIF()
ENDIF()
-IF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
+IF(USE_BUNDLED_ZLIB STREQUAL "Chromium")
+ ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
+ LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
+ LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
+ ADD_FEATURE_INFO(zlib ON "using (Chromium) bundled zlib")
+ELSEIF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
@@ -270,37 +294,47 @@ ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
SET(GIT_USE_STAT_MTIME_NSEC 1)
ENDIF()
-ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
+target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
# Collect sourcefiles
-FILE(GLOB SRC_H
+file(GLOB SRC_H
"${libgit2_SOURCE_DIR}/include/git2.h"
"${libgit2_SOURCE_DIR}/include/git2/*.h"
"${libgit2_SOURCE_DIR}/include/git2/sys/*.h")
+list(SORT SRC_H)
+target_sources(git2internal PRIVATE ${SRC_H})
# On Windows use specific platform sources
-IF (WIN32 AND NOT CYGWIN)
- IF(MSVC)
- SET(WIN_RC "win32/git2.rc")
- ENDIF()
-
- FILE(GLOB SRC_OS win32/*.c win32/*.h)
-ELSEIF (AMIGA)
- ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
-ELSE()
- ADD_FEATURE_INFO(valgrind VALGRIND "valgrind hints")
- IF (VALGRIND)
- ADD_DEFINITIONS(-DVALGRIND)
- ENDIF()
-
- FILE(GLOB SRC_OS unix/*.c unix/*.h)
+if(WIN32 AND NOT CYGWIN)
+ SET(WIN_RC "win32/git2.rc")
+
+ file(GLOB SRC_OS win32/*.c win32/*.h)
+ list(SORT SRC_OS)
+ target_sources(git2internal PRIVATE ${SRC_OS})
+elseif(AMIGA)
+ target_compile_definitions(git2internal PRIVATE NO_ADDRINFO NO_READDIR_R NO_MMAP)
+else()
+ file(GLOB SRC_OS unix/*.c unix/*.h)
+ list(SORT SRC_OS)
+ target_sources(git2internal PRIVATE ${SRC_OS})
+endif()
+
+IF (USE_LEAK_CHECKER STREQUAL "valgrind")
+ target_compile_definitions(git2internal PRIVATE VALGRIND)
ENDIF()
-FILE(GLOB SRC_GIT2 *.c *.h
+file(GLOB SRC_GIT2 *.c *.h
allocators/*.c allocators/*.h
streams/*.c streams/*.h
transports/*.c transports/*.h
xdiff/*.c xdiff/*.h)
+list(SORT SRC_GIT2)
+target_sources(git2internal PRIVATE ${SRC_GIT2})
+
+IF(APPLE)
+ # The old Secure Transport API has been deprecated in macOS 10.15.
+ SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
+ENDIF()
# the xdiff dependency is not (yet) warning-free, disable warnings as
# errors for the xdiff sources until we've sorted them out
@@ -322,10 +356,6 @@ ENDIF()
CONFIGURE_FILE(features.h.in git2/sys/features.h)
-SET(LIBGIT2_SOURCES ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
-
-ADD_LIBRARY(git2internal OBJECT ${LIBGIT2_SOURCES})
-SET_TARGET_PROPERTIES(git2internal PROPERTIES C_STANDARD 90)
IDE_SPLIT_SOURCES(git2internal)
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
@@ -361,19 +391,19 @@ ENDIF()
IDE_SPLIT_SOURCES(git2)
-IF (SONAME)
- SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
- SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_SOVERSION})
- IF (LIBGIT2_FILENAME)
- ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
- SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
- ELSEIF (DEFINED LIBGIT2_PREFIX)
- SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
- ENDIF()
-ENDIF()
+if(SONAME)
+ set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
+ set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
+ if(LIBGIT2_FILENAME)
+ target_compile_definitions(git2 PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
+ set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
+ elseif(DEFINED LIBGIT2_PREFIX)
+ set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
+ endif()
+endif()
PKG_BUILD_CONFIG(NAME libgit2
- VERSION ${LIBGIT2_VERSION_STRING}
+ VERSION ${libgit2_VERSION}
DESCRIPTION "The git library, take 2"
LIBS_SELF git2
PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
@@ -388,9 +418,9 @@ ENDIF ()
# Install
INSTALL(TARGETS git2
- RUNTIME DESTINATION ${BIN_INSTALL_DIR}
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-INSTALL(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${INCLUDE_INSTALL_DIR} )
-INSTALL(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${INCLUDE_INSTALL_DIR} )
+INSTALL(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+INSTALL(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
diff --git a/src/alloc.c b/src/alloc.c
index 51c4d80..2820d84 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6,16 +6,29 @@
*/
#include "alloc.h"
+#include "runtime.h"
+#include "allocators/failalloc.h"
#include "allocators/stdalloc.h"
-#include "allocators/win32_crtdbg.h"
-
-git_allocator git__allocator;
+#include "allocators/win32_leakcheck.h"
+
+/* Fail any allocation until git_libgit2_init is called. */
+git_allocator git__allocator = {
+ git_failalloc_malloc,
+ git_failalloc_calloc,
+ git_failalloc_strdup,
+ git_failalloc_strndup,
+ git_failalloc_substrdup,
+ git_failalloc_realloc,
+ git_failalloc_reallocarray,
+ git_failalloc_mallocarray,
+ git_failalloc_free
+};
static int setup_default_allocator(void)
{
-#if defined(GIT_MSVC_CRTDBG)
- return git_win32_crtdbg_init_allocator(&git__allocator);
+#if defined(GIT_WIN32_LEAKCHECK)
+ return git_win32_leakcheck_init_allocator(&git__allocator);
#else
return git_stdalloc_init_allocator(&git__allocator);
#endif
@@ -24,10 +37,10 @@ static int setup_default_allocator(void)
int git_allocator_global_init(void)
{
/*
- * We don't want to overwrite any allocator which has been set before
- * the init function is called.
+ * We don't want to overwrite any allocator which has been set
+ * before the init function is called.
*/
- if (git__allocator.gmalloc != NULL)
+ if (git__allocator.gmalloc != git_failalloc_malloc)
return 0;
return setup_default_allocator();
diff --git a/src/allocators/failalloc.c b/src/allocators/failalloc.c
new file mode 100644
index 0000000..5257d1d
--- /dev/null
+++ b/src/allocators/failalloc.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "failalloc.h"
+
+void *git_failalloc_malloc(size_t len, const char *file, int line)
+{
+ GIT_UNUSED(len);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+void *git_failalloc_calloc(size_t nelem, size_t elsize, const char *file, int line)
+{
+ GIT_UNUSED(nelem);
+ GIT_UNUSED(elsize);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+char *git_failalloc_strdup(const char *str, const char *file, int line)
+{
+ GIT_UNUSED(str);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+char *git_failalloc_strndup(const char *str, size_t n, const char *file, int line)
+{
+ GIT_UNUSED(str);
+ GIT_UNUSED(n);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+char *git_failalloc_substrdup(const char *start, size_t n, const char *file, int line)
+{
+ GIT_UNUSED(start);
+ GIT_UNUSED(n);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+void *git_failalloc_realloc(void *ptr, size_t size, const char *file, int line)
+{
+ GIT_UNUSED(ptr);
+ GIT_UNUSED(size);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+void *git_failalloc_reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
+{
+ GIT_UNUSED(ptr);
+ GIT_UNUSED(nelem);
+ GIT_UNUSED(elsize);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+void *git_failalloc_mallocarray(size_t nelem, size_t elsize, const char *file, int line)
+{
+ GIT_UNUSED(nelem);
+ GIT_UNUSED(elsize);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ return NULL;
+}
+
+void git_failalloc_free(void *ptr)
+{
+ GIT_UNUSED(ptr);
+}
diff --git a/src/allocators/failalloc.h b/src/allocators/failalloc.h
new file mode 100644
index 0000000..6115e51
--- /dev/null
+++ b/src/allocators/failalloc.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_allocators_failalloc_h__
+#define INCLUDE_allocators_failalloc_h__
+
+#include "common.h"
+
+extern void *git_failalloc_malloc(size_t len, const char *file, int line);
+extern void *git_failalloc_calloc(size_t nelem, size_t elsize, const char *file, int line);
+extern char *git_failalloc_strdup(const char *str, const char *file, int line);
+extern char *git_failalloc_strndup(const char *str, size_t n, const char *file, int line);
+extern char *git_failalloc_substrdup(const char *start, size_t n, const char *file, int line);
+extern void *git_failalloc_realloc(void *ptr, size_t size, const char *file, int line);
+extern void *git_failalloc_reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line);
+extern void *git_failalloc_mallocarray(size_t nelem, size_t elsize, const char *file, int line);
+extern void git_failalloc_free(void *ptr);
+
+#endif
diff --git a/src/allocators/stdalloc.c b/src/allocators/stdalloc.c
index c4938e3..2b36d9f 100644
--- a/src/allocators/stdalloc.c
+++ b/src/allocators/stdalloc.c
@@ -9,34 +9,56 @@
static void *stdalloc__malloc(size_t len, const char *file, int line)
{
- void *ptr = malloc(len);
+ void *ptr;
GIT_UNUSED(file);
GIT_UNUSED(line);
- if (!ptr) git_error_set_oom();
+#ifdef GIT_DEBUG_STRICT_ALLOC
+ if (!len)
+ return NULL;
+#endif
+
+ ptr = malloc(len);
+
+ if (!ptr)
+ git_error_set_oom();
+
return ptr;
}
static void *stdalloc__calloc(size_t nelem, size_t elsize, const char *file, int line)
{
- void *ptr = calloc(nelem, elsize);
+ void *ptr;
GIT_UNUSED(file);
GIT_UNUSED(line);
- if (!ptr) git_error_set_oom();
+#ifdef GIT_DEBUG_STRICT_ALLOC
+ if (!elsize || !nelem)
+ return NULL;
+#endif
+
+ ptr = calloc(nelem, elsize);
+
+ if (!ptr)
+ git_error_set_oom();
+
return ptr;
}
static char *stdalloc__strdup(const char *str, const char *file, int line)
{
- char *ptr = strdup(str);
+ char *ptr;
GIT_UNUSED(file);
GIT_UNUSED(line);
- if (!ptr) git_error_set_oom();
+ ptr = strdup(str);
+
+ if (!ptr)
+ git_error_set_oom();
+
return ptr;
}
@@ -48,7 +70,7 @@ static char *stdalloc__strndup(const char *str, size_t n, const char *file, int
length = p_strnlen(str, n);
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
- !(ptr = stdalloc__malloc(alloclength, file, line)))
+ !(ptr = stdalloc__malloc(alloclength, file, line)))
return NULL;
if (length)
@@ -65,7 +87,7 @@ static char *stdalloc__substrdup(const char *start, size_t n, const char *file,
size_t alloclen;
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
- !(ptr = stdalloc__malloc(alloclen, file, line)))
+ !(ptr = stdalloc__malloc(alloclen, file, line)))
return NULL;
memcpy(ptr, start, n);
@@ -75,12 +97,21 @@ static char *stdalloc__substrdup(const char *start, size_t n, const char *file,
static void *stdalloc__realloc(void *ptr, size_t size, const char *file, int line)
{
- void *new_ptr = realloc(ptr, size);
+ void *new_ptr;
GIT_UNUSED(file);
GIT_UNUSED(line);
- if (!new_ptr) git_error_set_oom();
+#ifdef GIT_DEBUG_STRICT_ALLOC
+ if (!size)
+ return NULL;
+#endif
+
+ new_ptr = realloc(ptr, size);
+
+ if (!new_ptr)
+ git_error_set_oom();
+
return new_ptr;
}
diff --git a/src/allocators/win32_crtdbg.c b/src/allocators/win32_crtdbg.c
deleted file mode 100644
index 1187e2f..0000000
--- a/src/allocators/win32_crtdbg.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "win32_crtdbg.h"
-
-#if defined(GIT_MSVC_CRTDBG)
-
-#include "win32/w32_crtdbg_stacktrace.h"
-
-static void *crtdbg__malloc(size_t len, const char *file, int line)
-{
- void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
- if (!ptr) git_error_set_oom();
- return ptr;
-}
-
-static void *crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line)
-{
- void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
- if (!ptr) git_error_set_oom();
- return ptr;
-}
-
-static char *crtdbg__strdup(const char *str, const char *file, int line)
-{
- char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
- if (!ptr) git_error_set_oom();
- return ptr;
-}
-
-static char *crtdbg__strndup(const char *str, size_t n, const char *file, int line)
-{
- size_t length = 0, alloclength;
- char *ptr;
-
- length = p_strnlen(str, n);
-
- if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
- !(ptr = crtdbg__malloc(alloclength, file, line)))
- return NULL;
-
- if (length)
- memcpy(ptr, str, length);
-
- ptr[length] = '\0';
-
- return ptr;
-}
-
-static char *crtdbg__substrdup(const char *start, size_t n, const char *file, int line)
-{
- char *ptr;
- size_t alloclen;
-
- if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
- !(ptr = crtdbg__malloc(alloclen, file, line)))
- return NULL;
-
- memcpy(ptr, start, n);
- ptr[n] = '\0';
- return ptr;
-}
-
-static void *crtdbg__realloc(void *ptr, size_t size, const char *file, int line)
-{
- void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
- if (!new_ptr) git_error_set_oom();
- return new_ptr;
-}
-
-static void *crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
-{
- size_t newsize;
-
- if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
- return NULL;
-
- return crtdbg__realloc(ptr, newsize, file, line);
-}
-
-static void *crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
-{
- return crtdbg__reallocarray(NULL, nelem, elsize, file, line);
-}
-
-static void crtdbg__free(void *ptr)
-{
- free(ptr);
-}
-
-int git_win32_crtdbg_init_allocator(git_allocator *allocator)
-{
- allocator->gmalloc = crtdbg__malloc;
- allocator->gcalloc = crtdbg__calloc;
- allocator->gstrdup = crtdbg__strdup;
- allocator->gstrndup = crtdbg__strndup;
- allocator->gsubstrdup = crtdbg__substrdup;
- allocator->grealloc = crtdbg__realloc;
- allocator->greallocarray = crtdbg__reallocarray;
- allocator->gmallocarray = crtdbg__mallocarray;
- allocator->gfree = crtdbg__free;
- return 0;
-}
-
-#else
-
-int git_win32_crtdbg_init_allocator(git_allocator *allocator)
-{
- GIT_UNUSED(allocator);
- git_error_set(GIT_EINVALID, "crtdbg memory allocator not available");
- return -1;
-}
-
-#endif
diff --git a/src/allocators/win32_crtdbg.h b/src/allocators/win32_crtdbg.h
deleted file mode 100644
index 754c6b6..0000000
--- a/src/allocators/win32_crtdbg.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#ifndef INCLUDE_allocators_crtdbg_h
-#define INCLUDE_allocators_crtdbg_h
-
-#include "common.h"
-
-#include "alloc.h"
-
-int git_win32_crtdbg_init_allocator(git_allocator *allocator);
-
-#endif
diff --git a/src/allocators/win32_leakcheck.c b/src/allocators/win32_leakcheck.c
new file mode 100644
index 0000000..fe06a14
--- /dev/null
+++ b/src/allocators/win32_leakcheck.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "win32_leakcheck.h"
+
+#if defined(GIT_WIN32_LEAKCHECK)
+
+#include "win32/w32_leakcheck.h"
+
+static void *leakcheck_malloc(size_t len, const char *file, int line)
+{
+ void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
+ if (!ptr) git_error_set_oom();
+ return ptr;
+}
+
+static void *leakcheck_calloc(size_t nelem, size_t elsize, const char *file, int line)
+{
+ void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
+ if (!ptr) git_error_set_oom();
+ return ptr;
+}
+
+static char *leakcheck_strdup(const char *str, const char *file, int line)
+{
+ char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
+ if (!ptr) git_error_set_oom();
+ return ptr;
+}
+
+static char *leakcheck_strndup(const char *str, size_t n, const char *file, int line)
+{
+ size_t length = 0, alloclength;
+ char *ptr;
+
+ length = p_strnlen(str, n);
+
+ if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
+ !(ptr = leakcheck_malloc(alloclength, file, line)))
+ return NULL;
+
+ if (length)
+ memcpy(ptr, str, length);
+
+ ptr[length] = '\0';
+
+ return ptr;
+}
+
+static char *leakcheck_substrdup(const char *start, size_t n, const char *file, int line)
+{
+ char *ptr;
+ size_t alloclen;
+
+ if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
+ !(ptr = leakcheck_malloc(alloclen, file, line)))
+ return NULL;
+
+ memcpy(ptr, start, n);
+ ptr[n] = '\0';
+ return ptr;
+}
+
+static void *leakcheck_realloc(void *ptr, size_t size, const char *file, int line)
+{
+ void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
+ if (!new_ptr) git_error_set_oom();
+ return new_ptr;
+}
+
+static void *leakcheck_reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
+{
+ size_t newsize;
+
+ if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
+ return NULL;
+
+ return leakcheck_realloc(ptr, newsize, file, line);
+}
+
+static void *leakcheck_mallocarray(size_t nelem, size_t elsize, const char *file, int line)
+{
+ return leakcheck_reallocarray(NULL, nelem, elsize, file, line);
+}
+
+static void leakcheck_free(void *ptr)
+{
+ free(ptr);
+}
+
+int git_win32_leakcheck_init_allocator(git_allocator *allocator)
+{
+ allocator->gmalloc = leakcheck_malloc;
+ allocator->gcalloc = leakcheck_calloc;
+ allocator->gstrdup = leakcheck_strdup;
+ allocator->gstrndup = leakcheck_strndup;
+ allocator->gsubstrdup = leakcheck_substrdup;
+ allocator->grealloc = leakcheck_realloc;
+ allocator->greallocarray = leakcheck_reallocarray;
+ allocator->gmallocarray = leakcheck_mallocarray;
+ allocator->gfree = leakcheck_free;
+ return 0;
+}
+
+#else
+
+int git_win32_leakcheck_init_allocator(git_allocator *allocator)
+{
+ GIT_UNUSED(allocator);
+ git_error_set(GIT_EINVALID, "leakcheck memory allocator not available");
+ return -1;
+}
+
+#endif
diff --git a/src/allocators/win32_leakcheck.h b/src/allocators/win32_leakcheck.h
new file mode 100644
index 0000000..089690f
--- /dev/null
+++ b/src/allocators/win32_leakcheck.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_allocators_win32_leakcheck_h
+#define INCLUDE_allocators_win32_leakcheck_h
+
+#include "common.h"
+
+#include "alloc.h"
+
+int git_win32_leakcheck_init_allocator(git_allocator *allocator);
+
+#endif
diff --git a/src/annotated_commit.c b/src/annotated_commit.c
index 5d4f370..e489476 100644
--- a/src/annotated_commit.c
+++ b/src/annotated_commit.c
@@ -26,7 +26,8 @@ static int annotated_commit_init(
git_annotated_commit *annotated_commit;
int error = 0;
- assert(out && commit);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(commit);
*out = NULL;
@@ -63,7 +64,9 @@ static int annotated_commit_init_from_id(
git_commit *commit = NULL;
int error = 0;
- assert(out && repo && id);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(id);
*out = NULL;
@@ -100,7 +103,9 @@ int git_annotated_commit_from_revspec(
git_object *obj, *commit;
int error;
- assert(out && repo && revspec);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(revspec);
if ((error = git_revparse_single(&obj, repo, revspec)) < 0)
return error;
@@ -126,7 +131,9 @@ int git_annotated_commit_from_ref(
git_object *peeled;
int error = 0;
- assert(out && repo && ref);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(ref);
*out = NULL;
@@ -154,11 +161,12 @@ int git_annotated_commit_from_head(
git_reference *head;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
- if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
+ if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
return -1;
error = git_annotated_commit_from_ref(out, repo, head);
@@ -174,7 +182,11 @@ int git_annotated_commit_from_fetchhead(
const char *remote_url,
const git_oid *id)
{
- assert(repo && id && branch_name && remote_url);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(branch_name);
+ GIT_ASSERT_ARG(remote_url);
+ GIT_ASSERT_ARG(id);
if (annotated_commit_init_from_id(out, repo, id, branch_name) < 0)
return -1;
@@ -192,14 +204,14 @@ int git_annotated_commit_from_fetchhead(
const git_oid *git_annotated_commit_id(
const git_annotated_commit *annotated_commit)
{
- assert(annotated_commit);
+ GIT_ASSERT_ARG_WITH_RETVAL(annotated_commit, NULL);
return git_commit_id(annotated_commit->commit);
}
const char *git_annotated_commit_ref(
const git_annotated_commit *annotated_commit)
{
- assert(annotated_commit);
+ GIT_ASSERT_ARG_WITH_RETVAL(annotated_commit, NULL);
return annotated_commit->ref_name;
}
diff --git a/src/apply.c b/src/apply.c
index fc60e14..7c65cd7 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -5,8 +5,6 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "apply.h"
-
#include "git2/apply.h"
#include "git2/patch.h"
#include "git2/filter.h"
@@ -21,6 +19,7 @@
#include "zstream.h"
#include "reader.h"
#include "index.h"
+#include "apply.h"
typedef struct {
/* The lines that we allocate ourself are allocated out of the pool.
@@ -63,7 +62,11 @@ static int patch_image_init_fromstr(
memset(out, 0x0, sizeof(patch_image));
- git_pool_init(&out->pool, sizeof(git_diff_line));
+ if (git_pool_init(&out->pool, sizeof(git_diff_line)) < 0)
+ return -1;
+
+ if (!in_len)
+ return 0;
for (start = in; start < in + in_len; start = end) {
end = memchr(start, '\n', in_len - (start - in));
@@ -395,7 +398,11 @@ int git_apply__patch(
unsigned int mode = 0;
int error = 0;
- assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
+ GIT_ASSERT_ARG(contents_out);
+ GIT_ASSERT_ARG(filename_out);
+ GIT_ASSERT_ARG(mode_out);
+ GIT_ASSERT_ARG(source || !source_len);
+ GIT_ASSERT_ARG(patch);
if (given_opts)
memcpy(&ctx.opts, given_opts, sizeof(git_apply_options));
@@ -620,7 +627,10 @@ int git_apply_to_tree(
size_t i;
int error = 0;
- assert(out && repo && preimage && diff);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(preimage);
+ GIT_ASSERT_ARG(diff);
*out = NULL;
@@ -768,6 +778,8 @@ done:
int git_apply_options_init(git_apply_options *opts, unsigned int version)
{
+ GIT_ASSERT_ARG(opts);
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_apply_options, GIT_APPLY_OPTIONS_INIT);
return 0;
@@ -801,7 +813,8 @@ int git_apply(
git_apply_options opts = GIT_APPLY_OPTIONS_INIT;
int error = GIT_EINVALID;
- assert(repo && diff);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(diff);
GIT_ERROR_CHECK_VERSION(
given_opts, GIT_APPLY_OPTIONS_VERSION, "git_apply_options");
@@ -825,7 +838,7 @@ int git_apply(
error = git_reader_for_workdir(&pre_reader, repo, false);
break;
default:
- assert(false);
+ GIT_ASSERT(false);
}
if (error < 0)
@@ -865,7 +878,7 @@ int git_apply(
error = git_apply__to_workdir(repo, diff, preimage, postimage, location, &opts);
break;
default:
- assert(false);
+ GIT_ASSERT(false);
}
if (error < 0)
diff --git a/src/array.h b/src/array.h
index 03537e7..e97688b 100644
--- a/src/array.h
+++ b/src/array.h
@@ -41,8 +41,8 @@
typedef git_array_t(char) git_array_generic_t;
-/* use a generic array for growth so this can return the new item */
-GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
+/* use a generic array for growth, return 0 on success */
+GIT_INLINE(int) git_array_grow(void *_a, size_t item_size)
{
volatile git_array_generic_t *a = _a;
size_t new_size;
@@ -59,24 +59,24 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
if ((new_array = git__reallocarray(a->ptr, new_size, item_size)) == NULL)
goto on_oom;
- a->ptr = new_array; a->asize = new_size; a->size++;
- return a->ptr + (a->size - 1) * item_size;
+ a->ptr = new_array;
+ a->asize = new_size;
+ return 0;
on_oom:
git_array_clear(*a);
- return NULL;
+ return -1;
}
#define git_array_alloc(a) \
- (((a).size >= (a).asize) ? \
- git_array_grow(&(a), sizeof(*(a).ptr)) : \
- ((a).ptr ? &(a).ptr[(a).size++] : NULL))
+ (((a).size < (a).asize || git_array_grow(&(a), sizeof(*(a).ptr)) == 0) ? \
+ &(a).ptr[(a).size++] : (void *)NULL)
-#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL)
+#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : (void *)NULL)
-#define git_array_pop(a) ((a).size ? &(a).ptr[--(a).size] : NULL)
+#define git_array_pop(a) ((a).size ? &(a).ptr[--(a).size] : (void *)NULL)
-#define git_array_get(a, i) (((i) < (a).size) ? &(a).ptr[(i)] : NULL)
+#define git_array_get(a, i) (((i) < (a).size) ? &(a).ptr[(i)] : (void *)NULL)
#define git_array_size(a) (a).size
diff --git a/src/assert_safe.h b/src/assert_safe.h
new file mode 100644
index 0000000..8c26110
--- /dev/null
+++ b/src/assert_safe.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_assert_safe_h__
+#define INCLUDE_assert_safe_h__
+
+/*
+ * In a debug build, we'll assert(3) for aide in debugging. In release
+ * builds, we will provide macros that will set an error message that
+ * indicate a failure and return. Note that memory leaks can occur in
+ * a release-mode assertion failure -- it is impractical to provide
+ * safe clean up routines in these very extreme failures, but care
+ * should be taken to not leak very large objects.
+ */
+
+#if (defined(_DEBUG) || defined(GIT_ASSERT_HARD)) && GIT_ASSERT_HARD != 0
+# include <assert.h>
+
+# define GIT_ASSERT(expr) assert(expr)
+# define GIT_ASSERT_ARG(expr) assert(expr)
+
+# define GIT_ASSERT_WITH_RETVAL(expr, fail) assert(expr)
+# define GIT_ASSERT_ARG_WITH_RETVAL(expr, fail) assert(expr)
+#else
+
+/** Internal consistency check to stop the function. */
+# define GIT_ASSERT(expr) GIT_ASSERT_WITH_RETVAL(expr, -1)
+
+/**
+ * Assert that a consumer-provided argument is valid, setting an
+ * actionable error message and returning -1 if it is not.
+ */
+# define GIT_ASSERT_ARG(expr) GIT_ASSERT_ARG_WITH_RETVAL(expr, -1)
+
+/** Internal consistency check to return the `fail` param on failure. */
+# define GIT_ASSERT_WITH_RETVAL(expr, fail) \
+ GIT_ASSERT__WITH_RETVAL(expr, GIT_ERROR_INTERNAL, "unrecoverable internal error", fail)
+
+/**
+ * Assert that a consumer-provided argument is valid, setting an
+ * actionable error message and returning the `fail` param if not.
+ */
+# define GIT_ASSERT_ARG_WITH_RETVAL(expr, fail) \
+ GIT_ASSERT__WITH_RETVAL(expr, GIT_ERROR_INVALID, "invalid argument", fail)
+
+# define GIT_ASSERT__WITH_RETVAL(expr, code, msg, fail) do { \
+ if (!(expr)) { \
+ git_error_set(code, "%s: '%s'", msg, #expr); \
+ return fail; \
+ } \
+ } while(0)
+
+#endif /* GIT_ASSERT_HARD */
+
+#endif
diff --git a/src/attr.c b/src/attr.c
index bd517cd..03b720c 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -36,16 +36,16 @@ git_attr_value_t git_attr_value(const char *attr)
static int collect_attr_files(
git_repository *repo,
git_attr_session *attr_session,
- uint32_t flags,
+ git_attr_options *opts,
const char *path,
git_vector *files);
static void release_attr_files(git_vector *files);
-int git_attr_get(
+int git_attr_get_ext(
const char **value,
git_repository *repo,
- uint32_t flags,
+ git_attr_options *opts,
const char *pathname,
const char *name)
{
@@ -58,17 +58,20 @@ int git_attr_get(
git_attr_rule *rule;
git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
- assert(value && repo && name);
+ GIT_ASSERT_ARG(value);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
+ GIT_ERROR_CHECK_VERSION(opts, GIT_ATTR_OPTIONS_VERSION, "git_attr_options");
*value = NULL;
if (git_repository_is_bare(repo))
dir_flag = GIT_DIR_FLAG_FALSE;
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
+ if (git_attr_path__init(&path, repo, pathname, git_repository_workdir(repo), dir_flag) < 0)
return -1;
- if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0)
+ if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0)
goto cleanup;
memset(&attr, 0, sizeof(attr));
@@ -95,6 +98,20 @@ cleanup:
return error;
}
+int git_attr_get(
+ const char **value,
+ git_repository *repo,
+ uint32_t flags,
+ const char *pathname,
+ const char *name)
+{
+ git_attr_options opts = GIT_ATTR_OPTIONS_INIT;
+
+ opts.flags = flags;
+
+ return git_attr_get_ext(value, repo, &opts, pathname, name);
+}
+
typedef struct {
git_attr_name name;
@@ -105,7 +122,7 @@ int git_attr_get_many_with_session(
const char **values,
git_repository *repo,
git_attr_session *attr_session,
- uint32_t flags,
+ git_attr_options *opts,
const char *pathname,
size_t num_attr,
const char **names)
@@ -123,15 +140,19 @@ int git_attr_get_many_with_session(
if (!num_attr)
return 0;
- assert(values && repo && names);
+ GIT_ASSERT_ARG(values);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(pathname);
+ GIT_ASSERT_ARG(names);
+ GIT_ERROR_CHECK_VERSION(opts, GIT_ATTR_OPTIONS_VERSION, "git_attr_options");
if (git_repository_is_bare(repo))
dir_flag = GIT_DIR_FLAG_FALSE;
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
+ if (git_attr_path__init(&path, repo, pathname, git_repository_workdir(repo), dir_flag) < 0)
return -1;
- if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0)
+ if ((error = collect_attr_files(repo, attr_session, opts, pathname, &files)) < 0)
goto cleanup;
info = git__calloc(num_attr, sizeof(attr_get_many_info));
@@ -185,8 +206,24 @@ int git_attr_get_many(
size_t num_attr,
const char **names)
{
+ git_attr_options opts = GIT_ATTR_OPTIONS_INIT;
+
+ opts.flags = flags;
+
+ return git_attr_get_many_with_session(
+ values, repo, NULL, &opts, pathname, num_attr, names);
+}
+
+int git_attr_get_many_ext(
+ const char **values,
+ git_repository *repo,
+ git_attr_options *opts,
+ const char *pathname,
+ size_t num_attr,
+ const char **names)
+{
return git_attr_get_many_with_session(
- values, repo, NULL, flags, pathname, num_attr, names);
+ values, repo, NULL, opts, pathname, num_attr, names);
}
int git_attr_foreach(
@@ -196,6 +233,20 @@ int git_attr_foreach(
int (*callback)(const char *name, const char *value, void *payload),
void *payload)
{
+ git_attr_options opts = GIT_ATTR_OPTIONS_INIT;
+
+ opts.flags = flags;
+
+ return git_attr_foreach_ext(repo, &opts, pathname, callback, payload);
+}
+
+int git_attr_foreach_ext(
+ git_repository *repo,
+ git_attr_options *opts,
+ const char *pathname,
+ int (*callback)(const char *name, const char *value, void *payload),
+ void *payload)
+{
int error;
git_attr_path path;
git_vector files = GIT_VECTOR_INIT;
@@ -206,15 +257,17 @@ int git_attr_foreach(
git_strmap *seen = NULL;
git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
- assert(repo && callback);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(callback);
+ GIT_ERROR_CHECK_VERSION(opts, GIT_ATTR_OPTIONS_VERSION, "git_attr_options");
if (git_repository_is_bare(repo))
dir_flag = GIT_DIR_FLAG_FALSE;
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
+ if (git_attr_path__init(&path, repo, pathname, git_repository_workdir(repo), dir_flag) < 0)
return -1;
- if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 ||
+ if ((error = collect_attr_files(repo, NULL, opts, pathname, &files)) < 0 ||
(error = git_strmap_new(&seen)) < 0)
goto cleanup;
@@ -247,26 +300,43 @@ cleanup:
return error;
}
-static int preload_attr_file(
+static int preload_attr_source(
git_repository *repo,
git_attr_session *attr_session,
- git_attr_file_source source,
- const char *base,
- const char *file,
- bool allow_macros)
+ git_attr_file_source *source)
{
int error;
git_attr_file *preload = NULL;
- if (!file)
+ if (!source)
return 0;
- if (!(error = git_attr_cache__get(&preload, repo, attr_session, source, base, file,
- git_attr_file__parse_buffer, allow_macros)))
+
+ error = git_attr_cache__get(&preload, repo, attr_session, source,
+ git_attr_file__parse_buffer, true);
+
+ if (!error)
git_attr_file__free(preload);
return error;
}
+GIT_INLINE(int) preload_attr_file(
+ git_repository *repo,
+ git_attr_session *attr_session,
+ const char *base,
+ const char *filename)
+{
+ git_attr_file_source source = { GIT_ATTR_FILE_SOURCE_FILE };
+
+ if (!filename)
+ return 0;
+
+ source.base = base;
+ source.filename = filename;
+
+ return preload_attr_source(repo, attr_session, &source);
+}
+
static int system_attr_file(
git_buf *out,
git_attr_session *attr_session)
@@ -308,9 +378,12 @@ static int system_attr_file(
static int attr_setup(
git_repository *repo,
git_attr_session *attr_session,
- uint32_t flags)
+ git_attr_options *opts)
{
- git_buf path = GIT_BUF_INIT;
+ git_buf system = GIT_BUF_INIT, info = GIT_BUF_INIT;
+ git_attr_file_source index_source = { GIT_ATTR_FILE_SOURCE_INDEX, NULL, GIT_ATTR_FILE, NULL };
+ git_attr_file_source head_source = { GIT_ATTR_FILE_SOURCE_COMMIT, NULL, GIT_ATTR_FILE, NULL };
+ git_attr_file_source commit_source = { GIT_ATTR_FILE_SOURCE_COMMIT, NULL, GIT_ATTR_FILE, NULL };
git_index *idx = NULL;
const char *workdir;
int error = 0;
@@ -326,45 +399,51 @@ static int attr_setup(
* definitions will be available for later file parsing.
*/
- if ((error = system_attr_file(&path, attr_session)) < 0 ||
- (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE,
- NULL, path.ptr, true)) < 0) {
+ if ((error = system_attr_file(&system, attr_session)) < 0 ||
+ (error = preload_attr_file(repo, attr_session, NULL, system.ptr)) < 0) {
if (error != GIT_ENOTFOUND)
goto out;
+
+ error = 0;
}
- if ((error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE,
- NULL, git_repository_attr_cache(repo)->cfg_attr_file, true)) < 0)
+ if ((error = preload_attr_file(repo, attr_session, NULL,
+ git_repository_attr_cache(repo)->cfg_attr_file)) < 0)
goto out;
- git_buf_clear(&path); /* git_repository_item_path expects an empty buffer, because it uses git_buf_set */
- if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
- (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE,
- path.ptr, GIT_ATTR_FILE_INREPO, true)) < 0) {
+ if ((error = git_repository_item_path(&info, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
+ (error = preload_attr_file(repo, attr_session, info.ptr, GIT_ATTR_FILE_INREPO)) < 0) {
if (error != GIT_ENOTFOUND)
goto out;
+
+ error = 0;
}
if ((workdir = git_repository_workdir(repo)) != NULL &&
- (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE,
- workdir, GIT_ATTR_FILE, true)) < 0)
+ (error = preload_attr_file(repo, attr_session, workdir, GIT_ATTR_FILE)) < 0)
goto out;
if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
- (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_INDEX,
- NULL, GIT_ATTR_FILE, true)) < 0)
+ (error = preload_attr_source(repo, attr_session, &index_source)) < 0)
goto out;
- if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
- (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_HEAD,
- NULL, GIT_ATTR_FILE, true)) < 0)
+ if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0) &&
+ (error = preload_attr_source(repo, attr_session, &head_source)) < 0)
goto out;
+ if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)) {
+ commit_source.commit_id = opts->commit_id;
+
+ if ((error = preload_attr_source(repo, attr_session, &commit_source)) < 0)
+ goto out;
+ }
+
if (attr_session)
attr_session->init_setup = 1;
out:
- git_buf_dispose(&path);
+ git_buf_dispose(&system);
+ git_buf_dispose(&info);
return error;
}
@@ -378,6 +457,9 @@ int git_attr_add_macro(
git_attr_rule *macro = NULL;
git_pool *pool;
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
+
if ((error = git_attr_cache__init(repo)) < 0)
return error;
@@ -406,56 +488,60 @@ int git_attr_add_macro(
typedef struct {
git_repository *repo;
git_attr_session *attr_session;
- uint32_t flags;
+ git_attr_options *opts;
const char *workdir;
git_index *index;
git_vector *files;
} attr_walk_up_info;
static int attr_decide_sources(
- uint32_t flags, bool has_wd, bool has_index, git_attr_file_source *srcs)
+ uint32_t flags,
+ bool has_wd,
+ bool has_index,
+ git_attr_file_source_t *srcs)
{
int count = 0;
switch (flags & 0x03) {
case GIT_ATTR_CHECK_FILE_THEN_INDEX:
if (has_wd)
- srcs[count++] = GIT_ATTR_FILE__FROM_FILE;
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_FILE;
if (has_index)
- srcs[count++] = GIT_ATTR_FILE__FROM_INDEX;
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_INDEX;
break;
case GIT_ATTR_CHECK_INDEX_THEN_FILE:
if (has_index)
- srcs[count++] = GIT_ATTR_FILE__FROM_INDEX;
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_INDEX;
if (has_wd)
- srcs[count++] = GIT_ATTR_FILE__FROM_FILE;
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_FILE;
break;
case GIT_ATTR_CHECK_INDEX_ONLY:
if (has_index)
- srcs[count++] = GIT_ATTR_FILE__FROM_INDEX;
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_INDEX;
break;
}
- if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
- srcs[count++] = GIT_ATTR_FILE__FROM_HEAD;
+ if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 ||
+ (flags & GIT_ATTR_CHECK_INCLUDE_COMMIT) != 0)
+ srcs[count++] = GIT_ATTR_FILE_SOURCE_COMMIT;
return count;
}
-static int push_attr_file(
+static int push_attr_source(
git_repository *repo,
git_attr_session *attr_session,
git_vector *list,
- git_attr_file_source source,
- const char *base,
- const char *filename,
+ git_attr_file_source *source,
bool allow_macros)
{
int error = 0;
git_attr_file *file = NULL;
error = git_attr_cache__get(&file, repo, attr_session,
- source, base, filename, git_attr_file__parse_buffer, allow_macros);
+ source,
+ git_attr_file__parse_buffer,
+ allow_macros);
if (error < 0)
return error;
@@ -468,20 +554,40 @@ static int push_attr_file(
return error;
}
+GIT_INLINE(int) push_attr_file(
+ git_repository *repo,
+ git_attr_session *attr_session,
+ git_vector *list,
+ const char *base,
+ const char *filename)
+{
+ git_attr_file_source source = { GIT_ATTR_FILE_SOURCE_FILE, base, filename };
+ return push_attr_source(repo, attr_session, list, &source, true);
+}
+
static int push_one_attr(void *ref, const char *path)
{
attr_walk_up_info *info = (attr_walk_up_info *)ref;
- git_attr_file_source src[GIT_ATTR_FILE_NUM_SOURCES];
+ git_attr_file_source_t src[GIT_ATTR_FILE_NUM_SOURCES];
int error = 0, n_src, i;
bool allow_macros;
- n_src = attr_decide_sources(
- info->flags, info->workdir != NULL, info->index != NULL, src);
+ n_src = attr_decide_sources(info->opts ? info->opts->flags : 0,
+ info->workdir != NULL,
+ info->index != NULL,
+ src);
+
allow_macros = info->workdir ? !strcmp(info->workdir, path) : false;
- for (i = 0; !error && i < n_src; ++i)
- error = push_attr_file(info->repo, info->attr_session, info->files,
- src[i], path, GIT_ATTR_FILE, allow_macros);
+ for (i = 0; !error && i < n_src; ++i) {
+ git_attr_file_source source = { src[i], path, GIT_ATTR_FILE };
+
+ if (src[i] == GIT_ATTR_FILE_SOURCE_COMMIT && info->opts)
+ source.commit_id = info->opts->commit_id;
+
+ error = push_attr_source(info->repo, info->attr_session, info->files,
+ &source, allow_macros);
+ }
return error;
}
@@ -501,7 +607,7 @@ static void release_attr_files(git_vector *files)
static int collect_attr_files(
git_repository *repo,
git_attr_session *attr_session,
- uint32_t flags,
+ git_attr_options *opts,
const char *path,
git_vector *files)
{
@@ -510,14 +616,18 @@ static int collect_attr_files(
const char *workdir = git_repository_workdir(repo);
attr_walk_up_info info = { NULL };
- if ((error = attr_setup(repo, attr_session, flags)) < 0)
+ if ((error = attr_setup(repo, attr_session, opts)) < 0)
return error;
/* Resolve path in a non-bare repo */
- if (workdir != NULL)
- error = git_path_find_dir(&dir, path, workdir);
- else
+ if (workdir != NULL) {
+ if (!(error = git_repository_workdir_path(&dir, repo, path)))
+ error = git_path_find_dir(&dir);
+ }
+ else {
error = git_path_dirname_r(&dir, path);
+ }
+
if (error < 0)
goto cleanup;
@@ -529,15 +639,14 @@ static int collect_attr_files(
*/
if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
- (error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE,
- attrfile.ptr, GIT_ATTR_FILE_INREPO, true)) < 0) {
+ (error = push_attr_file(repo, attr_session, files, attrfile.ptr, GIT_ATTR_FILE_INREPO)) < 0) {
if (error != GIT_ENOTFOUND)
goto cleanup;
}
info.repo = repo;
info.attr_session = attr_session;
- info.flags = flags;
+ info.opts = opts;
info.workdir = workdir;
if (git_repository_index__weakptr(&info.index, repo) < 0)
git_error_clear(); /* no error even if there is no index */
@@ -552,18 +661,16 @@ static int collect_attr_files(
goto cleanup;
if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) {
- error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE,
- NULL, git_repository_attr_cache(repo)->cfg_attr_file, true);
+ error = push_attr_file(repo, attr_session, files, NULL, git_repository_attr_cache(repo)->cfg_attr_file);
if (error < 0)
goto cleanup;
}
- if ((flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
+ if (!opts || (opts->flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) {
error = system_attr_file(&dir, attr_session);
if (!error)
- error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE,
- NULL, dir.ptr, true);
+ error = push_attr_file(repo, attr_session, files, NULL, dir.ptr);
else if (error == GIT_ENOTFOUND)
error = 0;
}
diff --git a/src/attr_file.c b/src/attr_file.c
index 82da526..f862738 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -10,7 +10,6 @@
#include "repository.h"
#include "filebuf.h"
#include "attrcache.h"
-#include "buf_text.h"
#include "git2/blob.h"
#include "git2/tree.h"
#include "blob.h"
@@ -34,23 +33,28 @@ static void attr_file_free(git_attr_file *file)
int git_attr_file__new(
git_attr_file **out,
git_attr_file_entry *entry,
- git_attr_file_source source)
+ git_attr_file_source *source)
{
git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file));
GIT_ERROR_CHECK_ALLOC(attrs);
if (git_mutex_init(&attrs->lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to initialize lock");
- git__free(attrs);
- return -1;
+ goto on_error;
}
- git_pool_init(&attrs->pool, 1);
+ if (git_pool_init(&attrs->pool, 1) < 0)
+ goto on_error;
+
GIT_REFCOUNT_INC(attrs);
- attrs->entry = entry;
- attrs->source = source;
+ attrs->entry = entry;
+ memcpy(&attrs->source, source, sizeof(git_attr_file_source));
*out = attrs;
return 0;
+
+on_error:
+ git__free(attrs);
+ return -1;
}
int git_attr_file__clear_rules(git_attr_file *file, bool need_lock)
@@ -104,11 +108,12 @@ int git_attr_file__load(
git_repository *repo,
git_attr_session *attr_session,
git_attr_file_entry *entry,
- git_attr_file_source source,
+ git_attr_file_source *source,
git_attr_file_parser parser,
bool allow_macros)
{
int error = 0;
+ git_commit *commit = NULL;
git_tree *tree = NULL;
git_tree_entry *tree_entry = NULL;
git_blob *blob = NULL;
@@ -118,17 +123,17 @@ int git_attr_file__load(
struct stat st;
bool nonexistent = false;
int bom_offset;
- git_bom_t bom;
+ git_buf_bom_t bom;
git_oid id;
git_object_size_t blobsize;
*out = NULL;
- switch (source) {
- case GIT_ATTR_FILE__IN_MEMORY:
+ switch (source->type) {
+ case GIT_ATTR_FILE_SOURCE_MEMORY:
/* in-memory attribute file doesn't need data */
break;
- case GIT_ATTR_FILE__FROM_INDEX: {
+ case GIT_ATTR_FILE_SOURCE_INDEX: {
if ((error = attr_file_oid_from_index(&id, repo, entry->path)) < 0 ||
(error = git_blob_lookup(&blob, repo, &id)) < 0)
return error;
@@ -141,7 +146,7 @@ int git_attr_file__load(
git_buf_put(&content, git_blob_rawcontent(blob), (size_t)blobsize);
break;
}
- case GIT_ATTR_FILE__FROM_FILE: {
+ case GIT_ATTR_FILE_SOURCE_FILE: {
int fd = -1;
/* For open or read errors, pretend that we got ENOTFOUND. */
@@ -158,10 +163,31 @@ int git_attr_file__load(
break;
}
- case GIT_ATTR_FILE__FROM_HEAD: {
- if ((error = git_repository_head_tree(&tree, repo)) < 0 ||
- (error = git_tree_entry_bypath(&tree_entry, tree, entry->path)) < 0 ||
- (error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0)
+ case GIT_ATTR_FILE_SOURCE_COMMIT: {
+ if (source->commit_id) {
+ if ((error = git_commit_lookup(&commit, repo, source->commit_id)) < 0 ||
+ (error = git_commit_tree(&tree, commit)) < 0)
+ goto cleanup;
+ } else {
+ if ((error = git_repository_head_tree(&tree, repo)) < 0)
+ goto cleanup;
+ }
+
+ if ((error = git_tree_entry_bypath(&tree_entry, tree, entry->path)) < 0) {
+ /*
+ * If the attributes file does not exist, we can
+ * cache an empty file for this commit to prevent
+ * needless future lookups.
+ */
+ if (error == GIT_ENOTFOUND) {
+ error = 0;
+ break;
+ }
+
+ goto cleanup;
+ }
+
+ if ((error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0)
goto cleanup;
/*
@@ -178,7 +204,7 @@ int git_attr_file__load(
break;
}
default:
- git_error_set(GIT_ERROR_INVALID, "unknown file source %d", source);
+ git_error_set(GIT_ERROR_INVALID, "unknown file source %d", source->type);
return -1;
}
@@ -187,9 +213,9 @@ int git_attr_file__load(
/* advance over a UTF8 BOM */
content_str = git_buf_cstr(&content);
- bom_offset = git_buf_text_detect_bom(&bom, &content);
+ bom_offset = git_buf_detect_bom(&bom, &content);
- if (bom == GIT_BOM_UTF8)
+ if (bom == GIT_BUF_BOM_UTF8)
content_str += bom_offset;
/* store the key of the attr_reader; don't bother with cache
@@ -206,11 +232,11 @@ int git_attr_file__load(
/* write cache breakers */
if (nonexistent)
file->nonexistent = 1;
- else if (source == GIT_ATTR_FILE__FROM_INDEX)
+ else if (source->type == GIT_ATTR_FILE_SOURCE_INDEX)
git_oid_cpy(&file->cache_data.oid, git_blob_id(blob));
- else if (source == GIT_ATTR_FILE__FROM_HEAD)
+ else if (source->type == GIT_ATTR_FILE_SOURCE_COMMIT)
git_oid_cpy(&file->cache_data.oid, git_tree_id(tree));
- else if (source == GIT_ATTR_FILE__FROM_FILE)
+ else if (source->type == GIT_ATTR_FILE_SOURCE_FILE)
git_futils_filestamp_set_from_stat(&file->cache_data.stamp, &st);
/* else always cacheable */
@@ -220,6 +246,7 @@ cleanup:
git_blob_free(blob);
git_tree_entry_free(tree_entry);
git_tree_free(tree);
+ git_commit_free(commit);
git_buf_dispose(&content);
return error;
@@ -228,7 +255,8 @@ cleanup:
int git_attr_file__out_of_date(
git_repository *repo,
git_attr_session *attr_session,
- git_attr_file *file)
+ git_attr_file *file,
+ git_attr_file_source *source)
{
if (!file)
return 1;
@@ -241,15 +269,15 @@ int git_attr_file__out_of_date(
else if (file->nonexistent)
return 1;
- switch (file->source) {
- case GIT_ATTR_FILE__IN_MEMORY:
+ switch (file->source.type) {
+ case GIT_ATTR_FILE_SOURCE_MEMORY:
return 0;
- case GIT_ATTR_FILE__FROM_FILE:
+ case GIT_ATTR_FILE_SOURCE_FILE:
return git_futils_filestamp_check(
&file->cache_data.stamp, file->entry->fullpath);
- case GIT_ATTR_FILE__FROM_INDEX: {
+ case GIT_ATTR_FILE_SOURCE_INDEX: {
int error;
git_oid id;
@@ -260,21 +288,34 @@ int git_attr_file__out_of_date(
return (git_oid__cmp(&file->cache_data.oid, &id) != 0);
}
- case GIT_ATTR_FILE__FROM_HEAD: {
- git_tree *tree;
+ case GIT_ATTR_FILE_SOURCE_COMMIT: {
+ git_tree *tree = NULL;
int error;
- if ((error = git_repository_head_tree(&tree, repo)) < 0)
+ if (source->commit_id) {
+ git_commit *commit = NULL;
+
+ if ((error = git_commit_lookup(&commit, repo, source->commit_id)) < 0)
+ return error;
+
+ error = git_commit_tree(&tree, commit);
+
+ git_commit_free(commit);
+ } else {
+ error = git_repository_head_tree(&tree, repo);
+ }
+
+ if (error < 0)
return error;
- error = git_oid__cmp(&file->cache_data.oid, git_tree_id(tree));
+ error = (git_oid__cmp(&file->cache_data.oid, git_tree_id(tree)) != 0);
git_tree_free(tree);
return error;
}
default:
- git_error_set(GIT_ERROR_INVALID, "invalid file type %d", file->source);
+ git_error_set(GIT_ERROR_INVALID, "invalid file type %d", file->source.type);
return -1;
}
}
@@ -346,7 +387,9 @@ uint32_t git_attr_file__name_hash(const char *name)
{
uint32_t h = 5381;
int c;
- assert(name);
+
+ GIT_ASSERT_ARG(name);
+
while ((c = (int)*name++) != 0)
h = ((h << 5) + h) + c;
return h;
@@ -383,6 +426,7 @@ int git_attr_file__lookup_one(
int git_attr_file__load_standalone(git_attr_file **out, const char *path)
{
git_buf content = GIT_BUF_INIT;
+ git_attr_file_source source = { GIT_ATTR_FILE_SOURCE_FILE };
git_attr_file *file = NULL;
int error;
@@ -394,9 +438,9 @@ int git_attr_file__load_standalone(git_attr_file **out, const char *path)
* don't have to free it - freeing file+pool will free cache entry, too.
*/
- if ((error = git_attr_file__new(&file, NULL, GIT_ATTR_FILE__FROM_FILE)) < 0 ||
+ if ((error = git_attr_file__new(&file, NULL, &source)) < 0 ||
(error = git_attr_file__parse_buffer(NULL, file, content.ptr, true)) < 0 ||
- (error = git_attr_cache__alloc_file_entry(&file->entry, NULL, path, &file->pool)) < 0)
+ (error = git_attr_cache__alloc_file_entry(&file->entry, NULL, NULL, path, &file->pool)) < 0)
goto out;
*out = file;
@@ -496,14 +540,19 @@ git_attr_assignment *git_attr_rule__lookup_assignment(
}
int git_attr_path__init(
- git_attr_path *info, const char *path, const char *base, git_dir_flag dir_flag)
+ git_attr_path *info,
+ git_repository *repo,
+ const char *path,
+ const char *base,
+ git_dir_flag dir_flag)
{
ssize_t root;
/* build full path as best we can */
git_buf_init(&info->full, 0);
- if (git_path_join_unrooted(&info->full, path, base, &root) < 0)
+ if (git_path_join_unrooted(&info->full, path, base, &root) < 0 ||
+ git_path_validate_workdir_buf(repo, &info->full) < 0)
return -1;
info->path = info->full.ptr + root;
@@ -655,7 +704,8 @@ int git_attr_fnmatch__parse(
int slash_count, allow_space;
bool escaped;
- assert(spec && base && *base);
+ GIT_ASSERT_ARG(spec);
+ GIT_ASSERT_ARG(base && *base);
if (parse_optimized_patterns(spec, pool, *base))
return 0;
@@ -823,7 +873,7 @@ int git_attr_assignment__parse(
const char *scan = *base;
git_attr_assignment *assign = NULL;
- assert(assigns && !assigns->length);
+ GIT_ASSERT_ARG(assigns && !assigns->length);
git_vector_set_cmp(assigns, sort_by_hash_and_name);
@@ -949,10 +999,10 @@ void git_attr_rule__free(git_attr_rule *rule)
int git_attr_session__init(git_attr_session *session, git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
memset(session, 0, sizeof(*session));
- session->key = git_atomic_inc(&repo->attr_session_key);
+ session->key = git_atomic32_inc(&repo->attr_session_key);
return 0;
}
diff --git a/src/attr_file.h b/src/attr_file.h
index 2b6b1d6..16e33ca 100644
--- a/src/attr_file.h
+++ b/src/attr_file.h
@@ -37,12 +37,30 @@
(GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_ALLOWMACRO)
typedef enum {
- GIT_ATTR_FILE__IN_MEMORY = 0,
- GIT_ATTR_FILE__FROM_FILE = 1,
- GIT_ATTR_FILE__FROM_INDEX = 2,
- GIT_ATTR_FILE__FROM_HEAD = 3,
+ GIT_ATTR_FILE_SOURCE_MEMORY = 0,
+ GIT_ATTR_FILE_SOURCE_FILE = 1,
+ GIT_ATTR_FILE_SOURCE_INDEX = 2,
+ GIT_ATTR_FILE_SOURCE_COMMIT = 3,
- GIT_ATTR_FILE_NUM_SOURCES = 4
+ GIT_ATTR_FILE_NUM_SOURCES = 4
+} git_attr_file_source_t;
+
+typedef struct {
+ /* The source location for the attribute file. */
+ git_attr_file_source_t type;
+
+ /*
+ * The filename of the attribute file to read (relative to the
+ * given base path).
+ */
+ const char *base;
+ const char *filename;
+
+ /*
+ * The commit ID when the given source type is a commit (or NULL
+ * for the repository's HEAD commit.)
+ */
+ git_oid *commit_id;
} git_attr_file_source;
extern const char *git_attr__true;
@@ -124,7 +142,7 @@ extern int git_attr_get_many_with_session(
const char **values_out,
git_repository *repo,
git_attr_session *attr_session,
- uint32_t flags,
+ git_attr_options *opts,
const char *path,
size_t num_attr,
const char **names);
@@ -142,7 +160,7 @@ typedef int (*git_attr_file_parser)(
int git_attr_file__new(
git_attr_file **out,
git_attr_file_entry *entry,
- git_attr_file_source source);
+ git_attr_file_source *source);
void git_attr_file__free(git_attr_file *file);
@@ -151,7 +169,7 @@ int git_attr_file__load(
git_repository *repo,
git_attr_session *attr_session,
git_attr_file_entry *ce,
- git_attr_file_source source,
+ git_attr_file_source *source,
git_attr_file_parser parser,
bool allow_macros);
@@ -159,7 +177,7 @@ int git_attr_file__load_standalone(
git_attr_file **out, const char *path);
int git_attr_file__out_of_date(
- git_repository *repo, git_attr_session *session, git_attr_file *file);
+ git_repository *repo, git_attr_session *session, git_attr_file *file, git_attr_file_source *source);
int git_attr_file__parse_buffer(
git_repository *repo, git_attr_file *attrs, const char *data, bool allow_macros);
@@ -207,8 +225,11 @@ extern git_attr_assignment *git_attr_rule__lookup_assignment(
typedef enum { GIT_DIR_FLAG_TRUE = 1, GIT_DIR_FLAG_FALSE = 0, GIT_DIR_FLAG_UNKNOWN = -1 } git_dir_flag;
extern int git_attr_path__init(
- git_attr_path *info, const char *path, const char *base, git_dir_flag is_dir);
-
+ git_attr_path *out,
+ git_repository *repo,
+ const char *path,
+ const char *base,
+ git_dir_flag is_dir);
extern void git_attr_path__free(git_attr_path *info);
extern int git_attr_assignment__parse(
diff --git a/src/attrcache.c b/src/attrcache.c
index f02dd9d..2b36b7a 100644
--- a/src/attrcache.c
+++ b/src/attrcache.c
@@ -38,6 +38,7 @@ GIT_INLINE(git_attr_file_entry *) attr_cache_lookup_entry(
int git_attr_cache__alloc_file_entry(
git_attr_file_entry **out,
+ git_repository *repo,
const char *base,
const char *path,
git_pool *pool)
@@ -65,6 +66,9 @@ int git_attr_cache__alloc_file_entry(
}
memcpy(&ce->fullpath[baselen], path, pathlen);
+ if (git_path_validate_workdir_with_len(repo, ce->fullpath, pathlen + baselen) < 0)
+ return -1;
+
ce->path = &ce->fullpath[baselen];
*out = ce;
@@ -79,8 +83,8 @@ static int attr_cache_make_entry(
git_attr_file_entry *entry = NULL;
int error;
- if ((error = git_attr_cache__alloc_file_entry(&entry, git_repository_workdir(repo),
- path, &cache->pool)) < 0)
+ if ((error = git_attr_cache__alloc_file_entry(&entry, repo,
+ git_repository_workdir(repo), path, &cache->pool)) < 0)
return error;
if ((error = git_strmap_set(cache->files, entry->path, entry)) < 0)
@@ -108,7 +112,7 @@ static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file)
* Replace the existing value if another thread has
* created it in the meantime.
*/
- old = git__swap(entry->file[file->source], file);
+ old = git_atomic_swap(entry->file[file->source.type], file);
if (old) {
GIT_REFCOUNT_OWN(old, NULL);
@@ -123,7 +127,7 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file)
{
int error = 0;
git_attr_file_entry *entry;
- git_attr_file *old = NULL;
+ git_attr_file *oldfile = NULL;
if (!file)
return 0;
@@ -132,13 +136,13 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file)
return error;
if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL)
- old = git__compare_and_swap(&entry->file[file->source], file, NULL);
+ oldfile = git_atomic_compare_and_swap(&entry->file[file->source.type], file, NULL);
attr_cache_unlock(cache);
- if (old) {
- GIT_REFCOUNT_OWN(old, NULL);
- git_attr_file__free(old);
+ if (oldfile == file) {
+ GIT_REFCOUNT_OWN(file, NULL);
+ git_attr_file__free(file);
}
return error;
@@ -154,40 +158,42 @@ static int attr_cache_lookup(
git_attr_file_entry **out_entry,
git_repository *repo,
git_attr_session *attr_session,
- git_attr_file_source source,
- const char *base,
- const char *filename)
+ git_attr_file_source *source)
{
int error = 0;
git_buf path = GIT_BUF_INIT;
- const char *wd = git_repository_workdir(repo), *relfile;
+ const char *wd = git_repository_workdir(repo);
+ const char *filename;
git_attr_cache *cache = git_repository_attr_cache(repo);
git_attr_file_entry *entry = NULL;
git_attr_file *file = NULL;
/* join base and path as needed */
- if (base != NULL && git_path_root(filename) < 0) {
+ if (source->base != NULL && git_path_root(source->filename) < 0) {
git_buf *p = attr_session ? &attr_session->tmp : &path;
- if (git_buf_joinpath(p, base, filename) < 0)
+ if (git_buf_joinpath(p, source->base, source->filename) < 0 ||
+ git_path_validate_workdir_buf(repo, p) < 0)
return -1;
filename = p->ptr;
+ } else {
+ filename = source->filename;
}
- relfile = filename;
- if (wd && !git__prefixcmp(relfile, wd))
- relfile += strlen(wd);
+ if (wd && !git__prefixcmp(filename, wd))
+ filename += strlen(wd);
/* check cache for existing entry */
if ((error = attr_cache_lock(cache)) < 0)
goto cleanup;
- entry = attr_cache_lookup_entry(cache, relfile);
- if (!entry)
- error = attr_cache_make_entry(&entry, repo, relfile);
- else if (entry->file[source] != NULL) {
- file = entry->file[source];
+ entry = attr_cache_lookup_entry(cache, filename);
+
+ if (!entry) {
+ error = attr_cache_make_entry(&entry, repo, filename);
+ } else if (entry->file[source->type] != NULL) {
+ file = entry->file[source->type];
GIT_REFCOUNT_INC(file);
}
@@ -205,9 +211,7 @@ int git_attr_cache__get(
git_attr_file **out,
git_repository *repo,
git_attr_session *attr_session,
- git_attr_file_source source,
- const char *base,
- const char *filename,
+ git_attr_file_source *source,
git_attr_file_parser parser,
bool allow_macros)
{
@@ -216,19 +220,21 @@ int git_attr_cache__get(
git_attr_file_entry *entry = NULL;
git_attr_file *file = NULL, *updated = NULL;
- if ((error = attr_cache_lookup(
- &file, &entry, repo, attr_session, source, base, filename)) < 0)
+ if ((error = attr_cache_lookup(&file, &entry, repo, attr_session, source)) < 0)
return error;
/* load file if we don't have one or if existing one is out of date */
- if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0)
- error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser, allow_macros);
+ if (!file ||
+ (error = git_attr_file__out_of_date(repo, attr_session, file, source)) > 0)
+ error = git_attr_file__load(&updated, repo, attr_session,
+ entry, source, parser,
+ allow_macros);
/* if we loaded the file, insert into and/or update cache */
if (updated) {
- if ((error = attr_cache_upsert(cache, updated)) < 0)
+ if ((error = attr_cache_upsert(cache, updated)) < 0) {
git_attr_file__free(updated);
- else {
+ } else {
git_attr_file__free(file); /* offset incref from lookup */
file = updated;
}
@@ -255,7 +261,7 @@ int git_attr_cache__get(
bool git_attr_cache__is_cached(
git_repository *repo,
- git_attr_file_source source,
+ git_attr_file_source_t source_type,
const char *filename)
{
git_attr_cache *cache = git_repository_attr_cache(repo);
@@ -268,7 +274,7 @@ bool git_attr_cache__is_cached(
if ((entry = git_strmap_get(files, filename)) == NULL)
return false;
- return entry && (entry->file[source] != NULL);
+ return entry && (entry->file[source_type] != NULL);
}
@@ -321,7 +327,7 @@ static void attr_cache__free(git_attr_cache *cache)
git_strmap_foreach_value(cache->files, entry, {
for (i = 0; i < GIT_ATTR_FILE_NUM_SOURCES; ++i) {
- if ((file = git__swap(entry->file[i], NULL)) != NULL) {
+ if ((file = git_atomic_swap(entry->file[i], NULL)) != NULL) {
GIT_REFCOUNT_OWN(file, NULL);
git_attr_file__free(file);
}
@@ -391,13 +397,11 @@ int git_attr_cache__init(git_repository *repo)
* hashtable for attribute macros, and string pool
*/
if ((ret = git_strmap_new(&cache->files)) < 0 ||
- (ret = git_strmap_new(&cache->macros)) < 0)
+ (ret = git_strmap_new(&cache->macros)) < 0 ||
+ (ret = git_pool_init(&cache->pool, 1)) < 0)
goto cancel;
- git_pool_init(&cache->pool, 1);
-
- cache = git__compare_and_swap(&repo->attrcache, NULL, cache);
- if (cache)
+ if (git_atomic_compare_and_swap(&repo->attrcache, NULL, cache) != NULL)
goto cancel; /* raced with another thread, free this but no error */
git_config_free(cfg);
@@ -418,7 +422,7 @@ int git_attr_cache_flush(git_repository *repo)
/* this could be done less expensively, but for now, we'll just free
* the entire attrcache and let the next use reinitialize it...
*/
- if (repo && (cache = git__swap(repo->attrcache, NULL)) != NULL)
+ if (repo && (cache = git_atomic_swap(repo->attrcache, NULL)) != NULL)
attr_cache__free(cache);
return 0;
diff --git a/src/attrcache.h b/src/attrcache.h
index 4b1d5ce..b13e0e8 100644
--- a/src/attrcache.h
+++ b/src/attrcache.h
@@ -31,19 +31,18 @@ extern int git_attr_cache__get(
git_attr_file **file,
git_repository *repo,
git_attr_session *attr_session,
- git_attr_file_source source,
- const char *base,
- const char *filename,
+ git_attr_file_source *source,
git_attr_file_parser parser,
bool allow_macros);
extern bool git_attr_cache__is_cached(
git_repository *repo,
- git_attr_file_source source,
- const char *path);
+ git_attr_file_source_t source_type,
+ const char *filename);
extern int git_attr_cache__alloc_file_entry(
git_attr_file_entry **out,
+ git_repository *repo,
const char *base,
const char *path,
git_pool *pool);
diff --git a/src/blame.c b/src/blame.c
index 404f1f6..10e311a 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -76,6 +76,14 @@ static git_blame_hunk* new_hunk(
return hunk;
}
+static void free_hunk(git_blame_hunk *hunk)
+{
+ git__free((void*)hunk->orig_path);
+ git_signature_free(hunk->final_signature);
+ git_signature_free(hunk->orig_signature);
+ git__free(hunk);
+}
+
static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
{
git_blame_hunk *newhunk = new_hunk(
@@ -90,17 +98,14 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
git_oid_cpy(&newhunk->orig_commit_id, &hunk->orig_commit_id);
git_oid_cpy(&newhunk->final_commit_id, &hunk->final_commit_id);
newhunk->boundary = hunk->boundary;
- git_signature_dup(&newhunk->final_signature, hunk->final_signature);
- git_signature_dup(&newhunk->orig_signature, hunk->orig_signature);
- return newhunk;
-}
-static void free_hunk(git_blame_hunk *hunk)
-{
- git__free((void*)hunk->orig_path);
- git_signature_free(hunk->final_signature);
- git_signature_free(hunk->orig_signature);
- git__free(hunk);
+ if (git_signature_dup(&newhunk->final_signature, hunk->final_signature) < 0 ||
+ git_signature_dup(&newhunk->orig_signature, hunk->orig_signature) < 0) {
+ free_hunk(newhunk);
+ return NULL;
+ }
+
+ return newhunk;
}
/* Starting with the hunk that includes start_line, shift all following hunks'
@@ -171,20 +176,21 @@ void git_blame_free(git_blame *blame)
uint32_t git_blame_get_hunk_count(git_blame *blame)
{
- assert(blame);
+ GIT_ASSERT_ARG(blame);
return (uint32_t)blame->hunks.length;
}
const git_blame_hunk *git_blame_get_hunk_byindex(git_blame *blame, uint32_t index)
{
- assert(blame);
+ GIT_ASSERT_ARG_WITH_RETVAL(blame, NULL);
return (git_blame_hunk*)git_vector_get(&blame->hunks, index);
}
const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, size_t lineno)
{
size_t i, new_lineno = lineno;
- assert(blame);
+
+ GIT_ASSERT_ARG_WITH_RETVAL(blame, NULL);
if (!git_vector_bsearch2(&i, &blame->hunks, hunk_byfinalline_search_cmp, &new_lineno)) {
return git_blame_get_hunk_byindex(blame, (uint32_t)i);
@@ -388,7 +394,10 @@ int git_blame_file(
git_blame_options normOptions = GIT_BLAME_OPTIONS_INIT;
git_blame *blame = NULL;
- assert(out && repo && path);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(path);
+
if ((error = normalize_options(&normOptions, options, repo)) < 0)
goto on_error;
@@ -415,7 +424,7 @@ on_error:
static bool hunk_is_bufferblame(git_blame_hunk *hunk)
{
- return git_oid_is_zero(&hunk->final_commit_id);
+ return hunk && git_oid_is_zero(&hunk->final_commit_id);
}
static int buffer_hunk_cb(
@@ -509,7 +518,9 @@ int git_blame_buffer(
diffopts.context_lines = 0;
- assert(out && reference && buffer && buffer_len);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(reference);
+ GIT_ASSERT_ARG(buffer && buffer_len);
blame = git_blame__alloc(reference->repository, reference->options, reference->path);
GIT_ERROR_CHECK_ALLOC(blame);
@@ -538,7 +549,9 @@ int git_blame_options_init(git_blame_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_blame_init_options(git_blame_options *opts, unsigned int version)
{
return git_blame_options_init(opts, version);
}
+#endif
diff --git a/src/blame_git.c b/src/blame_git.c
index a9157c4..073137a 100644
--- a/src/blame_git.c
+++ b/src/blame_git.c
@@ -365,11 +365,14 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
b->size -= trimmed - recovered;
}
-static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data)
+static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data, git_blame_options *options)
{
- xpparam_t xpp = {0};
xdemitconf_t xecfg = {0};
xdemitcb_t ecb = {0};
+ xpparam_t xpp = {0};
+
+ if (options->flags & GIT_BLAME_IGNORE_WHITESPACE)
+ xpp.flags |= XDF_IGNORE_WHITESPACE;
xecfg.hunk_func = my_emit;
ecb.priv = cb_data;
@@ -409,7 +412,7 @@ static int pass_blame_to_parent(
fill_origin_blob(parent, &file_p);
fill_origin_blob(target, &file_o);
- if (diff_hunks(file_p, file_o, &d) < 0)
+ if (diff_hunks(file_p, file_o, &d, &blame->options) < 0)
return -1;
/* The reset (i.e. anything after tlno) are the same as the parent */
diff --git a/src/blob.c b/src/blob.c
index 5e734e2..01ebf07 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -14,11 +14,11 @@
#include "filebuf.h"
#include "filter.h"
-#include "buf_text.h"
const void *git_blob_rawcontent(const git_blob *blob)
{
- assert(blob);
+ GIT_ASSERT_ARG_WITH_RETVAL(blob, NULL);
+
if (blob->raw)
return blob->data.raw.data;
else
@@ -27,7 +27,8 @@ const void *git_blob_rawcontent(const git_blob *blob)
git_object_size_t git_blob_rawsize(const git_blob *blob)
{
- assert(blob);
+ GIT_ASSERT_ARG(blob);
+
if (blob->raw)
return blob->data.raw.size;
else
@@ -53,7 +54,9 @@ void git_blob__free(void *_blob)
int git_blob__parse_raw(void *_blob, const char *data, size_t size)
{
git_blob *blob = (git_blob *) _blob;
- assert(blob);
+
+ GIT_ASSERT_ARG(blob);
+
blob->raw = 1;
blob->data.raw.data = data;
blob->data.raw.size = size;
@@ -63,7 +66,9 @@ int git_blob__parse_raw(void *_blob, const char *data, size_t size)
int git_blob__parse(void *_blob, git_odb_object *odb_obj)
{
git_blob *blob = (git_blob *) _blob;
- assert(blob);
+
+ GIT_ASSERT_ARG(blob);
+
git_cached_obj_incref((git_cached_obj *)odb_obj);
blob->raw = 0;
blob->data.odb = odb_obj;
@@ -77,7 +82,8 @@ int git_blob_create_from_buffer(
git_odb *odb;
git_odb_stream *stream;
- assert(id && repo);
+ GIT_ASSERT_ARG(id);
+ GIT_ASSERT_ARG(repo);
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
(error = git_odb_open_wstream(&stream, odb, len, GIT_OBJECT_BLOB)) < 0)
@@ -188,14 +194,10 @@ int git_blob__create_from_paths(
mode_t mode;
git_buf path = GIT_BUF_INIT;
- assert(hint_path || !try_load_filters);
+ GIT_ASSERT_ARG(hint_path || !try_load_filters);
if (!content_path) {
- if (git_repository__ensure_not_bare(repo, "create blob from file") < 0)
- return GIT_EBAREREPO;
-
- if (git_buf_joinpath(
- &path, git_repository_workdir(repo), hint_path) < 0)
+ if (git_repository_workdir_path(&path, repo, hint_path) < 0)
return -1;
content_path = path.ptr;
@@ -331,7 +333,8 @@ int git_blob_create_from_stream(git_writestream **out, git_repository *repo, con
git_buf path = GIT_BUF_INIT;
blob_writestream *stream;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
stream = git__calloc(1, sizeof(blob_writestream));
GIT_ERROR_CHECK_ALLOC(stream);
@@ -391,13 +394,22 @@ int git_blob_is_binary(const git_blob *blob)
git_buf content = GIT_BUF_INIT;
git_object_size_t size;
- assert(blob);
+ GIT_ASSERT_ARG(blob);
size = git_blob_rawsize(blob);
git_buf_attach_notowned(&content, git_blob_rawcontent(blob),
(size_t)min(size, GIT_FILTER_BYTES_TO_CHECK_NUL));
- return git_buf_text_is_binary(&content);
+ return git_buf_is_binary(&content);
+}
+
+int git_blob_filter_options_init(
+ git_blob_filter_options *opts,
+ unsigned int version)
+{
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version,
+ git_blob_filter_options, GIT_BLOB_FILTER_OPTIONS_INIT);
+ return 0;
}
int git_blob_filter(
@@ -409,15 +421,18 @@ int git_blob_filter(
int error = 0;
git_filter_list *fl = NULL;
git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
- git_filter_flag_t flags = GIT_FILTER_DEFAULT;
-
- assert(blob && path && out);
+ git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
- git_buf_sanitize(out);
+ GIT_ASSERT_ARG(blob);
+ GIT_ASSERT_ARG(path);
+ GIT_ASSERT_ARG(out);
GIT_ERROR_CHECK_VERSION(
given_opts, GIT_BLOB_FILTER_OPTIONS_VERSION, "git_blob_filter_options");
+ if (git_buf_sanitize(out) < 0)
+ return -1;
+
if (given_opts != NULL)
memcpy(&opts, given_opts, sizeof(git_blob_filter_options));
@@ -426,14 +441,19 @@ int git_blob_filter(
return 0;
if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
- flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
+ filter_opts.flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
- if ((opts.flags & GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD) != 0)
- flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
+ if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
+ filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
+
+ if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
+ filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_COMMIT;
+ filter_opts.commit_id = opts.commit_id;
+ }
- if (!(error = git_filter_list_load(
+ if (!(error = git_filter_list_load_ext(
&fl, git_blob_owner(blob), blob, path,
- GIT_FILTER_TO_WORKTREE, flags))) {
+ GIT_FILTER_TO_WORKTREE, &filter_opts))) {
error = git_filter_list_apply_to_blob(out, fl, blob);
@@ -445,6 +465,7 @@ int git_blob_filter(
/* Deprecated functions */
+#ifndef GIT_DEPRECATE_HARD
int git_blob_create_frombuffer(
git_oid *id, git_repository *repo, const void *buffer, size_t len)
{
@@ -491,3 +512,4 @@ int git_blob_filtered_content(
return git_blob_filter(out, blob, path, &opts);
}
+#endif
diff --git a/src/branch.c b/src/branch.c
index 8926c89..e6818a8 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -67,8 +67,10 @@ static int create_branch(
int error = -1;
int bare = git_repository_is_bare(repository);
- assert(branch_name && commit && ref_out);
- assert(git_object_owner((const git_object *)commit) == repository);
+ GIT_ASSERT_ARG(branch_name);
+ GIT_ASSERT_ARG(commit);
+ GIT_ASSERT_ARG(ref_out);
+ GIT_ASSERT_ARG(git_commit_owner(commit) == repository);
if (!git__strcmp(branch_name, "HEAD")) {
git_error_set(GIT_ERROR_REFERENCE, "'HEAD' is not a valid branch name");
@@ -134,39 +136,39 @@ int git_branch_create_from_annotated(
repository, branch_name, commit->commit, commit->description, force);
}
-static int branch_equals(git_repository *repo, const char *path, void *payload)
+static int branch_is_checked_out(git_repository *worktree, void *payload)
{
git_reference *branch = (git_reference *) payload;
git_reference *head = NULL;
- int equal = 0;
+ int error;
- if (git_reference__read_head(&head, repo, path) < 0 ||
- git_reference_type(head) != GIT_REFERENCE_SYMBOLIC)
- goto done;
+ if (git_repository_is_bare(worktree))
+ return 0;
- equal = !git__strcmp(head->target.symbolic, branch->name);
+ if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0) {
+ if (error == GIT_ENOTFOUND)
+ error = 0;
+ goto out;
+ }
-done:
+ if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC)
+ goto out;
+
+ error = !git__strcmp(head->target.symbolic, branch->name);
+
+out:
git_reference_free(head);
- return equal;
+ return error;
}
int git_branch_is_checked_out(const git_reference *branch)
{
- git_repository *repo;
- int flags = 0;
-
- assert(branch);
+ GIT_ASSERT_ARG(branch);
if (!git_reference_is_branch(branch))
return 0;
-
- repo = git_reference_owner(branch);
-
- if (git_repository_is_bare(repo))
- flags |= GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO;
-
- return git_repository_foreach_head(repo, branch_equals, flags, (void *) branch) == 1;
+ return git_repository_foreach_worktree(git_reference_owner(branch),
+ branch_is_checked_out, (void *)branch) == 1;
}
int git_branch_delete(git_reference *branch)
@@ -175,7 +177,7 @@ int git_branch_delete(git_reference *branch)
git_buf config_section = GIT_BUF_INIT;
int error = -1;
- assert(branch);
+ GIT_ASSERT_ARG(branch);
if (!git_reference_is_branch(branch) && !git_reference_is_remote(branch)) {
git_error_set(GIT_ERROR_INVALID, "reference '%s' is not a valid branch.",
@@ -290,7 +292,8 @@ int git_branch_move(
log_message = GIT_BUF_INIT;
int error;
- assert(branch && new_branch_name);
+ GIT_ASSERT_ARG(branch);
+ GIT_ASSERT_ARG(new_branch_name);
if (!git_reference_is_branch(branch))
return not_a_local_branch(git_reference_name(branch));
@@ -335,7 +338,10 @@ int git_branch_lookup(
git_branch_t branch_type)
{
int error = -1;
- assert(ref_out && repo && branch_name);
+
+ GIT_ASSERT_ARG(ref_out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(branch_name);
switch (branch_type) {
case GIT_BRANCH_LOCAL:
@@ -348,7 +354,7 @@ int git_branch_lookup(
error = retrieve_branch_reference(ref_out, repo, branch_name, true);
break;
default:
- assert(false);
+ GIT_ASSERT(false);
}
return error;
}
@@ -359,7 +365,8 @@ int git_branch_name(
{
const char *branch_name;
- assert(out && ref);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ref);
branch_name = ref->name;
@@ -407,9 +414,11 @@ int git_branch_upstream_name(
const git_refspec *refspec;
git_config *config;
- assert(out && refname);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(refname);
- git_buf_sanitize(out);
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
if (!git_reference__is_branch(refname))
return not_a_local_branch(refname);
@@ -459,7 +468,7 @@ cleanup:
return error;
}
-int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname)
+static int git_branch_upstream_with_format(git_buf *buf, git_repository *repo, const char *refname, const char *format, const char *format_name)
{
int error;
git_config *cfg;
@@ -470,13 +479,12 @@ int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *r
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
return error;
- git_buf_sanitize(buf);
-
- if ((error = retrieve_upstream_configuration(buf, cfg, refname, "branch.%s.remote")) < 0)
+ if ((error = git_buf_sanitize(buf)) < 0 ||
+ (error = retrieve_upstream_configuration(buf, cfg, refname, format)) < 0)
return error;
if (git_buf_len(buf) == 0) {
- git_error_set(GIT_ERROR_REFERENCE, "branch '%s' does not have an upstream remote", refname);
+ git_error_set(GIT_ERROR_REFERENCE, "branch '%s' does not have an upstream %s", refname, format_name);
error = GIT_ENOTFOUND;
git_buf_clear(buf);
}
@@ -484,6 +492,16 @@ int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *r
return error;
}
+int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname)
+{
+ return git_branch_upstream_with_format(buf, repo, refname, "branch.%s.remote", "remote");
+}
+
+int git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname)
+{
+ return git_branch_upstream_with_format(buf, repo, refname, "branch.%s.merge", "merge");
+}
+
int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refname)
{
git_strarray remote_list = {0};
@@ -493,9 +511,12 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
int error = 0;
char *remote_name = NULL;
- assert(buf && repo && refname);
+ GIT_ASSERT_ARG(buf);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(refname);
- git_buf_sanitize(buf);
+ if ((error = git_buf_sanitize(buf)) < 0)
+ return error;
/* Verify that this is a remote branch */
if (!git_reference__is_remote(refname)) {
@@ -548,7 +569,7 @@ cleanup:
if (error < 0)
git_buf_dispose(buf);
- git_strarray_free(&remote_list);
+ git_strarray_dispose(&remote_list);
return error;
}
@@ -704,7 +725,7 @@ int git_branch_is_head(
bool is_same = false;
int error;
- assert(branch);
+ GIT_ASSERT_ARG(branch);
if (!git_reference_is_branch(branch))
return false;
@@ -725,3 +746,32 @@ int git_branch_is_head(
return is_same;
}
+
+int git_branch_name_is_valid(int *valid, const char *name)
+{
+ git_buf ref_name = GIT_BUF_INIT;
+ int error = 0;
+
+ GIT_ASSERT(valid);
+
+ *valid = 0;
+
+ /*
+ * Discourage branch name starting with dash,
+ * https://github.com/git/git/commit/6348624010888b
+ * and discourage HEAD as branch name,
+ * https://github.com/git/git/commit/a625b092cc5994
+ */
+ if (!name || name[0] == '-' || !git__strcmp(name, "HEAD"))
+ goto done;
+
+ if ((error = git_buf_puts(&ref_name, GIT_REFS_HEADS_DIR)) < 0 ||
+ (error = git_buf_puts(&ref_name, name)) < 0)
+ goto done;
+
+ error = git_reference_name_is_valid(valid, ref_name.ptr);
+
+done:
+ git_buf_dispose(&ref_name);
+ return error;
+}
diff --git a/src/buf_text.c b/src/buf_text.c
deleted file mode 100644
index 88fcb87..0000000
--- a/src/buf_text.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#include "buf_text.h"
-
-int git_buf_text_puts_escaped(
- git_buf *buf,
- const char *string,
- const char *esc_chars,
- const char *esc_with)
-{
- const char *scan;
- size_t total = 0, esc_len = strlen(esc_with), count, alloclen;
-
- if (!string)
- return 0;
-
- for (scan = string; *scan; ) {
- /* count run of non-escaped characters */
- count = strcspn(scan, esc_chars);
- total += count;
- scan += count;
- /* count run of escaped characters */
- count = strspn(scan, esc_chars);
- total += count * (esc_len + 1);
- scan += count;
- }
-
- GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, total, 1);
- if (git_buf_grow_by(buf, alloclen) < 0)
- return -1;
-
- for (scan = string; *scan; ) {
- count = strcspn(scan, esc_chars);
-
- memmove(buf->ptr + buf->size, scan, count);
- scan += count;
- buf->size += count;
-
- for (count = strspn(scan, esc_chars); count > 0; --count) {
- /* copy escape sequence */
- memmove(buf->ptr + buf->size, esc_with, esc_len);
- buf->size += esc_len;
- /* copy character to be escaped */
- buf->ptr[buf->size] = *scan;
- buf->size++;
- scan++;
- }
- }
-
- buf->ptr[buf->size] = '\0';
-
- return 0;
-}
-
-void git_buf_text_unescape(git_buf *buf)
-{
- buf->size = git__unescape(buf->ptr);
-}
-
-int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src)
-{
- const char *scan = src->ptr;
- const char *scan_end = src->ptr + src->size;
- const char *next = memchr(scan, '\r', src->size);
- size_t new_size;
- char *out;
-
- assert(tgt != src);
-
- if (!next)
- return git_buf_set(tgt, src->ptr, src->size);
-
- /* reduce reallocs while in the loop */
- GIT_ERROR_CHECK_ALLOC_ADD(&new_size, src->size, 1);
- if (git_buf_grow(tgt, new_size) < 0)
- return -1;
-
- out = tgt->ptr;
- tgt->size = 0;
-
- /* Find the next \r and copy whole chunk up to there to tgt */
- for (; next; scan = next + 1, next = memchr(scan, '\r', scan_end - scan)) {
- if (next > scan) {
- size_t copylen = (size_t)(next - scan);
- memcpy(out, scan, copylen);
- out += copylen;
- }
-
- /* Do not drop \r unless it is followed by \n */
- if (next + 1 == scan_end || next[1] != '\n')
- *out++ = '\r';
- }
-
- /* Copy remaining input into dest */
- if (scan < scan_end) {
- size_t remaining = (size_t)(scan_end - scan);
- memcpy(out, scan, remaining);
- out += remaining;
- }
-
- tgt->size = (size_t)(out - tgt->ptr);
- tgt->ptr[tgt->size] = '\0';
-
- return 0;
-}
-
-int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src)
-{
- const char *start = src->ptr;
- const char *end = start + src->size;
- const char *scan = start;
- const char *next = memchr(scan, '\n', src->size);
- size_t alloclen;
-
- assert(tgt != src);
-
- if (!next)
- return git_buf_set(tgt, src->ptr, src->size);
-
- /* attempt to reduce reallocs while in the loop */
- GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4);
- GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
- if (git_buf_grow(tgt, alloclen) < 0)
- return -1;
- tgt->size = 0;
-
- for (; next; scan = next + 1, next = memchr(scan, '\n', end - scan)) {
- size_t copylen = next - scan;
-
- /* if we find mixed line endings, carry on */
- if (copylen && next[-1] == '\r')
- copylen--;
-
- GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, copylen, 3);
- if (git_buf_grow_by(tgt, alloclen) < 0)
- return -1;
-
- if (copylen) {
- memcpy(tgt->ptr + tgt->size, scan, copylen);
- tgt->size += copylen;
- }
-
- tgt->ptr[tgt->size++] = '\r';
- tgt->ptr[tgt->size++] = '\n';
- }
-
- tgt->ptr[tgt->size] = '\0';
- return git_buf_put(tgt, scan, end - scan);
-}
-
-int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings)
-{
- size_t i;
- const char *str, *pfx;
-
- git_buf_clear(buf);
-
- if (!strings || !strings->count)
- return 0;
-
- /* initialize common prefix to first string */
- if (git_buf_sets(buf, strings->strings[0]) < 0)
- return -1;
-
- /* go through the rest of the strings, truncating to shared prefix */
- for (i = 1; i < strings->count; ++i) {
-
- for (str = strings->strings[i], pfx = buf->ptr;
- *str && *str == *pfx; str++, pfx++)
- /* scanning */;
-
- git_buf_truncate(buf, pfx - buf->ptr);
-
- if (!buf->size)
- break;
- }
-
- return 0;
-}
-
-bool git_buf_text_is_binary(const git_buf *buf)
-{
- const char *scan = buf->ptr, *end = buf->ptr + buf->size;
- git_bom_t bom;
- int printable = 0, nonprintable = 0;
-
- scan += git_buf_text_detect_bom(&bom, buf);
-
- if (bom > GIT_BOM_UTF8)
- return 1;
-
- while (scan < end) {
- unsigned char c = *scan++;
-
- /* Printable characters are those above SPACE (0x1F) excluding DEL,
- * and including BS, ESC and FF.
- */
- if ((c > 0x1F && c != 127) || c == '\b' || c == '\033' || c == '\014')
- printable++;
- else if (c == '\0')
- return true;
- else if (!git__isspace(c))
- nonprintable++;
- }
-
- return ((printable >> 7) < nonprintable);
-}
-
-bool git_buf_text_contains_nul(const git_buf *buf)
-{
- return (memchr(buf->ptr, '\0', buf->size) != NULL);
-}
-
-int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf)
-{
- const char *ptr;
- size_t len;
-
- *bom = GIT_BOM_NONE;
- /* need at least 2 bytes to look for any BOM */
- if (buf->size < 2)
- return 0;
-
- ptr = buf->ptr;
- len = buf->size;
-
- switch (*ptr++) {
- case 0:
- if (len >= 4 && ptr[0] == 0 && ptr[1] == '\xFE' && ptr[2] == '\xFF') {
- *bom = GIT_BOM_UTF32_BE;
- return 4;
- }
- break;
- case '\xEF':
- if (len >= 3 && ptr[0] == '\xBB' && ptr[1] == '\xBF') {
- *bom = GIT_BOM_UTF8;
- return 3;
- }
- break;
- case '\xFE':
- if (*ptr == '\xFF') {
- *bom = GIT_BOM_UTF16_BE;
- return 2;
- }
- break;
- case '\xFF':
- if (*ptr != '\xFE')
- break;
- if (len >= 4 && ptr[1] == 0 && ptr[2] == 0) {
- *bom = GIT_BOM_UTF32_LE;
- return 4;
- } else {
- *bom = GIT_BOM_UTF16_LE;
- return 2;
- }
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-bool git_buf_text_gather_stats(
- git_buf_text_stats *stats, const git_buf *buf, bool skip_bom)
-{
- const char *scan = buf->ptr, *end = buf->ptr + buf->size;
- int skip;
-
- memset(stats, 0, sizeof(*stats));
-
- /* BOM detection */
- skip = git_buf_text_detect_bom(&stats->bom, buf);
- if (skip_bom)
- scan += skip;
-
- /* Ignore EOF character */
- if (buf->size > 0 && end[-1] == '\032')
- end--;
-
- /* Counting loop */
- while (scan < end) {
- unsigned char c = *scan++;
-
- if (c > 0x1F && c != 0x7F)
- stats->printable++;
- else switch (c) {
- case '\0':
- stats->nul++;
- stats->nonprintable++;
- break;
- case '\n':
- stats->lf++;
- break;
- case '\r':
- stats->cr++;
- if (scan < end && *scan == '\n')
- stats->crlf++;
- break;
- case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/
- stats->printable++;
- break;
- default:
- stats->nonprintable++;
- break;
- }
- }
-
- /* Treat files with a bare CR as binary */
- return (stats->cr != stats->crlf || stats->nul > 0 ||
- ((stats->printable >> 7) < stats->nonprintable));
-}
diff --git a/src/buf_text.h b/src/buf_text.h
deleted file mode 100644
index 726b0ae..0000000
--- a/src/buf_text.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_buf_text_h__
-#define INCLUDE_buf_text_h__
-
-#include "common.h"
-
-#include "buffer.h"
-
-typedef enum {
- GIT_BOM_NONE = 0,
- GIT_BOM_UTF8 = 1,
- GIT_BOM_UTF16_LE = 2,
- GIT_BOM_UTF16_BE = 3,
- GIT_BOM_UTF32_LE = 4,
- GIT_BOM_UTF32_BE = 5
-} git_bom_t;
-
-typedef struct {
- git_bom_t bom; /* BOM found at head of text */
- unsigned int nul, cr, lf, crlf; /* NUL, CR, LF and CRLF counts */
- unsigned int printable, nonprintable; /* These are just approximations! */
-} git_buf_text_stats;
-
-/**
- * Append string to buffer, prefixing each character from `esc_chars` with
- * `esc_with` string.
- *
- * @param buf Buffer to append data to
- * @param string String to escape and append
- * @param esc_chars Characters to be escaped
- * @param esc_with String to insert in from of each found character
- * @return 0 on success, <0 on failure (probably allocation problem)
- */
-extern int git_buf_text_puts_escaped(
- git_buf *buf,
- const char *string,
- const char *esc_chars,
- const char *esc_with);
-
-/**
- * Append string escaping characters that are regex special
- */
-GIT_INLINE(int) git_buf_text_puts_escape_regex(git_buf *buf, const char *string)
-{
- return git_buf_text_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\");
-}
-
-/**
- * Unescape all characters in a buffer in place
- *
- * I.e. remove backslashes
- */
-extern void git_buf_text_unescape(git_buf *buf);
-
-/**
- * Replace all \r\n with \n.
- *
- * @return 0 on success, -1 on memory error
- */
-extern int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src);
-
-/**
- * Replace all \n with \r\n. Does not modify existing \r\n.
- *
- * @return 0 on success, -1 on memory error
- */
-extern int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src);
-
-/**
- * Fill buffer with the common prefix of a array of strings
- *
- * Buffer will be set to empty if there is no common prefix
- */
-extern int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strs);
-
-/**
- * Check quickly if buffer looks like it contains binary data
- *
- * @param buf Buffer to check
- * @return true if buffer looks like non-text data
- */
-extern bool git_buf_text_is_binary(const git_buf *buf);
-
-/**
- * Check quickly if buffer contains a NUL byte
- *
- * @param buf Buffer to check
- * @return true if buffer contains a NUL byte
- */
-extern bool git_buf_text_contains_nul(const git_buf *buf);
-
-/**
- * Check if a buffer begins with a UTF BOM
- *
- * @param bom Set to the type of BOM detected or GIT_BOM_NONE
- * @param buf Buffer in which to check the first bytes for a BOM
- * @return Number of bytes of BOM data (or 0 if no BOM found)
- */
-extern int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf);
-
-/**
- * Gather stats for a piece of text
- *
- * Fill the `stats` structure with counts of unreadable characters, carriage
- * returns, etc, so it can be used in heuristics. This automatically skips
- * a trailing EOF (\032 character). Also it will look for a BOM at the
- * start of the text and can be told to skip that as well.
- *
- * @param stats Structure to be filled in
- * @param buf Text to process
- * @param skip_bom Exclude leading BOM from stats if true
- * @return Does the buffer heuristically look like binary data
- */
-extern bool git_buf_text_gather_stats(
- git_buf_text_stats *stats, const git_buf *buf, bool skip_bom);
-
-#endif
diff --git a/src/buffer.c b/src/buffer.c
index 328fdfe..794e1f1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -7,7 +7,6 @@
#include "buffer.h"
#include "posix.h"
#include "git2/buffer.h"
-#include "buf_text.h"
#include <ctype.h>
/* Used as default value for git_buf->ptr so that people can always
@@ -133,18 +132,24 @@ void git_buf_dispose(git_buf *buf)
git_buf_init(buf, 0);
}
+#ifndef GIT_DEPRECATE_HARD
void git_buf_free(git_buf *buf)
{
git_buf_dispose(buf);
}
+#endif
-void git_buf_sanitize(git_buf *buf)
+int git_buf_sanitize(git_buf *buf)
{
if (buf->ptr == NULL) {
- assert(buf->size == 0 && buf->asize == 0);
+ GIT_ASSERT_ARG(buf->size == 0 && buf->asize == 0);
+
buf->ptr = git_buf__initbuf;
- } else if (buf->asize > buf->size)
+ } else if (buf->asize > buf->size) {
buf->ptr[buf->size] = '\0';
+ }
+
+ return 0;
}
void git_buf_clear(git_buf *buf)
@@ -181,16 +186,6 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
return 0;
}
-int git_buf_is_binary(const git_buf *buf)
-{
- return git_buf_text_is_binary(buf);
-}
-
-int git_buf_contains_nul(const git_buf *buf)
-{
- return git_buf_text_contains_nul(buf);
-}
-
int git_buf_sets(git_buf *buf, const char *string)
{
return git_buf_set(buf, string, string ? strlen(string) : 0);
@@ -223,7 +218,7 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
if (len) {
size_t new_size;
- assert(data);
+ GIT_ASSERT_ARG(data);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, len);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
@@ -237,7 +232,8 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
int git_buf_puts(git_buf *buf, const char *string)
{
- assert(string);
+ GIT_ASSERT_ARG(string);
+
return git_buf_put(buf, string, strlen(string));
}
@@ -317,7 +313,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
return -1;
}
- assert(len % 4 == 0);
+ GIT_ASSERT_ARG(len % 4 == 0);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
ENSURE_SIZE(buf, new_size);
@@ -363,7 +359,7 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
for (i = 24; i >= 0; i -= 8) {
uint8_t ch = *data++;
- acc |= ch << i;
+ acc |= (uint32_t)ch << i;
if (--len == 0)
break;
@@ -549,22 +545,26 @@ int git_buf_printf(git_buf *buf, const char *format, ...)
return r;
}
-void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
+int git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
{
size_t copylen;
- assert(data && datasize && buf);
+ GIT_ASSERT_ARG(data);
+ GIT_ASSERT_ARG(datasize);
+ GIT_ASSERT_ARG(buf);
data[0] = '\0';
if (buf->size == 0 || buf->asize <= 0)
- return;
+ return 0;
copylen = buf->size;
if (copylen > datasize - 1)
copylen = datasize - 1;
memmove(data, buf->ptr, copylen);
data[copylen] = '\0';
+
+ return 0;
}
void git_buf_consume_bytes(git_buf *buf, size_t len)
@@ -757,7 +757,8 @@ int git_buf_join(
ssize_t offset_a = -1;
/* not safe to have str_b point internally to the buffer */
- assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
+ if (buf->size)
+ GIT_ASSERT_ARG(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
/* figure out if we need to insert a separator */
if (separator && strlen_a) {
@@ -767,7 +768,7 @@ int git_buf_join(
}
/* str_a could be part of the buffer */
- if (str_a >= buf->ptr && str_a < buf->ptr + buf->size)
+ if (buf->size && str_a >= buf->ptr && str_a < buf->ptr + buf->size)
offset_a = str_a - buf->ptr;
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b);
@@ -807,9 +808,9 @@ int git_buf_join3(
char *tgt;
/* for this function, disallow pointers into the existing buffer */
- assert(str_a < buf->ptr || str_a >= buf->ptr + buf->size);
- assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
- assert(str_c < buf->ptr || str_c >= buf->ptr + buf->size);
+ GIT_ASSERT(str_a < buf->ptr || str_a >= buf->ptr + buf->size);
+ GIT_ASSERT(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
+ GIT_ASSERT(str_c < buf->ptr || str_c >= buf->ptr + buf->size);
if (separator) {
if (len_a > 0) {
@@ -882,7 +883,9 @@ int git_buf_splice(
char *splice_loc;
size_t new_size, alloc_size;
- assert(buf && where <= buf->size && nb_to_remove <= buf->size - where);
+ GIT_ASSERT(buf);
+ GIT_ASSERT(where <= buf->size);
+ GIT_ASSERT(nb_to_remove <= buf->size - where);
splice_loc = buf->ptr + where;
@@ -1044,3 +1047,312 @@ invalid:
git_error_set(GIT_ERROR_INVALID, "invalid quoted line");
return -1;
}
+
+int git_buf_puts_escaped(
+ git_buf *buf,
+ const char *string,
+ const char *esc_chars,
+ const char *esc_with)
+{
+ const char *scan;
+ size_t total = 0, esc_len = strlen(esc_with), count, alloclen;
+
+ if (!string)
+ return 0;
+
+ for (scan = string; *scan; ) {
+ /* count run of non-escaped characters */
+ count = strcspn(scan, esc_chars);
+ total += count;
+ scan += count;
+ /* count run of escaped characters */
+ count = strspn(scan, esc_chars);
+ total += count * (esc_len + 1);
+ scan += count;
+ }
+
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, total, 1);
+ if (git_buf_grow_by(buf, alloclen) < 0)
+ return -1;
+
+ for (scan = string; *scan; ) {
+ count = strcspn(scan, esc_chars);
+
+ memmove(buf->ptr + buf->size, scan, count);
+ scan += count;
+ buf->size += count;
+
+ for (count = strspn(scan, esc_chars); count > 0; --count) {
+ /* copy escape sequence */
+ memmove(buf->ptr + buf->size, esc_with, esc_len);
+ buf->size += esc_len;
+ /* copy character to be escaped */
+ buf->ptr[buf->size] = *scan;
+ buf->size++;
+ scan++;
+ }
+ }
+
+ buf->ptr[buf->size] = '\0';
+
+ return 0;
+}
+
+void git_buf_unescape(git_buf *buf)
+{
+ buf->size = git__unescape(buf->ptr);
+}
+
+int git_buf_crlf_to_lf(git_buf *tgt, const git_buf *src)
+{
+ const char *scan = src->ptr;
+ const char *scan_end = src->ptr + src->size;
+ const char *next = memchr(scan, '\r', src->size);
+ size_t new_size;
+ char *out;
+
+ GIT_ASSERT(tgt != src);
+
+ if (!next)
+ return git_buf_set(tgt, src->ptr, src->size);
+
+ /* reduce reallocs while in the loop */
+ GIT_ERROR_CHECK_ALLOC_ADD(&new_size, src->size, 1);
+ if (git_buf_grow(tgt, new_size) < 0)
+ return -1;
+
+ out = tgt->ptr;
+ tgt->size = 0;
+
+ /* Find the next \r and copy whole chunk up to there to tgt */
+ for (; next; scan = next + 1, next = memchr(scan, '\r', scan_end - scan)) {
+ if (next > scan) {
+ size_t copylen = (size_t)(next - scan);
+ memcpy(out, scan, copylen);
+ out += copylen;
+ }
+
+ /* Do not drop \r unless it is followed by \n */
+ if (next + 1 == scan_end || next[1] != '\n')
+ *out++ = '\r';
+ }
+
+ /* Copy remaining input into dest */
+ if (scan < scan_end) {
+ size_t remaining = (size_t)(scan_end - scan);
+ memcpy(out, scan, remaining);
+ out += remaining;
+ }
+
+ tgt->size = (size_t)(out - tgt->ptr);
+ tgt->ptr[tgt->size] = '\0';
+
+ return 0;
+}
+
+int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src)
+{
+ const char *start = src->ptr;
+ const char *end = start + src->size;
+ const char *scan = start;
+ const char *next = memchr(scan, '\n', src->size);
+ size_t alloclen;
+
+ GIT_ASSERT(tgt != src);
+
+ if (!next)
+ return git_buf_set(tgt, src->ptr, src->size);
+
+ /* attempt to reduce reallocs while in the loop */
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4);
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
+ if (git_buf_grow(tgt, alloclen) < 0)
+ return -1;
+ tgt->size = 0;
+
+ for (; next; scan = next + 1, next = memchr(scan, '\n', end - scan)) {
+ size_t copylen = next - scan;
+
+ /* if we find mixed line endings, carry on */
+ if (copylen && next[-1] == '\r')
+ copylen--;
+
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, copylen, 3);
+ if (git_buf_grow_by(tgt, alloclen) < 0)
+ return -1;
+
+ if (copylen) {
+ memcpy(tgt->ptr + tgt->size, scan, copylen);
+ tgt->size += copylen;
+ }
+
+ tgt->ptr[tgt->size++] = '\r';
+ tgt->ptr[tgt->size++] = '\n';
+ }
+
+ tgt->ptr[tgt->size] = '\0';
+ return git_buf_put(tgt, scan, end - scan);
+}
+
+int git_buf_common_prefix(git_buf *buf, const git_strarray *strings)
+{
+ size_t i;
+ const char *str, *pfx;
+
+ git_buf_clear(buf);
+
+ if (!strings || !strings->count)
+ return 0;
+
+ /* initialize common prefix to first string */
+ if (git_buf_sets(buf, strings->strings[0]) < 0)
+ return -1;
+
+ /* go through the rest of the strings, truncating to shared prefix */
+ for (i = 1; i < strings->count; ++i) {
+
+ for (str = strings->strings[i], pfx = buf->ptr;
+ *str && *str == *pfx; str++, pfx++)
+ /* scanning */;
+
+ git_buf_truncate(buf, pfx - buf->ptr);
+
+ if (!buf->size)
+ break;
+ }
+
+ return 0;
+}
+
+int git_buf_is_binary(const git_buf *buf)
+{
+ const char *scan = buf->ptr, *end = buf->ptr + buf->size;
+ git_buf_bom_t bom;
+ int printable = 0, nonprintable = 0;
+
+ scan += git_buf_detect_bom(&bom, buf);
+
+ if (bom > GIT_BUF_BOM_UTF8)
+ return 1;
+
+ while (scan < end) {
+ unsigned char c = *scan++;
+
+ /* Printable characters are those above SPACE (0x1F) excluding DEL,
+ * and including BS, ESC and FF.
+ */
+ if ((c > 0x1F && c != 127) || c == '\b' || c == '\033' || c == '\014')
+ printable++;
+ else if (c == '\0')
+ return true;
+ else if (!git__isspace(c))
+ nonprintable++;
+ }
+
+ return ((printable >> 7) < nonprintable);
+}
+
+int git_buf_contains_nul(const git_buf *buf)
+{
+ return (memchr(buf->ptr, '\0', buf->size) != NULL);
+}
+
+int git_buf_detect_bom(git_buf_bom_t *bom, const git_buf *buf)
+{
+ const char *ptr;
+ size_t len;
+
+ *bom = GIT_BUF_BOM_NONE;
+ /* need at least 2 bytes to look for any BOM */
+ if (buf->size < 2)
+ return 0;
+
+ ptr = buf->ptr;
+ len = buf->size;
+
+ switch (*ptr++) {
+ case 0:
+ if (len >= 4 && ptr[0] == 0 && ptr[1] == '\xFE' && ptr[2] == '\xFF') {
+ *bom = GIT_BUF_BOM_UTF32_BE;
+ return 4;
+ }
+ break;
+ case '\xEF':
+ if (len >= 3 && ptr[0] == '\xBB' && ptr[1] == '\xBF') {
+ *bom = GIT_BUF_BOM_UTF8;
+ return 3;
+ }
+ break;
+ case '\xFE':
+ if (*ptr == '\xFF') {
+ *bom = GIT_BUF_BOM_UTF16_BE;
+ return 2;
+ }
+ break;
+ case '\xFF':
+ if (*ptr != '\xFE')
+ break;
+ if (len >= 4 && ptr[1] == 0 && ptr[2] == 0) {
+ *bom = GIT_BUF_BOM_UTF32_LE;
+ return 4;
+ } else {
+ *bom = GIT_BUF_BOM_UTF16_LE;
+ return 2;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+bool git_buf_gather_text_stats(
+ git_buf_text_stats *stats, const git_buf *buf, bool skip_bom)
+{
+ const char *scan = buf->ptr, *end = buf->ptr + buf->size;
+ int skip;
+
+ memset(stats, 0, sizeof(*stats));
+
+ /* BOM detection */
+ skip = git_buf_detect_bom(&stats->bom, buf);
+ if (skip_bom)
+ scan += skip;
+
+ /* Ignore EOF character */
+ if (buf->size > 0 && end[-1] == '\032')
+ end--;
+
+ /* Counting loop */
+ while (scan < end) {
+ unsigned char c = *scan++;
+
+ if (c > 0x1F && c != 0x7F)
+ stats->printable++;
+ else switch (c) {
+ case '\0':
+ stats->nul++;
+ stats->nonprintable++;
+ break;
+ case '\n':
+ stats->lf++;
+ break;
+ case '\r':
+ stats->cr++;
+ if (scan < end && *scan == '\n')
+ stats->crlf++;
+ break;
+ case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/
+ stats->printable++;
+ break;
+ default:
+ stats->nonprintable++;
+ break;
+ }
+ }
+
+ /* Treat files with a bare CR as binary */
+ return (stats->cr != stats->crlf || stats->nul > 0 ||
+ ((stats->printable >> 7) < stats->nonprintable));
+}
diff --git a/src/buffer.h b/src/buffer.h
index 6b717d2..d043ed6 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -17,6 +17,21 @@
* } git_buf;
*/
+typedef enum {
+ GIT_BUF_BOM_NONE = 0,
+ GIT_BUF_BOM_UTF8 = 1,
+ GIT_BUF_BOM_UTF16_LE = 2,
+ GIT_BUF_BOM_UTF16_BE = 3,
+ GIT_BUF_BOM_UTF32_LE = 4,
+ GIT_BUF_BOM_UTF32_BE = 5
+} git_buf_bom_t;
+
+typedef struct {
+ git_buf_bom_t bom; /* BOM found at head of text */
+ unsigned int nul, cr, lf, crlf; /* NUL, CR, LF and CRLF counts */
+ unsigned int printable, nonprintable; /* These are just approximations! */
+} git_buf_text_stats;
+
extern char git_buf__initbuf[];
extern char git_buf__oom[];
@@ -69,7 +84,7 @@ extern int git_buf_try_grow(
* git_buf__initbuf. If a buffer with a non-NULL ptr is passed in, this method
* assures that the buffer is '\0'-terminated.
*/
-extern void git_buf_sanitize(git_buf *buf);
+extern int git_buf_sanitize(git_buf *buf);
extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b);
extern char *git_buf_detach(git_buf *buf);
@@ -145,7 +160,7 @@ GIT_INLINE(size_t) git_buf_len(const git_buf *buf)
return buf->size;
}
-void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf);
+int git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf);
#define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1)
@@ -219,4 +234,81 @@ int git_buf_splice(
const char *data,
size_t nb_to_insert);
+/**
+ * Append string to buffer, prefixing each character from `esc_chars` with
+ * `esc_with` string.
+ *
+ * @param buf Buffer to append data to
+ * @param string String to escape and append
+ * @param esc_chars Characters to be escaped
+ * @param esc_with String to insert in from of each found character
+ * @return 0 on success, <0 on failure (probably allocation problem)
+ */
+extern int git_buf_puts_escaped(
+ git_buf *buf,
+ const char *string,
+ const char *esc_chars,
+ const char *esc_with);
+
+/**
+ * Append string escaping characters that are regex special
+ */
+GIT_INLINE(int) git_buf_puts_escape_regex(git_buf *buf, const char *string)
+{
+ return git_buf_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\");
+}
+
+/**
+ * Unescape all characters in a buffer in place
+ *
+ * I.e. remove backslashes
+ */
+extern void git_buf_unescape(git_buf *buf);
+
+/**
+ * Replace all \r\n with \n.
+ *
+ * @return 0 on success, -1 on memory error
+ */
+extern int git_buf_crlf_to_lf(git_buf *tgt, const git_buf *src);
+
+/**
+ * Replace all \n with \r\n. Does not modify existing \r\n.
+ *
+ * @return 0 on success, -1 on memory error
+ */
+extern int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src);
+
+/**
+ * Fill buffer with the common prefix of a array of strings
+ *
+ * Buffer will be set to empty if there is no common prefix
+ */
+extern int git_buf_common_prefix(git_buf *buf, const git_strarray *strs);
+
+/**
+ * Check if a buffer begins with a UTF BOM
+ *
+ * @param bom Set to the type of BOM detected or GIT_BOM_NONE
+ * @param buf Buffer in which to check the first bytes for a BOM
+ * @return Number of bytes of BOM data (or 0 if no BOM found)
+ */
+extern int git_buf_detect_bom(git_buf_bom_t *bom, const git_buf *buf);
+
+/**
+ * Gather stats for a piece of text
+ *
+ * Fill the `stats` structure with counts of unreadable characters, carriage
+ * returns, etc, so it can be used in heuristics. This automatically skips
+ * a trailing EOF (\032 character). Also it will look for a BOM at the
+ * start of the text and can be told to skip that as well.
+ *
+ * @param stats Structure to be filled in
+ * @param buf Text to process
+ * @param skip_bom Exclude leading BOM from stats if true
+ * @return Does the buffer heuristically look like binary data
+ */
+extern bool git_buf_gather_text_stats(
+ git_buf_text_stats *stats, const git_buf *buf, bool skip_bom);
+
#endif
diff --git a/src/cache.c b/src/cache.c
index 32ba993..2f68e35 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -9,7 +9,7 @@
#include "repository.h"
#include "commit.h"
-#include "thread-utils.h"
+#include "thread.h"
#include "util.h"
#include "odb.h"
#include "object.h"
@@ -41,27 +41,6 @@ int git_cache_set_max_object_size(git_object_t type, size_t size)
return 0;
}
-void git_cache_dump_stats(git_cache *cache)
-{
- git_cached_obj *object;
-
- if (git_cache_size(cache) == 0)
- return;
-
- printf("Cache %p: %"PRIuZ" items cached, %"PRIdZ" bytes\n",
- cache, git_cache_size(cache), cache->used_memory);
-
- git_oidmap_foreach_value(cache->map, object, {
- char oid_str[9];
- printf(" %s%c %s (%"PRIuZ")\n",
- git_object_type2string(object->type),
- object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ',
- git_oid_tostr(oid_str, sizeof(oid_str), &object->oid),
- object->size
- );
- });
-}
-
int git_cache_init(git_cache *cache)
{
memset(cache, 0, sizeof(*cache));
@@ -189,7 +168,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
return entry;
/* soften the load on the cache */
- if (git_cache__current_storage.val > git_cache__max_storage)
+ if (git_atomic_ssize_get(&git_cache__current_storage) > git_cache__max_storage)
cache_evict_entries(cache);
/* not found */
@@ -208,10 +187,14 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
entry = stored_entry;
} else if (stored_entry->flags == GIT_CACHE_STORE_RAW &&
entry->flags == GIT_CACHE_STORE_PARSED) {
- git_cached_obj_decref(stored_entry);
- git_cached_obj_incref(entry);
-
- git_oidmap_set(cache->map, &entry->oid, entry);
+ if (git_oidmap_set(cache->map, &entry->oid, entry) == 0) {
+ git_cached_obj_decref(stored_entry);
+ git_cached_obj_incref(entry);
+ } else {
+ git_cached_obj_decref(entry);
+ git_cached_obj_incref(stored_entry);
+ entry = stored_entry;
+ }
} else {
/* NO OP */
}
@@ -252,7 +235,7 @@ void git_cached_obj_decref(void *_obj)
{
git_cached_obj *obj = _obj;
- if (git_atomic_dec(&obj->refcount) == 0) {
+ if (git_atomic32_dec(&obj->refcount) == 0) {
switch (obj->flags) {
case GIT_CACHE_STORE_RAW:
git_odb_object__free(_obj);
diff --git a/src/cache.h b/src/cache.h
index 1e61792..42c4fa8 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -13,7 +13,7 @@
#include "git2/oid.h"
#include "git2/odb.h"
-#include "thread-utils.h"
+#include "thread.h"
#include "oidmap.h"
enum {
@@ -23,11 +23,11 @@ enum {
};
typedef struct {
- git_oid oid;
- int16_t type; /* git_object_t value */
- uint16_t flags; /* GIT_CACHE_STORE value */
- size_t size;
- git_atomic refcount;
+ git_oid oid;
+ int16_t type; /* git_object_t value */
+ uint16_t flags; /* GIT_CACHE_STORE value */
+ size_t size;
+ git_atomic32 refcount;
} git_cached_obj;
typedef struct {
@@ -61,7 +61,7 @@ GIT_INLINE(size_t) git_cache_size(git_cache *cache)
GIT_INLINE(void) git_cached_obj_incref(void *_obj)
{
git_cached_obj *obj = _obj;
- git_atomic_inc(&obj->refcount);
+ git_atomic32_inc(&obj->refcount);
}
void git_cached_obj_decref(void *_obj);
diff --git a/src/cc-compat.h b/src/cc-compat.h
index 7ade561..6bdc651 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -43,9 +43,17 @@
# define GIT_ALIGN(x,size) x
#endif
-#define GIT_UNUSED(x) ((void)(x))
+#if defined(__GNUC__)
+# define GIT_UNUSED(x) \
+ do { \
+ typeof(x) _unused __attribute__((unused)); \
+ _unused = (x); \
+ } while (0)
+#else
+# define GIT_UNUSED(x) ((void)(x))
+#endif
-/* Define the printf format specifer to use for size_t output */
+/* Define the printf format specifier to use for size_t output */
#if defined(_MSC_VER) || defined(__MINGW32__)
/* Visual Studio 2012 and prior lack PRId64 entirely */
diff --git a/src/checkout.c b/src/checkout.c
index 5cfa728..31d473e 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -26,7 +26,6 @@
#include "diff.h"
#include "diff_generate.h"
#include "pathspec.h"
-#include "buf_text.h"
#include "diff_xdiff.h"
#include "path.h"
#include "attr.h"
@@ -44,7 +43,6 @@ enum {
CHECKOUT_ACTION__REMOVE_CONFLICT = 16,
CHECKOUT_ACTION__UPDATE_CONFLICT = 32,
CHECKOUT_ACTION__MAX = 32,
- CHECKOUT_ACTION__DEFER_REMOVE = 64,
CHECKOUT_ACTION__REMOVE_AND_UPDATE =
(CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE),
};
@@ -196,7 +194,7 @@ static bool checkout_is_workdir_modified(
}
if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
- GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
+ GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
rval = true;
else if ((sm_oid = git_submodule_wd_id(sm)) == NULL)
rval = false;
@@ -217,9 +215,10 @@ static bool checkout_is_workdir_modified(
ie = git_index_get_bypath(data->index, wditem->path, 0);
if (ie != NULL &&
- git_index_time_eq(&wditem->mtime, &ie->mtime) &&
- wditem->file_size == ie->file_size &&
- !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) {
+ !git_index_entry_newer_than_index(ie, data->index) &&
+ git_index_time_eq(&wditem->mtime, &ie->mtime) &&
+ wditem->file_size == ie->file_size &&
+ !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) {
/* The workdir is modified iff the index entry is modified */
return !is_workdir_base_or_new(&ie->id, baseitem, newitem) ||
@@ -273,9 +272,8 @@ static int checkout_action_common(
/* if the file is on disk and doesn't match our mode, force update */
if (wd &&
- GIT_PERMS_IS_EXEC(wd->mode) !=
- GIT_PERMS_IS_EXEC(delta->new_file.mode))
- *action |= CHECKOUT_ACTION__REMOVE;
+ GIT_PERMS_IS_EXEC(wd->mode) != GIT_PERMS_IS_EXEC(delta->new_file.mode))
+ *action |= CHECKOUT_ACTION__REMOVE;
notify = GIT_CHECKOUT_NOTIFY_UPDATED;
}
@@ -330,6 +328,9 @@ static int checkout_target_fullpath(
if (path && git_buf_puts(&data->target_path, path) < 0)
return -1;
+ if (git_path_validate_workdir_buf(data->repo, &data->target_path) < 0)
+ return -1;
+
*out = &data->target_path;
return 0;
@@ -371,8 +372,13 @@ static int checkout_action_wd_only(
if (!git_pathspec__match(
pathspec, wd->path,
(data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0,
- git_iterator_ignore_case(workdir), NULL, NULL))
- return git_iterator_advance(wditem, workdir);
+ git_iterator_ignore_case(workdir), NULL, NULL)) {
+
+ if (wd->mode == GIT_FILEMODE_TREE)
+ return git_iterator_advance_into(wditem, workdir);
+ else
+ return git_iterator_advance(wditem, workdir);
+ }
/* check if item is tracked in the index but not in the checkout diff */
if (data->index != NULL) {
@@ -794,13 +800,13 @@ static int checkout_conflictdata_cmp(const void *a, const void *b)
int diff;
if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
- (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
+ (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
diff = checkout_idxentry_cmp(ca->theirs, cb->theirs);
return diff;
}
-int checkout_conflictdata_empty(
+static int checkout_conflictdata_empty(
const git_vector *conflicts, size_t idx, void *payload)
{
checkout_conflictdata *conflict;
@@ -1173,7 +1179,7 @@ static int checkout_conflicts_mark_directoryfile(
/* Find d/f conflicts */
git_vector_foreach(&data->update_conflicts, i, conflict) {
if ((conflict->ours && conflict->theirs) ||
- (!conflict->ours && !conflict->theirs))
+ (!conflict->ours && !conflict->theirs))
continue;
path = conflict->ours ?
@@ -1222,8 +1228,8 @@ static int checkout_get_update_conflicts(
return 0;
if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
- (error = checkout_conflicts_coalesce_renames(data)) < 0 ||
- (error = checkout_conflicts_mark_directoryfile(data)) < 0)
+ (error = checkout_conflicts_coalesce_renames(data)) < 0 ||
+ (error = checkout_conflicts_mark_directoryfile(data)) < 0)
goto done;
done:
@@ -1239,7 +1245,7 @@ static int checkout_conflict_append_remove(
checkout_data *data = payload;
const char *name;
- assert(ancestor || ours || theirs);
+ GIT_ASSERT_ARG(ancestor || ours || theirs);
if (ancestor)
name = git__strdup(ancestor->path);
@@ -1274,14 +1280,14 @@ static int checkout_verify_paths(
unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;
if (action & CHECKOUT_ACTION__REMOVE) {
- if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
+ if (!git_path_validate(repo, delta->old_file.path, delta->old_file.mode, flags)) {
git_error_set(GIT_ERROR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
return -1;
}
}
if (action & ~CHECKOUT_ACTION__REMOVE) {
- if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
+ if (!git_path_validate(repo, delta->new_file.path, delta->new_file.mode, flags)) {
git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
return -1;
}
@@ -1304,14 +1310,15 @@ static int checkout_get_actions(
size_t i, *counts = NULL;
uint32_t *actions = NULL;
- git_pool_init(&pathpool, 1);
+ if (git_pool_init(&pathpool, 1) < 0)
+ return -1;
if (data->opts.paths.count > 0 &&
- git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
+ git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
return -1;
if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
- error != GIT_ITEROVER)
+ error != GIT_ITEROVER)
goto fail;
deltas = &data->diff->deltas;
@@ -1350,8 +1357,7 @@ static int checkout_get_actions(
counts[CHECKOUT_ACTION__REMOVE] += data->removes.length;
if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
- (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
- {
+ (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) {
git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
counts[CHECKOUT_ACTION__CONFLICT],
counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
@@ -1362,7 +1368,7 @@ static int checkout_get_actions(
if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
- (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
+ (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
goto fail;
counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts);
@@ -1483,7 +1489,9 @@ static int checkout_stream_write(
static int checkout_stream_close(git_writestream *s)
{
struct checkout_stream *stream = (struct checkout_stream *)s;
- assert(stream && stream->open);
+
+ GIT_ASSERT_ARG(stream);
+ GIT_ASSERT_ARG(stream->open);
stream->open = 0;
return p_close(stream->fd);
@@ -1505,7 +1513,7 @@ static int blob_content_to_file(
int flags = data->opts.file_open_flags;
mode_t file_mode = data->opts.file_mode ?
data->opts.file_mode : entry_filemode;
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
struct checkout_stream writer;
mode_t mode;
git_filter_list *fl = NULL;
@@ -1528,13 +1536,13 @@ static int blob_content_to_file(
return fd;
}
- filter_opts.attr_session = &data->attr_session;
- filter_opts.temp_buf = &data->tmp;
+ filter_session.attr_session = &data->attr_session;
+ filter_session.temp_buf = &data->tmp;
if (!data->opts.disable_filters &&
- (error = git_filter_list__load_ext(
+ (error = git_filter_list__load(
&fl, data->repo, blob, hint_path,
- GIT_FILTER_TO_WORKTREE, &filter_opts))) {
+ GIT_FILTER_TO_WORKTREE, &filter_session))) {
p_close(fd);
return error;
}
@@ -1550,7 +1558,7 @@ static int blob_content_to_file(
error = git_filter_list_stream_blob(fl, blob, &writer.base);
- assert(writer.open == 0);
+ GIT_ASSERT(writer.open == 0);
git_filter_list_free(fl);
@@ -1853,26 +1861,6 @@ static int checkout_remove_the_old(
return 0;
}
-static int checkout_deferred_remove(git_repository *repo, const char *path)
-{
-#if 0
- int error = git_futils_rmdir_r(
- path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS);
-
- if (error == GIT_ENOTFOUND) {
- error = 0;
- git_error_clear();
- }
-
- return error;
-#else
- GIT_UNUSED(repo);
- GIT_UNUSED(path);
- assert(false);
- return 0;
-#endif
-}
-
static int checkout_create_the_new(
unsigned int *actions,
checkout_data *data)
@@ -1882,15 +1870,6 @@ static int checkout_create_the_new(
size_t i;
git_vector_foreach(&data->diff->deltas, i, delta) {
- if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
- /* this had a blocker directory that should only be removed iff
- * all of the contents of the directory were safely removed
- */
- if ((error = checkout_deferred_remove(
- data->repo, delta->old_file.path)) < 0)
- return error;
- }
-
if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
if ((error = checkout_blob(data, &delta->new_file)) < 0)
return error;
@@ -1915,20 +1894,10 @@ static int checkout_create_submodules(
unsigned int *actions,
checkout_data *data)
{
- int error = 0;
git_diff_delta *delta;
size_t i;
git_vector_foreach(&data->diff->deltas, i, delta) {
- if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
- /* this has a blocker directory that should only be removed iff
- * all of the contents of the directory were safely removed
- */
- if ((error = checkout_deferred_remove(
- data->repo, delta->old_file.path)) < 0)
- return error;
- }
-
if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
int error = checkout_submodule(data, &delta->new_file);
if (error < 0)
@@ -2011,7 +1980,7 @@ static int checkout_write_entry(
struct stat st;
int error;
- assert (side == conflict->ours || side == conflict->theirs);
+ GIT_ASSERT(side == conflict->ours || side == conflict->theirs);
if (checkout_target_fullpath(&fullpath, data, side->path) < 0)
return -1;
@@ -2065,7 +2034,8 @@ static int checkout_merge_path(
const char *our_label_raw, *their_label_raw, *suffix;
int error = 0;
- if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0)
+ if ((error = git_buf_joinpath(out, data->opts.target_directory, result->path)) < 0 ||
+ (error = git_path_validate_workdir_buf(data->repo, out)) < 0)
return error;
/* Most conflicts simply use the filename in the index */
@@ -2094,7 +2064,7 @@ static int checkout_write_merge(
git_merge_file_result result = {0};
git_filebuf output = GIT_FILEBUF_INIT;
git_filter_list *fl = NULL;
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
int error = 0;
if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)
@@ -2144,13 +2114,13 @@ static int checkout_write_merge(
in_data.ptr = (char *)result.ptr;
in_data.size = result.len;
- filter_opts.attr_session = &data->attr_session;
- filter_opts.temp_buf = &data->tmp;
+ filter_session.attr_session = &data->attr_session;
+ filter_session.temp_buf = &data->tmp;
- if ((error = git_filter_list__load_ext(
+ if ((error = git_filter_list__load(
&fl, data->repo, NULL, git_buf_cstr(&path_workdir),
- GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 ||
- (error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0)
+ GIT_FILTER_TO_WORKTREE, &filter_session)) < 0 ||
+ (error = git_filter_list__convert_buf(&out_data, fl, &in_data)) < 0)
goto done;
} else {
out_data.ptr = (char *)result.ptr;
@@ -2364,6 +2334,22 @@ static void checkout_data_clear(checkout_data *data)
git_attr_session__free(&data->attr_session);
}
+static int validate_target_directory(checkout_data *data)
+{
+ int error;
+
+ if ((error = git_path_validate_workdir(data->repo, data->opts.target_directory)) < 0)
+ return error;
+
+ if (git_path_isdir(data->opts.target_directory))
+ return 0;
+
+ error = checkout_mkdir(data, data->opts.target_directory, NULL,
+ GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR);
+
+ return error;
+}
+
static int checkout_data_init(
checkout_data *data,
git_iterator *target,
@@ -2396,10 +2382,7 @@ static int checkout_data_init(
if (!data->opts.target_directory)
data->opts.target_directory = git_repository_workdir(repo);
- else if (!git_path_isdir(data->opts.target_directory) &&
- (error = checkout_mkdir(data,
- data->opts.target_directory, NULL,
- GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0)
+ else if ((error = validate_target_directory(data)) < 0)
goto cleanup;
if ((error = git_repository_index(&data->index, data->repo)) < 0)
@@ -2520,9 +2503,8 @@ static int checkout_data_init(
git_config_entry_free(conflict_style);
}
- git_pool_init(&data->pool, 1);
-
- if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
+ if ((error = git_pool_init(&data->pool, 1)) < 0 ||
+ (error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
(error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
(error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
(error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
@@ -2544,6 +2526,17 @@ cleanup:
#define CHECKOUT_INDEX_DONT_WRITE_MASK \
(GIT_CHECKOUT_DONT_UPDATE_INDEX | GIT_CHECKOUT_DONT_WRITE_INDEX)
+GIT_INLINE(void) setup_pathspecs(
+ git_iterator_options *iter_opts,
+ const git_checkout_options *checkout_opts)
+{
+ if (checkout_opts &&
+ (checkout_opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
+ iter_opts->pathlist.count = checkout_opts->paths.count;
+ iter_opts->pathlist.strings = checkout_opts->paths.strings;
+ }
+}
+
int git_checkout_iterator(
git_iterator *target,
git_index *index,
@@ -2586,6 +2579,8 @@ int git_checkout_iterator(
workdir_opts.start = data.pfx;
workdir_opts.end = data.pfx;
+ setup_pathspecs(&workdir_opts, opts);
+
if ((error = git_iterator_reset_range(target, data.pfx, data.pfx)) < 0 ||
(error = git_iterator_for_workdir_ext(
&workdir, data.repo, data.opts.target_directory, index, NULL,
@@ -2596,10 +2591,8 @@ int git_checkout_iterator(
GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
baseline_opts.start = data.pfx;
baseline_opts.end = data.pfx;
- if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
- baseline_opts.pathlist.count = opts->paths.count;
- baseline_opts.pathlist.strings = opts->paths.strings;
- }
+
+ setup_pathspecs(&baseline_opts, opts);
if (data.opts.baseline_index) {
if ((error = git_iterator_for_index(
@@ -2613,7 +2606,7 @@ int git_checkout_iterator(
}
/* Should not have case insensitivity mismatch */
- assert(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
+ GIT_ASSERT(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
/* Generate baseline-to-target diff which will include an entry for
* every possible update that might need to be made.
@@ -2664,7 +2657,7 @@ int git_checkout_iterator(
(error = checkout_extensions_update_index(&data)) < 0)
goto cleanup;
- assert(data.completed_steps == data.total_steps);
+ GIT_ASSERT(data.completed_steps == data.total_steps);
if (data.opts.perfdata_cb)
data.opts.perfdata_cb(&data.perfdata, data.opts.perfdata_payload);
@@ -2689,6 +2682,7 @@ int git_checkout_index(
git_index *index,
const git_checkout_options *opts)
{
+ git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
int error, owned = 0;
git_iterator *index_i;
@@ -2716,7 +2710,9 @@ int git_checkout_index(
return error;
GIT_REFCOUNT_INC(index);
- if (!(error = git_iterator_for_index(&index_i, repo, index, NULL)))
+ setup_pathspecs(&iter_opts, opts);
+
+ if (!(error = git_iterator_for_index(&index_i, repo, index, &iter_opts)))
error = git_checkout_iterator(index_i, index, opts);
if (owned)
@@ -2773,10 +2769,7 @@ int git_checkout_tree(
if ((error = git_repository_index(&index, repo)) < 0)
return error;
- if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
- iter_opts.pathlist.count = opts->paths.count;
- iter_opts.pathlist.strings = opts->paths.strings;
- }
+ setup_pathspecs(&iter_opts, opts);
if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
error = git_checkout_iterator(tree_i, index, opts);
@@ -2792,7 +2785,8 @@ int git_checkout_head(
git_repository *repo,
const git_checkout_options *opts)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
+
return git_checkout_tree(repo, NULL, opts);
}
@@ -2803,7 +2797,9 @@ int git_checkout_options_init(git_checkout_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_checkout_init_options(git_checkout_options *opts, unsigned int version)
{
return git_checkout_options_init(opts, version);
}
+#endif
diff --git a/src/cherrypick.c b/src/cherrypick.c
index 640d11a..4287956 100644
--- a/src/cherrypick.c
+++ b/src/cherrypick.c
@@ -126,7 +126,10 @@ int git_cherrypick_commit(
git_tree *parent_tree = NULL, *our_tree = NULL, *cherrypick_tree = NULL;
int parent = 0, error = 0;
- assert(out && repo && cherrypick_commit && our_commit);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(cherrypick_commit);
+ GIT_ASSERT_ARG(our_commit);
if (git_commit_parentcount(cherrypick_commit) > 1) {
if (!mainline)
@@ -177,7 +180,8 @@ int git_cherrypick(
git_indexwriter indexwriter = GIT_INDEXWRITER_INIT;
int error = 0;
- assert(repo && commit);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(commit);
GIT_ERROR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options");
@@ -229,8 +233,10 @@ int git_cherrypick_options_init(
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_cherrypick_init_options(
git_cherrypick_options *opts, unsigned int version)
{
return git_cherrypick_options_init(opts, version);
}
+#endif
diff --git a/src/clone.c b/src/clone.c
index 3d749c3..e29a4aa 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -137,6 +137,80 @@ static int update_head_to_new_branch(
return error;
}
+static int update_head_to_default(git_repository *repo)
+{
+ git_buf initialbranch = GIT_BUF_INIT;
+ const char *branch_name;
+ int error = 0;
+
+ if ((error = git_repository_initialbranch(&initialbranch, repo)) < 0)
+ goto done;
+
+ if (git__prefixcmp(initialbranch.ptr, GIT_REFS_HEADS_DIR) != 0) {
+ git_error_set(GIT_ERROR_INVALID, "invalid initial branch '%s'", initialbranch.ptr);
+ error = -1;
+ goto done;
+ }
+
+ branch_name = initialbranch.ptr + strlen(GIT_REFS_HEADS_DIR);
+
+ error = setup_tracking_config(repo, branch_name, GIT_REMOTE_ORIGIN,
+ initialbranch.ptr);
+
+done:
+ git_buf_dispose(&initialbranch);
+ return error;
+}
+
+static int update_remote_head(
+ git_repository *repo,
+ git_remote *remote,
+ git_buf *target,
+ const char *reflog_message)
+{
+ git_refspec *refspec;
+ git_reference *remote_head = NULL;
+ git_buf remote_head_name = GIT_BUF_INIT;
+ git_buf remote_branch_name = GIT_BUF_INIT;
+ int error;
+
+ /* Determine the remote tracking ref name from the local branch */
+ refspec = git_remote__matching_refspec(remote, git_buf_cstr(target));
+
+ if (refspec == NULL) {
+ git_error_set(GIT_ERROR_NET, "the remote's default branch does not fit the refspec configuration");
+ error = GIT_EINVALIDSPEC;
+ goto cleanup;
+ }
+
+ if ((error = git_refspec_transform(
+ &remote_branch_name,
+ refspec,
+ git_buf_cstr(target))) < 0)
+ goto cleanup;
+
+ if ((error = git_buf_printf(&remote_head_name,
+ "%s%s/%s",
+ GIT_REFS_REMOTES_DIR,
+ git_remote_name(remote),
+ GIT_HEAD_FILE)) < 0)
+ goto cleanup;
+
+ error = git_reference_symbolic_create(
+ &remote_head,
+ repo,
+ git_buf_cstr(&remote_head_name),
+ git_buf_cstr(&remote_branch_name),
+ true,
+ reflog_message);
+
+cleanup:
+ git_reference_free(remote_head);
+ git_buf_dispose(&remote_branch_name);
+ git_buf_dispose(&remote_head_name);
+ return error;
+}
+
static int update_head_to_remote(
git_repository *repo,
git_remote *remote,
@@ -144,10 +218,8 @@ static int update_head_to_remote(
{
int error = 0;
size_t refs_len;
- git_refspec *refspec;
const git_remote_head *remote_head, **refs;
const git_oid *remote_head_id;
- git_buf remote_master_name = GIT_BUF_INIT;
git_buf branch = GIT_BUF_INIT;
if ((error = git_remote_ls(&refs, &refs_len, remote)) < 0)
@@ -155,12 +227,11 @@ static int update_head_to_remote(
/* We cloned an empty repository or one with an unborn HEAD */
if (refs_len == 0 || strcmp(refs[0]->name, GIT_HEAD_FILE))
- return setup_tracking_config(
- repo, "master", GIT_REMOTE_ORIGIN, GIT_REFS_HEADS_MASTER_FILE);
+ return update_head_to_default(repo);
/* We know we have HEAD, let's see where it points */
remote_head = refs[0];
- assert(remote_head);
+ GIT_ASSERT(remote_head);
remote_head_id = &remote_head->oid;
@@ -171,19 +242,7 @@ static int update_head_to_remote(
goto cleanup;
}
- refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch));
-
- if (refspec == NULL) {
- git_error_set(GIT_ERROR_NET, "the remote's default branch does not fit the refspec configuration");
- error = GIT_EINVALIDSPEC;
- goto cleanup;
- }
-
- /* Determine the remote tracking reference name from the local master */
- if ((error = git_refspec_transform(
- &remote_master_name,
- refspec,
- git_buf_cstr(&branch))) < 0)
+ if ((error = update_remote_head(repo, remote, &branch, reflog_message)) < 0)
goto cleanup;
error = update_head_to_new_branch(
@@ -193,7 +252,6 @@ static int update_head_to_remote(
reflog_message);
cleanup:
- git_buf_dispose(&remote_master_name);
git_buf_dispose(&branch);
return error;
@@ -201,29 +259,41 @@ cleanup:
static int update_head_to_branch(
git_repository *repo,
- const char *remote_name,
+ git_remote *remote,
const char *branch,
const char *reflog_message)
{
int retcode;
git_buf remote_branch_name = GIT_BUF_INIT;
git_reference* remote_ref = NULL;
+ git_buf default_branch = GIT_BUF_INIT;
- assert(remote_name && branch);
+ GIT_ASSERT_ARG(remote);
+ GIT_ASSERT_ARG(branch);
if ((retcode = git_buf_printf(&remote_branch_name, GIT_REFS_REMOTES_DIR "%s/%s",
- remote_name, branch)) < 0 )
+ git_remote_name(remote), branch)) < 0 )
goto cleanup;
if ((retcode = git_reference_lookup(&remote_ref, repo, git_buf_cstr(&remote_branch_name))) < 0)
goto cleanup;
- retcode = update_head_to_new_branch(repo, git_reference_target(remote_ref), branch,
- reflog_message);
+ if ((retcode = update_head_to_new_branch(repo, git_reference_target(remote_ref), branch,
+ reflog_message)) < 0)
+ goto cleanup;
+
+ if ((retcode = git_remote_default_branch(&default_branch, remote)) < 0)
+ goto cleanup;
+
+ if (!git_remote__matching_refspec(remote, git_buf_cstr(&default_branch)))
+ goto cleanup;
+
+ retcode = update_remote_head(repo, remote, &default_branch, reflog_message);
cleanup:
git_reference_free(remote_ref);
git_buf_dispose(&remote_branch_name);
+ git_buf_dispose(&default_branch);
return retcode;
}
@@ -308,8 +378,7 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
int error;
if (branch)
- error = update_head_to_branch(repo, git_remote_name(remote), branch,
- reflog_message);
+ error = update_head_to_branch(repo, remote, branch, reflog_message);
/* Point HEAD to the same ref as the remote's head */
else
error = update_head_to_remote(repo, remote, reflog_message);
@@ -327,7 +396,8 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
git_fetch_options fetch_opts;
git_remote *remote;
- assert(repo && _remote);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(_remote);
if (!git_repository_is_empty(repo)) {
git_error_set(GIT_ERROR_INVALID, "the repository is not empty");
@@ -394,7 +464,9 @@ static int git__clone(
uint32_t rmdir_flags = GIT_RMDIR_REMOVE_FILES;
git_repository_create_cb repository_cb;
- assert(out && url && local_path);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(url);
+ GIT_ASSERT_ARG(local_path);
if (_options)
memcpy(&options, _options, sizeof(git_clone_options));
@@ -479,10 +551,12 @@ int git_clone_options_init(git_clone_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_clone_init_options(git_clone_options *opts, unsigned int version)
{
return git_clone_options_init(opts, version);
}
+#endif
static bool can_link(const char *src, const char *dst, int link)
{
@@ -515,7 +589,8 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
git_buf src_odb = GIT_BUF_INIT, dst_odb = GIT_BUF_INIT, src_path = GIT_BUF_INIT;
git_buf reflog_message = GIT_BUF_INIT;
- assert(repo && remote);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(remote);
if (!git_repository_is_empty(repo)) {
git_error_set(GIT_ERROR_INVALID, "the repository is not empty");
diff --git a/src/commit.c b/src/commit.c
index cf9902d..96259d5 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -53,7 +53,8 @@ static int git_commit__create_buffer_internal(
size_t i = 0;
const git_oid *parent;
- assert(out && tree);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(tree);
git_oid__writebuf(out, "tree ", tree);
@@ -229,7 +230,8 @@ int git_commit_create_v(
int error = 0;
commit_parent_varargs data;
- assert(tree && git_tree_owner(tree) == repo);
+ GIT_ASSERT_ARG(tree);
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
data.total = parent_count;
va_start(data.args, parent_count);
@@ -306,7 +308,8 @@ int git_commit_create(
{
commit_parent_data data = { parent_count, parents, repo };
- assert(tree && git_tree_owner(tree) == repo);
+ GIT_ASSERT_ARG(tree);
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
return git_commit__create_internal(
id, repo, update_ref, author, committer,
@@ -337,7 +340,8 @@ int git_commit_amend(
git_reference *ref;
int error;
- assert(id && commit_to_amend);
+ GIT_ASSERT_ARG(id);
+ GIT_ASSERT_ARG(commit_to_amend);
repo = git_commit_owner(commit_to_amend);
@@ -356,7 +360,7 @@ int git_commit_amend(
git_oid_cpy(&tree_id, git_tree_id(old_tree));
git_tree_free(old_tree);
} else {
- assert(git_tree_owner(tree) == repo);
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
git_oid_cpy(&tree_id, git_tree_id(tree));
}
@@ -392,7 +396,8 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
size_t header_len;
git_signature dummy_sig;
- assert(commit && data);
+ GIT_ASSERT_ARG(commit);
+ GIT_ASSERT_ARG(data);
buffer = buffer_start;
@@ -506,28 +511,28 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
return git_commit__parse_ext(_commit, odb_obj, 0);
}
-#define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
+#define GIT_COMMIT_GETTER(_rvalue, _name, _return, _invalid) \
_rvalue git_commit_##_name(const git_commit *commit) \
{\
- assert(commit); \
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, _invalid); \
return _return; \
}
-GIT_COMMIT_GETTER(const git_signature *, author, commit->author)
-GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer)
-GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message)
-GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding)
-GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header)
-GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time)
-GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset)
-GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids))
-GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id)
+GIT_COMMIT_GETTER(const git_signature *, author, commit->author, NULL)
+GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer, NULL)
+GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message, NULL)
+GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding, NULL)
+GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header, NULL)
+GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time, INT64_MIN)
+GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset, -1)
+GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids), 0)
+GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id, NULL)
const char *git_commit_message(const git_commit *commit)
{
const char *message;
- assert(commit);
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
message = commit->raw_message;
@@ -544,7 +549,7 @@ const char *git_commit_summary(git_commit *commit)
const char *msg, *space;
bool space_contains_newline = false;
- assert(commit);
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
if (!commit->summary) {
for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) {
@@ -587,7 +592,7 @@ const char *git_commit_body(git_commit *commit)
{
const char *msg, *end;
- assert(commit);
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
if (!commit->body) {
/* search for end of summary */
@@ -612,14 +617,14 @@ const char *git_commit_body(git_commit *commit)
int git_commit_tree(git_tree **tree_out, const git_commit *commit)
{
- assert(commit);
+ GIT_ASSERT_ARG(commit);
return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_id);
}
const git_oid *git_commit_parent_id(
const git_commit *commit, unsigned int n)
{
- assert(commit);
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
return git_array_get(commit->parent_ids, n);
}
@@ -628,7 +633,7 @@ int git_commit_parent(
git_commit **parent, const git_commit *commit, unsigned int n)
{
const git_oid *parent_id;
- assert(commit);
+ GIT_ASSERT_ARG(commit);
parent_id = git_commit_parent_id(commit, n);
if (parent_id == NULL) {
@@ -647,7 +652,8 @@ int git_commit_nth_gen_ancestor(
git_commit *current, *parent = NULL;
int error;
- assert(ancestor && commit);
+ GIT_ASSERT_ARG(ancestor);
+ GIT_ASSERT_ARG(commit);
if (git_commit_dup(¤t, (git_commit *)commit) < 0)
return -1;
@@ -840,7 +846,8 @@ int git_commit_create_buffer(git_buf *out,
git_array_oid_t parents_arr = GIT_ARRAY_INIT;
const git_oid *tree_id;
- assert(tree && git_tree_owner(tree) == repo);
+ GIT_ASSERT_ARG(tree);
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
tree_id = git_tree_id(tree);
@@ -859,11 +866,13 @@ int git_commit_create_buffer(git_buf *out,
/**
* Append to 'out' properly marking continuations when there's a newline in 'content'
*/
-static void format_header_field(git_buf *out, const char *field, const char *content)
+static int format_header_field(git_buf *out, const char *field, const char *content)
{
const char *lf;
- assert(out && field && content);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(field);
+ GIT_ASSERT_ARG(content);
git_buf_puts(out, field);
git_buf_putc(out, ' ');
@@ -876,6 +885,8 @@ static void format_header_field(git_buf *out, const char *field, const char *con
git_buf_puts(out, content);
git_buf_putc(out, '\n');
+
+ return git_buf_oom(out) ? -1 : 0;
}
static const git_oid *commit_parent_from_commit(size_t n, void *payload)
@@ -926,7 +937,9 @@ int git_commit_create_with_signature(
if (signature != NULL) {
field = signature_field ? signature_field : "gpgsig";
- format_header_field(&commit, field, signature);
+
+ if ((error = format_header_field(&commit, field, signature)) < 0)
+ goto cleanup;
}
git_buf_puts(&commit, header_end);
diff --git a/src/commit_graph.c b/src/commit_graph.c
new file mode 100644
index 0000000..5569256
--- /dev/null
+++ b/src/commit_graph.c
@@ -0,0 +1,549 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "commit_graph.h"
+
+#include "futils.h"
+#include "hash.h"
+#include "pack.h"
+
+#define GIT_COMMIT_GRAPH_MISSING_PARENT 0x70000000
+
+#define COMMIT_GRAPH_SIGNATURE 0x43475048 /* "CGPH" */
+#define COMMIT_GRAPH_VERSION 1
+#define COMMIT_GRAPH_OBJECT_ID_VERSION 1
+struct git_commit_graph_header {
+ uint32_t signature;
+ uint8_t version;
+ uint8_t object_id_version;
+ uint8_t chunks;
+ uint8_t base_graph_files;
+};
+
+#define COMMIT_GRAPH_OID_FANOUT_ID 0x4f494446 /* "OIDF" */
+#define COMMIT_GRAPH_OID_LOOKUP_ID 0x4f49444c /* "OIDL" */
+#define COMMIT_GRAPH_COMMIT_DATA_ID 0x43444154 /* "CDAT" */
+#define COMMIT_GRAPH_EXTRA_EDGE_LIST_ID 0x45444745 /* "EDGE" */
+#define COMMIT_GRAPH_BLOOM_FILTER_INDEX_ID 0x42494458 /* "BIDX" */
+#define COMMIT_GRAPH_BLOOM_FILTER_DATA_ID 0x42444154 /* "BDAT" */
+
+struct git_commit_graph_chunk {
+ off64_t offset;
+ size_t length;
+};
+
+static int commit_graph_error(const char *message)
+{
+ git_error_set(GIT_ERROR_ODB, "invalid commit-graph file - %s", message);
+ return -1;
+}
+
+static int commit_graph_parse_oid_fanout(
+ git_commit_graph_file *file,
+ const unsigned char *data,
+ struct git_commit_graph_chunk *chunk_oid_fanout)
+{
+ uint32_t i, nr;
+ if (chunk_oid_fanout->offset == 0)
+ return commit_graph_error("missing OID Fanout chunk");
+ if (chunk_oid_fanout->length == 0)
+ return commit_graph_error("empty OID Fanout chunk");
+ if (chunk_oid_fanout->length != 256 * 4)
+ return commit_graph_error("OID Fanout chunk has wrong length");
+
+ file->oid_fanout = (const uint32_t *)(data + chunk_oid_fanout->offset);
+ nr = 0;
+ for (i = 0; i < 256; ++i) {
+ uint32_t n = ntohl(file->oid_fanout[i]);
+ if (n < nr)
+ return commit_graph_error("index is non-monotonic");
+ nr = n;
+ }
+ file->num_commits = nr;
+ return 0;
+}
+
+static int commit_graph_parse_oid_lookup(
+ git_commit_graph_file *file,
+ const unsigned char *data,
+ struct git_commit_graph_chunk *chunk_oid_lookup)
+{
+ uint32_t i;
+ git_oid *oid, *prev_oid, zero_oid = {{0}};
+
+ if (chunk_oid_lookup->offset == 0)
+ return commit_graph_error("missing OID Lookup chunk");
+ if (chunk_oid_lookup->length == 0)
+ return commit_graph_error("empty OID Lookup chunk");
+ if (chunk_oid_lookup->length != file->num_commits * GIT_OID_RAWSZ)
+ return commit_graph_error("OID Lookup chunk has wrong length");
+
+ file->oid_lookup = oid = (git_oid *)(data + chunk_oid_lookup->offset);
+ prev_oid = &zero_oid;
+ for (i = 0; i < file->num_commits; ++i, ++oid) {
+ if (git_oid_cmp(prev_oid, oid) >= 0)
+ return commit_graph_error("OID Lookup index is non-monotonic");
+ prev_oid = oid;
+ }
+
+ return 0;
+}
+
+static int commit_graph_parse_commit_data(
+ git_commit_graph_file *file,
+ const unsigned char *data,
+ struct git_commit_graph_chunk *chunk_commit_data)
+{
+ if (chunk_commit_data->offset == 0)
+ return commit_graph_error("missing Commit Data chunk");
+ if (chunk_commit_data->length == 0)
+ return commit_graph_error("empty Commit Data chunk");
+ if (chunk_commit_data->length != file->num_commits * (GIT_OID_RAWSZ + 16))
+ return commit_graph_error("Commit Data chunk has wrong length");
+
+ file->commit_data = data + chunk_commit_data->offset;
+
+ return 0;
+}
+
+static int commit_graph_parse_extra_edge_list(
+ git_commit_graph_file *file,
+ const unsigned char *data,
+ struct git_commit_graph_chunk *chunk_extra_edge_list)
+{
+ if (chunk_extra_edge_list->length == 0)
+ return 0;
+ if (chunk_extra_edge_list->length % 4 != 0)
+ return commit_graph_error("malformed Extra Edge List chunk");
+
+ file->extra_edge_list = data + chunk_extra_edge_list->offset;
+ file->num_extra_edge_list = chunk_extra_edge_list->length / 4;
+
+ return 0;
+}
+
+int git_commit_graph_file_parse(
+ git_commit_graph_file *file,
+ const unsigned char *data,
+ size_t size)
+{
+ struct git_commit_graph_header *hdr;
+ const unsigned char *chunk_hdr;
+ struct git_commit_graph_chunk *last_chunk;
+ uint32_t i;
+ off64_t last_chunk_offset, chunk_offset, trailer_offset;
+ git_oid cgraph_checksum = {{0}};
+ int error;
+ struct git_commit_graph_chunk chunk_oid_fanout = {0}, chunk_oid_lookup = {0},
+ chunk_commit_data = {0}, chunk_extra_edge_list = {0},
+ chunk_unsupported = {0};
+
+ GIT_ASSERT_ARG(file);
+
+ if (size < sizeof(struct git_commit_graph_header) + GIT_OID_RAWSZ)
+ return commit_graph_error("commit-graph is too short");
+
+ hdr = ((struct git_commit_graph_header *)data);
+
+ if (hdr->signature != htonl(COMMIT_GRAPH_SIGNATURE) || hdr->version != COMMIT_GRAPH_VERSION
+ || hdr->object_id_version != COMMIT_GRAPH_OBJECT_ID_VERSION) {
+ return commit_graph_error("unsupported commit-graph version");
+ }
+ if (hdr->chunks == 0)
+ return commit_graph_error("no chunks in commit-graph");
+
+ /*
+ * The very first chunk's offset should be after the header, all the chunk
+ * headers, and a special zero chunk.
+ */
+ last_chunk_offset = sizeof(struct git_commit_graph_header) + (1 + hdr->chunks) * 12;
+ trailer_offset = size - GIT_OID_RAWSZ;
+ if (trailer_offset < last_chunk_offset)
+ return commit_graph_error("wrong commit-graph size");
+ git_oid_cpy(&file->checksum, (git_oid *)(data + trailer_offset));
+
+ if (git_hash_buf(&cgraph_checksum, data, (size_t)trailer_offset) < 0)
+ return commit_graph_error("could not calculate signature");
+ if (!git_oid_equal(&cgraph_checksum, &file->checksum))
+ return commit_graph_error("index signature mismatch");
+
+ chunk_hdr = data + sizeof(struct git_commit_graph_header);
+ last_chunk = NULL;
+ for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
+ chunk_offset = ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32
+ | ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 8))));
+ if (chunk_offset < last_chunk_offset)
+ return commit_graph_error("chunks are non-monotonic");
+ if (chunk_offset >= trailer_offset)
+ return commit_graph_error("chunks extend beyond the trailer");
+ if (last_chunk != NULL)
+ last_chunk->length = (size_t)(chunk_offset - last_chunk_offset);
+ last_chunk_offset = chunk_offset;
+
+ switch (ntohl(*((uint32_t *)(chunk_hdr + 0)))) {
+ case COMMIT_GRAPH_OID_FANOUT_ID:
+ chunk_oid_fanout.offset = last_chunk_offset;
+ last_chunk = &chunk_oid_fanout;
+ break;
+
+ case COMMIT_GRAPH_OID_LOOKUP_ID:
+ chunk_oid_lookup.offset = last_chunk_offset;
+ last_chunk = &chunk_oid_lookup;
+ break;
+
+ case COMMIT_GRAPH_COMMIT_DATA_ID:
+ chunk_commit_data.offset = last_chunk_offset;
+ last_chunk = &chunk_commit_data;
+ break;
+
+ case COMMIT_GRAPH_EXTRA_EDGE_LIST_ID:
+ chunk_extra_edge_list.offset = last_chunk_offset;
+ last_chunk = &chunk_extra_edge_list;
+ break;
+
+ case COMMIT_GRAPH_BLOOM_FILTER_INDEX_ID:
+ case COMMIT_GRAPH_BLOOM_FILTER_DATA_ID:
+ chunk_unsupported.offset = last_chunk_offset;
+ last_chunk = &chunk_unsupported;
+ break;
+
+ default:
+ return commit_graph_error("unrecognized chunk ID");
+ }
+ }
+ last_chunk->length = (size_t)(trailer_offset - last_chunk_offset);
+
+ error = commit_graph_parse_oid_fanout(file, data, &chunk_oid_fanout);
+ if (error < 0)
+ return error;
+ error = commit_graph_parse_oid_lookup(file, data, &chunk_oid_lookup);
+ if (error < 0)
+ return error;
+ error = commit_graph_parse_commit_data(file, data, &chunk_commit_data);
+ if (error < 0)
+ return error;
+ error = commit_graph_parse_extra_edge_list(file, data, &chunk_extra_edge_list);
+ if (error < 0)
+ return error;
+
+ return 0;
+}
+
+int git_commit_graph_new(git_commit_graph **cgraph_out, const char *objects_dir, bool open_file)
+{
+ git_commit_graph *cgraph = NULL;
+ int error = 0;
+
+ GIT_ASSERT_ARG(cgraph_out);
+ GIT_ASSERT_ARG(objects_dir);
+
+ cgraph = git__calloc(1, sizeof(git_commit_graph));
+ GIT_ERROR_CHECK_ALLOC(cgraph);
+
+ error = git_buf_joinpath(&cgraph->filename, objects_dir, "info/commit-graph");
+ if (error < 0)
+ goto error;
+
+ if (open_file) {
+ error = git_commit_graph_file_open(&cgraph->file, git_buf_cstr(&cgraph->filename));
+ if (error < 0)
+ goto error;
+ cgraph->checked = 1;
+ }
+
+ *cgraph_out = cgraph;
+ return 0;
+
+error:
+ git_commit_graph_free(cgraph);
+ return error;
+}
+
+int git_commit_graph_open(git_commit_graph **cgraph_out, const char *objects_dir)
+{
+ return git_commit_graph_new(cgraph_out, objects_dir, true);
+}
+
+int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *path)
+{
+ git_commit_graph_file *file;
+ git_file fd = -1;
+ size_t cgraph_size;
+ struct stat st;
+ int error;
+
+ /* TODO: properly open the file without access time using O_NOATIME */
+ fd = git_futils_open_ro(path);
+ if (fd < 0)
+ return fd;
+
+ if (p_fstat(fd, &st) < 0) {
+ p_close(fd);
+ git_error_set(GIT_ERROR_ODB, "commit-graph file not found - '%s'", path);
+ return GIT_ENOTFOUND;
+ }
+
+ if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)) {
+ p_close(fd);
+ git_error_set(GIT_ERROR_ODB, "invalid pack index '%s'", path);
+ return GIT_ENOTFOUND;
+ }
+ cgraph_size = (size_t)st.st_size;
+
+ file = git__calloc(1, sizeof(git_commit_graph_file));
+ GIT_ERROR_CHECK_ALLOC(file);
+
+ error = git_futils_mmap_ro(&file->graph_map, fd, 0, cgraph_size);
+ p_close(fd);
+ if (error < 0) {
+ git_commit_graph_file_free(file);
+ return error;
+ }
+
+ if ((error = git_commit_graph_file_parse(file, file->graph_map.data, cgraph_size)) < 0) {
+ git_commit_graph_file_free(file);
+ return error;
+ }
+
+ *file_out = file;
+ return 0;
+}
+
+int git_commit_graph_get_file(git_commit_graph_file **file_out, git_commit_graph *cgraph)
+{
+ if (!cgraph->checked) {
+ int error = 0;
+ git_commit_graph_file *result = NULL;
+
+ /* We only check once, no matter the result. */
+ cgraph->checked = 1;
+
+ /* Best effort */
+ error = git_commit_graph_file_open(&result, git_buf_cstr(&cgraph->filename));
+
+ if (error < 0)
+ return error;
+
+ cgraph->file = result;
+ }
+ if (!cgraph->file)
+ return GIT_ENOTFOUND;
+
+ *file_out = cgraph->file;
+ return 0;
+}
+
+void git_commit_graph_refresh(git_commit_graph *cgraph)
+{
+ if (!cgraph->checked)
+ return;
+
+ if (cgraph->file
+ && git_commit_graph_file_needs_refresh(cgraph->file, git_buf_cstr(&cgraph->filename))) {
+ /* We just free the commit graph. The next time it is requested, it will be
+ * re-loaded. */
+ git_commit_graph_file_free(cgraph->file);
+ cgraph->file = NULL;
+ }
+ /* Force a lazy re-check next time it is needed. */
+ cgraph->checked = 0;
+}
+
+static int git_commit_graph_entry_get_byindex(
+ git_commit_graph_entry *e,
+ const git_commit_graph_file *file,
+ size_t pos)
+{
+ const unsigned char *commit_data;
+
+ GIT_ASSERT_ARG(e);
+ GIT_ASSERT_ARG(file);
+
+ if (pos >= file->num_commits) {
+ git_error_set(GIT_ERROR_INVALID, "commit index %zu does not exist", pos);
+ return GIT_ENOTFOUND;
+ }
+
+ commit_data = file->commit_data + pos * (GIT_OID_RAWSZ + 4 * sizeof(uint32_t));
+ git_oid_cpy(&e->tree_oid, (const git_oid *)commit_data);
+ e->parent_indices[0] = ntohl(*((uint32_t *)(commit_data + GIT_OID_RAWSZ)));
+ e->parent_indices[1]
+ = ntohl(*((uint32_t *)(commit_data + GIT_OID_RAWSZ + sizeof(uint32_t))));
+ e->parent_count = (e->parent_indices[0] != GIT_COMMIT_GRAPH_MISSING_PARENT)
+ + (e->parent_indices[1] != GIT_COMMIT_GRAPH_MISSING_PARENT);
+ e->generation = ntohl(*((uint32_t *)(commit_data + GIT_OID_RAWSZ + 2 * sizeof(uint32_t))));
+ e->commit_time = ntohl(*((uint32_t *)(commit_data + GIT_OID_RAWSZ + 3 * sizeof(uint32_t))));
+
+ e->commit_time |= (e->generation & UINT64_C(0x3)) << UINT64_C(32);
+ e->generation >>= 2u;
+ if (e->parent_indices[1] & 0x80000000u) {
+ uint32_t extra_edge_list_pos = e->parent_indices[1] & 0x7fffffff;
+
+ /* Make sure we're not being sent out of bounds */
+ if (extra_edge_list_pos >= file->num_extra_edge_list) {
+ git_error_set(GIT_ERROR_INVALID,
+ "commit %u does not exist",
+ extra_edge_list_pos);
+ return GIT_ENOTFOUND;
+ }
+
+ e->extra_parents_index = extra_edge_list_pos;
+ while (extra_edge_list_pos < file->num_extra_edge_list
+ && (ntohl(*(
+ (uint32_t *)(file->extra_edge_list
+ + extra_edge_list_pos * sizeof(uint32_t))))
+ & 0x80000000u)
+ == 0) {
+ extra_edge_list_pos++;
+ e->parent_count++;
+ }
+
+ }
+ git_oid_cpy(&e->sha1, &file->oid_lookup[pos]);
+ return 0;
+}
+
+bool git_commit_graph_file_needs_refresh(const git_commit_graph_file *file, const char *path)
+{
+ git_file fd = -1;
+ struct stat st;
+ ssize_t bytes_read;
+ git_oid cgraph_checksum = {{0}};
+
+ /* TODO: properly open the file without access time using O_NOATIME */
+ fd = git_futils_open_ro(path);
+ if (fd < 0)
+ return true;
+
+ if (p_fstat(fd, &st) < 0) {
+ p_close(fd);
+ return true;
+ }
+
+ if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)
+ || (size_t)st.st_size != file->graph_map.len) {
+ p_close(fd);
+ return true;
+ }
+
+ bytes_read = p_pread(fd, cgraph_checksum.id, GIT_OID_RAWSZ, st.st_size - GIT_OID_RAWSZ);
+ p_close(fd);
+ if (bytes_read != GIT_OID_RAWSZ)
+ return true;
+
+ return !git_oid_equal(&cgraph_checksum, &file->checksum);
+}
+
+int git_commit_graph_entry_find(
+ git_commit_graph_entry *e,
+ const git_commit_graph_file *file,
+ const git_oid *short_oid,
+ size_t len)
+{
+ int pos, found = 0;
+ uint32_t hi, lo;
+ const git_oid *current = NULL;
+
+ GIT_ASSERT_ARG(e);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(short_oid);
+
+ hi = ntohl(file->oid_fanout[(int)short_oid->id[0]]);
+ lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(file->oid_fanout[(int)short_oid->id[0] - 1]));
+
+ pos = git_pack__lookup_sha1(file->oid_lookup, GIT_OID_RAWSZ, lo, hi, short_oid->id);
+
+ if (pos >= 0) {
+ /* An object matching exactly the oid was found */
+ found = 1;
+ current = file->oid_lookup + pos;
+ } else {
+ /* No object was found */
+ /* pos refers to the object with the "closest" oid to short_oid */
+ pos = -1 - pos;
+ if (pos < (int)file->num_commits) {
+ current = file->oid_lookup + pos;
+
+ if (!git_oid_ncmp(short_oid, current, len))
+ found = 1;
+ }
+ }
+
+ if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)file->num_commits) {
+ /* Check for ambiguousity */
+ const git_oid *next = current + 1;
+
+ if (!git_oid_ncmp(short_oid, next, len)) {
+ found = 2;
+ }
+ }
+
+ if (!found)
+ return git_odb__error_notfound(
+ "failed to find offset for commit-graph index entry", short_oid, len);
+ if (found > 1)
+ return git_odb__error_ambiguous(
+ "found multiple offsets for commit-graph index entry");
+
+ return git_commit_graph_entry_get_byindex(e, file, pos);
+}
+
+int git_commit_graph_entry_parent(
+ git_commit_graph_entry *parent,
+ const git_commit_graph_file *file,
+ const git_commit_graph_entry *entry,
+ size_t n)
+{
+ GIT_ASSERT_ARG(parent);
+ GIT_ASSERT_ARG(file);
+
+ if (n >= entry->parent_count) {
+ git_error_set(GIT_ERROR_INVALID, "parent index %zu does not exist", n);
+ return GIT_ENOTFOUND;
+ }
+
+ if (n == 0 || (n == 1 && entry->parent_count == 2))
+ return git_commit_graph_entry_get_byindex(parent, file, entry->parent_indices[n]);
+
+ return git_commit_graph_entry_get_byindex(
+ parent,
+ file,
+ ntohl(
+ *(uint32_t *)(file->extra_edge_list
+ + (entry->extra_parents_index + n - 1)
+ * sizeof(uint32_t)))
+ & 0x7fffffff);
+}
+
+int git_commit_graph_file_close(git_commit_graph_file *file)
+{
+ GIT_ASSERT_ARG(file);
+
+ if (file->graph_map.data)
+ git_futils_mmap_free(&file->graph_map);
+
+ return 0;
+}
+
+void git_commit_graph_free(git_commit_graph *cgraph)
+{
+ if (!cgraph)
+ return;
+
+ git_buf_dispose(&cgraph->filename);
+ git_commit_graph_file_free(cgraph->file);
+ git__free(cgraph);
+}
+
+void git_commit_graph_file_free(git_commit_graph_file *file)
+{
+ if (!file)
+ return;
+
+ git_commit_graph_file_close(file);
+ git__free(file);
+}
diff --git a/src/commit_graph.h b/src/commit_graph.h
new file mode 100644
index 0000000..e5e3ea1
--- /dev/null
+++ b/src/commit_graph.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_commit_graph_h__
+#define INCLUDE_commit_graph_h__
+
+#include "common.h"
+
+#include "git2/types.h"
+#include "git2/sys/commit_graph.h"
+
+#include "map.h"
+
+/**
+ * A commit-graph file.
+ *
+ * This file contains metadata about commits, particularly the generation
+ * number for each one. This can help speed up graph operations without
+ * requiring a full graph traversal.
+ *
+ * Support for this feature was added in git 2.19.
+ */
+typedef struct git_commit_graph_file {
+ git_map graph_map;
+
+ /* The OID Fanout table. */
+ const uint32_t *oid_fanout;
+ /* The total number of commits in the graph. */
+ uint32_t num_commits;
+
+ /* The OID Lookup table. */
+ git_oid *oid_lookup;
+
+ /*
+ * The Commit Data table. Each entry contains the OID of the commit followed
+ * by two 8-byte fields in network byte order:
+ * - The indices of the first two parents (32 bits each).
+ * - The generation number (first 30 bits) and commit time in seconds since
+ * UNIX epoch (34 bits).
+ */
+ const unsigned char *commit_data;
+
+ /*
+ * The Extra Edge List table. Each 4-byte entry is a network byte order index
+ * of one of the i-th (i > 0) parents of commits in the `commit_data` table,
+ * when the commit has more than 2 parents.
+ */
+ const unsigned char *extra_edge_list;
+ /* The number of entries in the Extra Edge List table. Each entry is 4 bytes wide. */
+ size_t num_extra_edge_list;
+
+ /* The trailer of the file. Contains the SHA1-checksum of the whole file. */
+ git_oid checksum;
+} git_commit_graph_file;
+
+/**
+ * An entry in the commit-graph file. Provides a subset of the information that
+ * can be obtained from the commit header.
+ */
+typedef struct git_commit_graph_entry {
+ /* The generation number of the commit within the graph */
+ size_t generation;
+
+ /* Time in seconds from UNIX epoch. */
+ git_time_t commit_time;
+
+ /* The number of parents of the commit. */
+ size_t parent_count;
+
+ /*
+ * The indices of the parent commits within the Commit Data table. The value
+ * of `GIT_COMMIT_GRAPH_MISSING_PARENT` indicates that no parent is in that
+ * position.
+ */
+ size_t parent_indices[2];
+
+ /* The index within the Extra Edge List of any parent after the first two. */
+ size_t extra_parents_index;
+
+ /* The SHA-1 hash of the root tree of the commit. */
+ git_oid tree_oid;
+
+ /* The SHA-1 hash of the requested commit. */
+ git_oid sha1;
+} git_commit_graph_entry;
+
+/* A wrapper for git_commit_graph_file to enable lazy loading in the ODB. */
+struct git_commit_graph {
+ /* The path to the commit-graph file. Something like ".git/objects/info/commit-graph". */
+ git_buf filename;
+
+ /* The underlying commit-graph file. */
+ git_commit_graph_file *file;
+
+ /* Whether the commit-graph file was already checked for validity. */
+ bool checked;
+};
+
+/** Create a new commit-graph, optionally opening the underlying file. */
+int git_commit_graph_new(git_commit_graph **cgraph_out, const char *objects_dir, bool open_file);
+
+/** Open and validate a commit-graph file. */
+int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *path);
+
+/*
+ * Attempt to get the git_commit_graph's commit-graph file. This object is
+ * still owned by the git_commit_graph. If the repository does not contain a commit graph,
+ * it will return GIT_ENOTFOUND.
+ *
+ * This function is not thread-safe.
+ */
+int git_commit_graph_get_file(git_commit_graph_file **file_out, git_commit_graph *cgraph);
+
+/* Marks the commit-graph file as needing a refresh. */
+void git_commit_graph_refresh(git_commit_graph *cgraph);
+
+/*
+ * Returns whether the git_commit_graph_file needs to be reloaded since the
+ * contents of the commit-graph file have changed on disk.
+ */
+bool git_commit_graph_file_needs_refresh(
+ const git_commit_graph_file *file, const char *path);
+
+int git_commit_graph_entry_find(
+ git_commit_graph_entry *e,
+ const git_commit_graph_file *file,
+ const git_oid *short_oid,
+ size_t len);
+int git_commit_graph_entry_parent(
+ git_commit_graph_entry *parent,
+ const git_commit_graph_file *file,
+ const git_commit_graph_entry *entry,
+ size_t n);
+int git_commit_graph_file_close(git_commit_graph_file *cgraph);
+void git_commit_graph_file_free(git_commit_graph_file *cgraph);
+
+/* This is exposed for use in the fuzzers. */
+int git_commit_graph_file_parse(
+ git_commit_graph_file *file,
+ const unsigned char *data,
+ size_t size);
+
+#endif
diff --git a/src/commit_list.c b/src/commit_list.c
index 2e103ec..692b149 100644
--- a/src/commit_list.c
+++ b/src/commit_list.c
@@ -12,6 +12,24 @@
#include "odb.h"
#include "commit.h"
+int git_commit_list_generation_cmp(const void *a, const void *b)
+{
+ uint32_t generation_a = ((git_commit_list_node *) a)->generation;
+ uint32_t generation_b = ((git_commit_list_node *) b)->generation;
+
+ if (!generation_a || !generation_b) {
+ /* Fall back to comparing by timestamps if at least one commit lacks a generation. */
+ return git_commit_list_time_cmp(a, b);
+ }
+
+ if (generation_a < generation_b)
+ return 1;
+ if (generation_a > generation_b)
+ return -1;
+
+ return 0;
+}
+
int git_commit_list_time_cmp(const void *a, const void *b)
{
int64_t time_a = ((git_commit_list_node *) a)->time;
@@ -124,6 +142,7 @@ static int commit_quick_parse(
return -1;
}
+ node->generation = 0;
node->time = commit->committer->when.time;
node->out_degree = (uint16_t) git_array_size(commit->parent_ids);
node->parents = alloc_parents(walk, node, node->out_degree);
@@ -143,11 +162,38 @@ static int commit_quick_parse(
int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
{
git_odb_object *obj;
+ git_commit_graph_file *cgraph_file = NULL;
int error;
if (commit->parsed)
return 0;
+ /* Let's try to use the commit graph first. */
+ git_odb__get_commit_graph_file(&cgraph_file, walk->odb);
+ if (cgraph_file) {
+ git_commit_graph_entry e;
+
+ error = git_commit_graph_entry_find(&e, cgraph_file, &commit->oid, GIT_OID_RAWSZ);
+ if (error == 0 && git__is_uint16(e.parent_count)) {
+ size_t i;
+ commit->generation = (uint32_t)e.generation;
+ commit->time = e.commit_time;
+ commit->out_degree = (uint16_t)e.parent_count;
+ commit->parents = alloc_parents(walk, commit, commit->out_degree);
+ GIT_ERROR_CHECK_ALLOC(commit->parents);
+
+ for (i = 0; i < commit->out_degree; ++i) {
+ git_commit_graph_entry parent;
+ error = git_commit_graph_entry_parent(&parent, cgraph_file, &e, i);
+ if (error < 0)
+ return error;
+ commit->parents[i] = git_revwalk__commit_lookup(walk, &parent.sha1);
+ }
+ commit->parsed = 1;
+ return 0;
+ }
+ }
+
if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
return error;
diff --git a/src/commit_list.h b/src/commit_list.h
index 6a65f8a..aad39f3 100644
--- a/src/commit_list.h
+++ b/src/commit_list.h
@@ -26,6 +26,7 @@
typedef struct git_commit_list_node {
git_oid oid;
int64_t time;
+ uint32_t generation;
unsigned int seen:1,
uninteresting:1,
topo_delay:1,
@@ -45,6 +46,7 @@ typedef struct git_commit_list {
} git_commit_list;
git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk);
+int git_commit_list_generation_cmp(const void *a, const void *b);
int git_commit_list_time_cmp(const void *a, const void *b);
void git_commit_list_free(git_commit_list **list_p);
git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p);
diff --git a/src/common.h b/src/common.h
index a4152ca..9bb1116 100644
--- a/src/common.h
+++ b/src/common.h
@@ -19,6 +19,8 @@
# define GIT_INLINE(type) static __inline type
#elif defined(__GNUC__)
# define GIT_INLINE(type) static __inline__ type
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+# define GIT_INLINE(type) static inline type
#else
# define GIT_INLINE(type) static type
#endif
@@ -28,6 +30,24 @@
# define __has_builtin(x) 0
#endif
+/**
+ * Declare that a function's return value must be used.
+ *
+ * Used mostly to guard against potential silent bugs at runtime. This is
+ * recommended to be added to functions that:
+ *
+ * - Allocate / reallocate memory. This prevents memory leaks or errors where
+ * buffers are expected to have grown to a certain size, but could not be
+ * resized.
+ * - Acquire locks. When a lock cannot be acquired, that will almost certainly
+ * cause a data race / undefined behavior.
+ */
+#if defined(__GNUC__)
+# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+# define GIT_WARN_UNUSED_RESULT
+#endif
+
#include <assert.h>
#include <errno.h>
#include <limits.h>
@@ -63,7 +83,9 @@
# include <pthread.h>
# include <sched.h>
# endif
-#define GIT_STDLIB_CALL
+
+#define GIT_LIBGIT2_CALL
+#define GIT_SYSTEM_CALL
#ifdef GIT_USE_STAT_ATIMESPEC
# define st_atim st_atimespec
@@ -78,8 +100,10 @@
#include "git2/types.h"
#include "git2/errors.h"
#include "errors.h"
-#include "thread-utils.h"
+#include "thread.h"
#include "integer.h"
+#include "assert_safe.h"
+#include "utf8.h"
/*
* Include the declarations for deprecated functions; this ensures
diff --git a/src/config.c b/src/config.c
index 8338da0..7a5dadd 100644
--- a/src/config.c
+++ b/src/config.c
@@ -10,7 +10,6 @@
#include "git2/config.h"
#include "git2/sys/config.h"
-#include "buf_text.h"
#include "config_backend.h"
#include "regexp.h"
#include "sysdir.h"
@@ -108,7 +107,8 @@ int git_config_add_file_ondisk(
struct stat st;
int res;
- assert(cfg && path);
+ GIT_ASSERT_ARG(cfg);
+ GIT_ASSERT_ARG(path);
res = p_stat(path, &st);
if (res < 0 && errno != ENOENT && errno != ENOTDIR) {
@@ -316,7 +316,8 @@ int git_config_add_backend(
backend_internal *internal;
int result;
- assert(cfg && backend);
+ GIT_ASSERT_ARG(cfg);
+ GIT_ASSERT_ARG(backend);
GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
@@ -514,7 +515,8 @@ int git_config_backend_foreach_match(
git_regexp regex;
int error = 0;
- assert(backend && cb);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(cb);
if (regexp && git_regexp_compile(®ex, regexp, 0) < 0)
return -1;
@@ -886,7 +888,8 @@ int git_config_get_string_buf(
int ret;
const char *str;
- git_buf_sanitize(out);
+ if ((ret = git_buf_sanitize(out)) < 0)
+ return ret;
ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS);
str = !ret ? (entry->value ? entry->value : "") : NULL;
@@ -1000,7 +1003,7 @@ static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_it
return error;
}
-void multivar_iter_free(git_config_iterator *_iter)
+static void multivar_iter_free(git_config_iterator *_iter)
{
multivar_iter *iter = (multivar_iter *) _iter;
@@ -1084,19 +1087,31 @@ void git_config_iterator_free(git_config_iterator *iter)
int git_config_find_global(git_buf *path)
{
- git_buf_sanitize(path);
+ int error;
+
+ if ((error = git_buf_sanitize(path)) < 0)
+ return error;
+
return git_sysdir_find_global_file(path, GIT_CONFIG_FILENAME_GLOBAL);
}
int git_config_find_xdg(git_buf *path)
{
- git_buf_sanitize(path);
+ int error;
+
+ if ((error = git_buf_sanitize(path)) < 0)
+ return error;
+
return git_sysdir_find_xdg_file(path, GIT_CONFIG_FILENAME_XDG);
}
int git_config_find_system(git_buf *path)
{
- git_buf_sanitize(path);
+ int error;
+
+ if ((error = git_buf_sanitize(path)) < 0)
+ return error;
+
return git_sysdir_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM);
}
@@ -1104,7 +1119,9 @@ int git_config_find_programdata(git_buf *path)
{
int ret;
- git_buf_sanitize(path);
+ if ((ret = git_buf_sanitize(path)) < 0)
+ return ret;
+
ret = git_sysdir_find_programdata_file(path,
GIT_CONFIG_FILENAME_PROGRAMDATA);
if (ret != GIT_OK)
@@ -1182,7 +1199,7 @@ int git_config_lock(git_transaction **out, git_config *cfg)
git_config_backend *backend;
backend_internal *internal;
- assert(cfg);
+ GIT_ASSERT_ARG(cfg);
internal = git_vector_get(&cfg->backends, 0);
if (!internal || !internal->backend) {
@@ -1202,7 +1219,7 @@ int git_config_unlock(git_config *cfg, int commit)
git_config_backend *backend;
backend_internal *internal;
- assert(cfg);
+ GIT_ASSERT_ARG(cfg);
internal = git_vector_get(&cfg->backends, 0);
if (!internal || !internal->backend) {
@@ -1227,9 +1244,6 @@ int git_config_lookup_map_value(
{
size_t i;
- if (!value)
- goto fail_parse;
-
for (i = 0; i < map_n; ++i) {
const git_configmap *m = maps + i;
@@ -1238,7 +1252,7 @@ int git_config_lookup_map_value(
case GIT_CONFIGMAP_TRUE: {
int bool_val;
- if (git__parse_bool(&bool_val, value) == 0 &&
+ if (git_config_parse_bool(&bool_val, value) == 0 &&
bool_val == (int)m->type) {
*out = m->map_value;
return 0;
@@ -1252,7 +1266,7 @@ int git_config_lookup_map_value(
break;
case GIT_CONFIGMAP_STRING:
- if (strcasecmp(value, m->str_match) == 0) {
+ if (value && strcasecmp(value, m->str_match) == 0) {
*out = m->map_value;
return 0;
}
@@ -1260,7 +1274,6 @@ int git_config_lookup_map_value(
}
}
-fail_parse:
git_error_set(GIT_ERROR_CONFIG, "failed to map '%s'", value);
return -1;
}
@@ -1364,9 +1377,13 @@ fail_parse:
int git_config_parse_path(git_buf *out, const char *value)
{
- assert(out && value);
+ int error;
- git_buf_sanitize(out);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(value);
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
if (value[0] == '~') {
if (value[1] != '\0' && value[1] != '/') {
@@ -1409,7 +1426,8 @@ int git_config__normalize_name(const char *in, char **out)
{
char *name, *fdot, *ldot;
- assert(in && out);
+ GIT_ASSERT_ARG(in);
+ GIT_ASSERT_ARG(out);
name = git__strdup(in);
GIT_ERROR_CHECK_ALLOC(name);
@@ -1478,7 +1496,7 @@ int git_config_rename_section(
int error = 0;
struct rename_data data;
- git_buf_text_puts_escape_regex(&pattern, old_section_name);
+ git_buf_puts_escape_regex(&pattern, old_section_name);
if ((error = git_buf_puts(&pattern, "\\..+")) < 0)
goto cleanup;
diff --git a/src/config_cache.c b/src/config_cache.c
index e4e071b..4bb91f5 100644
--- a/src/config_cache.c
+++ b/src/config_cache.c
@@ -86,6 +86,7 @@ static struct map_data _configmaps[] = {
{"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT },
{"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_DEFAULT },
{"core.fsyncobjectfiles", NULL, 0, GIT_FSYNCOBJECTFILES_DEFAULT },
+ {"core.longpaths", NULL, 0, GIT_LONGPATHS_DEFAULT },
};
int git_config__configmap_lookup(int *out, git_config *config, git_configmap_item item)
@@ -111,17 +112,21 @@ int git_config__configmap_lookup(int *out, git_config *config, git_configmap_ite
int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item)
{
- *out = repo->configmap_cache[(int)item];
+ intptr_t value = (intptr_t)git_atomic_load(repo->configmap_cache[(int)item]);
- if (*out == GIT_CONFIGMAP_NOT_CACHED) {
- int error;
+ *out = (int)value;
+
+ if (value == GIT_CONFIGMAP_NOT_CACHED) {
git_config *config;
+ intptr_t oldval = value;
+ int error;
if ((error = git_repository_config__weakptr(&config, repo)) < 0 ||
(error = git_config__configmap_lookup(out, config, item)) < 0)
return error;
- repo->configmap_cache[(int)item] = *out;
+ value = *out;
+ git_atomic_compare_and_swap(&repo->configmap_cache[(int)item], (void *)oldval, (void *)value);
}
return 0;
diff --git a/src/config_entries.c b/src/config_entries.c
index 3ddd336..66aae09 100644
--- a/src/config_entries.c
+++ b/src/config_entries.c
@@ -11,9 +11,13 @@ typedef struct config_entry_list {
struct config_entry_list *next;
struct config_entry_list *last;
git_config_entry *entry;
- bool first;
} config_entry_list;
+typedef struct {
+ git_config_entry *entry;
+ bool multivar;
+} config_entry_map_head;
+
typedef struct config_entries_iterator {
git_config_iterator parent;
git_config_entries *entries;
@@ -102,14 +106,16 @@ void git_config_entries_incref(git_config_entries *entries)
static void config_entries_free(git_config_entries *entries)
{
config_entry_list *list = NULL, *next;
+ config_entry_map_head *head;
+ git_strmap_foreach_value(entries->map, head,
+ git__free((char *) head->entry->name); git__free(head)
+ );
git_strmap_free(entries->map);
list = entries->list;
while (list != NULL) {
next = list->next;
- if (list->first)
- git__free((char *) list->entry->name);
git__free((char *) list->entry->value);
git__free(list->entry);
git__free(list);
@@ -127,40 +133,42 @@ void git_config_entries_free(git_config_entries *entries)
int git_config_entries_append(git_config_entries *entries, git_config_entry *entry)
{
- config_entry_list *existing, *head;
-
- head = git__calloc(1, sizeof(config_entry_list));
- GIT_ERROR_CHECK_ALLOC(head);
- head->entry = entry;
-
- /*
- * This is a micro-optimization for configuration files
- * with a lot of same keys. As for multivars the entry's
- * key will be the same for all entries, we can just free
- * all except the first entry's name and just re-use it.
- */
- if ((existing = git_strmap_get(entries->map, entry->name)) != NULL) {
+ config_entry_list *list_head;
+ config_entry_map_head *map_head;
+
+ if ((map_head = git_strmap_get(entries->map, entry->name)) != NULL) {
+ map_head->multivar = true;
+ /*
+ * This is a micro-optimization for configuration files
+ * with a lot of same keys. As for multivars the entry's
+ * key will be the same for all entries, we can just free
+ * all except the first entry's name and just re-use it.
+ */
git__free((char *) entry->name);
- entry->name = existing->entry->name;
+ entry->name = map_head->entry->name;
} else {
- head->first = 1;
+ map_head = git__calloc(1, sizeof(*map_head));
+ if ((git_strmap_set(entries->map, entry->name, map_head)) < 0)
+ return -1;
}
+ map_head->entry = entry;
+
+ list_head = git__calloc(1, sizeof(config_entry_list));
+ GIT_ERROR_CHECK_ALLOC(list_head);
+ list_head->entry = entry;
if (entries->list)
- entries->list->last->next = head;
+ entries->list->last->next = list_head;
else
- entries->list = head;
- entries->list->last = head;
-
- if (git_strmap_set(entries->map, entry->name, head) < 0)
- return -1;
+ entries->list = list_head;
+ entries->list->last = list_head;
return 0;
}
int git_config_entries_get(git_config_entry **out, git_config_entries *entries, const char *key)
{
- config_entry_list *entry;
+ config_entry_map_head *entry;
if ((entry = git_strmap_get(entries->map, key)) == NULL)
return GIT_ENOTFOUND;
*out = entry->entry;
@@ -169,12 +177,12 @@ int git_config_entries_get(git_config_entry **out, git_config_entries *entries,
int git_config_entries_get_unique(git_config_entry **out, git_config_entries *entries, const char *key)
{
- config_entry_list *entry;
+ config_entry_map_head *entry;
if ((entry = git_strmap_get(entries->map, key)) == NULL)
return GIT_ENOTFOUND;
- if (!entry->first) {
+ if (entry->multivar) {
git_error_set(GIT_ERROR_CONFIG, "entry is not unique due to being a multivar");
return -1;
}
diff --git a/src/config_file.c b/src/config_file.c
index c9e3649..5267beb 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -111,6 +111,15 @@ static int config_file_open(git_config_backend *cfg, git_config_level_t level, c
if (!git_path_exists(b->file.path))
return 0;
+ /*
+ * git silently ignores configuration files that are not
+ * readable. We emulate that behavior. This is particularly
+ * important for sandboxed applications on macOS where the
+ * git configuration files may not be readable.
+ */
+ if (p_access(b->file.path, R_OK) < 0)
+ return GIT_ENOTFOUND;
+
if (res < 0 || (res = config_file_read(b->entries, repo, &b->file, level, 0)) < 0) {
git_config_entries_free(b->entries);
b->entries = NULL;
@@ -155,23 +164,27 @@ out:
return error;
}
+static void config_file_clear_includes(config_file_backend* cfg)
+{
+ config_file *include;
+ uint32_t i;
+
+ git_array_foreach(cfg->file.includes, i, include)
+ config_file_clear(include);
+ git_array_clear(cfg->file.includes);
+}
+
static int config_file_set_entries(git_config_backend *cfg, git_config_entries *entries)
{
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
git_config_entries *old = NULL;
- config_file *include;
int error;
- uint32_t i;
if (b->parent.readonly) {
git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
return -1;
}
- git_array_foreach(b->file.includes, i, include)
- config_file_clear(include);
- git_array_clear(b->file.includes);
-
if ((error = git_mutex_lock(&b->values_mutex)) < 0) {
git_error_set(GIT_ERROR_OS, "failed to lock config backend");
goto out;
@@ -193,6 +206,8 @@ static int config_file_refresh_from_buffer(git_config_backend *cfg, const char *
git_config_entries *entries = NULL;
int error;
+ config_file_clear_includes(b);
+
if ((error = git_config_entries_new(&entries)) < 0 ||
(error = config_file_read_buffer(entries, b->repo, &b->file,
b->level, 0, buf, buflen)) < 0 ||
@@ -220,6 +235,8 @@ static int config_file_refresh(git_config_backend *cfg)
if (!modified)
return 0;
+ config_file_clear_includes(b);
+
if ((error = git_config_entries_new(&entries)) < 0 ||
(error = config_file_read(entries, b->repo, &b->file, b->level, 0)) < 0 ||
(error = config_file_set_entries(cfg, entries)) < 0)
@@ -356,7 +373,7 @@ static int config_file_set_multivar(
int result;
char *key;
- assert(regexp);
+ GIT_ASSERT_ARG(regexp);
if ((result = git_config__normalize_name(name, &key)) < 0)
return result;
@@ -522,7 +539,7 @@ static char *escape_value(const char *ptr)
size_t len;
const char *esc;
- assert(ptr);
+ GIT_ASSERT_ARG_WITH_RETVAL(ptr, NULL);
len = strlen(ptr);
if (!len)
diff --git a/src/config_parse.c b/src/config_parse.c
index 48ad116..a2d779b 100644
--- a/src/config_parse.c
+++ b/src/config_parse.c
@@ -7,8 +7,6 @@
#include "config_parse.h"
-#include "buf_text.h"
-
#include <ctype.h>
const char *git_config_escapes = "ntb\"\\";
@@ -187,7 +185,7 @@ static int parse_section_header(git_config_parser *reader, char **section_out)
/* Make sure we were given a section header */
c = line[pos++];
- assert(c == '[');
+ GIT_ASSERT(c == '[');
c = line[pos++];
@@ -230,10 +228,10 @@ fail_parse:
static int skip_bom(git_parse_ctx *parser)
{
git_buf buf = GIT_BUF_INIT_CONST(parser->content, parser->content_len);
- git_bom_t bom;
- int bom_offset = git_buf_text_detect_bom(&bom, &buf);
+ git_buf_bom_t bom;
+ int bom_offset = git_buf_detect_bom(&bom, &buf);
- if (bom == GIT_BOM_UTF8)
+ if (bom == GIT_BUF_BOM_UTF8)
git_parse_advance_chars(parser, bom_offset);
/* TODO: reference implementation is pretty stupid with BoM */
@@ -451,7 +449,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var
git_buf_attach(&multi_value, value, 0);
value = NULL;
- if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 ||
+ if (parse_multiline_variable(reader, &multi_value, quote_count % 2) < 0 ||
git_buf_oom(&multi_value)) {
error = -1;
git_buf_dispose(&multi_value);
diff --git a/src/config_snapshot.c b/src/config_snapshot.c
index 62b9068..e295d2f 100644
--- a/src/config_snapshot.c
+++ b/src/config_snapshot.c
@@ -5,8 +5,9 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "config.h"
+#include "config_backend.h"
+#include "config.h"
#include "config_entries.h"
typedef struct {
diff --git a/src/crlf.c b/src/crlf.c
index 81b5216..1de9d8c 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -15,7 +15,6 @@
#include "futils.h"
#include "hash.h"
#include "filter.h"
-#include "buf_text.h"
#include "repository.h"
typedef enum {
@@ -219,7 +218,7 @@ static int crlf_apply_to_odb(
if (ca->crlf_action == GIT_CRLF_BINARY || !git_buf_len(from))
return GIT_PASSTHROUGH;
- is_binary = git_buf_text_gather_stats(&stats, from, false);
+ is_binary = git_buf_gather_text_stats(&stats, from, false);
/* Heuristics to see if we can skip the conversion.
* Straight from Core Git.
@@ -247,7 +246,7 @@ static int crlf_apply_to_odb(
return GIT_PASSTHROUGH;
/* Actually drop the carriage returns */
- return git_buf_text_crlf_to_lf(to, from);
+ return git_buf_crlf_to_lf(to, from);
}
static int crlf_apply_to_workdir(
@@ -262,7 +261,7 @@ static int crlf_apply_to_workdir(
if (git_buf_len(from) == 0 || output_eol(ca) != GIT_EOL_CRLF)
return GIT_PASSTHROUGH;
- is_binary = git_buf_text_gather_stats(&stats, from, false);
+ is_binary = git_buf_gather_text_stats(&stats, from, false);
/* If there are no LFs, or all LFs are part of a CRLF, nothing to do */
if (stats.lf == 0 || stats.lf == stats.crlf)
@@ -281,7 +280,7 @@ static int crlf_apply_to_workdir(
return GIT_PASSTHROUGH;
}
- return git_buf_text_lf_to_crlf(to, from);
+ return git_buf_lf_to_crlf(to, from);
}
static int convert_attrs(
diff --git a/src/date.c b/src/date.c
index 0e1b31a..71bf631 100644
--- a/src/date.c
+++ b/src/date.c
@@ -204,7 +204,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
if (month > 0 && month < 13 && day > 0 && day < 32) {
struct tm check = *tm;
struct tm *r = (now_tm ? &check : tm);
- time_t specified;
+ git_time_t specified;
r->tm_mon = month - 1;
r->tm_mday = day;
@@ -881,7 +881,8 @@ int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date)
struct tm gmt;
time_t t;
- assert(out && date);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(date);
t = (time_t) (date->time + date->offset * 60);
diff --git a/src/delta.c b/src/delta.c
index 1ff7752..2d2c5fa 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -256,7 +256,7 @@ void git_delta_index_free(git_delta_index *index)
size_t git_delta_index_size(git_delta_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
return index->memsize;
}
diff --git a/src/describe.c b/src/describe.c
index 42e5848..3648cce 100644
--- a/src/describe.c
+++ b/src/describe.c
@@ -655,7 +655,8 @@ int git_describe_commit(
int error = -1;
git_describe_options normalized;
- assert(committish);
+ GIT_ASSERT_ARG(result);
+ GIT_ASSERT_ARG(committish);
data.result = git__calloc(1, sizeof(git_describe_result));
GIT_ERROR_CHECK_ALLOC(data.result);
@@ -685,7 +686,7 @@ int git_describe_commit(
get_name, &data)) < 0)
goto cleanup;
- if (git_oidmap_size(data.names) == 0 && !opts->show_commit_oid_as_fallback) {
+ if (git_oidmap_size(data.names) == 0 && !normalized.show_commit_oid_as_fallback) {
git_error_set(GIT_ERROR_DESCRIBE, "cannot describe - "
"no reference found, cannot describe anything.");
error = -1;
@@ -775,12 +776,14 @@ int git_describe_format(git_buf *out, const git_describe_result *result, const g
struct commit_name *name;
git_describe_format_options opts;
- assert(out && result);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(result);
GIT_ERROR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options");
normalize_format_options(&opts, given);
- git_buf_sanitize(out);
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
if (opts.always_use_long_format && opts.abbreviated_size == 0) {
@@ -876,10 +879,12 @@ int git_describe_options_init(git_describe_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_describe_init_options(git_describe_options *opts, unsigned int version)
{
return git_describe_options_init(opts, version);
}
+#endif
int git_describe_format_options_init(git_describe_format_options *opts, unsigned int version)
{
@@ -888,7 +893,9 @@ int git_describe_format_options_init(git_describe_format_options *opts, unsigned
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_describe_init_format_options(git_describe_format_options *opts, unsigned int version)
{
return git_describe_format_options_init(opts, version);
}
+#endif
diff --git a/src/diff.c b/src/diff.c
index 47f49d9..4085c5f 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -32,11 +32,6 @@ GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta)
return str;
}
-const char *git_diff_delta__path(const git_diff_delta *delta)
-{
- return diff_delta__path(delta);
-}
-
int git_diff_delta__cmp(const void *a, const void *b)
{
const git_diff_delta *da = a, *db = b;
@@ -82,7 +77,7 @@ void git_diff_addref(git_diff *diff)
size_t git_diff_num_deltas(const git_diff *diff)
{
- assert(diff);
+ GIT_ASSERT_ARG(diff);
return diff->deltas.length;
}
@@ -91,7 +86,7 @@ size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
size_t i, count = 0;
const git_diff_delta *delta;
- assert(diff);
+ GIT_ASSERT_ARG(diff);
git_vector_foreach(&diff->deltas, i, delta) {
count += (delta->status == type);
@@ -102,7 +97,7 @@ size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
const git_diff_delta *git_diff_get_delta(const git_diff *diff, size_t idx)
{
- assert(diff);
+ GIT_ASSERT_ARG_WITH_RETVAL(diff, NULL);
return git_vector_get(&diff->deltas, idx);
}
@@ -113,7 +108,7 @@ int git_diff_is_sorted_icase(const git_diff *diff)
int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
{
- assert(out);
+ GIT_ASSERT_ARG(out);
GIT_ERROR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
out->stat_calls = diff->perf.stat_calls;
out->oid_calculations = diff->perf.oid_calculations;
@@ -132,7 +127,7 @@ int git_diff_foreach(
git_diff_delta *delta;
size_t idx;
- assert(diff);
+ GIT_ASSERT_ARG(diff);
git_vector_foreach(&diff->deltas, idx, delta) {
git_patch *patch;
@@ -155,7 +150,7 @@ int git_diff_foreach(
return error;
}
-int git_diff_format_email__append_header_tobuf(
+static int diff_format_email_append_header_tobuf(
git_buf *out,
const git_oid *id,
const git_signature *author,
@@ -212,7 +207,7 @@ int git_diff_format_email__append_header_tobuf(
return error;
}
-int git_diff_format_email__append_patches_tobuf(
+static int diff_format_email_append_patches_tobuf(
git_buf *out,
git_diff *diff)
{
@@ -248,8 +243,9 @@ int git_diff_format_email(
size_t allocsize;
int error;
- assert(out && diff && opts);
- assert(opts->summary && opts->id && opts->author);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diff);
+ GIT_ASSERT_ARG(opts && opts->summary && opts->id && opts->author);
GIT_ERROR_CHECK_VERSION(opts,
GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION,
@@ -292,7 +288,7 @@ int git_diff_format_email(
strncpy(summary, opts->summary, offset);
}
- error = git_diff_format_email__append_header_tobuf(out,
+ error = diff_format_email_append_header_tobuf(out,
opts->id, opts->author, summary == NULL ? opts->summary : summary,
opts->body, opts->patch_no, opts->total_patches, ignore_marker);
@@ -305,7 +301,7 @@ int git_diff_format_email(
(error = git_diff_get_stats(&stats, diff)) < 0 ||
(error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 ||
(error = git_buf_putc(out, '\n')) < 0 ||
- (error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0)
+ (error = diff_format_email_append_patches_tobuf(out, diff)) < 0)
goto on_error;
error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n");
@@ -331,7 +327,9 @@ int git_diff_commit_as_email(
GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
int error;
- assert (out && repo && commit);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(commit);
opts.flags = flags;
opts.patch_no = patch_no;
@@ -357,10 +355,12 @@ int git_diff_options_init(git_diff_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_diff_init_options(git_diff_options *opts, unsigned int version)
{
return git_diff_options_init(opts, version);
}
+#endif
int git_diff_find_options_init(
git_diff_find_options *opts, unsigned int version)
@@ -370,11 +370,13 @@ int git_diff_find_options_init(
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_diff_find_init_options(
git_diff_find_options *opts, unsigned int version)
{
return git_diff_find_options_init(opts, version);
}
+#endif
int git_diff_format_email_options_init(
git_diff_format_email_options *opts, unsigned int version)
@@ -385,11 +387,13 @@ int git_diff_format_email_options_init(
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_diff_format_email_init_options(
git_diff_format_email_options *opts, unsigned int version)
{
return git_diff_format_email_options_init(opts, version);
}
+#endif
static int flush_hunk(git_oid *result, git_hash_ctx *ctx)
{
@@ -426,7 +430,7 @@ static void strip_spaces(git_buf *buf)
git_buf_truncate(buf, len);
}
-int git_diff_patchid_print_callback__to_buf(
+static int diff_patchid_print_callback_to_buf(
const git_diff_delta *delta,
const git_diff_hunk *hunk,
const git_diff_line *line,
@@ -485,7 +489,7 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt
if ((error = git_diff_print(diff,
GIT_DIFF_FORMAT_PATCH_ID,
- git_diff_patchid_print_callback__to_buf,
+ diff_patchid_print_callback_to_buf,
&args)) < 0)
goto out;
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 831d326..a3892d3 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -13,7 +13,6 @@
#include "diff.h"
#include "strmap.h"
#include "map.h"
-#include "buf_text.h"
#include "config.h"
#include "regexp.h"
#include "repository.h"
@@ -142,18 +141,23 @@ static int diff_driver_funcname(const git_config_entry *entry, void *payload)
static git_diff_driver_registry *git_repository_driver_registry(
git_repository *repo)
{
- if (!repo->diff_drivers) {
- git_diff_driver_registry *reg = git_diff_driver_registry_new();
- reg = git__compare_and_swap(&repo->diff_drivers, NULL, reg);
+ git_diff_driver_registry *reg = git_atomic_load(repo->diff_drivers), *newreg;
+ if (reg)
+ return reg;
- if (reg != NULL) /* if we race, free losing allocation */
- git_diff_driver_registry_free(reg);
- }
-
- if (!repo->diff_drivers)
+ newreg = git_diff_driver_registry_new();
+ if (!newreg) {
git_error_set(GIT_ERROR_REPOSITORY, "unable to create diff driver registry");
-
- return repo->diff_drivers;
+ return newreg;
+ }
+ reg = git_atomic_compare_and_swap(&repo->diff_drivers, NULL, newreg);
+ if (!reg) {
+ reg = newreg;
+ } else {
+ /* if we race, free losing allocation */
+ git_diff_driver_registry_free(newreg);
+ }
+ return reg;
}
static int diff_driver_alloc(
@@ -358,7 +362,7 @@ int git_diff_driver_lookup(
int error = 0;
const char *values[1], *attrs[] = { "diff" };
- assert(out);
+ GIT_ASSERT_ARG(out);
*out = NULL;
if (!repo || !path || !strlen(path))
@@ -390,13 +394,13 @@ int git_diff_driver_lookup(
void git_diff_driver_free(git_diff_driver *driver)
{
- size_t i;
+ git_diff_driver_pattern *pat;
if (!driver)
return;
- for (i = 0; i < git_array_size(driver->fn_patterns); ++i)
- git_regexp_dispose(& git_array_get(driver->fn_patterns, i)->re);
+ while ((pat = git_array_pop(driver->fn_patterns)) != NULL)
+ git_regexp_dispose(&pat->re);
git_array_clear(driver->fn_patterns);
git_regexp_dispose(&driver->word_pattern);
@@ -428,8 +432,8 @@ int git_diff_driver_content_is_binary(
* let's just use the simple NUL-byte detection that core git uses.
*/
- /* previously was: if (git_buf_text_is_binary(&search)) */
- if (git_buf_text_contains_nul(&search))
+ /* previously was: if (git_buf_is_binary(&search)) */
+ if (git_buf_contains_nul(&search))
return 1;
return 0;
diff --git a/src/diff_file.c b/src/diff_file.c
index 621bff5..eeaf4a5 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -160,8 +160,10 @@ int git_diff_file_content__init_from_src(
fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
} else {
+ int error;
+ if ((error = git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB)) < 0)
+ return error;
fc->file->size = src->buflen;
- git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB);
fc->file->id_abbrev = GIT_OID_HEXSZ;
fc->map.len = src->buflen;
@@ -360,10 +362,7 @@ static int diff_file_content_load_workdir_file(
if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
git_buf out = GIT_BUF_INIT;
- error = git_filter_list_apply_to_data(&out, fl, &raw);
-
- if (out.ptr != raw.ptr)
- git_buf_dispose(&raw);
+ error = git_filter_list__convert_buf(&out, fl, &raw);
if (!error) {
fc->map.len = out.size;
@@ -392,8 +391,7 @@ static int diff_file_content_load_workdir(
if (fc->file->mode == GIT_FILEMODE_TREE)
return 0;
- if (git_buf_joinpath(
- &path, git_repository_workdir(fc->repo), fc->file->path) < 0)
+ if (git_repository_workdir_path(&path, fc->repo, fc->file->path) < 0)
return -1;
if (S_ISLNK(fc->file->mode))
diff --git a/src/diff_generate.c b/src/diff_generate.c
index b69ef30..aba9e52 100644
--- a/src/diff_generate.c
+++ b/src/diff_generate.c
@@ -128,7 +128,7 @@ static int diff_delta__from_one(
git_diff_delta *delta;
const char *matched_pathspec;
- assert((oitem != NULL) ^ (nitem != NULL));
+ GIT_ASSERT_ARG((oitem != NULL) ^ (nitem != NULL));
if (oitem) {
entry = oitem;
@@ -160,7 +160,7 @@ static int diff_delta__from_one(
GIT_ERROR_CHECK_ALLOC(delta);
/* This fn is just for single-sided diffs */
- assert(status != GIT_DELTA_MODIFIED);
+ GIT_ASSERT(status != GIT_DELTA_MODIFIED);
delta->nfiles = 1;
if (has_old) {
@@ -301,14 +301,14 @@ GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta)
delta->old_file.path : delta->new_file.path;
}
-int git_diff_delta__i2w_cmp(const void *a, const void *b)
+static int diff_delta_i2w_cmp(const void *a, const void *b)
{
const git_diff_delta *da = a, *db = b;
int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db));
return val ? val : ((int)da->status - (int)db->status);
}
-int git_diff_delta__i2w_casecmp(const void *a, const void *b)
+static int diff_delta_i2w_casecmp(const void *a, const void *b)
{
const git_diff_delta *da = a, *db = b;
int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db));
@@ -361,7 +361,7 @@ static const char *diff_mnemonic_prefix(
return pfx;
}
-void git_diff__set_ignore_case(git_diff *diff, bool ignore_case)
+static void diff_set_ignore_case(git_diff *diff, bool ignore_case)
{
if (!ignore_case) {
diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE;
@@ -408,7 +408,9 @@ static git_diff_generated *diff_generated_alloc(
git_diff_generated *diff;
git_diff_options dflt = GIT_DIFF_OPTIONS_INIT;
- assert(repo && old_iter && new_iter);
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(old_iter, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(new_iter, NULL);
if ((diff = git__calloc(1, sizeof(git_diff_generated))) == NULL)
return NULL;
@@ -423,16 +425,15 @@ static git_diff_generated *diff_generated_alloc(
git_attr_session__init(&diff->base.attrsession, repo);
memcpy(&diff->base.opts, &dflt, sizeof(git_diff_options));
- git_pool_init(&diff->base.pool, 1);
-
- if (git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) {
+ if (git_pool_init(&diff->base.pool, 1) < 0 ||
+ git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) {
git_diff_free(&diff->base);
return NULL;
}
/* Use case-insensitive compare if either iterator has
* the ignore_case bit set */
- git_diff__set_ignore_case(
+ diff_set_ignore_case(
&diff->base,
git_iterator_ignore_case(old_iter) ||
git_iterator_ignore_case(new_iter));
@@ -590,13 +591,12 @@ int git_diff__oid_for_entry(
git_filter_list *fl = NULL;
int error = 0;
- assert(d->type == GIT_DIFF_TYPE_GENERATED);
+ GIT_ASSERT(d->type == GIT_DIFF_TYPE_GENERATED);
diff = (git_diff_generated *)d;
memset(out, 0, sizeof(*out));
- if (git_buf_joinpath(&full_path,
- git_repository_workdir(diff->base.repo), entry.path) < 0)
+ if (git_repository_workdir_path(&full_path, diff->base.repo, entry.path) < 0)
return -1;
if (!mode) {
@@ -679,6 +679,8 @@ typedef struct {
git_iterator *new_iter;
const git_index_entry *oitem;
const git_index_entry *nitem;
+ git_strmap *submodule_cache;
+ bool submodule_cache_initialized;
} diff_in_progress;
#define MODE_BITS_MASK 0000777
@@ -693,6 +695,7 @@ static int maybe_modified_submodule(
git_submodule *sub;
unsigned int sm_status = 0;
git_submodule_ignore_t ign = diff->base.opts.ignore_submodules;
+ git_strmap *submodule_cache = NULL;
*status = GIT_DELTA_UNMODIFIED;
@@ -700,8 +703,23 @@ static int maybe_modified_submodule(
ign == GIT_SUBMODULE_IGNORE_ALL)
return 0;
- if ((error = git_submodule_lookup(
- &sub, diff->base.repo, info->nitem->path)) < 0) {
+ if (diff->base.repo->submodule_cache != NULL) {
+ submodule_cache = diff->base.repo->submodule_cache;
+ } else {
+ if (!info->submodule_cache_initialized) {
+ info->submodule_cache_initialized = true;
+ /*
+ * Try to cache the submodule information to avoid having to parse it for
+ * every submodule. It is okay if it fails, the cache will still be NULL
+ * and the submodules will be attempted to be looked up individually.
+ */
+ git_submodule_cache_init(&info->submodule_cache, diff->base.repo);
+ }
+ submodule_cache = info->submodule_cache;
+ }
+
+ if ((error = git_submodule__lookup_with_cache(
+ &sub, diff->base.repo, info->nitem->path, submodule_cache)) < 0) {
/* GIT_EEXISTS means dir with .git in it was found - ignore it */
if (error == GIT_EEXISTS) {
@@ -1191,7 +1209,7 @@ int git_diff__from_iterators(
const git_diff_options *opts)
{
git_diff_generated *diff;
- diff_in_progress info;
+ diff_in_progress info = {0};
int error = 0;
*out = NULL;
@@ -1205,8 +1223,9 @@ int git_diff__from_iterators(
/* make iterators have matching icase behavior */
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE)) {
- git_iterator_set_ignore_case(old_iter, true);
- git_iterator_set_ignore_case(new_iter, true);
+ if ((error = git_iterator_set_ignore_case(old_iter, true)) < 0 ||
+ (error = git_iterator_set_ignore_case(new_iter, true)) < 0)
+ goto cleanup;
}
/* finish initialization */
@@ -1258,6 +1277,8 @@ cleanup:
*out = &diff->base;
else
git_diff_free(&diff->base);
+ if (info.submodule_cache)
+ git_submodule_cache_free(info.submodule_cache);
return error;
}
@@ -1303,7 +1324,8 @@ int git_diff_tree_to_tree(
char *prefix = NULL;
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -1359,7 +1381,8 @@ int git_diff_tree_to_index(
bool index_ignore_case = false;
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -1376,7 +1399,7 @@ int git_diff_tree_to_index(
/* if index is in case-insensitive order, re-sort deltas to match */
if (index_ignore_case)
- git_diff__set_ignore_case(diff, true);
+ diff_set_ignore_case(diff, true);
*out = diff;
diff = NULL;
@@ -1402,7 +1425,8 @@ int git_diff_index_to_workdir(
char *prefix = NULL;
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -1445,7 +1469,8 @@ int git_diff_tree_to_workdir(
git_index *index;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -1478,7 +1503,8 @@ int git_diff_tree_to_workdir_with_index(
git_index *index = NULL;
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -1514,7 +1540,9 @@ int git_diff_index_to_index(
char *prefix = NULL;
int error;
- assert(out && old_index && new_index);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(old_index);
+ GIT_ASSERT_ARG(new_index);
*out = NULL;
@@ -1527,7 +1555,7 @@ int git_diff_index_to_index(
/* if index is in case-insensitive order, re-sort deltas to match */
if (old_index->ignore_case || new_index->ignore_case)
- git_diff__set_ignore_case(diff, true);
+ diff_set_ignore_case(diff, true);
*out = diff;
diff = NULL;
@@ -1584,10 +1612,10 @@ int git_diff__paired_foreach(
if (i2w_icase && !icase_mismatch) {
strcomp = git__strcasecmp;
- git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp);
+ git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_casecmp);
git_vector_sort(&idx2wd->deltas);
} else if (idx2wd != NULL) {
- git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp);
+ git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_cmp);
git_vector_sort(&idx2wd->deltas);
}
diff --git a/src/diff_parse.c b/src/diff_parse.c
index 098e56f..75e41a5 100644
--- a/src/diff_parse.c
+++ b/src/diff_parse.c
@@ -52,9 +52,8 @@ static git_diff_parsed *diff_parsed_alloc(void)
diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE;
- git_pool_init(&diff->base.pool, 1);
-
- if (git_vector_init(&diff->patches, 0, NULL) < 0 ||
+ if (git_pool_init(&diff->base.pool, 1) < 0 ||
+ git_vector_init(&diff->patches, 0, NULL) < 0 ||
git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) {
git_diff_free(&diff->base);
return NULL;
diff --git a/src/diff_print.c b/src/diff_print.c
index 369e5c1..062e267 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -95,7 +95,7 @@ static int diff_print_info_init_frompatch(
git_diff_line_cb cb,
void *payload)
{
- assert(patch);
+ GIT_ASSERT_ARG(patch);
memset(pi, 0, sizeof(diff_print_info));
@@ -337,7 +337,7 @@ static int diff_delta_format_with_paths(
return git_buf_printf(out, template, oldpath, newpath);
}
-int diff_delta_format_similarity_header(
+static int diff_delta_format_similarity_header(
git_buf *out,
const git_diff_delta *delta)
{
@@ -351,17 +351,16 @@ int diff_delta_format_similarity_header(
goto done;
}
+ GIT_ASSERT(delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED);
if (delta->status == GIT_DELTA_RENAMED)
type = "rename";
- else if (delta->status == GIT_DELTA_COPIED)
- type = "copy";
else
- abort();
+ type = "copy";
if ((error = git_buf_puts(&old_path, delta->old_file.path)) < 0 ||
- (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
- (error = git_buf_quote(&old_path)) < 0 ||
- (error = git_buf_quote(&new_path)) < 0)
+ (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
+ (error = git_buf_quote(&old_path)) < 0 ||
+ (error = git_buf_quote(&new_path)) < 0)
goto done;
git_buf_printf(out,
@@ -428,8 +427,11 @@ int git_diff_delta__format_file_header(
git_buf_printf(out, "diff --git %s %s\n",
old_path.ptr, new_path.ptr);
+ if (unchanged && delta->old_file.mode != delta->new_file.mode)
+ diff_print_modes(out, delta);
+
if (delta->status == GIT_DELTA_RENAMED ||
- (delta->status == GIT_DELTA_COPIED && unchanged)) {
+ (delta->status == GIT_DELTA_COPIED && unchanged)) {
if ((error = diff_delta_format_similarity_header(out, delta)) < 0)
goto done;
}
@@ -444,9 +446,6 @@ int git_diff_delta__format_file_header(
"--- %s\n+++ %s\n", old_path.ptr, new_path.ptr);
}
- if (unchanged && delta->old_file.mode != delta->new_file.mode)
- diff_print_modes(out, delta);
-
if (git_buf_oom(out))
error = -1;
@@ -492,6 +491,9 @@ static int format_binary(
}
git_buf_putc(pi->buf, '\n');
+ if (git_buf_oom(pi->buf))
+ return -1;
+
return 0;
}
@@ -502,21 +504,17 @@ static int diff_print_patch_file_binary_noshow(
git_buf old_path = GIT_BUF_INIT, new_path = GIT_BUF_INIT;
int error;
- if ((error = diff_delta_format_path(
- &old_path, old_pfx, delta->old_file.path)) < 0 ||
- (error = diff_delta_format_path(
- &new_path, new_pfx, delta->new_file.path)) < 0)
+ if ((error = diff_delta_format_path(&old_path, old_pfx, delta->old_file.path)) < 0 ||
+ (error = diff_delta_format_path(&new_path, new_pfx, delta->new_file.path)) < 0 ||
+ (error = diff_delta_format_with_paths(pi->buf, delta, "Binary files %s and %s differ\n",
+ old_path.ptr, new_path.ptr)) < 0)
goto done;
pi->line.num_lines = 1;
- error = diff_delta_format_with_paths(
- pi->buf, delta, "Binary files %s and %s differ\n",
- old_path.ptr, new_path.ptr);
done:
git_buf_dispose(&old_path);
git_buf_dispose(&new_path);
-
return error;
}
@@ -540,10 +538,9 @@ static int diff_print_patch_file_binary(
pi->line.num_lines++;
if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data,
- binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
- (error = format_binary(pi, binary->old_file.type, binary->old_file.data,
- binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
-
+ binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
+ (error = format_binary(pi, binary->old_file.type, binary->old_file.data,
+ binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
if (error == GIT_EBUFS) {
git_error_clear();
git_buf_truncate(pi->buf, pre_binary_size);
@@ -580,16 +577,15 @@ static int diff_print_patch_file(
GIT_UNUSED(progress);
if (S_ISDIR(delta->new_file.mode) ||
- delta->status == GIT_DELTA_UNMODIFIED ||
- delta->status == GIT_DELTA_IGNORED ||
- delta->status == GIT_DELTA_UNREADABLE ||
- (delta->status == GIT_DELTA_UNTRACKED &&
+ delta->status == GIT_DELTA_UNMODIFIED ||
+ delta->status == GIT_DELTA_IGNORED ||
+ delta->status == GIT_DELTA_UNREADABLE ||
+ (delta->status == GIT_DELTA_UNTRACKED &&
(pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0))
return 0;
- if ((error = git_diff_delta__format_file_header(
- pi->buf, delta, oldpfx, newpfx,
- id_strlen, print_index)) < 0)
+ if ((error = git_diff_delta__format_file_header(pi->buf, delta, oldpfx, newpfx,
+ id_strlen, print_index)) < 0)
return error;
pi->line.origin = GIT_DIFF_LINE_FILE_HDR;
@@ -699,17 +695,16 @@ int git_diff_print(
return -1;
}
- if (!(error = diff_print_info_init_fromdiff(
- &pi, &buf, diff, format, print_cb, payload))) {
- error = git_diff_foreach(
- diff, print_file, print_binary, print_hunk, print_line, &pi);
+ if ((error = diff_print_info_init_fromdiff(&pi, &buf, diff, format, print_cb, payload)) < 0)
+ goto out;
- if (error) /* make sure error message is set */
- git_error_set_after_callback_function(error, "git_diff_print");
+ if ((error = git_diff_foreach(diff, print_file, print_binary, print_hunk, print_line, &pi)) != 0) {
+ git_error_set_after_callback_function(error, "git_diff_print");
+ goto out;
}
+out:
git_buf_dispose(&buf);
-
return error;
}
@@ -728,8 +723,8 @@ int git_diff_print_callback__to_buf(
}
if (line->origin == GIT_DIFF_LINE_ADDITION ||
- line->origin == GIT_DIFF_LINE_DELETION ||
- line->origin == GIT_DIFF_LINE_CONTEXT)
+ line->origin == GIT_DIFF_LINE_DELETION ||
+ line->origin == GIT_DIFF_LINE_CONTEXT)
git_buf_putc(output, line->origin);
return git_buf_put(output, line->content, line->content_len);
@@ -742,24 +737,42 @@ int git_diff_print_callback__to_file_handle(
void *payload)
{
FILE *fp = payload ? payload : stdout;
+ int error;
- GIT_UNUSED(delta); GIT_UNUSED(hunk);
+ GIT_UNUSED(delta);
+ GIT_UNUSED(hunk);
if (line->origin == GIT_DIFF_LINE_CONTEXT ||
- line->origin == GIT_DIFF_LINE_ADDITION ||
- line->origin == GIT_DIFF_LINE_DELETION)
- fputc(line->origin, fp);
- fwrite(line->content, 1, line->content_len, fp);
+ line->origin == GIT_DIFF_LINE_ADDITION ||
+ line->origin == GIT_DIFF_LINE_DELETION) {
+ while ((error = fputc(line->origin, fp)) == EINTR)
+ continue;
+ if (error) {
+ git_error_set(GIT_ERROR_OS, "could not write status");
+ return -1;
+ }
+ }
+
+ if (fwrite(line->content, line->content_len, 1, fp) != 1) {
+ git_error_set(GIT_ERROR_OS, "could not write line");
+ return -1;
+ }
+
return 0;
}
/* print a git_diff to a git_buf */
int git_diff_to_buf(git_buf *out, git_diff *diff, git_diff_format_t format)
{
- assert(out && diff);
- git_buf_sanitize(out);
- return git_diff_print(
- diff, format, git_diff_print_callback__to_buf, out);
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diff);
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
+
+ return git_diff_print(diff, format, git_diff_print_callback__to_buf, out);
}
/* print a git_patch to an output callback */
@@ -768,35 +781,38 @@ int git_patch_print(
git_diff_line_cb print_cb,
void *payload)
{
- int error;
git_buf temp = GIT_BUF_INIT;
diff_print_info pi;
+ int error;
- assert(patch && print_cb);
+ GIT_ASSERT_ARG(patch);
+ GIT_ASSERT_ARG(print_cb);
- if (!(error = diff_print_info_init_frompatch(
- &pi, &temp, patch,
- GIT_DIFF_FORMAT_PATCH, print_cb, payload)))
- {
- error = git_patch__invoke_callbacks(
- patch,
- diff_print_patch_file, diff_print_patch_binary,
- diff_print_patch_hunk, diff_print_patch_line,
- &pi);
+ if ((error = diff_print_info_init_frompatch(&pi, &temp, patch,
+ GIT_DIFF_FORMAT_PATCH, print_cb, payload)) < 0)
+ goto out;
- if (error) /* make sure error message is set */
- git_error_set_after_callback_function(error, "git_patch_print");
+ if ((error = git_patch__invoke_callbacks(patch, diff_print_patch_file, diff_print_patch_binary,
+ diff_print_patch_hunk, diff_print_patch_line, &pi)) < 0) {
+ git_error_set_after_callback_function(error, "git_patch_print");
+ goto out;
}
+out:
git_buf_dispose(&temp);
-
return error;
}
/* print a git_patch to a git_buf */
int git_patch_to_buf(git_buf *out, git_patch *patch)
{
- assert(out && patch);
- git_buf_sanitize(out);
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(patch);
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
+
return git_patch_print(patch, git_diff_print_callback__to_buf, out);
}
diff --git a/src/diff_stats.c b/src/diff_stats.c
index 19c9da0..41a25bf 100644
--- a/src/diff_stats.c
+++ b/src/diff_stats.c
@@ -46,14 +46,14 @@ static int digits_for_value(size_t val)
return count;
}
-int git_diff_file_stats__full_to_buf(
+static int diff_file_stats_full_to_buf(
git_buf *out,
const git_diff_delta *delta,
const diff_file_stats *filestat,
const git_diff_stats *stats,
size_t width)
{
- const char *old_path = NULL, *new_path = NULL;
+ const char *old_path = NULL, *new_path = NULL, *adddel_path = NULL;
size_t padding;
git_object_size_t old_size, new_size;
@@ -62,7 +62,7 @@ int git_diff_file_stats__full_to_buf(
old_size = delta->old_file.size;
new_size = delta->new_file.size;
- if (strcmp(old_path, new_path) != 0) {
+ if (old_path && new_path && strcmp(old_path, new_path) != 0) {
size_t common_dirlen;
int error;
@@ -82,10 +82,11 @@ int git_diff_file_stats__full_to_buf(
if (error < 0)
goto on_error;
} else {
- if (git_buf_printf(out, " %s", old_path) < 0)
+ adddel_path = new_path ? new_path : old_path;
+ if (git_buf_printf(out, " %s", adddel_path) < 0)
goto on_error;
- padding = stats->max_name - strlen(old_path);
+ padding = stats->max_name - strlen(adddel_path);
if (stats->renames > 0)
padding += strlen(DIFF_RENAME_FILE_SEPARATOR);
@@ -134,7 +135,7 @@ on_error:
return (git_buf_oom(out) ? -1 : 0);
}
-int git_diff_file_stats__number_to_buf(
+static int diff_file_stats_number_to_buf(
git_buf *out,
const git_diff_delta *delta,
const diff_file_stats *filestats)
@@ -151,7 +152,7 @@ int git_diff_file_stats__number_to_buf(
return error;
}
-int git_diff_file_stats__summary_to_buf(
+static int diff_file_stats_summary_to_buf(
git_buf *out,
const git_diff_delta *delta)
{
@@ -182,7 +183,8 @@ int git_diff_get_stats(
git_diff_stats *stats = NULL;
int error = 0;
- assert(out && diff);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diff);
stats = git__calloc(1, sizeof(git_diff_stats));
GIT_ERROR_CHECK_ALLOC(stats);
@@ -211,7 +213,7 @@ int git_diff_get_stats(
/* TODO ugh */
namelen = strlen(delta->new_file.path);
- if (strcmp(delta->old_file.path, delta->new_file.path) != 0) {
+ if (delta->old_file.path && strcmp(delta->old_file.path, delta->new_file.path) != 0) {
namelen += strlen(delta->old_file.path);
stats->renames++;
}
@@ -250,7 +252,7 @@ int git_diff_get_stats(
size_t git_diff_stats_files_changed(
const git_diff_stats *stats)
{
- assert(stats);
+ GIT_ASSERT_ARG(stats);
return stats->files_changed;
}
@@ -258,7 +260,7 @@ size_t git_diff_stats_files_changed(
size_t git_diff_stats_insertions(
const git_diff_stats *stats)
{
- assert(stats);
+ GIT_ASSERT_ARG(stats);
return stats->insertions;
}
@@ -266,7 +268,7 @@ size_t git_diff_stats_insertions(
size_t git_diff_stats_deletions(
const git_diff_stats *stats)
{
- assert(stats);
+ GIT_ASSERT_ARG(stats);
return stats->deletions;
}
@@ -281,14 +283,15 @@ int git_diff_stats_to_buf(
size_t i;
const git_diff_delta *delta;
- assert(out && stats);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(stats);
if (format & GIT_DIFF_STATS_NUMBER) {
for (i = 0; i < stats->files_changed; ++i) {
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
continue;
- error = git_diff_file_stats__number_to_buf(
+ error = diff_file_stats_number_to_buf(
out, delta, &stats->filestats[i]);
if (error < 0)
return error;
@@ -309,7 +312,7 @@ int git_diff_stats_to_buf(
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
continue;
- error = git_diff_file_stats__full_to_buf(
+ error = diff_file_stats_full_to_buf(
out, delta, &stats->filestats[i], stats, width);
if (error < 0)
return error;
@@ -342,7 +345,7 @@ int git_diff_stats_to_buf(
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
continue;
- error = git_diff_file_stats__summary_to_buf(out, delta);
+ error = diff_file_stats_summary_to_buf(out, delta);
if (error < 0)
return error;
}
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 437144a..908175d 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -87,7 +87,7 @@ git_diff_delta *git_diff__merge_like_cgit(
a->status == GIT_DELTA_UNREADABLE)
return dup;
- assert(b->status != GIT_DELTA_UNMODIFIED);
+ GIT_ASSERT_WITH_RETVAL(b->status != GIT_DELTA_UNMODIFIED, NULL);
/* A cgit exception is that the diff of a file that is only in the
* index (i.e. not in HEAD nor workdir) is given as empty.
@@ -121,7 +121,8 @@ int git_diff__merge(
bool ignore_case, reversed;
unsigned int i, j;
- assert(onto && from);
+ GIT_ASSERT_ARG(onto);
+ GIT_ASSERT_ARG(from);
if (!from->deltas.length)
return 0;
@@ -136,11 +137,10 @@ int git_diff__merge(
return -1;
}
- if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0)
+ if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0 ||
+ git_pool_init(&onto_pool, 1) < 0)
return -1;
- git_pool_init(&onto_pool, 1);
-
for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) {
git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i);
const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j);
@@ -476,8 +476,8 @@ static int similarity_sig(
git_diff_file *file = info->file;
if (info->src == GIT_ITERATOR_WORKDIR) {
- if ((error = git_buf_joinpath(
- &info->data, git_repository_workdir(info->repo), file->path)) < 0)
+ if ((error = git_repository_workdir_path(
+ &info->data, info->repo, file->path)) < 0)
return error;
/* if path is not a regular file, just skip this item */
@@ -816,7 +816,7 @@ int git_diff_find_similar(
diff_find_match *best_match;
git_diff_file swap;
- assert(diff);
+ GIT_ASSERT_ARG(diff);
if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0)
return error;
@@ -979,7 +979,7 @@ find_best_matches:
src->flags |= GIT_DIFF_FLAG__TO_DELETE;
num_rewrites++;
} else {
- assert(delta_is_split(tgt));
+ GIT_ASSERT(delta_is_split(tgt));
if (best_match->similarity < opts.rename_from_rewrite_threshold)
continue;
@@ -989,7 +989,7 @@ find_best_matches:
delta_make_rename(tgt, src, best_match->similarity);
num_rewrites--;
- assert(src->status == GIT_DELTA_DELETED);
+ GIT_ASSERT(src->status == GIT_DELTA_DELETED);
memcpy(&src->old_file, &swap, sizeof(src->old_file));
memset(&src->new_file, 0, sizeof(src->new_file));
src->new_file.path = src->old_file.path;
@@ -1025,7 +1025,7 @@ find_best_matches:
num_updates++;
} else {
- assert(delta_is_split(src));
+ GIT_ASSERT(delta_is_split(src));
if (best_match->similarity < opts.rename_from_rewrite_threshold)
continue;
@@ -1039,7 +1039,7 @@ find_best_matches:
memcpy(&src->old_file, &swap, sizeof(src->old_file));
/* if we've just swapped the new element into the correct
- * place, clear the SPLIT flag
+ * place, clear the SPLIT and RENAME_TARGET flags
*/
if (tgt2src[s].idx == t &&
tgt2src[s].similarity >
@@ -1047,7 +1047,7 @@ find_best_matches:
src->status = GIT_DELTA_RENAMED;
src->similarity = tgt2src[s].similarity;
tgt2src[s].similarity = 0;
- src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
+ src->flags &= ~(GIT_DIFF_FLAG__TO_SPLIT | GIT_DIFF_FLAG__IS_RENAME_TARGET);
num_rewrites--;
}
/* otherwise, if we just overwrote a source, update mapping */
diff --git a/src/diff_xdiff.c b/src/diff_xdiff.c
index c4668fa..278e2be 100644
--- a/src/diff_xdiff.c
+++ b/src/diff_xdiff.c
@@ -6,7 +6,6 @@
*/
#include "diff_xdiff.h"
-#include "util.h"
#include "git2/errors.h"
#include "diff.h"
@@ -128,7 +127,7 @@ static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len)
info->hunk.header_len = sizeof(info->hunk.header) - 1;
/* Sanitize the hunk header in case there is invalid Unicode */
- buffer_len = git__utf8_valid_buf_length((const uint8_t *) bufs[0].ptr, info->hunk.header_len);
+ buffer_len = git_utf8_valid_buf_length(bufs[0].ptr, info->hunk.header_len);
/* Sanitizing the hunk header may delete the newline, so add it back again if there is room */
if (buffer_len < info->hunk.header_len) {
bufs[0].ptr[buffer_len] = '\n';
@@ -259,5 +258,8 @@ void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts)
if (flags & GIT_DIFF_MINIMAL)
xo->params.flags |= XDF_NEED_MINIMAL;
+ if (flags & GIT_DIFF_IGNORE_BLANK_LINES)
+ xo->params.flags |= XDF_IGNORE_BLANK_LINES;
+
xo->callback.outf = git_xdiff_cb;
}
diff --git a/src/diff_xdiff.h b/src/diff_xdiff.h
index aca80b1..9b303e9 100644
--- a/src/diff_xdiff.h
+++ b/src/diff_xdiff.h
@@ -16,7 +16,7 @@
/* xdiff cannot cope with large files. these files should not be passed to
* xdiff. callers should treat these large files as binary.
*/
-#define GIT_XDIFF_MAX_SIZE (1024LL * 1024 * 1023)
+#define GIT_XDIFF_MAX_SIZE (INT64_C(1024) * 1024 * 1023)
/* A git_xdiff_output is a git_patch_generate_output with extra fields
* necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
diff --git a/src/errors.c b/src/errors.c
index b34aa3a..3d1d1c9 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -7,9 +7,10 @@
#include "common.h"
-#include "global.h"
+#include "threadstate.h"
#include "posix.h"
#include "buffer.h"
+#include "libgit2.h"
/********************************************
* New error handling
@@ -20,20 +21,25 @@ static git_error g_git_oom_error = {
GIT_ERROR_NOMEMORY
};
+static git_error g_git_uninitialized_error = {
+ "libgit2 has not been initialized; you must call git_libgit2_init",
+ GIT_ERROR_INVALID
+};
+
static void set_error_from_buffer(int error_class)
{
- git_error *error = &GIT_GLOBAL->error_t;
- git_buf *buf = &GIT_GLOBAL->error_buf;
+ git_error *error = &GIT_THREADSTATE->error_t;
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
error->message = buf->ptr;
error->klass = error_class;
- GIT_GLOBAL->last_error = error;
+ GIT_THREADSTATE->last_error = error;
}
static void set_error(int error_class, char *string)
{
- git_buf *buf = &GIT_GLOBAL->error_buf;
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
git_buf_clear(buf);
if (string) {
@@ -46,7 +52,7 @@ static void set_error(int error_class, char *string)
void git_error_set_oom(void)
{
- GIT_GLOBAL->last_error = &g_git_oom_error;
+ GIT_THREADSTATE->last_error = &g_git_oom_error;
}
void git_error_set(int error_class, const char *fmt, ...)
@@ -64,7 +70,7 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0;
#endif
int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
- git_buf *buf = &GIT_GLOBAL->error_buf;
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
git_buf_clear(buf);
if (fmt) {
@@ -97,9 +103,9 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
int git_error_set_str(int error_class, const char *string)
{
- git_buf *buf = &GIT_GLOBAL->error_buf;
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
- assert(string);
+ GIT_ASSERT_ARG(string);
if (!string) {
git_error_set(GIT_ERROR_INVALID, "unspecified caller error");
@@ -118,9 +124,9 @@ int git_error_set_str(int error_class, const char *string)
void git_error_clear(void)
{
- if (GIT_GLOBAL->last_error != NULL) {
+ if (GIT_THREADSTATE->last_error != NULL) {
set_error(0, NULL);
- GIT_GLOBAL->last_error = NULL;
+ GIT_THREADSTATE->last_error = NULL;
}
errno = 0;
@@ -131,13 +137,17 @@ void git_error_clear(void)
const git_error *git_error_last(void)
{
- return GIT_GLOBAL->last_error;
+ /* If the library is not initialized, return a static error. */
+ if (!git_libgit2_init_count())
+ return &g_git_uninitialized_error;
+
+ return GIT_THREADSTATE->last_error;
}
int git_error_state_capture(git_error_state *state, int error_code)
{
- git_error *error = GIT_GLOBAL->last_error;
- git_buf *error_buf = &GIT_GLOBAL->error_buf;
+ git_error *error = GIT_THREADSTATE->last_error;
+ git_buf *error_buf = &GIT_THREADSTATE->error_buf;
memset(state, 0, sizeof(git_error_state));
@@ -210,6 +220,7 @@ void git_error_system_set(int code)
/* Deprecated error values and functions */
+#ifndef GIT_DEPRECATE_HARD
const git_error *giterr_last(void)
{
return git_error_last();
@@ -229,3 +240,4 @@ void giterr_set_oom(void)
{
git_error_set_oom();
}
+#endif
diff --git a/src/features.h.in b/src/features.h.in
index e000de5..202cef4 100644
--- a/src/features.h.in
+++ b/src/features.h.in
@@ -2,9 +2,12 @@
#define INCLUDE_features_h__
#cmakedefine GIT_DEBUG_POOL 1
+#cmakedefine GIT_DEBUG_STRICT_ALLOC 1
+#cmakedefine GIT_DEBUG_STRICT_OPEN 1
+
#cmakedefine GIT_TRACE 1
#cmakedefine GIT_THREADS 1
-#cmakedefine GIT_MSVC_CRTDBG 1
+#cmakedefine GIT_WIN32_LEAKCHECK 1
#cmakedefine GIT_ARCH_64 1
#cmakedefine GIT_ARCH_32 1
@@ -32,6 +35,7 @@
#cmakedefine GIT_WINHTTP 1
#cmakedefine GIT_HTTPS 1
#cmakedefine GIT_OPENSSL 1
+#cmakedefine GIT_OPENSSL_DYNAMIC 1
#cmakedefine GIT_SECURE_TRANSPORT 1
#cmakedefine GIT_MBEDTLS 1
diff --git a/src/fetch.c b/src/fetch.c
index f2f3131..dedbb54 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -21,9 +21,12 @@
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
{
- int match = 0;
+ int match = 0, valid;
- if (!git_reference_is_valid_name(head->name))
+ if (git_reference_name_is_valid(&valid, head->name) < 0)
+ return -1;
+
+ if (!valid)
return 0;
if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
@@ -155,7 +158,9 @@ int git_fetch_options_init(git_fetch_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_fetch_init_options(git_fetch_options *opts, unsigned int version)
{
return git_fetch_options_init(opts, version);
}
+#endif
diff --git a/src/fetchhead.c b/src/fetchhead.c
index ea610f3..88c567e 100644
--- a/src/fetchhead.c
+++ b/src/fetchhead.c
@@ -73,7 +73,8 @@ int git_fetchhead_ref_create(
{
git_fetchhead_ref *fetchhead_ref;
- assert(out && oid);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(oid);
*out = NULL;
@@ -108,7 +109,8 @@ static int fetchhead_ref_write(
const char *type, *name;
int head = 0;
- assert(file && fetchhead_ref);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(fetchhead_ref);
git_oid_fmt(oid, &fetchhead_ref->oid);
oid[GIT_OID_HEXSZ] = '\0';
@@ -145,7 +147,8 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
unsigned int i;
git_fetchhead_ref *fetchhead_ref;
- assert(repo && fetchhead_refs);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(fetchhead_refs);
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
return -1;
@@ -279,7 +282,8 @@ int git_repository_fetchhead_foreach(git_repository *repo,
size_t line_num = 0;
int error = 0;
- assert(repo && cb);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(cb);
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
return -1;
diff --git a/src/filebuf.c b/src/filebuf.c
index e12a9ea..a3f6b14 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -184,7 +184,7 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
} while (zs->avail_out == 0);
- assert(zs->avail_in == 0);
+ GIT_ASSERT(zs->avail_in == 0);
if (file->compute_digest)
git_hash_update(&file->digest, source, len);
@@ -278,10 +278,9 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
int compression, error = -1;
size_t path_len, alloc_len;
- /* opening an already open buffer is a programming error;
- * assert that this never happens instead of returning
- * an error code */
- assert(file && path && file->buffer == NULL);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(path);
+ GIT_ASSERT(file->buffer == NULL);
memset(file, 0x0, sizeof(git_filebuf));
@@ -389,7 +388,9 @@ cleanup:
int git_filebuf_hash(git_oid *oid, git_filebuf *file)
{
- assert(oid && file && file->compute_digest);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(file->compute_digest);
flush_buffer(file);
@@ -415,7 +416,8 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path)
int git_filebuf_commit(git_filebuf *file)
{
/* temporary files cannot be committed */
- assert(file && file->path_original);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT(file->path_original);
file->flush_mode = Z_FINISH;
flush_buffer(file);
diff --git a/src/filter.c b/src/filter.c
index bb9d66a..eed175e 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -11,7 +11,7 @@
#include "futils.h"
#include "hash.h"
#include "repository.h"
-#include "global.h"
+#include "runtime.h"
#include "git2/sys/filter.h"
#include "git2/config.h"
#include "blob.h"
@@ -19,12 +19,12 @@
#include "array.h"
struct git_filter_source {
- git_repository *repo;
- const char *path;
- git_oid oid; /* zero if unknown (which is likely) */
- uint16_t filemode; /* zero if unknown */
- git_filter_mode_t mode;
- uint32_t flags;
+ git_repository *repo;
+ const char *path;
+ git_oid oid; /* zero if unknown (which is likely) */
+ uint16_t filemode; /* zero if unknown */
+ git_filter_mode_t mode;
+ git_filter_options options;
};
typedef struct {
@@ -206,7 +206,7 @@ int git_filter_global_init(void)
GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
error = -1;
- git__on_shutdown(git_filter_global_shutdown);
+ error = git_runtime_shutdown_register(git_filter_global_shutdown);
done:
if (error) {
@@ -266,7 +266,8 @@ int git_filter_register(
{
int error;
- assert(name && filter);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(filter);
if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -293,7 +294,7 @@ int git_filter_unregister(const char *name)
git_filter_def *fdef;
int error = 0;
- assert(name);
+ GIT_ASSERT_ARG(name);
/* cannot unregister default filters */
if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
@@ -395,7 +396,7 @@ git_filter_mode_t git_filter_source_mode(const git_filter_source *src)
uint32_t git_filter_source_flags(const git_filter_source *src)
{
- return src->flags;
+ return src->options.flags;
}
static int filter_list_new(
@@ -415,7 +416,8 @@ static int filter_list_new(
fl->source.repo = src->repo;
fl->source.path = fl->path;
fl->source.mode = src->mode;
- fl->source.flags = src->flags;
+
+ memcpy(&fl->source.options, &src->options, sizeof(git_filter_options));
*out = fl;
return 0;
@@ -424,25 +426,30 @@ static int filter_list_new(
static int filter_list_check_attributes(
const char ***out,
git_repository *repo,
- git_attr_session *attr_session,
+ git_filter_session *filter_session,
git_filter_def *fdef,
const git_filter_source *src)
{
const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
- uint32_t flags = 0;
+ git_attr_options attr_opts = GIT_ATTR_OPTIONS_INIT;
size_t i;
int error;
GIT_ERROR_CHECK_ALLOC(strs);
- if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
- flags |= GIT_ATTR_CHECK_NO_SYSTEM;
+ if ((src->options.flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
+ attr_opts.flags |= GIT_ATTR_CHECK_NO_SYSTEM;
+
+ if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
+ attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
- if ((src->flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
- flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
+ if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
+ attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_COMMIT;
+ attr_opts.commit_id = src->options.commit_id;
+ }
error = git_attr_get_many_with_session(
- strs, repo, attr_session, flags, src->path, fdef->nattrs, fdef->attrs);
+ strs, repo, filter_session->attr_session, &attr_opts, src->path, fdef->nattrs, fdef->attrs);
/* if no values were found but no matches are needed, it's okay! */
if (error == GIT_ENOTFOUND && !fdef->nmatches) {
@@ -487,17 +494,17 @@ int git_filter_list_new(
src.repo = repo;
src.path = NULL;
src.mode = mode;
- src.flags = flags;
+ src.options.flags = flags;
return filter_list_new(out, &src);
}
-int git_filter_list__load_ext(
+int git_filter_list__load(
git_filter_list **filters,
git_repository *repo,
git_blob *blob, /* can be NULL */
const char *path,
git_filter_mode_t mode,
- git_filter_options *filter_opts)
+ git_filter_session *filter_session)
{
int error = 0;
git_filter_list *fl = NULL;
@@ -514,7 +521,8 @@ int git_filter_list__load_ext(
src.repo = repo;
src.path = path;
src.mode = mode;
- src.flags = filter_opts->flags;
+
+ memcpy(&src.options, &filter_session->options, sizeof(git_filter_options));
if (blob)
git_oid_cpy(&src.oid, git_blob_id(blob));
@@ -528,7 +536,8 @@ int git_filter_list__load_ext(
if (fdef->nattrs > 0) {
error = filter_list_check_attributes(
- &values, repo, filter_opts->attr_session, fdef, &src);
+ &values, repo,
+ filter_session, fdef, &src);
if (error == GIT_ENOTFOUND) {
error = 0;
@@ -555,7 +564,7 @@ int git_filter_list__load_ext(
if ((error = filter_list_new(&fl, &src)) < 0)
break;
- fl->temp_buf = filter_opts->temp_buf;
+ fl->temp_buf = filter_session->temp_buf;
}
fe = git_array_alloc(fl->filters);
@@ -579,6 +588,23 @@ int git_filter_list__load_ext(
return error;
}
+int git_filter_list_load_ext(
+ git_filter_list **filters,
+ git_repository *repo,
+ git_blob *blob, /* can be NULL */
+ const char *path,
+ git_filter_mode_t mode,
+ git_filter_options *opts)
+{
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
+
+ if (opts)
+ memcpy(&filter_session.options, opts, sizeof(git_filter_options));
+
+ return git_filter_list__load(
+ filters, repo, blob, path, mode, &filter_session);
+}
+
int git_filter_list_load(
git_filter_list **filters,
git_repository *repo,
@@ -587,12 +613,12 @@ int git_filter_list_load(
git_filter_mode_t mode,
uint32_t flags)
{
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
- filter_opts.flags = flags;
+ filter_session.options.flags = flags;
- return git_filter_list__load_ext(
- filters, repo, blob, path, mode, &filter_opts);
+ return git_filter_list__load(
+ filters, repo, blob, path, mode, &filter_session);
}
void git_filter_list_free(git_filter_list *fl)
@@ -618,7 +644,7 @@ int git_filter_list_contains(
{
size_t i;
- assert(name);
+ GIT_ASSERT_ARG(name);
if (!fl)
return 0;
@@ -639,7 +665,8 @@ int git_filter_list_push(
git_filter_def *fdef = NULL;
git_filter_entry *fe;
- assert(fl && filter);
+ GIT_ASSERT_ARG(fl);
+ GIT_ASSERT_ARG(filter);
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -684,9 +711,8 @@ static int buf_stream_write(
git_writestream *s, const char *buffer, size_t len)
{
struct buf_stream *buf_stream = (struct buf_stream *)s;
- assert(buf_stream);
-
- assert(buf_stream->complete == 0);
+ GIT_ASSERT_ARG(buf_stream);
+ GIT_ASSERT(buf_stream->complete == 0);
return git_buf_put(buf_stream->target, buffer, len);
}
@@ -694,9 +720,9 @@ static int buf_stream_write(
static int buf_stream_close(git_writestream *s)
{
struct buf_stream *buf_stream = (struct buf_stream *)s;
- assert(buf_stream);
+ GIT_ASSERT_ARG(buf_stream);
- assert(buf_stream->complete == 0);
+ GIT_ASSERT(buf_stream->complete == 0);
buf_stream->complete = 1;
return 0;
@@ -719,27 +745,47 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
git_buf_clear(target);
}
-int git_filter_list_apply_to_data(
- git_buf *tgt, git_filter_list *filters, git_buf *src)
+int git_filter_list_apply_to_buffer(
+ git_buf *out,
+ git_filter_list *filters,
+ const char *in,
+ size_t in_len)
{
struct buf_stream writer;
int error;
- git_buf_sanitize(tgt);
- git_buf_sanitize(src);
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
+
+ buf_stream_init(&writer, out);
- if (!filters) {
- git_buf_attach_notowned(tgt, src->ptr, src->size);
+ if ((error = git_filter_list_stream_buffer(filters,
+ in, in_len, &writer.parent)) < 0)
+ return error;
+
+ GIT_ASSERT(writer.complete);
+ return error;
+}
+
+int git_filter_list__convert_buf(
+ git_buf *out,
+ git_filter_list *filters,
+ git_buf *in)
+{
+ int error;
+
+ if (!filters || git_filter_list_length(filters) == 0) {
+ git_buf_swap(out, in);
+ git_buf_dispose(in);
return 0;
}
- buf_stream_init(&writer, tgt);
+ error = git_filter_list_apply_to_buffer(out, filters,
+ in->ptr, in->size);
- if ((error = git_filter_list_stream_data(filters, src,
- &writer.parent)) < 0)
- return error;
+ if (!error)
+ git_buf_dispose(in);
- assert(writer.complete);
return error;
}
@@ -758,7 +804,7 @@ int git_filter_list_apply_to_file(
filters, repo, path, &writer.parent)) < 0)
return error;
- assert(writer.complete);
+ GIT_ASSERT(writer.complete);
return error;
}
@@ -789,7 +835,7 @@ int git_filter_list_apply_to_blob(
filters, blob, &writer.parent)) < 0)
return error;
- assert(writer.complete);
+ GIT_ASSERT(writer.complete);
return error;
}
@@ -808,7 +854,7 @@ static int proxy_stream_write(
git_writestream *s, const char *buffer, size_t len)
{
struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
- assert(proxy_stream);
+ GIT_ASSERT_ARG(proxy_stream);
return git_buf_put(&proxy_stream->input, buffer, len);
}
@@ -820,7 +866,7 @@ static int proxy_stream_close(git_writestream *s)
git_error_state error_state = {0};
int error;
- assert(proxy_stream);
+ GIT_ASSERT_ARG(proxy_stream);
error = proxy_stream->filter->apply(
proxy_stream->filter,
@@ -832,7 +878,9 @@ static int proxy_stream_close(git_writestream *s)
if (error == GIT_PASSTHROUGH) {
writebuf = &proxy_stream->input;
} else if (error == 0) {
- git_buf_sanitize(proxy_stream->output);
+ if ((error = git_buf_sanitize(proxy_stream->output)) < 0)
+ return error;
+
writebuf = proxy_stream->output;
} else {
/* close stream before erroring out taking care
@@ -853,11 +901,12 @@ static int proxy_stream_close(git_writestream *s)
static void proxy_stream_free(git_writestream *s)
{
struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
- assert(proxy_stream);
- git_buf_dispose(&proxy_stream->input);
- git_buf_dispose(&proxy_stream->temp_buf);
- git__free(proxy_stream);
+ if (proxy_stream) {
+ git_buf_dispose(&proxy_stream->input);
+ git_buf_dispose(&proxy_stream->temp_buf);
+ git__free(proxy_stream);
+ }
}
static int proxy_stream_init(
@@ -911,7 +960,7 @@ static int stream_list_init(
git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
git_writestream *filter_stream;
- assert(fe->filter->stream || fe->filter->apply);
+ GIT_ASSERT(fe->filter->stream || fe->filter->apply);
/* If necessary, create a stream that proxies the traditional
* application.
@@ -941,7 +990,7 @@ out:
return error;
}
-void stream_list_free(git_vector *streams)
+static void filter_streams_free(git_vector *streams)
{
git_writestream *stream;
size_t i;
@@ -967,8 +1016,10 @@ int git_filter_list_stream_file(
if ((error = stream_list_init(
&stream_start, &filter_streams, filters, target)) < 0 ||
- (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0)
+ (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
+ (error = git_path_validate_workdir_buf(repo, &abspath)) < 0)
goto done;
+
initialized = 1;
if ((fd = git_futils_open_ro(abspath.ptr)) < 0) {
@@ -990,35 +1041,33 @@ done:
if (fd >= 0)
p_close(fd);
- stream_list_free(&filter_streams);
+ filter_streams_free(&filter_streams);
git_buf_dispose(&abspath);
return error;
}
-int git_filter_list_stream_data(
+int git_filter_list_stream_buffer(
git_filter_list *filters,
- git_buf *data,
+ const char *buffer,
+ size_t len,
git_writestream *target)
{
git_vector filter_streams = GIT_VECTOR_INIT;
git_writestream *stream_start;
int error, initialized = 0;
- git_buf_sanitize(data);
-
if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
goto out;
initialized = 1;
- if ((error = stream_start->write(
- stream_start, data->ptr, data->size)) < 0)
+ if ((error = stream_start->write(stream_start, buffer, len)) < 0)
goto out;
out:
if (initialized)
error |= stream_start->close(stream_start);
- stream_list_free(&filter_streams);
+ filter_streams_free(&filter_streams);
return error;
}
@@ -1035,7 +1084,7 @@ int git_filter_list_stream_blob(
if (filters)
git_oid_cpy(&filters->source.oid, git_blob_id(blob));
- return git_filter_list_stream_data(filters, &in, target);
+ return git_filter_list_stream_buffer(filters, in.ptr, in.size, target);
}
int git_filter_init(git_filter *filter, unsigned int version)
@@ -1043,3 +1092,31 @@ int git_filter_init(git_filter *filter, unsigned int version)
GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);
return 0;
}
+
+#ifndef GIT_DEPRECATE_HARD
+
+int git_filter_list_stream_data(
+ git_filter_list *filters,
+ git_buf *data,
+ git_writestream *target)
+{
+ int error;
+
+ if ((error = git_buf_sanitize(data)) < 0)
+ return error;
+
+ return git_filter_list_stream_buffer(filters, data->ptr, data->size, target);
+}
+
+int git_filter_list_apply_to_data(
+ git_buf *tgt, git_filter_list *filters, git_buf *src)
+{
+ int error;
+
+ if ((error = git_buf_sanitize(src)) < 0)
+ return error;
+
+ return git_filter_list_apply_to_buffer(tgt, filters, src->ptr, src->size);
+}
+
+#endif
diff --git a/src/filter.h b/src/filter.h
index 34081fb..55ed50e 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -16,24 +16,33 @@
#define GIT_FILTER_BYTES_TO_CHECK_NUL 8000
typedef struct {
+ git_filter_options options;
git_attr_session *attr_session;
git_buf *temp_buf;
- uint32_t flags;
-} git_filter_options;
+} git_filter_session;
-#define GIT_FILTER_OPTIONS_INIT {0}
+#define GIT_FILTER_SESSION_INIT {GIT_FILTER_OPTIONS_INIT, 0}
extern int git_filter_global_init(void);
extern void git_filter_free(git_filter *filter);
-extern int git_filter_list__load_ext(
+extern int git_filter_list__load(
git_filter_list **filters,
git_repository *repo,
git_blob *blob, /* can be NULL */
const char *path,
git_filter_mode_t mode,
- git_filter_options *filter_opts);
+ git_filter_session *filter_session);
+
+/*
+ * The given input buffer will be converted to the given output buffer.
+ * The input buffer will be freed (_if_ it was allocated).
+ */
+extern int git_filter_list__convert_buf(
+ git_buf *out,
+ git_filter_list *filters,
+ git_buf *in);
/*
* Available filters
diff --git a/src/futils.c b/src/futils.c
index a7c360a..a448208 100644
--- a/src/futils.c
+++ b/src/futils.c
@@ -7,8 +7,9 @@
#include "futils.h"
-#include "global.h"
+#include "runtime.h"
#include "strmap.h"
+#include "hash.h"
#include <ctype.h>
#if GIT_WIN32
#include "win32/findfile.h"
@@ -184,7 +185,8 @@ int git_futils_readbuffer_updated(
git_buf buf = GIT_BUF_INIT;
git_oid checksum_new;
- assert(out && path && *path);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(path && *path);
if (updated != NULL)
*updated = 0;
@@ -492,7 +494,7 @@ int git_futils_mkdir(
goto done;
}
- assert(len);
+ GIT_ASSERT(len);
/*
* We've walked all the given path's parents and it's either relative
@@ -834,12 +836,12 @@ int git_futils_rmdir_r(
return error;
}
-int git_futils_fake_symlink(const char *old, const char *new)
+int git_futils_fake_symlink(const char *target, const char *path)
{
int retcode = GIT_ERROR;
- int fd = git_futils_creat_withpath(new, 0755, 0644);
+ int fd = git_futils_creat_withpath(path, 0755, 0644);
if (fd >= 0) {
- retcode = p_write(fd, old, strlen(old));
+ retcode = p_write(fd, target, strlen(target));
p_close(fd);
}
return retcode;
@@ -1127,8 +1129,6 @@ int git_futils_filestamp_check(
void git_futils_filestamp_set(
git_futils_filestamp *target, const git_futils_filestamp *source)
{
- assert(target);
-
if (source)
memcpy(target, source, sizeof(*target));
else
diff --git a/src/futils.h b/src/futils.h
index 3d56646..5893612 100644
--- a/src/futils.h
+++ b/src/futils.h
@@ -257,7 +257,7 @@ extern int git_futils_truncate(const char *path, int mode);
*/
extern int git_futils_filesize(uint64_t *out, git_file fd);
-#define GIT_PERMS_IS_EXEC(MODE) (((MODE) & 0111) != 0)
+#define GIT_PERMS_IS_EXEC(MODE) (((MODE) & 0100) != 0)
#define GIT_PERMS_CANONICAL(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0755 : 0644)
#define GIT_PERMS_FOR_WRITE(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0777 : 0666)
@@ -316,11 +316,11 @@ extern void git_futils_mmap_free(git_map *map);
/**
* Create a "fake" symlink (text file containing the target path).
*
- * @param new symlink file to be created
- * @param old original symlink target
+ * @param target original symlink target
+ * @param path symlink file to be created
* @return 0 on success, -1 on error
*/
-extern int git_futils_fake_symlink(const char *new, const char *old);
+extern int git_futils_fake_symlink(const char *target, const char *path);
/**
* A file stamp represents a snapshot of information about a file that can
diff --git a/src/global.c b/src/global.c
deleted file mode 100644
index 5af35aa..0000000
--- a/src/global.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "global.h"
-
-#include "alloc.h"
-#include "hash.h"
-#include "sysdir.h"
-#include "filter.h"
-#include "merge_driver.h"
-#include "streams/registry.h"
-#include "streams/mbedtls.h"
-#include "streams/openssl.h"
-#include "thread-utils.h"
-#include "git2/global.h"
-#include "transports/ssh.h"
-
-#if defined(GIT_MSVC_CRTDBG)
-#include "win32/w32_stack.h"
-#include "win32/w32_crtdbg_stacktrace.h"
-#endif
-
-git_mutex git__mwindow_mutex;
-
-typedef int (*git_global_init_fn)(void);
-
-static git_global_init_fn git__init_callbacks[] = {
- git_allocator_global_init,
- git_hash_global_init,
- git_sysdir_global_init,
- git_filter_global_init,
- git_merge_driver_global_init,
- git_transport_ssh_global_init,
- git_stream_registry_global_init,
- git_openssl_stream_global_init,
- git_mbedtls_stream_global_init,
- git_mwindow_global_init
-};
-
-static git_global_shutdown_fn git__shutdown_callbacks[ARRAY_SIZE(git__init_callbacks)];
-
-static git_atomic git__n_shutdown_callbacks;
-static git_atomic git__n_inits;
-char *git__user_agent;
-char *git__ssl_ciphers;
-
-void git__on_shutdown(git_global_shutdown_fn callback)
-{
- int count = git_atomic_inc(&git__n_shutdown_callbacks);
- assert(count <= (int) ARRAY_SIZE(git__shutdown_callbacks) && count > 0);
- git__shutdown_callbacks[count - 1] = callback;
-}
-
-static void git__global_state_cleanup(git_global_st *st)
-{
- if (!st)
- return;
-
- git__free(st->error_t.message);
- st->error_t.message = NULL;
-}
-
-static int init_common(void)
-{
- size_t i;
- int ret;
-
- /* Initialize the CRT debug allocator first, before our first malloc */
-#if defined(GIT_MSVC_CRTDBG)
- git_win32__crtdbg_stacktrace_init();
- git_win32__stack_init();
-#endif
-
- /* Initialize subsystems that have global state */
- for (i = 0; i < ARRAY_SIZE(git__init_callbacks); i++)
- if ((ret = git__init_callbacks[i]()) != 0)
- break;
-
- GIT_MEMORY_BARRIER;
-
- return ret;
-}
-
-static void shutdown_common(void)
-{
- int pos;
-
- /* Shutdown subsystems that have registered */
- for (pos = git_atomic_get(&git__n_shutdown_callbacks);
- pos > 0;
- pos = git_atomic_dec(&git__n_shutdown_callbacks)) {
-
- git_global_shutdown_fn cb = git__swap(
- git__shutdown_callbacks[pos - 1], NULL);
-
- if (cb != NULL)
- cb();
- }
-
- git__free(git__user_agent);
- git__free(git__ssl_ciphers);
-}
-
-/**
- * Handle the global state with TLS
- *
- * If libgit2 is built with GIT_THREADS enabled,
- * the `git_libgit2_init()` function must be called
- * before calling any other function of the library.
- *
- * This function allocates a TLS index (using pthreads
- * or the native Win32 API) to store the global state
- * on a per-thread basis.
- *
- * Any internal method that requires global state will
- * then call `git__global_state()` which returns a pointer
- * to the global state structure; this pointer is lazily
- * allocated on each thread.
- *
- * Before shutting down the library, the
- * `git_libgit2_shutdown` method must be called to free
- * the previously reserved TLS index.
- *
- * If libgit2 is built without threading support, the
- * `git__global_statestate()` call returns a pointer to a single,
- * statically allocated global state. The `git_thread_`
- * functions are not available in that case.
- */
-
-/*
- * `git_libgit2_init()` allows subsystems to perform global setup,
- * which may take place in the global scope. An explicit memory
- * fence exists at the exit of `git_libgit2_init()`. Without this,
- * CPU cores are free to reorder cache invalidation of `_tls_init`
- * before cache invalidation of the subsystems' newly written global
- * state.
- */
-#if defined(GIT_THREADS) && defined(GIT_WIN32)
-
-static DWORD _fls_index;
-static volatile LONG _mutex = 0;
-
-static void WINAPI fls_free(void *st)
-{
- git__global_state_cleanup(st);
- git__free(st);
-}
-
-static int synchronized_threads_init(void)
-{
- int error;
-
- if ((_fls_index = FlsAlloc(fls_free)) == FLS_OUT_OF_INDEXES)
- return -1;
-
- git_threads_init();
-
- if (git_mutex_init(&git__mwindow_mutex))
- return -1;
-
- error = init_common();
-
- return error;
-}
-
-int git_libgit2_init(void)
-{
- int ret;
-
- /* Enter the lock */
- while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); }
-
- /* Only do work on a 0 -> 1 transition of the refcount */
- if ((ret = git_atomic_inc(&git__n_inits)) == 1) {
- if (synchronized_threads_init() < 0)
- ret = -1;
- }
-
- /* Exit the lock */
- InterlockedExchange(&_mutex, 0);
-
- return ret;
-}
-
-int git_libgit2_shutdown(void)
-{
- int ret;
-
- /* Enter the lock */
- while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); }
-
- /* Only do work on a 1 -> 0 transition of the refcount */
- if ((ret = git_atomic_dec(&git__n_inits)) == 0) {
- shutdown_common();
-
- FlsFree(_fls_index);
- git_mutex_free(&git__mwindow_mutex);
-
-#if defined(GIT_MSVC_CRTDBG)
- git_win32__crtdbg_stacktrace_cleanup();
- git_win32__stack_cleanup();
-#endif
- }
-
- /* Exit the lock */
- InterlockedExchange(&_mutex, 0);
-
- return ret;
-}
-
-git_global_st *git__global_state(void)
-{
- git_global_st *ptr;
-
- assert(git_atomic_get(&git__n_inits) > 0);
-
- if ((ptr = FlsGetValue(_fls_index)) != NULL)
- return ptr;
-
- ptr = git__calloc(1, sizeof(git_global_st));
- if (!ptr)
- return NULL;
-
- git_buf_init(&ptr->error_buf, 0);
-
- FlsSetValue(_fls_index, ptr);
- return ptr;
-}
-
-#elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
-
-static pthread_key_t _tls_key;
-static pthread_mutex_t _init_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_once_t _once_init = PTHREAD_ONCE_INIT;
-int init_error = 0;
-
-static void cb__free_status(void *st)
-{
- git__global_state_cleanup(st);
- git__free(st);
-}
-
-static void init_once(void)
-{
- if ((init_error = git_mutex_init(&git__mwindow_mutex)) != 0)
- return;
-
- pthread_key_create(&_tls_key, &cb__free_status);
-
- init_error = init_common();
-}
-
-int git_libgit2_init(void)
-{
- int ret, err;
-
- if ((err = pthread_mutex_lock(&_init_mutex)) != 0)
- return err;
-
- ret = git_atomic_inc(&git__n_inits);
- err = pthread_once(&_once_init, init_once);
- err |= pthread_mutex_unlock(&_init_mutex);
-
- if (err || init_error)
- return err | init_error;
-
- return ret;
-}
-
-int git_libgit2_shutdown(void)
-{
- void *ptr = NULL;
- pthread_once_t new_once = PTHREAD_ONCE_INIT;
- int error, ret;
-
- if ((error = pthread_mutex_lock(&_init_mutex)) != 0)
- return error;
-
- if ((ret = git_atomic_dec(&git__n_inits)) != 0)
- goto out;
-
- /* Shut down any subsystems that have global state */
- shutdown_common();
-
- ptr = pthread_getspecific(_tls_key);
- pthread_setspecific(_tls_key, NULL);
-
- git__global_state_cleanup(ptr);
- git__free(ptr);
-
- pthread_key_delete(_tls_key);
- git_mutex_free(&git__mwindow_mutex);
- _once_init = new_once;
-
-out:
- if ((error = pthread_mutex_unlock(&_init_mutex)) != 0)
- return error;
-
- return ret;
-}
-
-git_global_st *git__global_state(void)
-{
- git_global_st *ptr;
-
- assert(git_atomic_get(&git__n_inits) > 0);
-
- if ((ptr = pthread_getspecific(_tls_key)) != NULL)
- return ptr;
-
- ptr = git__calloc(1, sizeof(git_global_st));
- if (!ptr)
- return NULL;
-
- git_buf_init(&ptr->error_buf, 0);
- pthread_setspecific(_tls_key, ptr);
- return ptr;
-}
-
-#else
-
-static git_global_st __state;
-
-int git_libgit2_init(void)
-{
- int ret;
-
- /* Only init subsystems the first time */
- if ((ret = git_atomic_inc(&git__n_inits)) != 1)
- return ret;
-
- if ((ret = init_common()) < 0)
- return ret;
-
- return 1;
-}
-
-int git_libgit2_shutdown(void)
-{
- int ret;
-
- /* Shut down any subsystems that have global state */
- if ((ret = git_atomic_dec(&git__n_inits)) == 0) {
- shutdown_common();
- git__global_state_cleanup(&__state);
- memset(&__state, 0, sizeof(__state));
- }
-
- return ret;
-}
-
-git_global_st *git__global_state(void)
-{
- return &__state;
-}
-
-#endif /* GIT_THREADS */
diff --git a/src/global.h b/src/global.h
deleted file mode 100644
index db41dad..0000000
--- a/src/global.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_global_h__
-#define INCLUDE_global_h__
-
-#include "common.h"
-
-#include "mwindow.h"
-#include "hash.h"
-
-typedef struct {
- git_error *last_error;
- git_error error_t;
- git_buf error_buf;
- char oid_fmt[GIT_OID_HEXSZ+1];
-
- /* On Windows, this is the current child thread that was started by
- * `git_thread_create`. This is used to set the thread's exit code
- * when terminated by `git_thread_exit`. It is unused on POSIX.
- */
- git_thread *current_thread;
-} git_global_st;
-
-git_global_st *git__global_state(void);
-
-extern git_mutex git__mwindow_mutex;
-
-#define GIT_GLOBAL (git__global_state())
-
-typedef void (*git_global_shutdown_fn)(void);
-
-extern void git__on_shutdown(git_global_shutdown_fn callback);
-
-extern const char *git_libgit2__user_agent(void);
-extern const char *git_libgit2__ssl_ciphers(void);
-
-#endif
diff --git a/src/graph.c b/src/graph.c
index df82f0f..35e914f 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -43,7 +43,7 @@ static int mark_parents(git_revwalk *walk, git_commit_list_node *one,
return 0;
}
- if (git_pqueue_init(&list, 0, 2, git_commit_list_time_cmp) < 0)
+ if (git_pqueue_init(&list, 0, 2, git_commit_list_generation_cmp) < 0)
return -1;
if (git_commit_list_parse(walk, one) < 0)
@@ -176,19 +176,74 @@ on_error:
int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const git_oid *ancestor)
{
- git_oid merge_base;
- int error;
-
if (git_oid_equal(commit, ancestor))
return 0;
- error = git_merge_base(&merge_base, repo, commit, ancestor);
- /* No merge-base found, it's not a descendant */
- if (error == GIT_ENOTFOUND)
+ return git_graph_reachable_from_any(repo, ancestor, commit, 1);
+}
+
+int git_graph_reachable_from_any(
+ git_repository *repo,
+ const git_oid *commit_id,
+ const git_oid descendant_array[],
+ size_t length)
+{
+ git_revwalk *walk = NULL;
+ git_vector list;
+ git_commit_list *result = NULL;
+ git_commit_list_node *commit;
+ size_t i;
+ uint32_t minimum_generation = 0xffffffff;
+ int error = 0;
+
+ if (!length)
return 0;
- if (error < 0)
+ for (i = 0; i < length; ++i) {
+ if (git_oid_equal(commit_id, &descendant_array[i]))
+ return 1;
+ }
+
+ if ((error = git_vector_init(&list, length + 1, NULL)) < 0)
return error;
- return git_oid_equal(&merge_base, ancestor);
+ if ((error = git_revwalk_new(&walk, repo)) < 0)
+ goto done;
+
+ for (i = 0; i < length; i++) {
+ commit = git_revwalk__commit_lookup(walk, &descendant_array[i]);
+ if (commit == NULL) {
+ error = -1;
+ goto done;
+ }
+
+ git_vector_insert(&list, commit);
+ if (minimum_generation > commit->generation)
+ minimum_generation = commit->generation;
+ }
+
+ commit = git_revwalk__commit_lookup(walk, commit_id);
+ if (commit == NULL) {
+ error = -1;
+ goto done;
+ }
+
+ if (minimum_generation > commit->generation)
+ minimum_generation = commit->generation;
+
+ if ((error = git_merge__bases_many(&result, walk, commit, &list, minimum_generation)) < 0)
+ goto done;
+
+ if (result) {
+ error = git_oid_equal(commit_id, &result->item->oid);
+ } else {
+ /* No merge-base found, it's not a descendant */
+ error = 0;
+ }
+
+done:
+ git_commit_list_free(&result);
+ git_vector_free(&list);
+ git_revwalk_free(walk);
+ return error;
}
diff --git a/src/hash.c b/src/hash.c
index 405c46a..5a7278e 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -16,7 +16,7 @@ int git_hash_ctx_init(git_hash_ctx *ctx)
{
int error;
- if ((error = git_hash_sha1_ctx_init(&ctx->sha1)) < 0)
+ if ((error = git_hash_sha1_ctx_init(&ctx->ctx.sha1)) < 0)
return error;
ctx->algo = GIT_HASH_ALGO_SHA1;
@@ -28,10 +28,10 @@ void git_hash_ctx_cleanup(git_hash_ctx *ctx)
{
switch (ctx->algo) {
case GIT_HASH_ALGO_SHA1:
- git_hash_sha1_ctx_cleanup(&ctx->sha1);
+ git_hash_sha1_ctx_cleanup(&ctx->ctx.sha1);
return;
default:
- assert(0);
+ /* unreachable */ ;
}
}
@@ -39,33 +39,36 @@ int git_hash_init(git_hash_ctx *ctx)
{
switch (ctx->algo) {
case GIT_HASH_ALGO_SHA1:
- return git_hash_sha1_init(&ctx->sha1);
+ return git_hash_sha1_init(&ctx->ctx.sha1);
default:
- assert(0);
- return -1;
+ /* unreachable */ ;
}
+ GIT_ASSERT(0);
+ return -1;
}
int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
{
switch (ctx->algo) {
case GIT_HASH_ALGO_SHA1:
- return git_hash_sha1_update(&ctx->sha1, data, len);
+ return git_hash_sha1_update(&ctx->ctx.sha1, data, len);
default:
- assert(0);
- return -1;
+ /* unreachable */ ;
}
+ GIT_ASSERT(0);
+ return -1;
}
int git_hash_final(git_oid *out, git_hash_ctx *ctx)
{
switch (ctx->algo) {
case GIT_HASH_ALGO_SHA1:
- return git_hash_sha1_final(out, &ctx->sha1);
+ return git_hash_sha1_final(out, &ctx->ctx.sha1);
default:
- assert(0);
- return -1;
+ /* unreachable */ ;
}
+ GIT_ASSERT(0);
+ return -1;
}
int git_hash_buf(git_oid *out, const void *data, size_t len)
@@ -80,7 +83,7 @@ int git_hash_buf(git_oid *out, const void *data, size_t len)
error = git_hash_final(out, &ctx);
git_hash_ctx_cleanup(&ctx);
-
+
return error;
}
diff --git a/src/hash.h b/src/hash.h
index 017bb28..87305cc 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -27,7 +27,7 @@ typedef enum {
typedef struct git_hash_ctx {
union {
git_hash_sha1_ctx sha1;
- };
+ } ctx;
git_hash_algo_t algo;
} git_hash_ctx;
diff --git a/src/hash/sha1/collisiondetect.c b/src/hash/sha1/collisiondetect.c
index e6a1267..722ebf3 100644
--- a/src/hash/sha1/collisiondetect.c
+++ b/src/hash/sha1/collisiondetect.c
@@ -24,21 +24,21 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
SHA1DCInit(&ctx->c);
return 0;
}
int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
SHA1DCUpdate(&ctx->c, data, len);
return 0;
}
int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
if (SHA1DCFinal(out->id, &ctx->c)) {
git_error_set(GIT_ERROR_SHA1, "SHA1 collision attack detected");
return -1;
diff --git a/src/hash/sha1/common_crypto.c b/src/hash/sha1/common_crypto.c
index 0449a3c..4250e0b 100644
--- a/src/hash/sha1/common_crypto.c
+++ b/src/hash/sha1/common_crypto.c
@@ -26,7 +26,7 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
CC_SHA1_Init(&ctx->c);
return 0;
}
@@ -35,7 +35,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *_data, size_t len)
{
const unsigned char *data = _data;
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
while (len > 0) {
CC_LONG chunk = (len > CC_LONG_MAX) ? CC_LONG_MAX : (CC_LONG)len;
@@ -51,7 +51,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *_data, size_t len)
int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
CC_SHA1_Final(out->id, &ctx->c);
return 0;
}
diff --git a/src/hash/sha1/generic.h b/src/hash/sha1/generic.h
index e4cc602..53fc082 100644
--- a/src/hash/sha1/generic.h
+++ b/src/hash/sha1/generic.h
@@ -11,7 +11,7 @@
#include "hash/sha1.h"
struct git_hash_sha1_ctx {
- unsigned long long size;
+ uint64_t size;
unsigned int H[5];
unsigned int W[16];
};
diff --git a/src/hash/sha1/mbedtls.c b/src/hash/sha1/mbedtls.c
index e44343f..04e7da5 100644
--- a/src/hash/sha1/mbedtls.c
+++ b/src/hash/sha1/mbedtls.c
@@ -19,28 +19,28 @@ int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
{
- assert(ctx);
- mbedtls_sha1_free(&ctx->c);
+ if (ctx)
+ mbedtls_sha1_free(&ctx->c);
}
int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
{
- assert(ctx);
- mbedtls_sha1_init(&ctx->c);
- mbedtls_sha1_starts(&ctx->c);
- return 0;
+ GIT_ASSERT_ARG(ctx);
+ mbedtls_sha1_init(&ctx->c);
+ mbedtls_sha1_starts(&ctx->c);
+ return 0;
}
int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
{
- assert(ctx);
- mbedtls_sha1_update(&ctx->c, data, len);
- return 0;
+ GIT_ASSERT_ARG(ctx);
+ mbedtls_sha1_update(&ctx->c, data, len);
+ return 0;
}
int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
{
- assert(ctx);
- mbedtls_sha1_finish(&ctx->c, out->id);
- return 0;
+ GIT_ASSERT_ARG(ctx);
+ mbedtls_sha1_finish(&ctx->c, out->id);
+ return 0;
}
diff --git a/src/hash/sha1/openssl.c b/src/hash/sha1/openssl.c
index ba3212f..68d9611 100644
--- a/src/hash/sha1/openssl.c
+++ b/src/hash/sha1/openssl.c
@@ -24,7 +24,7 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
if (SHA1_Init(&ctx->c) != 1) {
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to initialize hash context");
@@ -36,7 +36,7 @@ int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
if (SHA1_Update(&ctx->c, data, len) != 1) {
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to update hash");
@@ -48,7 +48,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
{
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
if (SHA1_Final(out->id, &ctx->c) != 1) {
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to finalize hash");
diff --git a/src/hash/sha1/sha1dc/sha1.c b/src/hash/sha1/sha1dc/sha1.c
index 9d3cf81..86b8cc0 100644
--- a/src/hash/sha1/sha1dc/sha1.c
+++ b/src/hash/sha1/sha1dc/sha1.c
@@ -10,10 +10,8 @@
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
-#ifdef __unix__
#include <sys/types.h> /* make sure macros like _BIG_ENDIAN visible */
#endif
-#endif
#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C
#include SHA1DC_CUSTOM_INCLUDE_SHA1_C
diff --git a/src/hash/sha1/win32.c b/src/hash/sha1/win32.c
index c736956..a6e7061 100644
--- a/src/hash/sha1/win32.c
+++ b/src/hash/sha1/win32.c
@@ -7,7 +7,7 @@
#include "win32.h"
-#include "global.h"
+#include "runtime.h"
#include <wincrypt.h>
#include <strsafe.h>
@@ -129,7 +129,8 @@ int git_hash_sha1_global_init(void)
if ((error = hash_cng_prov_init()) < 0)
error = hash_cryptoapi_prov_init();
- git__on_shutdown(sha1_shutdown);
+ if (!error)
+ error = git_runtime_shutdown_register(sha1_shutdown);
return error;
}
@@ -163,7 +164,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_sha1_ctx *ctx, const void *_data,
{
const BYTE *data = (BYTE *)_data;
- assert(ctx->ctx.cryptoapi.valid);
+ GIT_ASSERT(ctx->ctx.cryptoapi.valid);
while (len > 0) {
DWORD chunk = (len > MAXDWORD) ? MAXDWORD : (DWORD)len;
@@ -185,7 +186,7 @@ GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_sha1_ctx *ctx)
DWORD len = 20;
int error = 0;
- assert(ctx->ctx.cryptoapi.valid);
+ GIT_ASSERT(ctx->ctx.cryptoapi.valid);
if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) {
git_error_set(GIT_ERROR_OS, "legacy hash data could not be finished");
@@ -285,7 +286,7 @@ int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
{
int error = 0;
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
/*
* When compiled with GIT_THREADS, the global hash_prov data is
@@ -302,27 +303,30 @@ int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
{
- assert(ctx && ctx->type);
+ GIT_ASSERT_ARG(ctx);
+ GIT_ASSERT_ARG(ctx->type);
return (ctx->type == CNG) ? hash_cng_init(ctx) : hash_cryptoapi_init(ctx);
}
int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
{
- assert(ctx && ctx->type);
+ GIT_ASSERT_ARG(ctx);
+ GIT_ASSERT_ARG(ctx->type);
return (ctx->type == CNG) ? hash_cng_update(ctx, data, len) : hash_cryptoapi_update(ctx, data, len);
}
int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
{
- assert(ctx && ctx->type);
+ GIT_ASSERT_ARG(ctx);
+ GIT_ASSERT_ARG(ctx->type);
return (ctx->type == CNG) ? hash_cng_final(out, ctx) : hash_cryptoapi_final(out, ctx);
}
void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
{
- assert(ctx);
-
- if (ctx->type == CNG)
+ if (!ctx)
+ return;
+ else if (ctx->type == CNG)
hash_ctx_cng_cleanup(ctx);
else if(ctx->type == CRYPTOAPI)
hash_ctx_cryptoapi_cleanup(ctx);
diff --git a/src/hashsig.c b/src/hashsig.c
index 14ec34b..43310ca 100644
--- a/src/hashsig.c
+++ b/src/hashsig.c
@@ -17,7 +17,7 @@ typedef uint64_t hashsig_state;
#define HASHSIG_SCALE 100
#define HASHSIG_MAX_RUN 80
-#define HASHSIG_HASH_START 0x012345678ABCDEF0LL
+#define HASHSIG_HASH_START INT64_C(0x012345678ABCDEF0)
#define HASHSIG_HASH_SHIFT 5
#define HASHSIG_HASH_MIX(S,CH) \
@@ -133,13 +133,13 @@ typedef struct {
uint8_t ignore_ch[256];
} hashsig_in_progress;
-static void hashsig_in_progress_init(
+static int hashsig_in_progress_init(
hashsig_in_progress *prog, git_hashsig *sig)
{
int i;
/* no more than one can be set */
- assert(!(sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) ||
+ GIT_ASSERT(!(sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) ||
!(sig->opt & GIT_HASHSIG_SMART_WHITESPACE));
if (sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) {
@@ -153,6 +153,8 @@ static void hashsig_in_progress_init(
} else {
memset(prog, 0, sizeof(*prog));
}
+
+ return 0;
}
static int hashsig_add_hashes(
@@ -251,7 +253,8 @@ int git_hashsig_create(
git_hashsig *sig = hashsig_alloc(opts);
GIT_ERROR_CHECK_ALLOC(sig);
- hashsig_in_progress_init(&prog, sig);
+ if ((error = hashsig_in_progress_init(&prog, sig)) < 0)
+ return error;
error = hashsig_add_hashes(sig, (const uint8_t *)buf, buflen, &prog);
@@ -283,7 +286,8 @@ int git_hashsig_create_fromfile(
return fd;
}
- hashsig_in_progress_init(&prog, sig);
+ if ((error = hashsig_in_progress_init(&prog, sig)) < 0)
+ return error;
while (!error) {
if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {
@@ -318,7 +322,7 @@ static int hashsig_heap_compare(const hashsig_heap *a, const hashsig_heap *b)
{
int matches = 0, i, j, cmp;
- assert(a->cmp == b->cmp);
+ GIT_ASSERT_WITH_RETVAL(a->cmp == b->cmp, 0);
/* hash heaps are sorted - just look for overlap vs total */
@@ -354,9 +358,16 @@ int git_hashsig_compare(const git_hashsig *a, const git_hashsig *b)
/* if we have fewer than the maximum number of elements, then just use
* one array since the two arrays will be the same
*/
- if (a->mins.size < HASHSIG_HEAP_SIZE)
+ if (a->mins.size < HASHSIG_HEAP_SIZE) {
return hashsig_heap_compare(&a->mins, &b->mins);
- else
- return (hashsig_heap_compare(&a->mins, &b->mins) +
- hashsig_heap_compare(&a->maxs, &b->maxs)) / 2;
+ } else {
+ int mins, maxs;
+
+ if ((mins = hashsig_heap_compare(&a->mins, &b->mins)) < 0)
+ return mins;
+ if ((maxs = hashsig_heap_compare(&a->maxs, &b->maxs)) < 0)
+ return maxs;
+
+ return (mins + maxs) / 2;
+ }
}
diff --git a/src/ident.c b/src/ident.c
index 7eccf9a..ae3ef1b 100644
--- a/src/ident.c
+++ b/src/ident.c
@@ -10,7 +10,6 @@
#include "git2/sys/filter.h"
#include "filter.h"
#include "buffer.h"
-#include "buf_text.h"
static int ident_find_id(
const char **id_start, const char **id_end, const char *start, size_t len)
@@ -105,7 +104,7 @@ static int ident_apply(
GIT_UNUSED(self); GIT_UNUSED(payload);
/* Don't filter binary files */
- if (git_buf_text_is_binary(from))
+ if (git_buf_is_binary(from))
return GIT_PASSTHROUGH;
if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
diff --git a/src/idxmap.c b/src/idxmap.c
index 4dcf963..bc23608 100644
--- a/src/idxmap.c
+++ b/src/idxmap.c
@@ -138,28 +138,6 @@ void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key)
return kh_val(map, idx);
}
-void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval)
-{
- khiter_t idx = kh_put(idx, map, key, rval);
-
- if ((*rval) >= 0) {
- if ((*rval) == 0)
- kh_key(map, idx) = key;
- kh_val(map, idx) = value;
- }
-}
-
-void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key, void *value, int *rval)
-{
- khiter_t idx = kh_put(idxicase, map, key, rval);
-
- if ((*rval) >= 0) {
- if ((*rval) == 0)
- kh_key(map, idx) = key;
- kh_val(map, idx) = value;
- }
-}
-
int git_idxmap_delete(git_idxmap *map, const git_index_entry *key)
{
khiter_t idx = kh_get(idx, map, key);
diff --git a/src/ignore.c b/src/ignore.c
index f5fb507..f7551cd 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
*/
static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
{
- int error = 0, wildmatch_flags;
+ int error = 0, wildmatch_flags, effective_flags;
size_t i;
git_attr_fnmatch *rule;
char *path;
@@ -141,8 +141,17 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
if (git_buf_oom(&buf))
goto out;
+ /*
+ * if rule isn't for full path we match without PATHNAME flag
+ * as lines like *.txt should match something like dir/test.txt
+ * requiring * to also match /
+ */
+ effective_flags = wildmatch_flags;
+ if (!(rule->flags & GIT_ATTR_FNMATCH_FULLPATH))
+ effective_flags &= ~WM_PATHNAME;
+
/* if we found a match, we want to keep this rule */
- if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
+ if ((wildmatch(git_buf_cstr(&buf), path, effective_flags)) == WM_MATCH) {
*out = 1;
error = 0;
goto out;
@@ -238,11 +247,12 @@ static int push_ignore_file(
const char *base,
const char *filename)
{
- int error = 0;
+ git_attr_file_source source = { GIT_ATTR_FILE_SOURCE_FILE, base, filename };
git_attr_file *file = NULL;
+ int error = 0;
+
+ error = git_attr_cache__get(&file, ignores->repo, NULL, &source, parse_ignore_file, false);
- error = git_attr_cache__get(&file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
- base, filename, parse_ignore_file, false);
if (error < 0)
return error;
@@ -263,13 +273,13 @@ static int push_one_ignore(void *payload, const char *path)
static int get_internal_ignores(git_attr_file **out, git_repository *repo)
{
+ git_attr_file_source source = { GIT_ATTR_FILE_SOURCE_MEMORY, NULL, GIT_IGNORE_INTERNAL };
int error;
if ((error = git_attr_cache__init(repo)) < 0)
return error;
- error = git_attr_cache__get(out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL,
- GIT_IGNORE_INTERNAL, NULL, false);
+ error = git_attr_cache__get(out, repo, NULL, &source, NULL, false);
/* if internal rules list is empty, insert default rules */
if (!error && !(*out)->rules.length)
@@ -287,7 +297,9 @@ int git_ignore__for_path(
const char *workdir = git_repository_workdir(repo);
git_buf infopath = GIT_BUF_INIT;
- assert(repo && ignores && path);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(ignores);
+ GIT_ASSERT_ARG(path);
memset(ignores, 0, sizeof(*ignores));
ignores->repo = repo;
@@ -307,12 +319,17 @@ int git_ignore__for_path(
if ((error = git_path_dirname_r(&local, path)) < 0 ||
(error = git_path_resolve_relative(&local, 0)) < 0 ||
(error = git_path_to_dir(&local)) < 0 ||
- (error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0)
- {;} /* Nothing, we just want to stop on the first error */
+ (error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0 ||
+ (error = git_path_validate_workdir_buf(repo, &ignores->dir)) < 0) {
+ /* Nothing, we just want to stop on the first error */
+ }
+
git_buf_dispose(&local);
} else {
- error = git_buf_joinpath(&ignores->dir, path, "");
+ if (!(error = git_buf_joinpath(&ignores->dir, path, "")))
+ error = git_path_validate_filesystem(ignores->dir.ptr, ignores->dir.size);
}
+
if (error < 0)
goto cleanup;
@@ -451,7 +468,7 @@ int git_ignore__lookup(
*out = GIT_IGNORE_NOTFOUND;
if (git_attr_path__init(
- &path, pathname, git_repository_workdir(ignores->repo), dir_flag) < 0)
+ &path, ignores->repo, pathname, git_repository_workdir(ignores->repo), dir_flag) < 0)
return -1;
/* first process builtins - success means path was found */
@@ -521,7 +538,9 @@ int git_ignore_path_is_ignored(
git_attr_file *file;
git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
- assert(repo && ignored && pathname);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(ignored);
+ GIT_ASSERT_ARG(pathname);
workdir = git_repository_workdir(repo);
@@ -533,7 +552,7 @@ int git_ignore_path_is_ignored(
else if (git_repository_is_bare(repo))
dir_flag = GIT_DIR_FLAG_FALSE;
- if ((error = git_attr_path__init(&path, pathname, workdir, dir_flag)) < 0 ||
+ if ((error = git_attr_path__init(&path, repo, pathname, workdir, dir_flag)) < 0 ||
(error = git_ignore__for_path(repo, path.path, &ignores)) < 0)
goto cleanup;
@@ -586,7 +605,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
git_attr_fnmatch *match;
int ignored;
git_buf path = GIT_BUF_INIT;
- const char *wd, *filename;
+ const char *filename;
git_index *idx;
if ((error = git_repository__ensure_not_bare(
@@ -594,8 +613,6 @@ int git_ignore__check_pathspec_for_exact_ignores(
(error = git_repository_index(&idx, repo)) < 0)
return error;
- wd = git_repository_workdir(repo);
-
git_vector_foreach(vspec, i, match) {
/* skip wildcard matches (if they are being used) */
if ((match->flags & GIT_ATTR_FNMATCH_HASWILD) != 0 &&
@@ -608,7 +625,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
if (git_index_get_bypath(idx, filename, 0) != NULL)
continue;
- if ((error = git_buf_joinpath(&path, wd, filename)) < 0)
+ if ((error = git_repository_workdir_path(&path, repo, filename)) < 0)
break;
/* is there a file on disk that matches this exactly? */
@@ -632,4 +649,3 @@ int git_ignore__check_pathspec_for_exact_ignores(
return error;
}
-
diff --git a/src/index.c b/src/index.c
index 907bd6d..5c33051 100644
--- a/src/index.c
+++ b/src/index.c
@@ -406,12 +406,13 @@ int git_index_open(git_index **index_out, const char *index_path)
git_index *index;
int error = -1;
- assert(index_out);
+ GIT_ASSERT_ARG(index_out);
index = git__calloc(1, sizeof(git_index));
GIT_ERROR_CHECK_ALLOC(index);
- git_pool_init(&index->tree_pool, 1);
+ if (git_pool_init(&index->tree_pool, 1) < 0)
+ goto fail;
if (index_path != NULL) {
index->index_file_path = git__strdup(index_path);
@@ -460,7 +461,8 @@ static void index_free(git_index *index)
/* index iterators increment the refcount of the index, so if we
* get here then there should be no outstanding iterators.
*/
- assert(!git_atomic_get(&index->readers));
+ if (git_atomic32_get(&index->readers))
+ return;
git_index_clear(index);
git_idxmap_free(index->entries_map);
@@ -486,14 +488,14 @@ void git_index_free(git_index *index)
/* call with locked index */
static void index_free_deleted(git_index *index)
{
- int readers = (int)git_atomic_get(&index->readers);
+ int readers = (int)git_atomic32_get(&index->readers);
size_t i;
if (readers > 0 || !index->deleted.length)
return;
for (i = 0; i < index->deleted.length; ++i) {
- git_index_entry *ie = git__swap(index->deleted.contents[i], NULL);
+ git_index_entry *ie = git_atomic_swap(index->deleted.contents[i], NULL);
index_entry_free(ie);
}
@@ -514,7 +516,7 @@ static int index_remove_entry(git_index *index, size_t pos)
error = git_vector_remove(&index->entries, pos);
if (!error) {
- if (git_atomic_get(&index->readers) > 0) {
+ if (git_atomic32_get(&index->readers) > 0) {
error = git_vector_insert(&index->deleted, entry);
} else {
index_entry_free(entry);
@@ -530,7 +532,7 @@ int git_index_clear(git_index *index)
{
int error = 0;
- assert(index);
+ GIT_ASSERT_ARG(index);
index->dirty = 1;
index->tree = NULL;
@@ -565,7 +567,7 @@ int git_index_set_caps(git_index *index, int caps)
{
unsigned int old_ignore_case;
- assert(index);
+ GIT_ASSERT_ARG(index);
old_ignore_case = index->ignore_case;
@@ -777,14 +779,14 @@ done:
unsigned git_index_version(git_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
return index->version;
}
int git_index_set_version(git_index *index, unsigned int version)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
if (version < INDEX_VERSION_NUMBER_LB ||
version > INDEX_VERSION_NUMBER_UB) {
@@ -813,9 +815,9 @@ int git_index_write(git_index *index)
return error;
}
-const char * git_index_path(const git_index *index)
+const char *git_index_path(const git_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG_WITH_RETVAL(index, NULL);
return index->index_file_path;
}
@@ -823,7 +825,8 @@ int git_index_write_tree(git_oid *oid, git_index *index)
{
git_repository *repo;
- assert(oid && index);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(index);
repo = INDEX_OWNER(index);
@@ -837,20 +840,25 @@ int git_index_write_tree(git_oid *oid, git_index *index)
int git_index_write_tree_to(
git_oid *oid, git_index *index, git_repository *repo)
{
- assert(oid && index && repo);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(repo);
+
return git_tree__write_index(oid, index, repo);
}
size_t git_index_entrycount(const git_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
+
return index->entries.length;
}
const git_index_entry *git_index_get_byindex(
git_index *index, size_t n)
{
- assert(index);
+ GIT_ASSERT_ARG_WITH_RETVAL(index, NULL);
+
git_vector_sort(&index->entries);
return git_vector_get(&index->entries, n);
}
@@ -861,7 +869,7 @@ const git_index_entry *git_index_get_bypath(
git_index_entry key = {{ 0 }};
git_index_entry *value;
- assert(index);
+ GIT_ASSERT_ARG_WITH_RETVAL(index, NULL);
key.path = path;
GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
@@ -936,7 +944,7 @@ static int index_entry_create(
if (st)
mode = st->st_mode;
- if (!git_path_isvalid(repo, path, mode, path_valid_flags)) {
+ if (!git_path_validate(repo, path, mode, path_valid_flags)) {
git_error_set(GIT_ERROR_INDEX, "invalid path: '%s'", path);
return -1;
}
@@ -980,7 +988,7 @@ static int index_entry_init(
if (git_repository__ensure_not_bare(repo, "create blob from file") < 0)
return GIT_EBAREREPO;
- if (git_buf_joinpath(&path, git_repository_workdir(repo), rel_path) < 0)
+ if (git_repository_workdir_path(&path, repo, rel_path) < 0)
return -1;
error = git_path_lstat(path.ptr, &st);
@@ -1038,23 +1046,24 @@ static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
{
git_index_reuc_entry *reuc = NULL;
- assert(reuc_out && path);
+ GIT_ASSERT_ARG(reuc_out);
+ GIT_ASSERT_ARG(path);
*reuc_out = reuc = reuc_entry_alloc(path);
GIT_ERROR_CHECK_ALLOC(reuc);
if ((reuc->mode[0] = ancestor_mode) > 0) {
- assert(ancestor_oid);
+ GIT_ASSERT(ancestor_oid);
git_oid_cpy(&reuc->oid[0], ancestor_oid);
}
if ((reuc->mode[1] = our_mode) > 0) {
- assert(our_oid);
+ GIT_ASSERT(our_oid);
git_oid_cpy(&reuc->oid[1], our_oid);
}
if ((reuc->mode[2] = their_mode) > 0) {
- assert(their_oid);
+ GIT_ASSERT(their_oid);
git_oid_cpy(&reuc->oid[2], their_oid);
}
@@ -1346,7 +1355,8 @@ static int index_insert(
size_t path_length, position;
int error;
- assert(index && entry_ptr);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(entry_ptr);
entry = *entry_ptr;
@@ -1471,7 +1481,8 @@ int git_index_add_from_buffer(
int error = 0;
git_oid id;
- assert(index && source_entry->path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(source_entry && source_entry->path);
if (INDEX_OWNER(index) == NULL)
return create_index_error(-1,
@@ -1521,7 +1532,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
struct stat st;
int error;
- if ((error = git_buf_joinpath(&abspath, git_repository_workdir(repo), path)) < 0)
+ if ((error = git_repository_workdir_path(&abspath, repo, path)) < 0)
return error;
if ((error = p_stat(abspath.ptr, &st)) < 0) {
@@ -1556,7 +1567,8 @@ int git_index_add_bypath(git_index *index, const char *path)
git_index_entry *entry = NULL;
int ret;
- assert(index && path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
if ((ret = index_entry_init(&entry, index, path)) == 0)
ret = index_insert(index, &entry, 1, false, false, true);
@@ -1608,7 +1620,8 @@ int git_index_remove_bypath(git_index *index, const char *path)
{
int ret;
- assert(index && path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
if (((ret = git_index_remove(index, path, 0)) < 0 &&
ret != GIT_ENOTFOUND) ||
@@ -1628,7 +1641,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
int error = 0;
size_t i;
- assert(index);
+ GIT_ASSERT_ARG(index);
if (!source_entries->length)
return 0;
@@ -1669,7 +1682,8 @@ int git_index_add(git_index *index, const git_index_entry *source_entry)
git_index_entry *entry = NULL;
int ret;
- assert(index && source_entry && source_entry->path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(source_entry && source_entry->path);
if (!valid_filemode(source_entry->mode)) {
git_error_set(GIT_ERROR_INDEX, "invalid entry mode");
@@ -1757,7 +1771,8 @@ int git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix)
int git_index__find_pos(
size_t *out, git_index *index, const char *path, size_t path_len, int stage)
{
- assert(index && path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
return index_find(out, index, path, path_len, stage);
}
@@ -1765,7 +1780,8 @@ int git_index_find(size_t *at_pos, git_index *index, const char *path)
{
size_t pos;
- assert(index && path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
if (git_vector_bsearch2(
&pos, &index->entries, index->entries_search_path, path) < 0) {
@@ -1798,7 +1814,7 @@ int git_index_conflict_add(git_index *index,
unsigned short i;
int ret = 0;
- assert (index);
+ GIT_ASSERT_ARG(index);
if ((ancestor_entry &&
(ret = index_entry_dup(&entries[0], index, ancestor_entry)) < 0) ||
@@ -1869,7 +1885,10 @@ static int index_conflict__get_byindex(
size_t count;
int stage, len = 0;
- assert(ancestor_out && our_out && their_out && index);
+ GIT_ASSERT_ARG(ancestor_out);
+ GIT_ASSERT_ARG(our_out);
+ GIT_ASSERT_ARG(their_out);
+ GIT_ASSERT_ARG(index);
*ancestor_out = NULL;
*our_out = NULL;
@@ -1915,7 +1934,11 @@ int git_index_conflict_get(
size_t pos;
int len = 0;
- assert(ancestor_out && our_out && their_out && index && path);
+ GIT_ASSERT_ARG(ancestor_out);
+ GIT_ASSERT_ARG(our_out);
+ GIT_ASSERT_ARG(their_out);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
*ancestor_out = NULL;
*our_out = NULL;
@@ -1962,13 +1985,14 @@ static int index_conflict_remove(git_index *index, const char *path)
int git_index_conflict_remove(git_index *index, const char *path)
{
- assert(index && path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
return index_conflict_remove(index, path);
}
int git_index_conflict_cleanup(git_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
return index_conflict_remove(index, NULL);
}
@@ -1977,7 +2001,7 @@ int git_index_has_conflicts(const git_index *index)
size_t i;
git_index_entry *entry;
- assert(index);
+ GIT_ASSERT_ARG(index);
git_vector_foreach(&index->entries, i, entry) {
if (GIT_INDEX_ENTRY_STAGE(entry) > 0)
@@ -1994,7 +2018,8 @@ int git_index_iterator_new(
git_index_iterator *it;
int error;
- assert(iterator_out && index);
+ GIT_ASSERT_ARG(iterator_out);
+ GIT_ASSERT_ARG(index);
it = git__calloc(1, sizeof(git_index_iterator));
GIT_ERROR_CHECK_ALLOC(it);
@@ -2014,7 +2039,8 @@ int git_index_iterator_next(
const git_index_entry **out,
git_index_iterator *it)
{
- assert(out && it);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(it);
if (it->cur >= git_vector_length(&it->snap))
return GIT_ITEROVER;
@@ -2038,7 +2064,8 @@ int git_index_conflict_iterator_new(
{
git_index_conflict_iterator *it = NULL;
- assert(iterator_out && index);
+ GIT_ASSERT_ARG(iterator_out);
+ GIT_ASSERT_ARG(index);
it = git__calloc(1, sizeof(git_index_conflict_iterator));
GIT_ERROR_CHECK_ALLOC(it);
@@ -2058,7 +2085,10 @@ int git_index_conflict_next(
const git_index_entry *entry;
int len;
- assert(ancestor_out && our_out && their_out && iterator);
+ GIT_ASSERT_ARG(ancestor_out);
+ GIT_ASSERT_ARG(our_out);
+ GIT_ASSERT_ARG(their_out);
+ GIT_ASSERT_ARG(iterator);
*ancestor_out = NULL;
*our_out = NULL;
@@ -2096,14 +2126,14 @@ void git_index_conflict_iterator_free(git_index_conflict_iterator *iterator)
size_t git_index_name_entrycount(git_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
return index->names.length;
}
const git_index_name_entry *git_index_name_get_byindex(
git_index *index, size_t n)
{
- assert(index);
+ GIT_ASSERT_ARG_WITH_RETVAL(index, NULL);
git_vector_sort(&index->names);
return git_vector_get(&index->names, n);
@@ -2124,7 +2154,7 @@ int git_index_name_add(git_index *index,
{
git_index_name_entry *conflict_name;
- assert((ancestor && ours) || (ancestor && theirs) || (ours && theirs));
+ GIT_ASSERT_ARG((ancestor && ours) || (ancestor && theirs) || (ours && theirs));
conflict_name = git__calloc(1, sizeof(git_index_name_entry));
GIT_ERROR_CHECK_ALLOC(conflict_name);
@@ -2147,7 +2177,7 @@ int git_index_name_clear(git_index *index)
size_t i;
git_index_name_entry *conflict_name;
- assert(index);
+ GIT_ASSERT_ARG(index);
git_vector_foreach(&index->names, i, conflict_name)
index_name_entry_free(conflict_name);
@@ -2161,7 +2191,7 @@ int git_index_name_clear(git_index *index)
size_t git_index_reuc_entrycount(git_index *index)
{
- assert(index);
+ GIT_ASSERT_ARG(index);
return index->reuc.length;
}
@@ -2178,8 +2208,9 @@ static int index_reuc_insert(
{
int res;
- assert(index && reuc && reuc->path != NULL);
- assert(git_vector_is_sorted(&index->reuc));
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(reuc && reuc->path != NULL);
+ GIT_ASSERT(git_vector_is_sorted(&index->reuc));
res = git_vector_insert_sorted(&index->reuc, reuc, &index_reuc_on_dup);
index->dirty = 1;
@@ -2195,7 +2226,8 @@ int git_index_reuc_add(git_index *index, const char *path,
git_index_reuc_entry *reuc = NULL;
int error = 0;
- assert(index && path);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(path);
if ((error = index_entry_reuc_init(&reuc, path, ancestor_mode,
ancestor_oid, our_mode, our_oid, their_mode, their_oid)) < 0 ||
@@ -2214,12 +2246,14 @@ const git_index_reuc_entry *git_index_reuc_get_bypath(
git_index *index, const char *path)
{
size_t pos;
- assert(index && path);
+
+ GIT_ASSERT_ARG_WITH_RETVAL(index, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(path, NULL);
if (!index->reuc.length)
return NULL;
- assert(git_vector_is_sorted(&index->reuc));
+ GIT_ASSERT_WITH_RETVAL(git_vector_is_sorted(&index->reuc), NULL);
if (git_index_reuc_find(&pos, index, path) < 0)
return NULL;
@@ -2230,8 +2264,8 @@ const git_index_reuc_entry *git_index_reuc_get_bypath(
const git_index_reuc_entry *git_index_reuc_get_byindex(
git_index *index, size_t n)
{
- assert(index);
- assert(git_vector_is_sorted(&index->reuc));
+ GIT_ASSERT_ARG_WITH_RETVAL(index, NULL);
+ GIT_ASSERT_WITH_RETVAL(git_vector_is_sorted(&index->reuc), NULL);
return git_vector_get(&index->reuc, n);
}
@@ -2241,7 +2275,8 @@ int git_index_reuc_remove(git_index *index, size_t position)
int error;
git_index_reuc_entry *reuc;
- assert(git_vector_is_sorted(&index->reuc));
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT(git_vector_is_sorted(&index->reuc));
reuc = git_vector_get(&index->reuc, position);
error = git_vector_remove(&index->reuc, position);
@@ -2257,10 +2292,10 @@ int git_index_reuc_clear(git_index *index)
{
size_t i;
- assert(index);
+ GIT_ASSERT_ARG(index);
for (i = 0; i < index->reuc.length; ++i)
- index_entry_reuc_free(git__swap(index->reuc.contents[i], NULL));
+ index_entry_reuc_free(git_atomic_swap(index->reuc.contents[i], NULL));
git_vector_clear(&index->reuc);
@@ -2625,7 +2660,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
seek_forward(INDEX_HEADER_SIZE);
- assert(!index->entries.length);
+ GIT_ASSERT(!index->entries.length);
if ((error = index_map_resize(index->entries_map, header.entry_count, index->ignore_case)) < 0)
return error;
@@ -2744,7 +2779,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
++same_len;
}
path_len -= same_len;
- varint_len = git_encode_varint(NULL, 0, same_len);
+ varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
}
disk_size = index_entry_size(path_len, varint_len, entry->flags);
@@ -2780,23 +2815,26 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
ondisk.flags = htons(entry->flags);
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
+ const size_t path_offset = offsetof(struct entry_long, path);
struct entry_long ondisk_ext;
memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
ondisk_ext.flags_extended = htons(entry->flags_extended &
GIT_INDEX_ENTRY_EXTENDED_FLAGS);
- memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path));
- path = ((struct entry_long*)mem)->path;
- disk_size -= offsetof(struct entry_long, path);
+ memcpy(mem, &ondisk_ext, path_offset);
+ path = (char *)mem + path_offset;
+ disk_size -= path_offset;
} else {
- memcpy(mem, &ondisk, offsetof(struct entry_short, path));
- path = ((struct entry_short*)mem)->path;
- disk_size -= offsetof(struct entry_short, path);
+ const size_t path_offset = offsetof(struct entry_short, path);
+ memcpy(mem, &ondisk, path_offset);
+ path = (char *)mem + path_offset;
+ disk_size -= path_offset;
}
if (last) {
varint_len = git_encode_varint((unsigned char *) path,
- disk_size, same_len);
- assert(varint_len > 0);
+ disk_size, strlen(last) - same_len);
+ GIT_ASSERT(varint_len > 0);
+
path += varint_len;
disk_size -= varint_len;
@@ -2804,14 +2842,14 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
* If using path compression, we are not allowed
* to have additional trailing NULs.
*/
- assert(disk_size == path_len + 1);
+ GIT_ASSERT(disk_size == path_len + 1);
} else {
/*
* If no path compression is used, we do have
* NULs as padding. As such, simply assert that
* we have enough space left to write the path.
*/
- assert(disk_size > path_len);
+ GIT_ASSERT(disk_size > path_len);
}
memcpy(path, path_start, path_len + 1);
@@ -2823,14 +2861,16 @@ static int write_entries(git_index *index, git_filebuf *file)
{
int error = 0;
size_t i;
- git_vector case_sorted, *entries;
+ git_vector case_sorted = GIT_VECTOR_INIT, *entries = NULL;
git_index_entry *entry;
const char *last = NULL;
/* If index->entries is sorted case-insensitively, then we need
* to re-sort it case-sensitively before writing */
if (index->ignore_case) {
- git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp);
+ if ((error = git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp)) < 0)
+ goto done;
+
git_vector_sort(&case_sorted);
entries = &case_sorted;
} else {
@@ -2847,9 +2887,8 @@ static int write_entries(git_index *index, git_filebuf *file)
last = entry->path;
}
- if (index->ignore_case)
- git_vector_free(&case_sorted);
-
+done:
+ git_vector_free(&case_sorted);
return error;
}
@@ -3007,7 +3046,8 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
bool is_extended;
uint32_t index_version_number;
- assert(index && file);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(file);
if (index->version <= INDEX_VERSION_NUMBER_EXT) {
is_extended = is_index_extended(index);
@@ -3158,7 +3198,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
/* well, this isn't good */;
} else {
git_vector_swap(&entries, &index->entries);
- entries_map = git__swap(index->entries_map, entries_map);
+ entries_map = git_atomic_swap(index->entries_map, entries_map);
}
index->dirty = 1;
@@ -3189,7 +3229,7 @@ static int git_index_read_iterator(
size_t i;
int error;
- assert((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
+ GIT_ASSERT((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
(error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
@@ -3292,7 +3332,7 @@ static int git_index_read_iterator(
goto done;
git_vector_swap(&new_entries, &index->entries);
- new_entries_map = git__swap(index->entries_map, new_entries_map);
+ new_entries_map = git_atomic_swap(index->entries_map, new_entries_map);
git_vector_foreach(&remove_entries, i, entry) {
if (index->tree)
@@ -3361,7 +3401,7 @@ int git_index_add_all(
git_pathspec ps;
bool no_fnmatch = (flags & GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH) != 0;
- assert(index);
+ GIT_ASSERT_ARG(index);
repo = INDEX_OWNER(index);
if ((error = git_repository__ensure_not_bare(repo, "index add all")) < 0)
@@ -3447,8 +3487,8 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
payload,
};
- assert(index);
- assert(action == INDEX_ACTION_UPDATE || action == INDEX_ACTION_ADDALL);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(action == INDEX_ACTION_UPDATE || action == INDEX_ACTION_ADDALL);
repo = INDEX_OWNER(index);
@@ -3502,7 +3542,7 @@ static int index_apply_to_all(
const char *match;
git_buf path = GIT_BUF_INIT;
- assert(index);
+ GIT_ASSERT_ARG(index);
if ((error = git_pathspec__init(&ps, paths)) < 0)
return error;
@@ -3598,7 +3638,7 @@ int git_index_snapshot_new(git_vector *snap, git_index *index)
GIT_REFCOUNT_INC(index);
- git_atomic_inc(&index->readers);
+ git_atomic32_inc(&index->readers);
git_vector_sort(&index->entries);
error = git_vector_dup(snap, &index->entries, index->entries._cmp);
@@ -3613,7 +3653,7 @@ void git_index_snapshot_release(git_vector *snap, git_index *index)
{
git_vector_free(snap);
- git_atomic_dec(&index->readers);
+ git_atomic32_dec(&index->readers);
git_index_free(index);
}
@@ -3716,9 +3756,11 @@ void git_indexwriter_cleanup(git_indexwriter *writer)
/* Deprecated functions */
+#ifndef GIT_DEPRECATE_HARD
int git_index_add_frombuffer(
git_index *index, const git_index_entry *source_entry,
const void *buffer, size_t len)
{
return git_index_add_from_buffer(index, source_entry, buffer, len);
}
+#endif
diff --git a/src/index.h b/src/index.h
index 54402f5..a365867 100644
--- a/src/index.h
+++ b/src/index.h
@@ -33,7 +33,7 @@ struct git_index {
git_idxmap *entries_map;
git_vector deleted; /* deleted entries if readers > 0 */
- git_atomic readers; /* number of active iterators */
+ git_atomic32 readers; /* number of active iterators */
unsigned int on_disk:1;
unsigned int ignore_case:1;
diff --git a/src/indexer.c b/src/indexer.c
index 717549f..d546888 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -24,8 +24,6 @@
#include "zstream.h"
#include "object.h"
-extern git_mutex git__mwindow_mutex;
-
size_t git_indexer__max_objects = UINT32_MAX;
#define UINT31_MAX (0x7FFFFFFF)
@@ -123,10 +121,12 @@ int git_indexer_options_init(git_indexer_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_indexer_init_options(git_indexer_options *opts, unsigned int version)
{
return git_indexer_options_init(opts, version);
}
+#endif
int git_indexer_new(
git_indexer **out,
@@ -150,11 +150,11 @@ int git_indexer_new(
idx->progress_cb = opts.progress_cb;
idx->progress_payload = opts.progress_cb_payload;
idx->mode = mode ? mode : GIT_PACK_FILE_MODE;
- git_hash_ctx_init(&idx->hash_ctx);
- git_hash_ctx_init(&idx->trailer);
git_buf_init(&idx->entry_data, 0);
- if ((error = git_oidmap_new(&idx->expected_oids)) < 0)
+ if ((error = git_hash_ctx_init(&idx->hash_ctx)) < 0 ||
+ (error = git_hash_ctx_init(&idx->trailer)) < 0 ||
+ (error = git_oidmap_new(&idx->expected_oids)) < 0)
goto cleanup;
idx->do_verify = opts.verify;
@@ -237,7 +237,8 @@ static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream)
{
ssize_t read;
- assert(idx && stream);
+ GIT_ASSERT_ARG(idx);
+ GIT_ASSERT_ARG(stream);
do {
if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0)
@@ -260,15 +261,16 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
{
git_mwindow *w = NULL;
- assert(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
+ GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
if (type == GIT_OBJECT_REF_DELTA) {
idx->off += GIT_OID_RAWSZ;
} else {
- off64_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
+ off64_t base_off;
+ int error = get_delta_base(&base_off, idx->pack, &w, &idx->off, type, idx->entry_start);
git_mwindow_close(&w);
- if (base_off < 0)
- return (int)base_off;
+ if (error < 0)
+ return error;
}
return 0;
@@ -279,7 +281,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
{
ssize_t read;
- assert(stream);
+ GIT_ASSERT_ARG(stream);
do {
read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf));
@@ -424,7 +426,10 @@ static int store_object(git_indexer *idx)
pentry = git__calloc(1, sizeof(struct git_pack_entry));
GIT_ERROR_CHECK_ALLOC(pentry);
- git_hash_final(&oid, &idx->hash_ctx);
+ if (git_hash_final(&oid, &idx->hash_ctx)) {
+ git__free(pentry);
+ goto on_error;
+ }
entry_size = idx->off - entry_start;
if (entry_start > UINT31_MAX) {
entry->offset = UINT32_MAX;
@@ -598,6 +603,23 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
{
+#ifdef NO_MMAP
+ size_t remaining_size = size;
+ const char *ptr = (const char *)data;
+
+ /* Handle data size larger that ssize_t */
+ while (remaining_size > 0) {
+ ssize_t nb;
+ HANDLE_EINTR(nb, p_pwrite(idx->pack->mwf.fd, (void *)ptr,
+ remaining_size, offset));
+ if (nb <= 0)
+ return -1;
+
+ ptr += nb;
+ offset += nb;
+ remaining_size -= nb;
+ }
+#else
git_file fd = idx->pack->mwf.fd;
size_t mmap_alignment;
size_t page_offset;
@@ -606,7 +628,8 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
git_map map;
int error;
- assert(data && size);
+ GIT_ASSERT_ARG(data);
+ GIT_ASSERT_ARG(size);
if ((error = git__mmap_alignment(&mmap_alignment)) < 0)
return error;
@@ -621,6 +644,7 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
map_data = (unsigned char *)map.data;
memcpy(map_data + page_offset, data, size);
p_munmap(&map);
+#endif
return 0;
}
@@ -632,7 +656,6 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
size_t page_offset;
off64_t page_start;
off64_t current_size = idx->pack->mwf.size;
- int fd = idx->pack->mwf.fd;
int error;
if (!size)
@@ -649,8 +672,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
page_offset = new_size % mmap_alignment;
page_start = new_size - page_offset;
- if (p_lseek(fd, page_start + mmap_alignment - 1, SEEK_SET) < 0 ||
- p_write(idx->pack->mwf.fd, data, 1) < 0) {
+ if (p_pwrite(idx->pack->mwf.fd, data, 1, page_start + mmap_alignment - 1) < 0) {
git_error_set(GIT_ERROR_OS, "cannot extend packfile '%s'", idx->pack->pack_name);
return -1;
}
@@ -671,7 +693,7 @@ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
return GIT_EBUFS;
if (!idx->have_stream) {
- error = git_packfile_unpack_header(&entry_size, &type, &idx->pack->mwf, &w, &idx->off);
+ error = git_packfile_unpack_header(&entry_size, &type, idx->pack, &w, &idx->off);
if (error == GIT_EBUFS) {
idx->off = entry_start;
return error;
@@ -753,7 +775,9 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
struct git_pack_header *hdr = &idx->hdr;
git_mwindow_file *mwf = &idx->pack->mwf;
- assert(idx && data && stats);
+ GIT_ASSERT_ARG(idx);
+ GIT_ASSERT_ARG(data);
+ GIT_ASSERT_ARG(stats);
if ((error = append_to_pack(idx, data, size)) < 0)
return error;
@@ -807,7 +831,8 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
/* Now that we have data in the pack, let's try to parse it */
/* As the file grows any windows we try to use will be out of date */
- git_mwindow_free_all(mwf);
+ if ((error = git_mwindow_free_all(mwf)) < 0)
+ goto on_error;
while (stats->indexed_objects < idx->nr_objects) {
if ((error = read_stream_object(idx, stats)) != 0) {
@@ -851,16 +876,16 @@ static int index_path(git_buf *path, git_indexer *idx, const char *suffix)
* Rewind the packfile by the trailer, as we might need to fix the
* packfile by injecting objects at the tail and must overwrite it.
*/
-static void seek_back_trailer(git_indexer *idx)
+static int seek_back_trailer(git_indexer *idx)
{
idx->pack->mwf.size -= GIT_OID_RAWSZ;
- git_mwindow_free_all(&idx->pack->mwf);
+ return git_mwindow_free_all(&idx->pack->mwf);
}
static int inject_object(git_indexer *idx, git_oid *id)
{
- git_odb_object *obj;
- struct entry *entry;
+ git_odb_object *obj = NULL;
+ struct entry *entry = NULL;
struct git_pack_entry *pentry = NULL;
git_oid foo = {{0}};
unsigned char hdr[64];
@@ -870,12 +895,14 @@ static int inject_object(git_indexer *idx, git_oid *id)
size_t len, hdr_len;
int error;
- seek_back_trailer(idx);
+ if ((error = seek_back_trailer(idx)) < 0)
+ goto cleanup;
+
entry_start = idx->pack->mwf.size;
- if (git_odb_read(&obj, idx->odb, id) < 0) {
+ if ((error = git_odb_read(&obj, idx->odb, id)) < 0) {
git_error_set(GIT_ERROR_INDEXER, "missing delta bases");
- return -1;
+ goto cleanup;
}
data = git_odb_object_data(obj);
@@ -887,8 +914,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
entry->crc = crc32(0L, Z_NULL, 0);
/* Write out the object header */
- hdr_len = git_packfile__object_header(hdr, len, git_odb_object_type(obj));
- if ((error = append_to_pack(idx, hdr, hdr_len)) < 0)
+ if ((error = git_packfile__object_header(&hdr_len, hdr, len, git_odb_object_type(obj))) < 0 ||
+ (error = append_to_pack(idx, hdr, hdr_len)) < 0)
goto cleanup;
idx->pack->mwf.size += hdr_len;
@@ -944,7 +971,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
unsigned int left = 0;
git_oid base;
- assert(git_vector_length(&idx->deltas) > 0);
+ GIT_ASSERT(git_vector_length(&idx->deltas) > 0);
if (idx->odb == NULL) {
git_error_set(GIT_ERROR_INDEXER, "cannot fix a thin pack without an ODB");
@@ -957,7 +984,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
continue;
curpos = delta->delta_off;
- error = git_packfile_unpack_header(&size, &type, &idx->pack->mwf, &w, &curpos);
+ error = git_packfile_unpack_header(&size, &type, idx->pack, &w, &curpos);
if (error < 0)
return error;
@@ -1075,7 +1102,9 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
* hash_partially() keep the existing trailer out of the
* calculation.
*/
- git_mwindow_free_all(mwf);
+ if (git_mwindow_free_all(mwf) < 0)
+ return -1;
+
idx->inbuf_len = 0;
while (hashed < mwf->size) {
ptr = git_mwindow_open(mwf, &w, hashed, chunk, &left);
@@ -1247,7 +1276,8 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
if (git_filebuf_commit_at(&index_file, filename.ptr) < 0)
goto on_error;
- git_mwindow_free_all(&idx->pack->mwf);
+ if (git_mwindow_free_all(&idx->pack->mwf) < 0)
+ goto on_error;
/* Truncate file to undo rounding up to next page_size in append_to_pack */
if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
@@ -1317,13 +1347,7 @@ void git_indexer_free(git_indexer *idx)
git_vector_free_deep(&idx->deltas);
- if (!git_mutex_lock(&git__mwindow_mutex)) {
- if (!idx->pack_committed)
- git_packfile_close(idx->pack, true);
-
- git_packfile_free(idx->pack);
- git_mutex_unlock(&git__mwindow_mutex);
- }
+ git_packfile_free(idx->pack, !idx->pack_committed);
iter = 0;
while (git_oidmap_iterate((void **) &value, idx->expected_oids, &iter, &key) == 0)
diff --git a/src/integer.h b/src/integer.h
index 067c0be..6327717 100644
--- a/src/integer.h
+++ b/src/integer.h
@@ -43,10 +43,10 @@ GIT_INLINE(int) git__is_ulong(int64_t p)
}
/** @return true if p fits into the range of an int */
-GIT_INLINE(int) git__is_int(long long p)
+GIT_INLINE(int) git__is_int(int64_t p)
{
int r = (int)p;
- return p == (long long)r;
+ return p == (int64_t)r;
}
/* Use clang/gcc compiler intrinsics whenever possible */
@@ -77,6 +77,15 @@ GIT_INLINE(int) git__is_int(long long p)
# define git__sub_int_overflow(out, one, two) \
__builtin_ssub_overflow(one, two, out)
+# define git__add_int64_overflow(out, one, two) \
+ __builtin_add_overflow(one, two, out)
+
+/* clang on 32-bit systems produces an undefined reference to `__mulodi4`. */
+# if !defined(__clang__) || !defined(GIT_ARCH_32)
+# define git__multiply_int64_overflow(out, one, two) \
+ __builtin_mul_overflow(one, two, out)
+# endif
+
/* Use Microsoft's safe integer handling functions where available */
#elif defined(_MSC_VER)
@@ -87,11 +96,17 @@ GIT_INLINE(int) git__is_int(long long p)
(SizeTAdd(one, two, out) != S_OK)
# define git__multiply_sizet_overflow(out, one, two) \
(SizeTMult(one, two, out) != S_OK)
+
#define git__add_int_overflow(out, one, two) \
(IntAdd(one, two, out) != S_OK)
#define git__sub_int_overflow(out, one, two) \
(IntSub(one, two, out) != S_OK)
+#define git__add_int64_overflow(out, one, two) \
+ (LongLongAdd(one, two, out) != S_OK)
+#define git__multiply_int64_overflow(out, one, two) \
+ (LongLongMult(one, two, out) != S_OK)
+
#else
/**
@@ -136,6 +151,68 @@ GIT_INLINE(bool) git__sub_int_overflow(int *out, int one, int two)
return false;
}
+GIT_INLINE(bool) git__add_int64_overflow(int64_t *out, int64_t one, int64_t two)
+{
+ if ((two > 0 && one > (INT64_MAX - two)) ||
+ (two < 0 && one < (INT64_MIN - two)))
+ return true;
+ *out = one + two;
+ return false;
+}
+
+#endif
+
+/* If we could not provide an intrinsic implementation for this, provide a (slow) fallback. */
+#if !defined(git__multiply_int64_overflow)
+GIT_INLINE(bool) git__multiply_int64_overflow(int64_t *out, int64_t one, int64_t two)
+{
+ /*
+ * Detects whether `INT64_MAX < (one * two) || INT64_MIN > (one * two)`,
+ * without incurring in undefined behavior. That is done by performing the
+ * comparison with a division instead of a multiplication, which translates
+ * to `INT64_MAX / one < two || INT64_MIN / one > two`. Some caveats:
+ *
+ * - The comparison sign is inverted when both sides of the inequality are
+ * multiplied/divided by a negative number, so if `one < 0` the comparison
+ * needs to be flipped.
+ * - `INT64_MAX / -1` itself overflows (or traps), so that case should be
+ * avoided.
+ * - Since the overflow flag is defined as the discrepance between the result
+ * of performing the multiplication in a signed integer at twice the width
+ * of the operands, and the truncated+sign-extended version of that same
+ * result, there are four cases where the result is the opposite of what
+ * would be expected:
+ * * `INT64_MIN * -1` / `-1 * INT64_MIN`
+ * * `INT64_MIN * 1 / `1 * INT64_MIN`
+ */
+ if (one && two) {
+ if (one > 0 && two > 0) {
+ if (INT64_MAX / one < two)
+ return true;
+ } else if (one < 0 && two < 0) {
+ if ((one == -1 && two == INT64_MIN) ||
+ (two == -1 && one == INT64_MIN)) {
+ *out = INT64_MIN;
+ return false;
+ }
+ if (INT64_MAX / one > two)
+ return true;
+ } else if (one > 0 && two < 0) {
+ if ((one == 1 && two == INT64_MIN) ||
+ (INT64_MIN / one > two))
+ return true;
+ } else if (one == -1) {
+ if (INT64_MIN / two > one)
+ return true;
+ } else {
+ if ((one == INT64_MIN && two == 1) ||
+ (INT64_MIN / one < two))
+ return true;
+ }
+ }
+ *out = one * two;
+ return false;
+}
#endif
#endif
diff --git a/src/iterator.c b/src/iterator.c
index e26e2c0..ce9f305 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -330,7 +330,7 @@ static iterator_pathlist_search_t iterator_pathlist_search(
break;
/* an exact match would have been matched by the bsearch above */
- assert(p[path_len]);
+ GIT_ASSERT_WITH_RETVAL(p[path_len], ITERATOR_PATHLIST_NONE);
/* is this a literal directory entry (eg `foo/`) or a file beneath */
if (p[path_len] == '/') {
@@ -678,14 +678,14 @@ done:
return error;
}
-static void tree_iterator_frame_pop(tree_iterator *iter)
+static int tree_iterator_frame_pop(tree_iterator *iter)
{
tree_iterator_frame *frame;
git_buf *buf = NULL;
git_tree *tree;
size_t i;
- assert(iter->frames.size);
+ GIT_ASSERT(iter->frames.size);
frame = git_array_pop(iter->frames);
@@ -705,6 +705,8 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
git_vector_free(&frame->similar_trees);
git_buf_dispose(&frame->path);
+
+ return 0;
}
static int tree_iterator_current(
@@ -760,7 +762,9 @@ static int tree_iterator_advance(const git_index_entry **out, git_iterator *i)
/* no more entries in this frame. pop the frame out */
if (frame->next_idx == frame->entries.length) {
- tree_iterator_frame_pop(iter);
+ if ((error = tree_iterator_frame_pop(iter)) < 0)
+ break;
+
continue;
}
@@ -838,7 +842,7 @@ static int tree_iterator_advance_into(
const git_index_entry **out, git_iterator *i)
{
tree_iterator *iter = (tree_iterator *)i;
- tree_iterator_frame *frame;
+ tree_iterator_frame *frame;
tree_iterator_entry *prev_entry;
int error;
@@ -855,7 +859,7 @@ static int tree_iterator_advance_into(
* we will have pushed a new (empty) frame on to the stack for this
* new directory. since it's empty, its current_entry should be null.
*/
- assert(iterator__do_autoexpand(i) ^ (prev_entry != NULL));
+ GIT_ASSERT(iterator__do_autoexpand(i) ^ (prev_entry != NULL));
if (prev_entry) {
if (!git_tree_entry__is_tree(prev_entry->tree_entry))
@@ -897,9 +901,8 @@ static int tree_iterator_init(tree_iterator *iter)
{
int error;
- git_pool_init(&iter->entry_pool, sizeof(tree_iterator_entry));
-
- if ((error = tree_iterator_frame_init(iter, iter->root, NULL)) < 0)
+ if ((error = git_pool_init(&iter->entry_pool, sizeof(tree_iterator_entry))) < 0 ||
+ (error = tree_iterator_frame_init(iter, iter->root, NULL)) < 0)
return error;
iter->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS;
@@ -974,7 +977,7 @@ int git_iterator_current_tree_entry(
tree_iterator_frame *frame;
tree_iterator_entry *entry;
- assert(i->type == GIT_ITERATOR_TREE);
+ GIT_ASSERT(i->type == GIT_ITERATOR_TREE);
iter = (tree_iterator *)i;
@@ -991,11 +994,11 @@ int git_iterator_current_parent_tree(
tree_iterator *iter;
tree_iterator_frame *frame;
- assert(i->type == GIT_ITERATOR_TREE);
+ GIT_ASSERT(i->type == GIT_ITERATOR_TREE);
iter = (tree_iterator *)i;
- assert(depth < iter->frames.size);
+ GIT_ASSERT(depth < iter->frames.size);
frame = &iter->frames.ptr[iter->frames.size-depth-1];
*parent_tree = frame->tree;
@@ -1275,7 +1278,8 @@ static int filesystem_iterator_entry_hash(
return git_repository_hashfile(&entry->id,
iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
- if (!(error = git_buf_joinpath(&fullpath, iter->root, entry->path)))
+ if (!(error = git_buf_joinpath(&fullpath, iter->root, entry->path)) &&
+ !(error = git_path_validate_workdir_buf(iter->base.repo, &fullpath)))
error = git_odb_hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB);
git_buf_dispose(&fullpath);
@@ -1356,7 +1360,8 @@ static int filesystem_iterator_frame_push(
else
git_buf_puts(&root, iter->root);
- if (git_buf_oom(&root)) {
+ if (git_buf_oom(&root) ||
+ git_path_validate_workdir_buf(iter->base.repo, &root) < 0) {
error = -1;
goto done;
}
@@ -1376,7 +1381,8 @@ static int filesystem_iterator_frame_push(
filesystem_iterator_entry_cmp)) < 0)
goto done;
- git_pool_init(&new_frame->entry_pool, 1);
+ if ((error = git_pool_init(&new_frame->entry_pool, 1)) < 0)
+ goto done;
/* check if this directory is ignored */
filesystem_iterator_frame_push_ignores(iter, frame_entry, new_frame);
@@ -1385,10 +1391,11 @@ static int filesystem_iterator_frame_push(
iterator_pathlist_search_t pathlist_match = ITERATOR_PATHLIST_FULL;
bool dir_expected = false;
- if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0)
+ if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0 ||
+ (error = git_path_validate_workdir_with_len(iter->base.repo, path, path_len)) < 0)
goto done;
- assert(path_len > iter->root_len);
+ GIT_ASSERT(path_len > iter->root_len);
/* remove the prefix if requested */
path += iter->root_len;
@@ -1469,17 +1476,19 @@ done:
return error;
}
-GIT_INLINE(void) filesystem_iterator_frame_pop(filesystem_iterator *iter)
+GIT_INLINE(int) filesystem_iterator_frame_pop(filesystem_iterator *iter)
{
filesystem_iterator_frame *frame;
- assert(iter->frames.size);
+ GIT_ASSERT(iter->frames.size);
frame = git_array_pop(iter->frames);
filesystem_iterator_frame_pop_ignores(iter);
git_pool_clear(&frame->entry_pool);
git_vector_free(&frame->entries);
+
+ return 0;
}
static void filesystem_iterator_set_current(
@@ -1556,7 +1565,8 @@ static int filesystem_iterator_is_dir(
}
if ((error = git_buf_joinpath(&fullpath, iter->root, entry->path)) < 0 ||
- (error = p_stat(fullpath.ptr, &st)) < 0)
+ (error = git_path_validate_workdir_buf(iter->base.repo, &fullpath)) < 0 ||
+ (error = p_stat(fullpath.ptr, &st)) < 0)
goto done;
*is_dir = S_ISDIR(st.st_mode);
@@ -1646,7 +1656,7 @@ static int filesystem_iterator_advance_into(
* we will have pushed a new (empty) frame on to the stack for this
* new directory. since it's empty, its current_entry should be null.
*/
- assert(iterator__do_autoexpand(i) ^ (prev_entry != NULL));
+ GIT_ASSERT(iterator__do_autoexpand(i) ^ (prev_entry != NULL));
if (prev_entry) {
if (prev_entry->st.st_mode != GIT_FILEMODE_COMMIT &&
@@ -1762,12 +1772,13 @@ static int filesystem_iterator_advance_over(
*out = NULL;
*status = GIT_ITERATOR_STATUS_NORMAL;
- assert(iterator__has_been_accessed(i));
+ GIT_ASSERT(iterator__has_been_accessed(i));
current_frame = filesystem_iterator_current_frame(iter);
- assert(current_frame);
+ GIT_ASSERT(current_frame);
+
current_entry = filesystem_iterator_current_entry(current_frame);
- assert(current_entry);
+ GIT_ASSERT(current_entry);
if ((error = git_iterator_current(&entry, i)) < 0)
return error;
@@ -2065,8 +2076,8 @@ static bool index_iterator_create_pseudotree(
static int index_iterator_skip_pseudotree(index_iterator *iter)
{
- assert(iterator__has_been_accessed(&iter->base));
- assert(S_ISDIR(iter->entry->mode));
+ GIT_ASSERT(iterator__has_been_accessed(&iter->base));
+ GIT_ASSERT(S_ISDIR(iter->entry->mode));
while (true) {
const git_index_entry *next_entry = NULL;
@@ -2280,10 +2291,11 @@ int git_iterator_reset_range(
return i->cb->reset(i);
}
-void git_iterator_set_ignore_case(git_iterator *i, bool ignore_case)
+int git_iterator_set_ignore_case(git_iterator *i, bool ignore_case)
{
- assert(!iterator__has_been_accessed(i));
+ GIT_ASSERT(!iterator__has_been_accessed(i));
iterator_set_ignore_case(i, ignore_case);
+ return 0;
}
void git_iterator_free(git_iterator *iter)
diff --git a/src/iterator.h b/src/iterator.h
index ebd6936..30465df 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -263,7 +263,7 @@ GIT_INLINE(bool) git_iterator_ignore_case(git_iterator *iter)
return ((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0);
}
-extern void git_iterator_set_ignore_case(
+extern int git_iterator_set_ignore_case(
git_iterator *iter, bool ignore_case);
extern int git_iterator_current_tree_entry(
diff --git a/src/khash.h b/src/khash.h
index 40e2d18..7adccdb 100644
--- a/src/khash.h
+++ b/src/khash.h
@@ -131,17 +131,8 @@ int main() {
/* compiler specific configuration */
-#if UINT_MAX == 0xffffffffu
-typedef unsigned int khint32_t;
-#elif ULONG_MAX == 0xffffffffu
-typedef unsigned long khint32_t;
-#endif
-
-#if ULONG_MAX == ULLONG_MAX
-typedef unsigned long khint64_t;
-#else
-typedef unsigned long long khint64_t;
-#endif
+typedef uint32_t khint32_t;
+typedef uint64_t khint64_t;
#ifndef kh_inline
#ifdef _MSC_VER
diff --git a/src/libgit2.c b/src/libgit2.c
new file mode 100644
index 0000000..aee9cf2
--- /dev/null
+++ b/src/libgit2.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "libgit2.h"
+
+#include <git2.h>
+#include "alloc.h"
+#include "cache.h"
+#include "common.h"
+#include "filter.h"
+#include "hash.h"
+#include "index.h"
+#include "merge_driver.h"
+#include "pool.h"
+#include "mwindow.h"
+#include "object.h"
+#include "odb.h"
+#include "refs.h"
+#include "runtime.h"
+#include "sysdir.h"
+#include "thread.h"
+#include "threadstate.h"
+#include "git2/global.h"
+#include "streams/registry.h"
+#include "streams/mbedtls.h"
+#include "streams/openssl.h"
+#include "transports/smart.h"
+#include "transports/http.h"
+#include "transports/ssh.h"
+
+#ifdef GIT_WIN32
+# include "win32/w32_leakcheck.h"
+#endif
+
+/* Declarations for tuneable settings */
+extern size_t git_mwindow__window_size;
+extern size_t git_mwindow__mapped_limit;
+extern size_t git_mwindow__file_limit;
+extern size_t git_indexer__max_objects;
+extern bool git_disable_pack_keep_file_checks;
+extern int git_odb__packed_priority;
+extern int git_odb__loose_priority;
+
+char *git__user_agent;
+char *git__ssl_ciphers;
+
+static void libgit2_settings_global_shutdown(void)
+{
+ git__free(git__user_agent);
+ git__free(git__ssl_ciphers);
+}
+
+static int git_libgit2_settings_global_init(void)
+{
+ return git_runtime_shutdown_register(libgit2_settings_global_shutdown);
+}
+
+int git_libgit2_init(void)
+{
+ static git_runtime_init_fn init_fns[] = {
+#ifdef GIT_WIN32
+ git_win32_leakcheck_global_init,
+#endif
+ git_allocator_global_init,
+ git_threadstate_global_init,
+ git_threads_global_init,
+ git_hash_global_init,
+ git_sysdir_global_init,
+ git_filter_global_init,
+ git_merge_driver_global_init,
+ git_transport_ssh_global_init,
+ git_stream_registry_global_init,
+ git_openssl_stream_global_init,
+ git_mbedtls_stream_global_init,
+ git_mwindow_global_init,
+ git_pool_global_init,
+ git_libgit2_settings_global_init
+ };
+
+ return git_runtime_init(init_fns, ARRAY_SIZE(init_fns));
+}
+
+int git_libgit2_init_count(void)
+{
+ return git_runtime_init_count();
+}
+
+int git_libgit2_shutdown(void)
+{
+ return git_runtime_shutdown();
+}
+
+int git_libgit2_version(int *major, int *minor, int *rev)
+{
+ *major = LIBGIT2_VER_MAJOR;
+ *minor = LIBGIT2_VER_MINOR;
+ *rev = LIBGIT2_VER_REVISION;
+
+ return 0;
+}
+
+int git_libgit2_features(void)
+{
+ return 0
+#ifdef GIT_THREADS
+ | GIT_FEATURE_THREADS
+#endif
+#ifdef GIT_HTTPS
+ | GIT_FEATURE_HTTPS
+#endif
+#if defined(GIT_SSH)
+ | GIT_FEATURE_SSH
+#endif
+#if defined(GIT_USE_NSEC)
+ | GIT_FEATURE_NSEC
+#endif
+ ;
+}
+
+static int config_level_to_sysdir(int *out, int config_level)
+{
+ switch (config_level) {
+ case GIT_CONFIG_LEVEL_SYSTEM:
+ *out = GIT_SYSDIR_SYSTEM;
+ return 0;
+ case GIT_CONFIG_LEVEL_XDG:
+ *out = GIT_SYSDIR_XDG;
+ return 0;
+ case GIT_CONFIG_LEVEL_GLOBAL:
+ *out = GIT_SYSDIR_GLOBAL;
+ return 0;
+ case GIT_CONFIG_LEVEL_PROGRAMDATA:
+ *out = GIT_SYSDIR_PROGRAMDATA;
+ return 0;
+ default:
+ break;
+ }
+
+ git_error_set(
+ GIT_ERROR_INVALID, "invalid config path selector %d", config_level);
+ return -1;
+}
+
+const char *git_libgit2__user_agent(void)
+{
+ return git__user_agent;
+}
+
+const char *git_libgit2__ssl_ciphers(void)
+{
+ return git__ssl_ciphers;
+}
+
+int git_libgit2_opts(int key, ...)
+{
+ int error = 0;
+ va_list ap;
+
+ va_start(ap, key);
+
+ switch (key) {
+ case GIT_OPT_SET_MWINDOW_SIZE:
+ git_mwindow__window_size = va_arg(ap, size_t);
+ break;
+
+ case GIT_OPT_GET_MWINDOW_SIZE:
+ *(va_arg(ap, size_t *)) = git_mwindow__window_size;
+ break;
+
+ case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT:
+ git_mwindow__mapped_limit = va_arg(ap, size_t);
+ break;
+
+ case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT:
+ *(va_arg(ap, size_t *)) = git_mwindow__mapped_limit;
+ break;
+
+ case GIT_OPT_SET_MWINDOW_FILE_LIMIT:
+ git_mwindow__file_limit = va_arg(ap, size_t);
+ break;
+
+ case GIT_OPT_GET_MWINDOW_FILE_LIMIT:
+ *(va_arg(ap, size_t *)) = git_mwindow__file_limit;
+ break;
+
+ case GIT_OPT_GET_SEARCH_PATH:
+ {
+ int sysdir = va_arg(ap, int);
+ git_buf *out = va_arg(ap, git_buf *);
+ const git_buf *tmp;
+ int level;
+
+ if ((error = config_level_to_sysdir(&level, sysdir)) < 0 ||
+ (error = git_buf_sanitize(out)) < 0 ||
+ (error = git_sysdir_get(&tmp, level)) < 0)
+ break;
+
+ error = git_buf_sets(out, tmp->ptr);
+ }
+ break;
+
+ case GIT_OPT_SET_SEARCH_PATH:
+ {
+ int level;
+
+ if ((error = config_level_to_sysdir(&level, va_arg(ap, int))) >= 0)
+ error = git_sysdir_set(level, va_arg(ap, const char *));
+ }
+ break;
+
+ case GIT_OPT_SET_CACHE_OBJECT_LIMIT:
+ {
+ git_object_t type = (git_object_t)va_arg(ap, int);
+ size_t size = va_arg(ap, size_t);
+ error = git_cache_set_max_object_size(type, size);
+ break;
+ }
+
+ case GIT_OPT_SET_CACHE_MAX_SIZE:
+ git_cache__max_storage = va_arg(ap, ssize_t);
+ break;
+
+ case GIT_OPT_ENABLE_CACHING:
+ git_cache__enabled = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_GET_CACHED_MEMORY:
+ *(va_arg(ap, ssize_t *)) = git_cache__current_storage.val;
+ *(va_arg(ap, ssize_t *)) = git_cache__max_storage;
+ break;
+
+ case GIT_OPT_GET_TEMPLATE_PATH:
+ {
+ git_buf *out = va_arg(ap, git_buf *);
+ const git_buf *tmp;
+
+ if ((error = git_buf_sanitize(out)) < 0 ||
+ (error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0)
+ break;
+
+ error = git_buf_sets(out, tmp->ptr);
+ }
+ break;
+
+ case GIT_OPT_SET_TEMPLATE_PATH:
+ error = git_sysdir_set(GIT_SYSDIR_TEMPLATE, va_arg(ap, const char *));
+ break;
+
+ case GIT_OPT_SET_SSL_CERT_LOCATIONS:
+#ifdef GIT_OPENSSL
+ {
+ const char *file = va_arg(ap, const char *);
+ const char *path = va_arg(ap, const char *);
+ error = git_openssl__set_cert_location(file, path);
+ }
+#elif defined(GIT_MBEDTLS)
+ {
+ const char *file = va_arg(ap, const char *);
+ const char *path = va_arg(ap, const char *);
+ if (file)
+ error = git_mbedtls__set_cert_location(file, 0);
+ if (error && path)
+ error = git_mbedtls__set_cert_location(path, 1);
+ }
+#else
+ git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support certificate locations");
+ error = -1;
+#endif
+ break;
+ case GIT_OPT_SET_USER_AGENT:
+ git__free(git__user_agent);
+ git__user_agent = git__strdup(va_arg(ap, const char *));
+ if (!git__user_agent) {
+ git_error_set_oom();
+ error = -1;
+ }
+
+ break;
+
+ case GIT_OPT_ENABLE_STRICT_OBJECT_CREATION:
+ git_object__strict_input_validation = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION:
+ git_reference__enable_symbolic_ref_target_validation = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_SET_SSL_CIPHERS:
+#if (GIT_OPENSSL || GIT_MBEDTLS)
+ {
+ git__free(git__ssl_ciphers);
+ git__ssl_ciphers = git__strdup(va_arg(ap, const char *));
+ if (!git__ssl_ciphers) {
+ git_error_set_oom();
+ error = -1;
+ }
+ }
+#else
+ git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support custom ciphers");
+ error = -1;
+#endif
+ break;
+
+ case GIT_OPT_GET_USER_AGENT:
+ {
+ git_buf *out = va_arg(ap, git_buf *);
+ if ((error = git_buf_sanitize(out)) < 0)
+ break;
+ error = git_buf_sets(out, git__user_agent);
+ }
+ break;
+
+ case GIT_OPT_ENABLE_OFS_DELTA:
+ git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_ENABLE_FSYNC_GITDIR:
+ git_repository__fsync_gitdir = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_GET_WINDOWS_SHAREMODE:
+#ifdef GIT_WIN32
+ *(va_arg(ap, unsigned long *)) = git_win32__createfile_sharemode;
+#endif
+ break;
+
+ case GIT_OPT_SET_WINDOWS_SHAREMODE:
+#ifdef GIT_WIN32
+ git_win32__createfile_sharemode = va_arg(ap, unsigned long);
+#endif
+ break;
+
+ case GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION:
+ git_odb__strict_hash_verification = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_SET_ALLOCATOR:
+ error = git_allocator_setup(va_arg(ap, git_allocator *));
+ break;
+
+ case GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY:
+ git_index__enforce_unsaved_safety = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_SET_PACK_MAX_OBJECTS:
+ git_indexer__max_objects = va_arg(ap, size_t);
+ break;
+
+ case GIT_OPT_GET_PACK_MAX_OBJECTS:
+ *(va_arg(ap, size_t *)) = git_indexer__max_objects;
+ break;
+
+ case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS:
+ git_disable_pack_keep_file_checks = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE:
+ git_http__expect_continue = (va_arg(ap, int) != 0);
+ break;
+
+ case GIT_OPT_SET_ODB_PACKED_PRIORITY:
+ git_odb__packed_priority = va_arg(ap, int);
+ break;
+
+ case GIT_OPT_SET_ODB_LOOSE_PRIORITY:
+ git_odb__loose_priority = va_arg(ap, int);
+ break;
+
+ default:
+ git_error_set(GIT_ERROR_INVALID, "invalid option key");
+ error = -1;
+ }
+
+ va_end(ap);
+
+ return error;
+}
diff --git a/src/libgit2.h b/src/libgit2.h
new file mode 100644
index 0000000..a898367
--- /dev/null
+++ b/src/libgit2.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_libgit2_h__
+#define INCLUDE_libgit2_h__
+
+extern int git_libgit2_init_count(void);
+
+extern const char *git_libgit2__user_agent(void);
+extern const char *git_libgit2__ssl_ciphers(void);
+
+#endif
diff --git a/src/mailmap.c b/src/mailmap.c
index 409cdbd..b69d55e 100644
--- a/src/mailmap.c
+++ b/src/mailmap.c
@@ -43,7 +43,8 @@ static int mailmap_entry_cmp(const void *a_raw, const void *b_raw)
const git_mailmap_entry *b = (const git_mailmap_entry *)b_raw;
int cmp;
- assert(a && b && a->replace_email && b->replace_email);
+ GIT_ASSERT_ARG(a && a->replace_email);
+ GIT_ASSERT_ARG(b && b->replace_email);
cmp = git__strcmp(a->replace_email, b->replace_email);
if (cmp)
@@ -185,7 +186,8 @@ static int mailmap_add_entry_unterminated(
git_mailmap_entry *entry = git__calloc(1, sizeof(git_mailmap_entry));
GIT_ERROR_CHECK_ALLOC(entry);
- assert(mm && replace_email && *replace_email);
+ GIT_ASSERT_ARG(mm);
+ GIT_ASSERT_ARG(replace_email && *replace_email);
if (real_name_size > 0) {
entry->real_name = git__substrdup(real_name, real_name_size);
@@ -290,7 +292,8 @@ static int mailmap_add_blob(
git_buf content = GIT_BUF_INIT;
int error;
- assert(mm && repo);
+ GIT_ASSERT_ARG(mm);
+ GIT_ASSERT_ARG(repo);
error = git_revparse_single(&object, repo, rev);
if (error < 0)
@@ -327,6 +330,10 @@ static int mailmap_add_file_ondisk(
if (error < 0)
goto cleanup;
+ error = git_path_validate_workdir_buf(repo, &fullpath);
+ if (error < 0)
+ goto cleanup;
+
error = git_futils_readbuffer(&content, fullpath.ptr);
if (error < 0)
goto cleanup;
@@ -350,8 +357,6 @@ static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
const char *rev = NULL;
const char *path = NULL;
- assert(mm && repo);
-
/* If we're in a bare repo, default blob to 'HEAD:.mailmap' */
if (repo->is_bare)
rev = MM_BLOB_DEFAULT;
@@ -389,9 +394,14 @@ static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
int git_mailmap_from_repository(git_mailmap **out, git_repository *repo)
{
- int error = git_mailmap_new(out);
- if (error < 0)
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+
+ if ((error = git_mailmap_new(out)) < 0)
return error;
+
mailmap_add_from_repository(*out, repo);
return 0;
}
@@ -408,7 +418,7 @@ const git_mailmap_entry *git_mailmap_entry_lookup(
git_mailmap_entry needle = { NULL };
needle.replace_email = (char *)email;
- assert(email);
+ GIT_ASSERT_ARG_WITH_RETVAL(email, NULL);
if (!mm)
return NULL;
@@ -431,7 +441,8 @@ const git_mailmap_entry *git_mailmap_entry_lookup(
if (git__strcmp(entry->replace_email, email))
break; /* it's a different email, so we're done looking */
- assert(entry->replace_name); /* should be specific */
+ /* should be specific */
+ GIT_ASSERT_WITH_RETVAL(entry->replace_name, NULL);
if (!name || !git__strcmp(entry->replace_name, name))
return entry;
}
@@ -447,7 +458,9 @@ int git_mailmap_resolve(
const char *name, const char *email)
{
const git_mailmap_entry *entry = NULL;
- assert(name && email);
+
+ GIT_ASSERT(name);
+ GIT_ASSERT(email);
*real_name = name;
*real_email = email;
diff --git a/src/map.h b/src/map.h
index 6328d8c..01931d1 100644
--- a/src/map.h
+++ b/src/map.h
@@ -36,9 +36,9 @@ typedef struct { /* memory mapped buffer */
} git_map;
#define GIT_MMAP_VALIDATE(out, len, prot, flags) do { \
- assert(out != NULL && len > 0); \
- assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \
- assert((flags & GIT_MAP_FIXED) == 0); } while (0)
+ GIT_ASSERT(out != NULL && len > 0); \
+ GIT_ASSERT((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \
+ GIT_ASSERT((flags & GIT_MAP_FIXED) == 0); } while (0)
extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset);
extern int p_munmap(git_map *map);
diff --git a/src/merge.c b/src/merge.c
index 05a776e..0e4bb58 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -68,9 +68,19 @@ struct merge_diff_df_data {
git_merge_diff *prev_conflict;
};
+/*
+ * This acts as a negative cache entry marker. In case we've tried to calculate
+ * similarity metrics for a given blob already but `git_hashsig` determined
+ * that it's too small in order to have a meaningful hash signature, we will
+ * insert the address of this marker instead of `NULL`. Like this, we can
+ * easily check whether we have checked a gien entry already and skip doing the
+ * calculation again and again.
+ */
+static int cache_invalid_marker;
+
/* Merge base computation */
-int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[])
+static int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[])
{
git_revwalk *walk = NULL;
git_vector list;
@@ -102,7 +112,7 @@ int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_reposito
if (commit == NULL)
goto on_error;
- if (git_merge__bases_many(&result, walk, commit, &list) < 0)
+ if (git_merge__bases_many(&result, walk, commit, &list, 0) < 0)
goto on_error;
if (!result) {
@@ -129,7 +139,9 @@ int git_merge_base_many(git_oid *out, git_repository *repo, size_t length, const
git_commit_list *result = NULL;
int error = 0;
- assert(out && repo && input_array);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(input_array);
if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0)
return error;
@@ -149,7 +161,9 @@ int git_merge_bases_many(git_oidarray *out, git_repository *repo, size_t length,
int error = 0;
git_array_oid_t array;
- assert(out && repo && input_array);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(input_array);
if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0)
return error;
@@ -183,7 +197,9 @@ int git_merge_base_octopus(git_oid *out, git_repository *repo, size_t length, co
unsigned int i;
int error = -1;
- assert(out && repo && input_array);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(input_array);
if (length < 2) {
git_error_set(GIT_ERROR_INVALID, "at least two commits are required to find an ancestor");
@@ -227,7 +243,7 @@ static int merge_bases(git_commit_list **out, git_revwalk **walk_out, git_reposi
if (commit == NULL)
goto on_error;
- if (git_merge__bases_many(&result, walk, commit, &list) < 0)
+ if (git_merge__bases_many(&result, walk, commit, &list, 0) < 0)
goto on_error;
if (!result) {
@@ -362,7 +378,11 @@ static int clear_commit_marks(git_commit_list_node *commit, unsigned int mark)
}
static int paint_down_to_common(
- git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
+ git_commit_list **out,
+ git_revwalk *walk,
+ git_commit_list_node *one,
+ git_vector *twos,
+ uint32_t minimum_generation)
{
git_pqueue list;
git_commit_list *result = NULL;
@@ -371,7 +391,7 @@ static int paint_down_to_common(
int error;
unsigned int i;
- if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0)
+ if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_generation_cmp) < 0)
return -1;
one->flags |= PARENT1;
@@ -383,7 +403,6 @@ static int paint_down_to_common(
return -1;
two->flags |= PARENT2;
-
if (git_pqueue_insert(&list, two) < 0)
return -1;
}
@@ -411,6 +430,8 @@ static int paint_down_to_common(
git_commit_list_node *p = commit->parents[i];
if ((p->flags & flags) == flags)
continue;
+ if (p->generation < minimum_generation)
+ continue;
if ((error = git_commit_list_parse(walk, p)) < 0)
return error;
@@ -426,7 +447,7 @@ static int paint_down_to_common(
return 0;
}
-static int remove_redundant(git_revwalk *walk, git_vector *commits)
+static int remove_redundant(git_revwalk *walk, git_vector *commits, uint32_t minimum_generation)
{
git_vector work = GIT_VECTOR_INIT;
unsigned char *redundant;
@@ -462,7 +483,7 @@ static int remove_redundant(git_revwalk *walk, git_vector *commits)
goto done;
}
- error = paint_down_to_common(&common, walk, commit, &work);
+ error = paint_down_to_common(&common, walk, commit, &work, minimum_generation);
if (error < 0)
goto done;
@@ -494,7 +515,12 @@ done:
return error;
}
-int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos)
+int git_merge__bases_many(
+ git_commit_list **out,
+ git_revwalk *walk,
+ git_commit_list_node *one,
+ git_vector *twos,
+ uint32_t minimum_generation)
{
int error;
unsigned int i;
@@ -516,7 +542,7 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
if (git_commit_list_parse(walk, one) < 0)
return -1;
- error = paint_down_to_common(&result, walk, one, twos);
+ error = paint_down_to_common(&result, walk, one, twos, minimum_generation);
if (error < 0)
return error;
@@ -543,7 +569,7 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
if ((error = clear_commit_marks(one, ALL_FLAGS)) < 0 ||
(error = clear_commit_marks_many(twos, ALL_FLAGS)) < 0 ||
- (error = remove_redundant(walk, &redundant)) < 0) {
+ (error = remove_redundant(walk, &redundant, minimum_generation)) < 0) {
git_vector_free(&redundant);
return error;
}
@@ -571,7 +597,8 @@ int git_repository_mergehead_foreach(
git_oid oid;
int error = 0;
- assert(repo && cb);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(cb);
if ((error = git_buf_joinpath(&merge_head_path, repo->gitdir,
GIT_MERGE_HEAD_FILE)) < 0)
@@ -640,7 +667,9 @@ static int merge_conflict_resolve_trivial(
git_index_entry const *result = NULL;
int error = 0;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -723,7 +752,9 @@ static int merge_conflict_resolve_one_removed(
int ours_changed, theirs_changed;
int error = 0;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -763,7 +794,9 @@ static int merge_conflict_resolve_one_renamed(
git_index_entry *merged;
int error = 0;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -907,7 +940,9 @@ static int merge_conflict_resolve_contents(
bool fallback = false;
int error;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -1027,6 +1062,9 @@ static int index_entry_similarity_calc(
git_object_size_t blobsize;
int error;
+ if (*out || *out == &cache_invalid_marker)
+ return 0;
+
*out = NULL;
if ((error = git_blob_lookup(&blob, repo, &entry->id)) < 0)
@@ -1047,6 +1085,8 @@ static int index_entry_similarity_calc(
error = opts->metric->buffer_signature(out, &diff_file,
git_blob_rawcontent(blob), (size_t)blobsize,
opts->metric->payload);
+ if (error == GIT_EBUFS)
+ *out = &cache_invalid_marker;
git_blob_free(blob);
@@ -1069,18 +1109,16 @@ static int index_entry_similarity_inexact(
return 0;
/* update signature cache if needed */
- if (!cache[a_idx] && (error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0)
- return error;
- if (!cache[b_idx] && (error = index_entry_similarity_calc(&cache[b_idx], repo, b, opts)) < 0)
+ if ((error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0 ||
+ (error = index_entry_similarity_calc(&cache[b_idx], repo, b, opts)) < 0)
return error;
/* some metrics may not wish to process this file (too big / too small) */
- if (!cache[a_idx] || !cache[b_idx])
+ if (cache[a_idx] == &cache_invalid_marker || cache[b_idx] == &cache_invalid_marker)
return 0;
/* compare signatures */
- if (opts->metric->similarity(
- &score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0)
+ if (opts->metric->similarity(&score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0)
return -1;
/* clip score */
@@ -1504,9 +1542,11 @@ int git_merge_diff_list__find_renames(
size_t src_count, tgt_count, i;
int error = 0;
- assert(diff_list && opts);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(opts);
- if ((opts->flags & GIT_MERGE_FIND_RENAMES) == 0)
+ if ((opts->flags & GIT_MERGE_FIND_RENAMES) == 0 ||
+ !diff_list->conflicts.length)
return 0;
similarity_ours = git__calloc(diff_list->conflicts.length,
@@ -1550,7 +1590,7 @@ int git_merge_diff_list__find_renames(
done:
if (cache != NULL) {
for (i = 0; i < cache_size; ++i) {
- if (cache[i] != NULL)
+ if (cache[i] != NULL && cache[i] != &cache_invalid_marker)
opts->metric->free_signature(cache[i], opts->metric->payload);
}
@@ -1797,12 +1837,12 @@ git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo)
diff_list->repo = repo;
- git_pool_init(&diff_list->pool, 1);
- if (git_vector_init(&diff_list->staged, 0, NULL) < 0 ||
- git_vector_init(&diff_list->conflicts, 0, NULL) < 0 ||
- git_vector_init(&diff_list->resolved, 0, NULL) < 0) {
- git_merge_diff_list__free(diff_list);
+ if (git_pool_init(&diff_list->pool, 1) < 0 ||
+ git_vector_init(&diff_list->staged, 0, NULL) < 0 ||
+ git_vector_init(&diff_list->conflicts, 0, NULL) < 0 ||
+ git_vector_init(&diff_list->resolved, 0, NULL) < 0) {
+ git_merge_diff_list__free(diff_list);
return NULL;
}
@@ -1830,7 +1870,8 @@ static int merge_normalize_opts(
git_config_entry *entry = NULL;
int error = 0;
- assert(repo && opts);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(opts);
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
return error;
@@ -2057,7 +2098,8 @@ int git_merge__iterators(
size_t i;
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -2141,7 +2183,8 @@ int git_merge_trees(
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
/* if one side is treesame to the ancestor, take the other side */
if (ancestor_tree && merge_opts && (merge_opts->flags & GIT_MERGE_SKIP_REUC)) {
@@ -2245,8 +2288,11 @@ static int create_virtual_base(
result->type = GIT_ANNOTATED_COMMIT_VIRTUAL;
result->index = index;
- insert_head_ids(&result->parents, one);
- insert_head_ids(&result->parents, two);
+ if (insert_head_ids(&result->parents, one) < 0 ||
+ insert_head_ids(&result->parents, two) < 0) {
+ git_annotated_commit_free(result);
+ return -1;
+ }
*out = result;
return 0;
@@ -2428,7 +2474,8 @@ static int write_merge_head(
size_t i;
int error = 0;
- assert(repo && heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(heads);
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_HEAD_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) < 0)
@@ -2456,7 +2503,7 @@ static int write_merge_mode(git_repository *repo)
git_buf file_path = GIT_BUF_INIT;
int error = 0;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MODE_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) < 0)
@@ -2676,7 +2723,8 @@ static int write_merge_msg(
char sep = 0;
int error = 0;
- assert(repo && heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(heads);
entries = git__calloc(heads_len, sizeof(struct merge_msg_entry));
GIT_ERROR_CHECK_ALLOC(entries);
@@ -2787,7 +2835,9 @@ int git_merge__setup(
{
int error = 0;
- assert (repo && our_head && heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(our_head);
+ GIT_ASSERT_ARG(heads);
if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 &&
(error = write_merge_head(repo, heads, heads_len)) == 0 &&
@@ -2811,7 +2861,9 @@ static int merge_ancestor_head(
size_t i, alloc_len;
int error = 0;
- assert(repo && our_head && their_heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(our_head);
+ GIT_ASSERT_ARG(their_heads);
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1);
oids = git__calloc(alloc_len, sizeof(git_oid));
@@ -2832,7 +2884,7 @@ on_error:
return error;
}
-const char *merge_their_label(const char *branchname)
+static const char *merge_their_label(const char *branchname)
{
const char *slash;
@@ -3189,7 +3241,10 @@ int git_merge_analysis_for_ref(
int error = 0;
bool unborn;
- assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
+ GIT_ASSERT_ARG(analysis_out);
+ GIT_ASSERT_ARG(preference_out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(their_heads && their_heads_len > 0);
if (their_heads_len != 1) {
git_error_set(GIT_ERROR_MERGE, "can only merge a single branch");
@@ -3271,7 +3326,8 @@ int git_merge(
unsigned int checkout_strategy;
int error = 0;
- assert(repo && their_heads && their_heads_len > 0);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(their_heads && their_heads_len > 0);
if (their_heads_len != 1) {
git_error_set(GIT_ERROR_MERGE, "can only merge a single branch");
@@ -3338,10 +3394,12 @@ int git_merge_options_init(git_merge_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_merge_init_options(git_merge_options *opts, unsigned int version)
{
return git_merge_options_init(opts, version);
}
+#endif
int git_merge_file_input_init(git_merge_file_input *input, unsigned int version)
{
@@ -3350,10 +3408,12 @@ int git_merge_file_input_init(git_merge_file_input *input, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_merge_file_init_input(git_merge_file_input *input, unsigned int version)
{
return git_merge_file_input_init(input, version);
}
+#endif
int git_merge_file_options_init(
git_merge_file_options *opts, unsigned int version)
@@ -3363,8 +3423,10 @@ int git_merge_file_options_init(
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_merge_file_init_options(
git_merge_file_options *opts, unsigned int version)
{
return git_merge_file_options_init(opts, version);
}
+#endif
diff --git a/src/merge.h b/src/merge.h
index b0a7de2..3e7f80c 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -129,7 +129,8 @@ int git_merge__bases_many(
git_commit_list **out,
git_revwalk *walk,
git_commit_list_node *one,
- git_vector *twos);
+ git_vector *twos,
+ uint32_t minimum_generation);
/*
* Three-way tree differencing
diff --git a/src/merge_driver.c b/src/merge_driver.c
index 666349b..17c386a 100644
--- a/src/merge_driver.c
+++ b/src/merge_driver.c
@@ -8,7 +8,7 @@
#include "merge_driver.h"
#include "vector.h"
-#include "global.h"
+#include "runtime.h"
#include "merge.h"
#include "git2/merge.h"
#include "git2/sys/merge.h"
@@ -32,33 +32,38 @@ static struct merge_driver_registry merge_driver_registry;
static void git_merge_driver_global_shutdown(void);
-git_repository* git_merge_driver_source_repo(const git_merge_driver_source *src)
+git_repository *git_merge_driver_source_repo(
+ const git_merge_driver_source *src)
{
- assert(src);
+ GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
return src->repo;
}
-const git_index_entry* git_merge_driver_source_ancestor(const git_merge_driver_source *src)
+const git_index_entry *git_merge_driver_source_ancestor(
+ const git_merge_driver_source *src)
{
- assert(src);
+ GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
return src->ancestor;
}
-const git_index_entry* git_merge_driver_source_ours(const git_merge_driver_source *src)
+const git_index_entry *git_merge_driver_source_ours(
+ const git_merge_driver_source *src)
{
- assert(src);
+ GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
return src->ours;
}
-const git_index_entry* git_merge_driver_source_theirs(const git_merge_driver_source *src)
+const git_index_entry *git_merge_driver_source_theirs(
+ const git_merge_driver_source *src)
{
- assert(src);
+ GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
return src->theirs;
}
-const git_merge_file_options* git_merge_driver_source_file_options(const git_merge_driver_source *src)
+const git_merge_file_options *git_merge_driver_source_file_options(
+ const git_merge_driver_source *src)
{
- assert(src);
+ GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
return src->file_opts;
}
@@ -209,7 +214,7 @@ int git_merge_driver_global_init(void)
merge_driver_name__binary, &git_merge_driver__binary)) < 0)
goto done;
- git__on_shutdown(git_merge_driver_global_shutdown);
+ error = git_runtime_shutdown_register(git_merge_driver_global_shutdown);
done:
if (error < 0)
@@ -262,7 +267,8 @@ int git_merge_driver_register(const char *name, git_merge_driver *driver)
{
int error;
- assert(name && driver);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(driver);
if (git_rwlock_wrlock(&merge_driver_registry.lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to lock merge driver registry");
diff --git a/src/merge_file.c b/src/merge_file.c
index 23daa84..bfa3ec5 100644
--- a/src/merge_file.c
+++ b/src/merge_file.c
@@ -28,7 +28,7 @@
#define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0)
-int git_merge_file__input_from_index(
+static int merge_file_input_from_index(
git_merge_file_input *input_out,
git_odb_object **odb_object_out,
git_odb *odb,
@@ -36,7 +36,10 @@ int git_merge_file__input_from_index(
{
int error = 0;
- assert(input_out && odb_object_out && odb && entry);
+ GIT_ASSERT_ARG(input_out);
+ GIT_ASSERT_ARG(odb_object_out);
+ GIT_ASSERT_ARG(odb);
+ GIT_ASSERT_ARG(entry);
if ((error = git_odb_read(odb_object_out, odb, &entry->id)) < 0)
goto done;
@@ -241,7 +244,9 @@ int git_merge_file(
{
git_merge_file_input inputs[3] = { {0} };
- assert(out && ours && theirs);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ours);
+ GIT_ASSERT_ARG(theirs);
memset(out, 0x0, sizeof(git_merge_file_result));
@@ -268,7 +273,10 @@ int git_merge_file_from_index(
git_odb_object *odb_object[3] = { 0 };
int error = 0;
- assert(out && repo && ours && theirs);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(ours);
+ GIT_ASSERT_ARG(theirs);
memset(out, 0x0, sizeof(git_merge_file_result));
@@ -276,17 +284,15 @@ int git_merge_file_from_index(
goto done;
if (ancestor) {
- if ((error = git_merge_file__input_from_index(
+ if ((error = merge_file_input_from_index(
&ancestor_input, &odb_object[0], odb, ancestor)) < 0)
goto done;
ancestor_ptr = &ancestor_input;
}
- if ((error = git_merge_file__input_from_index(
- &our_input, &odb_object[1], odb, ours)) < 0 ||
- (error = git_merge_file__input_from_index(
- &their_input, &odb_object[2], odb, theirs)) < 0)
+ if ((error = merge_file_input_from_index(&our_input, &odb_object[1], odb, ours)) < 0 ||
+ (error = merge_file_input_from_index(&their_input, &odb_object[2], odb, theirs)) < 0)
goto done;
error = merge_file__from_inputs(out,
diff --git a/src/message.c b/src/message.c
index 6c5a237..327b984 100644
--- a/src/message.c
+++ b/src/message.c
@@ -28,8 +28,10 @@ int git_message_prettify(git_buf *message_out, const char *message, int strip_co
int consecutive_empty_lines = 0;
size_t i, line_length, rtrimmed_line_length;
char *next_newline;
+ int error;
- git_buf_sanitize(message_out);
+ if ((error = git_buf_sanitize(message_out)) < 0)
+ return error;
for (i = 0; i < strlen(message); i += line_length) {
next_newline = memchr(message + i, '\n', message_len - i);
diff --git a/src/midx.c b/src/midx.c
new file mode 100644
index 0000000..d6bb9c1
--- /dev/null
+++ b/src/midx.c
@@ -0,0 +1,477 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "midx.h"
+
+#include "buffer.h"
+#include "futils.h"
+#include "hash.h"
+#include "odb.h"
+#include "pack.h"
+
+#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
+#define MIDX_VERSION 1
+#define MIDX_OBJECT_ID_VERSION 1
+struct git_midx_header {
+ uint32_t signature;
+ uint8_t version;
+ uint8_t object_id_version;
+ uint8_t chunks;
+ uint8_t base_midx_files;
+ uint32_t packfiles;
+};
+
+#define MIDX_PACKFILE_NAMES_ID 0x504e414d /* "PNAM" */
+#define MIDX_OID_FANOUT_ID 0x4f494446 /* "OIDF" */
+#define MIDX_OID_LOOKUP_ID 0x4f49444c /* "OIDL" */
+#define MIDX_OBJECT_OFFSETS_ID 0x4f4f4646 /* "OOFF" */
+#define MIDX_OBJECT_LARGE_OFFSETS_ID 0x4c4f4646 /* "LOFF" */
+
+struct git_midx_chunk {
+ off64_t offset;
+ size_t length;
+};
+
+static int midx_error(const char *message)
+{
+ git_error_set(GIT_ERROR_ODB, "invalid multi-pack-index file - %s", message);
+ return -1;
+}
+
+static int midx_parse_packfile_names(
+ git_midx_file *idx,
+ const unsigned char *data,
+ uint32_t packfiles,
+ struct git_midx_chunk *chunk)
+{
+ int error;
+ uint32_t i;
+ char *packfile_name = (char *)(data + chunk->offset);
+ size_t chunk_size = chunk->length, len;
+ if (chunk->offset == 0)
+ return midx_error("missing Packfile Names chunk");
+ if (chunk->length == 0)
+ return midx_error("empty Packfile Names chunk");
+ if ((error = git_vector_init(&idx->packfile_names, packfiles, git__strcmp_cb)) < 0)
+ return error;
+ for (i = 0; i < packfiles; ++i) {
+ len = p_strnlen(packfile_name, chunk_size);
+ if (len == 0)
+ return midx_error("empty packfile name");
+ if (len + 1 > chunk_size)
+ return midx_error("unterminated packfile name");
+ git_vector_insert(&idx->packfile_names, packfile_name);
+ if (i && strcmp(git_vector_get(&idx->packfile_names, i - 1), packfile_name) >= 0)
+ return midx_error("packfile names are not sorted");
+ if (strlen(packfile_name) <= strlen(".idx") || git__suffixcmp(packfile_name, ".idx") != 0)
+ return midx_error("non-.idx packfile name");
+ if (strchr(packfile_name, '/') != NULL || strchr(packfile_name, '\\') != NULL)
+ return midx_error("non-local packfile");
+ packfile_name += len + 1;
+ chunk_size -= len + 1;
+ }
+ return 0;
+}
+
+static int midx_parse_oid_fanout(
+ git_midx_file *idx,
+ const unsigned char *data,
+ struct git_midx_chunk *chunk_oid_fanout)
+{
+ uint32_t i, nr;
+ if (chunk_oid_fanout->offset == 0)
+ return midx_error("missing OID Fanout chunk");
+ if (chunk_oid_fanout->length == 0)
+ return midx_error("empty OID Fanout chunk");
+ if (chunk_oid_fanout->length != 256 * 4)
+ return midx_error("OID Fanout chunk has wrong length");
+
+ idx->oid_fanout = (const uint32_t *)(data + chunk_oid_fanout->offset);
+ nr = 0;
+ for (i = 0; i < 256; ++i) {
+ uint32_t n = ntohl(idx->oid_fanout[i]);
+ if (n < nr)
+ return midx_error("index is non-monotonic");
+ nr = n;
+ }
+ idx->num_objects = nr;
+ return 0;
+}
+
+static int midx_parse_oid_lookup(
+ git_midx_file *idx,
+ const unsigned char *data,
+ struct git_midx_chunk *chunk_oid_lookup)
+{
+ uint32_t i;
+ git_oid *oid, *prev_oid, zero_oid = {{0}};
+
+ if (chunk_oid_lookup->offset == 0)
+ return midx_error("missing OID Lookup chunk");
+ if (chunk_oid_lookup->length == 0)
+ return midx_error("empty OID Lookup chunk");
+ if (chunk_oid_lookup->length != idx->num_objects * GIT_OID_RAWSZ)
+ return midx_error("OID Lookup chunk has wrong length");
+
+ idx->oid_lookup = oid = (git_oid *)(data + chunk_oid_lookup->offset);
+ prev_oid = &zero_oid;
+ for (i = 0; i < idx->num_objects; ++i, ++oid) {
+ if (git_oid_cmp(prev_oid, oid) >= 0)
+ return midx_error("OID Lookup index is non-monotonic");
+ prev_oid = oid;
+ }
+
+ return 0;
+}
+
+static int midx_parse_object_offsets(
+ git_midx_file *idx,
+ const unsigned char *data,
+ struct git_midx_chunk *chunk_object_offsets)
+{
+ if (chunk_object_offsets->offset == 0)
+ return midx_error("missing Object Offsets chunk");
+ if (chunk_object_offsets->length == 0)
+ return midx_error("empty Object Offsets chunk");
+ if (chunk_object_offsets->length != idx->num_objects * 8)
+ return midx_error("Object Offsets chunk has wrong length");
+
+ idx->object_offsets = data + chunk_object_offsets->offset;
+
+ return 0;
+}
+
+static int midx_parse_object_large_offsets(
+ git_midx_file *idx,
+ const unsigned char *data,
+ struct git_midx_chunk *chunk_object_large_offsets)
+{
+ if (chunk_object_large_offsets->length == 0)
+ return 0;
+ if (chunk_object_large_offsets->length % 8 != 0)
+ return midx_error("malformed Object Large Offsets chunk");
+
+ idx->object_large_offsets = data + chunk_object_large_offsets->offset;
+ idx->num_object_large_offsets = chunk_object_large_offsets->length / 8;
+
+ return 0;
+}
+
+int git_midx_parse(
+ git_midx_file *idx,
+ const unsigned char *data,
+ size_t size)
+{
+ struct git_midx_header *hdr;
+ const unsigned char *chunk_hdr;
+ struct git_midx_chunk *last_chunk;
+ uint32_t i;
+ off64_t last_chunk_offset, chunk_offset, trailer_offset;
+ git_oid idx_checksum = {{0}};
+ int error;
+ struct git_midx_chunk chunk_packfile_names = {0},
+ chunk_oid_fanout = {0},
+ chunk_oid_lookup = {0},
+ chunk_object_offsets = {0},
+ chunk_object_large_offsets = {0};
+
+ GIT_ASSERT_ARG(idx);
+
+ if (size < sizeof(struct git_midx_header) + GIT_OID_RAWSZ)
+ return midx_error("multi-pack index is too short");
+
+ hdr = ((struct git_midx_header *)data);
+
+ if (hdr->signature != htonl(MIDX_SIGNATURE) ||
+ hdr->version != MIDX_VERSION ||
+ hdr->object_id_version != MIDX_OBJECT_ID_VERSION) {
+ return midx_error("unsupported multi-pack index version");
+ }
+ if (hdr->chunks == 0)
+ return midx_error("no chunks in multi-pack index");
+
+ /*
+ * The very first chunk's offset should be after the header, all the chunk
+ * headers, and a special zero chunk.
+ */
+ last_chunk_offset =
+ sizeof(struct git_midx_header) +
+ (1 + hdr->chunks) * 12;
+ trailer_offset = size - GIT_OID_RAWSZ;
+ if (trailer_offset < last_chunk_offset)
+ return midx_error("wrong index size");
+ git_oid_cpy(&idx->checksum, (git_oid *)(data + trailer_offset));
+
+ if (git_hash_buf(&idx_checksum, data, (size_t)trailer_offset) < 0)
+ return midx_error("could not calculate signature");
+ if (!git_oid_equal(&idx_checksum, &idx->checksum))
+ return midx_error("index signature mismatch");
+
+ chunk_hdr = data + sizeof(struct git_midx_header);
+ last_chunk = NULL;
+ for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
+ chunk_offset = ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32 |
+ ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 8))));
+ if (chunk_offset < last_chunk_offset)
+ return midx_error("chunks are non-monotonic");
+ if (chunk_offset >= trailer_offset)
+ return midx_error("chunks extend beyond the trailer");
+ if (last_chunk != NULL)
+ last_chunk->length = (size_t)(chunk_offset - last_chunk_offset);
+ last_chunk_offset = chunk_offset;
+
+ switch (ntohl(*((uint32_t *)(chunk_hdr + 0)))) {
+ case MIDX_PACKFILE_NAMES_ID:
+ chunk_packfile_names.offset = last_chunk_offset;
+ last_chunk = &chunk_packfile_names;
+ break;
+
+ case MIDX_OID_FANOUT_ID:
+ chunk_oid_fanout.offset = last_chunk_offset;
+ last_chunk = &chunk_oid_fanout;
+ break;
+
+ case MIDX_OID_LOOKUP_ID:
+ chunk_oid_lookup.offset = last_chunk_offset;
+ last_chunk = &chunk_oid_lookup;
+ break;
+
+ case MIDX_OBJECT_OFFSETS_ID:
+ chunk_object_offsets.offset = last_chunk_offset;
+ last_chunk = &chunk_object_offsets;
+ break;
+
+ case MIDX_OBJECT_LARGE_OFFSETS_ID:
+ chunk_object_large_offsets.offset = last_chunk_offset;
+ last_chunk = &chunk_object_large_offsets;
+ break;
+
+ default:
+ return midx_error("unrecognized chunk ID");
+ }
+ }
+ last_chunk->length = (size_t)(trailer_offset - last_chunk_offset);
+
+ error = midx_parse_packfile_names(
+ idx, data, ntohl(hdr->packfiles), &chunk_packfile_names);
+ if (error < 0)
+ return error;
+ error = midx_parse_oid_fanout(idx, data, &chunk_oid_fanout);
+ if (error < 0)
+ return error;
+ error = midx_parse_oid_lookup(idx, data, &chunk_oid_lookup);
+ if (error < 0)
+ return error;
+ error = midx_parse_object_offsets(idx, data, &chunk_object_offsets);
+ if (error < 0)
+ return error;
+ error = midx_parse_object_large_offsets(idx, data, &chunk_object_large_offsets);
+ if (error < 0)
+ return error;
+
+ return 0;
+}
+
+int git_midx_open(
+ git_midx_file **idx_out,
+ const char *path)
+{
+ git_midx_file *idx;
+ git_file fd = -1;
+ size_t idx_size;
+ struct stat st;
+ int error;
+
+ /* TODO: properly open the file without access time using O_NOATIME */
+ fd = git_futils_open_ro(path);
+ if (fd < 0)
+ return fd;
+
+ if (p_fstat(fd, &st) < 0) {
+ p_close(fd);
+ git_error_set(GIT_ERROR_ODB, "multi-pack-index file not found - '%s'", path);
+ return -1;
+ }
+
+ if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)) {
+ p_close(fd);
+ git_error_set(GIT_ERROR_ODB, "invalid pack index '%s'", path);
+ return -1;
+ }
+ idx_size = (size_t)st.st_size;
+
+ idx = git__calloc(1, sizeof(git_midx_file));
+ GIT_ERROR_CHECK_ALLOC(idx);
+
+ error = git_buf_sets(&idx->filename, path);
+ if (error < 0)
+ return error;
+
+ error = git_futils_mmap_ro(&idx->index_map, fd, 0, idx_size);
+ p_close(fd);
+ if (error < 0) {
+ git_midx_free(idx);
+ return error;
+ }
+
+ if ((error = git_midx_parse(idx, idx->index_map.data, idx_size)) < 0) {
+ git_midx_free(idx);
+ return error;
+ }
+
+ *idx_out = idx;
+ return 0;
+}
+
+bool git_midx_needs_refresh(
+ const git_midx_file *idx,
+ const char *path)
+{
+ git_file fd = -1;
+ struct stat st;
+ ssize_t bytes_read;
+ git_oid idx_checksum = {{0}};
+
+ /* TODO: properly open the file without access time using O_NOATIME */
+ fd = git_futils_open_ro(path);
+ if (fd < 0)
+ return true;
+
+ if (p_fstat(fd, &st) < 0) {
+ p_close(fd);
+ return true;
+ }
+
+ if (!S_ISREG(st.st_mode) ||
+ !git__is_sizet(st.st_size) ||
+ (size_t)st.st_size != idx->index_map.len) {
+ p_close(fd);
+ return true;
+ }
+
+ bytes_read = p_pread(fd, &idx_checksum, GIT_OID_RAWSZ, st.st_size - GIT_OID_RAWSZ);
+ p_close(fd);
+
+ if (bytes_read != GIT_OID_RAWSZ)
+ return true;
+
+ return !git_oid_equal(&idx_checksum, &idx->checksum);
+}
+
+int git_midx_entry_find(
+ git_midx_entry *e,
+ git_midx_file *idx,
+ const git_oid *short_oid,
+ size_t len)
+{
+ int pos, found = 0;
+ size_t pack_index;
+ uint32_t hi, lo;
+ const git_oid *current = NULL;
+ const unsigned char *object_offset;
+ off64_t offset;
+
+ GIT_ASSERT_ARG(idx);
+
+ hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]);
+ lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
+
+ pos = git_pack__lookup_sha1(idx->oid_lookup, GIT_OID_RAWSZ, lo, hi, short_oid->id);
+
+ if (pos >= 0) {
+ /* An object matching exactly the oid was found */
+ found = 1;
+ current = idx->oid_lookup + pos;
+ } else {
+ /* No object was found */
+ /* pos refers to the object with the "closest" oid to short_oid */
+ pos = -1 - pos;
+ if (pos < (int)idx->num_objects) {
+ current = idx->oid_lookup + pos;
+
+ if (!git_oid_ncmp(short_oid, current, len))
+ found = 1;
+ }
+ }
+
+ if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) {
+ /* Check for ambiguousity */
+ const git_oid *next = current + 1;
+
+ if (!git_oid_ncmp(short_oid, next, len)) {
+ found = 2;
+ }
+ }
+
+ if (!found)
+ return git_odb__error_notfound("failed to find offset for multi-pack index entry", short_oid, len);
+ if (found > 1)
+ return git_odb__error_ambiguous("found multiple offsets for multi-pack index entry");
+
+ object_offset = idx->object_offsets + pos * 8;
+ offset = ntohl(*((uint32_t *)(object_offset + 4)));
+ if (offset & 0x80000000) {
+ uint32_t object_large_offsets_pos = offset & 0x7fffffff;
+ const unsigned char *object_large_offsets_index = idx->object_large_offsets;
+
+ /* Make sure we're not being sent out of bounds */
+ if (object_large_offsets_pos >= idx->num_object_large_offsets)
+ return git_odb__error_notfound("invalid index into the object large offsets table", short_oid, len);
+
+ object_large_offsets_index += 8 * object_large_offsets_pos;
+
+ offset = (((uint64_t)ntohl(*((uint32_t *)(object_large_offsets_index + 0)))) << 32) |
+ ntohl(*((uint32_t *)(object_large_offsets_index + 4)));
+ }
+ pack_index = ntohl(*((uint32_t *)(object_offset + 0)));
+ if (pack_index >= git_vector_length(&idx->packfile_names))
+ return midx_error("invalid index into the packfile names table");
+ e->pack_index = pack_index;
+ e->offset = offset;
+ git_oid_cpy(&e->sha1, current);
+ return 0;
+}
+
+int git_midx_foreach_entry(
+ git_midx_file *idx,
+ git_odb_foreach_cb cb,
+ void *data)
+{
+ size_t i;
+ int error;
+
+ GIT_ASSERT_ARG(idx);
+
+ for (i = 0; i < idx->num_objects; ++i) {
+ if ((error = cb(&idx->oid_lookup[i], data)) != 0)
+ return git_error_set_after_callback(error);
+ }
+
+ return error;
+}
+
+int git_midx_close(git_midx_file *idx)
+{
+ GIT_ASSERT_ARG(idx);
+
+ if (idx->index_map.data)
+ git_futils_mmap_free(&idx->index_map);
+
+ git_vector_free(&idx->packfile_names);
+
+ return 0;
+}
+
+void git_midx_free(git_midx_file *idx)
+{
+ if (!idx)
+ return;
+
+ git_buf_dispose(&idx->filename);
+ git_midx_close(idx);
+ git__free(idx);
+}
diff --git a/src/midx.h b/src/midx.h
new file mode 100644
index 0000000..543ff21
--- /dev/null
+++ b/src/midx.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_midx_h__
+#define INCLUDE_midx_h__
+
+#include "common.h"
+
+#include <ctype.h>
+
+#include "map.h"
+#include "mwindow.h"
+#include "odb.h"
+
+/*
+ * A multi-pack-index file.
+ *
+ * This file contains a merged index for multiple independent .pack files. This
+ * can help speed up locating objects without requiring a garbage collection
+ * cycle to create a single .pack file.
+ *
+ * Support for this feature was added in git 2.21, and requires the
+ * `core.multiPackIndex` config option to be set.
+ */
+typedef struct git_midx_file {
+ git_map index_map;
+
+ /* The table of Packfile Names. */
+ git_vector packfile_names;
+
+ /* The OID Fanout table. */
+ const uint32_t *oid_fanout;
+ /* The total number of objects in the index. */
+ uint32_t num_objects;
+
+ /* The OID Lookup table. */
+ git_oid *oid_lookup;
+
+ /* The Object Offsets table. Each entry has two 4-byte fields with the pack index and the offset. */
+ const unsigned char *object_offsets;
+
+ /* The Object Large Offsets table. */
+ const unsigned char *object_large_offsets;
+ /* The number of entries in the Object Large Offsets table. Each entry has an 8-byte with an offset */
+ size_t num_object_large_offsets;
+
+ /* The trailer of the file. Contains the SHA1-checksum of the whole file. */
+ git_oid checksum;
+
+ /* something like ".git/objects/pack/multi-pack-index". */
+ git_buf filename;
+} git_midx_file;
+
+/*
+ * An entry in the multi-pack-index file. Similar in purpose to git_pack_entry.
+ */
+typedef struct git_midx_entry {
+ /* The index within idx->packfile_names where the packfile name can be found. */
+ size_t pack_index;
+ /* The offset within the .pack file where the requested object is found. */
+ off64_t offset;
+ /* The SHA-1 hash of the requested object. */
+ git_oid sha1;
+} git_midx_entry;
+
+int git_midx_open(
+ git_midx_file **idx_out,
+ const char *path);
+bool git_midx_needs_refresh(
+ const git_midx_file *idx,
+ const char *path);
+int git_midx_entry_find(
+ git_midx_entry *e,
+ git_midx_file *idx,
+ const git_oid *short_oid,
+ size_t len);
+int git_midx_foreach_entry(
+ git_midx_file *idx,
+ git_odb_foreach_cb cb,
+ void *data);
+int git_midx_close(git_midx_file *idx);
+void git_midx_free(git_midx_file *idx);
+
+/* This is exposed for use in the fuzzers. */
+int git_midx_parse(
+ git_midx_file *idx,
+ const unsigned char *data,
+ size_t size);
+
+#endif
diff --git a/src/mwindow.c b/src/mwindow.c
index 262786a..da2dae2 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -10,7 +10,7 @@
#include "vector.h"
#include "futils.h"
#include "map.h"
-#include "global.h"
+#include "runtime.h"
#include "strmap.h"
#include "pack.h"
@@ -20,31 +20,45 @@
: 32 * 1024 * 1024)
#define DEFAULT_MAPPED_LIMIT \
- ((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL))
+ ((1024 * 1024) * (sizeof(void*) >= 8 ? UINT64_C(8192) : UINT64_C(256)))
+
+/* default is unlimited */
+#define DEFAULT_FILE_LIMIT 0
size_t git_mwindow__window_size = DEFAULT_WINDOW_SIZE;
size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT;
+size_t git_mwindow__file_limit = DEFAULT_FILE_LIMIT;
+
+/* Mutex to control access to `git_mwindow__mem_ctl` and `git__pack_cache`. */
+git_mutex git__mwindow_mutex;
-/* Whenever you want to read or modify this, grab git__mwindow_mutex */
-static git_mwindow_ctl mem_ctl;
+/* Whenever you want to read or modify this, grab `git__mwindow_mutex` */
+git_mwindow_ctl git_mwindow__mem_ctl;
/* Global list of mwindow files, to open packs once across repos */
git_strmap *git__pack_cache = NULL;
-static void git_mwindow_files_free(void)
+static void git_mwindow_global_shutdown(void)
{
git_strmap *tmp = git__pack_cache;
+ git_mutex_free(&git__mwindow_mutex);
+
git__pack_cache = NULL;
git_strmap_free(tmp);
}
int git_mwindow_global_init(void)
{
- assert(!git__pack_cache);
+ int error;
+
+ GIT_ASSERT(!git__pack_cache);
- git__on_shutdown(git_mwindow_files_free);
- return git_strmap_new(&git__pack_cache);
+ if ((error = git_mutex_init(&git__mwindow_mutex)) < 0 ||
+ (error = git_strmap_new(&git__pack_cache)) < 0)
+ return error;
+
+ return git_runtime_shutdown_register(git_mwindow_global_shutdown);
}
int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
@@ -65,7 +79,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
git__free(packname);
if (pack != NULL) {
- git_atomic_inc(&pack->refcount);
+ git_atomic32_inc(&pack->refcount);
git_mutex_unlock(&git__mwindow_mutex);
*out = pack;
return 0;
@@ -77,62 +91,51 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
return error;
}
- git_atomic_inc(&pack->refcount);
+ git_atomic32_inc(&pack->refcount);
error = git_strmap_set(git__pack_cache, pack->pack_name, pack);
git_mutex_unlock(&git__mwindow_mutex);
-
if (error < 0) {
- git_packfile_free(pack);
- return -1;
+ git_packfile_free(pack, false);
+ return error;
}
*out = pack;
return 0;
}
-void git_mwindow_put_pack(struct git_pack_file *pack)
+int git_mwindow_put_pack(struct git_pack_file *pack)
{
- int count;
+ int count, error;
+ struct git_pack_file *pack_to_delete = NULL;
- if (git_mutex_lock(&git__mwindow_mutex) < 0)
- return;
+ if ((error = git_mutex_lock(&git__mwindow_mutex)) < 0)
+ return error;
/* put before get would be a corrupted state */
- assert(git__pack_cache);
+ GIT_ASSERT(git__pack_cache);
/* if we cannot find it, the state is corrupted */
- assert(git_strmap_exists(git__pack_cache, pack->pack_name));
+ GIT_ASSERT(git_strmap_exists(git__pack_cache, pack->pack_name));
- count = git_atomic_dec(&pack->refcount);
+ count = git_atomic32_dec(&pack->refcount);
if (count == 0) {
git_strmap_delete(git__pack_cache, pack->pack_name);
- git_packfile_free(pack);
+ pack_to_delete = pack;
}
-
git_mutex_unlock(&git__mwindow_mutex);
- return;
-}
-
-void git_mwindow_free_all(git_mwindow_file *mwf)
-{
- if (git_mutex_lock(&git__mwindow_mutex)) {
- git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
- return;
- }
-
- git_mwindow_free_all_locked(mwf);
+ git_packfile_free(pack_to_delete, false);
- git_mutex_unlock(&git__mwindow_mutex);
+ return 0;
}
/*
* Free all the windows in a sequence, typically because we're done
- * with the file
+ * with the file. Needs to hold the git__mwindow_mutex.
*/
-void git_mwindow_free_all_locked(git_mwindow_file *mwf)
+static int git_mwindow_free_all_locked(git_mwindow_file *mwf)
{
- git_mwindow_ctl *ctl = &mem_ctl;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
size_t i;
/*
@@ -152,7 +155,7 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
while (mwf->windows) {
git_mwindow *w = mwf->windows;
- assert(w->inuse_cnt == 0);
+ GIT_ASSERT(w->inuse_cnt == 0);
ctl->mapped -= w->window_map.len;
ctl->open_windows--;
@@ -162,6 +165,24 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
mwf->windows = w->next;
git__free(w);
}
+
+ return 0;
+}
+
+int git_mwindow_free_all(git_mwindow_file *mwf)
+{
+ int error;
+
+ if (git_mutex_lock(&git__mwindow_mutex)) {
+ git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
+ return -1;
+ }
+
+ error = git_mwindow_free_all_locked(mwf);
+
+ git_mutex_unlock(&git__mwindow_mutex);
+
+ return error;
}
/*
@@ -174,92 +195,154 @@ int git_mwindow_contains(git_mwindow *win, off64_t offset)
&& offset <= (off64_t)(win_off + win->window_map.len);
}
+#define GIT_MWINDOW__LRU -1
+#define GIT_MWINDOW__MRU 1
+
/*
- * Find the least-recently-used window in a file
+ * Find the least- or most-recently-used window in a file that is not currently
+ * being used. The 'only_unused' flag controls whether the caller requires the
+ * file to only have unused windows. If '*out_window' is non-null, it is used as
+ * a starting point for the comparison.
+ *
+ * Returns whether such a window was found in the file.
*/
-static void git_mwindow_scan_lru(
- git_mwindow_file *mwf,
- git_mwindow **lru_w,
- git_mwindow **lru_l)
+static bool git_mwindow_scan_recently_used(
+ git_mwindow_file *mwf,
+ git_mwindow **out_window,
+ git_mwindow **out_last,
+ bool only_unused,
+ int comparison_sign)
{
- git_mwindow *w, *w_l;
-
- for (w_l = NULL, w = mwf->windows; w; w = w->next) {
- if (!w->inuse_cnt) {
- /*
- * If the current one is more recent than the last one,
- * store it in the output parameter. If lru_w is NULL,
- * it's the first loop, so store it as well.
- */
- if (!*lru_w || w->last_used < (*lru_w)->last_used) {
- *lru_w = w;
- *lru_l = w_l;
- }
+ git_mwindow *w, *w_last;
+ git_mwindow *lru_window = NULL, *lru_last = NULL;
+ bool found = false;
+
+ GIT_ASSERT_ARG(mwf);
+ GIT_ASSERT_ARG(out_window);
+
+ lru_window = *out_window;
+ if (out_last)
+ lru_last = *out_last;
+
+ for (w_last = NULL, w = mwf->windows; w; w_last = w, w = w->next) {
+ if (w->inuse_cnt) {
+ if (only_unused)
+ return false;
+ /* This window is currently being used. Skip it. */
+ continue;
+ }
+
+ /*
+ * If the current one is more (or less) recent than the last one,
+ * store it in the output parameter. If lru_window is NULL,
+ * it's the first loop, so store it as well.
+ */
+ if (!lru_window ||
+ (comparison_sign == GIT_MWINDOW__LRU && lru_window->last_used > w->last_used) ||
+ (comparison_sign == GIT_MWINDOW__MRU && lru_window->last_used < w->last_used)) {
+ lru_window = w;
+ lru_last = w_last;
+ found = true;
}
- w_l = w;
}
+
+ if (!found)
+ return false;
+
+ *out_window = lru_window;
+ if (out_last)
+ *out_last = lru_last;
+ return true;
}
/*
- * Close the least recently used window. You should check to see if
- * the file descriptors need closing from time to time. Called under
- * lock from new_window.
+ * Close the least recently used window (that is currently not being used) out
+ * of all the files. Called under lock from new_window_locked.
*/
-static int git_mwindow_close_lru(git_mwindow_file *mwf)
+static int git_mwindow_close_lru_window_locked(void)
{
- git_mwindow_ctl *ctl = &mem_ctl;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
+ git_mwindow_file *cur;
size_t i;
- git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows;
+ git_mwindow *lru_window = NULL, *lru_last = NULL, **list = NULL;
- /* FIXME: Does this give us any advantage? */
- if(mwf->windows)
- git_mwindow_scan_lru(mwf, &lru_w, &lru_l);
-
- for (i = 0; i < ctl->windowfiles.length; ++i) {
- git_mwindow *last = lru_w;
- git_mwindow_file *cur = git_vector_get(&ctl->windowfiles, i);
- git_mwindow_scan_lru(cur, &lru_w, &lru_l);
- if (lru_w != last)
+ git_vector_foreach(&ctl->windowfiles, i, cur) {
+ if (git_mwindow_scan_recently_used(
+ cur, &lru_window, &lru_last, false, GIT_MWINDOW__LRU)) {
list = &cur->windows;
+ }
}
- if (!lru_w) {
+ if (!lru_window) {
git_error_set(GIT_ERROR_OS, "failed to close memory window; couldn't find LRU");
return -1;
}
- ctl->mapped -= lru_w->window_map.len;
- git_futils_mmap_free(&lru_w->window_map);
+ ctl->mapped -= lru_window->window_map.len;
+ git_futils_mmap_free(&lru_window->window_map);
- if (lru_l)
- lru_l->next = lru_w->next;
+ if (lru_last)
+ lru_last->next = lru_window->next;
else
- *list = lru_w->next;
+ *list = lru_window->next;
- git__free(lru_w);
+ git__free(lru_window);
ctl->open_windows--;
return 0;
}
+/*
+ * Finds the file that does not have any open windows AND whose
+ * most-recently-used window is the least-recently used one across all
+ * currently open files.
+ *
+ * Called under lock from new_window_locked.
+ */
+static int git_mwindow_find_lru_file_locked(git_mwindow_file **out)
+{
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
+ git_mwindow_file *lru_file = NULL, *current_file = NULL;
+ git_mwindow *lru_window = NULL;
+ size_t i;
+
+ git_vector_foreach(&ctl->windowfiles, i, current_file) {
+ git_mwindow *mru_window = NULL;
+ if (!git_mwindow_scan_recently_used(
+ current_file, &mru_window, NULL, true, GIT_MWINDOW__MRU)) {
+ continue;
+ }
+ if (!lru_window || lru_window->last_used > mru_window->last_used) {
+ lru_window = mru_window;
+ lru_file = current_file;
+ }
+ }
+
+ if (!lru_file) {
+ git_error_set(GIT_ERROR_OS, "failed to close memory window file; couldn't find LRU");
+ return -1;
+ }
+
+ *out = lru_file;
+ return 0;
+}
+
/* This gets called under lock from git_mwindow_open */
-static git_mwindow *new_window(
- git_mwindow_file *mwf,
+static git_mwindow *new_window_locked(
git_file fd,
off64_t size,
off64_t offset)
{
- git_mwindow_ctl *ctl = &mem_ctl;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
size_t walign = git_mwindow__window_size / 2;
off64_t len;
git_mwindow *w;
- w = git__malloc(sizeof(*w));
+ w = git__calloc(1, sizeof(*w));
if (w == NULL)
return NULL;
- memset(w, 0x0, sizeof(*w));
w->offset = (offset / walign) * walign;
len = size - w->offset;
@@ -269,7 +352,7 @@ static git_mwindow *new_window(
ctl->mapped += (size_t)len;
while (git_mwindow__mapped_limit < ctl->mapped &&
- git_mwindow_close_lru(mwf) == 0) /* nop */;
+ git_mwindow_close_lru_window_locked() == 0) /* nop */;
/*
* We treat `mapped_limit` as a soft limit. If we can't find a
@@ -283,7 +366,7 @@ static git_mwindow *new_window(
* we're below our soft limits, so free up what we can and try again.
*/
- while (git_mwindow_close_lru(mwf) == 0)
+ while (git_mwindow_close_lru_window_locked() == 0)
/* nop */;
if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) {
@@ -315,7 +398,7 @@ unsigned char *git_mwindow_open(
size_t extra,
unsigned int *left)
{
- git_mwindow_ctl *ctl = &mem_ctl;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
git_mwindow *w = *cursor;
if (git_mutex_lock(&git__mwindow_mutex)) {
@@ -339,7 +422,7 @@ unsigned char *git_mwindow_open(
* one.
*/
if (!w) {
- w = new_window(mwf, mwf->fd, mwf->size, offset);
+ w = new_window_locked(mwf->fd, mwf->size, offset);
if (w == NULL) {
git_mutex_unlock(&git__mwindow_mutex);
return NULL;
@@ -367,8 +450,11 @@ unsigned char *git_mwindow_open(
int git_mwindow_file_register(git_mwindow_file *mwf)
{
- git_mwindow_ctl *ctl = &mem_ctl;
- int ret;
+ git_vector closed_files = GIT_VECTOR_INIT;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
+ int error;
+ size_t i;
+ git_mwindow_file *closed_file = NULL;
if (git_mutex_lock(&git__mwindow_mutex)) {
git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
@@ -376,20 +462,53 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
}
if (ctl->windowfiles.length == 0 &&
- git_vector_init(&ctl->windowfiles, 8, NULL) < 0) {
+ (error = git_vector_init(&ctl->windowfiles, 8, NULL)) < 0) {
git_mutex_unlock(&git__mwindow_mutex);
- return -1;
+ goto cleanup;
+ }
+
+ if (git_mwindow__file_limit) {
+ git_mwindow_file *lru_file;
+ while (git_mwindow__file_limit <= ctl->windowfiles.length &&
+ git_mwindow_find_lru_file_locked(&lru_file) == 0) {
+ if ((error = git_vector_insert(&closed_files, lru_file)) < 0) {
+ /*
+ * Exceeding the file limit seems preferrable to being open to
+ * data races that can end up corrupting the heap.
+ */
+ break;
+ }
+ git_mwindow_free_all_locked(lru_file);
+ }
}
- ret = git_vector_insert(&ctl->windowfiles, mwf);
+ error = git_vector_insert(&ctl->windowfiles, mwf);
git_mutex_unlock(&git__mwindow_mutex);
+ if (error < 0)
+ goto cleanup;
+
+ /*
+ * Once we have released the global windowfiles lock, we can close each
+ * individual file. Before doing so, acquire that file's lock to avoid
+ * closing a file that is currently being used.
+ */
+ git_vector_foreach(&closed_files, i, closed_file) {
+ error = git_mutex_lock(&closed_file->lock);
+ if (error < 0)
+ continue;
+ p_close(closed_file->fd);
+ closed_file->fd = -1;
+ git_mutex_unlock(&closed_file->lock);
+ }
- return ret;
+cleanup:
+ git_vector_free(&closed_files);
+ return error;
}
void git_mwindow_file_deregister(git_mwindow_file *mwf)
{
- git_mwindow_ctl *ctl = &mem_ctl;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
git_mwindow_file *cur;
size_t i;
diff --git a/src/mwindow.h b/src/mwindow.h
index 1a391b0..e3a03f0 100644
--- a/src/mwindow.h
+++ b/src/mwindow.h
@@ -22,6 +22,7 @@ typedef struct git_mwindow {
} git_mwindow;
typedef struct git_mwindow_file {
+ git_mutex lock; /* protects updates to fd */
git_mwindow *windows;
int fd;
off64_t size;
@@ -38,8 +39,7 @@ typedef struct git_mwindow_ctl {
} git_mwindow_ctl;
int git_mwindow_contains(git_mwindow *win, off64_t offset);
-void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
-void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
+int git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off64_t offset, size_t extra, unsigned int *left);
int git_mwindow_file_register(git_mwindow_file *mwf);
void git_mwindow_file_deregister(git_mwindow_file *mwf);
@@ -49,6 +49,6 @@ extern int git_mwindow_global_init(void);
struct git_pack_file; /* just declaration to avoid cyclical includes */
int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
-void git_mwindow_put_pack(struct git_pack_file *pack);
+int git_mwindow_put_pack(struct git_pack_file *pack);
#endif
diff --git a/src/net.c b/src/net.c
index d42fce5..d4a9f8a 100644
--- a/src/net.c
+++ b/src/net.c
@@ -14,7 +14,7 @@
#include "posix.h"
#include "buffer.h"
#include "http_parser.h"
-#include "global.h"
+#include "runtime.h"
#define DEFAULT_PORT_HTTP "80"
#define DEFAULT_PORT_HTTPS "443"
@@ -281,7 +281,8 @@ int git_net_url_apply_redirect(
git_net_url tmp = GIT_NET_URL_INIT;
int error = 0;
- assert(url && redirect_location);
+ GIT_ASSERT(url);
+ GIT_ASSERT(redirect_location);
if (redirect_location[0] == '/') {
git__free(url->path);
@@ -334,9 +335,19 @@ bool git_net_url_valid(git_net_url *url)
return (url->host && url->port && url->path);
}
-int git_net_url_is_default_port(git_net_url *url)
+bool git_net_url_is_default_port(git_net_url *url)
{
- return (strcmp(url->port, default_port_for_scheme(url->scheme)) == 0);
+ const char *default_port;
+
+ if ((default_port = default_port_for_scheme(url->scheme)) != NULL)
+ return (strcmp(url->port, default_port) == 0);
+ else
+ return false;
+}
+
+bool git_net_url_is_ipv6(git_net_url *url)
+{
+ return (strchr(url->host, ':') != NULL);
}
void git_net_url_swap(git_net_url *a, git_net_url *b)
diff --git a/src/net.h b/src/net.h
index 7e72db1..391b99a 100644
--- a/src/net.h
+++ b/src/net.h
@@ -33,8 +33,11 @@ extern int git_net_url_joinpath(
/** Ensures that a URL is minimally valid (contains a host, port and path) */
extern bool git_net_url_valid(git_net_url *url);
-/** Returns nonzero if the URL is on the default port. */
-extern int git_net_url_is_default_port(git_net_url *url);
+/** Returns true if the URL is on the default port. */
+extern bool git_net_url_is_default_port(git_net_url *url);
+
+/** Returns true if the host portion of the URL is an ipv6 address. */
+extern bool git_net_url_is_ipv6(git_net_url *url);
/* Applies a redirect to the URL with a git-aware service suffix. */
extern int git_net_url_apply_redirect(
diff --git a/src/netops.c b/src/netops.c
index 04ae824..a1ee292 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -13,7 +13,7 @@
#include "posix.h"
#include "buffer.h"
#include "http_parser.h"
-#include "global.h"
+#include "runtime.h"
int gitno_recv(gitno_buffer *buf)
{
@@ -61,18 +61,20 @@ void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data
}
/* Consume up to ptr and move the rest of the buffer to the beginning */
-void gitno_consume(gitno_buffer *buf, const char *ptr)
+int gitno_consume(gitno_buffer *buf, const char *ptr)
{
size_t consumed;
- assert(ptr - buf->data >= 0);
- assert(ptr - buf->data <= (int) buf->len);
+ GIT_ASSERT(ptr - buf->data >= 0);
+ GIT_ASSERT(ptr - buf->data <= (int) buf->len);
consumed = ptr - buf->data;
memmove(buf->data, ptr, buf->offset - consumed);
memset(buf->data + buf->offset, 0x0, buf->len - buf->offset);
buf->offset -= consumed;
+
+ return 0;
}
/* Consume const bytes and move the rest of the buffer to the beginning */
diff --git a/src/netops.h b/src/netops.h
index 52f1ccc..7140b39 100644
--- a/src/netops.h
+++ b/src/netops.h
@@ -14,7 +14,7 @@
#include "net.h"
#ifdef GIT_OPENSSL
-# include <openssl/ssl.h>
+# include "streams/openssl.h"
#endif
typedef struct gitno_ssl {
@@ -62,7 +62,7 @@ void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data
void gitno_buffer_setup_callback(gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data);
int gitno_recv(gitno_buffer *buf);
-void gitno_consume(gitno_buffer *buf, const char *ptr);
+int gitno_consume(gitno_buffer *buf, const char *ptr);
void gitno_consume_n(gitno_buffer *buf, size_t cons);
#endif
diff --git a/src/notes.c b/src/notes.c
index 4633a16..b9e1985 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -627,11 +627,11 @@ int git_note_default_ref(git_buf *out, git_repository *repo)
char *default_ref;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
- git_buf_sanitize(out);
-
- if ((error = note_get_default_ref(&default_ref, repo)) < 0)
+ if ((error = git_buf_sanitize(out)) < 0 ||
+ (error = note_get_default_ref(&default_ref, repo)) < 0)
return error;
git_buf_attach(out, default_ref, strlen(default_ref));
@@ -640,25 +640,25 @@ int git_note_default_ref(git_buf *out, git_repository *repo)
const git_signature *git_note_committer(const git_note *note)
{
- assert(note);
+ GIT_ASSERT_ARG_WITH_RETVAL(note, NULL);
return note->committer;
}
const git_signature *git_note_author(const git_note *note)
{
- assert(note);
+ GIT_ASSERT_ARG_WITH_RETVAL(note, NULL);
return note->author;
}
-const char * git_note_message(const git_note *note)
+const char *git_note_message(const git_note *note)
{
- assert(note);
+ GIT_ASSERT_ARG_WITH_RETVAL(note, NULL);
return note->message;
}
-const git_oid * git_note_id(const git_note *note)
+const git_oid *git_note_id(const git_note *note)
{
- assert(note);
+ GIT_ASSERT_ARG_WITH_RETVAL(note, NULL);
return ¬e->id;
}
@@ -808,8 +808,11 @@ int git_note_next(
git_oid_cpy(note_id, &item->id);
- if (!(error = process_entry_path(item->path, annotated_id)))
- git_iterator_advance(NULL, it);
+ if ((error = process_entry_path(item->path, annotated_id)) < 0)
+ return error;
- return error;
+ if ((error = git_iterator_advance(NULL, it)) < 0 && error != GIT_ITEROVER)
+ return error;
+
+ return 0;
}
diff --git a/src/object.c b/src/object.c
index 1b47ab1..42e1e46 100644
--- a/src/object.c
+++ b/src/object.c
@@ -67,7 +67,7 @@ int git_object__from_raw(
size_t object_size;
int error;
- assert(object_out);
+ GIT_ASSERT_ARG(object_out);
*object_out = NULL;
/* Validate type match */
@@ -86,11 +86,12 @@ int git_object__from_raw(
GIT_ERROR_CHECK_ALLOC(object);
object->cached.flags = GIT_CACHE_STORE_PARSED;
object->cached.type = type;
- git_odb_hash(&object->cached.oid, data, size, type);
+ if ((error = git_odb_hash(&object->cached.oid, data, size, type)) < 0)
+ return error;
/* Parse raw object data */
def = &git_objects_table[type];
- assert(def->free && def->parse_raw);
+ GIT_ASSERT(def->free && def->parse_raw);
if ((error = def->parse_raw(object, data, size)) < 0) {
def->free(object);
@@ -114,7 +115,7 @@ int git_object__from_odb_object(
git_object_def *def;
git_object *object = NULL;
- assert(object_out);
+ GIT_ASSERT_ARG(object_out);
*object_out = NULL;
/* Validate type match */
@@ -140,7 +141,7 @@ int git_object__from_odb_object(
/* Parse raw object data */
def = &git_objects_table[odb_obj->cached.type];
- assert(def->free && def->parse);
+ GIT_ASSERT(def->free && def->parse);
if ((error = def->parse(object, odb_obj)) < 0)
def->free(object);
@@ -173,7 +174,9 @@ int git_object_lookup_prefix(
git_odb_object *odb_obj = NULL;
int error = 0;
- assert(repo && object_out && id);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(object_out);
+ GIT_ASSERT_ARG(id);
if (len < GIT_OID_MINPREFIXLEN) {
git_error_set(GIT_ERROR_OBJECT, "ambiguous lookup - OID prefix is too short");
@@ -210,7 +213,7 @@ int git_object_lookup_prefix(
} else if (cached->flags == GIT_CACHE_STORE_RAW) {
odb_obj = (git_odb_object *)cached;
} else {
- assert(!"Wrong caching type in the global object cache");
+ GIT_ASSERT(!"Wrong caching type in the global object cache");
}
} else {
/* Object was not found in the cache, let's explore the backends.
@@ -262,19 +265,19 @@ void git_object_free(git_object *object)
const git_oid *git_object_id(const git_object *obj)
{
- assert(obj);
+ GIT_ASSERT_ARG_WITH_RETVAL(obj, NULL);
return &obj->cached.oid;
}
git_object_t git_object_type(const git_object *obj)
{
- assert(obj);
+ GIT_ASSERT_ARG_WITH_RETVAL(obj, GIT_OBJECT_INVALID);
return obj->cached.type;
}
git_repository *git_object_owner(const git_object *obj)
{
- assert(obj);
+ GIT_ASSERT_ARG_WITH_RETVAL(obj, NULL);
return obj->repo;
}
@@ -395,9 +398,10 @@ int git_object_peel(
git_object *source, *deref = NULL;
int error;
- assert(object && peeled);
+ GIT_ASSERT_ARG(object);
+ GIT_ASSERT_ARG(peeled);
- assert(target_type == GIT_OBJECT_TAG ||
+ GIT_ASSERT_ARG(target_type == GIT_OBJECT_TAG ||
target_type == GIT_OBJECT_COMMIT ||
target_type == GIT_OBJECT_TREE ||
target_type == GIT_OBJECT_BLOB ||
@@ -460,7 +464,9 @@ int git_object_lookup_bypath(
git_tree *tree = NULL;
git_tree_entry *entry = NULL;
- assert(out && treeish && path);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(treeish);
+ GIT_ASSERT_ARG(path);
if ((error = git_object_peel((git_object**)&tree, treeish, GIT_OBJECT_TREE)) < 0 ||
(error = git_tree_entry_bypath(&entry, tree, path)) < 0)
@@ -492,9 +498,12 @@ int git_object_short_id(git_buf *out, const git_object *obj)
git_oid id = {{0}};
git_odb *odb;
- assert(out && obj);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(obj);
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
- git_buf_sanitize(out);
repo = git_object_owner(obj);
if ((error = git_repository__configmap_lookup(&len, repo, GIT_CONFIGMAP_ABBREV)) < 0)
diff --git a/src/odb.c b/src/odb.c
index 68d9a9a..e3a5381 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -23,14 +23,14 @@
#define GIT_ALTERNATES_FILE "info/alternates"
+#define GIT_ALTERNATES_MAX_DEPTH 5
+
/*
* We work under the assumption that most objects for long-running
* operations will be packed
*/
-#define GIT_LOOSE_PRIORITY 1
-#define GIT_PACKED_PRIORITY 2
-
-#define GIT_ALTERNATES_MAX_DEPTH 5
+int git_odb__loose_priority = GIT_ODB_DEFAULT_LOOSE_PRIORITY;
+int git_odb__packed_priority = GIT_ODB_DEFAULT_PACKED_PRIORITY;
bool git_odb__strict_hash_verification = true;
@@ -44,8 +44,8 @@ typedef struct
static git_cache *odb_cache(git_odb *odb)
{
- if (odb->rc.owner != NULL) {
- git_repository *owner = odb->rc.owner;
+ git_repository *owner = GIT_REFCOUNT_OWNER(odb);
+ if (owner != NULL) {
return &owner->objects;
}
@@ -114,7 +114,8 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj)
size_t hdrlen;
int error;
- assert(id && obj);
+ GIT_ASSERT_ARG(id);
+ GIT_ASSERT_ARG(obj);
if (!git_object_typeisloose(obj->type)) {
git_error_set(GIT_ERROR_INVALID, "invalid object type");
@@ -259,9 +260,7 @@ int git_odb__hashfd_filtered(
if (!(error = git_futils_readbuffer_fd(&raw, fd, size))) {
git_buf post = GIT_BUF_INIT;
- error = git_filter_list_apply_to_data(&post, fl, &raw);
-
- git_buf_dispose(&raw);
+ error = git_filter_list__convert_buf(&post, fl, &raw);
if (!error)
error = git_odb_hash(out, post.ptr, post.size, type);
@@ -298,14 +297,15 @@ int git_odb__hashlink(git_oid *out, const char *path)
GIT_ERROR_CHECK_ALLOC(link_data);
read_len = p_readlink(path, link_data, size);
- link_data[size] = '\0';
- if (read_len != size) {
+ if (read_len == -1) {
git_error_set(GIT_ERROR_OS, "failed to read symlink data for '%s'", path);
git__free(link_data);
return -1;
}
+ GIT_ASSERT(read_len <= size);
+ link_data[read_len] = '\0';
- result = git_odb_hash(out, link_data, size, GIT_OBJECT_BLOB);
+ result = git_odb_hash(out, link_data, read_len, GIT_OBJECT_BLOB);
git__free(link_data);
} else {
int fd = git_futils_open_ro(path);
@@ -346,7 +346,7 @@ int git_odb_hash(git_oid *id, const void *data, size_t len, git_object_t type)
{
git_rawobj raw;
- assert(id);
+ GIT_ASSERT_ARG(id);
raw.data = (void *)data;
raw.len = len;
@@ -376,7 +376,7 @@ static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t
{
fake_wstream *stream = (fake_wstream *)_stream;
- assert(stream->written + len <= stream->size);
+ GIT_ASSERT(stream->written + len <= stream->size);
memcpy(stream->buffer + stream->written, data, len);
stream->written += len;
@@ -449,12 +449,18 @@ int git_odb_new(git_odb **out)
git_odb *db = git__calloc(1, sizeof(*db));
GIT_ERROR_CHECK_ALLOC(db);
+ if (git_mutex_init(&db->lock) < 0) {
+ git__free(db);
+ return -1;
+ }
if (git_cache_init(&db->own_cache) < 0) {
+ git_mutex_free(&db->lock);
git__free(db);
return -1;
}
if (git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) {
git_cache_dispose(&db->own_cache);
+ git_mutex_free(&db->lock);
git__free(db);
return -1;
}
@@ -470,12 +476,13 @@ static int add_backend_internal(
{
backend_internal *internal;
- assert(odb && backend);
+ GIT_ASSERT_ARG(odb);
+ GIT_ASSERT_ARG(backend);
GIT_ERROR_CHECK_VERSION(backend, GIT_ODB_BACKEND_VERSION, "git_odb_backend");
/* Check if the backend is already owned by another ODB */
- assert(!backend->odb || backend->odb == odb);
+ GIT_ASSERT(!backend->odb || backend->odb == odb);
internal = git__malloc(sizeof(backend_internal));
GIT_ERROR_CHECK_ALLOC(internal);
@@ -485,13 +492,18 @@ static int add_backend_internal(
internal->is_alternate = is_alternate;
internal->disk_inode = disk_inode;
+ if (git_mutex_lock(&odb->lock) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return -1;
+ }
if (git_vector_insert(&odb->backends, internal) < 0) {
+ git_mutex_unlock(&odb->lock);
git__free(internal);
return -1;
}
-
git_vector_sort(&odb->backends);
internal->backend->odb = odb;
+ git_mutex_unlock(&odb->lock);
return 0;
}
@@ -507,8 +519,19 @@ int git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority)
size_t git_odb_num_backends(git_odb *odb)
{
- assert(odb);
- return odb->backends.length;
+ size_t length;
+ bool locked = true;
+
+ GIT_ASSERT_ARG(odb);
+
+ if (git_mutex_lock(&odb->lock) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ locked = false;
+ }
+ length = odb->backends.length;
+ if (locked)
+ git_mutex_unlock(&odb->lock);
+ return length;
}
static int git_odb__error_unsupported_in_backend(const char *action)
@@ -522,24 +545,35 @@ static int git_odb__error_unsupported_in_backend(const char *action)
int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos)
{
backend_internal *internal;
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(odb);
+
- assert(out && odb);
+ if ((error = git_mutex_lock(&odb->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
internal = git_vector_get(&odb->backends, pos);
- if (internal && internal->backend) {
- *out = internal->backend;
- return 0;
+ if (!internal || !internal->backend) {
+ git_mutex_unlock(&odb->lock);
+
+ git_error_set(GIT_ERROR_ODB, "no ODB backend loaded at index %" PRIuZ, pos);
+ return GIT_ENOTFOUND;
}
+ *out = internal->backend;
+ git_mutex_unlock(&odb->lock);
- git_error_set(GIT_ERROR_ODB, "no ODB backend loaded at index %" PRIuZ, pos);
- return GIT_ENOTFOUND;
+ return 0;
}
int git_odb__add_default_backends(
git_odb *db, const char *objects_dir,
bool as_alternates, int alternate_depth)
{
- size_t i;
+ size_t i = 0;
struct stat st;
ino_t inode;
git_odb_backend *loose, *packed;
@@ -548,7 +582,7 @@ int git_odb__add_default_backends(
* a cross-platform workaround for this */
#ifdef GIT_WIN32
GIT_UNUSED(i);
- GIT_UNUSED(st);
+ GIT_UNUSED(&st);
inode = 0;
#else
@@ -563,22 +597,39 @@ int git_odb__add_default_backends(
inode = st.st_ino;
+ if (git_mutex_lock(&db->lock) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return -1;
+ }
for (i = 0; i < db->backends.length; ++i) {
backend_internal *backend = git_vector_get(&db->backends, i);
- if (backend->disk_inode == inode)
+ if (backend->disk_inode == inode) {
+ git_mutex_unlock(&db->lock);
return 0;
+ }
}
+ git_mutex_unlock(&db->lock);
#endif
/* add the loose object backend */
if (git_odb_backend_loose(&loose, objects_dir, -1, db->do_fsync, 0, 0) < 0 ||
- add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0)
+ add_backend_internal(db, loose, git_odb__loose_priority, as_alternates, inode) < 0)
return -1;
/* add the packed file backend */
if (git_odb_backend_pack(&packed, objects_dir) < 0 ||
- add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates, inode) < 0)
+ add_backend_internal(db, packed, git_odb__packed_priority, as_alternates, inode) < 0)
+ return -1;
+
+ if (git_mutex_lock(&db->lock) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
return -1;
+ }
+ if (!db->cgraph && git_commit_graph_new(&db->cgraph, objects_dir, false) < 0) {
+ git_mutex_unlock(&db->lock);
+ return -1;
+ }
+ git_mutex_unlock(&db->lock);
return load_alternates(db, objects_dir, alternate_depth);
}
@@ -641,11 +692,29 @@ int git_odb_add_disk_alternate(git_odb *odb, const char *path)
return git_odb__add_default_backends(odb, path, true, 0);
}
+int git_odb_set_commit_graph(git_odb *odb, git_commit_graph *cgraph)
+{
+ int error = 0;
+
+ GIT_ASSERT_ARG(odb);
+
+ if ((error = git_mutex_lock(&odb->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the db lock");
+ return error;
+ }
+ git_commit_graph_free(odb->cgraph);
+ odb->cgraph = cgraph;
+ git_mutex_unlock(&odb->lock);
+
+ return error;
+}
+
int git_odb_open(git_odb **out, const char *objects_dir)
{
git_odb *db;
- assert(out && objects_dir);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(objects_dir);
*out = NULL;
@@ -664,7 +733,7 @@ int git_odb_open(git_odb **out, const char *objects_dir)
int git_odb__set_caps(git_odb *odb, int caps)
{
if (caps == GIT_ODB_CAP_FROM_OWNER) {
- git_repository *repo = odb->rc.owner;
+ git_repository *repo = GIT_REFCOUNT_OWNER(odb);
int val;
if (!repo) {
@@ -682,7 +751,12 @@ int git_odb__set_caps(git_odb *odb, int caps)
static void odb_free(git_odb *db)
{
size_t i;
+ bool locked = true;
+ if (git_mutex_lock(&db->lock) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ locked = false;
+ }
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *backend = internal->backend;
@@ -691,9 +765,13 @@ static void odb_free(git_odb *db)
git__free(internal);
}
+ if (locked)
+ git_mutex_unlock(&db->lock);
+ git_commit_graph_free(db->cgraph);
git_vector_free(&db->backends);
git_cache_dispose(&db->own_cache);
+ git_mutex_free(&db->lock);
git__memzero(db, sizeof(*db));
git__free(db);
@@ -714,7 +792,12 @@ static int odb_exists_1(
{
size_t i;
bool found = false;
+ int error;
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
for (i = 0; i < db->backends.length && !found; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -725,10 +808,34 @@ static int odb_exists_1(
if (b->exists != NULL)
found = (bool)b->exists(b, id);
}
+ git_mutex_unlock(&db->lock);
return (int)found;
}
+int git_odb__get_commit_graph_file(git_commit_graph_file **out, git_odb *db)
+{
+ int error = 0;
+ git_commit_graph_file *result = NULL;
+
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the db lock");
+ return error;
+ }
+ if (!db->cgraph) {
+ error = GIT_ENOTFOUND;
+ goto done;
+ }
+ error = git_commit_graph_get_file(&result, db->cgraph);
+ if (error)
+ goto done;
+ *out = result;
+
+done:
+ git_mutex_unlock(&db->lock);
+ return error;
+}
+
static int odb_freshen_1(
git_odb *db,
const git_oid *id,
@@ -736,7 +843,12 @@ static int odb_freshen_1(
{
size_t i;
bool found = false;
+ int error;
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
for (i = 0; i < db->backends.length && !found; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -749,13 +861,15 @@ static int odb_freshen_1(
else if (b->exists != NULL)
found = b->exists(b, id);
}
+ git_mutex_unlock(&db->lock);
return (int)found;
}
int git_odb__freshen(git_odb *db, const git_oid *id)
{
- assert(db && id);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(id);
if (odb_freshen_1(db, id, false))
return 1;
@@ -771,7 +885,8 @@ int git_odb_exists(git_odb *db, const git_oid *id)
{
git_odb_object *object;
- assert(db && id);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(id);
if (git_oid_is_zero(id))
return 0;
@@ -798,6 +913,11 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db,
int error = GIT_ENOTFOUND, num_found = 0;
git_oid last_found = {{0}}, found;
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
+ error = GIT_ENOTFOUND;
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -811,18 +931,23 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db,
error = b->exists_prefix(&found, b, key, len);
if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH)
continue;
- if (error)
+ if (error) {
+ git_mutex_unlock(&db->lock);
return error;
+ }
/* make sure found item doesn't introduce ambiguity */
if (num_found) {
- if (git_oid__cmp(&last_found, &found))
+ if (git_oid__cmp(&last_found, &found)) {
+ git_mutex_unlock(&db->lock);
return git_odb__error_ambiguous("multiple matches for prefix");
+ }
} else {
git_oid_cpy(&last_found, &found);
num_found++;
}
}
+ git_mutex_unlock(&db->lock);
if (!num_found)
return GIT_ENOTFOUND;
@@ -839,7 +964,8 @@ int git_odb_exists_prefix(
int error;
git_oid key = {{0}};
- assert(db && short_id);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(short_id);
if (len < GIT_OID_MINPREFIXLEN)
return git_odb__error_ambiguous("prefix length too short");
@@ -875,7 +1001,8 @@ int git_odb_expand_ids(
{
size_t i;
- assert(db && ids);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(ids);
for (i = 0; i < count; i++) {
git_odb_expand_id *query = &ids[i];
@@ -962,6 +1089,10 @@ static int odb_read_header_1(
return 0;
}
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -983,9 +1114,11 @@ static int odb_read_header_1(
case GIT_ENOTFOUND:
break;
default:
+ git_mutex_unlock(&db->lock);
return error;
}
}
+ git_mutex_unlock(&db->lock);
return passthrough ? GIT_PASSTHROUGH : GIT_ENOTFOUND;
}
@@ -997,7 +1130,11 @@ int git_odb__read_header_or_object(
int error = GIT_ENOTFOUND;
git_odb_object *object;
- assert(db && id && out && len_p && type_p);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(id);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(len_p);
+ GIT_ASSERT_ARG(type_p);
*out = NULL;
@@ -1054,6 +1191,10 @@ static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id,
return error;
}
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
for (i = 0; i < db->backends.length && !found; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -1066,12 +1207,15 @@ static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id,
if (error == GIT_PASSTHROUGH || error == GIT_ENOTFOUND)
continue;
- if (error < 0)
+ if (error < 0) {
+ git_mutex_unlock(&db->lock);
return error;
+ }
found = true;
}
}
+ git_mutex_unlock(&db->lock);
if (!found)
return GIT_ENOTFOUND;
@@ -1104,7 +1248,9 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
{
int error;
- assert(out && db && id);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(id);
if (git_oid_is_zero(id))
return error_null_oid(GIT_ENOTFOUND, "cannot read object");
@@ -1162,6 +1308,10 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
bool found = false;
git_odb_object *object;
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -1178,8 +1328,10 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
continue;
}
- if (error)
+ if (error) {
+ git_mutex_unlock(&db->lock);
goto out;
+ }
git__free(data);
data = raw.data;
@@ -1194,6 +1346,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
error = git_odb__error_ambiguous(buf.ptr);
git_buf_dispose(&buf);
+ git_mutex_unlock(&db->lock);
goto out;
}
@@ -1201,6 +1354,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
found = true;
}
}
+ git_mutex_unlock(&db->lock);
if (!found)
return GIT_ENOTFOUND;
@@ -1237,7 +1391,8 @@ int git_odb_read_prefix(
git_oid key = {{0}};
int error;
- assert(out && db);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(db);
if (len < GIT_OID_MINPREFIXLEN)
return git_odb__error_ambiguous("prefix length too short");
@@ -1267,28 +1422,46 @@ int git_odb_read_prefix(
int git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload)
{
unsigned int i;
+ git_vector backends = GIT_VECTOR_INIT;
backend_internal *internal;
+ int error = 0;
- git_vector_foreach(&db->backends, i, internal) {
+ /* Make a copy of the backends vector to invoke the callback without holding the lock. */
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ goto cleanup;
+ }
+ error = git_vector_dup(&backends, &db->backends, NULL);
+ git_mutex_unlock(&db->lock);
+
+ if (error < 0)
+ goto cleanup;
+
+ git_vector_foreach(&backends, i, internal) {
git_odb_backend *b = internal->backend;
- int error = b->foreach(b, cb, payload);
+ error = b->foreach(b, cb, payload);
if (error != 0)
- return error;
+ goto cleanup;
}
- return 0;
+cleanup:
+ git_vector_free(&backends);
+
+ return error;
}
int git_odb_write(
git_oid *oid, git_odb *db, const void *data, size_t len, git_object_t type)
{
size_t i;
- int error = GIT_ERROR;
+ int error;
git_odb_stream *stream;
- assert(oid && db);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(db);
- git_odb_hash(oid, data, len, type);
+ if ((error = git_odb_hash(oid, data, len, type)) < 0)
+ return error;
if (git_oid_is_zero(oid))
return error_null_oid(GIT_EINVALID, "cannot write object");
@@ -1296,7 +1469,11 @@ int git_odb_write(
if (git_odb__freshen(db, oid))
return 0;
- for (i = 0; i < db->backends.length && error < 0; ++i) {
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
+ for (i = 0, error = GIT_ERROR; i < db->backends.length && error < 0; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -1307,6 +1484,7 @@ int git_odb_write(
if (b->write != NULL)
error = b->write(b, oid, data, len, type);
}
+ git_mutex_unlock(&db->lock);
if (!error || error == GIT_PASSTHROUGH)
return 0;
@@ -1345,8 +1523,14 @@ int git_odb_open_wstream(
int error = GIT_ERROR;
git_hash_ctx *ctx = NULL;
- assert(stream && db);
+ GIT_ASSERT_ARG(stream);
+ GIT_ASSERT_ARG(db);
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
+ error = GIT_ERROR;
for (i = 0; i < db->backends.length && error < 0; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -1363,6 +1547,7 @@ int git_odb_open_wstream(
error = init_fake_wstream(stream, b, size, type);
}
}
+ git_mutex_unlock(&db->lock);
if (error < 0) {
if (error == GIT_PASSTHROUGH)
@@ -1455,8 +1640,14 @@ int git_odb_open_rstream(
size_t i, reads = 0;
int error = GIT_ERROR;
- assert(stream && db);
+ GIT_ASSERT_ARG(stream);
+ GIT_ASSERT_ARG(db);
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
+ error = GIT_ERROR;
for (i = 0; i < db->backends.length && error < 0; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -1466,6 +1657,7 @@ int git_odb_open_rstream(
error = b->readstream(stream, len, type, b, oid);
}
}
+ git_mutex_unlock(&db->lock);
if (error == GIT_PASSTHROUGH)
error = 0;
@@ -1480,8 +1672,14 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_indexer_
size_t i, writes = 0;
int error = GIT_ERROR;
- assert(out && db);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(db);
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
+ error = GIT_ERROR;
for (i = 0; i < db->backends.length && error < 0; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -1495,6 +1693,7 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_indexer_
error = b->writepack(out, b, db, progress_cb, progress_payload);
}
}
+ git_mutex_unlock(&db->lock);
if (error == GIT_PASSTHROUGH)
error = 0;
@@ -1510,10 +1709,12 @@ void *git_odb_backend_data_alloc(git_odb_backend *backend, size_t len)
return git__malloc(len);
}
+#ifndef GIT_DEPRECATE_HARD
void *git_odb_backend_malloc(git_odb_backend *backend, size_t len)
{
return git_odb_backend_data_alloc(backend, len);
}
+#endif
void git_odb_backend_data_free(git_odb_backend *backend, void *data)
{
@@ -1524,18 +1725,29 @@ void git_odb_backend_data_free(git_odb_backend *backend, void *data)
int git_odb_refresh(struct git_odb *db)
{
size_t i;
- assert(db);
+ int error;
+
+ GIT_ASSERT_ARG(db);
+ if ((error = git_mutex_lock(&db->lock)) < 0) {
+ git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
+ return error;
+ }
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
if (b->refresh != NULL) {
int error = b->refresh(b);
- if (error < 0)
+ if (error < 0) {
+ git_mutex_unlock(&db->lock);
return error;
+ }
}
}
+ if (db->cgraph)
+ git_commit_graph_refresh(db->cgraph);
+ git_mutex_unlock(&db->lock);
return 0;
}
diff --git a/src/odb.h b/src/odb.h
index 8dd4efd..4a8ebff 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -12,16 +12,21 @@
#include "git2/odb.h"
#include "git2/oid.h"
#include "git2/types.h"
+#include "git2/sys/commit_graph.h"
-#include "vector.h"
#include "cache.h"
-#include "posix.h"
+#include "commit_graph.h"
#include "filter.h"
+#include "posix.h"
+#include "vector.h"
#define GIT_OBJECTS_DIR "objects/"
#define GIT_OBJECT_DIR_MODE 0777
#define GIT_OBJECT_FILE_MODE 0444
+#define GIT_ODB_DEFAULT_LOOSE_PRIORITY 1
+#define GIT_ODB_DEFAULT_PACKED_PRIORITY 2
+
extern bool git_odb__strict_hash_verification;
/* DO NOT EXPORT */
@@ -40,8 +45,10 @@ struct git_odb_object {
/* EXPORT */
struct git_odb {
git_refcount rc;
+ git_mutex lock; /* protects backends */
git_vector backends;
git_cache own_cache;
+ git_commit_graph *cgraph;
unsigned int do_fsync :1;
};
@@ -126,6 +133,13 @@ int git_odb__read_header_or_object(
git_odb_object **out, size_t *len_p, git_object_t *type_p,
git_odb *db, const git_oid *id);
+/*
+ * Attempt to get the ODB's commit-graph file. This object is still owned by
+ * the ODB. If the repository does not contain a commit-graph, it will return
+ * GIT_ENOTFOUND.
+ */
+int git_odb__get_commit_graph_file(git_commit_graph_file **out, git_odb *odb);
+
/* freshen an entry in the object database */
int git_odb__freshen(git_odb *db, const git_oid *id);
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 4a54b3f..b0abbbf 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -304,12 +304,12 @@ static int read_loose_standard(git_rawobj *out, git_buf *obj)
* (including the initial sequence in the head buffer).
*/
if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) ||
- (body = git__malloc(alloc_size)) == NULL) {
+ (body = git__calloc(1, alloc_size)) == NULL) {
error = -1;
goto done;
}
- assert(decompressed >= head_len);
+ GIT_ASSERT(decompressed >= head_len);
body_len = decompressed - head_len;
if (body_len)
@@ -344,7 +344,8 @@ static int read_loose(git_rawobj *out, git_buf *loc)
int error;
git_buf obj = GIT_BUF_INIT;
- assert(out && loc);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(loc);
if (git_buf_oom(loc))
return -1;
@@ -386,8 +387,8 @@ static int read_header_loose_standard(
git_rawobj *out, const unsigned char *data, size_t len)
{
git_zstream zs = GIT_ZSTREAM_INIT;
- obj_hdr hdr;
- unsigned char inflated[MAX_HEADER_LEN];
+ obj_hdr hdr = {0};
+ unsigned char inflated[MAX_HEADER_LEN] = {0};
size_t header_len, inflated_len = sizeof(inflated);
int error;
@@ -411,7 +412,8 @@ static int read_header_loose(git_rawobj *out, git_buf *loc)
ssize_t obj_len;
int fd, error;
- assert(out && loc);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(loc);
if (git_buf_oom(loc))
return -1;
@@ -585,7 +587,8 @@ static int loose_backend__read_header(size_t *len_p, git_object_t *type_p, git_o
git_rawobj raw;
int error;
- assert(backend && oid);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(oid);
raw.len = 0;
raw.type = GIT_OBJECT_INVALID;
@@ -609,7 +612,8 @@ static int loose_backend__read(void **buffer_p, size_t *len_p, git_object_t *typ
git_rawobj raw;
int error = 0;
- assert(backend && oid);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(oid);
if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) {
error = git_odb__error_notfound("no matching loose object",
@@ -636,7 +640,7 @@ static int loose_backend__read_prefix(
{
int error = 0;
- assert(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ);
+ GIT_ASSERT_ARG(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ);
if (len == GIT_OID_HEXSZ) {
/* We can fall back to regular read method */
@@ -647,7 +651,7 @@ static int loose_backend__read_prefix(
git_buf object_path = GIT_BUF_INIT;
git_rawobj raw;
- assert(backend && short_oid);
+ GIT_ASSERT_ARG(backend && short_oid);
if ((error = locate_object_short_oid(&object_path, out_oid,
(loose_backend *)backend, short_oid, len)) == 0 &&
@@ -669,7 +673,8 @@ static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
git_buf object_path = GIT_BUF_INIT;
int error;
- assert(backend && oid);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(oid);
error = locate_object(&object_path, (loose_backend *)backend, oid);
@@ -684,7 +689,10 @@ static int loose_backend__exists_prefix(
git_buf object_path = GIT_BUF_INIT;
int error;
- assert(backend && out && short_id && len >= GIT_OID_MINPREFIXLEN);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(short_id);
+ GIT_ASSERT_ARG(len >= GIT_OID_MINPREFIXLEN);
error = locate_object_short_oid(
&object_path, out, (loose_backend *)backend, short_id, len);
@@ -759,7 +767,8 @@ static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb
struct foreach_state state;
loose_backend *backend = (loose_backend *) _backend;
- assert(backend && cb);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(cb);
objects_dir = backend->objects_dir;
@@ -833,7 +842,7 @@ static int loose_backend__writestream(git_odb_stream **stream_out, git_odb_backe
size_t hdrlen;
int error;
- assert(_backend);
+ GIT_ASSERT_ARG(_backend);
backend = (loose_backend *)_backend;
*stream_out = NULL;
@@ -991,7 +1000,11 @@ static int loose_backend__readstream(
obj_hdr hdr;
int error = 0;
- assert(stream_out && len_out && type_out && _backend && oid);
+ GIT_ASSERT_ARG(stream_out);
+ GIT_ASSERT_ARG(len_out);
+ GIT_ASSERT_ARG(type_out);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(oid);
backend = (loose_backend *)_backend;
*stream_out = NULL;
@@ -1108,11 +1121,7 @@ static int loose_backend__freshen(
static void loose_backend__free(git_odb_backend *_backend)
{
- loose_backend *backend;
- assert(_backend);
- backend = (loose_backend *)_backend;
-
- git__free(backend);
+ git__free(_backend);
}
int git_odb_backend_loose(
@@ -1126,7 +1135,8 @@ int git_odb_backend_loose(
loose_backend *backend;
size_t objects_dirlen, alloclen;
- assert(backend_out && objects_dir);
+ GIT_ASSERT_ARG(backend_out);
+ GIT_ASSERT_ARG(objects_dir);
objects_dirlen = strlen(objects_dir);
diff --git a/src/odb_mempack.c b/src/odb_mempack.c
index 69c423b..d08356a 100644
--- a/src/odb_mempack.c
+++ b/src/odb_mempack.c
@@ -110,6 +110,8 @@ int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *_back
if (git_packbuilder_new(&packbuilder, repo) < 0)
return -1;
+ git_packbuilder_set_threads(packbuilder, 0);
+
for (i = 0; i < db->commits.size; ++i) {
struct memobject *commit = db->commits.ptr[i];
@@ -154,7 +156,7 @@ int git_mempack_new(git_odb_backend **out)
{
struct memory_packer_db *db;
- assert(out);
+ GIT_ASSERT_ARG(out);
db = git__calloc(1, sizeof(struct memory_packer_db));
GIT_ERROR_CHECK_ALLOC(db);
diff --git a/src/odb_pack.c b/src/odb_pack.c
index c93d07c..3df8a42 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -11,12 +11,12 @@
#include "git2/repository.h"
#include "git2/indexer.h"
#include "git2/sys/odb_backend.h"
+#include "delta.h"
#include "futils.h"
#include "hash.h"
-#include "odb.h"
-#include "delta.h"
-#include "sha1_lookup.h"
+#include "midx.h"
#include "mwindow.h"
+#include "odb.h"
#include "pack.h"
#include "git2/odb_backend.h"
@@ -26,6 +26,8 @@
struct pack_backend {
git_odb_backend parent;
+ git_midx_file *midx;
+ git_vector midx_packs;
git_vector packs;
struct git_pack_file *last_found;
char *pack_folder;
@@ -48,36 +50,43 @@ struct pack_writepack {
* Initialization of the Pack Backend
* --------------------------------------------------
*
- * # git_odb_backend_pack
- * | Creates the pack backend structure, initializes the
- * | callback pointers to our default read() and exist() methods,
- * | and tries to preload all the known packfiles in the ODB.
+ * # git_odb_backend_pack
+ * | Creates the pack backend structure, initializes the
+ * | callback pointers to our default read() and exist() methods,
+ * | and tries to find the `pack` folder, if it exists. ODBs without a `pack`
+ * | folder are ignored altogether. If there is a `pack` folder, it tries to
+ * | preload all the known packfiles in the ODB.
* |
- * |-# packfile_load_all
- * | Tries to find the `pack` folder, if it exists. ODBs without
- * | a pack folder are ignored altogether. If there's a `pack` folder
- * | we run a `dirent` callback through every file in the pack folder
- * | to find our packfiles. The packfiles are then sorted according
- * | to a sorting callback.
- * |
- * |-# packfile_load__cb
- * | | This callback is called from `dirent` with every single file
- * | | inside the pack folder. We find the packs by actually locating
- * | | their index (ends in ".idx"). From that index, we verify that
- * | | the corresponding packfile exists and is valid, and if so, we
- * | | add it to the pack list.
- * | |
- * | |-# packfile_check
- * | Make sure that there's a packfile to back this index, and store
- * | some very basic information regarding the packfile itself,
- * | such as the full path, the size, and the modification time.
- * | We don't actually open the packfile to check for internal consistency.
- * |
- * |-# packfile_sort__cb
- * Sort all the preloaded packs according to some specific criteria:
- * we prioritize the "newer" packs because it's more likely they
- * contain the objects we are looking for, and we prioritize local
- * packs over remote ones.
+ * |-# pack_backend__refresh
+ * | The `multi-pack-index` is loaded if it exists and is valid.
+ * | Then we run a `dirent` callback through every file in the pack folder,
+ * | even those present in `multi-pack-index`. The unindexed packfiles are
+ * | then sorted according to a sorting callback.
+ * |
+ * |-# refresh_multi_pack_index
+ * | Detect the presence of the `multi-pack-index` file. If it needs to be
+ * | refreshed, frees the old copy and tries to load the new one, together
+ * | with all the packfiles it indexes. If the process fails, fall back to
+ * | the old behavior, as if the `multi-pack-index` file was not there.
+ * |
+ * |-# packfile_load__cb
+ * | | This callback is called from `dirent` with every single file
+ * | | inside the pack folder. We find the packs by actually locating
+ * | | their index (ends in ".idx"). From that index, we verify that
+ * | | the corresponding packfile exists and is valid, and if so, we
+ * | | add it to the pack list.
+ * | |
+ * | # git_mwindow_get_pack
+ * | Make sure that there's a packfile to back this index, and store
+ * | some very basic information regarding the packfile itself,
+ * | such as the full path, the size, and the modification time.
+ * | We don't actually open the packfile to check for internal consistency.
+ * |
+ * |-# packfile_sort__cb
+ * Sort all the preloaded packs according to some specific criteria:
+ * we prioritize the "newer" packs because it's more likely they
+ * contain the objects we are looking for, and we prioritize local
+ * packs over remote ones.
*
*
*
@@ -85,48 +94,66 @@ struct pack_writepack {
* A standard packed `exist` query for an OID
* --------------------------------------------------
*
- * # pack_backend__exists
- * | Check if the given SHA1 oid exists in any of the packs
- * | that have been loaded for our ODB.
+ * # pack_backend__exists / pack_backend__exists_prefix
+ * | Check if the given SHA1 oid (or a SHA1 oid prefix) exists in any of the
+ * | packs that have been loaded for our ODB.
* |
- * |-# pack_entry_find
- * | Iterate through all the packs that have been preloaded
- * | (starting by the pack where the latest object was found)
- * | to try to find the OID in one of them.
- * |
- * |-# pack_entry_find1
- * | Check the index of an individual pack to see if the SHA1
- * | OID can be found. If we can find the offset to that SHA1
- * | inside of the index, that means the object is contained
- * | inside of the packfile and we can stop searching.
- * | Before returning, we verify that the packfile behing the
- * | index we are searching still exists on disk.
- * |
- * |-# pack_entry_find_offset
- * | | Mmap the actual index file to disk if it hasn't been opened
- * | | yet, and run a binary search through it to find the OID.
- * | | See <http://book.git-scm.com/7_the_packfile.html> for specifics
- * | | on the Packfile Index format and how do we find entries in it.
- * | |
- * | |-# pack_index_open
- * | | Guess the name of the index based on the full path to the
- * | | packfile, open it and verify its contents. Only if the index
- * | | has not been opened already.
- * | |
- * | |-# pack_index_check
- * | Mmap the index file and do a quick run through the header
- * | to guess the index version (right now we support v1 and v2),
- * | and to verify that the size of the index makes sense.
- * |
- * |-# packfile_open
- * See `packfile_open` in Chapter 3
+ * |-# pack_entry_find / pack_entry_find_prefix
+ * | If there is a multi-pack-index present, search the SHA1 oid in that
+ * | index first. If it is not found there, iterate through all the unindexed
+ * | packs that have been preloaded (starting by the pack where the latest
+ * | object was found) to try to find the OID in one of them.
+ * |
+ * |-# git_midx_entry_find
+ * | Search for the SHA1 oid in the multi-pack-index. See
+ * | <https://github.com/git/git/blob/master/Documentation/technical/pack-format.txt>
+ * | for specifics on the multi-pack-index format and how do we find
+ * | entries in it.
+ * |
+ * |-# git_pack_entry_find
+ * | Check the index of an individual unindexed pack to see if the SHA1
+ * | OID can be found. If we can find the offset to that SHA1 inside of the
+ * | index, that means the object is contained inside of the packfile and
+ * | we can stop searching. Before returning, we verify that the
+ * | packfile behing the index we are searching still exists on disk.
+ * |
+ * |-# pack_entry_find_offset
+ * | Mmap the actual index file to disk if it hasn't been opened
+ * | yet, and run a binary search through it to find the OID.
+ * | See <https://github.com/git/git/blob/master/Documentation/technical/pack-format.txt>
+ * | for specifics on the Packfile Index format and how do we find
+ * | entries in it.
+ * |
+ * |-# pack_index_open
+ * | Guess the name of the index based on the full path to the
+ * | packfile, open it and verify its contents. Only if the index
+ * | has not been opened already.
+ * |
+ * |-# pack_index_check
+ * Mmap the index file and do a quick run through the header
+ * to guess the index version (right now we support v1 and v2),
+ * and to verify that the size of the index makes sense.
*
*
*
* Chapter 3: The neverending story...
* A standard packed `lookup` query for an OID
* --------------------------------------------------
- * TODO
+ *
+ * # pack_backend__read / pack_backend__read_prefix
+ * | Check if the given SHA1 oid (or a SHA1 oid prefix) exists in any of the
+ * | packs that have been loaded for our ODB. If it does, open the packfile and
+ * | read from it.
+ * |
+ * |-# git_packfile_unpack
+ * Armed with a packfile and the offset within it, we can finally unpack
+ * the object pointed at by the SHA1 oid. This involves mmapping part of
+ * the `.pack` file, and uncompressing the object within it (if it is
+ * stored in the undelfitied representation), or finding a base object and
+ * applying some deltas to its uncompressed representation (if it is stored
+ * in the deltified representation). See
+ * <https://github.com/git/git/blob/master/Documentation/technical/pack-format.txt>
+ * for specifics on the Packfile format and how do we read from it.
*
*/
@@ -141,6 +168,8 @@ static int packfile_sort__cb(const void *a_, const void *b_);
static int packfile_load__cb(void *_data, git_buf *path);
+static int packfile_byname_search_cmp(const void *path, const void *pack_entry);
+
static int pack_entry_find(struct git_pack_entry *e,
struct pack_backend *backend, const git_oid *oid);
@@ -164,6 +193,14 @@ static int pack_entry_find_prefix(
*
***********************************************************/
+static int packfile_byname_search_cmp(const void *path_, const void *p_)
+{
+ const git_buf *path = (const git_buf *)path_;
+ const struct git_pack_file *p = (const struct git_pack_file *)p_;
+
+ return strncmp(p->pack_name, git_buf_cstr(path), git_buf_len(path));
+}
+
static int packfile_sort__cb(const void *a_, const void *b_)
{
const struct git_pack_file *a = a_;
@@ -199,20 +236,20 @@ static int packfile_load__cb(void *data, git_buf *path)
struct pack_backend *backend = data;
struct git_pack_file *pack;
const char *path_str = git_buf_cstr(path);
- size_t i, cmp_len = git_buf_len(path);
+ git_buf index_prefix = GIT_BUF_INIT;
+ size_t cmp_len = git_buf_len(path);
int error;
if (cmp_len <= strlen(".idx") || git__suffixcmp(path_str, ".idx") != 0)
return 0; /* not an index */
cmp_len -= strlen(".idx");
+ git_buf_attach_notowned(&index_prefix, path_str, cmp_len);
- for (i = 0; i < backend->packs.length; ++i) {
- struct git_pack_file *p = git_vector_get(&backend->packs, i);
-
- if (strncmp(p->pack_name, path_str, cmp_len) == 0)
- return 0;
- }
+ if (git_vector_search2(NULL, &backend->midx_packs, packfile_byname_search_cmp, &index_prefix) == 0)
+ return 0;
+ if (git_vector_search2(NULL, &backend->packs, packfile_byname_search_cmp, &index_prefix) == 0)
+ return 0;
error = git_mwindow_get_pack(&pack, path->ptr);
@@ -229,22 +266,26 @@ static int packfile_load__cb(void *data, git_buf *path)
}
-static int pack_entry_find_inner(
- struct git_pack_entry *e,
- struct pack_backend *backend,
- const git_oid *oid,
- struct git_pack_file *last_found)
+static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backend, const git_oid *oid)
{
+ struct git_pack_file *last_found = backend->last_found, *p;
+ git_midx_entry midx_entry;
size_t i;
+ if (backend->midx &&
+ git_midx_entry_find(&midx_entry, backend->midx, oid, GIT_OID_HEXSZ) == 0 &&
+ midx_entry.pack_index < git_vector_length(&backend->midx_packs)) {
+ e->offset = midx_entry.offset;
+ git_oid_cpy(&e->sha1, &midx_entry.sha1);
+ e->p = git_vector_get(&backend->midx_packs, midx_entry.pack_index);
+ return 0;
+ }
+
if (last_found &&
git_pack_entry_find(e, last_found, oid, GIT_OID_HEXSZ) == 0)
return 0;
- for (i = 0; i < backend->packs.length; ++i) {
- struct git_pack_file *p;
-
- p = git_vector_get(&backend->packs, i);
+ git_vector_foreach(&backend->packs, i, p) {
if (p == last_found)
continue;
@@ -254,20 +295,6 @@ static int pack_entry_find_inner(
}
}
- return -1;
-}
-
-static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backend, const git_oid *oid)
-{
- struct git_pack_file *last_found = backend->last_found;
-
- if (backend->last_found &&
- git_pack_entry_find(e, backend->last_found, oid, GIT_OID_HEXSZ) == 0)
- return 0;
-
- if (!pack_entry_find_inner(e, backend, oid, last_found))
- return 0;
-
return git_odb__error_notfound(
"failed to find pack entry", oid, GIT_OID_HEXSZ);
}
@@ -282,22 +309,35 @@ static int pack_entry_find_prefix(
size_t i;
git_oid found_full_oid = {{0}};
bool found = false;
- struct git_pack_file *last_found = backend->last_found;
+ struct git_pack_file *last_found = backend->last_found, *p;
+ git_midx_entry midx_entry;
+
+ if (backend->midx) {
+ error = git_midx_entry_find(&midx_entry, backend->midx, short_oid, len);
+ if (error == GIT_EAMBIGUOUS)
+ return error;
+ if (!error && midx_entry.pack_index < git_vector_length(&backend->midx_packs)) {
+ e->offset = midx_entry.offset;
+ git_oid_cpy(&e->sha1, &midx_entry.sha1);
+ e->p = git_vector_get(&backend->midx_packs, midx_entry.pack_index);
+ git_oid_cpy(&found_full_oid, &e->sha1);
+ found = true;
+ }
+ }
if (last_found) {
error = git_pack_entry_find(e, last_found, short_oid, len);
if (error == GIT_EAMBIGUOUS)
return error;
if (!error) {
+ if (found && git_oid_cmp(&e->sha1, &found_full_oid))
+ return git_odb__error_ambiguous("found multiple pack entries");
git_oid_cpy(&found_full_oid, &e->sha1);
found = true;
}
}
- for (i = 0; i < backend->packs.length; ++i) {
- struct git_pack_file *p;
-
- p = git_vector_get(&backend->packs, i);
+ git_vector_foreach(&backend->packs, i, p) {
if (p == last_found)
continue;
@@ -320,6 +360,141 @@ static int pack_entry_find_prefix(
return 0;
}
+/***********************************************************
+ *
+ * MULTI-PACK-INDEX SUPPORT
+ *
+ * Functions needed to support the multi-pack-index.
+ *
+ ***********************************************************/
+
+/*
+ * Remove the multi-pack-index, and move all midx_packs to packs.
+ */
+static int remove_multi_pack_index(struct pack_backend *backend)
+{
+ size_t i, j = git_vector_length(&backend->packs);
+ struct pack_backend *p;
+ int error = git_vector_size_hint(
+ &backend->packs,
+ j + git_vector_length(&backend->midx_packs));
+ if (error < 0)
+ return error;
+
+ git_vector_foreach(&backend->midx_packs, i, p)
+ git_vector_set(NULL, &backend->packs, j++, p);
+ git_vector_clear(&backend->midx_packs);
+
+ git_midx_free(backend->midx);
+ backend->midx = NULL;
+
+ return 0;
+}
+
+/*
+ * Loads a single .pack file referred to by the multi-pack-index. These must
+ * match the order in which they are declared in the multi-pack-index file,
+ * since these files are referred to by their index.
+ */
+static int process_multi_pack_index_pack(
+ struct pack_backend *backend,
+ size_t i,
+ const char *packfile_name)
+{
+ int error;
+ size_t cmp_len = strlen(packfile_name);
+ struct git_pack_file *pack;
+ size_t found_position;
+ git_buf pack_path = GIT_BUF_INIT, index_prefix = GIT_BUF_INIT;
+
+ error = git_buf_joinpath(&pack_path, backend->pack_folder, packfile_name);
+ if (error < 0)
+ return error;
+
+ /* This is ensured by midx__parse_packfile_name() */
+ if (cmp_len <= strlen(".idx") || git__suffixcmp(git_buf_cstr(&pack_path), ".idx") != 0)
+ return git_odb__error_notfound("midx file contained a non-index", NULL, 0);
+
+ cmp_len -= strlen(".idx");
+ git_buf_attach_notowned(&index_prefix, git_buf_cstr(&pack_path), cmp_len);
+
+ if (git_vector_search2(&found_position, &backend->packs, packfile_byname_search_cmp, &index_prefix) == 0) {
+ /* Pack was found in the packs list. Moving it to the midx_packs list. */
+ git_buf_dispose(&pack_path);
+ git_vector_set(NULL, &backend->midx_packs, i, git_vector_get(&backend->packs, found_position));
+ git_vector_remove(&backend->packs, found_position);
+ return 0;
+ }
+
+ /* Pack was not found. Allocate a new one. */
+ error = git_mwindow_get_pack(&pack, git_buf_cstr(&pack_path));
+ git_buf_dispose(&pack_path);
+ if (error < 0)
+ return error;
+
+ git_vector_set(NULL, &backend->midx_packs, i, pack);
+ return 0;
+}
+
+/*
+ * Reads the multi-pack-index. If this fails for whatever reason, the
+ * multi-pack-index object is freed, and all the packfiles that are related to
+ * it are moved to the unindexed packfiles vector.
+ */
+static int refresh_multi_pack_index(struct pack_backend *backend)
+{
+ int error;
+ git_buf midx_path = GIT_BUF_INIT;
+ const char *packfile_name;
+ size_t i;
+
+ error = git_buf_joinpath(&midx_path, backend->pack_folder, "multi-pack-index");
+ if (error < 0)
+ return error;
+
+ /*
+ * Check whether the multi-pack-index has changed. If it has, close any
+ * old multi-pack-index and move all the packfiles to the unindexed
+ * packs. This is done to prevent losing any open packfiles in case
+ * refreshing the new multi-pack-index fails, or the file is deleted.
+ */
+ if (backend->midx) {
+ if (!git_midx_needs_refresh(backend->midx, git_buf_cstr(&midx_path))) {
+ git_buf_dispose(&midx_path);
+ return 0;
+ }
+ error = remove_multi_pack_index(backend);
+ if (error < 0) {
+ git_buf_dispose(&midx_path);
+ return error;
+ }
+ }
+
+ error = git_midx_open(&backend->midx, git_buf_cstr(&midx_path));
+ git_buf_dispose(&midx_path);
+ if (error < 0)
+ return error;
+
+ git_vector_resize_to(&backend->midx_packs, git_vector_length(&backend->midx->packfile_names));
+
+ git_vector_foreach(&backend->midx->packfile_names, i, packfile_name) {
+ error = process_multi_pack_index_pack(backend, i, packfile_name);
+ if (error < 0) {
+ /*
+ * Something failed during reading multi-pack-index.
+ * Restore the state of backend as if the
+ * multi-pack-index was never there, and move all
+ * packfiles that have been processed so far to the
+ * unindexed packs.
+ */
+ git_vector_resize_to(&backend->midx_packs, i);
+ remove_multi_pack_index(backend);
+ return error;
+ }
+ }
+
+ return 0;
+}
/***********************************************************
*
@@ -341,9 +516,16 @@ static int pack_backend__refresh(git_odb_backend *backend_)
if (p_stat(backend->pack_folder, &st) < 0 || !S_ISDIR(st.st_mode))
return git_odb__error_notfound("failed to refresh packfiles", NULL, 0);
- git_buf_sets(&path, backend->pack_folder);
+ if (refresh_multi_pack_index(backend) < 0) {
+ /*
+ * It is okay if this fails. We will just not use the
+ * multi-pack-index in this case.
+ */
+ git_error_clear();
+ }
/* reload all packs */
+ git_buf_sets(&path, backend->pack_folder);
error = git_path_direach(&path, 0, packfile_load__cb, backend);
git_buf_dispose(&path);
@@ -359,7 +541,10 @@ static int pack_backend__read_header(
struct git_pack_entry e;
int error;
- assert(len_p && type_p && backend && oid);
+ GIT_ASSERT_ARG(len_p);
+ GIT_ASSERT_ARG(type_p);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(oid);
if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0)
return error;
@@ -470,13 +655,17 @@ static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb c
struct pack_backend *backend;
unsigned int i;
- assert(_backend && cb);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(cb);
+
backend = (struct pack_backend *)_backend;
/* Make sure we know about the packfiles */
- if ((error = pack_backend__refresh(_backend)) < 0)
+ if ((error = pack_backend__refresh(_backend)) != 0)
return error;
+ if (backend->midx && (error = git_midx_foreach_entry(backend->midx, cb, data)) != 0)
+ return error;
git_vector_foreach(&backend->packs, i, p) {
if ((error = git_pack_foreach_entry(p, cb, data)) != 0)
return error;
@@ -489,7 +678,7 @@ static int pack_backend__writepack_append(struct git_odb_writepack *_writepack,
{
struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
- assert(writepack);
+ GIT_ASSERT_ARG(writepack);
return git_indexer_append(writepack->indexer, data, size, stats);
}
@@ -498,16 +687,19 @@ static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack,
{
struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
- assert(writepack);
+ GIT_ASSERT_ARG(writepack);
return git_indexer_commit(writepack->indexer, stats);
}
static void pack_backend__writepack_free(struct git_odb_writepack *_writepack)
{
- struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
+ struct pack_writepack *writepack;
- assert(writepack);
+ if (!_writepack)
+ return;
+
+ writepack = (struct pack_writepack *)_writepack;
git_indexer_free(writepack->indexer);
git__free(writepack);
@@ -523,7 +715,8 @@ static int pack_backend__writepack(struct git_odb_writepack **out,
struct pack_backend *backend;
struct pack_writepack *writepack;
- assert(out && _backend);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(_backend);
*out = NULL;
@@ -554,17 +747,21 @@ static int pack_backend__writepack(struct git_odb_writepack **out,
static void pack_backend__free(git_odb_backend *_backend)
{
struct pack_backend *backend;
+ struct git_pack_file *p;
size_t i;
- assert(_backend);
+ if (!_backend)
+ return;
backend = (struct pack_backend *)_backend;
- for (i = 0; i < backend->packs.length; ++i) {
- struct git_pack_file *p = git_vector_get(&backend->packs, i);
+ git_vector_foreach(&backend->midx_packs, i, p)
+ git_mwindow_put_pack(p);
+ git_vector_foreach(&backend->packs, i, p)
git_mwindow_put_pack(p);
- }
+ git_midx_free(backend->midx);
+ git_vector_free(&backend->midx_packs);
git_vector_free(&backend->packs);
git__free(backend->pack_folder);
git__free(backend);
@@ -575,7 +772,12 @@ static int pack_backend__alloc(struct pack_backend **out, size_t initial_size)
struct pack_backend *backend = git__calloc(1, sizeof(struct pack_backend));
GIT_ERROR_CHECK_ALLOC(backend);
+ if (git_vector_init(&backend->midx_packs, 0, NULL) < 0) {
+ git__free(backend);
+ return -1;
+ }
if (git_vector_init(&backend->packs, initial_size, packfile_sort__cb) < 0) {
+ git_vector_free(&backend->midx_packs);
git__free(backend);
return -1;
}
diff --git a/src/oid.c b/src/oid.c
index 6419566..893e2fc 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -9,7 +9,7 @@
#include "git2/oid.h"
#include "repository.h"
-#include "global.h"
+#include "threadstate.h"
#include <string.h>
#include <limits.h>
@@ -26,7 +26,8 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
size_t p;
int v;
- assert(out && str);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(str);
if (!length)
return oid_error_invalid("too short");
@@ -107,7 +108,7 @@ int git_oid_pathfmt(char *str, const git_oid *oid)
char *git_oid_tostr_s(const git_oid *oid)
{
- char *str = GIT_GLOBAL->oid_fmt;
+ char *str = GIT_THREADSTATE->oid_fmt;
git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid);
return str;
}
@@ -253,10 +254,12 @@ int git_oid_is_zero(const git_oid *oid_a)
return 1;
}
+#ifndef GIT_DEPRECATE_HARD
int git_oid_iszero(const git_oid *oid_a)
{
return git_oid_is_zero(oid_a);
}
+#endif
typedef short node_index;
@@ -314,7 +317,7 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length)
{
git_oid_shorten *os;
- assert((size_t)((int)min_length) == min_length);
+ GIT_ASSERT_ARG_WITH_RETVAL((size_t)((int)min_length) == min_length, NULL);
os = git__calloc(1, sizeof(git_oid_shorten));
if (os == NULL)
diff --git a/src/pack-objects.c b/src/pack-objects.c
index bdd5171..faff310 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -12,7 +12,7 @@
#include "iterator.h"
#include "netops.h"
#include "pack.h"
-#include "thread-utils.h"
+#include "thread.h"
#include "tree.h"
#include "util.h"
#include "revwalk.h"
@@ -48,18 +48,10 @@ struct walk_object {
};
#ifdef GIT_THREADS
-
-#define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \
- int result = git_mutex_##op(&(pb)->mtx); \
- assert(!result); \
- GIT_UNUSED(result); \
- } while (0)
-
+# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) git_mutex_##op(&(pb)->mtx)
#else
-
-#define GIT_PACKBUILDER__MUTEX_OP(pb,mtx,op) GIT_UNUSED(pb)
-
-#endif /* GIT_THREADS */
+# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) git__noop()
+#endif
#define git_packbuilder__cache_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, lock)
#define git_packbuilder__cache_unlock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, unlock)
@@ -141,14 +133,11 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
pb = git__calloc(1, sizeof(*pb));
GIT_ERROR_CHECK_ALLOC(pb);
- if (git_oidmap_new(&pb->object_ix) < 0)
- goto on_error;
-
- if (git_oidmap_new(&pb->walk_objects) < 0)
+ if (git_oidmap_new(&pb->object_ix) < 0 ||
+ git_oidmap_new(&pb->walk_objects) < 0 ||
+ git_pool_init(&pb->object_pool, sizeof(struct walk_object)) < 0)
goto on_error;
- git_pool_init(&pb->object_pool, sizeof(struct walk_object));
-
pb->repo = repo;
pb->nr_threads = 1; /* do not spawn any thread by default */
@@ -180,13 +169,13 @@ on_error:
unsigned int git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n)
{
- assert(pb);
+ GIT_ASSERT_ARG(pb);
#ifdef GIT_THREADS
pb->nr_threads = n;
#else
GIT_UNUSED(n);
- assert(1 == pb->nr_threads);
+ GIT_ASSERT(pb->nr_threads == 1);
#endif
return pb->nr_threads;
@@ -214,7 +203,8 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
size_t newsize;
int ret;
- assert(pb && oid);
+ GIT_ASSERT_ARG(pb);
+ GIT_ASSERT_ARG(oid);
/* If the object already exists in the hash table, then we don't
* have any work to do */
@@ -261,7 +251,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
double current_time = git__timer();
double elapsed = current_time - pb->last_progress_report_time;
- if (elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
+ if (elapsed < 0 || elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
pb->last_progress_report_time = current_time;
ret = pb->progress_cb(
@@ -350,10 +340,9 @@ static int write_object(
}
/* Write header */
- hdr_len = git_packfile__object_header(hdr, data_len, type);
-
- if ((error = write_cb(hdr, hdr_len, cb_data)) < 0 ||
- (error = git_hash_update(&pb->ctx, hdr, hdr_len)) < 0)
+ if ((error = git_packfile__object_header(&hdr_len, hdr, data_len, type)) < 0 ||
+ (error = write_cb(hdr, hdr_len, cb_data)) < 0 ||
+ (error = git_hash_update(&pb->ctx, hdr, hdr_len)) < 0)
goto done;
if (type == GIT_OBJECT_REF_DELTA) {
@@ -374,7 +363,9 @@ static int write_object(
GIT_ERROR_CHECK_ALLOC(zbuf);
git_zstream_reset(&pb->zstream);
- git_zstream_set_input(&pb->zstream, data, data_len);
+
+ if ((error = git_zstream_set_input(&pb->zstream, data, data_len)) < 0)
+ goto done;
while (!git_zstream_done(&pb->zstream)) {
if ((error = git_zstream_get_output(zbuf, &zbuf_len, &pb->zstream)) < 0 ||
@@ -526,13 +517,18 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
return 0;
}
-static git_pobject **compute_write_order(git_packbuilder *pb)
+static int compute_write_order(git_pobject ***out, git_packbuilder *pb)
{
size_t i, wo_end, last_untagged;
git_pobject **wo;
+ *out = NULL;
+
+ if (!pb->nr_objects)
+ return 0;
+
if ((wo = git__mallocarray(pb->nr_objects, sizeof(*wo))) == NULL)
- return NULL;
+ return -1;
for (i = 0; i < pb->nr_objects; i++) {
git_pobject *po = pb->object_list + i;
@@ -561,7 +557,7 @@ static git_pobject **compute_write_order(git_packbuilder *pb)
*/
if (git_tag_foreach(pb->repo, &cb_tag_foreach, pb) < 0) {
git__free(wo);
- return NULL;
+ return -1;
}
/*
@@ -618,10 +614,11 @@ static git_pobject **compute_write_order(git_packbuilder *pb)
if (wo_end != pb->nr_objects) {
git__free(wo);
git_error_set(GIT_ERROR_INVALID, "invalid write order");
- return NULL;
+ return -1;
}
- return wo;
+ *out = wo;
+ return 0;
}
static int write_pack(git_packbuilder *pb,
@@ -634,15 +631,15 @@ static int write_pack(git_packbuilder *pb,
struct git_pack_header ph;
git_oid entry_oid;
size_t i = 0;
- int error = 0;
+ int error;
- write_order = compute_write_order(pb);
- if (write_order == NULL)
- return -1;
+ if ((error = compute_write_order(&write_order, pb)) < 0)
+ return error;
if (!git__is_uint32(pb->nr_objects)) {
git_error_set(GIT_ERROR_INVALID, "too many objects");
- return -1;
+ error = -1;
+ goto done;
}
/* Write pack header */
@@ -853,10 +850,11 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
}
}
- git_packbuilder__cache_lock(pb);
+ GIT_ASSERT(git_packbuilder__cache_lock(pb) == 0);
+
if (trg_object->delta_data) {
git__free(trg_object->delta_data);
- assert(pb->delta_cache_size >= trg_object->delta_size);
+ GIT_ASSERT(pb->delta_cache_size >= trg_object->delta_size);
pb->delta_cache_size -= trg_object->delta_size;
trg_object->delta_data = NULL;
}
@@ -864,7 +862,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
bool overflow = git__add_sizet_overflow(
&pb->delta_cache_size, pb->delta_cache_size, delta_size);
- git_packbuilder__cache_unlock(pb);
+ GIT_ASSERT(git_packbuilder__cache_unlock(pb) == 0);
if (overflow) {
git__free(delta_buf);
@@ -875,7 +873,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
GIT_ERROR_CHECK_ALLOC(trg_object->delta_data);
} else {
/* create delta when writing the pack */
- git_packbuilder__cache_unlock(pb);
+ GIT_ASSERT(git_packbuilder__cache_unlock(pb) == 0);
git__free(delta_buf);
}
@@ -930,7 +928,7 @@ static int report_delta_progress(
double current_time = git__timer();
double elapsed = current_time - pb->last_progress_report_time;
- if (force || elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
+ if (force || elapsed < 0 || elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
pb->last_progress_report_time = current_time;
ret = pb->progress_cb(
@@ -963,9 +961,9 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
struct unpacked *n = array + idx;
size_t max_depth, j, best_base = SIZE_MAX;
- git_packbuilder__progress_lock(pb);
+ GIT_ASSERT(git_packbuilder__progress_lock(pb) == 0);
if (!*list_size) {
- git_packbuilder__progress_unlock(pb);
+ GIT_ASSERT(git_packbuilder__progress_unlock(pb) == 0);
break;
}
@@ -974,7 +972,7 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
po = *list++;
(*list_size)--;
- git_packbuilder__progress_unlock(pb);
+ GIT_ASSERT(git_packbuilder__progress_unlock(pb) == 0);
mem_usage -= free_unpacked(n);
n->object = po;
@@ -1049,10 +1047,10 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
po->z_delta_size = zbuf.size;
git_buf_clear(&zbuf);
- git_packbuilder__cache_lock(pb);
+ GIT_ASSERT(git_packbuilder__cache_lock(pb) == 0);
pb->delta_cache_size -= po->delta_size;
pb->delta_cache_size += po->z_delta_size;
- git_packbuilder__cache_unlock(pb);
+ GIT_ASSERT(git_packbuilder__cache_unlock(pb) == 0);
}
/*
@@ -1130,10 +1128,10 @@ static void *threaded_find_deltas(void *arg)
; /* TODO */
}
- git_packbuilder__progress_lock(me->pb);
+ GIT_ASSERT_WITH_RETVAL(git_packbuilder__progress_lock(me->pb) == 0, NULL);
me->working = 0;
git_cond_signal(&me->pb->progress_cond);
- git_packbuilder__progress_unlock(me->pb);
+ GIT_ASSERT_WITH_RETVAL(git_packbuilder__progress_unlock(me->pb) == 0, NULL);
if (git_mutex_lock(&me->mutex)) {
git_error_set(GIT_ERROR_THREAD, "unable to lock packfile condition mutex");
@@ -1166,7 +1164,7 @@ static int ll_find_deltas(git_packbuilder *pb, git_pobject **list,
int ret, active_threads = 0;
if (!pb->nr_threads)
- pb->nr_threads = git_online_cpus();
+ pb->nr_threads = git__online_cpus();
if (pb->nr_threads <= 1) {
find_deltas(pb, list, &list_size, window, depth);
@@ -1238,7 +1236,7 @@ static int ll_find_deltas(git_packbuilder *pb, git_pobject **list,
* 'working' flag from 1 -> 0. This indicates that it is
* ready to receive more work using our work-stealing
* algorithm. */
- git_packbuilder__progress_lock(pb);
+ GIT_ASSERT(git_packbuilder__progress_lock(pb) == 0);
for (;;) {
for (i = 0; !target && i < pb->nr_threads; i++)
if (!p[i].working)
@@ -1281,7 +1279,7 @@ static int ll_find_deltas(git_packbuilder *pb, git_pobject **list,
target->list_size = sub_size;
target->remaining = sub_size;
target->working = 1;
- git_packbuilder__progress_unlock(pb);
+ GIT_ASSERT(git_packbuilder__progress_unlock(pb) == 0);
if (git_mutex_lock(&target->mutex)) {
git_error_set(GIT_ERROR_THREAD, "unable to lock packfile condition mutex");
@@ -1364,8 +1362,13 @@ int git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t siz
int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb)
{
+ int error;
+
+ if ((error = git_buf_sanitize(buf)) < 0)
+ return error;
+
PREPARE_PACK;
- git_buf_sanitize(buf);
+
return write_pack(pb, &write_pack_buf, buf);
}
@@ -1382,20 +1385,29 @@ int git_packbuilder_write(
git_indexer_progress_cb progress_cb,
void *progress_cb_payload)
{
+ int error = -1;
+ git_buf object_path = GIT_BUF_INIT;
git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
- git_indexer *indexer;
+ git_indexer *indexer = NULL;
git_indexer_progress stats;
struct pack_write_context ctx;
int t;
PREPARE_PACK;
+ if (path == NULL) {
+ if ((error = git_repository_item_path(&object_path, pb->repo, GIT_REPOSITORY_ITEM_OBJECTS)) < 0)
+ goto cleanup;
+ if ((error = git_buf_joinpath(&object_path, git_buf_cstr(&object_path), "pack")) < 0)
+ goto cleanup;
+ path = git_buf_cstr(&object_path);
+ }
+
opts.progress_cb = progress_cb;
opts.progress_cb_payload = progress_cb_payload;
- if (git_indexer_new(
- &indexer, path, mode, pb->odb, &opts) < 0)
- return -1;
+ if ((error = git_indexer_new(&indexer, path, mode, pb->odb, &opts)) < 0)
+ goto cleanup;
if (!git_repository__configmap_lookup(&t, pb->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t)
git_indexer__set_fsync(indexer, 1);
@@ -1403,16 +1415,18 @@ int git_packbuilder_write(
ctx.indexer = indexer;
ctx.stats = &stats;
- if (git_packbuilder_foreach(pb, write_cb, &ctx) < 0 ||
- git_indexer_commit(indexer, &stats) < 0) {
- git_indexer_free(indexer);
- return -1;
- }
+ if ((error = git_packbuilder_foreach(pb, write_cb, &ctx)) < 0)
+ goto cleanup;
+
+ if ((error = git_indexer_commit(indexer, &stats)) < 0)
+ goto cleanup;
git_oid_cpy(&pb->pack_oid, git_indexer_hash(indexer));
+cleanup:
git_indexer_free(indexer);
- return 0;
+ git_buf_dispose(&object_path);
+ return error;
}
#undef PREPARE_PACK
@@ -1476,7 +1490,8 @@ int git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid *id, const c
git_object *obj;
int error;
- assert(pb && id);
+ GIT_ASSERT_ARG(pb);
+ GIT_ASSERT_ARG(id);
if ((error = git_object_lookup(&obj, pb->repo, id, GIT_OBJECT_ANY)) < 0)
return error;
@@ -1632,7 +1647,7 @@ static int mark_edges_uninteresting(git_packbuilder *pb, git_commit_list *commit
return 0;
}
-int insert_tree(git_packbuilder *pb, git_tree *tree)
+static int pack_objects_insert_tree(git_packbuilder *pb, git_tree *tree)
{
size_t i;
int error;
@@ -1659,7 +1674,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
if ((error = git_tree_lookup(&subtree, pb->repo, entry_id)) < 0)
return error;
- error = insert_tree(pb, subtree);
+ error = pack_objects_insert_tree(pb, subtree);
git_tree_free(subtree);
if (error < 0)
@@ -1685,7 +1700,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
return error;
}
-int insert_commit(git_packbuilder *pb, struct walk_object *obj)
+static int pack_objects_insert_commit(git_packbuilder *pb, struct walk_object *obj)
{
int error;
git_commit *commit = NULL;
@@ -1702,7 +1717,7 @@ int insert_commit(git_packbuilder *pb, struct walk_object *obj)
if ((error = git_tree_lookup(&tree, pb->repo, git_commit_tree_id(commit))) < 0)
goto cleanup;
- if ((error = insert_tree(pb, tree)) < 0)
+ if ((error = pack_objects_insert_tree(pb, tree)) < 0)
goto cleanup;
cleanup:
@@ -1717,7 +1732,8 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk)
git_oid id;
struct walk_object *obj;
- assert(pb && walk);
+ GIT_ASSERT_ARG(pb);
+ GIT_ASSERT_ARG(walk);
if ((error = mark_edges_uninteresting(pb, walk->user_input)) < 0)
return error;
@@ -1737,7 +1753,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk)
if (obj->seen || obj->uninteresting)
continue;
- if ((error = insert_commit(pb, obj)) < 0)
+ if ((error = pack_objects_insert_commit(pb, obj)) < 0)
return error;
}
diff --git a/src/pack.c b/src/pack.c
index 7c6fc2c..5d284ca 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -12,13 +12,13 @@
#include "mwindow.h"
#include "odb.h"
#include "oid.h"
-#include "sha1_lookup.h"
+#include "oidarray.h"
/* Option to bypass checking existence of '.keep' files */
bool git_disable_pack_keep_file_checks = false;
-static int packfile_open(struct git_pack_file *p);
-static off64_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n);
+static int packfile_open_locked(struct git_pack_file *p);
+static off64_t nth_packed_object_offset_locked(struct git_pack_file *p, uint32_t n);
static int packfile_unpack_compressed(
git_rawobj *obj,
struct git_pack_file *p,
@@ -57,7 +57,7 @@ static git_pack_cache_entry *new_cache_object(git_rawobj *source)
if (!e)
return NULL;
- git_atomic_inc(&e->refcount);
+ git_atomic32_inc(&e->refcount);
memcpy(&e->raw, source, sizeof(git_rawobj));
return e;
@@ -68,7 +68,6 @@ static void free_cache_object(void *o)
git_pack_cache_entry *e = (git_pack_cache_entry *)o;
if (e != NULL) {
- assert(e->refcount.val == 0);
git__free(e->raw.data);
git__free(e);
}
@@ -115,7 +114,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, off64_t offset)
return NULL;
if ((entry = git_offmap_get(cache->entries, offset)) != NULL) {
- git_atomic_inc(&entry->refcount);
+ git_atomic32_inc(&entry->refcount);
entry->last_usage = cache->use_ctr++;
}
git_mutex_unlock(&cache->lock);
@@ -130,7 +129,7 @@ static void free_lowest_entry(git_pack_cache *cache)
git_pack_cache_entry *entry;
git_offmap_foreach(cache->entries, offset, entry, {
- if (entry && entry->refcount.val == 0) {
+ if (entry && git_atomic32_get(&entry->refcount) == 0) {
cache->memory_used -= entry->raw.len;
git_offmap_delete(cache->entries, offset);
free_cache_object(entry);
@@ -197,7 +196,8 @@ static void pack_index_free(struct git_pack_file *p)
}
}
-static int pack_index_check(const char *path, struct git_pack_file *p)
+/* Run with the packfile lock held */
+static int pack_index_check_locked(const char *path, struct git_pack_file *p)
{
struct git_pack_idx_header *hdr;
uint32_t version, nr, i, *index;
@@ -303,40 +303,36 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
return 0;
}
-static int pack_index_open(struct git_pack_file *p)
+/* Run with the packfile lock held */
+static int pack_index_open_locked(struct git_pack_file *p)
{
int error = 0;
size_t name_len;
- git_buf idx_name;
+ git_buf idx_name = GIT_BUF_INIT;
if (p->index_version > -1)
- return 0;
+ goto cleanup;
+ /* checked by git_pack_file alloc */
name_len = strlen(p->pack_name);
- assert(name_len > strlen(".pack")); /* checked by git_pack_file alloc */
+ GIT_ASSERT(name_len > strlen(".pack"));
- if (git_buf_init(&idx_name, name_len) < 0)
- return -1;
+ if ((error = git_buf_init(&idx_name, name_len)) < 0)
+ goto cleanup;
git_buf_put(&idx_name, p->pack_name, name_len - strlen(".pack"));
git_buf_puts(&idx_name, ".idx");
if (git_buf_oom(&idx_name)) {
- git_buf_dispose(&idx_name);
- return -1;
- }
-
- if ((error = git_mutex_lock(&p->lock)) < 0) {
- git_buf_dispose(&idx_name);
- return error;
+ error = -1;
+ goto cleanup;
}
if (p->index_version == -1)
- error = pack_index_check(idx_name.ptr, p);
+ error = pack_index_check_locked(idx_name.ptr, p);
+cleanup:
git_buf_dispose(&idx_name);
- git_mutex_unlock(&p->lock);
-
return error;
}
@@ -346,8 +342,20 @@ static unsigned char *pack_window_open(
off64_t offset,
unsigned int *left)
{
- if (p->mwf.fd == -1 && packfile_open(p) < 0)
+ unsigned char *pack_data = NULL;
+
+ if (git_mutex_lock(&p->lock) < 0) {
+ git_error_set(GIT_ERROR_THREAD, "unable to lock packfile");
+ return NULL;
+ }
+ if (git_mutex_lock(&p->mwf.lock) < 0) {
+ git_mutex_unlock(&p->lock);
+ git_error_set(GIT_ERROR_THREAD, "unable to lock packfile");
return NULL;
+ }
+
+ if (p->mwf.fd == -1 && packfile_open_locked(p) < 0)
+ goto cleanup;
/* Since packfiles end in a hash of their content and it's
* pointless to ask for an offset into the middle of that
@@ -358,11 +366,16 @@ static unsigned char *pack_window_open(
* around.
*/
if (offset > (p->mwf.size - 20))
- return NULL;
+ goto cleanup;
if (offset < 0)
- return NULL;
+ goto cleanup;
- return git_mwindow_open(&p->mwf, w_cursor, offset, 20, left);
+ pack_data = git_mwindow_open(&p->mwf, w_cursor, offset, 20, left);
+
+cleanup:
+ git_mutex_unlock(&p->mwf.lock);
+ git_mutex_unlock(&p->lock);
+ return pack_data;
}
/*
@@ -373,12 +386,12 @@ static unsigned char *pack_window_open(
* - each byte afterwards: low seven bits are size continuation,
* with the high bit being "size continues"
*/
-size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_object_t type)
+int git_packfile__object_header(size_t *out, unsigned char *hdr, size_t size, git_object_t type)
{
unsigned char *hdr_base;
unsigned char c;
- assert(type >= GIT_OBJECT_COMMIT && type <= GIT_OBJECT_REF_DELTA);
+ GIT_ASSERT_ARG(type >= GIT_OBJECT_COMMIT && type <= GIT_OBJECT_REF_DELTA);
/* TODO: add support for chunked objects; see git.git 6c0d19b1 */
@@ -393,7 +406,8 @@ size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_object_t
}
*hdr++ = c;
- return (hdr - hdr_base);
+ *out = (hdr - hdr_base);
+ return 0;
}
@@ -437,14 +451,27 @@ static int packfile_unpack_header1(
int git_packfile_unpack_header(
size_t *size_p,
git_object_t *type_p,
- git_mwindow_file *mwf,
+ struct git_pack_file *p,
git_mwindow **w_curs,
off64_t *curpos)
{
unsigned char *base;
unsigned int left;
unsigned long used;
- int ret;
+ int error;
+
+ if ((error = git_mutex_lock(&p->lock)) < 0)
+ return error;
+ if ((error = git_mutex_lock(&p->mwf.lock)) < 0) {
+ git_mutex_unlock(&p->lock);
+ return error;
+ }
+
+ if (p->mwf.fd == -1 && (error = packfile_open_locked(p)) < 0) {
+ git_mutex_unlock(&p->lock);
+ git_mutex_unlock(&p->mwf.lock);
+ return error;
+ }
/* pack_window_open() assures us we have [base, base + 20) available
* as a range that we can look at at. (Its actually the hash
@@ -452,16 +479,17 @@ int git_packfile_unpack_header(
* the maximum deflated object size is 2^137, which is just
* insane, so we know won't exceed what we have been given.
*/
-/* base = pack_window_open(p, w_curs, *curpos, &left); */
- base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left);
+ base = git_mwindow_open(&p->mwf, w_curs, *curpos, 20, &left);
+ git_mutex_unlock(&p->lock);
+ git_mutex_unlock(&p->mwf.lock);
if (base == NULL)
return GIT_EBUFS;
- ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
+ error = packfile_unpack_header1(&used, size_p, type_p, base, left);
git_mwindow_close(w_curs);
- if (ret == GIT_EBUFS)
- return ret;
- else if (ret < 0)
+ if (error == GIT_EBUFS)
+ return error;
+ else if (error < 0)
return packfile_error("header length is zero");
*curpos += used;
@@ -481,7 +509,27 @@ int git_packfile_resolve_header(
off64_t base_offset;
int error;
- error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
+ error = git_mutex_lock(&p->lock);
+ if (error < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile reader");
+ return error;
+ }
+ error = git_mutex_lock(&p->mwf.lock);
+ if (error < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile reader");
+ git_mutex_unlock(&p->lock);
+ return error;
+ }
+
+ if (p->mwf.fd == -1 && (error = packfile_open_locked(p)) < 0) {
+ git_mutex_unlock(&p->mwf.lock);
+ git_mutex_unlock(&p->lock);
+ return error;
+ }
+ git_mutex_unlock(&p->mwf.lock);
+ git_mutex_unlock(&p->lock);
+
+ error = git_packfile_unpack_header(&size, &type, p, &w_curs, &curpos);
if (error < 0)
return error;
@@ -489,8 +537,12 @@ int git_packfile_resolve_header(
size_t base_size;
git_packfile_stream stream;
- base_offset = get_delta_base(p, &w_curs, &curpos, type, offset);
+ error = get_delta_base(&base_offset, p, &w_curs, &curpos, type, offset);
git_mwindow_close(&w_curs);
+
+ if (error < 0)
+ return error;
+
if ((error = git_packfile_stream_open(&stream, p, curpos)) < 0)
return error;
error = git_delta_read_header_fromstream(&base_size, size_p, &stream);
@@ -504,13 +556,17 @@ int git_packfile_resolve_header(
while (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) {
curpos = base_offset;
- error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
+ error = git_packfile_unpack_header(&size, &type, p, &w_curs, &curpos);
if (error < 0)
return error;
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA)
break;
- base_offset = get_delta_base(p, &w_curs, &curpos, type, base_offset);
+
+ error = get_delta_base(&base_offset, p, &w_curs, &curpos, type, base_offset);
git_mwindow_close(&w_curs);
+
+ if (error < 0)
+ return error;
}
*type_p = type;
@@ -571,8 +627,7 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
elem->base_key = obj_offset;
- error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
-
+ error = git_packfile_unpack_header(&size, &type, p, &w_curs, &curpos);
if (error < 0)
goto on_error;
@@ -584,17 +639,11 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA)
break;
- base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
+ error = get_delta_base(&base_offset, p, &w_curs, &curpos, type, obj_offset);
git_mwindow_close(&w_curs);
- if (base_offset == 0) {
- error = packfile_error("delta offset is zero");
- goto on_error;
- }
- if (base_offset < 0) { /* must actually be an error code */
- error = (int)base_offset;
+ if (error < 0)
goto on_error;
- }
/* we need to pass the pos *after* the delta-base bit */
elem->offset = curpos;
@@ -629,6 +678,25 @@ int git_packfile_unpack(
size_t stack_size = 0, elem_pos, alloclen;
git_object_t base_type;
+ error = git_mutex_lock(&p->lock);
+ if (error < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile reader");
+ return error;
+ }
+ error = git_mutex_lock(&p->mwf.lock);
+ if (error < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile reader");
+ git_mutex_unlock(&p->lock);
+ return error;
+ }
+
+ if (p->mwf.fd == -1)
+ error = packfile_open_locked(p);
+ git_mutex_unlock(&p->mwf.lock);
+ git_mutex_unlock(&p->lock);
+ if (error < 0)
+ return error;
+
/*
* TODO: optionally check the CRC on the packfile
*/
@@ -691,7 +759,7 @@ int git_packfile_unpack(
GIT_ERROR_CHECK_ALLOC(obj->data);
memcpy(obj->data, data, obj->len + 1);
- git_atomic_dec(&cached->refcount);
+ git_atomic32_dec(&cached->refcount);
goto cleanup;
}
@@ -739,7 +807,7 @@ int git_packfile_unpack(
}
if (cached) {
- git_atomic_dec(&cached->refcount);
+ git_atomic32_dec(&cached->refcount);
cached = NULL;
}
@@ -753,7 +821,7 @@ cleanup:
if (error < 0) {
git__free(obj->data);
if (cached)
- git_atomic_dec(&cached->refcount);
+ git_atomic32_dec(&cached->refcount);
}
if (elem)
@@ -840,10 +908,13 @@ static int packfile_unpack_compressed(
do {
size_t bytes = buffer_len - total;
- unsigned int window_len;
+ unsigned int window_len, consumed;
unsigned char *in;
- in = pack_window_open(p, mwindow, *position, &window_len);
+ if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) {
+ error = -1;
+ goto out;
+ }
if ((error = git_zstream_set_input(&zstream, in, window_len)) < 0 ||
(error = git_zstream_get_output_chunk(data + total, &bytes, &zstream)) < 0) {
@@ -853,9 +924,17 @@ static int packfile_unpack_compressed(
git_mwindow_close(mwindow);
- *position += window_len - zstream.in_len;
+ consumed = window_len - (unsigned int)zstream.in_len;
+
+ if (!bytes && !consumed) {
+ git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream");
+ error = -1;
+ goto out;
+ }
+
+ *position += consumed;
total += bytes;
- } while (total < size);
+ } while (!git_zstream_eos(&zstream));
if (total != size || !git_zstream_eos(&zstream)) {
git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream");
@@ -879,18 +958,21 @@ out:
* curpos is where the data starts, delta_obj_offset is the where the
* header starts
*/
-off64_t get_delta_base(
- struct git_pack_file *p,
- git_mwindow **w_curs,
- off64_t *curpos,
- git_object_t type,
- off64_t delta_obj_offset)
+int get_delta_base(
+ off64_t *delta_base_out,
+ struct git_pack_file *p,
+ git_mwindow **w_curs,
+ off64_t *curpos,
+ git_object_t type,
+ off64_t delta_obj_offset)
{
unsigned int left = 0;
unsigned char *base_info;
off64_t base_offset;
git_oid unused;
+ GIT_ASSERT_ARG(delta_base_out);
+
base_info = pack_window_open(p, w_curs, *curpos, &left);
/* Assumption: the only reason this would fail is because the file is too small */
if (base_info == NULL)
@@ -910,12 +992,12 @@ off64_t get_delta_base(
return GIT_EBUFS;
unsigned_base_offset += 1;
if (!unsigned_base_offset || MSB(unsigned_base_offset, 7))
- return 0; /* overflow */
+ return packfile_error("overflow");
c = base_info[used++];
unsigned_base_offset = (unsigned_base_offset << 7) + (c & 127);
}
if (unsigned_base_offset == 0 || (size_t)delta_obj_offset <= unsigned_base_offset)
- return 0; /* out of bound */
+ return packfile_error("out of bounds");
base_offset = delta_obj_offset - unsigned_base_offset;
*curpos += used;
} else if (type == GIT_OBJECT_REF_DELTA) {
@@ -926,8 +1008,12 @@ off64_t get_delta_base(
git_oid_fromraw(&oid, base_info);
if ((entry = git_oidmap_get(p->idx_cache, &oid)) != NULL) {
+ if (entry->offset == 0)
+ return packfile_error("delta offset is zero");
+
*curpos += 20;
- return entry->offset;
+ *delta_base_out = entry->offset;
+ return 0;
} else {
/* If we're building an index, don't try to find the pack
* entry; we just haven't seen it yet. We'll make
@@ -942,9 +1028,13 @@ off64_t get_delta_base(
return packfile_error("base entry delta is not in the same pack");
*curpos += 20;
} else
- return 0;
+ return packfile_error("unknown object type");
+
+ if (base_offset == 0)
+ return packfile_error("delta offset is zero");
- return base_offset;
+ *delta_base_out = base_offset;
+ return 0;
}
/***********************************************************
@@ -953,63 +1043,63 @@ off64_t get_delta_base(
*
***********************************************************/
-void git_packfile_close(struct git_pack_file *p, bool unlink_packfile)
+void git_packfile_free(struct git_pack_file *p, bool unlink_packfile)
{
+ bool locked = true;
+
+ if (!p)
+ return;
+
+ cache_free(&p->bases);
+
+ if (git_mutex_lock(&p->lock) < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile");
+ locked = false;
+ }
if (p->mwf.fd >= 0) {
- git_mwindow_free_all_locked(&p->mwf);
+ git_mwindow_free_all(&p->mwf);
p_close(p->mwf.fd);
p->mwf.fd = -1;
}
+ if (locked)
+ git_mutex_unlock(&p->lock);
if (unlink_packfile)
p_unlink(p->pack_name);
-}
-
-void git_packfile_free(struct git_pack_file *p)
-{
- if (!p)
- return;
-
- cache_free(&p->bases);
-
- git_packfile_close(p, false);
pack_index_free(p);
git__free(p->bad_object_sha1);
- git_mutex_free(&p->lock);
git_mutex_free(&p->bases.lock);
+ git_mutex_free(&p->mwf.lock);
+ git_mutex_free(&p->lock);
git__free(p);
}
-static int packfile_open(struct git_pack_file *p)
+/* Run with the packfile and mwf locks held */
+static int packfile_open_locked(struct git_pack_file *p)
{
struct stat st;
struct git_pack_header hdr;
git_oid sha1;
unsigned char *idx_sha1;
- if (p->index_version == -1 && pack_index_open(p) < 0)
+ if (pack_index_open_locked(p) < 0)
return git_odb__error_notfound("failed to open packfile", NULL, 0);
- /* if mwf opened by another thread, return now */
- if (git_mutex_lock(&p->lock) < 0)
- return packfile_error("failed to get lock for open");
-
- if (p->mwf.fd >= 0) {
- git_mutex_unlock(&p->lock);
+ if (p->mwf.fd >= 0)
return 0;
- }
/* TODO: open with noatime */
p->mwf.fd = git_futils_open_ro(p->pack_name);
if (p->mwf.fd < 0)
goto cleanup;
- if (p_fstat(p->mwf.fd, &st) < 0 ||
- git_mwindow_file_register(&p->mwf) < 0)
+ if (p_fstat(p->mwf.fd, &st) < 0) {
+ git_error_set(GIT_ERROR_OS, "could not stat packfile");
goto cleanup;
+ }
/* If we created the struct before we had the pack we lack size. */
if (!p->mwf.size) {
@@ -1040,8 +1130,7 @@ static int packfile_open(struct git_pack_file *p)
/* Verify the pack matches its index. */
if (p->num_objects != ntohl(hdr.hdr_entries) ||
- p_lseek(p->mwf.fd, p->mwf.size - GIT_OID_RAWSZ, SEEK_SET) == -1 ||
- p_read(p->mwf.fd, sha1.id, GIT_OID_RAWSZ) < 0)
+ p_pread(p->mwf.fd, sha1.id, GIT_OID_RAWSZ, p->mwf.size - GIT_OID_RAWSZ) < 0)
goto cleanup;
idx_sha1 = ((unsigned char *)p->index_map.data) + p->index_map.len - 40;
@@ -1049,7 +1138,9 @@ static int packfile_open(struct git_pack_file *p)
if (git_oid__cmp(&sha1, (git_oid *)idx_sha1) != 0)
goto cleanup;
- git_mutex_unlock(&p->lock);
+ if (git_mwindow_file_register(&p->mwf) < 0)
+ goto cleanup;
+
return 0;
cleanup:
@@ -1059,8 +1150,6 @@ cleanup:
p_close(p->mwf.fd);
p->mwf.fd = -1;
- git_mutex_unlock(&p->lock);
-
return -1;
}
@@ -1130,13 +1219,22 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
p->mtime = (git_time_t)st.st_mtime;
p->index_version = -1;
- if (git_mutex_init(&p->lock)) {
+ if (git_mutex_init(&p->lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to initialize packfile mutex");
git__free(p);
return -1;
}
+ if (git_mutex_init(&p->mwf.lock) < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to initialize packfile window mutex");
+ git_mutex_free(&p->lock);
+ git__free(p);
+ return -1;
+ }
+
if (cache_init(&p->bases) < 0) {
+ git_mutex_free(&p->mwf.lock);
+ git_mutex_free(&p->lock);
git__free(p);
return -1;
}
@@ -1152,28 +1250,29 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
*
***********************************************************/
-static off64_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n)
+static off64_t nth_packed_object_offset_locked(struct git_pack_file *p, uint32_t n)
{
- const unsigned char *index = p->index_map.data;
- const unsigned char *end = index + p->index_map.len;
+ const unsigned char *index, *end;
+ uint32_t off32;
+
+ index = p->index_map.data;
+ end = index + p->index_map.len;
index += 4 * 256;
- if (p->index_version == 1) {
+ if (p->index_version == 1)
return ntohl(*((uint32_t *)(index + 24 * n)));
- } else {
- uint32_t off;
- index += 8 + p->num_objects * (20 + 4);
- off = ntohl(*((uint32_t *)(index + 4 * n)));
- if (!(off & 0x80000000))
- return off;
- index += p->num_objects * 4 + (off & 0x7fffffff) * 8;
-
- /* Make sure we're not being sent out of bounds */
- if (index >= end - 8)
- return -1;
- return (((uint64_t)ntohl(*((uint32_t *)(index + 0)))) << 32) |
- ntohl(*((uint32_t *)(index + 4)));
- }
+ index += 8 + p->num_objects * (20 + 4);
+ off32 = ntohl(*((uint32_t *)(index + 4 * n)));
+ if (!(off32 & 0x80000000))
+ return off32;
+ index += p->num_objects * 4 + (off32 & 0x7fffffff) * 8;
+
+ /* Make sure we're not being sent out of bounds */
+ if (index >= end - 8)
+ return -1;
+
+ return (((uint64_t)ntohl(*((uint32_t *)(index + 0)))) << 32) |
+ ntohl(*((uint32_t *)(index + 4)));
}
static int git__memcmp4(const void *a, const void *b) {
@@ -1185,33 +1284,40 @@ int git_pack_foreach_entry(
git_odb_foreach_cb cb,
void *data)
{
- const unsigned char *index = p->index_map.data, *current;
+ const unsigned char *index, *current;
uint32_t i;
int error = 0;
+ git_array_oid_t oids = GIT_ARRAY_INIT;
+ git_oid *oid;
- if (index == NULL) {
- if ((error = pack_index_open(p)) < 0)
- return error;
-
- assert(p->index_map.data);
+ if (git_mutex_lock(&p->lock) < 0)
+ return packfile_error("failed to get lock for git_pack_foreach_entry");
- index = p->index_map.data;
+ if ((error = pack_index_open_locked(p)) < 0) {
+ git_mutex_unlock(&p->lock);
+ return error;
}
- if (p->index_version > 1) {
+ GIT_ASSERT(p->index_map.data);
+ index = p->index_map.data;
+
+ if (p->index_version > 1)
index += 8;
- }
index += 4 * 256;
if (p->oids == NULL) {
git_vector offsets, oids;
- if ((error = git_vector_init(&oids, p->num_objects, NULL)))
+ if ((error = git_vector_init(&oids, p->num_objects, NULL))) {
+ git_mutex_unlock(&p->lock);
return error;
+ }
- if ((error = git_vector_init(&offsets, p->num_objects, git__memcmp4)))
+ if ((error = git_vector_init(&offsets, p->num_objects, git__memcmp4))) {
+ git_mutex_unlock(&p->lock);
return error;
+ }
if (p->index_version > 1) {
const unsigned char *off = index + 24 * p->num_objects;
@@ -1232,13 +1338,57 @@ int git_pack_foreach_entry(
p->oids = (git_oid **)git_vector_detach(NULL, NULL, &oids);
}
- for (i = 0; i < p->num_objects; i++)
- if ((error = cb(p->oids[i], data)) != 0)
- return git_error_set_after_callback(error);
+ /* We need to copy the OIDs to another array before we relinquish the lock to avoid races. */
+ git_array_init_to_size(oids, p->num_objects);
+ if (!oids.ptr) {
+ git_mutex_unlock(&p->lock);
+ git_array_clear(oids);
+ GIT_ERROR_CHECK_ARRAY(oids);
+ }
+ for (i = 0; i < p->num_objects; i++) {
+ oid = git_array_alloc(oids);
+ if (!oid) {
+ git_mutex_unlock(&p->lock);
+ git_array_clear(oids);
+ GIT_ERROR_CHECK_ALLOC(oid);
+ }
+ git_oid_cpy(oid, p->oids[i]);
+ }
+
+ git_mutex_unlock(&p->lock);
+
+ git_array_foreach(oids, i, oid) {
+ if ((error = cb(oid, data)) != 0) {
+ git_error_set_after_callback(error);
+ break;
+ }
+ }
+ git_array_clear(oids);
return error;
}
+int git_pack__lookup_sha1(const void *oid_lookup_table, size_t stride, unsigned lo,
+ unsigned hi, const unsigned char *oid_prefix)
+{
+ const unsigned char *base = oid_lookup_table;
+
+ while (lo < hi) {
+ unsigned mi = (lo + hi) / 2;
+ int cmp = git_oid__hashcmp(base + mi * stride, oid_prefix);
+
+ if (!cmp)
+ return mi;
+
+ if (cmp > 0)
+ hi = mi;
+ else
+ lo = mi+1;
+ }
+
+ return -((int)lo)-1;
+}
+
static int pack_entry_find_offset(
off64_t *offset_out,
git_oid *found_oid,
@@ -1252,17 +1402,17 @@ static int pack_entry_find_offset(
int pos, found = 0;
off64_t offset;
const unsigned char *current = 0;
+ int error = 0;
*offset_out = 0;
- if (p->index_version == -1) {
- int error;
+ if (git_mutex_lock(&p->lock) < 0)
+ return packfile_error("failed to get lock for pack_entry_find_offset");
- if ((error = pack_index_open(p)) < 0)
- return error;
- assert(p->index_map.data);
- }
+ if ((error = pack_index_open_locked(p)) < 0)
+ goto cleanup;
+ GIT_ASSERT(p->index_map.data);
index = p->index_map.data;
level1_ofs = p->index_map.data;
@@ -1287,7 +1437,7 @@ static int pack_entry_find_offset(
short_oid->id[0], short_oid->id[1], short_oid->id[2], lo, hi, p->num_objects);
#endif
- pos = sha1_position(index, stride, lo, hi, short_oid->id);
+ pos = git_pack__lookup_sha1(index, stride, lo, hi, short_oid->id);
if (pos >= 0) {
/* An object matching exactly the oid was found */
@@ -1314,14 +1464,19 @@ static int pack_entry_find_offset(
}
}
- if (!found)
- return git_odb__error_notfound("failed to find offset for pack entry", short_oid, len);
- if (found > 1)
- return git_odb__error_ambiguous("found multiple offsets for pack entry");
+ if (!found) {
+ error = git_odb__error_notfound("failed to find offset for pack entry", short_oid, len);
+ goto cleanup;
+ }
+ if (found > 1) {
+ error = git_odb__error_ambiguous("found multiple offsets for pack entry");
+ goto cleanup;
+ }
- if ((offset = nth_packed_object_offset(p, pos)) < 0) {
+ if ((offset = nth_packed_object_offset_locked(p, pos)) < 0) {
git_error_set(GIT_ERROR_ODB, "packfile index is corrupt");
- return -1;
+ error = -1;
+ goto cleanup;
}
*offset_out = offset;
@@ -1336,7 +1491,9 @@ static int pack_entry_find_offset(
}
#endif
- return 0;
+cleanup:
+ git_mutex_unlock(&p->lock);
+ return error;
}
int git_pack_entry_find(
@@ -1349,7 +1506,7 @@ int git_pack_entry_find(
git_oid found_oid;
int error;
- assert(p);
+ GIT_ASSERT_ARG(p);
if (len == GIT_OID_HEXSZ && p->num_bad_objects) {
unsigned i;
@@ -1362,10 +1519,26 @@ int git_pack_entry_find(
if (error < 0)
return error;
+ error = git_mutex_lock(&p->lock);
+ if (error < 0) {
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile reader");
+ return error;
+ }
+ error = git_mutex_lock(&p->mwf.lock);
+ if (error < 0) {
+ git_mutex_unlock(&p->lock);
+ git_error_set(GIT_ERROR_OS, "failed to lock packfile reader");
+ return error;
+ }
+
/* we found a unique entry in the index;
* make sure the packfile backing the index
* still exists on disk */
- if (p->mwf.fd == -1 && (error = packfile_open(p)) < 0)
+ if (p->mwf.fd == -1)
+ error = packfile_open_locked(p);
+ git_mutex_unlock(&p->mwf.lock);
+ git_mutex_unlock(&p->lock);
+ if (error < 0)
return error;
e->offset = offset;
diff --git a/src/pack.h b/src/pack.h
index a6a32ff..1d07724 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -58,7 +58,7 @@ struct git_pack_idx_header {
typedef struct git_pack_cache_entry {
size_t last_usage; /* enough? */
- git_atomic refcount;
+ git_atomic32 refcount;
git_rawobj raw;
} git_pack_cache_entry;
@@ -85,8 +85,8 @@ typedef struct {
struct git_pack_file {
git_mwindow_file mwf;
git_map index_map;
- git_mutex lock; /* protect updates to mwf and index_map */
- git_atomic refcount;
+ git_mutex lock; /* protect updates to index_map */
+ git_atomic32 refcount;
uint32_t num_objects;
uint32_t num_bad_objects;
@@ -106,6 +106,19 @@ struct git_pack_file {
char pack_name[GIT_FLEX_ARRAY]; /* more */
};
+/**
+ * Return the position where an OID (or a prefix) would be inserted within the
+ * OID Lookup Table of an .idx file. This performs binary search between the lo
+ * and hi indices.
+ *
+ * The stride parameter is provided because .idx files version 1 store the OIDs
+ * interleaved with the 4-byte file offsets of the objects within the .pack
+ * file (stride = 24), whereas files with version 2 store them in a contiguous
+ * flat array (stride = 20).
+ */
+int git_pack__lookup_sha1(const void *oid_lookup_table, size_t stride, unsigned lo,
+ unsigned hi, const unsigned char *oid_prefix);
+
struct git_pack_entry {
off64_t offset;
git_oid sha1;
@@ -120,14 +133,14 @@ typedef struct git_packfile_stream {
git_mwindow *mw;
} git_packfile_stream;
-size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_object_t type);
+int git_packfile__object_header(size_t *out, unsigned char *hdr, size_t size, git_object_t type);
int git_packfile__name(char **out, const char *path);
int git_packfile_unpack_header(
size_t *size_p,
git_object_t *type_p,
- git_mwindow_file *mwf,
+ struct git_pack_file *p,
git_mwindow **w_curs,
off64_t *curpos);
@@ -143,12 +156,15 @@ int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p,
ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len);
void git_packfile_stream_dispose(git_packfile_stream *obj);
-off64_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
- off64_t *curpos, git_object_t type,
+int get_delta_base(
+ off64_t *delta_base_out,
+ struct git_pack_file *p,
+ git_mwindow **w_curs,
+ off64_t *curpos,
+ git_object_t type,
off64_t delta_obj_offset);
-void git_packfile_close(struct git_pack_file *p, bool unlink_packfile);
-void git_packfile_free(struct git_pack_file *p);
+void git_packfile_free(struct git_pack_file *p, bool unlink_packfile);
int git_packfile_alloc(struct git_pack_file **pack_out, const char *path);
int git_pack_entry_find(
diff --git a/src/patch.c b/src/patch.c
index 82181bb..f02c928 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -65,7 +65,7 @@ size_t git_patch_size(
{
size_t out;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
out = patch->content_size;
@@ -129,13 +129,13 @@ int git_patch_line_stats(
const git_diff_delta *git_patch_get_delta(const git_patch *patch)
{
- assert(patch);
+ GIT_ASSERT_ARG_WITH_RETVAL(patch, NULL);
return patch->delta;
}
size_t git_patch_num_hunks(const git_patch *patch)
{
- assert(patch);
+ GIT_ASSERT_ARG(patch);
return git_array_size(patch->hunks);
}
@@ -152,7 +152,7 @@ int git_patch_get_hunk(
size_t hunk_idx)
{
git_patch_hunk *hunk;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
hunk = git_array_get(patch->hunks, hunk_idx);
@@ -170,7 +170,7 @@ int git_patch_get_hunk(
int git_patch_num_lines_in_hunk(const git_patch *patch, size_t hunk_idx)
{
git_patch_hunk *hunk;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
if (!(hunk = git_array_get(patch->hunks, hunk_idx)))
return patch_error_outofrange("hunk");
@@ -186,7 +186,7 @@ int git_patch_get_line_in_hunk(
git_patch_hunk *hunk;
git_diff_line *line;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
if (!(hunk = git_array_get(patch->hunks, hunk_idx))) {
if (out) *out = NULL;
@@ -204,9 +204,16 @@ int git_patch_get_line_in_hunk(
return 0;
}
+git_repository *git_patch_owner(const git_patch *patch)
+{
+ return patch->repo;
+}
+
int git_patch_from_diff(git_patch **out, git_diff *diff, size_t idx)
{
- assert(out && diff && diff->patch_fn);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diff);
+ GIT_ASSERT_ARG(diff->patch_fn);
return diff->patch_fn(out, diff, idx);
}
diff --git a/src/patch_generate.c b/src/patch_generate.c
index 18256d0..38cd714 100644
--- a/src/patch_generate.c
+++ b/src/patch_generate.c
@@ -209,9 +209,7 @@ static int patch_generated_load(git_patch_generated *patch, git_patch_generated_
if ((error = git_diff_file_content__load(
&patch->ofile, &patch->base.diff_opts)) < 0 ||
- should_skip_binary(patch, patch->ofile.file))
- goto cleanup;
- if ((error = git_diff_file_content__load(
+ (error = git_diff_file_content__load(
&patch->nfile, &patch->base.diff_opts)) < 0 ||
should_skip_binary(patch, patch->nfile.file))
goto cleanup;
@@ -563,7 +561,7 @@ static int patch_from_sources(
patch_generated_with_delta *pd;
git_xdiff_output xo;
- assert(out);
+ GIT_ASSERT_ARG(out);
*out = NULL;
if ((error = patch_generated_with_delta_alloc(
@@ -842,7 +840,7 @@ static int patch_generated_line_cb(
GIT_UNUSED(hunk_);
hunk = git_array_last(patch->base.hunks);
- assert(hunk); /* programmer error if no hunk is available */
+ GIT_ASSERT(hunk); /* programmer error if no hunk is available */
line = git_array_alloc(patch->base.lines);
GIT_ERROR_CHECK_ALLOC(line);
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 9d089ad..2cc5c59 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -198,7 +198,7 @@ static int parse_header_git_index(
return -1;
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ' ') {
- uint16_t mode;
+ uint16_t mode = 0;
git_parse_advance_chars(&ctx->parse_ctx, 1);
@@ -407,10 +407,12 @@ static const parse_header_transition transitions[] = {
{ "--- " , STATE_DIFF, STATE_PATH, parse_header_git_oldpath },
{ "--- " , STATE_INDEX, STATE_PATH, parse_header_git_oldpath },
+ { "--- " , STATE_FILEMODE, STATE_PATH, parse_header_git_oldpath },
{ "+++ " , STATE_PATH, STATE_END, parse_header_git_newpath },
{ "GIT binary patch" , STATE_INDEX, STATE_END, NULL },
{ "Binary files " , STATE_INDEX, STATE_END, NULL },
+ { "similarity index " , STATE_END, STATE_SIMILARITY, parse_header_similarity },
{ "similarity index " , STATE_DIFF, STATE_SIMILARITY, parse_header_similarity },
{ "dissimilarity index ", STATE_DIFF, STATE_SIMILARITY, parse_header_dissimilarity },
{ "rename from " , STATE_SIMILARITY, STATE_RENAME, parse_header_renamefrom },
@@ -940,7 +942,7 @@ static int parse_patch_body(
return parse_patch_hunks(patch, ctx);
}
-int check_header_names(
+static int check_header_names(
const char *one,
const char *two,
const char *old_or_new,
@@ -1166,7 +1168,8 @@ int git_patch_parse(
size_t start, used;
int error = 0;
- assert(out && ctx);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ctx);
*out = NULL;
diff --git a/src/path.c b/src/path.c
index 625b95c..ec57322 100644
--- a/src/path.c
+++ b/src/path.c
@@ -274,24 +274,6 @@ size_t git_path_basename_offset(git_buf *buffer)
return 0;
}
-const char *git_path_topdir(const char *path)
-{
- size_t len;
- ssize_t i;
-
- assert(path);
- len = strlen(path);
-
- if (!len || path[len - 1] != '/')
- return NULL;
-
- for (i = (ssize_t)len - 2; i >= 0; --i)
- if (path[i] == '/')
- break;
-
- return &path[i + 1];
-}
-
int git_path_root(const char *path)
{
int offset = 0, prefix_len;
@@ -322,10 +304,12 @@ int git_path_root(const char *path)
return -1; /* Not a real error - signals that path is not rooted */
}
-void git_path_trim_slashes(git_buf *path)
+static void path_trim_slashes(git_buf *path)
{
int ceiling = git_path_root(path->ptr) + 1;
- assert(ceiling >= 0);
+
+ if (ceiling < 0)
+ return;
while (path->size > (size_t)ceiling) {
if (path->ptr[path->size-1] != '/')
@@ -341,7 +325,8 @@ int git_path_join_unrooted(
{
ssize_t root;
- assert(path && path_out);
+ GIT_ASSERT_ARG(path_out);
+ GIT_ASSERT_ARG(path);
root = (ssize_t)git_path_root(path);
@@ -389,7 +374,8 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
{
char buf[GIT_PATH_MAX];
- assert(path && path_out);
+ GIT_ASSERT_ARG(path_out);
+ GIT_ASSERT_ARG(path);
/* construct path if needed */
if (base != NULL && git_path_root(path) < 0) {
@@ -440,7 +426,9 @@ void git_path_string_to_dir(char* path, size_t size)
int git__percent_decode(git_buf *decoded_out, const char *input)
{
int len, hi, lo, i;
- assert(decoded_out && input);
+
+ GIT_ASSERT_ARG(decoded_out);
+ GIT_ASSERT_ARG(input);
len = (int)strlen(input);
git_buf_clear(decoded_out);
@@ -501,7 +489,8 @@ int git_path_fromurl(git_buf *local_path_out, const char *file_url)
{
int offset;
- assert(local_path_out && file_url);
+ GIT_ASSERT_ARG(local_path_out);
+ GIT_ASSERT_ARG(file_url);
if ((offset = local_file_url_prefixlen(file_url)) < 0 ||
file_url[offset] == '\0' || file_url[offset] == '/')
@@ -526,7 +515,8 @@ int git_path_walk_up(
ssize_t stop = 0, scan;
char oldc = '\0';
- assert(path && cb);
+ GIT_ASSERT_ARG(path);
+ GIT_ASSERT_ARG(cb);
if (ceiling != NULL) {
if (git__prefixcmp(path->ptr, ceiling) == 0)
@@ -581,7 +571,7 @@ int git_path_walk_up(
bool git_path_exists(const char *path)
{
- assert(path);
+ GIT_ASSERT_ARG_WITH_RETVAL(path, false);
return p_access(path, F_OK) == 0;
}
@@ -598,7 +588,7 @@ bool git_path_isfile(const char *path)
{
struct stat st;
- assert(path);
+ GIT_ASSERT_ARG_WITH_RETVAL(path, false);
if (p_stat(path, &st) < 0)
return false;
@@ -609,7 +599,7 @@ bool git_path_islink(const char *path)
{
struct stat st;
- assert(path);
+ GIT_ASSERT_ARG_WITH_RETVAL(path, false);
if (p_lstat(path, &st) < 0)
return false;
@@ -764,15 +754,13 @@ bool git_path_contains_file(git_buf *base, const char *file)
return _check_dir_contents(base, file, &git_path_isfile);
}
-int git_path_find_dir(git_buf *dir, const char *path, const char *base)
+int git_path_find_dir(git_buf *dir)
{
- int error = git_path_join_unrooted(dir, path, base, NULL);
+ int error = 0;
+ char buf[GIT_PATH_MAX];
- if (!error) {
- char buf[GIT_PATH_MAX];
- if (p_realpath(dir->ptr, buf) != NULL)
- error = git_buf_sets(dir, buf);
- }
+ if (p_realpath(dir->ptr, buf) != NULL)
+ error = git_buf_sets(dir, buf);
/* call dirname if this is not a directory */
if (!error) /* && git_path_isdir(dir->ptr) == false) */
@@ -1211,7 +1199,8 @@ int git_path_diriter_init(
if (is_win7_or_later < 0)
is_win7_or_later = git_has_win32_version(6, 1, 0);
- assert(diriter && path);
+ GIT_ASSERT_ARG(diriter);
+ GIT_ASSERT_ARG(path);
memset(diriter, 0, sizeof(git_path_diriter));
diriter->handle = INVALID_HANDLE_VALUE;
@@ -1219,7 +1208,7 @@ int git_path_diriter_init(
if (git_buf_puts(&diriter->path_utf8, path) < 0)
return -1;
- git_path_trim_slashes(&diriter->path_utf8);
+ path_trim_slashes(&diriter->path_utf8);
if (diriter->path_utf8.size == 0) {
git_error_set(GIT_ERROR_FILESYSTEM, "could not open directory '%s'", path);
@@ -1311,9 +1300,10 @@ int git_path_diriter_filename(
size_t *out_len,
git_path_diriter *diriter)
{
- assert(out && out_len && diriter);
-
- assert(diriter->path_utf8.size > diriter->parent_utf8_len);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(out_len);
+ GIT_ASSERT_ARG(diriter);
+ GIT_ASSERT(diriter->path_utf8.size > diriter->parent_utf8_len);
*out = &diriter->path_utf8.ptr[diriter->parent_utf8_len+1];
*out_len = diriter->path_utf8.size - diriter->parent_utf8_len - 1;
@@ -1325,7 +1315,9 @@ int git_path_diriter_fullpath(
size_t *out_len,
git_path_diriter *diriter)
{
- assert(out && out_len && diriter);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(out_len);
+ GIT_ASSERT_ARG(diriter);
*out = diriter->path_utf8.ptr;
*out_len = diriter->path_utf8.size;
@@ -1334,7 +1326,8 @@ int git_path_diriter_fullpath(
int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter)
{
- assert(out && diriter);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diriter);
return git_win32__file_attribute_to_stat(out,
(WIN32_FILE_ATTRIBUTE_DATA *)&diriter->current,
@@ -1361,14 +1354,15 @@ int git_path_diriter_init(
const char *path,
unsigned int flags)
{
- assert(diriter && path);
+ GIT_ASSERT_ARG(diriter);
+ GIT_ASSERT_ARG(path);
memset(diriter, 0, sizeof(git_path_diriter));
if (git_buf_puts(&diriter->path, path) < 0)
return -1;
- git_path_trim_slashes(&diriter->path);
+ path_trim_slashes(&diriter->path);
if (diriter->path.size == 0) {
git_error_set(GIT_ERROR_FILESYSTEM, "could not open directory '%s'", path);
@@ -1401,7 +1395,7 @@ int git_path_diriter_next(git_path_diriter *diriter)
bool skip_dot = !(diriter->flags & GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
int error = 0;
- assert(diriter);
+ GIT_ASSERT_ARG(diriter);
errno = 0;
@@ -1444,9 +1438,10 @@ int git_path_diriter_filename(
size_t *out_len,
git_path_diriter *diriter)
{
- assert(out && out_len && diriter);
-
- assert(diriter->path.size > diriter->parent_len);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(out_len);
+ GIT_ASSERT_ARG(diriter);
+ GIT_ASSERT(diriter->path.size > diriter->parent_len);
*out = &diriter->path.ptr[diriter->parent_len+1];
*out_len = diriter->path.size - diriter->parent_len - 1;
@@ -1458,7 +1453,9 @@ int git_path_diriter_fullpath(
size_t *out_len,
git_path_diriter *diriter)
{
- assert(out && out_len && diriter);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(out_len);
+ GIT_ASSERT_ARG(diriter);
*out = diriter->path.ptr;
*out_len = diriter->path.size;
@@ -1467,7 +1464,8 @@ int git_path_diriter_fullpath(
int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter)
{
- assert(out && diriter);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diriter);
return git_path_lstat(diriter->path.ptr, out);
}
@@ -1503,7 +1501,8 @@ int git_path_dirload(
char *dup;
int error;
- assert(contents && path);
+ GIT_ASSERT_ARG(contents);
+ GIT_ASSERT_ARG(path);
if ((error = git_path_diriter_init(&iter, path, flags)) < 0)
return error;
@@ -1512,7 +1511,7 @@ int git_path_dirload(
if ((error = git_path_diriter_fullpath(&name, &name_len, &iter)) < 0)
break;
- assert(name_len > prefix_len);
+ GIT_ASSERT(name_len > prefix_len);
dup = git__strndup(name + prefix_len, name_len - prefix_len);
GIT_ERROR_CHECK_ALLOC(dup);
@@ -1561,8 +1560,8 @@ GIT_INLINE(bool) verify_dospath(
static int32_t next_hfs_char(const char **in, size_t *len)
{
while (*len) {
- int32_t codepoint;
- int cp_len = git__utf8_iterate((const uint8_t *)(*in), (int)(*len), &codepoint);
+ uint32_t codepoint;
+ int cp_len = git_utf8_iterate(&codepoint, *in, *len);
if (cp_len < 0)
return -1;
@@ -1594,7 +1593,7 @@ static int32_t next_hfs_char(const char **in, size_t *len)
* the ASCII range, which is perfectly fine, because the
* git folder name can only be composed of ascii characters
*/
- return git__tolower(codepoint);
+ return git__tolower((int)codepoint);
}
return 0; /* NULL byte -- end of string */
}
@@ -1876,7 +1875,7 @@ GIT_INLINE(unsigned int) dotgit_flags(
return flags;
}
-bool git_path_isvalid(
+bool git_path_validate(
git_repository *repo,
const char *path,
uint16_t mode,
@@ -1903,6 +1902,52 @@ bool git_path_isvalid(
return verify_component(repo, start, (c - start), mode, flags);
}
+#ifdef GIT_WIN32
+GIT_INLINE(bool) should_validate_longpaths(git_repository *repo)
+{
+ int longpaths = 0;
+
+ if (repo &&
+ git_repository__configmap_lookup(&longpaths, repo, GIT_CONFIGMAP_LONGPATHS) < 0)
+ longpaths = 0;
+
+ return (longpaths == 0);
+}
+
+#else
+
+GIT_INLINE(bool) should_validate_longpaths(git_repository *repo)
+{
+ GIT_UNUSED(repo);
+
+ return false;
+}
+#endif
+
+int git_path_validate_workdir(git_repository *repo, const char *path)
+{
+ if (should_validate_longpaths(repo))
+ return git_path_validate_filesystem(path, strlen(path));
+
+ return 0;
+}
+
+int git_path_validate_workdir_with_len(
+ git_repository *repo,
+ const char *path,
+ size_t path_len)
+{
+ if (should_validate_longpaths(repo))
+ return git_path_validate_filesystem(path, path_len);
+
+ return 0;
+}
+
+int git_path_validate_workdir_buf(git_repository *repo, git_buf *path)
+{
+ return git_path_validate_workdir_with_len(repo, path->ptr, path->size);
+}
+
int git_path_normalize_slashes(git_buf *out, const char *path)
{
int error;
@@ -2045,7 +2090,7 @@ int git_path_validate_system_file_ownership(const char *path)
git_error_set(GIT_ERROR_INVALID, "programdata configuration file owner is not valid");
ret = GIT_ERROR;
}
- free(info);
+ git__free(info);
cleanup:
if (descriptor)
diff --git a/src/path.h b/src/path.h
index ed6b935..dcf5652 100644
--- a/src/path.h
+++ b/src/path.h
@@ -67,8 +67,6 @@ extern int git_path_basename_r(git_buf *buffer, const char *path);
*/
extern size_t git_path_basename_offset(git_buf *buffer);
-extern const char *git_path_topdir(const char *path);
-
/**
* Find offset to root of path if path has one.
*
@@ -285,7 +283,7 @@ extern int git_path_prettify_dir(git_buf *path_out, const char *path, const char
* appends the trailing '/'. If the path does not exist, it is
* treated like a regular filename.
*/
-extern int git_path_find_dir(git_buf *dir, const char *path, const char *base);
+extern int git_path_find_dir(git_buf *dir);
/**
* Resolve relative references within a path.
@@ -628,21 +626,96 @@ extern int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or
#define GIT_PATH_REJECT_INDEX_DEFAULTS \
GIT_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT
-/*
- * Determine whether a path is a valid git path or not - this must not contain
+/**
+ * Validate a "bare" git path. This ensures that the given path is legal
+ * to place in the index or a tree. This should be checked by mechanisms
+ * like `git_index_add` and `git_treebuilder_insert` when taking user
+ * data, and by `git_checkout` before constructing on-disk paths.
+ *
+ * This will ensure that a git path does not contain any "unsafe" components,
* a '.' or '..' component, or a component that is ".git" (in any case).
*
+ * (Note: if you take or construct an on-disk path -- a workdir path,
+ * a path to a git repository or a reference name that could be a loose
+ * ref -- you should _also_ validate that with `git_path_validate_workdir`.)
+ *
* `repo` is optional. If specified, it will be used to determine the short
* path name to reject (if `GIT_PATH_REJECT_DOS_SHORTNAME` is specified),
* in addition to the default of "git~1".
*/
-extern bool git_path_isvalid(
+extern bool git_path_validate(
git_repository *repo,
const char *path,
uint16_t mode,
unsigned int flags);
/**
+ * Validate an on-disk path, taking into account that it will have a
+ * suffix appended (eg, `.lock`).
+ */
+GIT_INLINE(int) git_path_validate_filesystem_with_suffix(
+ const char *path,
+ size_t path_len,
+ size_t suffix_len)
+{
+#ifdef GIT_WIN32
+ size_t path_chars, total_chars;
+
+ path_chars = git_utf8_char_length(path, path_len);
+
+ if (GIT_ADD_SIZET_OVERFLOW(&total_chars, path_chars, suffix_len) ||
+ total_chars > MAX_PATH) {
+ git_error_set(GIT_ERROR_FILESYSTEM, "path too long: '%s'", path);
+ return -1;
+ }
+ return 0;
+#else
+ GIT_UNUSED(path);
+ GIT_UNUSED(path_len);
+ GIT_UNUSED(suffix_len);
+ return 0;
+#endif
+}
+
+/**
+ * Validate an path on the filesystem. This ensures that the given
+ * path is valid for the operating system/platform; for example, this
+ * will ensure that the given absolute path is smaller than MAX_PATH on
+ * Windows.
+ *
+ * For paths within the working directory, you should use ensure that
+ * `core.longpaths` is obeyed. Use `git_path_validate_workdir`.
+ */
+GIT_INLINE(int) git_path_validate_filesystem(
+ const char *path,
+ size_t path_len)
+{
+ return git_path_validate_filesystem_with_suffix(path, path_len, 0);
+}
+
+/**
+ * Validate a path relative to the repo's worktree. This ensures that
+ * the given working tree path is valid for the operating system/platform.
+ * This will ensure that an absolute path is smaller than MAX_PATH on
+ * Windows, while keeping `core.longpaths` configuration settings in mind.
+ *
+ * This should be checked by mechamisms like `git_checkout` after
+ * contructing on-disk paths and before trying to write them.
+ *
+ * If the repository is null, no repository configuration is applied.
+ */
+extern int git_path_validate_workdir(
+ git_repository *repo,
+ const char *path);
+extern int git_path_validate_workdir_with_len(
+ git_repository *repo,
+ const char *path,
+ size_t path_len);
+extern int git_path_validate_workdir_buf(
+ git_repository *repo,
+ git_buf *buf);
+
+/**
* Convert any backslashes into slashes
*/
int git_path_normalize_slashes(git_buf *out, const char *path);
diff --git a/src/pathspec.c b/src/pathspec.c
index 19ea9eb..8f1bdf0 100644
--- a/src/pathspec.c
+++ b/src/pathspec.c
@@ -9,7 +9,6 @@
#include "git2/pathspec.h"
#include "git2/diff.h"
-#include "buf_text.h"
#include "attr_file.h"
#include "iterator.h"
#include "repository.h"
@@ -25,7 +24,7 @@ char *git_pathspec_prefix(const git_strarray *pathspec)
const char *scan;
if (!pathspec || !pathspec->count ||
- git_buf_text_common_prefix(&prefix, pathspec) < 0)
+ git_buf_common_prefix(&prefix, pathspec) < 0)
return NULL;
/* diff prefix will only be leading non-wildcards */
@@ -41,7 +40,7 @@ char *git_pathspec_prefix(const git_strarray *pathspec)
return NULL;
}
- git_buf_text_unescape(&prefix);
+ git_buf_unescape(&prefix);
return git_buf_detach(&prefix);
}
@@ -238,9 +237,9 @@ int git_pathspec__init(git_pathspec *ps, const git_strarray *paths)
memset(ps, 0, sizeof(*ps));
ps->prefix = git_pathspec_prefix(paths);
- git_pool_init(&ps->pool, 1);
- if ((error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 0)
+ if ((error = git_pool_init(&ps->pool, 1)) < 0 ||
+ (error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 0)
git_pathspec__clear(ps);
return error;
@@ -289,7 +288,8 @@ int git_pathspec_matches_path(
bool no_fnmatch = (flags & GIT_PATHSPEC_NO_GLOB) != 0;
bool casefold = (flags & GIT_PATHSPEC_IGNORE_CASE) != 0;
- assert(ps && path);
+ GIT_ASSERT_ARG(ps);
+ GIT_ASSERT_ARG(path);
return (0 != git_pathspec__match(
&ps->pathspec, path, no_fnmatch, casefold, NULL, NULL));
@@ -316,7 +316,8 @@ static git_pathspec_match_list *pathspec_match_alloc(
if (!m)
return NULL;
- git_pool_init(&m->pool, 1);
+ if (git_pool_init(&m->pool, 1) < 0)
+ return NULL;
/* need to keep reference to pathspec and increment refcount because
* failures array stores pointers to the pattern strings of the
@@ -525,7 +526,7 @@ int git_pathspec_match_workdir(
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
int error = 0;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
iter_opts.flags = pathspec_match_iter_flags(flags);
@@ -547,7 +548,7 @@ int git_pathspec_match_index(
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
int error = 0;
- assert(index);
+ GIT_ASSERT_ARG(index);
iter_opts.flags = pathspec_match_iter_flags(flags);
@@ -569,7 +570,7 @@ int git_pathspec_match_tree(
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
int error = 0;
- assert(tree);
+ GIT_ASSERT_ARG(tree);
iter_opts.flags = pathspec_match_iter_flags(flags);
@@ -597,7 +598,7 @@ int git_pathspec_match_diff(
const git_diff_delta *delta, **match;
git_bitvec used_patterns;
- assert(diff);
+ GIT_ASSERT_ARG(diff);
if (git_bitvec_init(&used_patterns, patterns->length) < 0)
return -1;
diff --git a/src/pool.c b/src/pool.c
index b3bc8d4..16ffa39 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -21,30 +21,29 @@ struct git_pool_page {
static void *pool_alloc_page(git_pool *pool, size_t size);
-size_t git_pool__system_page_size(void)
-{
- static size_t size = 0;
+#ifndef GIT_DEBUG_POOL
- if (!size) {
- size_t page_size;
- if (git__page_size(&page_size) < 0)
- page_size = 4096;
- /* allow space for malloc overhead */
- size = (page_size - (2 * sizeof(void *)) - sizeof(git_pool_page));
- }
+static size_t system_page_size = 0;
- return size;
+int git_pool_global_init(void)
+{
+ if (git__page_size(&system_page_size) < 0)
+ system_page_size = 4096;
+ /* allow space for malloc overhead */
+ system_page_size -= (2 * sizeof(void *)) + sizeof(git_pool_page);
+ return 0;
}
-#ifndef GIT_DEBUG_POOL
-void git_pool_init(git_pool *pool, size_t item_size)
+int git_pool_init(git_pool *pool, size_t item_size)
{
- assert(pool);
- assert(item_size >= 1);
+ GIT_ASSERT_ARG(pool);
+ GIT_ASSERT_ARG(item_size >= 1);
memset(pool, 0, sizeof(git_pool));
pool->item_size = item_size;
- pool->page_size = git_pool__system_page_size();
+ pool->page_size = system_page_size;
+
+ return 0;
}
void git_pool_clear(git_pool *pool)
@@ -112,6 +111,11 @@ bool git_pool__ptr_in_pool(git_pool *pool, void *ptr)
#else
+int git_pool_global_init(void)
+{
+ return 0;
+}
+
static int git_pool__ptr_cmp(const void * a, const void * b)
{
if(a > b) {
@@ -125,15 +129,17 @@ static int git_pool__ptr_cmp(const void * a, const void * b)
}
}
-void git_pool_init(git_pool *pool, size_t item_size)
+int git_pool_init(git_pool *pool, size_t item_size)
{
- assert(pool);
- assert(item_size >= 1);
+ GIT_ASSERT_ARG(pool);
+ GIT_ASSERT_ARG(item_size >= 1);
memset(pool, 0, sizeof(git_pool));
pool->item_size = item_size;
pool->page_size = git_pool__system_page_size();
git_vector_init(&pool->allocations, 100, git_pool__ptr_cmp);
+
+ return 0;
}
void git_pool_clear(git_pool *pool)
@@ -199,7 +205,9 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
{
char *ptr = NULL;
- assert(pool && str && pool->item_size == sizeof(char));
+ GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(str, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
if (n == SIZE_MAX)
return NULL;
@@ -214,7 +222,10 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
char *git_pool_strdup(git_pool *pool, const char *str)
{
- assert(pool && str && pool->item_size == sizeof(char));
+ GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(str, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
+
return git_pool_strndup(pool, str, strlen(str));
}
@@ -228,7 +239,8 @@ char *git_pool_strcat(git_pool *pool, const char *a, const char *b)
void *ptr;
size_t len_a, len_b, total;
- assert(pool && pool->item_size == sizeof(char));
+ GIT_ASSERT_ARG_WITH_RETVAL(pool, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(pool->item_size == sizeof(char), NULL);
len_a = a ? strlen(a) : 0;
len_b = b ? strlen(b) : 0;
diff --git a/src/pool.h b/src/pool.h
index 23f6899..cecb846 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -81,7 +81,7 @@ typedef struct {
* Of course, you can use this in other ways, but those are the
* two most common patterns.
*/
-extern void git_pool_init(git_pool *pool, size_t item_size);
+extern int git_pool_init(git_pool *pool, size_t item_size);
/**
* Free all items in pool
@@ -135,4 +135,12 @@ extern uint32_t git_pool__open_pages(git_pool *pool);
#endif
extern bool git_pool__ptr_in_pool(git_pool *pool, void *ptr);
+/**
+ * This function is being called by our global setup routines to
+ * initialize the system pool size.
+ *
+ * @return 0 on success, <0 on failure
+ */
+extern int git_pool_global_init(void);
+
#endif
diff --git a/src/posix.c b/src/posix.c
index fbaa7c3..c401348 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -109,6 +109,13 @@ int p_open(const char *path, volatile int flags, ...)
{
mode_t mode = 0;
+ #ifdef GIT_DEBUG_STRICT_OPEN
+ if (strstr(path, "//") != NULL) {
+ errno = EACCES;
+ return -1;
+ }
+ #endif
+
if (flags & O_CREAT) {
va_list arg_list;
@@ -129,7 +136,8 @@ int p_getcwd(char *buffer_out, size_t size)
{
char *cwd_buffer;
- assert(buffer_out && size > 0);
+ GIT_ASSERT_ARG(buffer_out);
+ GIT_ASSERT_ARG(size > 0);
cwd_buffer = getcwd(buffer_out, size);
@@ -196,7 +204,7 @@ int p_write(git_file fd, const void *buf, size_t cnt)
while (cnt) {
ssize_t r;
#ifdef GIT_WIN32
- assert((size_t)((unsigned int)cnt) == cnt);
+ GIT_ASSERT((size_t)((unsigned int)cnt) == cnt);
r = write(fd, b, (unsigned int)cnt);
#else
r = write(fd, b, cnt);
@@ -237,24 +245,43 @@ int git__mmap_alignment(size_t *alignment)
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset)
{
+ const char *ptr;
+ size_t remaining_len;
+
GIT_MMAP_VALIDATE(out, len, prot, flags);
- out->data = NULL;
- out->len = 0;
+ /* writes cannot be emulated without handling pagefaults since write happens by
+ * writing to mapped memory */
+ if (prot & GIT_PROT_WRITE) {
+ git_error_set(GIT_ERROR_OS, "trying to map %s-writeable",
+ ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED) ? "shared": "private");
+ return -1;
+ }
- if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
- git_error_set(GIT_ERROR_OS, "trying to map shared-writeable");
+ if (!git__is_ssizet(len)) {
+ errno = EINVAL;
return -1;
}
+ out->len = 0;
out->data = git__malloc(len);
GIT_ERROR_CHECK_ALLOC(out->data);
- if (!git__is_ssizet(len) ||
- (p_lseek(fd, offset, SEEK_SET) < 0) ||
- (p_read(fd, out->data, len) != (ssize_t)len)) {
- git_error_set(GIT_ERROR_OS, "mmap emulation failed");
- return -1;
+ remaining_len = len;
+ ptr = (const char *)out->data;
+ while (remaining_len > 0) {
+ ssize_t nb;
+ HANDLE_EINTR(nb, p_pread(fd, (void *)ptr, remaining_len, offset));
+ if (nb <= 0) {
+ git_error_set(GIT_ERROR_OS, "mmap emulation failed");
+ git__free(out->data);
+ out->data = NULL;
+ return -1;
+ }
+
+ ptr += nb;
+ offset += nb;
+ remaining_len -= nb;
}
out->len = len;
@@ -263,9 +290,13 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset
int p_munmap(git_map *map)
{
- assert(map != NULL);
+ GIT_ASSERT_ARG(map);
git__free(map->data);
+ /* Initializing will help debug use-after-free */
+ map->len = 0;
+ map->data = NULL;
+
return 0;
}
diff --git a/src/posix.h b/src/posix.h
index eef6677..d98bc82 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -89,6 +89,12 @@
#define EAFNOSUPPORT (INT_MAX-1)
#endif
+/* Compiler independent macro to handle signal interrpted system calls */
+#define HANDLE_EINTR(result, x) do { \
+ result = (x); \
+ } while (result == -1 && errno == EINTR);
+
+
/* Provide a 64-bit size for offsets. */
#if defined(_MSC_VER)
@@ -119,6 +125,9 @@ typedef int git_file;
extern ssize_t p_read(git_file fd, void *buf, size_t cnt);
extern int p_write(git_file fd, const void *buf, size_t cnt);
+extern ssize_t p_pread(int fd, void *data, size_t size, off64_t offset);
+extern ssize_t p_pwrite(int fd, const void *data, size_t size, off64_t offset);
+
#define p_close(fd) close(fd)
#define p_umask(m) umask(m)
diff --git a/src/proxy.c b/src/proxy.c
index 367c4b1..78a4c55 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -16,10 +16,12 @@ int git_proxy_options_init(git_proxy_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
{
return git_proxy_options_init(opts, version);
}
+#endif
int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
{
diff --git a/src/push.c b/src/push.c
index 67ebcfb..b724188 100644
--- a/src/push.c
+++ b/src/push.c
@@ -349,8 +349,9 @@ static int queue_objects(git_push *push)
if (git_oid_is_zero(&head->oid))
continue;
- /* TODO */
- git_revwalk_hide(rw, &head->oid);
+ if ((error = git_revwalk_hide(rw, &head->oid)) < 0 &&
+ error != GIT_ENOTFOUND && error != GIT_EINVALIDSPEC && error != GIT_EPEEL)
+ goto on_error;
}
error = git_packbuilder_insert_walk(push->pb, rw);
@@ -554,7 +555,9 @@ int git_push_options_init(git_push_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_push_init_options(git_push_options *opts, unsigned int version)
{
return git_push_options_init(opts, version);
}
+#endif
diff --git a/src/reader.c b/src/reader.c
index 90f700a..4892894 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -61,7 +61,8 @@ int git_reader_for_tree(git_reader **out, git_tree *tree)
{
tree_reader *reader;
- assert(out && tree);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(tree);
reader = git__calloc(1, sizeof(tree_reader));
GIT_ERROR_CHECK_ALLOC(reader);
@@ -97,8 +98,7 @@ static int workdir_reader_read(
git_oid id;
int error;
- if ((error = git_buf_joinpath(&path,
- git_repository_workdir(reader->repo), filename)) < 0)
+ if ((error = git_repository_workdir_path(&path, reader->repo, filename)) < 0)
goto done;
if ((error = p_lstat(path.ptr, &st)) < 0) {
@@ -158,7 +158,8 @@ int git_reader_for_workdir(
workdir_reader *reader;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
reader = git__calloc(1, sizeof(workdir_reader));
GIT_ERROR_CHECK_ALLOC(reader);
@@ -223,7 +224,8 @@ int git_reader_for_index(
index_reader *reader;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
reader = git__calloc(1, sizeof(index_reader));
GIT_ERROR_CHECK_ALLOC(reader);
@@ -251,7 +253,9 @@ int git_reader_read(
git_reader *reader,
const char *filename)
{
- assert(out && reader && filename);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(reader);
+ GIT_ASSERT_ARG(filename);
return reader->read(out, out_id, out_filemode, reader, filename);
}
diff --git a/src/rebase.c b/src/rebase.c
index 0a38807..bf6581a 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -186,8 +186,8 @@ static git_rebase_operation *rebase_operation_alloc(
{
git_rebase_operation *operation;
- assert((type == GIT_REBASE_OPERATION_EXEC) == !id);
- assert((type == GIT_REBASE_OPERATION_EXEC) == !!exec);
+ GIT_ASSERT_WITH_RETVAL((type == GIT_REBASE_OPERATION_EXEC) == !id, NULL);
+ GIT_ASSERT_WITH_RETVAL((type == GIT_REBASE_OPERATION_EXEC) == !!exec, NULL);
if ((operation = git_array_alloc(rebase->operations)) == NULL)
return NULL;
@@ -301,7 +301,7 @@ int git_rebase_open(
size_t state_path_len;
int error;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if ((error = rebase_check_versions(given_opts)) < 0)
return error;
@@ -501,10 +501,12 @@ int git_rebase_options_init(git_rebase_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_rebase_init_options(git_rebase_options *opts, unsigned int version)
{
return git_rebase_options_init(opts, version);
}
+#endif
static int rebase_ensure_not_in_progress(git_repository *repo)
{
@@ -699,7 +701,8 @@ int git_rebase_init(
bool inmemory = (given_opts && given_opts->inmemory);
int error;
- assert(repo && (upstream || onto));
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(upstream || onto);
*out = NULL;
@@ -910,7 +913,8 @@ int git_rebase_next(
{
int error;
- assert(out && rebase);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(rebase);
if ((error = rebase_movenext(rebase)) < 0)
return error;
@@ -929,7 +933,9 @@ int git_rebase_inmemory_index(
git_index **out,
git_rebase *rebase)
{
- assert(out && rebase && rebase->index);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(rebase);
+ GIT_ASSERT_ARG(rebase->index);
GIT_REFCOUNT_INC(rebase->index);
*out = rebase->index;
@@ -1004,12 +1010,12 @@ static int rebase_commit__create(
}
if (git_buf_is_allocated(&commit_signature)) {
- assert(git_buf_contains_nul(&commit_signature));
+ GIT_ASSERT(git_buf_contains_nul(&commit_signature));
commit_signature_string = git_buf_cstr(&commit_signature);
}
if (git_buf_is_allocated(&signature_field)) {
- assert(git_buf_contains_nul(&signature_field));
+ GIT_ASSERT(git_buf_contains_nul(&signature_field));
signature_field_string = git_buf_cstr(&signature_field);
}
@@ -1053,7 +1059,7 @@ static int rebase_commit_merge(
int error;
operation = git_array_get(rebase->operations, rebase->current);
- assert(operation);
+ GIT_ASSERT(operation);
if ((error = rebase_ensure_not_dirty(rebase->repo, false, true, GIT_EUNMERGED)) < 0 ||
(error = git_repository_head(&head, rebase->repo)) < 0 ||
@@ -1093,9 +1099,9 @@ static int rebase_commit_inmemory(
git_commit *commit = NULL;
int error = 0;
- assert(rebase->index);
- assert(rebase->last_commit);
- assert(rebase->current < rebase->operations.size);
+ GIT_ASSERT_ARG(rebase->index);
+ GIT_ASSERT_ARG(rebase->last_commit);
+ GIT_ASSERT_ARG(rebase->current < rebase->operations.size);
if ((error = rebase_commit__create(&commit, rebase, rebase->index,
rebase->last_commit, author, committer, message_encoding, message)) < 0)
@@ -1123,7 +1129,8 @@ int git_rebase_commit(
{
int error;
- assert(rebase && committer);
+ GIT_ASSERT_ARG(rebase);
+ GIT_ASSERT_ARG(committer);
if (rebase->inmemory)
error = rebase_commit_inmemory(
@@ -1143,7 +1150,7 @@ int git_rebase_abort(git_rebase *rebase)
git_commit *orig_head_commit = NULL;
int error;
- assert(rebase);
+ GIT_ASSERT_ARG(rebase);
if (rebase->inmemory)
return 0;
@@ -1356,7 +1363,7 @@ int git_rebase_finish(
{
int error = 0;
- assert(rebase);
+ GIT_ASSERT_ARG(rebase);
if (rebase->inmemory)
return 0;
@@ -1371,14 +1378,17 @@ int git_rebase_finish(
}
const char *git_rebase_orig_head_name(git_rebase *rebase) {
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return rebase->orig_head_name;
}
const git_oid *git_rebase_orig_head_id(git_rebase *rebase) {
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return &rebase->orig_head_id;
}
const char *git_rebase_onto_name(git_rebase *rebase) {
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return rebase->onto_name;
}
@@ -1388,21 +1398,21 @@ const git_oid *git_rebase_onto_id(git_rebase *rebase) {
size_t git_rebase_operation_entrycount(git_rebase *rebase)
{
- assert(rebase);
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, 0);
return git_array_size(rebase->operations);
}
size_t git_rebase_operation_current(git_rebase *rebase)
{
- assert(rebase);
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, 0);
return rebase->started ? rebase->current : GIT_REBASE_NO_OPERATION;
}
git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx)
{
- assert(rebase);
+ GIT_ASSERT_ARG_WITH_RETVAL(rebase, NULL);
return git_array_get(rebase->operations, idx);
}
diff --git a/src/refdb.c b/src/refdb.c
index fbbf519..ed33de9 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -17,11 +17,15 @@
#include "reflog.h"
#include "posix.h"
+#define DEFAULT_NESTING_LEVEL 5
+#define MAX_NESTING_LEVEL 10
+
int git_refdb_new(git_refdb **out, git_repository *repo)
{
git_refdb *db;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
db = git__calloc(1, sizeof(*db));
GIT_ERROR_CHECK_ALLOC(db);
@@ -38,7 +42,8 @@ int git_refdb_open(git_refdb **out, git_repository *repo)
git_refdb *db;
git_refdb_backend *dir;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -86,7 +91,7 @@ int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
int git_refdb_compress(git_refdb *db)
{
- assert(db);
+ GIT_ASSERT_ARG(db);
if (db->backend->compress)
return db->backend->compress(db->backend);
@@ -111,7 +116,9 @@ void git_refdb_free(git_refdb *db)
int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name)
{
- assert(exists && refdb && refdb->backend);
+ GIT_ASSERT_ARG(exists);
+ GIT_ASSERT_ARG(refdb);
+ GIT_ASSERT_ARG(refdb->backend);
return refdb->backend->exists(exists, refdb->backend, ref_name);
}
@@ -121,7 +128,10 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name)
git_reference *ref;
int error;
- assert(db && db->backend && out && ref_name);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ref_name);
error = db->backend->lookup(&ref, db->backend, ref_name);
if (error < 0)
@@ -134,6 +144,59 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name)
return 0;
}
+int git_refdb_resolve(
+ git_reference **out,
+ git_refdb *db,
+ const char *ref_name,
+ int max_nesting)
+{
+ git_reference *ref = NULL;
+ int error = 0, nesting;
+
+ *out = NULL;
+
+ if (max_nesting > MAX_NESTING_LEVEL)
+ max_nesting = MAX_NESTING_LEVEL;
+ else if (max_nesting < 0)
+ max_nesting = DEFAULT_NESTING_LEVEL;
+
+ if ((error = git_refdb_lookup(&ref, db, ref_name)) < 0)
+ goto out;
+
+ for (nesting = 0; nesting < max_nesting; nesting++) {
+ git_reference *resolved;
+
+ if (ref->type == GIT_REFERENCE_DIRECT)
+ break;
+
+ if ((error = git_refdb_lookup(&resolved, db, git_reference_symbolic_target(ref))) < 0) {
+ /* If we found a symbolic reference with a nonexistent target, return it. */
+ if (error == GIT_ENOTFOUND) {
+ error = 0;
+ *out = ref;
+ ref = NULL;
+ }
+ goto out;
+ }
+
+ git_reference_free(ref);
+ ref = resolved;
+ }
+
+ if (ref->type != GIT_REFERENCE_DIRECT && max_nesting != 0) {
+ git_error_set(GIT_ERROR_REFERENCE,
+ "cannot resolve reference (>%u levels deep)", max_nesting);
+ error = -1;
+ goto out;
+ }
+
+ *out = ref;
+ ref = NULL;
+out:
+ git_reference_free(ref);
+ return error;
+}
+
int git_refdb_iterator(git_reference_iterator **out, git_refdb *db, const char *glob)
{
int error;
@@ -178,7 +241,8 @@ void git_refdb_iterator_free(git_reference_iterator *iter)
int git_refdb_write(git_refdb *db, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target)
{
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
GIT_REFCOUNT_INC(db);
ref->db = db;
@@ -197,7 +261,9 @@ int git_refdb_rename(
{
int error;
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
+
error = db->backend->rename(out, db->backend, old_name, new_name, force, who, message);
if (error < 0)
return error;
@@ -212,7 +278,9 @@ int git_refdb_rename(
int git_refdb_delete(struct git_refdb *db, const char *ref_name, const git_oid *old_id, const char *old_target)
{
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
+
return db->backend->del(db->backend, ref_name, old_id, old_target);
}
@@ -220,7 +288,8 @@ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name)
{
int error;
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
if ((error = db->backend->reflog_read(out, db->backend, name)) < 0)
return error;
@@ -231,16 +300,97 @@ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name)
return 0;
}
+int git_refdb_should_write_reflog(int *out, git_refdb *db, const git_reference *ref)
+{
+ int error, logall;
+
+ error = git_repository__configmap_lookup(&logall, db->repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
+ if (error < 0)
+ return error;
+
+ /* Defaults to the opposite of the repo being bare */
+ if (logall == GIT_LOGALLREFUPDATES_UNSET)
+ logall = !git_repository_is_bare(db->repo);
+
+ *out = 0;
+ switch (logall) {
+ case GIT_LOGALLREFUPDATES_FALSE:
+ *out = 0;
+ break;
+
+ case GIT_LOGALLREFUPDATES_TRUE:
+ /* Only write if it already has a log,
+ * or if it's under heads/, remotes/ or notes/
+ */
+ *out = git_refdb_has_log(db, ref->name) ||
+ !git__prefixcmp(ref->name, GIT_REFS_HEADS_DIR) ||
+ !git__strcmp(ref->name, GIT_HEAD_FILE) ||
+ !git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR) ||
+ !git__prefixcmp(ref->name, GIT_REFS_NOTES_DIR);
+ break;
+
+ case GIT_LOGALLREFUPDATES_ALWAYS:
+ *out = 1;
+ break;
+ }
+
+ return 0;
+}
+
+int git_refdb_should_write_head_reflog(int *out, git_refdb *db, const git_reference *ref)
+{
+ git_reference *head = NULL, *resolved = NULL;
+ const char *name;
+ int error;
+
+ *out = 0;
+
+ if (ref->type == GIT_REFERENCE_SYMBOLIC) {
+ error = 0;
+ goto out;
+ }
+
+ if ((error = git_refdb_lookup(&head, db, GIT_HEAD_FILE)) < 0)
+ goto out;
+
+ if (git_reference_type(head) == GIT_REFERENCE_DIRECT)
+ goto out;
+
+ /* Go down the symref chain until we find the branch */
+ if ((error = git_refdb_resolve(&resolved, db, git_reference_symbolic_target(head), -1)) < 0) {
+ if (error != GIT_ENOTFOUND)
+ goto out;
+ error = 0;
+ name = git_reference_symbolic_target(head);
+ } else if (git_reference_type(resolved) == GIT_REFERENCE_SYMBOLIC) {
+ name = git_reference_symbolic_target(resolved);
+ } else {
+ name = git_reference_name(resolved);
+ }
+
+ if (strcmp(name, ref->name))
+ goto out;
+
+ *out = 1;
+
+out:
+ git_reference_free(resolved);
+ git_reference_free(head);
+ return error;
+}
+
int git_refdb_has_log(git_refdb *db, const char *refname)
{
- assert(db && refname);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(refname);
return db->backend->has_log(db->backend, refname);
}
int git_refdb_ensure_log(git_refdb *db, const char *refname)
{
- assert(db && refname);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(refname);
return db->backend->ensure_log(db->backend, refname);
}
@@ -254,7 +404,9 @@ int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version)
int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
{
- assert(payload && db && refname);
+ GIT_ASSERT_ARG(payload);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(refname);
if (!db->backend->lock) {
git_error_set(GIT_ERROR_REFERENCE, "backend does not support locking");
@@ -266,7 +418,7 @@ int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message)
{
- assert(db);
+ GIT_ASSERT_ARG(db);
return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message);
}
diff --git a/src/refdb.h b/src/refdb.h
index 2d4ec75..84e19b1 100644
--- a/src/refdb.h
+++ b/src/refdb.h
@@ -30,6 +30,31 @@ int git_refdb_lookup(
git_refdb *refdb,
const char *ref_name);
+/**
+ * Resolve the reference by following symbolic references.
+ *
+ * Given a reference name, this function will follow any symbolic references up
+ * to `max_nesting` deep and return the resolved direct reference. If any of
+ * the intermediate symbolic references points to a non-existing reference,
+ * then that symbolic reference is returned instead with an error code of `0`.
+ * If the given reference is a direct reference already, it is returned
+ * directly.
+ *
+ * If `max_nesting` is `0`, the reference will not be resolved. If it's
+ * negative, it will be set to the default resolve depth which is `5`.
+ *
+ * @param out Pointer to store the result in.
+ * @param db The refdb to use for resolving the reference.
+ * @param ref_name The reference name to lookup and resolve.
+ * @param max_nesting The maximum nesting depth.
+ * @return `0` on success, a negative error code otherwise.
+ */
+int git_refdb_resolve(
+ git_reference **out,
+ git_refdb *db,
+ const char *ref_name,
+ int max_nesting);
+
int git_refdb_rename(
git_reference **out,
git_refdb *db,
@@ -50,6 +75,50 @@ int git_refdb_delete(git_refdb *refdb, const char *ref_name, const git_oid *old_
int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name);
int git_refdb_reflog_write(git_reflog *reflog);
+/**
+ * Determine whether a reflog entry should be created for the given reference.
+ *
+ * Whether or not writing to a reference should create a reflog entry is
+ * dependent on a number of things. Most importantly, there's the
+ * "core.logAllRefUpdates" setting that controls in which situations a
+ * reference should get a corresponding reflog entry. The following values for
+ * it are understood:
+ *
+ * - "false": Do not log reference updates.
+ *
+ * - "true": Log normal reference updates. This will write entries for
+ * references in "refs/heads", "refs/remotes", "refs/notes" and
+ * "HEAD" or if the reference already has a log entry.
+ *
+ * - "always": Always create a reflog entry.
+ *
+ * If unset, the value will default to "true" for non-bare repositories and
+ * "false" for bare ones.
+ *
+ * @param out pointer to which the result will be written, `1` means a reflog
+ * entry should be written, `0` means none should be written.
+ * @param db The refdb to decide this for.
+ * @param ref The reference one wants to check.
+ * @return `0` on success, a negative error code otherwise.
+ */
+int git_refdb_should_write_reflog(int *out, git_refdb *db, const git_reference *ref);
+
+/**
+ * Determine whether a reflog entry should be created for HEAD if creating one
+ * for the given reference
+ *
+ * In case the given reference is being pointed to by HEAD, then creating a
+ * reflog entry for this reference also requires us to create a corresponding
+ * reflog entry for HEAD. This function can be used to determine that scenario.
+ *
+ * @param out pointer to which the result will be written, `1` means a reflog
+ * entry should be written, `0` means none should be written.
+ * @param db The refdb to decide this for.
+ * @param ref The reference one wants to check.
+ * @return `0` on success, a negative error code otherwise.
+ */
+int git_refdb_should_write_head_reflog(int *out, git_refdb *db, const git_reference *ref);
+
int git_refdb_has_log(git_refdb *db, const char *refname);
int git_refdb_ensure_log(git_refdb *refdb, const char *refname);
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index a721f98..0cb9255 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -5,8 +5,6 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "refdb_fs.h"
-
#include "refs.h"
#include "hash.h"
#include "repository.h"
@@ -70,6 +68,35 @@ typedef struct refdb_fs_backend {
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
+GIT_INLINE(int) loose_path(
+ git_buf *out,
+ const char *base,
+ const char *refname)
+{
+ if (git_buf_joinpath(out, base, refname) < 0)
+ return -1;
+
+ return git_path_validate_filesystem_with_suffix(out->ptr, out->size,
+ CONST_STRLEN(".lock"));
+}
+
+GIT_INLINE(int) reflog_path(
+ git_buf *out,
+ git_repository *repo,
+ const char *refname)
+{
+ const char *base;
+ int error;
+
+ base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
+ repo->commondir;
+
+ if ((error = git_buf_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
+ return error;
+
+ return loose_path(out, out->ptr, refname);
+}
+
static int packref_cmp(const void *a_, const void *b_)
{
const struct packref *a = a_, *b = b_;
@@ -95,7 +122,7 @@ static int packed_reload(refdb_fs_backend *backend)
*/
if (error <= 0) {
if (error == GIT_ENOTFOUND) {
- git_sortedcache_clear(backend->refcache, true);
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, true));
git_error_clear();
error = 0;
}
@@ -104,7 +131,7 @@ static int packed_reload(refdb_fs_backend *backend)
/* At this point, refresh the packed refs from the loaded buffer. */
- git_sortedcache_clear(backend->refcache, false);
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
scan = (char *)packedrefs.ptr;
eof = scan + packedrefs.size;
@@ -192,7 +219,7 @@ static int packed_reload(refdb_fs_backend *backend)
parse_failed:
git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
- git_sortedcache_clear(backend->refcache, false);
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
git_sortedcache_wunlock(backend->refcache);
git_buf_dispose(&packedrefs);
@@ -225,9 +252,8 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
{
int error;
- /* build full path to file */
- if ((error = git_buf_joinpath(buf, base, path)) < 0 ||
- (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
+ if ((error = loose_path(buf, base, path)) < 0 ||
+ (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
git_buf_dispose(buf);
return error;
@@ -256,7 +282,8 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
goto done;
- git_sortedcache_wlock(backend->refcache);
+ if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
+ goto done;
if (!(error = git_sortedcache_upsert(
(void **)&ref, backend->refcache, name))) {
@@ -333,11 +360,11 @@ static int refdb_fs_backend__exists(
git_buf ref_path = GIT_BUF_INIT;
int error;
- assert(backend);
+ GIT_ASSERT_ARG(backend);
*exists = 0;
- if ((error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
+ if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
goto out;
if (git_path_isfile(ref_path.ptr)) {
@@ -474,7 +501,7 @@ static int refdb_fs_backend__lookup(
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
int error;
- assert(backend);
+ GIT_ASSERT_ARG(backend);
if (!(error = loose_lookup(out, backend, ref_name)))
return 0;
@@ -551,7 +578,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
}
}
- if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
+ if ((error = git_buf_puts(&path, backend->commonpath)) < 0 ||
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
git_buf_dispose(&path);
return error;
@@ -680,12 +707,13 @@ static int refdb_fs_backend__iterator(
refdb_fs_iter *iter = NULL;
int error;
- assert(backend);
+ GIT_ASSERT_ARG(backend);
iter = git__calloc(1, sizeof(refdb_fs_iter));
GIT_ERROR_CHECK_ALLOC(iter);
- git_pool_init(&iter->pool, 1);
+ if ((error = git_pool_init(&iter->pool, 1)) < 0)
+ goto out;
if ((error = git_vector_init(&iter->loose, 8, NULL)) < 0)
goto out;
@@ -761,7 +789,8 @@ static int reference_path_available(
}
}
- git_sortedcache_rlock(backend->refcache);
+ if ((error = git_sortedcache_rlock(backend->refcache)) < 0)
+ return error;
for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
struct packref *ref = git_sortedcache_entry(backend->refcache, i);
@@ -784,9 +813,11 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
git_buf ref_path = GIT_BUF_INIT;
const char *basedir;
- assert(file && backend && name);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(name);
- if (!git_path_isvalid(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
+ if (!git_path_validate(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
return GIT_EINVALIDSPEC;
}
@@ -802,8 +833,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
return error;
- if (git_buf_joinpath(&ref_path, basedir, name) < 0)
- return -1;
+ if ((error = loose_path(&ref_path, basedir, name)) < 0)
+ return error;
filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
if (backend->fsync)
@@ -820,7 +851,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
static int loose_commit(git_filebuf *file, const git_reference *ref)
{
- assert(file && ref);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(ref);
if (ref->type == GIT_REFERENCE_DIRECT) {
char oid[GIT_OID_HEXSZ + 1];
@@ -830,7 +862,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
} else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
} else {
- assert(0); /* don't let this happen */
+ GIT_ASSERT(0);
}
return git_filebuf_commit(file);
@@ -1067,7 +1099,7 @@ static int packed_write(refdb_fs_backend *backend)
for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
struct packref *ref = git_sortedcache_entry(refcache, i);
- assert(ref);
+ GIT_ASSERT(ref);
if ((error = packed_find_peel(backend, ref)) < 0)
goto fail;
@@ -1129,44 +1161,6 @@ cleanup:
}
static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message);
-static int has_reflog(git_repository *repo, const char *name);
-
-static int should_write_reflog(int *write, git_repository *repo, const char *name)
-{
- int error, logall;
-
- error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
- if (error < 0)
- return error;
-
- /* Defaults to the opposite of the repo being bare */
- if (logall == GIT_LOGALLREFUPDATES_UNSET)
- logall = !git_repository_is_bare(repo);
-
- *write = 0;
- switch (logall) {
- case GIT_LOGALLREFUPDATES_FALSE:
- *write = 0;
- break;
-
- case GIT_LOGALLREFUPDATES_TRUE:
- /* Only write if it already has a log,
- * or if it's under heads/, remotes/ or notes/
- */
- *write = has_reflog(repo, name) ||
- !git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
- !git__strcmp(name, GIT_HEAD_FILE) ||
- !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
- !git__prefixcmp(name, GIT_REFS_NOTES_DIR);
- break;
-
- case GIT_LOGALLREFUPDATES_ALWAYS:
- *write = 1;
- break;
- }
-
- return 0;
-}
static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
const git_oid *old_id, const char *old_target)
@@ -1179,8 +1173,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
if (!old_id && !old_target)
return 0;
- if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0)
+ if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
+ if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
+ return 0;
goto out;
+ }
/* If the types don't match, there's no way the values do */
if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
@@ -1220,54 +1217,28 @@ out:
*/
static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message)
{
- int error;
+ git_reference *head = NULL;
+ git_refdb *refdb = NULL;
+ int error, write_reflog;
git_oid old_id;
- git_reference *tmp = NULL, *head = NULL, *peeled = NULL;
- const char *name;
- if (ref->type == GIT_REFERENCE_SYMBOLIC)
- return 0;
+ if ((error = git_repository_refdb(&refdb, backend->repo)) < 0 ||
+ (error = git_refdb_should_write_head_reflog(&write_reflog, refdb, ref)) < 0)
+ goto out;
+ if (!write_reflog)
+ goto out;
/* if we can't resolve, we use {0}*40 as old id */
if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0)
memset(&old_id, 0, sizeof(old_id));
- if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0)
- return error;
-
- if (git_reference_type(head) == GIT_REFERENCE_DIRECT)
- goto cleanup;
-
- if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0)
- goto cleanup;
-
- /* Go down the symref chain until we find the branch */
- while (git_reference_type(tmp) == GIT_REFERENCE_SYMBOLIC) {
- error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp));
- if (error < 0)
- break;
-
- git_reference_free(tmp);
- tmp = peeled;
- }
-
- if (error == GIT_ENOTFOUND) {
- error = 0;
- name = git_reference_symbolic_target(tmp);
- } else if (error < 0) {
- goto cleanup;
- } else {
- name = git_reference_name(tmp);
- }
-
- if (strcmp(name, ref->name))
- goto cleanup;
-
- error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message);
+ if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0 ||
+ (error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message)) < 0)
+ goto out;
-cleanup:
- git_reference_free(tmp);
+out:
git_reference_free(head);
+ git_refdb_free(refdb);
return error;
}
@@ -1284,7 +1255,7 @@ static int refdb_fs_backend__write(
git_filebuf file = GIT_FILEBUF_INIT;
int error = 0;
- assert(backend);
+ GIT_ASSERT_ARG(backend);
if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
return error;
@@ -1336,7 +1307,10 @@ static int refdb_fs_backend__write_tail(
}
if (update_reflog) {
- if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0)
+ git_refdb *refdb;
+
+ if ((error = git_repository_refdb__weakptr(&refdb, backend->repo)) < 0 ||
+ (error = git_refdb_should_write_reflog(&should_write, refdb, ref)) < 0)
goto on_error;
if (should_write) {
@@ -1354,7 +1328,7 @@ on_error:
return error;
}
-static void refdb_fs_backend__prune_refs(
+static int refdb_fs_backend__prune_refs(
refdb_fs_backend *backend,
const char *ref_name,
const char *prefix)
@@ -1362,10 +1336,12 @@ static void refdb_fs_backend__prune_refs(
git_buf relative_path = GIT_BUF_INIT;
git_buf base_path = GIT_BUF_INIT;
size_t commonlen;
+ int error;
- assert(backend && ref_name);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(ref_name);
- if (git_buf_sets(&relative_path, ref_name) < 0)
+ if ((error = git_buf_sets(&relative_path, ref_name)) < 0)
goto cleanup;
git_path_squash_slashes(&relative_path);
@@ -1375,20 +1351,33 @@ static void refdb_fs_backend__prune_refs(
git_buf_truncate(&relative_path, commonlen);
- if (prefix) {
- if (git_buf_join3(&base_path, '/', backend->commonpath, prefix, git_buf_cstr(&relative_path)) < 0)
- goto cleanup;
- } else {
- if (git_buf_joinpath(&base_path, backend->commonpath, git_buf_cstr(&relative_path)) < 0)
- goto cleanup;
- }
+ if (prefix)
+ error = git_buf_join3(&base_path, '/',
+ backend->commonpath, prefix,
+ git_buf_cstr(&relative_path));
+ else
+ error = git_buf_joinpath(&base_path,
+ backend->commonpath,
+ git_buf_cstr(&relative_path));
- git_futils_rmdir_r(ref_name + commonlen, git_buf_cstr(&base_path), GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
+ if (!error)
+ error = git_path_validate_filesystem(base_path.ptr, base_path.size);
+
+ if (error < 0)
+ goto cleanup;
+
+ error = git_futils_rmdir_r(ref_name + commonlen,
+ git_buf_cstr(&base_path),
+ GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
+
+ if (error == GIT_ENOTFOUND)
+ error = 0;
}
cleanup:
git_buf_dispose(&relative_path);
git_buf_dispose(&base_path);
+ return error;
}
static int refdb_fs_backend__delete(
@@ -1400,7 +1389,8 @@ static int refdb_fs_backend__delete(
git_filebuf file = GIT_FILEBUF_INIT;
int error = 0;
- assert(backend && ref_name);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(ref_name);
if ((error = loose_lock(&file, backend, ref_name)) < 0)
return error;
@@ -1415,19 +1405,19 @@ static int refdb_fs_backend__delete(
static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
{
- git_buf loose_path = GIT_BUF_INIT;
+ git_buf path = GIT_BUF_INIT;
int error = 0;
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
- return -1;
+ if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
+ return error;
- error = p_unlink(loose_path.ptr);
+ error = p_unlink(path.ptr);
if (error < 0 && errno == ENOENT)
error = GIT_ENOTFOUND;
else if (error != 0)
error = -1;
- git_buf_dispose(&loose_path);
+ git_buf_dispose(&path);
return error;
}
@@ -1486,7 +1476,7 @@ static int refdb_fs_backend__delete_tail(
cleanup:
git_filebuf_cleanup(file);
if (error == 0)
- refdb_fs_backend__prune_refs(backend, ref_name, "");
+ error = refdb_fs_backend__prune_refs(backend, ref_name, "");
return error;
}
@@ -1506,7 +1496,7 @@ static int refdb_fs_backend__rename(
git_filebuf file = GIT_FILEBUF_INIT;
int error;
- assert(backend);
+ GIT_ASSERT_ARG(backend);
if ((error = reference_path_available(
backend, new_name, old_name, force)) < 0 ||
@@ -1559,7 +1549,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
int error;
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
- assert(backend);
+ GIT_ASSERT_ARG(backend);
if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
(error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
@@ -1573,7 +1563,8 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
{
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
- assert(backend);
+ if (!backend)
+ return;
git_sortedcache_free(backend->refcache);
git__free(backend->gitpath);
@@ -1618,8 +1609,9 @@ static char *setup_namespace(git_repository *repo, const char *in)
GIT_MKDIR_PATH, NULL) < 0)
goto done;
- /* Return root of the namespaced gitpath, i.e. without the trailing '/refs' */
+ /* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
git_buf_rtruncate_at_char(&path, '/');
+ git_buf_putc(&path, '/');
out = git_buf_detach(&path);
done:
@@ -1720,13 +1712,6 @@ static int create_new_reflog_file(const char *filepath)
return p_close(fd);
}
-GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
-{
- if (strcmp(name, GIT_HEAD_FILE) == 0)
- return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
- return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
-}
-
static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
{
refdb_fs_backend *backend;
@@ -1734,12 +1719,12 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
git_buf path = GIT_BUF_INIT;
int error;
- assert(_backend && name);
+ GIT_ASSERT_ARG(_backend && name);
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
repo = backend->repo;
- if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
+ if ((error = reflog_path(&path, repo, name)) < 0)
return error;
error = create_new_reflog_file(git_buf_cstr(&path));
@@ -1753,7 +1738,7 @@ static int has_reflog(git_repository *repo, const char *name)
int ret = 0;
git_buf path = GIT_BUF_INIT;
- if (retrieve_reflog_path(&path, repo, name) < 0)
+ if (reflog_path(&path, repo, name) < 0)
goto cleanup;
ret = git_path_isfile(git_buf_cstr(&path));
@@ -1767,7 +1752,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
{
refdb_fs_backend *backend;
- assert(_backend && name);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(name);
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
@@ -1783,7 +1769,9 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
git_repository *repo;
refdb_fs_backend *backend;
- assert(out && _backend && name);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(name);
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
repo = backend->repo;
@@ -1791,7 +1779,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
if (reflog_alloc(&log, name) < 0)
return -1;
- if (retrieve_reflog_path(&log_path, repo, name) < 0)
+ if (reflog_path(&log_path, repo, name) < 0)
goto cleanup;
error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
@@ -1868,12 +1856,12 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
repo = backend->repo;
- if (!git_path_isvalid(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
+ if (!git_path_validate(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
return GIT_EINVALIDSPEC;
}
- if (retrieve_reflog_path(&log_path, repo, refname) < 0)
+ if (reflog_path(&log_path, repo, refname) < 0)
return -1;
if (!git_path_isfile(git_buf_cstr(&log_path))) {
@@ -1900,7 +1888,8 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
git_buf log = GIT_BUF_INIT;
git_filebuf fbuf = GIT_FILEBUF_INIT;
- assert(_backend && reflog);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(reflog);
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
@@ -1973,7 +1962,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
goto cleanup;
- if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0)
+ if ((error = reflog_path(&path, repo, ref->name)) < 0)
goto cleanup;
if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
@@ -2022,7 +2011,9 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
git_repository *repo;
refdb_fs_backend *backend;
- assert(_backend && old_name && new_name);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(old_name);
+ GIT_ASSERT_ARG(new_name);
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
repo = backend->repo;
@@ -2034,11 +2025,11 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
return -1;
- if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
- return -1;
+ if ((error = loose_path(&old_path, git_buf_cstr(&temp_path), old_name)) < 0)
+ return error;
- if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0)
- return -1;
+ if ((error = loose_path(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized))) < 0)
+ return error;
if (!git_path_exists(git_buf_cstr(&old_path))) {
error = GIT_ENOTFOUND;
@@ -2052,8 +2043,8 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
* - a/b -> a/b/c
* - a/b/c/d -> a/b/c
*/
- if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0)
- return -1;
+ if ((error = loose_path(&temp_path, git_buf_cstr(&temp_path), "temp_reflog")) < 0)
+ return error;
if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
error = -1;
@@ -2099,9 +2090,10 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
git_buf path = GIT_BUF_INIT;
int error;
- assert(_backend && name);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(name);
- if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
+ if ((error = reflog_path(&path, backend->repo, name)) < 0)
goto out;
if (!git_path_exists(path.ptr))
@@ -2110,7 +2102,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
if ((error = p_unlink(path.ptr)) < 0)
goto out;
- refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
+ error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
out:
git_buf_dispose(&path);
@@ -2129,6 +2121,9 @@ int git_refdb_backend_fs(
backend = git__calloc(1, sizeof(refdb_fs_backend));
GIT_ERROR_CHECK_ALLOC(backend);
+ if (git_refdb_init_backend(&backend->parent, GIT_REFDB_BACKEND_VERSION) < 0)
+ goto fail;
+
backend->repo = repository;
if (repository->gitdir) {
diff --git a/src/refdb_fs.h b/src/refdb_fs.h
deleted file mode 100644
index 0c84814..0000000
--- a/src/refdb_fs.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_refdb_fs_h__
-#define INCLUDE_refdb_fs_h__
-
-#include "common.h"
-
-#include "strmap.h"
-
-typedef struct {
- git_strmap *packfile;
- time_t packfile_time;
-} git_refcache;
-
-#endif
diff --git a/src/reflog.c b/src/reflog.c
index 24dada0..1e9c0d4 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -12,12 +12,8 @@
#include "signature.h"
#include "refdb.h"
-#include <git2/sys/refdb_backend.h>
-
-git_reflog_entry *git_reflog_entry__alloc(void)
-{
- return git__calloc(1, sizeof(git_reflog_entry));
-}
+#include "git2/sys/refdb_backend.h"
+#include "git2/sys/reflog.h"
void git_reflog_entry__free(git_reflog_entry *entry)
{
@@ -54,7 +50,9 @@ int git_reflog_read(git_reflog **reflog, git_repository *repo, const char *name
git_refdb *refdb;
int error;
- assert(reflog && repo && name);
+ GIT_ASSERT_ARG(reflog);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
return error;
@@ -66,7 +64,8 @@ int git_reflog_write(git_reflog *reflog)
{
git_refdb *db;
- assert(reflog && reflog->db);
+ GIT_ASSERT_ARG(reflog);
+ GIT_ASSERT_ARG(reflog->db);
db = reflog->db;
return db->backend->reflog_write(db->backend, reflog);
@@ -77,7 +76,9 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign
const git_reflog_entry *previous;
git_reflog_entry *entry;
- assert(reflog && new_oid && committer);
+ GIT_ASSERT_ARG(reflog);
+ GIT_ASSERT_ARG(new_oid);
+ GIT_ASSERT_ARG(committer);
entry = git__calloc(1, sizeof(git_reflog_entry));
GIT_ERROR_CHECK_ALLOC(entry);
@@ -143,13 +144,13 @@ int git_reflog_delete(git_repository *repo, const char *name)
size_t git_reflog_entrycount(git_reflog *reflog)
{
- assert(reflog);
+ GIT_ASSERT_ARG_WITH_RETVAL(reflog, 0);
return reflog->entries.length;
}
-const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size_t idx)
+const git_reflog_entry *git_reflog_entry_byindex(const git_reflog *reflog, size_t idx)
{
- assert(reflog);
+ GIT_ASSERT_ARG_WITH_RETVAL(reflog, NULL);
if (idx >= reflog->entries.length)
return NULL;
@@ -158,27 +159,27 @@ const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size
&reflog->entries, reflog_inverse_index(idx, reflog->entries.length));
}
-const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry)
+const git_oid *git_reflog_entry_id_old(const git_reflog_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
return &entry->oid_old;
}
-const git_oid * git_reflog_entry_id_new(const git_reflog_entry *entry)
+const git_oid *git_reflog_entry_id_new(const git_reflog_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
return &entry->oid_cur;
}
-const git_signature * git_reflog_entry_committer(const git_reflog_entry *entry)
+const git_signature *git_reflog_entry_committer(const git_reflog_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
return entry->committer;
}
-const char * git_reflog_entry_message(const git_reflog_entry *entry)
+const char *git_reflog_entry_message(const git_reflog_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
return entry->msg;
}
diff --git a/src/refs.c b/src/refs.c
index 633d83a..4900afa 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -27,9 +27,6 @@
bool git_reference__enable_symbolic_ref_target_validation = true;
-#define DEFAULT_NESTING_LEVEL 5
-#define MAX_NESTING_LEVEL 10
-
enum {
GIT_PACKREF_HAS_PEEL = 1,
GIT_PACKREF_WAS_LOOSE = 2
@@ -53,7 +50,8 @@ git_reference *git_reference__alloc_symbolic(
{
git_reference *ref;
- assert(name && target);
+ GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(target, NULL);
ref = alloc_ref(name);
if (!ref)
@@ -76,7 +74,8 @@ git_reference *git_reference__alloc(
{
git_reference *ref;
- assert(name && oid);
+ GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(oid, NULL);
ref = alloc_ref(name);
if (!ref)
@@ -97,7 +96,8 @@ git_reference *git_reference__realloc(
size_t namelen, reflen;
git_reference *rewrite = NULL;
- assert(ptr_to_ref && name);
+ GIT_ASSERT_ARG_WITH_RETVAL(ptr_to_ref, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
namelen = strlen(name);
@@ -214,92 +214,37 @@ int git_reference_lookup_resolved(
const char *name,
int max_nesting)
{
- git_refname_t scan_name;
- git_reference_t scan_type;
- int error = 0, nesting;
- git_reference *ref = NULL;
+ git_refname_t normalized;
git_refdb *refdb;
+ int error = 0;
- assert(ref_out && repo && name);
-
- *ref_out = NULL;
-
- if (max_nesting > MAX_NESTING_LEVEL)
- max_nesting = MAX_NESTING_LEVEL;
- else if (max_nesting < 0)
- max_nesting = DEFAULT_NESTING_LEVEL;
-
- scan_type = GIT_REFERENCE_SYMBOLIC;
-
- if ((error = reference_normalize_for_repo(scan_name, repo, name, true)) < 0)
- return error;
+ GIT_ASSERT_ARG(ref_out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
- if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
+ if ((error = reference_normalize_for_repo(normalized, repo, name, true)) < 0 ||
+ (error = git_repository_refdb__weakptr(&refdb, repo)) < 0 ||
+ (error = git_refdb_resolve(ref_out, refdb, normalized, max_nesting)) < 0)
return error;
- for (nesting = max_nesting;
- nesting >= 0 && scan_type == GIT_REFERENCE_SYMBOLIC;
- nesting--)
- {
- if (nesting != max_nesting) {
- strncpy(scan_name, ref->target.symbolic, sizeof(scan_name));
- git_reference_free(ref);
- }
-
- if ((error = git_refdb_lookup(&ref, refdb, scan_name)) < 0)
- return error;
-
- scan_type = ref->type;
- }
-
- if (scan_type != GIT_REFERENCE_DIRECT && max_nesting != 0) {
- git_error_set(GIT_ERROR_REFERENCE,
- "cannot resolve reference (>%u levels deep)", max_nesting);
- git_reference_free(ref);
- return -1;
+ /*
+ * The resolved reference may be a symbolic reference in case its
+ * target doesn't exist. If the user asked us to resolve (e.g.
+ * `max_nesting != 0`), then we need to return an error in case we got
+ * a symbolic reference back.
+ */
+ if (max_nesting && git_reference_type(*ref_out) == GIT_REFERENCE_SYMBOLIC) {
+ git_reference_free(*ref_out);
+ *ref_out = NULL;
+ return GIT_ENOTFOUND;
}
- *ref_out = ref;
return 0;
}
-int git_reference__read_head(
- git_reference **out,
- git_repository *repo,
- const char *path)
-{
- git_buf reference = GIT_BUF_INIT;
- char *name = NULL;
- int error;
-
- if ((error = git_futils_readbuffer(&reference, path)) < 0)
- goto out;
- git_buf_rtrim(&reference);
-
- if (git__strncmp(reference.ptr, GIT_SYMREF, strlen(GIT_SYMREF)) == 0) {
- git_buf_consume(&reference, reference.ptr + strlen(GIT_SYMREF));
-
- name = git_path_basename(path);
-
- if ((*out = git_reference__alloc_symbolic(name, reference.ptr)) == NULL) {
- error = -1;
- goto out;
- }
- } else {
- if ((error = git_reference_lookup(out, repo, reference.ptr)) < 0)
- goto out;
- }
-
-out:
- git__free(name);
- git_buf_dispose(&reference);
-
- return error;
-}
-
int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname)
{
- int error = 0, i;
+ int error = 0, i, valid;
bool fallbackmode = true, foundvalid = false;
git_reference *ref;
git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
@@ -325,10 +270,11 @@ int git_reference_dwim(git_reference **out, git_repository *repo, const char *re
git_buf_clear(&refnamebuf);
- if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0)
+ if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0 ||
+ (error = git_reference_name_is_valid(&valid, git_buf_cstr(&refnamebuf))) < 0)
goto cleanup;
- if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) {
+ if (!valid) {
error = GIT_EINVALIDSPEC;
continue;
}
@@ -366,25 +312,25 @@ cleanup:
*/
git_reference_t git_reference_type(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG(ref);
return ref->type;
}
const char *git_reference_name(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
return ref->name;
}
git_repository *git_reference_owner(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
return ref->db->repo;
}
const git_oid *git_reference_target(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
if (ref->type != GIT_REFERENCE_DIRECT)
return NULL;
@@ -394,7 +340,7 @@ const git_oid *git_reference_target(const git_reference *ref)
const git_oid *git_reference_target_peel(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
if (ref->type != GIT_REFERENCE_DIRECT || git_oid_is_zero(&ref->peel))
return NULL;
@@ -404,7 +350,7 @@ const git_oid *git_reference_target_peel(const git_reference *ref)
const char *git_reference_symbolic_target(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
if (ref->type != GIT_REFERENCE_SYMBOLIC)
return NULL;
@@ -429,8 +375,9 @@ static int reference__create(
git_reference *ref = NULL;
int error = 0;
- assert(repo && name);
- assert(symbolic || signature);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(symbolic || signature);
if (ref_out)
*ref_out = NULL;
@@ -444,7 +391,7 @@ static int reference__create(
return error;
if (oid != NULL) {
- assert(symbolic == NULL);
+ GIT_ASSERT(symbolic == NULL);
if (!git_object__is_valid(repo, oid, GIT_OBJECT_ANY)) {
git_error_set(GIT_ERROR_REFERENCE,
@@ -480,7 +427,7 @@ static int reference__create(
return 0;
}
-int configured_ident(git_signature **out, const git_repository *repo)
+static int refs_configured_ident(git_signature **out, const git_repository *repo)
{
if (repo->ident_name && repo->ident_email)
return git_signature_now(out, repo->ident_name, repo->ident_email);
@@ -494,7 +441,7 @@ int git_reference__log_signature(git_signature **out, git_repository *repo)
int error;
git_signature *who;
- if(((error = configured_ident(&who, repo)) < 0) &&
+ if(((error = refs_configured_ident(&who, repo)) < 0) &&
((error = git_signature_default(&who, repo)) < 0) &&
((error = git_signature_now(&who, "unknown", "unknown")) < 0))
return error;
@@ -516,7 +463,7 @@ int git_reference_create_matching(
int error;
git_signature *who = NULL;
- assert(id);
+ GIT_ASSERT_ARG(id);
if ((error = git_reference__log_signature(&who, repo)) < 0)
return error;
@@ -551,7 +498,7 @@ int git_reference_symbolic_create_matching(
int error;
git_signature *who = NULL;
- assert(target);
+ GIT_ASSERT_ARG(target);
if ((error = git_reference__log_signature(&who, repo)) < 0)
return error;
@@ -592,7 +539,9 @@ int git_reference_set_target(
int error;
git_repository *repo;
- assert(out && ref && id);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ref);
+ GIT_ASSERT_ARG(id);
repo = ref->db->repo;
@@ -619,7 +568,9 @@ int git_reference_symbolic_set_target(
{
int error;
- assert(out && ref && target);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ref);
+ GIT_ASSERT_ARG(target);
if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0)
return error;
@@ -631,84 +582,33 @@ int git_reference_symbolic_set_target(
typedef struct {
const char *old_name;
git_refname_t new_name;
-} rename_cb_data;
+} refs_update_head_payload;
-static int update_wt_heads(git_repository *repo, const char *path, void *payload)
+static int refs_update_head(git_repository *worktree, void *_payload)
{
- rename_cb_data *data = (rename_cb_data *) payload;
- git_reference *head = NULL;
- char *gitdir = NULL;
+ refs_update_head_payload *payload = (refs_update_head_payload *)_payload;
+ git_reference *head = NULL, *updated = NULL;
int error;
- if ((error = git_reference__read_head(&head, repo, path)) < 0) {
- git_error_set(GIT_ERROR_REFERENCE, "could not read HEAD when renaming references");
- goto out;
- }
-
- if ((gitdir = git_path_dirname(path)) == NULL) {
- error = -1;
+ if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0)
goto out;
- }
if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC ||
- git__strcmp(head->target.symbolic, data->old_name) != 0) {
- error = 0;
+ git__strcmp(git_reference_symbolic_target(head), payload->old_name) != 0)
goto out;
- }
- /* Update HEAD it was pointing to the reference being renamed */
- if ((error = git_repository_create_head(gitdir, data->new_name)) < 0) {
+ /* Update HEAD if it was pointing to the reference being renamed */
+ if ((error = git_reference_symbolic_set_target(&updated, head, payload->new_name, NULL)) < 0) {
git_error_set(GIT_ERROR_REFERENCE, "failed to update HEAD after renaming reference");
goto out;
}
out:
+ git_reference_free(updated);
git_reference_free(head);
- git__free(gitdir);
-
return error;
}
-static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force,
- const git_signature *signature, const char *message)
-{
- git_repository *repo;
- git_refname_t normalized;
- bool should_head_be_updated = false;
- int error = 0;
-
- assert(ref && new_name && signature);
-
- repo = git_reference_owner(ref);
-
- if ((error = reference_normalize_for_repo(
- normalized, repo, new_name, true)) < 0)
- return error;
-
- /* Check if we have to update HEAD. */
- if ((error = git_branch_is_head(ref)) < 0)
- return error;
-
- should_head_be_updated = (error > 0);
-
- if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0)
- return error;
-
- /* Update HEAD if it was pointing to the reference being renamed */
- if (should_head_be_updated) {
- error = git_repository_set_head(ref->db->repo, normalized);
- } else {
- rename_cb_data payload;
- payload.old_name = ref->name;
- memcpy(&payload.new_name, &normalized, sizeof(normalized));
-
- error = git_repository_foreach_head(repo, update_wt_heads, 0, &payload);
- }
-
- return error;
-}
-
-
int git_reference_rename(
git_reference **out,
git_reference *ref,
@@ -716,17 +616,29 @@ int git_reference_rename(
int force,
const char *log_message)
{
- git_signature *who;
+ refs_update_head_payload payload;
+ git_signature *signature = NULL;
+ git_repository *repo;
int error;
- assert(out && ref);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ref);
- if ((error = git_reference__log_signature(&who, ref->db->repo)) < 0)
- return error;
+ repo = git_reference_owner(ref);
- error = reference__rename(out, ref, new_name, force, who, log_message);
- git_signature_free(who);
+ if ((error = git_reference__log_signature(&signature, repo)) < 0 ||
+ (error = reference_normalize_for_repo(payload.new_name, repo, new_name, true)) < 0 ||
+ (error = git_refdb_rename(out, ref->db, ref->name, payload.new_name, force, signature, log_message)) < 0)
+ goto out;
+ payload.old_name = ref->name;
+
+ /* We may have to update any HEAD that was pointing to the renamed reference. */
+ if ((error = git_repository_foreach_worktree(repo, refs_update_head, &payload)) < 0)
+ goto out;
+
+out:
+ git_signature_free(signature);
return error;
}
@@ -876,7 +788,8 @@ int git_reference_list(
{
git_vector ref_list;
- assert(array && repo);
+ GIT_ASSERT_ARG(array);
+ GIT_ASSERT_ARG(repo);
array->strings = NULL;
array->count = 0;
@@ -960,7 +873,8 @@ static bool is_all_caps_and_underscore(const char *name, size_t len)
size_t i;
char c;
- assert(name && len > 0);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(len > 0);
for (i = 0; i < len; i++)
{
@@ -991,7 +905,7 @@ int git_reference__normalize_name(
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
#endif
- assert(name);
+ GIT_ASSERT_ARG(name);
process_flags = flags;
current = (char *)name;
@@ -1123,7 +1037,8 @@ int git_reference_normalize_name(
goto cleanup;
}
- git_buf_copy_cstr(buffer_out, buffer_size, &buf);
+ if ((error = git_buf_copy_cstr(buffer_out, buffer_size, &buf)) < 0)
+ goto cleanup;
error = 0;
@@ -1139,7 +1054,9 @@ int git_reference_cmp(
const git_reference *ref2)
{
git_reference_t type1, type2;
- assert(ref1 && ref2);
+
+ GIT_ASSERT_ARG(ref1);
+ GIT_ASSERT_ARG(ref2);
type1 = git_reference_type(ref1);
type2 = git_reference_type(ref2);
@@ -1154,40 +1071,6 @@ int git_reference_cmp(
return git_oid__cmp(&ref1->target.oid, &ref2->target.oid);
}
-/**
- * Get the end of a chain of references. If the final one is not
- * found, we return the reference just before that.
- */
-static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting)
-{
- git_reference *ref;
- int error = 0;
-
- if (nesting > MAX_NESTING_LEVEL) {
- git_error_set(GIT_ERROR_REFERENCE, "reference chain too deep (%d)", nesting);
- return GIT_ENOTFOUND;
- }
-
- /* set to NULL to let the caller know that they're at the end of the chain */
- if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) {
- *out = NULL;
- return error;
- }
-
- if (git_reference_type(ref) == GIT_REFERENCE_DIRECT) {
- *out = ref;
- error = 0;
- } else {
- error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1);
- if (error == GIT_ENOTFOUND && !*out)
- *out = ref;
- else
- git_reference_free(ref);
- }
-
- return error;
-}
-
/*
* Starting with the reference given by `ref_name`, follows symbolic
* references until a direct reference is found and updated the OID
@@ -1202,31 +1085,37 @@ int git_reference__update_terminal(
{
git_reference *ref = NULL, *ref2 = NULL;
git_signature *who = NULL;
+ git_refdb *refdb = NULL;
const git_signature *to_use;
int error = 0;
if (!sig && (error = git_reference__log_signature(&who, repo)) < 0)
- return error;
+ goto out;
to_use = sig ? sig : who;
- error = get_terminal(&ref, repo, ref_name, 0);
- /* found a dangling symref */
- if (error == GIT_ENOTFOUND && ref) {
- assert(git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC);
- git_error_clear();
+ if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
+ goto out;
+
+ if ((error = git_refdb_resolve(&ref, refdb, ref_name, -1)) < 0) {
+ if (error == GIT_ENOTFOUND) {
+ git_error_clear();
+ error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
+ log_message, NULL, NULL);
+ }
+ goto out;
+ }
+
+ /* In case the resolved reference is symbolic, then it's a dangling symref. */
+ if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use,
log_message, NULL, NULL);
- } else if (error == GIT_ENOTFOUND) {
- git_error_clear();
- error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
- log_message, NULL, NULL);
- } else if (error == 0) {
- assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT);
+ } else {
error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use,
log_message, &ref->target.oid, NULL);
}
+out:
git_reference_free(ref2);
git_reference_free(ref);
git_signature_free(who);
@@ -1290,7 +1179,8 @@ int git_reference_has_log(git_repository *repo, const char *refname)
int error;
git_refdb *refdb;
- assert(repo && refname);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(refname);
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
return error;
@@ -1303,7 +1193,8 @@ int git_reference_ensure_log(git_repository *repo, const char *refname)
int error;
git_refdb *refdb;
- assert(repo && refname);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(refname);
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
return error;
@@ -1318,7 +1209,7 @@ int git_reference__is_branch(const char *ref_name)
int git_reference_is_branch(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG(ref);
return git_reference__is_branch(ref->name);
}
@@ -1329,7 +1220,7 @@ int git_reference__is_remote(const char *ref_name)
int git_reference_is_remote(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG(ref);
return git_reference__is_remote(ref->name);
}
@@ -1340,7 +1231,7 @@ int git_reference__is_tag(const char *ref_name)
int git_reference_is_tag(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG(ref);
return git_reference__is_tag(ref->name);
}
@@ -1351,7 +1242,7 @@ int git_reference__is_note(const char *ref_name)
int git_reference_is_note(const git_reference *ref)
{
- assert(ref);
+ GIT_ASSERT_ARG(ref);
return git_reference__is_note(ref->name);
}
@@ -1373,7 +1264,7 @@ int git_reference_peel(
git_object *target = NULL;
int error;
- assert(ref);
+ GIT_ASSERT_ARG(ref);
if (ref->type == GIT_REFERENCE_DIRECT) {
resolved = ref;
@@ -1415,19 +1306,30 @@ cleanup:
return error;
}
-int git_reference__is_valid_name(const char *refname, unsigned int flags)
+int git_reference__name_is_valid(
+ int *valid,
+ const char *refname,
+ unsigned int flags)
{
- if (git_reference__normalize_name(NULL, refname, flags) < 0) {
- git_error_clear();
- return false;
- }
+ int error;
- return true;
+ GIT_ASSERT(valid && refname);
+
+ *valid = 0;
+
+ error = git_reference__normalize_name(NULL, refname, flags);
+
+ if (!error)
+ *valid = 1;
+ else if (error == GIT_EINVALIDSPEC)
+ error = 0;
+
+ return error;
}
-int git_reference_is_valid_name(const char *refname)
+int git_reference_name_is_valid(int *valid, const char *refname)
{
- return git_reference__is_valid_name(refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
+ return git_reference__name_is_valid(valid, refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
}
const char *git_reference__shorthand(const char *name)
@@ -1441,7 +1343,7 @@ const char *git_reference__shorthand(const char *name)
else if (!git__prefixcmp(name, GIT_REFS_DIR))
return name + strlen(GIT_REFS_DIR);
- /* No shorthands are avaiable, so just return the name */
+ /* No shorthands are available, so just return the name. */
return name;
}
@@ -1454,7 +1356,10 @@ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_re
{
int error;
git_reference *tmp_ref;
- assert(unborn && ref && repo);
+
+ GIT_ASSERT_ARG(unborn);
+ GIT_ASSERT_ARG(ref);
+ GIT_ASSERT_ARG(repo);
if (ref->type == GIT_REFERENCE_DIRECT) {
*unborn = 0;
@@ -1473,3 +1378,18 @@ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_re
return 0;
}
+
+/* Deprecated functions */
+
+#ifndef GIT_DEPRECATE_HARD
+
+int git_reference_is_valid_name(const char *refname)
+{
+ int valid = 0;
+
+ git_reference__name_is_valid(&valid, refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
+
+ return valid;
+}
+
+#endif
diff --git a/src/refs.h b/src/refs.h
index adc345a..376a512 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -45,7 +45,6 @@ extern bool git_reference__enable_symbolic_ref_target_validation;
#define GIT_REBASE_APPLY_DIR "rebase-apply/"
#define GIT_REBASE_APPLY_REBASING_FILE GIT_REBASE_APPLY_DIR "rebasing"
#define GIT_REBASE_APPLY_APPLYING_FILE GIT_REBASE_APPLY_DIR "applying"
-#define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master"
#define GIT_SEQUENCER_DIR "sequencer/"
#define GIT_SEQUENCER_HEAD_FILE GIT_SEQUENCER_DIR "head"
@@ -86,10 +85,11 @@ git_reference *git_reference__realloc(git_reference **ptr_to_ref, const char *na
int git_reference__normalize_name(git_buf *buf, const char *name, unsigned int flags);
int git_reference__update_terminal(git_repository *repo, const char *ref_name, const git_oid *oid, const git_signature *sig, const char *log_message);
-int git_reference__is_valid_name(const char *refname, unsigned int flags);
+int git_reference__name_is_valid(int *valid, const char *name, unsigned int flags);
int git_reference__is_branch(const char *ref_name);
int git_reference__is_remote(const char *ref_name);
int git_reference__is_tag(const char *ref_name);
+int git_reference__is_note(const char *ref_name);
const char *git_reference__shorthand(const char *name);
/**
@@ -115,24 +115,6 @@ int git_reference_lookup_resolved(
const char *name,
int max_deref);
-/**
- * Read reference from a file.
- *
- * This function will read in the file at `path`. If it is a
- * symref, it will return a new unresolved symbolic reference
- * with the given name pointing to the reference pointed to by
- * the file. If it is not a symbolic reference, it will return
- * the resolved reference.
- *
- * Note that because the refdb is not involved for symbolic references, they
- * won't be owned, hence you should either not make the returned reference
- * 'externally visible', or perform the lookup before returning it to the user.
- */
-int git_reference__read_head(
- git_reference **out,
- git_repository *repo,
- const char *path);
-
int git_reference__log_signature(git_signature **out, git_repository *repo);
/** Update a reference after a commit. */
diff --git a/src/refspec.c b/src/refspec.c
index 854240a..d0be29b 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -21,9 +21,11 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
size_t llen;
int is_glob = 0;
const char *lhs, *rhs;
- int flags;
+ int valid = 0;
+ unsigned int flags;
- assert(refspec && input);
+ GIT_ASSERT_ARG(refspec);
+ GIT_ASSERT_ARG(input);
memset(refspec, 0x0, sizeof(git_refspec));
refspec->push = !is_fetch;
@@ -75,57 +77,69 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
if (is_fetch) {
/*
- * LHS
- * - empty is allowed; it means HEAD.
- * - otherwise it must be a valid looking ref.
- */
+ * LHS
+ * - empty is allowed; it means HEAD.
+ * - otherwise it must be a valid looking ref.
+ */
if (!*refspec->src)
; /* empty is ok */
- else if (!git_reference__is_valid_name(refspec->src, flags))
+ else if (git_reference__name_is_valid(&valid, refspec->src, flags) < 0)
+ goto on_error;
+ else if (!valid)
goto invalid;
+
/*
- * RHS
- * - missing is ok, and is same as empty.
- * - empty is ok; it means not to store.
- * - otherwise it must be a valid looking ref.
- */
+ * RHS
+ * - missing is ok, and is same as empty.
+ * - empty is ok; it means not to store.
+ * - otherwise it must be a valid looking ref.
+ */
if (!refspec->dst)
; /* ok */
else if (!*refspec->dst)
; /* ok */
- else if (!git_reference__is_valid_name(refspec->dst, flags))
+ else if (git_reference__name_is_valid(&valid, refspec->dst, flags) < 0)
+ goto on_error;
+ else if (!valid)
goto invalid;
} else {
/*
- * LHS
- * - empty is allowed; it means delete.
- * - when wildcarded, it must be a valid looking ref.
- * - otherwise, it must be an extended SHA-1, but
- * there is no existing way to validate this.
- */
+ * LHS
+ * - empty is allowed; it means delete.
+ * - when wildcarded, it must be a valid looking ref.
+ * - otherwise, it must be an extended SHA-1, but
+ * there is no existing way to validate this.
+ */
if (!*refspec->src)
; /* empty is ok */
else if (is_glob) {
- if (!git_reference__is_valid_name(refspec->src, flags))
+ if (git_reference__name_is_valid(&valid, refspec->src, flags) < 0)
+ goto on_error;
+ else if (!valid)
goto invalid;
}
else {
; /* anything goes, for now */
}
+
/*
- * RHS
- * - missing is allowed, but LHS then must be a
- * valid looking ref.
- * - empty is not allowed.
- * - otherwise it must be a valid looking ref.
- */
+ * RHS
+ * - missing is allowed, but LHS then must be a
+ * valid looking ref.
+ * - empty is not allowed.
+ * - otherwise it must be a valid looking ref.
+ */
if (!refspec->dst) {
- if (!git_reference__is_valid_name(refspec->src, flags))
+ if (git_reference__name_is_valid(&valid, refspec->src, flags) < 0)
+ goto on_error;
+ else if (!valid)
goto invalid;
} else if (!*refspec->dst) {
goto invalid;
} else {
- if (!git_reference__is_valid_name(refspec->dst, flags))
+ if (git_reference__name_is_valid(&valid, refspec->dst, flags) < 0)
+ goto on_error;
+ else if (!valid)
goto invalid;
}
@@ -141,11 +155,14 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
return 0;
- invalid:
- git_error_set(
- GIT_ERROR_INVALID,
- "'%s' is not a valid refspec.", input);
- git_refspec__dispose(refspec);
+invalid:
+ git_error_set(GIT_ERROR_INVALID,
+ "'%s' is not a valid refspec.", input);
+ git_refspec__dispose(refspec);
+ return GIT_EINVALIDSPEC;
+
+on_error:
+ git_refspec__dispose(refspec);
return -1;
}
@@ -164,7 +181,8 @@ void git_refspec__dispose(git_refspec *refspec)
int git_refspec_parse(git_refspec **out_refspec, const char *input, int is_fetch)
{
git_refspec *refspec;
- assert(out_refspec && input);
+ GIT_ASSERT_ARG(out_refspec);
+ GIT_ASSERT_ARG(input);
*out_refspec = NULL;
@@ -203,7 +221,7 @@ const char *git_refspec_string(const git_refspec *refspec)
int git_refspec_force(const git_refspec *refspec)
{
- assert(refspec);
+ GIT_ASSERT_ARG(refspec);
return refspec->force;
}
@@ -229,8 +247,11 @@ static int refspec_transform(
{
const char *from_star, *to_star;
size_t replacement_len, star_offset;
+ int error;
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
- git_buf_sanitize(out);
git_buf_clear(out);
/*
@@ -242,7 +263,7 @@ static int refspec_transform(
from_star = strchr(from, '*');
to_star = strchr(to, '*');
- assert(from_star && to_star);
+ GIT_ASSERT(from_star && to_star);
/* star offset, both in 'from' and in 'name' */
star_offset = from_star - from;
@@ -262,8 +283,14 @@ static int refspec_transform(
int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name)
{
- assert(out && spec && name);
- git_buf_sanitize(out);
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(spec);
+ GIT_ASSERT_ARG(name);
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
if (!git_refspec_src_matches(spec, name)) {
git_error_set(GIT_ERROR_INVALID, "ref '%s' doesn't match the source", name);
@@ -278,8 +305,14 @@ int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *nam
int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name)
{
- assert(out && spec && name);
- git_buf_sanitize(out);
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(spec);
+ GIT_ASSERT_ARG(name);
+
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
if (!git_refspec_dst_matches(spec, name)) {
git_error_set(GIT_ERROR_INVALID, "ref '%s' doesn't match the destination", name);
@@ -306,14 +339,15 @@ int git_refspec__serialize(git_buf *out, const git_refspec *refspec)
int git_refspec_is_wildcard(const git_refspec *spec)
{
- assert(spec && spec->src);
+ GIT_ASSERT_ARG(spec);
+ GIT_ASSERT_ARG(spec->src);
return (spec->src[strlen(spec->src) - 1] == '*');
}
git_direction git_refspec_direction(const git_refspec *spec)
{
- assert(spec);
+ GIT_ASSERT_ARG(spec);
return spec->push;
}
@@ -332,7 +366,9 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
NULL
};
- assert(out && spec && refs);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(spec);
+ GIT_ASSERT_ARG(refs);
cur = git__calloc(1, sizeof(git_refspec));
GIT_ERROR_CHECK_ALLOC(cur);
diff --git a/src/regexp.c b/src/regexp.c
index 5fe49f3..c1b9ef4 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -12,7 +12,7 @@
int git_regexp_compile(git_regexp *r, const char *pattern, int flags)
{
int erroffset, cflags = 0;
- const char *error;
+ const char *error = NULL;
if (flags & GIT_REGEXP_ICASE)
cflags |= PCRE_CASELESS;
@@ -41,7 +41,7 @@ int git_regexp_match(const git_regexp *r, const char *string)
int git_regexp_search(const git_regexp *r, const char *string, size_t nmatches, git_regmatch *matches)
{
- int static_ovec[9], *ovec;
+ int static_ovec[9] = {0}, *ovec;
int error;
size_t i;
diff --git a/src/remote.c b/src/remote.c
index 740dd94..ec68cc0 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -82,9 +82,11 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
static int ensure_remote_name_is_valid(const char *name)
{
- int error = 0;
+ int valid, error;
+
+ error = git_remote_name_is_valid(&valid, name);
- if (!git_remote_is_valid_name(name)) {
+ if (!error && !valid) {
git_error_set(
GIT_ERROR_CONFIG,
"'%s' is not a valid remote name.", name ? name : "(null)");
@@ -110,12 +112,8 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
if ((error = ensure_remote_name_is_valid(name)) < 0)
return error;
- if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0) {
- if (git_error_last()->klass != GIT_ERROR_NOMEMORY)
- error = GIT_EINVALIDSPEC;
-
+ if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0)
return error;
- }
git_refspec__dispose(&spec);
@@ -123,7 +121,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
return error;
/*
- * "$^" is a unmatcheable regexp: it will not match anything at all, so
+ * "$^" is an unmatchable regexp: it will not match anything at all, so
* all values will be considered new and we will not replace any
* present value.
*/
@@ -195,10 +193,12 @@ int git_remote_create_options_init(git_remote_create_options *opts, unsigned int
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_remote_create_init_options(git_remote_create_options *opts, unsigned int version)
{
return git_remote_create_options_init(opts, version);
}
+#endif
int git_remote_create_with_opts(git_remote **out, const char *url, const git_remote_create_options *opts)
{
@@ -210,7 +210,8 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
int error = -1;
- assert(out && url);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(url);
if (!opts) {
opts = &dummy_opts;
@@ -459,7 +460,9 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
struct refspec_cb_data data = { NULL };
bool optional_setting_found = false, found;
- assert(out && repo && name);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
if ((error = ensure_remote_name_is_valid(name)) < 0)
return error;
@@ -581,19 +584,19 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
const char *git_remote_name(const git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
return remote->name;
}
git_repository *git_remote_owner(const git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
return remote->repo;
}
const char *git_remote_url(const git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
return remote->url;
}
@@ -603,7 +606,8 @@ static int set_url(git_repository *repo, const char *remote, const char *pattern
git_buf buf = GIT_BUF_INIT, canonical_url = GIT_BUF_INIT;
int error;
- assert(repo && remote);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(remote);
if ((error = ensure_remote_name_is_valid(remote)) < 0)
return error;
@@ -637,7 +641,7 @@ int git_remote_set_url(git_repository *repo, const char *remote, const char *url
const char *git_remote_pushurl(const git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
return remote->pushurl;
}
@@ -648,14 +652,17 @@ int git_remote_set_pushurl(git_repository *repo, const char *remote, const char*
static int resolve_url(git_buf *resolved_url, const char *url, int direction, const git_remote_callbacks *callbacks)
{
- int status;
+ int status, error;
if (callbacks && callbacks->resolve_url) {
git_buf_clear(resolved_url);
status = callbacks->resolve_url(resolved_url, url, direction, callbacks->payload);
if (status != GIT_PASSTHROUGH) {
git_error_set_after_callback_function(status, "git_resolve_url_cb");
- git_buf_sanitize(resolved_url);
+
+ if ((error = git_buf_sanitize(resolved_url)) < 0)
+ return error;
+
return status;
}
}
@@ -667,8 +674,8 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
{
const char *url = NULL;
- assert(remote);
- assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
+ GIT_ASSERT_ARG(remote);
+ GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
if (direction == GIT_DIRECTION_FETCH) {
url = remote->url;
@@ -686,7 +693,7 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
return resolve_url(url_out, url, direction, callbacks);
}
-int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs)
+static int remote_transport_set_callbacks(git_transport *t, const git_remote_callbacks *cbs)
{
if (!t->set_callbacks || !cbs)
return 0;
@@ -713,7 +720,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
git_credential_acquire_cb credentials = NULL;
git_transport_cb transport = NULL;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (callbacks) {
GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
@@ -744,7 +751,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
if ((error = set_transport_custom_headers(t, conn->custom_headers)) != 0)
goto on_error;
- if ((error = set_transport_callbacks(t, callbacks)) < 0 ||
+ if ((error = remote_transport_set_callbacks(t, callbacks)) < 0 ||
(error = t->connect(t, url.ptr, credentials, payload, conn->proxy, direction, flags)) != 0)
goto on_error;
@@ -778,7 +785,7 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (!remote->transport) {
git_error_set(GIT_ERROR_NET, "this remote has never connected");
@@ -795,7 +802,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
git_buf val = GIT_BUF_INIT;
int error;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (!proxy_url || !remote->repo)
return -1;
@@ -924,7 +931,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
const git_strarray *custom_headers = NULL;
const git_proxy_options *proxy = NULL;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (!remote->repo) {
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
@@ -1063,7 +1070,8 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
unsigned int i;
git_remote_head *remote_ref;
- assert(update_heads && fetchspec_src);
+ GIT_ASSERT_ARG(update_heads);
+ GIT_ASSERT_ARG(fetchspec_src);
*out = NULL;
@@ -1117,7 +1125,9 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
const char *ref_name;
int error = 0, update;
- assert(out && spec && ref);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(spec);
+ GIT_ASSERT_ARG(ref);
*out = NULL;
@@ -1131,6 +1141,16 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
ref_name = git_reference_name(resolved_ref);
}
+ /*
+ * The ref name may be unresolvable - perhaps it's pointing to
+ * something invalid. In this case, there is no remote head for
+ * this ref.
+ */
+ if (!ref_name) {
+ error = 0;
+ goto cleanup;
+ }
+
if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0)
goto cleanup;
@@ -1154,7 +1174,7 @@ static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git
unsigned int i = 0;
int error = 0;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
/* no heads, nothing to do */
if (update_heads->length == 0)
@@ -1237,7 +1257,7 @@ static int prune_candidates(git_vector *candidates, git_remote *remote)
}
out:
- git_strarray_free(&arr);
+ git_strarray_dispose(&arr);
return error;
}
@@ -1297,7 +1317,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
if (error == GIT_ENOTFOUND)
continue;
- /* if we did find a source, remove it from the candiates */
+ /* If we did find a source, remove it from the candidates. */
if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0)
goto cleanup;
@@ -1360,7 +1380,7 @@ static int update_tips_for_spec(
git_vector *refs,
const char *log_message)
{
- int error = 0, autotag;
+ int error = 0, autotag, valid;
unsigned int i = 0;
git_buf refname = GIT_BUF_INIT;
git_oid old;
@@ -1370,7 +1390,7 @@ static int update_tips_for_spec(
git_refspec tagspec;
git_vector update_heads;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (git_repository_odb__weakptr(&odb, remote->repo) < 0)
return -1;
@@ -1388,7 +1408,10 @@ static int update_tips_for_spec(
git_buf_clear(&refname);
/* Ignore malformed ref names (which also saves us from tag^{} */
- if (!git_reference_is_valid_name(head->name))
+ if (git_reference_name_is_valid(&valid, head->name) < 0)
+ goto on_error;
+
+ if (!valid)
continue;
/* If we have a tag, see if the auto-follow rules say to update it */
@@ -1437,6 +1460,11 @@ static int update_tips_for_spec(
if (error < 0 && error != GIT_ENOTFOUND)
goto on_error;
+ if (!(error || error == GIT_ENOTFOUND)
+ && !spec->force
+ && !git_graph_descendant_of(remote->repo, &head->oid, &old))
+ continue;
+
if (error == GIT_ENOTFOUND) {
memset(&old, 0, GIT_OID_RAWSZ);
@@ -1497,6 +1525,7 @@ static int next_head(const git_remote *remote, git_vector *refs,
git_remote_head *head;
git_refspec *spec, *passive_spec;
size_t i, j, k;
+ int valid;
active = &remote->active_refspecs;
passive = &remote->passive_refspecs;
@@ -1508,7 +1537,10 @@ static int next_head(const git_remote *remote, git_vector *refs,
for (; i < refs->length; i++) {
head = git_vector_get(refs, i);
- if (!git_reference_is_valid_name(head->name))
+ if (git_reference_name_is_valid(&valid, head->name) < 0)
+ return -1;
+
+ if (!valid)
continue;
for (; j < active->length; j++) {
@@ -1655,7 +1687,7 @@ int git_remote_update_tips(
goto out;
}
- /* only try to do opportunisitic updates if the refpec lists differ */
+ /* Only try to do opportunistic updates if the refpec lists differ. */
if (remote->passed_refspecs)
error = opportunistic_updates(remote, callbacks, &refs, reflog_message);
@@ -1667,7 +1699,7 @@ out:
int git_remote_connected(const git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (!remote->transport || !remote->transport->is_connected)
return 0;
@@ -1678,7 +1710,7 @@ int git_remote_connected(const git_remote *remote)
int git_remote_stop(git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (remote->transport && remote->transport->cancel)
remote->transport->cancel(remote->transport);
@@ -1688,7 +1720,7 @@ int git_remote_stop(git_remote *remote)
int git_remote_disconnect(git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (git_remote_connected(remote))
remote->transport->close(remote->transport);
@@ -1774,7 +1806,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
const git_indexer_progress *git_remote_stats(git_remote *remote)
{
- assert(remote);
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
return &remote->stats;
}
@@ -1789,7 +1821,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
git_config *config;
int error;
- assert(repo && remote);
+ GIT_ASSERT_ARG(repo && remote);
if ((error = ensure_remote_name_is_valid(remote)) < 0)
return error;
@@ -2053,7 +2085,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name,
git_vector problem_refspecs = GIT_VECTOR_INIT;
git_remote *remote = NULL;
- assert(out && repo && name && new_name);
+ GIT_ASSERT_ARG(out && repo && name && new_name);
if ((error = git_remote_lookup(&remote, repo, name)) < 0)
return error;
@@ -2087,24 +2119,34 @@ cleanup:
return error;
}
-int git_remote_is_valid_name(
- const char *remote_name)
+int git_remote_name_is_valid(int *valid, const char *remote_name)
{
git_buf buf = GIT_BUF_INIT;
- git_refspec refspec;
- int error = -1;
+ git_refspec refspec = {0};
+ int error;
+
+ GIT_ASSERT(valid);
+
+ *valid = 0;
if (!remote_name || *remote_name == '\0')
return 0;
- git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name);
+ if ((error = git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)) < 0)
+ goto done;
+
error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true);
+ if (!error)
+ *valid = 1;
+ else if (error == GIT_EINVALIDSPEC)
+ error = 0;
+
+done:
git_buf_dispose(&buf);
git_refspec__dispose(&refspec);
- git_error_clear();
- return error == 0;
+ return error;
}
git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname)
@@ -2219,7 +2261,7 @@ static const char *name_offset(size_t *len_out, const char *name)
prefix_len = strlen("remote.");
dot = strchr(name + prefix_len, '.');
- assert(dot);
+ GIT_ASSERT_ARG_WITH_RETVAL(dot, NULL);
*len_out = dot - name - prefix_len;
return name + prefix_len;
@@ -2249,10 +2291,13 @@ static int remove_branch_config_related_entries(
if (strcmp(remote_name, entry->value))
continue;
- branch = name_offset(&branch_len, entry->name);
+ if ((branch = name_offset(&branch_len, entry->name)) == NULL) {
+ error = -1;
+ break;
+ }
git_buf_clear(&buf);
- if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
+ if ((error = git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch)) < 0)
break;
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
@@ -2262,7 +2307,7 @@ static int remove_branch_config_related_entries(
}
git_buf_clear(&buf);
- if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
+ if ((error = git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch)) < 0)
break;
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
@@ -2357,7 +2402,8 @@ int git_remote_delete(git_repository *repo, const char *name)
{
int error;
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
if ((error = remove_branch_config_related_entries(repo, name)) < 0 ||
(error = remove_remote_tracking(repo, name)) < 0 ||
@@ -2373,29 +2419,37 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
const git_remote_head *guess = NULL;
const git_oid *head_id;
size_t heads_len, i;
+ git_buf local_default = GIT_BUF_INIT;
int error;
- assert(out);
+ GIT_ASSERT_ARG(out);
if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
- return error;
+ goto done;
- if (heads_len == 0)
- return GIT_ENOTFOUND;
+ if (heads_len == 0 || strcmp(heads[0]->name, GIT_HEAD_FILE)) {
+ error = GIT_ENOTFOUND;
+ goto done;
+ }
- if (strcmp(heads[0]->name, GIT_HEAD_FILE))
- return GIT_ENOTFOUND;
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
- git_buf_sanitize(out);
/* the first one must be HEAD so if that has the symref info, we're done */
- if (heads[0]->symref_target)
- return git_buf_puts(out, heads[0]->symref_target);
+ if (heads[0]->symref_target) {
+ error = git_buf_puts(out, heads[0]->symref_target);
+ goto done;
+ }
/*
* If there's no symref information, we have to look over them
- * and guess. We return the first match unless the master
- * branch is a candidate. Then we return the master branch.
+ * and guess. We return the first match unless the default
+ * branch is a candidate. Then we return the default branch.
*/
+
+ if ((error = git_repository_initialbranch(&local_default, remote->repo)) < 0)
+ goto done;
+
head_id = &heads[0]->oid;
for (i = 1; i < heads_len; i++) {
@@ -2410,16 +2464,22 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
continue;
}
- if (!git__strcmp(GIT_REFS_HEADS_MASTER_FILE, heads[i]->name)) {
+ if (!git__strcmp(local_default.ptr, heads[i]->name)) {
guess = heads[i];
break;
}
}
- if (!guess)
- return GIT_ENOTFOUND;
+ if (!guess) {
+ error = GIT_ENOTFOUND;
+ goto done;
+ }
+
+ error = git_buf_puts(out, guess->name);
- return git_buf_puts(out, guess->name);
+done:
+ git_buf_dispose(&local_default);
+ return error;
}
int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts)
@@ -2431,7 +2491,7 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
const git_remote_callbacks *cbs = NULL;
git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (!remote->repo) {
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
@@ -2497,7 +2557,7 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
const git_strarray *custom_headers = NULL;
const git_proxy_options *proxy = NULL;
- assert(remote);
+ GIT_ASSERT_ARG(remote);
if (!remote->repo) {
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
@@ -2512,8 +2572,6 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
proxy = &opts->proxy_opts;
}
- assert(remote);
-
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
return error;
@@ -2540,9 +2598,9 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
git_config_entry *entry;
git_config_iterator *iter;
- assert(config);
- assert(url);
- assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
+ GIT_ASSERT_ARG_WITH_RETVAL(config, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(url, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH, NULL);
/* Add 1 to prefix/suffix length due to the additional escaped dot */
prefix_length = strlen(PREFIX) + 1;
@@ -2590,3 +2648,17 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
return result.ptr;
}
+
+/* Deprecated functions */
+
+#ifndef GIT_DEPRECATE_HARD
+
+int git_remote_is_valid_name(const char *remote_name)
+{
+ int valid = 0;
+
+ git_remote_name_is_valid(&valid, remote_name);
+ return valid;
+}
+
+#endif
diff --git a/src/repository.c b/src/repository.c
index 2469e13..9ed46bf 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -62,16 +62,18 @@ static const struct {
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "worktrees", true }
};
-static int check_repositoryformatversion(git_config *config);
+static int check_repositoryformatversion(int *version, git_config *config);
+static int check_extensions(git_config *config, int version);
#define GIT_COMMONDIR_FILE "commondir"
#define GIT_GITDIR_FILE "gitdir"
#define GIT_FILE_CONTENT_PREFIX "gitdir:"
-#define GIT_BRANCH_MASTER "master"
+#define GIT_BRANCH_DEFAULT "master"
#define GIT_REPO_VERSION 0
+#define GIT_REPO_MAX_VERSION 1
git_buf git_repository__reserved_names_win32[] = {
{ DOT_GIT, 0, CONST_STRLEN(DOT_GIT) },
@@ -91,7 +93,7 @@ static void set_odb(git_repository *repo, git_odb *odb)
GIT_REFCOUNT_INC(odb);
}
- if ((odb = git__swap(repo->_odb, odb)) != NULL) {
+ if ((odb = git_atomic_swap(repo->_odb, odb)) != NULL) {
GIT_REFCOUNT_OWN(odb, NULL);
git_odb_free(odb);
}
@@ -104,7 +106,7 @@ static void set_refdb(git_repository *repo, git_refdb *refdb)
GIT_REFCOUNT_INC(refdb);
}
- if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) {
+ if ((refdb = git_atomic_swap(repo->_refdb, refdb)) != NULL) {
GIT_REFCOUNT_OWN(refdb, NULL);
git_refdb_free(refdb);
}
@@ -117,7 +119,7 @@ static void set_config(git_repository *repo, git_config *config)
GIT_REFCOUNT_INC(config);
}
- if ((config = git__swap(repo->_config, config)) != NULL) {
+ if ((config = git_atomic_swap(repo->_config, config)) != NULL) {
GIT_REFCOUNT_OWN(config, NULL);
git_config_free(config);
}
@@ -132,7 +134,7 @@ static void set_index(git_repository *repo, git_index *index)
GIT_REFCOUNT_INC(index);
}
- if ((index = git__swap(repo->_index, index)) != NULL) {
+ if ((index = git_atomic_swap(repo->_index, index)) != NULL) {
GIT_REFCOUNT_OWN(index, NULL);
git_index_free(index);
}
@@ -140,7 +142,7 @@ static void set_index(git_repository *repo, git_index *index)
int git_repository__cleanup(git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
git_repository_submodule_cache_clear(repo);
git_cache_clear(&repo->objects);
@@ -184,49 +186,96 @@ void git_repository_free(git_repository *repo)
git__free(repo);
}
+/* Check if we have a separate commondir (e.g. we have a worktree) */
+static int lookup_commondir(bool *separate, git_buf *commondir, git_buf *repository_path)
+{
+ git_buf common_link = GIT_BUF_INIT;
+ int error;
+
+ /*
+ * If there's no commondir file, the repository path is the
+ * common path, but it needs a trailing slash.
+ */
+ if (!git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
+ if ((error = git_buf_set(commondir, repository_path->ptr, repository_path->size)) == 0)
+ error = git_path_to_dir(commondir);
+
+ *separate = false;
+ goto done;
+ }
+
+ *separate = true;
+
+ if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
+ (error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
+ goto done;
+
+ git_buf_rtrim(&common_link);
+ if (git_path_is_relative(common_link.ptr)) {
+ if ((error = git_buf_joinpath(commondir, repository_path->ptr, common_link.ptr)) < 0)
+ goto done;
+ } else {
+ git_buf_swap(commondir, &common_link);
+ }
+
+ git_buf_dispose(&common_link);
+
+ /* Make sure the commondir path always has a trailing slash */
+ error = git_path_prettify_dir(commondir, commondir->ptr, NULL);
+
+done:
+ return error;
+}
+
+GIT_INLINE(int) validate_repo_path(git_buf *path)
+{
+ /*
+ * The longest static path in a repository (or commondir) is the
+ * packed refs file. (Loose refs may be longer since they
+ * include the reference name, but will be validated when the
+ * path is constructed.)
+ */
+ static size_t suffix_len =
+ CONST_STRLEN("objects/pack/pack-.pack.lock") +
+ GIT_OID_HEXSZ;
+
+ return git_path_validate_filesystem_with_suffix(
+ path->ptr, path->size, suffix_len);
+}
+
/*
* Git repository open methods
*
* Open a repository object from its path
*/
-static bool valid_repository_path(git_buf *repository_path, git_buf *common_path)
+static int is_valid_repository_path(bool *out, git_buf *repository_path, git_buf *common_path)
{
- /* Check if we have a separate commondir (e.g. we have a
- * worktree) */
- if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
- git_buf common_link = GIT_BUF_INIT;
- git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE);
-
- git_futils_readbuffer(&common_link, common_link.ptr);
- git_buf_rtrim(&common_link);
-
- if (git_path_is_relative(common_link.ptr)) {
- git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr);
- } else {
- git_buf_swap(common_path, &common_link);
- }
+ bool separate_commondir = false;
+ int error;
- git_buf_dispose(&common_link);
- }
- else {
- git_buf_set(common_path, repository_path->ptr, repository_path->size);
- }
+ *out = false;
- /* Make sure the commondir path always has a trailing * slash */
- if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1)
- git_buf_putc(common_path, '/');
+ if ((error = lookup_commondir(&separate_commondir, common_path, repository_path)) < 0)
+ return error;
/* Ensure HEAD file exists */
if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false)
- return false;
+ return 0;
/* Check files in common dir */
if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false)
- return false;
+ return 0;
if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false)
- return false;
+ return 0;
- return true;
+ /* Ensure the repo (and commondir) are valid paths */
+ if ((error = validate_repo_path(common_path)) < 0 ||
+ (separate_commondir &&
+ (error = validate_repo_path(repository_path)) < 0))
+ return error;
+
+ *out = true;
+ return 0;
}
static git_repository *repository_alloc(void)
@@ -358,7 +407,7 @@ static size_t find_ceiling_dir_offset(
const char *ceil, *sep;
size_t len, max_len = 0, min_len;
- assert(path);
+ GIT_ASSERT_ARG(path);
min_len = (size_t)(git_path_root(path) + 1);
@@ -404,7 +453,8 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
git_buf file = GIT_BUF_INIT;
size_t prefix_len = strlen(GIT_FILE_CONTENT_PREFIX);
- assert(path_out && file_path);
+ GIT_ASSERT_ARG(path_out);
+ GIT_ASSERT_ARG(file_path);
if (git_futils_readbuffer(&file, file_path) < 0)
return -1;
@@ -441,15 +491,15 @@ static int find_repo(
uint32_t flags,
const char *ceiling_dirs)
{
- int error;
git_buf path = GIT_BUF_INIT;
git_buf repo_link = GIT_BUF_INIT;
git_buf common_link = GIT_BUF_INIT;
struct stat st;
dev_t initial_device = 0;
int min_iterations;
- bool in_dot_git;
+ bool in_dot_git, is_valid;
size_t ceiling_offset = 0;
+ int error;
git_buf_clear(gitdir_path);
@@ -475,9 +525,8 @@ static int find_repo(
for (;;) {
if (!(flags & GIT_REPOSITORY_OPEN_NO_DOTGIT)) {
if (!in_dot_git) {
- error = git_buf_joinpath(&path, path.ptr, DOT_GIT);
- if (error < 0)
- break;
+ if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
+ goto out;
}
in_dot_git = !in_dot_git;
}
@@ -491,28 +540,33 @@ static int find_repo(
break;
if (S_ISDIR(st.st_mode)) {
- if (valid_repository_path(&path, &common_link)) {
- git_path_to_dir(&path);
- git_buf_set(gitdir_path, path.ptr, path.size);
+ if ((error = is_valid_repository_path(&is_valid, &path, &common_link)) < 0)
+ goto out;
+
+ if (is_valid) {
+ if ((error = git_path_to_dir(&path)) < 0 ||
+ (error = git_buf_set(gitdir_path, path.ptr, path.size)) < 0)
+ goto out;
if (gitlink_path)
- git_buf_attach(gitlink_path,
- git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0);
+ if ((error = git_buf_attach(gitlink_path, git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0)) < 0)
+ goto out;
if (commondir_path)
git_buf_swap(&common_link, commondir_path);
break;
}
- }
- else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) {
- error = read_gitfile(&repo_link, path.ptr);
- if (error < 0)
- break;
- if (valid_repository_path(&repo_link, &common_link)) {
+ } else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) {
+ if ((error = read_gitfile(&repo_link, path.ptr)) < 0 ||
+ (error = is_valid_repository_path(&is_valid, &repo_link, &common_link)) < 0)
+ goto out;
+
+ if (is_valid) {
git_buf_swap(gitdir_path, &repo_link);
if (gitlink_path)
- error = git_buf_put(gitlink_path, path.ptr, path.size);
+ if ((error = git_buf_put(gitlink_path, path.ptr, path.size)) < 0)
+ goto out;
if (commondir_path)
git_buf_swap(&common_link, commondir_path);
}
@@ -523,10 +577,8 @@ static int find_repo(
/* Move up one directory. If we're in_dot_git, we'll search the
* parent itself next. If we're !in_dot_git, we'll search .git
* in the parent directory next (added at the top of the loop). */
- if (git_path_dirname_r(&path, path.ptr) < 0) {
- error = -1;
- break;
- }
+ if ((error = git_path_dirname_r(&path, path.ptr)) < 0)
+ goto out;
/* Once we've checked the directory (and .git if applicable),
* find the ceiling for a search. */
@@ -534,31 +586,28 @@ static int find_repo(
ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
/* Check if we should stop searching here. */
- if (min_iterations == 0
- && (path.ptr[ceiling_offset] == 0
- || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
+ if (min_iterations == 0 &&
+ (path.ptr[ceiling_offset] == 0 || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
break;
}
- if (!error && workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
+ if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
if (!git_buf_len(gitdir_path))
git_buf_clear(workdir_path);
- else {
- git_path_dirname_r(workdir_path, path.ptr);
- git_path_to_dir(workdir_path);
- }
- if (git_buf_oom(workdir_path))
- return -1;
+ else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 ||
+ (error = git_path_to_dir(workdir_path)) < 0)
+ goto out;
}
/* If we didn't find the repository, and we don't have any other error
* to report, report that. */
- if (!git_buf_len(gitdir_path) && !error) {
- git_error_set(GIT_ERROR_REPOSITORY,
- "could not find repository from '%s'", start_path);
+ if (!git_buf_len(gitdir_path)) {
+ git_error_set(GIT_ERROR_REPOSITORY, "could not find repository from '%s'", start_path);
error = GIT_ENOTFOUND;
+ goto out;
}
+out:
git_buf_dispose(&path);
git_buf_dispose(&repo_link);
git_buf_dispose(&common_link);
@@ -569,14 +618,16 @@ int git_repository_open_bare(
git_repository **repo_ptr,
const char *bare_path)
{
- int error;
git_buf path = GIT_BUF_INIT, common_path = GIT_BUF_INIT;
git_repository *repo = NULL;
+ bool is_valid;
+ int error;
- if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0)
+ if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0 ||
+ (error = is_valid_repository_path(&is_valid, &path, &common_path)) < 0)
return error;
- if (!valid_repository_path(&path, &common_path)) {
+ if (!is_valid) {
git_buf_dispose(&path);
git_buf_dispose(&common_path);
git_error_set(GIT_ERROR_REPOSITORY, "path is not a repository: %s", bare_path);
@@ -804,6 +855,7 @@ int git_repository_open_ext(
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
git_repository *repo = NULL;
git_config *config = NULL;
+ int version = 0;
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
return _git_repository_open_ext_from_env(repo_ptr, start_path);
@@ -845,7 +897,10 @@ int git_repository_open_ext(
if (error < 0 && error != GIT_ENOTFOUND)
goto cleanup;
- if (config && (error = check_repositoryformatversion(config)) < 0)
+ if (config && (error = check_repositoryformatversion(&version, config)) < 0)
+ goto cleanup;
+
+ if ((error = check_extensions(config, version)) < 0)
goto cleanup;
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
@@ -886,7 +941,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
size_t len;
int err;
- assert(repo_out && wt);
+ GIT_ASSERT_ARG(repo_out);
+ GIT_ASSERT_ARG(wt);
*repo_out = NULL;
len = strlen(wt->gitlink_path);
@@ -930,10 +986,12 @@ int git_repository_discover(
const char *ceiling_dirs)
{
uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0;
+ int error;
- assert(start_path);
+ GIT_ASSERT_ARG(start_path);
- git_buf_sanitize(out);
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
return find_repo(out, NULL, NULL, NULL, start_path, flags, ceiling_dirs);
}
@@ -950,7 +1008,7 @@ static int load_config(
git_buf config_path = GIT_BUF_INIT;
git_config *cfg = NULL;
- assert(out);
+ GIT_ASSERT_ARG(out);
if ((error = git_config_new(&cfg)) < 0)
return error;
@@ -1035,8 +1093,7 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo)
if (!error) {
GIT_REFCOUNT_OWN(config, repo);
- config = git__compare_and_swap(&repo->_config, NULL, config);
- if (config != NULL) {
+ if (git_atomic_compare_and_swap(&repo->_config, NULL, config) != NULL) {
GIT_REFCOUNT_OWN(config, NULL);
git_config_free(config);
}
@@ -1074,7 +1131,9 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
int git_repository_set_config(git_repository *repo, git_config *config)
{
- assert(repo && config);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(config);
+
set_config(repo, config);
return 0;
}
@@ -1083,9 +1142,11 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
{
int error = 0;
- assert(repo && out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(out);
- if (repo->_odb == NULL) {
+ *out = git_atomic_load(repo->_odb);
+ if (*out == NULL) {
git_buf odb_path = GIT_BUF_INIT;
git_odb *odb;
@@ -1102,16 +1163,15 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
return error;
}
- odb = git__compare_and_swap(&repo->_odb, NULL, odb);
- if (odb != NULL) {
+ if (git_atomic_compare_and_swap(&repo->_odb, NULL, odb) != NULL) {
GIT_REFCOUNT_OWN(odb, NULL);
git_odb_free(odb);
}
git_buf_dispose(&odb_path);
+ *out = git_atomic_load(repo->_odb);
}
- *out = repo->_odb;
return error;
}
@@ -1126,7 +1186,9 @@ int git_repository_odb(git_odb **out, git_repository *repo)
int git_repository_set_odb(git_repository *repo, git_odb *odb)
{
- assert(repo && odb);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(odb);
+
set_odb(repo, odb);
return 0;
}
@@ -1135,7 +1197,8 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
{
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
if (repo->_refdb == NULL) {
git_refdb *refdb;
@@ -1144,8 +1207,7 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
if (!error) {
GIT_REFCOUNT_OWN(refdb, repo);
- refdb = git__compare_and_swap(&repo->_refdb, NULL, refdb);
- if (refdb != NULL) {
+ if (git_atomic_compare_and_swap(&repo->_refdb, NULL, refdb) != NULL) {
GIT_REFCOUNT_OWN(refdb, NULL);
git_refdb_free(refdb);
}
@@ -1167,7 +1229,9 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
{
- assert(repo && refdb);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(refdb);
+
set_refdb(repo, refdb);
return 0;
}
@@ -1176,7 +1240,8 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
{
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
if (repo->_index == NULL) {
git_buf index_path = GIT_BUF_INIT;
@@ -1189,8 +1254,7 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
if (!error) {
GIT_REFCOUNT_OWN(index, repo);
- index = git__compare_and_swap(&repo->_index, NULL, index);
- if (index != NULL) {
+ if (git_atomic_compare_and_swap(&repo->_index, NULL, index) != NULL) {
GIT_REFCOUNT_OWN(index, NULL);
git_index_free(index);
}
@@ -1217,7 +1281,7 @@ int git_repository_index(git_index **out, git_repository *repo)
int git_repository_set_index(git_repository *repo, git_index *index)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
set_index(repo, index);
return 0;
}
@@ -1341,11 +1405,11 @@ bool git_repository__reserved_names(
}
#endif
-static int check_repositoryformatversion(git_config *config)
+static int check_repositoryformatversion(int *version, git_config *config)
{
- int version, error;
+ int error;
- error = git_config_get_int32(&version, config, "core.repositoryformatversion");
+ error = git_config_get_int32(version, config, "core.repositoryformatversion");
/* git ignores this if the config variable isn't there */
if (error == GIT_ENOTFOUND)
return 0;
@@ -1353,16 +1417,35 @@ static int check_repositoryformatversion(git_config *config)
if (error < 0)
return -1;
- if (GIT_REPO_VERSION < version) {
+ if (GIT_REPO_MAX_VERSION < *version) {
git_error_set(GIT_ERROR_REPOSITORY,
- "unsupported repository version %d. Only versions up to %d are supported.",
- version, GIT_REPO_VERSION);
+ "unsupported repository version %d; only versions up to %d are supported",
+ *version, GIT_REPO_MAX_VERSION);
return -1;
}
return 0;
}
+static int check_valid_extension(const git_config_entry *entry, void *payload)
+{
+ GIT_UNUSED(payload);
+
+ if (!strcmp(entry->name, "extensions.noop"))
+ return 0;
+
+ git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name);
+ return -1;
+}
+
+static int check_extensions(git_config *config, int version)
+{
+ if (version < 1)
+ return 0;
+
+ return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL);
+}
+
int git_repository_create_head(const char *git_dir, const char *ref_name)
{
git_buf ref_path = GIT_BUF_INIT;
@@ -1374,9 +1457,6 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
(error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
goto out;
- if (!ref_name)
- ref_name = GIT_BRANCH_MASTER;
-
if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0)
fmt = "ref: %s\n";
else
@@ -1574,11 +1654,15 @@ static int repo_init_config(
git_config *config = NULL;
bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0);
bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0);
+ int version = 0;
if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0)
goto cleanup;
- if (is_reinit && (error = check_repositoryformatversion(config)) < 0)
+ if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0)
+ goto cleanup;
+
+ if ((error = check_extensions(config, version)) < 0)
goto cleanup;
#define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \
@@ -2023,6 +2107,44 @@ static int repo_init_directories(
return error;
}
+static int repo_init_head(const char *repo_dir, const char *given)
+{
+ git_config *cfg = NULL;
+ git_buf head_path = GIT_BUF_INIT, cfg_branch = GIT_BUF_INIT;
+ const char *initial_head = NULL;
+ int error;
+
+ if ((error = git_buf_joinpath(&head_path, repo_dir, GIT_HEAD_FILE)) < 0)
+ goto out;
+
+ /*
+ * A template may have set a HEAD; use that unless it's been
+ * overridden by the caller's given initial head setting.
+ */
+ if (git_path_exists(head_path.ptr) && !given)
+ goto out;
+
+ if (given) {
+ initial_head = given;
+ } else if ((error = git_config_open_default(&cfg)) >= 0 &&
+ (error = git_config_get_string_buf(&cfg_branch, cfg, "init.defaultbranch")) >= 0 &&
+ *cfg_branch.ptr) {
+ initial_head = cfg_branch.ptr;
+ }
+
+ if (!initial_head)
+ initial_head = GIT_BRANCH_DEFAULT;
+
+ error = git_repository_create_head(repo_dir, initial_head);
+
+out:
+ git_config_free(cfg);
+ git_buf_dispose(&head_path);
+ git_buf_dispose(&cfg_branch);
+
+ return error;
+}
+
static int repo_init_create_origin(git_repository *repo, const char *url)
{
int error;
@@ -2053,11 +2175,14 @@ int git_repository_init_ext(
git_repository_init_options *opts)
{
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
- common_path = GIT_BUF_INIT, head_path = GIT_BUF_INIT;
+ common_path = GIT_BUF_INIT;
const char *wd;
+ bool is_valid;
int error;
- assert(out && given_repo && opts);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(given_repo);
+ GIT_ASSERT_ARG(opts);
GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
@@ -2066,7 +2191,10 @@ int git_repository_init_ext(
wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path);
- if (valid_repository_path(&repo_path, &common_path)) {
+ if ((error = is_valid_repository_path(&is_valid, &repo_path, &common_path)) < 0)
+ goto out;
+
+ if (is_valid) {
if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) {
git_error_set(GIT_ERROR_REPOSITORY,
"attempt to reinitialize '%s'", given_repo);
@@ -2083,16 +2211,7 @@ int git_repository_init_ext(
} else {
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
- (error = git_buf_joinpath(&head_path, repo_path.ptr, GIT_HEAD_FILE)) < 0)
- goto out;
-
- /*
- * Only set the new HEAD if the file does not exist already via
- * a template or if the caller has explicitly supplied an
- * initial HEAD value.
- */
- if ((!git_path_exists(head_path.ptr) || opts->initial_head) &&
- (error = git_repository_create_head(repo_path.ptr, opts->initial_head)) < 0)
+ (error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0)
goto out;
}
@@ -2104,7 +2223,6 @@ int git_repository_init_ext(
goto out;
out:
- git_buf_dispose(&head_path);
git_buf_dispose(&common_path);
git_buf_dispose(&repo_path);
git_buf_dispose(&wd_path);
@@ -2135,18 +2253,13 @@ int git_repository_head_detached(git_repository *repo)
return exists;
}
-static int get_worktree_file_path(git_buf *out, git_repository *repo, const char *worktree, const char *file)
-{
- git_buf_clear(out);
- return git_buf_printf(out, "%s/worktrees/%s/%s", repo->commondir, worktree, file);
-}
-
int git_repository_head_detached_for_worktree(git_repository *repo, const char *name)
{
git_reference *ref = NULL;
int error;
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
if ((error = git_repository_head_for_worktree(&ref, repo, name)) < 0)
goto out;
@@ -2163,7 +2276,7 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
git_reference *head;
int error;
- assert(head_out);
+ GIT_ASSERT_ARG(head_out);
if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
return error;
@@ -2181,73 +2294,79 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
int git_repository_head_for_worktree(git_reference **out, git_repository *repo, const char *name)
{
- git_buf path = GIT_BUF_INIT;
+ git_repository *worktree_repo = NULL;
+ git_worktree *worktree = NULL;
git_reference *head = NULL;
int error;
- assert(out && repo && name);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
*out = NULL;
- if ((error = get_worktree_file_path(&path, repo, name, GIT_HEAD_FILE)) < 0 ||
- (error = git_reference__read_head(&head, repo, path.ptr)) < 0)
+ if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 ||
+ (error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 ||
+ (error = git_reference_lookup(&head, worktree_repo, GIT_HEAD_FILE)) < 0)
goto out;
if (git_reference_type(head) != GIT_REFERENCE_DIRECT) {
- git_reference *resolved;
-
- error = git_reference_lookup_resolved(&resolved, repo, git_reference_symbolic_target(head), -1);
- git_reference_free(head);
- head = resolved;
+ if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0)
+ goto out;
+ } else {
+ *out = head;
+ head = NULL;
}
- *out = head;
-
out:
- if (error)
- git_reference_free(head);
-
- git_buf_dispose(&path);
-
+ git_reference_free(head);
+ git_worktree_free(worktree);
+ git_repository_free(worktree_repo);
return error;
}
-int git_repository_foreach_head(git_repository *repo,
- git_repository_foreach_head_cb cb,
- int flags, void *payload)
+int git_repository_foreach_worktree(git_repository *repo,
+ git_repository_foreach_worktree_cb cb,
+ void *payload)
{
- git_strarray worktrees = GIT_VECTOR_INIT;
- git_buf path = GIT_BUF_INIT;
- int error = 0;
+ git_strarray worktrees = {0};
+ git_repository *worktree_repo = NULL;
+ git_worktree *worktree = NULL;
+ int error;
size_t i;
+ if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
+ (error = cb(worktree_repo, payload) != 0))
+ goto out;
- if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO)) {
- /* Gather HEAD of main repository */
- if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
- (error = cb(repo, path.ptr, payload) != 0))
- goto out;
- }
+ git_repository_free(worktree_repo);
+ worktree_repo = NULL;
- if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES)) {
- if ((error = git_worktree_list(&worktrees, repo)) < 0) {
- error = 0;
- goto out;
- }
+ if ((error = git_worktree_list(&worktrees, repo)) < 0)
+ goto out;
- /* Gather HEADs of all worktrees */
- for (i = 0; i < worktrees.count; i++) {
- if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0)
- continue;
+ for (i = 0; i < worktrees.count; i++) {
+ git_repository_free(worktree_repo);
+ worktree_repo = NULL;
+ git_worktree_free(worktree);
+ worktree = NULL;
- if ((error = cb(repo, path.ptr, payload)) != 0)
+ if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) ||
+ (error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0) {
+ if (error != GIT_ENOTFOUND)
goto out;
+ error = 0;
+ continue;
}
+
+ if ((error = cb(worktree_repo, payload)) != 0)
+ goto out;
}
out:
- git_buf_dispose(&path);
- git_strarray_free(&worktrees);
+ git_strarray_dispose(&worktrees);
+ git_repository_free(worktree_repo);
+ git_worktree_free(worktree);
return error;
}
@@ -2270,43 +2389,79 @@ int git_repository_head_unborn(git_repository *repo)
return 0;
}
-static int at_least_one_cb(const char *refname, void *payload)
+static int repo_contains_no_reference(git_repository *repo)
{
- GIT_UNUSED(refname);
- GIT_UNUSED(payload);
- return GIT_PASSTHROUGH;
+ git_reference_iterator *iter;
+ const char *refname;
+ int error;
+
+ if ((error = git_reference_iterator_new(&iter, repo)) < 0)
+ return error;
+
+ error = git_reference_next_name(&refname, iter);
+ git_reference_iterator_free(iter);
+
+ if (error == GIT_ITEROVER)
+ return 1;
+
+ return error;
}
-static int repo_contains_no_reference(git_repository *repo)
+int git_repository_initialbranch(git_buf *out, git_repository *repo)
{
- int error = git_reference_foreach_name(repo, &at_least_one_cb, NULL);
+ git_config *config;
+ git_config_entry *entry = NULL;
+ const char *branch;
+ int valid, error;
- if (error == GIT_PASSTHROUGH)
- return 0;
+ if ((error = git_repository_config__weakptr(&config, repo)) < 0)
+ return error;
- if (!error)
- return 1;
+ if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0 &&
+ *entry->value) {
+ branch = entry->value;
+ }
+ else if (!error || error == GIT_ENOTFOUND) {
+ branch = GIT_BRANCH_DEFAULT;
+ }
+ else {
+ goto done;
+ }
+
+ if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
+ (error = git_buf_puts(out, branch)) < 0 ||
+ (error = git_reference_name_is_valid(&valid, out->ptr)) < 0)
+ goto done;
+ if (!valid) {
+ git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid branch name");
+ error = -1;
+ }
+
+done:
+ git_config_entry_free(entry);
return error;
}
int git_repository_is_empty(git_repository *repo)
{
git_reference *head = NULL;
- int is_empty = 0;
+ git_buf initialbranch = GIT_BUF_INIT;
+ int result = 0;
- if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0)
- return -1;
+ if ((result = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0 ||
+ (result = git_repository_initialbranch(&initialbranch, repo)) < 0)
+ goto done;
- if (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC)
- is_empty =
- (strcmp(git_reference_symbolic_target(head),
- GIT_REFS_HEADS_DIR "master") == 0) &&
- repo_contains_no_reference(repo);
+ result = (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC &&
+ strcmp(git_reference_symbolic_target(head), initialbranch.ptr) == 0 &&
+ repo_contains_no_reference(repo));
+done:
git_reference_free(head);
+ git_buf_dispose(&initialbranch);
- return is_empty;
+ return result;
}
static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
@@ -2359,13 +2514,13 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
const char *git_repository_path(const git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
return repo->gitdir;
}
const char *git_repository_workdir(const git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
if (repo->is_bare)
return NULL;
@@ -2373,9 +2528,25 @@ const char *git_repository_workdir(const git_repository *repo)
return repo->workdir;
}
+int git_repository_workdir_path(
+ git_buf *out, git_repository *repo, const char *path)
+{
+ int error;
+
+ if (!repo->workdir) {
+ git_error_set(GIT_ERROR_REPOSITORY, "repository has no working directory");
+ return GIT_EBAREREPO;
+ }
+
+ if (!(error = git_buf_joinpath(out, repo->workdir, path)))
+ error = git_path_validate_workdir_buf(repo, out);
+
+ return error;
+}
+
const char *git_repository_commondir(const git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
return repo->commondir;
}
@@ -2385,7 +2556,8 @@ int git_repository_set_workdir(
int error = 0;
git_buf path = GIT_BUF_INIT;
- assert(repo && workdir);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(workdir);
if (git_path_prettify_dir(&path, workdir, NULL) < 0)
return -1;
@@ -2425,13 +2597,13 @@ int git_repository_set_workdir(
int git_repository_is_bare(const git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
return repo->is_bare;
}
int git_repository_is_worktree(const git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
return repo->is_worktree;
}
@@ -2440,7 +2612,7 @@ int git_repository_set_bare(git_repository *repo)
int error;
git_config *config;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if (repo->is_bare)
return 0;
@@ -2508,7 +2680,8 @@ int git_repository_message(git_buf *out, git_repository *repo)
struct stat st;
int error;
- git_buf_sanitize(out);
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0)
return -1;
@@ -2553,16 +2726,19 @@ int git_repository_hashfile(
uint64_t len;
git_buf full_path = GIT_BUF_INIT;
- assert(out && path && repo); /* as_path can be NULL */
+ /* as_path can be NULL */
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(path);
+ GIT_ASSERT_ARG(repo);
/* At some point, it would be nice if repo could be NULL to just
* apply filter rules defined in system and global files, but for
* now that is not possible because git_filters_load() needs it.
*/
- error = git_path_join_unrooted(
- &full_path, path, git_repository_workdir(repo), NULL);
- if (error < 0)
+ if ((error = git_path_join_unrooted(
+ &full_path, path, git_repository_workdir(repo), NULL)) < 0 ||
+ (error = git_path_validate_workdir_buf(repo, &full_path)) < 0)
return error;
if (!as_path)
@@ -2638,7 +2814,8 @@ static int detach(git_repository *repo, const git_oid *id, const char *new)
git_object *object = NULL, *peeled = NULL;
git_reference *new_head = NULL, *current = NULL;
- assert(repo && id);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(id);
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0)
return error;
@@ -2674,7 +2851,8 @@ int git_repository_set_head(
git_buf log_message = GIT_BUF_INIT;
int error;
- assert(repo && refname);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(refname);
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0)
return error;
@@ -2726,7 +2904,8 @@ int git_repository_set_head_detached_from_annotated(
git_repository *repo,
const git_annotated_commit *commitish)
{
- assert(repo && commitish);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(commitish);
return detach(repo, git_annotated_commit_id(commitish), commitish->description);
}
@@ -2738,7 +2917,7 @@ int git_repository_detach_head(git_repository* repo)
git_buf log_message = GIT_BUF_INIT;
int error;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0)
return error;
@@ -2773,7 +2952,7 @@ int git_repository_state(git_repository *repo)
git_buf repo_path = GIT_BUF_INIT;
int state = GIT_REPOSITORY_STATE_NONE;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if (git_buf_puts(&repo_path, repo->gitdir) < 0)
return -1;
@@ -2850,7 +3029,7 @@ static const char *state_files[] = {
int git_repository_state_cleanup(git_repository *repo)
{
- assert(repo);
+ GIT_ASSERT_ARG(repo);
return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files));
}
@@ -2886,11 +3065,13 @@ int git_repository_init_options_init(
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_repository_init_init_options(
git_repository_init_options *opts, unsigned int version)
{
return git_repository_init_options_init(opts, version);
}
+#endif
int git_repository_ident(const char **name, const char **email, const git_repository *repo)
{
@@ -2914,8 +3095,8 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
GIT_ERROR_CHECK_ALLOC(tmp_email);
}
- tmp_name = git__swap(repo->ident_name, tmp_name);
- tmp_email = git__swap(repo->ident_email, tmp_email);
+ tmp_name = git_atomic_swap(repo->ident_name, tmp_name);
+ tmp_email = git_atomic_swap(repo->ident_email, tmp_email);
git__free(tmp_name);
git__free(tmp_email);
@@ -2925,28 +3106,16 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
int git_repository_submodule_cache_all(git_repository *repo)
{
- int error;
-
- assert(repo);
-
- if ((error = git_strmap_new(&repo->submodule_cache)))
- return error;
-
- error = git_submodule__map(repo, repo->submodule_cache);
- return error;
+ GIT_ASSERT_ARG(repo);
+ return git_submodule_cache_init(&repo->submodule_cache, repo);
}
int git_repository_submodule_cache_clear(git_repository *repo)
{
- git_submodule *sm;
- assert(repo);
- if (repo->submodule_cache == NULL) {
- return 0;
- }
- git_strmap_foreach_value(repo->submodule_cache, sm, {
- git_submodule_free(sm);
- });
- git_strmap_free(repo->submodule_cache);
- repo->submodule_cache = 0;
- return 0;
+ int error = 0;
+ GIT_ASSERT_ARG(repo);
+
+ error = git_submodule_cache_free(repo->submodule_cache);
+ repo->submodule_cache = NULL;
+ return error;
}
diff --git a/src/repository.h b/src/repository.h
index bafdb58..f48dd9e 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -51,6 +51,7 @@ typedef enum {
GIT_CONFIGMAP_PROTECTHFS, /* core.protectHFS */
GIT_CONFIGMAP_PROTECTNTFS, /* core.protectNTFS */
GIT_CONFIGMAP_FSYNCOBJECTFILES, /* core.fsyncObjectFiles */
+ GIT_CONFIGMAP_LONGPATHS, /* core.longpaths */
GIT_CONFIGMAP_CACHE_MAX
} git_configmap_item;
@@ -116,6 +117,8 @@ typedef enum {
GIT_PROTECTNTFS_DEFAULT = GIT_CONFIGMAP_TRUE,
/* core.fsyncObjectFiles */
GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CONFIGMAP_FALSE,
+ /* core.longpaths */
+ GIT_LONGPATHS_DEFAULT = GIT_CONFIGMAP_FALSE,
} git_configmap_value;
/* internal repository init flags */
@@ -152,9 +155,9 @@ struct git_repository {
unsigned int lru_counter;
- git_atomic attr_session_key;
+ git_atomic32 attr_session_key;
- git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
+ intptr_t configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
git_strmap *submodule_cache;
};
@@ -166,34 +169,11 @@ GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo)
int git_repository_head_tree(git_tree **tree, git_repository *repo);
int git_repository_create_head(const char *git_dir, const char *ref_name);
-/*
- * Called for each HEAD.
- *
- * Can return either 0, causing the iteration over HEADs to
- * continue, or a non-0 value causing the iteration to abort. The
- * return value is passed back to the caller of
- * `git_repository_foreach_head`
- */
-typedef int (*git_repository_foreach_head_cb)(git_repository *repo, const char *path, void *payload);
+typedef int (*git_repository_foreach_worktree_cb)(git_repository *, void *);
-enum {
- /* Skip enumeration of the main repository HEAD */
- GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO = (1u << 0),
- /* Skip enumeration of worktree HEADs */
- GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES = (1u << 1),
-};
-
-/*
- * Iterate over repository and all worktree HEADs.
- *
- * This function will be called for the repository HEAD and for
- * all HEADS of linked worktrees. For each HEAD, the callback is
- * executed with the given payload. The return value equals the
- * return value of the last executed callback function.
- */
-int git_repository_foreach_head(git_repository *repo,
- git_repository_foreach_head_cb cb,
- int flags, void *payload);
+int git_repository_foreach_worktree(git_repository *repo,
+ git_repository_foreach_worktree_cb cb,
+ void *payload);
/*
* Weak pointers to repository internals.
@@ -255,4 +235,18 @@ extern size_t git_repository__reserved_names_posix_len;
bool git_repository__reserved_names(
git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs);
+/*
+ * The default branch for the repository; the `init.defaultBranch`
+ * configuration option, if set, or `master` if it is not.
+ */
+int git_repository_initialbranch(git_buf *out, git_repository *repo);
+
+/*
+ * Given a relative `path`, this makes it absolute based on the
+ * repository's working directory. This will perform validation
+ * to ensure that the path is not longer than MAX_PATH on Windows
+ * (unless `core.longpaths` is set in the repo config).
+ */
+int git_repository_workdir_path(git_buf *out, git_repository *repo, const char *path);
+
#endif
diff --git a/src/reset.c b/src/reset.c
index ca6a5bd..dfae91d 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -33,7 +33,7 @@ int git_reset_default(
int error;
git_index *index = NULL;
- assert(pathspecs != NULL && pathspecs->count > 0);
+ GIT_ASSERT_ARG(pathspecs && pathspecs->count > 0);
memset(&entry, 0, sizeof(git_index_entry));
@@ -62,10 +62,10 @@ int git_reset_default(
for (i = 0, max_i = git_diff_num_deltas(diff); i < max_i; ++i) {
const git_diff_delta *delta = git_diff_get_delta(diff, i);
- assert(delta->status == GIT_DELTA_ADDED ||
- delta->status == GIT_DELTA_MODIFIED ||
- delta->status == GIT_DELTA_CONFLICTED ||
- delta->status == GIT_DELTA_DELETED);
+ GIT_ASSERT(delta->status == GIT_DELTA_ADDED ||
+ delta->status == GIT_DELTA_MODIFIED ||
+ delta->status == GIT_DELTA_CONFLICTED ||
+ delta->status == GIT_DELTA_DELETED);
error = git_index_conflict_remove(index, delta->old_file.path);
if (error < 0) {
@@ -113,7 +113,8 @@ static int reset(
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
git_buf log_message = GIT_BUF_INIT;
- assert(repo && target);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(target);
if (checkout_opts)
opts = *checkout_opts;
diff --git a/src/revert.c b/src/revert.c
index b41a2a1..683f0d7 100644
--- a/src/revert.c
+++ b/src/revert.c
@@ -129,7 +129,10 @@ int git_revert_commit(
git_tree *parent_tree = NULL, *our_tree = NULL, *revert_tree = NULL;
int parent = 0, error = 0;
- assert(out && repo && revert_commit && our_commit);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(revert_commit);
+ GIT_ASSERT_ARG(our_commit);
if (git_commit_parentcount(revert_commit) > 1) {
if (!mainline)
@@ -180,7 +183,8 @@ int git_revert(
git_indexwriter indexwriter = GIT_INDEXWRITER_INIT;
int error;
- assert(repo && commit);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(commit);
GIT_ERROR_CHECK_VERSION(given_opts, GIT_REVERT_OPTIONS_VERSION, "git_revert_options");
@@ -231,7 +235,9 @@ int git_revert_options_init(git_revert_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_revert_init_options(git_revert_options *opts, unsigned int version)
{
return git_revert_options_init(opts, version);
}
+#endif
diff --git a/src/revparse.c b/src/revparse.c
index c627de6..b0c312d 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -317,7 +317,7 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s
git_buf identifier = GIT_BUF_INIT;
git_time_t timestamp;
- assert(*out == NULL);
+ GIT_ASSERT(*out == NULL);
if (git_buf_put(&identifier, spec, identifier_len) < 0)
return -1;
@@ -524,7 +524,7 @@ static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t *
{
git_buf_clear(buf);
- assert(spec[*pos] == '^' || spec[*pos] == '@');
+ GIT_ASSERT_ARG(spec[*pos] == '^' || spec[*pos] == '@');
(*pos)++;
@@ -537,7 +537,8 @@ static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t *
if (spec[*pos] == '\0')
return GIT_EINVALIDSPEC;
- git_buf_putc(buf, spec[(*pos)++]);
+ if (git_buf_putc(buf, spec[(*pos)++]) < 0)
+ return -1;
}
(*pos)++;
@@ -549,7 +550,7 @@ static int extract_path(git_buf *buf, const char *spec, size_t *pos)
{
git_buf_clear(buf);
- assert(spec[*pos] == ':');
+ GIT_ASSERT_ARG(spec[*pos] == ':');
(*pos)++;
@@ -567,7 +568,7 @@ static int extract_how_many(int *n, const char *spec, size_t *pos)
int parsed, accumulated;
char kind = spec[*pos];
- assert(spec[*pos] == '^' || spec[*pos] == '~');
+ GIT_ASSERT_ARG(spec[*pos] == '^' || spec[*pos] == '~');
accumulated = 0;
@@ -585,7 +586,7 @@ static int extract_how_many(int *n, const char *spec, size_t *pos)
*pos = end_ptr - spec;
}
- } while (spec[(*pos)] == kind && kind == '~');
+ } while (spec[(*pos)] == kind && kind == '~');
*n = accumulated;
@@ -659,7 +660,7 @@ static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_
return GIT_EINVALIDSPEC;
}
-int revparse__ext(
+static int revparse(
git_object **object_out,
git_reference **reference_out,
size_t *identifier_len_out,
@@ -675,7 +676,10 @@ int revparse__ext(
bool should_return_reference = true;
- assert(object_out && reference_out && repo && spec);
+ GIT_ASSERT_ARG(object_out);
+ GIT_ASSERT_ARG(reference_out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(spec);
*object_out = NULL;
*reference_out = NULL;
@@ -835,7 +839,7 @@ int git_revparse_ext(
git_object *obj = NULL;
git_reference *ref = NULL;
- if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0)
+ if ((error = revparse(&obj, &ref, &identifier_len, repo, spec)) < 0)
goto cleanup;
*object_out = obj;
@@ -881,14 +885,16 @@ int git_revparse(
const char *dotdot;
int error = 0;
- assert(revspec && repo && spec);
+ GIT_ASSERT_ARG(revspec);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(spec);
memset(revspec, 0x0, sizeof(*revspec));
if ((dotdot = strstr(spec, "..")) != NULL) {
char *lstr;
const char *rstr;
- revspec->flags = GIT_REVPARSE_RANGE;
+ revspec->flags = GIT_REVSPEC_RANGE;
/*
* Following git.git, don't allow '..' because it makes command line
@@ -904,7 +910,7 @@ int git_revparse(
lstr = git__substrdup(spec, dotdot - spec);
rstr = dotdot + 2;
if (dotdot[2] == '.') {
- revspec->flags |= GIT_REVPARSE_MERGE_BASE;
+ revspec->flags |= GIT_REVSPEC_MERGE_BASE;
rstr++;
}
@@ -922,7 +928,7 @@ int git_revparse(
git__free((void*)lstr);
} else {
- revspec->flags = GIT_REVPARSE_SINGLE;
+ revspec->flags = GIT_REVSPEC_SINGLE;
error = git_revparse_single(&revspec->from, repo, spec);
}
diff --git a/src/revwalk.c b/src/revwalk.c
index 4587b5a..a686a9f 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -58,7 +58,7 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
return 0;
git_error_set(GIT_ERROR_INVALID, "object is not a committish");
- return -1;
+ return error;
}
if (error < 0)
return error;
@@ -99,7 +99,8 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk && oid);
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(oid);
return git_revwalk__push_commit(walk, oid, &opts);
}
@@ -108,7 +109,9 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
int git_revwalk_hide(git_revwalk *walk, const git_oid *oid)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk && oid);
+
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(oid);
opts.uninteresting = 1;
return git_revwalk__push_commit(walk, oid, &opts);
@@ -133,7 +136,8 @@ int git_revwalk__push_glob(git_revwalk *walk, const char *glob, const git_revwal
git_reference_iterator *iter;
size_t wildcard;
- assert(walk && glob);
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(glob);
if (given_opts)
memcpy(&opts, given_opts, sizeof(opts));
@@ -172,7 +176,9 @@ out:
int git_revwalk_push_glob(git_revwalk *walk, const char *glob)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk && glob);
+
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(glob);
return git_revwalk__push_glob(walk, glob, &opts);
}
@@ -180,7 +186,9 @@ int git_revwalk_push_glob(git_revwalk *walk, const char *glob)
int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk && glob);
+
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(glob);
opts.uninteresting = 1;
return git_revwalk__push_glob(walk, glob, &opts);
@@ -189,7 +197,8 @@ int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
int git_revwalk_push_head(git_revwalk *walk)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk);
+
+ GIT_ASSERT_ARG(walk);
return git_revwalk__push_ref(walk, GIT_HEAD_FILE, &opts);
}
@@ -197,7 +206,8 @@ int git_revwalk_push_head(git_revwalk *walk)
int git_revwalk_hide_head(git_revwalk *walk)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk);
+
+ GIT_ASSERT_ARG(walk);
opts.uninteresting = 1;
return git_revwalk__push_ref(walk, GIT_HEAD_FILE, &opts);
@@ -206,7 +216,9 @@ int git_revwalk_hide_head(git_revwalk *walk)
int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk && refname);
+
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(refname);
return git_revwalk__push_ref(walk, refname, &opts);
}
@@ -226,7 +238,7 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
goto out;
}
- if (revspec.flags & GIT_REVPARSE_MERGE_BASE) {
+ if (revspec.flags & GIT_REVSPEC_MERGE_BASE) {
/* TODO: support "<commit>...<commit>" */
git_error_set(GIT_ERROR_INVALID, "symmetric differences not implemented in revwalk");
error = GIT_EINVALIDSPEC;
@@ -249,7 +261,10 @@ out:
int git_revwalk_hide_ref(git_revwalk *walk, const char *refname)
{
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
- assert(walk && refname);
+
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(refname);
+
opts.uninteresting = 1;
return git_revwalk__push_ref(walk, refname, &opts);
}
@@ -659,13 +674,11 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
git_revwalk *walk = git__calloc(1, sizeof(git_revwalk));
GIT_ERROR_CHECK_ALLOC(walk);
- if (git_oidmap_new(&walk->commits) < 0)
+ if (git_oidmap_new(&walk->commits) < 0 ||
+ git_pqueue_init(&walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0 ||
+ git_pool_init(&walk->commit_pool, COMMIT_ALLOC) < 0)
return -1;
- if (git_pqueue_init(&walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0)
- return -1;
-
- git_pool_init(&walk->commit_pool, COMMIT_ALLOC);
walk->get_next = &revwalk_next_unsorted;
walk->enqueue = &revwalk_enqueue_unsorted;
@@ -696,13 +709,14 @@ void git_revwalk_free(git_revwalk *walk)
git_repository *git_revwalk_repository(git_revwalk *walk)
{
- assert(walk);
+ GIT_ASSERT_ARG_WITH_RETVAL(walk, NULL);
+
return walk->repo;
}
int git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
{
- assert(walk);
+ GIT_ASSERT_ARG(walk);
if (walk->walking)
git_revwalk_reset(walk);
@@ -734,7 +748,8 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
int error;
git_commit_list_node *next;
- assert(walk && oid);
+ GIT_ASSERT_ARG(walk);
+ GIT_ASSERT_ARG(oid);
if (!walk->walking) {
if ((error = prepare_walk(walk)) < 0)
@@ -759,7 +774,7 @@ int git_revwalk_reset(git_revwalk *walk)
{
git_commit_list_node *commit;
- assert(walk);
+ GIT_ASSERT_ARG(walk);
git_oidmap_foreach_value(walk->commits, commit, {
commit->seen = 0;
@@ -789,7 +804,7 @@ int git_revwalk_add_hide_cb(
git_revwalk_hide_cb hide_cb,
void *payload)
{
- assert(walk);
+ GIT_ASSERT_ARG(walk);
if (walk->walking)
git_revwalk_reset(walk);
diff --git a/src/runtime.c b/src/runtime.c
new file mode 100644
index 0000000..c05dee8
--- /dev/null
+++ b/src/runtime.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "common.h"
+#include "runtime.h"
+
+static git_runtime_shutdown_fn shutdown_callback[32];
+static git_atomic32 shutdown_callback_count;
+
+static git_atomic32 init_count;
+
+static int init_common(git_runtime_init_fn init_fns[], size_t cnt)
+{
+ size_t i;
+ int ret;
+
+ /* Initialize subsystems that have global state */
+ for (i = 0; i < cnt; i++) {
+ if ((ret = init_fns[i]()) != 0)
+ break;
+ }
+
+ GIT_MEMORY_BARRIER;
+
+ return ret;
+}
+
+static void shutdown_common(void)
+{
+ git_runtime_shutdown_fn cb;
+ int pos;
+
+ for (pos = git_atomic32_get(&shutdown_callback_count);
+ pos > 0;
+ pos = git_atomic32_dec(&shutdown_callback_count)) {
+ cb = git_atomic_swap(shutdown_callback[pos - 1], NULL);
+
+ if (cb != NULL)
+ cb();
+ }
+}
+
+int git_runtime_shutdown_register(git_runtime_shutdown_fn callback)
+{
+ int count = git_atomic32_inc(&shutdown_callback_count);
+
+ if (count > (int)ARRAY_SIZE(shutdown_callback) || count == 0) {
+ git_error_set(GIT_ERROR_INVALID,
+ "too many shutdown callbacks registered");
+ git_atomic32_dec(&shutdown_callback_count);
+ return -1;
+ }
+
+ shutdown_callback[count - 1] = callback;
+
+ return 0;
+}
+
+#if defined(GIT_THREADS) && defined(GIT_WIN32)
+
+/*
+ * On Win32, we use a spinlock to provide locking semantics. This is
+ * lighter-weight than a proper critical section.
+ */
+static volatile LONG init_spinlock = 0;
+
+GIT_INLINE(int) init_lock(void)
+{
+ while (InterlockedCompareExchange(&init_spinlock, 1, 0)) { Sleep(0); }
+ return 0;
+}
+
+GIT_INLINE(int) init_unlock(void)
+{
+ InterlockedExchange(&init_spinlock, 0);
+ return 0;
+}
+
+#elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
+
+/*
+ * On POSIX, we need to use a proper mutex for locking. We might prefer
+ * a spinlock here, too, but there's no static initializer for a
+ * pthread_spinlock_t.
+ */
+static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+GIT_INLINE(int) init_lock(void)
+{
+ return pthread_mutex_lock(&init_mutex) == 0 ? 0 : -1;
+}
+
+GIT_INLINE(int) init_unlock(void)
+{
+ return pthread_mutex_unlock(&init_mutex) == 0 ? 0 : -1;
+}
+
+#elif defined(GIT_THREADS)
+# error unknown threading model
+#else
+
+# define init_lock() git__noop()
+# define init_unlock() git__noop()
+
+#endif
+
+int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt)
+{
+ int ret;
+
+ if (init_lock() < 0)
+ return -1;
+
+ /* Only do work on a 0 -> 1 transition of the refcount */
+ if ((ret = git_atomic32_inc(&init_count)) == 1) {
+ if (init_common(init_fns, cnt) < 0)
+ ret = -1;
+ }
+
+ if (init_unlock() < 0)
+ return -1;
+
+ return ret;
+}
+
+int git_runtime_init_count(void)
+{
+ int ret;
+
+ if (init_lock() < 0)
+ return -1;
+
+ ret = git_atomic32_get(&init_count);
+
+ if (init_unlock() < 0)
+ return -1;
+
+ return ret;
+}
+
+int git_runtime_shutdown(void)
+{
+ int ret;
+
+ /* Enter the lock */
+ if (init_lock() < 0)
+ return -1;
+
+ /* Only do work on a 1 -> 0 transition of the refcount */
+ if ((ret = git_atomic32_dec(&init_count)) == 0)
+ shutdown_common();
+
+ /* Exit the lock */
+ if (init_unlock() < 0)
+ return -1;
+
+ return ret;
+}
diff --git a/src/runtime.h b/src/runtime.h
new file mode 100644
index 0000000..24ac58e
--- /dev/null
+++ b/src/runtime.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_runtime_h__
+#define INCLUDE_runtime_h__
+
+#include "common.h"
+
+typedef int (*git_runtime_init_fn)(void);
+typedef void (*git_runtime_shutdown_fn)(void);
+
+/**
+ * Start up a new runtime. If this is the first time that this
+ * function is called within the context of the current library
+ * or executable, then the given `init_fns` will be invoked. If
+ * it is not the first time, they will be ignored.
+ *
+ * The given initialization functions _may_ register shutdown
+ * handlers using `git_runtime_shutdown_register` to be notified
+ * when the runtime is shutdown.
+ *
+ * @param init_fns The list of initialization functions to call
+ * @param cnt The number of init_fns
+ * @return The number of initializations performed (including this one) or an error
+ */
+int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt);
+
+/*
+ * Returns the number of initializations active (the number of calls to
+ * `git_runtime_init` minus the number of calls sto `git_runtime_shutdown`).
+ * If 0, the runtime is not currently initialized.
+ *
+ * @return The number of initializations performed or an error
+ */
+int git_runtime_init_count(void);
+
+/**
+ * Shut down the runtime. If this is the last shutdown call,
+ * such that there are no remaining `init` calls, then any
+ * shutdown hooks that have been registered will be invoked.
+ *
+ * The number of outstanding initializations will be returned.
+ * If this number is 0, then the runtime is shutdown.
+ *
+ * @return The number of outstanding initializations (after this one) or an error
+ */
+int git_runtime_shutdown(void);
+
+/**
+ * Register a shutdown handler for this runtime. This should be done
+ * by a function invoked by `git_runtime_init` to ensure that the
+ * appropriate locks are taken.
+ *
+ * @param callback The shutdown handler callback
+ * @return 0 or an error code
+ */
+int git_runtime_shutdown_register(git_runtime_shutdown_fn callback);
+
+#endif
diff --git a/src/settings.c b/src/settings.c
deleted file mode 100644
index f9f6b84..0000000
--- a/src/settings.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "common.h"
-
-#ifdef GIT_OPENSSL
-# include <openssl/err.h>
-#endif
-
-#ifdef GIT_MBEDTLS
-# include <mbedtls/error.h>
-#endif
-
-#include <git2.h>
-#include "alloc.h"
-#include "sysdir.h"
-#include "cache.h"
-#include "global.h"
-#include "object.h"
-#include "odb.h"
-#include "refs.h"
-#include "index.h"
-#include "transports/smart.h"
-#include "transports/http.h"
-#include "streams/openssl.h"
-#include "streams/mbedtls.h"
-
-int git_libgit2_version(int *major, int *minor, int *rev)
-{
- *major = LIBGIT2_VER_MAJOR;
- *minor = LIBGIT2_VER_MINOR;
- *rev = LIBGIT2_VER_REVISION;
-
- return 0;
-}
-
-int git_libgit2_features(void)
-{
- return 0
-#ifdef GIT_THREADS
- | GIT_FEATURE_THREADS
-#endif
-#ifdef GIT_HTTPS
- | GIT_FEATURE_HTTPS
-#endif
-#if defined(GIT_SSH)
- | GIT_FEATURE_SSH
-#endif
-#if defined(GIT_USE_NSEC)
- | GIT_FEATURE_NSEC
-#endif
- ;
-}
-
-/* Declarations for tuneable settings */
-extern size_t git_mwindow__window_size;
-extern size_t git_mwindow__mapped_limit;
-extern size_t git_indexer__max_objects;
-extern bool git_disable_pack_keep_file_checks;
-
-static int config_level_to_sysdir(int config_level)
-{
- int val = -1;
-
- switch (config_level) {
- case GIT_CONFIG_LEVEL_SYSTEM:
- val = GIT_SYSDIR_SYSTEM;
- break;
- case GIT_CONFIG_LEVEL_XDG:
- val = GIT_SYSDIR_XDG;
- break;
- case GIT_CONFIG_LEVEL_GLOBAL:
- val = GIT_SYSDIR_GLOBAL;
- break;
- case GIT_CONFIG_LEVEL_PROGRAMDATA:
- val = GIT_SYSDIR_PROGRAMDATA;
- break;
- default:
- git_error_set(
- GIT_ERROR_INVALID, "invalid config path selector %d", config_level);
- }
-
- return val;
-}
-
-extern char *git__user_agent;
-extern char *git__ssl_ciphers;
-
-const char *git_libgit2__user_agent(void)
-{
- return git__user_agent;
-}
-
-const char *git_libgit2__ssl_ciphers(void)
-{
- return git__ssl_ciphers;
-}
-
-int git_libgit2_opts(int key, ...)
-{
- int error = 0;
- va_list ap;
-
- va_start(ap, key);
-
- switch (key) {
- case GIT_OPT_SET_MWINDOW_SIZE:
- git_mwindow__window_size = va_arg(ap, size_t);
- break;
-
- case GIT_OPT_GET_MWINDOW_SIZE:
- *(va_arg(ap, size_t *)) = git_mwindow__window_size;
- break;
-
- case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT:
- git_mwindow__mapped_limit = va_arg(ap, size_t);
- break;
-
- case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT:
- *(va_arg(ap, size_t *)) = git_mwindow__mapped_limit;
- break;
-
- case GIT_OPT_GET_SEARCH_PATH:
- if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) {
- git_buf *out = va_arg(ap, git_buf *);
- const git_buf *tmp;
-
- git_buf_sanitize(out);
- if ((error = git_sysdir_get(&tmp, error)) < 0)
- break;
-
- error = git_buf_sets(out, tmp->ptr);
- }
- break;
-
- case GIT_OPT_SET_SEARCH_PATH:
- if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0)
- error = git_sysdir_set(error, va_arg(ap, const char *));
- break;
-
- case GIT_OPT_SET_CACHE_OBJECT_LIMIT:
- {
- git_object_t type = (git_object_t)va_arg(ap, int);
- size_t size = va_arg(ap, size_t);
- error = git_cache_set_max_object_size(type, size);
- break;
- }
-
- case GIT_OPT_SET_CACHE_MAX_SIZE:
- git_cache__max_storage = va_arg(ap, ssize_t);
- break;
-
- case GIT_OPT_ENABLE_CACHING:
- git_cache__enabled = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_GET_CACHED_MEMORY:
- *(va_arg(ap, ssize_t *)) = git_cache__current_storage.val;
- *(va_arg(ap, ssize_t *)) = git_cache__max_storage;
- break;
-
- case GIT_OPT_GET_TEMPLATE_PATH:
- {
- git_buf *out = va_arg(ap, git_buf *);
- const git_buf *tmp;
-
- git_buf_sanitize(out);
- if ((error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0)
- break;
-
- error = git_buf_sets(out, tmp->ptr);
- }
- break;
-
- case GIT_OPT_SET_TEMPLATE_PATH:
- error = git_sysdir_set(GIT_SYSDIR_TEMPLATE, va_arg(ap, const char *));
- break;
-
- case GIT_OPT_SET_SSL_CERT_LOCATIONS:
-#ifdef GIT_OPENSSL
- {
- const char *file = va_arg(ap, const char *);
- const char *path = va_arg(ap, const char *);
- error = git_openssl__set_cert_location(file, path);
- }
-#elif defined(GIT_MBEDTLS)
- {
- const char *file = va_arg(ap, const char *);
- const char *path = va_arg(ap, const char *);
- if (file)
- error = git_mbedtls__set_cert_location(file, 0);
- if (error && path)
- error = git_mbedtls__set_cert_location(path, 1);
- }
-#else
- git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support certificate locations");
- error = -1;
-#endif
- break;
- case GIT_OPT_SET_USER_AGENT:
- git__free(git__user_agent);
- git__user_agent = git__strdup(va_arg(ap, const char *));
- if (!git__user_agent) {
- git_error_set_oom();
- error = -1;
- }
-
- break;
-
- case GIT_OPT_ENABLE_STRICT_OBJECT_CREATION:
- git_object__strict_input_validation = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION:
- git_reference__enable_symbolic_ref_target_validation = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_SET_SSL_CIPHERS:
-#if (GIT_OPENSSL || GIT_MBEDTLS)
- {
- git__free(git__ssl_ciphers);
- git__ssl_ciphers = git__strdup(va_arg(ap, const char *));
- if (!git__ssl_ciphers) {
- git_error_set_oom();
- error = -1;
- }
- }
-#else
- git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support custom ciphers");
- error = -1;
-#endif
- break;
-
- case GIT_OPT_GET_USER_AGENT:
- {
- git_buf *out = va_arg(ap, git_buf *);
- git_buf_sanitize(out);
- error = git_buf_sets(out, git__user_agent);
- }
- break;
-
- case GIT_OPT_ENABLE_OFS_DELTA:
- git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_ENABLE_FSYNC_GITDIR:
- git_repository__fsync_gitdir = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_GET_WINDOWS_SHAREMODE:
-#ifdef GIT_WIN32
- *(va_arg(ap, unsigned long *)) = git_win32__createfile_sharemode;
-#endif
- break;
-
- case GIT_OPT_SET_WINDOWS_SHAREMODE:
-#ifdef GIT_WIN32
- git_win32__createfile_sharemode = va_arg(ap, unsigned long);
-#endif
- break;
-
- case GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION:
- git_odb__strict_hash_verification = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_SET_ALLOCATOR:
- error = git_allocator_setup(va_arg(ap, git_allocator *));
- break;
-
- case GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY:
- git_index__enforce_unsaved_safety = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_SET_PACK_MAX_OBJECTS:
- git_indexer__max_objects = va_arg(ap, size_t);
- break;
-
- case GIT_OPT_GET_PACK_MAX_OBJECTS:
- *(va_arg(ap, size_t *)) = git_indexer__max_objects;
- break;
-
- case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS:
- git_disable_pack_keep_file_checks = (va_arg(ap, int) != 0);
- break;
-
- case GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE:
- git_http__expect_continue = (va_arg(ap, int) != 0);
- break;
-
- default:
- git_error_set(GIT_ERROR_INVALID, "invalid option key");
- error = -1;
- }
-
- va_end(ap);
-
- return error;
-}
diff --git a/src/settings.h b/src/settings.h
new file mode 100644
index 0000000..dc42ce9
--- /dev/null
+++ b/src/settings.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+extern int git_settings_global_init(void);
+
+extern const char *git_libgit2__user_agent(void);
+extern const char *git_libgit2__ssl_ciphers(void);
diff --git a/src/sha1_lookup.c b/src/sha1_lookup.c
deleted file mode 100644
index 14fcb40..0000000
--- a/src/sha1_lookup.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "sha1_lookup.h"
-
-#include <stdio.h>
-
-#include "oid.h"
-
-int sha1_position(const void *table,
- size_t stride,
- unsigned lo, unsigned hi,
- const unsigned char *key)
-{
- const unsigned char *base = table;
-
- while (lo < hi) {
- unsigned mi = (lo + hi) / 2;
- int cmp = git_oid__hashcmp(base + mi * stride, key);
-
- if (!cmp)
- return mi;
-
- if (cmp > 0)
- hi = mi;
- else
- lo = mi+1;
- }
-
- return -((int)lo)-1;
-}
diff --git a/src/sha1_lookup.h b/src/sha1_lookup.h
deleted file mode 100644
index 841ea5b..0000000
--- a/src/sha1_lookup.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_sha1_lookup_h__
-#define INCLUDE_sha1_lookup_h__
-
-#include "common.h"
-
-#include <stdlib.h>
-
-int sha1_position(const void *table,
- size_t stride,
- unsigned lo, unsigned hi,
- const unsigned char *key);
-
-#endif
diff --git a/src/signature.c b/src/signature.c
index f4c8a10..1efda21 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -65,7 +65,8 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
{
git_signature *p = NULL;
- assert(name && email);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(email);
*sig_out = NULL;
@@ -279,7 +280,8 @@ int git_signature_from_buffer(git_signature **out, const char *buf)
const char *buf_end;
int error;
- assert(out && buf);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(buf);
*out = NULL;
@@ -302,8 +304,6 @@ void git_signature__writebuf(git_buf *buf, const char *header, const git_signatu
int offset, hours, mins;
char sign;
- assert(buf && sig);
-
offset = sig->when.offset;
sign = (sig->when.offset < 0 || sig->when.sign == '-') ? '-' : '+';
@@ -320,7 +320,8 @@ void git_signature__writebuf(git_buf *buf, const char *header, const git_signatu
bool git_signature__equal(const git_signature *one, const git_signature *two)
{
- assert(one && two);
+ GIT_ASSERT_ARG(one);
+ GIT_ASSERT_ARG(two);
return
git__strcmp(one->name, two->name) == 0 &&
diff --git a/src/sortedcache.c b/src/sortedcache.c
index 8f7ea23..ee6363f 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -25,9 +25,8 @@ int git_sortedcache_new(
sc = git__calloc(1, alloclen);
GIT_ERROR_CHECK_ALLOC(sc);
- git_pool_init(&sc->pool, 1);
-
- if (git_vector_init(&sc->items, 4, item_cmp) < 0 ||
+ if (git_pool_init(&sc->pool, 1) < 0 ||
+ git_vector_init(&sc->items, 4, item_cmp) < 0 ||
git_strmap_new(&sc->map) < 0)
goto fail;
diff --git a/src/sortedcache.h b/src/sortedcache.h
index e553d01..0e1f63c 100644
--- a/src/sortedcache.h
+++ b/src/sortedcache.h
@@ -12,7 +12,7 @@
#include "util.h"
#include "futils.h"
#include "vector.h"
-#include "thread-utils.h"
+#include "thread.h"
#include "pool.h"
#include "strmap.h"
@@ -58,7 +58,7 @@ typedef struct {
* may be NULL. The cache makes it easy to load this and check
* if it has been modified since the last load and/or write.
*/
-int git_sortedcache_new(
+GIT_WARN_UNUSED_RESULT int git_sortedcache_new(
git_sortedcache **out,
size_t item_path_offset, /* use offsetof(struct, path-field) macro */
git_sortedcache_free_item_fn free_item,
@@ -71,7 +71,7 @@ int git_sortedcache_new(
* - `copy_item` can be NULL to just use memcpy
* - if `lock`, grabs read lock on `src` during copy and releases after
*/
-int git_sortedcache_copy(
+GIT_WARN_UNUSED_RESULT int git_sortedcache_copy(
git_sortedcache **out,
git_sortedcache *src,
bool lock,
@@ -100,7 +100,7 @@ const char *git_sortedcache_path(git_sortedcache *sc);
*/
/* Lock sortedcache for write */
-int git_sortedcache_wlock(git_sortedcache *sc);
+GIT_WARN_UNUSED_RESULT int git_sortedcache_wlock(git_sortedcache *sc);
/* Unlock sorted cache when done with write */
void git_sortedcache_wunlock(git_sortedcache *sc);
@@ -120,7 +120,8 @@ void git_sortedcache_wunlock(git_sortedcache *sc);
*
* @return 0 if up-to-date, 1 if out-of-date, <0 on error
*/
-int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf);
+GIT_WARN_UNUSED_RESULT int git_sortedcache_lockandload(
+ git_sortedcache *sc, git_buf *buf);
/* Refresh file timestamp after write completes
* You should already be holding the write lock when you call this.
@@ -132,12 +133,13 @@ void git_sortedcache_updated(git_sortedcache *sc);
* If `wlock` is true, grabs write lock and releases when done, otherwise
* you should already be holding a write lock when you call this.
*/
-int git_sortedcache_clear(git_sortedcache *sc, bool wlock);
+GIT_WARN_UNUSED_RESULT int git_sortedcache_clear(
+ git_sortedcache *sc, bool wlock);
/* Find and/or insert item, returning pointer to item data.
* You should already be holding the write lock when you call this.
*/
-int git_sortedcache_upsert(
+GIT_WARN_UNUSED_RESULT int git_sortedcache_upsert(
void **out, git_sortedcache *sc, const char *key);
/* Removes entry at pos from cache
@@ -155,7 +157,7 @@ int git_sortedcache_remove(git_sortedcache *sc, size_t pos);
*/
/* Lock sortedcache for read */
-int git_sortedcache_rlock(git_sortedcache *sc);
+GIT_WARN_UNUSED_RESULT int git_sortedcache_rlock(git_sortedcache *sc);
/* Unlock sorted cache when done with read */
void git_sortedcache_runlock(git_sortedcache *sc);
diff --git a/src/stash.c b/src/stash.c
index 4a13d05..8ee1273 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -173,7 +173,7 @@ static int stash_to_index(
git_index *index,
const char *path)
{
- git_index *repo_index;
+ git_index *repo_index = NULL;
git_index_entry entry = {{0}};
struct stat st;
int error;
@@ -187,7 +187,7 @@ static int stash_to_index(
return error;
git_index_entry__init_from_stat(&entry, &st,
- (repo_index != NULL || !repo_index->distrust_filemode));
+ (repo_index == NULL || !repo_index->distrust_filemode));
entry.path = path;
@@ -546,7 +546,9 @@ int git_stash_save(
git_buf msg = GIT_BUF_INIT;
int error;
- assert(out && repo && stasher);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(stasher);
if ((error = git_repository__ensure_not_bare(repo, "stash save")) < 0)
return error;
@@ -776,10 +778,12 @@ int git_stash_apply_options_init(git_stash_apply_options *opts, unsigned int ver
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version)
{
return git_stash_apply_options_init(opts, version);
}
+#endif
#define NOTIFY_PROGRESS(opts, progress_type) \
do { \
diff --git a/src/status.c b/src/status.c
index 6a12844..c985646 100644
--- a/src/status.c
+++ b/src/status.c
@@ -391,14 +391,14 @@ done:
size_t git_status_list_entrycount(git_status_list *status)
{
- assert(status);
+ GIT_ASSERT_ARG_WITH_RETVAL(status, 0);
return status->paired.length;
}
const git_status_entry *git_status_byindex(git_status_list *status, size_t i)
{
- assert(status);
+ GIT_ASSERT_ARG_WITH_RETVAL(status, NULL);
return git_vector_get(&status->paired, i);
}
@@ -492,7 +492,9 @@ int git_status_file(
struct status_file_info sfi = {0};
git_index *index;
- assert(status_flags && repo && path);
+ GIT_ASSERT_ARG(status_flags);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(path);
if ((error = git_repository_index__weakptr(&index, repo)) < 0)
return error;
@@ -548,15 +550,18 @@ int git_status_options_init(git_status_options *opts, unsigned int version)
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_status_init_options(git_status_options *opts, unsigned int version)
{
return git_status_options_init(opts, version);
}
+#endif
int git_status_list_get_perfdata(
git_diff_perfdata *out, const git_status_list *status)
{
- assert(out);
+ GIT_ASSERT_ARG(out);
+
GIT_ERROR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
out->stat_calls = 0;
diff --git a/src/strarray.c b/src/strarray.c
new file mode 100644
index 0000000..2f9b77c
--- /dev/null
+++ b/src/strarray.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "util.h"
+
+#include "common.h"
+
+int git_strarray_copy(git_strarray *tgt, const git_strarray *src)
+{
+ size_t i;
+
+ GIT_ASSERT_ARG(tgt);
+ GIT_ASSERT_ARG(src);
+
+ memset(tgt, 0, sizeof(*tgt));
+
+ if (!src->count)
+ return 0;
+
+ tgt->strings = git__calloc(src->count, sizeof(char *));
+ GIT_ERROR_CHECK_ALLOC(tgt->strings);
+
+ for (i = 0; i < src->count; ++i) {
+ if (!src->strings[i])
+ continue;
+
+ tgt->strings[tgt->count] = git__strdup(src->strings[i]);
+ if (!tgt->strings[tgt->count]) {
+ git_strarray_dispose(tgt);
+ memset(tgt, 0, sizeof(*tgt));
+ return -1;
+ }
+
+ tgt->count++;
+ }
+
+ return 0;
+}
+
+void git_strarray_dispose(git_strarray *array)
+{
+ size_t i;
+
+ if (array == NULL)
+ return;
+
+ for (i = 0; i < array->count; ++i)
+ git__free(array->strings[i]);
+
+ git__free(array->strings);
+
+ memset(array, 0, sizeof(*array));
+}
+
+#ifndef GIT_DEPRECATE_HARD
+void git_strarray_free(git_strarray *array)
+{
+ git_strarray_dispose(array);
+}
+#endif
diff --git a/src/streams/mbedtls.c b/src/streams/mbedtls.c
index cbe2f68..22b9f47 100644
--- a/src/streams/mbedtls.c
+++ b/src/streams/mbedtls.c
@@ -11,7 +11,7 @@
#include <ctype.h>
-#include "global.h"
+#include "runtime.h"
#include "stream.h"
#include "streams/socket.h"
#include "netops.h"
@@ -152,9 +152,7 @@ int git_mbedtls_stream_global_init(void)
if (!loaded && crtpath != NULL && stat(crtpath, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))
loaded = (git_mbedtls__set_cert_location(crtpath, 1) == 0);
- git__on_shutdown(shutdown_ssl);
-
- return 0;
+ return git_runtime_shutdown_register(shutdown_ssl);
cleanup:
mbedtls_ctr_drbg_free(ctr_drbg);
@@ -183,8 +181,8 @@ static int ssl_set_error(mbedtls_ssl_context *ssl, int error)
char errbuf[512];
int ret = -1;
- assert(error != MBEDTLS_ERR_SSL_WANT_READ);
- assert(error != MBEDTLS_ERR_SSL_WANT_WRITE);
+ GIT_ASSERT(error != MBEDTLS_ERR_SSL_WANT_READ);
+ GIT_ASSERT(error != MBEDTLS_ERR_SSL_WANT_WRITE);
if (error != 0)
mbedtls_strerror( error, errbuf, 512 );
@@ -425,7 +423,9 @@ int git_mbedtls_stream_new(
git_stream *stream;
int error;
- assert(out && host && port);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(host);
+ GIT_ASSERT_ARG(port);
if ((error = git_socket_stream_new(&stream, host, port)) < 0)
return error;
@@ -444,7 +444,7 @@ int git_mbedtls__set_cert_location(const char *path, int is_dir)
char errbuf[512];
mbedtls_x509_crt *cacert;
- assert(path != NULL);
+ GIT_ASSERT_ARG(path);
cacert = git__malloc(sizeof(mbedtls_x509_crt));
GIT_ERROR_CHECK_ALLOC(cacert);
diff --git a/src/streams/openssl.c b/src/streams/openssl.c
index 98a3635..89c9678 100644
--- a/src/streams/openssl.c
+++ b/src/streams/openssl.c
@@ -6,12 +6,16 @@
*/
#include "streams/openssl.h"
+#include "streams/openssl_legacy.h"
+#include "streams/openssl_dynamic.h"
#ifdef GIT_OPENSSL
#include <ctype.h>
-#include "global.h"
+#include "common.h"
+#include "runtime.h"
+#include "settings.h"
#include "posix.h"
#include "stream.h"
#include "streams/socket.h"
@@ -25,191 +29,107 @@
# include <netinet/in.h>
#endif
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/x509v3.h>
-#include <openssl/bio.h>
-
-#ifdef VALGRIND
-# include <valgrind/memcheck.h>
+#ifndef GIT_OPENSSL_DYNAMIC
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+# include <openssl/x509v3.h>
+# include <openssl/bio.h>
#endif
SSL_CTX *git__ssl_ctx;
#define GIT_SSL_DEFAULT_CIPHERS "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES128-SHA256:DHE-DSS-AES256-SHA256:DHE-DSS-AES128-SHA:DHE-DSS-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA"
-#if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L) || \
- (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
-# define OPENSSL_LEGACY_API
-#endif
-/*
- * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
- * which do not exist in previous versions. We define these inline functions so
- * we can program against the interface instead of littering the implementation
- * with ifdefs. We do the same for OPENSSL_init_ssl.
- */
-#if defined(OPENSSL_LEGACY_API)
-static int OPENSSL_init_ssl(int opts, void *settings)
-{
- GIT_UNUSED(opts);
- GIT_UNUSED(settings);
- SSL_load_error_strings();
- OpenSSL_add_ssl_algorithms();
- return 0;
-}
+static BIO_METHOD *git_stream_bio_method;
+static int init_bio_method(void);
-static BIO_METHOD* BIO_meth_new(int type, const char *name)
+/**
+ * This function aims to clean-up the SSL context which
+ * we allocated.
+ */
+static void shutdown_ssl(void)
{
- BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
- if (!meth) {
- return NULL;
+ if (git_stream_bio_method) {
+ BIO_meth_free(git_stream_bio_method);
+ git_stream_bio_method = NULL;
}
- meth->type = type;
- meth->name = name;
-
- return meth;
-}
-
-static void BIO_meth_free(BIO_METHOD *biom)
-{
- git__free(biom);
-}
-
-static int BIO_meth_set_write(BIO_METHOD *biom, int (*write) (BIO *, const char *, int))
-{
- biom->bwrite = write;
- return 1;
-}
-
-static int BIO_meth_set_read(BIO_METHOD *biom, int (*read) (BIO *, char *, int))
-{
- biom->bread = read;
- return 1;
-}
-
-static int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts) (BIO *, const char *))
-{
- biom->bputs = puts;
- return 1;
-}
-
-static int BIO_meth_set_gets(BIO_METHOD *biom, int (*gets) (BIO *, char *, int))
-
-{
- biom->bgets = gets;
- return 1;
-}
-
-static int BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *))
-{
- biom->ctrl = ctrl;
- return 1;
-}
-
-static int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
-{
- biom->create = create;
- return 1;
-}
-
-static int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
-{
- biom->destroy = destroy;
- return 1;
-}
-
-static int BIO_get_new_index(void)
-{
- /* This exists as of 1.1 so before we'd just have 0 */
- return 0;
-}
-
-static void BIO_set_init(BIO *b, int init)
-{
- b->init = init;
+ if (git__ssl_ctx) {
+ SSL_CTX_free(git__ssl_ctx);
+ git__ssl_ctx = NULL;
+ }
}
-static void BIO_set_data(BIO *a, void *ptr)
-{
- a->ptr = ptr;
-}
+#ifdef VALGRIND
+# if !defined(GIT_OPENSSL_LEGACY) && !defined(GIT_OPENSSL_DYNAMIC)
-static void *BIO_get_data(BIO *a)
+static void *git_openssl_malloc(size_t bytes, const char *file, int line)
{
- return a->ptr;
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+ return git__calloc(1, bytes);
}
-
-static const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
+
+static void *git_openssl_realloc(void *mem, size_t size, const char *file, int line)
{
- return ASN1_STRING_data((ASN1_STRING *)x);
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+ return git__realloc(mem, size);
}
-
-# if defined(GIT_THREADS)
-static git_mutex *openssl_locks;
-
-static void openssl_locking_function(
- int mode, int n, const char *file, int line)
+
+static void git_openssl_free(void *mem, const char *file, int line)
{
- int lock;
-
GIT_UNUSED(file);
GIT_UNUSED(line);
-
- lock = mode & CRYPTO_LOCK;
-
- if (lock) {
- git_mutex_lock(&openssl_locks[n]);
- } else {
- git_mutex_unlock(&openssl_locks[n]);
- }
+ git__free(mem);
}
-
-static void shutdown_ssl_locking(void)
+# else /* !GIT_OPENSSL_LEGACY && !GIT_OPENSSL_DYNAMIC */
+static void *git_openssl_malloc(size_t bytes)
{
- int num_locks, i;
-
- num_locks = CRYPTO_num_locks();
- CRYPTO_set_locking_callback(NULL);
-
- for (i = 0; i < num_locks; ++i)
- git_mutex_free(&openssl_locks[i]);
- git__free(openssl_locks);
+ return git__calloc(1, bytes);
}
-# endif /* GIT_THREADS */
-#endif /* OPENSSL_LEGACY_API */
-static BIO_METHOD *git_stream_bio_method;
-static int init_bio_method(void);
-
-/**
- * This function aims to clean-up the SSL context which
- * we allocated.
- */
-static void shutdown_ssl(void)
+static void *git_openssl_realloc(void *mem, size_t size)
{
- if (git_stream_bio_method) {
- BIO_meth_free(git_stream_bio_method);
- git_stream_bio_method = NULL;
- }
+ return git__realloc(mem, size);
+}
- if (git__ssl_ctx) {
- SSL_CTX_free(git__ssl_ctx);
- git__ssl_ctx = NULL;
- }
+static void git_openssl_free(void *mem)
+{
+ git__free(mem);
}
+# endif /* !GIT_OPENSSL_LEGACY && !GIT_OPENSSL_DYNAMIC */
+#endif /* VALGRIND */
-int git_openssl_stream_global_init(void)
+static int openssl_init(void)
{
long ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
const char *ciphers = git_libgit2__ssl_ciphers();
+#ifdef VALGRIND
+ static bool allocators_initialized = false;
+#endif
/* Older OpenSSL and MacOS OpenSSL doesn't have this */
#ifdef SSL_OP_NO_COMPRESSION
ssl_opts |= SSL_OP_NO_COMPRESSION;
#endif
+#ifdef VALGRIND
+ /*
+ * Swap in our own allocator functions that initialize
+ * allocated memory to avoid spurious valgrind warnings.
+ * Don't error on failure; many builds of OpenSSL do not
+ * allow you to set these functions.
+ */
+ if (!allocators_initialized) {
+ CRYPTO_set_mem_functions(git_openssl_malloc,
+ git_openssl_realloc,
+ git_openssl_free);
+ allocators_initialized = true;
+ }
+#endif
+
OPENSSL_init_ssl(0, NULL);
/*
@@ -236,9 +156,7 @@ int git_openssl_stream_global_init(void)
if (init_bio_method() < 0)
goto error;
- git__on_shutdown(shutdown_ssl);
-
- return 0;
+ return git_runtime_shutdown_register(shutdown_ssl);
error:
git_error_set(GIT_ERROR_NET, "could not initialize openssl: %s",
@@ -248,42 +166,60 @@ error:
return -1;
}
-#if defined(GIT_THREADS) && defined(OPENSSL_LEGACY_API)
-static void threadid_cb(CRYPTO_THREADID *threadid)
+/*
+ * When we use dynamic loading, we defer OpenSSL initialization until
+ * it's first used. `openssl_ensure_initialized` will do the work
+ * under a mutex.
+ */
+git_mutex openssl_mutex;
+bool openssl_initialized;
+
+int git_openssl_stream_global_init(void)
{
- GIT_UNUSED(threadid);
- CRYPTO_THREADID_set_numeric(threadid, git_thread_currentid());
-}
+#ifndef GIT_OPENSSL_DYNAMIC
+ return openssl_init();
+#else
+ if (git_mutex_init(&openssl_mutex) != 0)
+ return -1;
+
+ return 0;
#endif
+}
-int git_openssl_set_locking(void)
+static int openssl_ensure_initialized(void)
{
-#if defined(GIT_THREADS) && defined(OPENSSL_LEGACY_API)
- int num_locks, i;
+#ifdef GIT_OPENSSL_DYNAMIC
+ int error = 0;
- CRYPTO_THREADID_set_callback(threadid_cb);
+ if (git_mutex_lock(&openssl_mutex) != 0)
+ return -1;
- num_locks = CRYPTO_num_locks();
- openssl_locks = git__calloc(num_locks, sizeof(git_mutex));
- GIT_ERROR_CHECK_ALLOC(openssl_locks);
+ if (!openssl_initialized) {
+ if ((error = git_openssl_stream_dynamic_init()) == 0)
+ error = openssl_init();
- for (i = 0; i < num_locks; i++) {
- if (git_mutex_init(&openssl_locks[i]) != 0) {
- git_error_set(GIT_ERROR_SSL, "failed to initialize openssl locks");
- return -1;
- }
+ openssl_initialized = true;
}
- CRYPTO_set_locking_callback(openssl_locking_function);
- git__on_shutdown(shutdown_ssl_locking);
+ error |= git_mutex_unlock(&openssl_mutex);
+ return error;
+
+#else
return 0;
-#elif !defined(OPENSSL_LEGACY_API)
+#endif
+}
+
+#if !defined(GIT_OPENSSL_LEGACY) && !defined(GIT_OPENSSL_DYNAMIC)
+int git_openssl_set_locking(void)
+{
+# ifdef GIT_THREADS
return 0;
-#else
+# else
git_error_set(GIT_ERROR_THREAD, "libgit2 was not built with threads");
return -1;
-#endif
+# endif
}
+#endif
static int bio_create(BIO *b)
@@ -314,11 +250,6 @@ static int bio_read(BIO *b, char *buf, int len)
static int bio_write(BIO *b, const char *buf, int len)
{
git_stream *io = (git_stream *) BIO_get_data(b);
-
-#ifdef VALGRIND
- VALGRIND_MAKE_MEM_DEFINED(buf, len);
-#endif
-
return (int) git_stream_write(io, buf, len, 0);
}
@@ -371,8 +302,8 @@ static int ssl_set_error(SSL *ssl, int error)
err = SSL_get_error(ssl, error);
- assert(err != SSL_ERROR_WANT_READ);
- assert(err != SSL_ERROR_WANT_WRITE);
+ GIT_ASSERT(err != SSL_ERROR_WANT_READ);
+ GIT_ASSERT(err != SSL_ERROR_WANT_WRITE);
switch (err) {
case SSL_ERROR_WANT_CONNECT:
@@ -595,10 +526,6 @@ static int openssl_connect(git_stream *stream)
BIO_set_data(bio, st->io);
SSL_set_bio(st->ssl, bio, bio);
-#ifdef VALGRIND
- VALGRIND_MAKE_MEM_DEFINED(st->ssl, sizeof(SSL));
-#endif
-
/* specify the host in case SNI is needed */
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
SSL_set_tlsext_host_name(st->ssl, st->host);
@@ -609,25 +536,22 @@ static int openssl_connect(git_stream *stream)
st->connected = true;
-#ifdef VALGRIND
- VALGRIND_MAKE_MEM_DEFINED(st->ssl, sizeof(SSL));
-#endif
-
return verify_server_cert(st->ssl, st->host);
}
static int openssl_certificate(git_cert **out, git_stream *stream)
{
openssl_stream *st = (openssl_stream *) stream;
- int len;
X509 *cert = SSL_get_peer_certificate(st->ssl);
- unsigned char *guard, *encoded_cert;
+ unsigned char *guard, *encoded_cert = NULL;
+ int error, len;
/* Retrieve the length of the certificate first */
len = i2d_X509(cert, NULL);
if (len < 0) {
git_error_set(GIT_ERROR_NET, "failed to retrieve certificate information");
- return -1;
+ error = -1;
+ goto out;
}
encoded_cert = git__malloc(len);
@@ -637,18 +561,23 @@ static int openssl_certificate(git_cert **out, git_stream *stream)
len = i2d_X509(cert, &guard);
if (len < 0) {
- git__free(encoded_cert);
git_error_set(GIT_ERROR_NET, "failed to retrieve certificate information");
- return -1;
+ error = -1;
+ goto out;
}
st->cert_info.parent.cert_type = GIT_CERT_X509;
st->cert_info.data = encoded_cert;
st->cert_info.len = len;
+ encoded_cert = NULL;
*out = &st->cert_info.parent;
+ error = 0;
- return 0;
+out:
+ git__free(encoded_cert);
+ X509_free(cert);
+ return error;
}
static int openssl_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts)
@@ -679,10 +608,6 @@ static ssize_t openssl_read(git_stream *stream, void *data, size_t len)
if ((ret = SSL_read(st->ssl, data, len)) <= 0)
return ssl_set_error(st->ssl, ret);
-#ifdef VALGRIND
- VALGRIND_MAKE_MEM_DEFINED(data, ret);
-#endif
-
return ret;
}
@@ -720,7 +645,9 @@ static int openssl_stream_wrap(
{
openssl_stream *st;
- assert(out && in && host);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(in);
+ GIT_ASSERT_ARG(host);
st = git__calloc(1, sizeof(openssl_stream));
GIT_ERROR_CHECK_ALLOC(st);
@@ -755,6 +682,9 @@ static int openssl_stream_wrap(
int git_openssl_stream_wrap(git_stream **out, git_stream *in, const char *host)
{
+ if (openssl_ensure_initialized() < 0)
+ return -1;
+
return openssl_stream_wrap(out, in, host, 0);
}
@@ -763,7 +693,12 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
git_stream *stream = NULL;
int error;
- assert(out && host && port);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(host);
+ GIT_ASSERT_ARG(port);
+
+ if (openssl_ensure_initialized() < 0)
+ return -1;
if ((error = git_socket_stream_new(&stream, host, port)) < 0)
return error;
@@ -778,6 +713,9 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
int git_openssl__set_cert_location(const char *file, const char *path)
{
+ if (openssl_ensure_initialized() < 0)
+ return -1;
+
if (SSL_CTX_load_verify_locations(git__ssl_ctx, file, path) == 0) {
char errmsg[256];
diff --git a/src/streams/openssl.h b/src/streams/openssl.h
index 826d1ef..89fb60a 100644
--- a/src/streams/openssl.h
+++ b/src/streams/openssl.h
@@ -8,14 +8,22 @@
#define INCLUDE_streams_openssl_h__
#include "common.h"
+#include "streams/openssl_legacy.h"
+#include "streams/openssl_dynamic.h"
#include "git2/sys/stream.h"
extern int git_openssl_stream_global_init(void);
+#if defined(GIT_OPENSSL) && !defined(GIT_OPENSSL_DYNAMIC)
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+# include <openssl/x509v3.h>
+# include <openssl/bio.h>
+# endif
+
#ifdef GIT_OPENSSL
extern int git_openssl__set_cert_location(const char *file, const char *path);
-
extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port);
extern int git_openssl_stream_wrap(git_stream **out, git_stream *in, const char *host);
#endif
diff --git a/src/streams/openssl_dynamic.c b/src/streams/openssl_dynamic.c
new file mode 100644
index 0000000..da16b6e
--- /dev/null
+++ b/src/streams/openssl_dynamic.c
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "streams/openssl.h"
+#include "streams/openssl_dynamic.h"
+
+#if defined(GIT_OPENSSL) && defined(GIT_OPENSSL_DYNAMIC)
+
+#include "runtime.h"
+
+#include <dlfcn.h>
+
+unsigned char *(*ASN1_STRING_data)(ASN1_STRING *x);
+const unsigned char *(*ASN1_STRING_get0_data)(const ASN1_STRING *x);
+int (*ASN1_STRING_length)(const ASN1_STRING *x);
+int (*ASN1_STRING_to_UTF8)(unsigned char **out, const ASN1_STRING *in);
+int (*ASN1_STRING_type)(const ASN1_STRING *x);
+
+void *(*BIO_get_data)(BIO *a);
+int (*BIO_get_new_index)(void);
+int (*OPENSSL_init_ssl)(uint64_t opts, const void *settings);
+void (*BIO_meth_free)(BIO_METHOD *biom);
+int (*BIO_meth_set_create)(BIO_METHOD *biom, int (*create) (BIO *));
+int (*BIO_meth_set_ctrl)(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *));
+int (*BIO_meth_set_destroy)(BIO_METHOD *biom, int (*destroy) (BIO *));
+int (*BIO_meth_set_gets)(BIO_METHOD *biom, int (*gets) (BIO *, char *, int));
+int (*BIO_meth_set_puts)(BIO_METHOD *biom, int (*puts) (BIO *, const char *));
+int (*BIO_meth_set_read)(BIO_METHOD *biom, int (*read) (BIO *, char *, int));
+int (*BIO_meth_set_write)(BIO_METHOD *biom, int (*write) (BIO *, const char *, int));
+BIO_METHOD *(*BIO_meth_new)(int type, const char *name);
+BIO *(*BIO_new)(const BIO_METHOD *type);
+void (*BIO_set_data)(BIO *a, void *ptr);
+void (*BIO_set_init)(BIO *a, int init);
+
+void (*CRYPTO_free)(void *ptr, const char *file, int line);
+void *(*CRYPTO_malloc)(size_t num, const char *file, int line);
+int (*CRYPTO_num_locks)(void);
+void (*CRYPTO_set_locking_callback)(void (*func)(int mode, int type, const char *file, int line));
+int (*CRYPTO_set_mem_functions)(void *(*m)(size_t bytes), void *(*r)(void *mem, size_t size), void (*f)(void *mem));
+int (*CRYPTO_THREADID_set_callback)(void (*func)(CRYPTO_THREADID *id));
+void (*CRYPTO_THREADID_set_numeric)(CRYPTO_THREADID *id, unsigned long val);
+
+char *(*ERR_error_string)(unsigned long e, char *buf);
+void (*ERR_error_string_n)(unsigned long e, char *buf, size_t len);
+unsigned long (*ERR_get_error)(void);
+
+int (*SSL_connect)(SSL *ssl);
+long (*SSL_ctrl)(SSL *ssl, int cmd, long arg, void *parg);
+void (*SSL_free)(SSL *ssl);
+int (*SSL_get_error)(SSL *ssl, int ret);
+X509 *(*SSL_get_peer_certificate)(const SSL *ssl);
+long (*SSL_get_verify_result)(const SSL *ssl);
+int (*SSL_library_init)(void);
+void (*SSL_load_error_strings)(void);
+SSL *(*SSL_new)(SSL_CTX *ctx);
+int (*SSL_read)(SSL *ssl, const void *buf, int num);
+void (*SSL_set_bio)(SSL *ssl, BIO *rbio, BIO *wbio);
+int (*SSL_shutdown)(SSL *ssl);
+int (*SSL_write)(SSL *ssl, const void *buf, int num);
+
+long (*SSL_CTX_ctrl)(SSL_CTX *ctx, int cmd, long larg, void *parg);
+void (*SSL_CTX_free)(SSL_CTX *ctx);
+SSL_CTX *(*SSL_CTX_new)(const SSL_METHOD *method);
+int (*SSL_CTX_set_cipher_list)(SSL_CTX *ctx, const char *str);
+int (*SSL_CTX_set_default_verify_paths)(SSL_CTX *ctx);
+long (*SSL_CTX_set_options)(SSL_CTX *ctx, long options);
+void (*SSL_CTX_set_verify)(SSL_CTX *ctx, int mode, int (*verify_callback)(int, X509_STORE_CTX *));
+int (*SSL_CTX_load_verify_locations)(SSL_CTX *ctx, const char *CAfile, const char *CApath);
+
+const SSL_METHOD *(*SSLv23_method)(void);
+const SSL_METHOD *(*TLS_method)(void);
+
+ASN1_STRING *(*X509_NAME_ENTRY_get_data)(const X509_NAME_ENTRY *ne);
+X509_NAME_ENTRY *(*X509_NAME_get_entry)(X509_NAME *name, int loc);
+int (*X509_NAME_get_index_by_NID)(X509_NAME *name, int nid, int lastpos);
+void (*X509_free)(X509 *a);
+void *(*X509_get_ext_d2i)(const X509 *x, int nid, int *crit, int *idx);
+X509_NAME *(*X509_get_subject_name)(const X509 *x);
+
+int (*i2d_X509)(X509 *a, unsigned char **ppout);
+
+int (*OPENSSL_sk_num)(const void *sk);
+void *(*OPENSSL_sk_value)(const void *sk, int i);
+void (*OPENSSL_sk_free)(void *sk);
+
+int (*sk_num)(const void *sk);
+void *(*sk_value)(const void *sk, int i);
+void (*sk_free)(void *sk);
+
+void *openssl_handle;
+
+GIT_INLINE(void *) openssl_sym(int *err, const char *name, bool required)
+{
+ void *symbol;
+
+ /* if we've seen an err, noop to retain it */
+ if (*err)
+ return NULL;
+
+
+ if ((symbol = dlsym(openssl_handle, name)) == NULL && required) {
+ const char *msg = dlerror();
+ git_error_set(GIT_ERROR_SSL, "could not load ssl function '%s': %s", name, msg ? msg : "unknown error");
+ *err = -1;
+ }
+
+ return symbol;
+}
+
+static void dynamic_shutdown(void)
+{
+ dlclose(openssl_handle);
+ openssl_handle = NULL;
+}
+
+int git_openssl_stream_dynamic_init(void)
+{
+ int err = 0;
+
+ if ((openssl_handle = dlopen("libssl.so.1.1", RTLD_NOW)) == NULL &&
+ (openssl_handle = dlopen("libssl.1.1.dylib", RTLD_NOW)) == NULL &&
+ (openssl_handle = dlopen("libssl.so.1.0.0", RTLD_NOW)) == NULL &&
+ (openssl_handle = dlopen("libssl.1.0.0.dylib", RTLD_NOW)) == NULL &&
+ (openssl_handle = dlopen("libssl.so.10", RTLD_NOW)) == NULL) {
+ git_error_set(GIT_ERROR_SSL, "could not load ssl libraries");
+ return -1;
+ }
+
+ ASN1_STRING_data = (unsigned char *(*)(ASN1_STRING *x))openssl_sym(&err, "ASN1_STRING_data", false);
+ ASN1_STRING_get0_data = (const unsigned char *(*)(const ASN1_STRING *x))openssl_sym(&err, "ASN1_STRING_get0_data", false);
+ ASN1_STRING_length = (int (*)(const ASN1_STRING *))openssl_sym(&err, "ASN1_STRING_length", true);
+ ASN1_STRING_to_UTF8 = (int (*)(unsigned char **, const ASN1_STRING *))openssl_sym(&err, "ASN1_STRING_to_UTF8", true);
+ ASN1_STRING_type = (int (*)(const ASN1_STRING *))openssl_sym(&err, "ASN1_STRING_type", true);
+
+ BIO_get_data = (void *(*)(BIO *))openssl_sym(&err, "BIO_get_data", false);
+ BIO_get_new_index = (int (*)(void))openssl_sym(&err, "BIO_get_new_index", false);
+ BIO_meth_free = (void (*)(BIO_METHOD *))openssl_sym(&err, "BIO_meth_free", false);
+ BIO_meth_new = (BIO_METHOD *(*)(int, const char *))openssl_sym(&err, "BIO_meth_new", false);
+ BIO_meth_set_create = (int (*)(BIO_METHOD *, int (*)(BIO *)))openssl_sym(&err, "BIO_meth_set_create", false);
+ BIO_meth_set_ctrl = (int (*)(BIO_METHOD *, long (*)(BIO *, int, long, void *)))openssl_sym(&err, "BIO_meth_set_ctrl", false);
+ BIO_meth_set_destroy = (int (*)(BIO_METHOD *, int (*)(BIO *)))openssl_sym(&err, "BIO_meth_set_destroy", false);
+ BIO_meth_set_gets = (int (*)(BIO_METHOD *, int (*)(BIO *, char *, int)))openssl_sym(&err, "BIO_meth_set_gets", false);
+ BIO_meth_set_puts = (int (*)(BIO_METHOD *, int (*)(BIO *, const char *)))openssl_sym(&err, "BIO_meth_set_puts", false);
+ BIO_meth_set_read = (int (*)(BIO_METHOD *, int (*)(BIO *, char *, int)))openssl_sym(&err, "BIO_meth_set_read", false);
+ BIO_meth_set_write = (int (*)(BIO_METHOD *, int (*)(BIO *, const char *, int)))openssl_sym(&err, "BIO_meth_set_write", false);
+ BIO_new = (BIO *(*)(const BIO_METHOD *))openssl_sym(&err, "BIO_new", true);
+ BIO_set_data = (void (*)(BIO *a, void *))openssl_sym(&err, "BIO_set_data", false);
+ BIO_set_init = (void (*)(BIO *a, int))openssl_sym(&err, "BIO_set_init", false);
+
+ CRYPTO_free = (void (*)(void *, const char *, int))openssl_sym(&err, "CRYPTO_free", true);
+ CRYPTO_malloc = (void *(*)(size_t, const char *, int))openssl_sym(&err, "CRYPTO_malloc", true);
+ CRYPTO_num_locks = (int (*)(void))openssl_sym(&err, "CRYPTO_num_locks", false);
+ CRYPTO_set_locking_callback = (void (*)(void (*)(int, int, const char *, int)))openssl_sym(&err, "CRYPTO_set_locking_callback", false);
+ CRYPTO_set_mem_functions = (int (*)(void *(*)(size_t), void *(*)(void *, size_t), void (*f)(void *)))openssl_sym(&err, "CRYPTO_set_mem_functions", true);
+
+ CRYPTO_THREADID_set_callback = (int (*)(void (*)(CRYPTO_THREADID *)))openssl_sym(&err, "CRYPTO_THREADID_set_callback", false);
+ CRYPTO_THREADID_set_numeric = (void (*)(CRYPTO_THREADID *, unsigned long))openssl_sym(&err, "CRYPTO_THREADID_set_numeric", false);
+
+ ERR_error_string = (char *(*)(unsigned long, char *))openssl_sym(&err, "ERR_error_string", true);
+ ERR_error_string_n = (void (*)(unsigned long, char *, size_t))openssl_sym(&err, "ERR_error_string_n", true);
+ ERR_get_error = (unsigned long (*)(void))openssl_sym(&err, "ERR_get_error", true);
+
+ OPENSSL_init_ssl = (int (*)(uint64_t opts, const void *settings))openssl_sym(&err, "OPENSSL_init_ssl", false);
+ OPENSSL_sk_num = (int (*)(const void *))openssl_sym(&err, "OPENSSL_sk_num", false);
+ OPENSSL_sk_value = (void *(*)(const void *sk, int i))openssl_sym(&err, "OPENSSL_sk_value", false);
+ OPENSSL_sk_free = (void (*)(void *))openssl_sym(&err, "OPENSSL_sk_free", false);
+
+ sk_num = (int (*)(const void *))openssl_sym(&err, "sk_num", false);
+ sk_value = (void *(*)(const void *sk, int i))openssl_sym(&err, "sk_value", false);
+ sk_free = (void (*)(void *))openssl_sym(&err, "sk_free", false);
+
+ SSL_connect = (int (*)(SSL *))openssl_sym(&err, "SSL_connect", true);
+ SSL_ctrl = (long (*)(SSL *, int, long, void *))openssl_sym(&err, "SSL_ctrl", true);
+ SSL_get_peer_certificate = (X509 *(*)(const SSL *))openssl_sym(&err, "SSL_get_peer_certificate", true);
+ SSL_library_init = (int (*)(void))openssl_sym(&err, "SSL_library_init", false);
+ SSL_free = (void (*)(SSL *))openssl_sym(&err, "SSL_free", true);
+ SSL_get_error = (int (*)(SSL *, int))openssl_sym(&err, "SSL_get_error", true);
+ SSL_get_verify_result = (long (*)(const SSL *ssl))openssl_sym(&err, "SSL_get_verify_result", true);
+ SSL_load_error_strings = (void (*)(void))openssl_sym(&err, "SSL_load_error_strings", false);
+ SSL_new = (SSL *(*)(SSL_CTX *))openssl_sym(&err, "SSL_new", true);
+ SSL_read = (int (*)(SSL *, const void *, int))openssl_sym(&err, "SSL_read", true);
+ SSL_set_bio = (void (*)(SSL *, BIO *, BIO *))openssl_sym(&err, "SSL_set_bio", true);
+ SSL_shutdown = (int (*)(SSL *ssl))openssl_sym(&err, "SSL_shutdown", true);
+ SSL_write = (int (*)(SSL *, const void *, int))openssl_sym(&err, "SSL_write", true);
+
+ SSL_CTX_ctrl = (long (*)(SSL_CTX *, int, long, void *))openssl_sym(&err, "SSL_CTX_ctrl", true);
+ SSL_CTX_free = (void (*)(SSL_CTX *))openssl_sym(&err, "SSL_CTX_free", true);
+ SSL_CTX_new = (SSL_CTX *(*)(const SSL_METHOD *))openssl_sym(&err, "SSL_CTX_new", true);
+ SSL_CTX_set_cipher_list = (int (*)(SSL_CTX *, const char *))openssl_sym(&err, "SSL_CTX_set_cipher_list", true);
+ SSL_CTX_set_default_verify_paths = (int (*)(SSL_CTX *ctx))openssl_sym(&err, "SSL_CTX_set_default_verify_paths", true);
+ SSL_CTX_set_options = (long (*)(SSL_CTX *, long))openssl_sym(&err, "SSL_CTX_set_options", false);
+ SSL_CTX_set_verify = (void (*)(SSL_CTX *, int, int (*)(int, X509_STORE_CTX *)))openssl_sym(&err, "SSL_CTX_set_verify", true);
+ SSL_CTX_load_verify_locations = (int (*)(SSL_CTX *, const char *, const char *))openssl_sym(&err, "SSL_CTX_load_verify_locations", true);
+
+ SSLv23_method = (const SSL_METHOD *(*)(void))openssl_sym(&err, "SSLv23_method", false);
+ TLS_method = (const SSL_METHOD *(*)(void))openssl_sym(&err, "TLS_method", false);
+
+ X509_NAME_ENTRY_get_data = (ASN1_STRING *(*)(const X509_NAME_ENTRY *))openssl_sym(&err, "X509_NAME_ENTRY_get_data", true);
+ X509_NAME_get_entry = (X509_NAME_ENTRY *(*)(X509_NAME *, int))openssl_sym(&err, "X509_NAME_get_entry", true);
+ X509_NAME_get_index_by_NID = (int (*)(X509_NAME *, int, int))openssl_sym(&err, "X509_NAME_get_index_by_NID", true);
+ X509_free = (void (*)(X509 *))openssl_sym(&err, "X509_free", true);
+ X509_get_ext_d2i = (void *(*)(const X509 *x, int nid, int *crit, int *idx))openssl_sym(&err, "X509_get_ext_d2i", true);
+ X509_get_subject_name = (X509_NAME *(*)(const X509 *))openssl_sym(&err, "X509_get_subject_name", true);
+
+ i2d_X509 = (int (*)(X509 *a, unsigned char **ppout))openssl_sym(&err, "i2d_X509", true);
+
+ if (err)
+ goto on_error;
+
+ /* Add legacy functionality */
+ if (!OPENSSL_init_ssl) {
+ OPENSSL_init_ssl = OPENSSL_init_ssl__legacy;
+
+ if (!SSL_library_init ||
+ !SSL_load_error_strings ||
+ !CRYPTO_num_locks ||
+ !CRYPTO_set_locking_callback ||
+ !CRYPTO_THREADID_set_callback ||
+ !CRYPTO_THREADID_set_numeric) {
+ git_error_set(GIT_ERROR_SSL, "could not load legacy openssl initialization functions");
+ goto on_error;
+ }
+ }
+
+ if (!SSL_CTX_set_options)
+ SSL_CTX_set_options = SSL_CTX_set_options__legacy;
+
+ if (TLS_method)
+ SSLv23_method = TLS_method;
+
+ if (!BIO_meth_new) {
+ BIO_meth_new = BIO_meth_new__legacy;
+ BIO_meth_new = BIO_meth_new__legacy;
+ BIO_meth_free = BIO_meth_free__legacy;
+ BIO_meth_set_write = BIO_meth_set_write__legacy;
+ BIO_meth_set_read = BIO_meth_set_read__legacy;
+ BIO_meth_set_puts = BIO_meth_set_puts__legacy;
+ BIO_meth_set_gets = BIO_meth_set_gets__legacy;
+ BIO_meth_set_ctrl = BIO_meth_set_ctrl__legacy;
+ BIO_meth_set_create = BIO_meth_set_create__legacy;
+ BIO_meth_set_destroy = BIO_meth_set_destroy__legacy;
+ BIO_get_new_index = BIO_get_new_index__legacy;
+ BIO_set_data = BIO_set_data__legacy;
+ BIO_set_init = BIO_set_init__legacy;
+ BIO_get_data = BIO_get_data__legacy;
+ }
+
+ if (!ASN1_STRING_get0_data) {
+ if (!ASN1_STRING_data) {
+ git_error_set(GIT_ERROR_SSL, "could not load legacy openssl string function");
+ goto on_error;
+ }
+
+ ASN1_STRING_get0_data = ASN1_STRING_get0_data__legacy;
+ }
+
+ if ((!OPENSSL_sk_num && !sk_num) ||
+ (!OPENSSL_sk_value && !sk_value) ||
+ (!OPENSSL_sk_free && !sk_free)) {
+ git_error_set(GIT_ERROR_SSL, "could not load legacy openssl stack functions");
+ goto on_error;
+ }
+
+ if (git_runtime_shutdown_register(dynamic_shutdown) != 0)
+ goto on_error;
+
+ return 0;
+
+on_error:
+ dlclose(openssl_handle);
+ return -1;
+}
+
+
+int sk_GENERAL_NAME_num(const GENERAL_NAME *sk)
+{
+ if (OPENSSL_sk_num)
+ return OPENSSL_sk_num(sk);
+ else if (sk_num)
+ return sk_num(sk);
+
+ GIT_ASSERT_WITH_RETVAL(false, 0);
+ return 0;
+}
+
+GENERAL_NAME *sk_GENERAL_NAME_value(const GENERAL_NAME *sk, int i)
+{
+ if (OPENSSL_sk_value)
+ return OPENSSL_sk_value(sk, i);
+ else if (sk_value)
+ return sk_value(sk, i);
+
+ GIT_ASSERT_WITH_RETVAL(false, NULL);
+ return NULL;
+}
+
+void GENERAL_NAMES_free(GENERAL_NAME *sk)
+{
+ if (OPENSSL_sk_free)
+ OPENSSL_sk_free(sk);
+ else if (sk_free)
+ sk_free(sk);
+}
+
+#endif /* GIT_OPENSSL && GIT_OPENSSL_DYNAMIC */
diff --git a/src/streams/openssl_dynamic.h b/src/streams/openssl_dynamic.h
new file mode 100644
index 0000000..12d927a
--- /dev/null
+++ b/src/streams/openssl_dynamic.h
@@ -0,0 +1,348 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ * ECC cipher suite support in OpenSSL originally developed by
+ * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
+ */
+/* ====================================================================
+ * Copyright 2005 Nokia. All rights reserved.
+ *
+ * The portions of the attached software ("Contribution") is developed by
+ * Nokia Corporation and is licensed pursuant to the OpenSSL open source
+ * license.
+ *
+ * The Contribution, originally written by Mika Kousa and Pasi Eronen of
+ * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
+ * support (see RFC 4279) to OpenSSL.
+ *
+ * No patent licenses or other rights except those expressly stated in
+ * the OpenSSL open source license shall be deemed granted or received
+ * expressly, by implication, estoppel, or otherwise.
+ *
+ * No assurances are provided by Nokia that the Contribution does not
+ * infringe the patent or other intellectual property rights of any third
+ * party or that the license provides you with all the necessary rights
+ * to make use of the Contribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
+ * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
+ * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
+ * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
+ * OTHERWISE.
+ */
+
+#ifndef INCLUDE_streams_openssl_dynamic_h__
+#define INCLUDE_streams_openssl_dynamic_h__
+
+#ifdef GIT_OPENSSL_DYNAMIC
+
+# define BIO_CTRL_FLUSH 11
+
+# define BIO_TYPE_SOURCE_SINK 0x0400
+
+# define CRYPTO_LOCK 1
+
+# define GEN_DNS 2
+# define GEN_IPADD 7
+
+# define NID_commonName 13
+# define NID_subject_alt_name 85
+
+# define SSL_VERIFY_NONE 0x00
+
+# define SSL_CTRL_OPTIONS 32
+# define SSL_CTRL_MODE 33
+# define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
+
+# define SSL_ERROR_NONE 0
+# define SSL_ERROR_SSL 1
+# define SSL_ERROR_WANT_READ 2
+# define SSL_ERROR_WANT_WRITE 3
+# define SSL_ERROR_WANT_X509_LOOKUP 4
+# define SSL_ERROR_SYSCALL 5
+# define SSL_ERROR_ZERO_RETURN 6
+# define SSL_ERROR_WANT_CONNECT 7
+# define SSL_ERROR_WANT_ACCEPT 8
+
+# define SSL_OP_NO_COMPRESSION 0x00020000L
+# define SSL_OP_NO_SSLv2 0x01000000L
+# define SSL_OP_NO_SSLv3 0x02000000L
+
+# define SSL_MODE_AUTO_RETRY 0x00000004L
+
+# define TLSEXT_NAMETYPE_host_name 0
+
+# define V_ASN1_UTF8STRING 12
+
+# define X509_V_OK 0
+
+/* Most of the OpenSSL types are mercifully opaque, so we can treat them like `void *` */
+typedef struct bio_st BIO;
+typedef struct bio_method_st BIO_METHOD;
+typedef void bio_info_cb;
+typedef void * CRYPTO_EX_DATA;
+typedef void CRYPTO_THREADID;
+typedef void GENERAL_NAMES;
+typedef void SSL;
+typedef void SSL_CTX;
+typedef void SSL_METHOD;
+typedef void X509;
+typedef void X509_NAME;
+typedef void X509_NAME_ENTRY;
+typedef void X509_STORE_CTX;
+
+typedef struct {
+ int length;
+ int type;
+ unsigned char *data;
+ long flags;
+} ASN1_STRING;
+
+typedef struct {
+ int type;
+ union {
+ char *ptr;
+ ASN1_STRING *ia5;
+ } d;
+} GENERAL_NAME;
+
+struct bio_st {
+ BIO_METHOD *method;
+ /* bio, mode, argp, argi, argl, ret */
+ long (*callback) (struct bio_st *, int, const char *, int, long, long);
+ char *cb_arg; /* first argument for the callback */
+ int init;
+ int shutdown;
+ int flags; /* extra storage */
+ int retry_reason;
+ int num;
+ void *ptr;
+ struct bio_st *next_bio; /* used by filter BIOs */
+ struct bio_st *prev_bio; /* used by filter BIOs */
+ int references;
+ unsigned long num_read;
+ unsigned long num_write;
+ CRYPTO_EX_DATA ex_data;
+};
+
+struct bio_method_st {
+ int type;
+ const char *name;
+ int (*bwrite) (BIO *, const char *, int);
+ int (*bread) (BIO *, char *, int);
+ int (*bputs) (BIO *, const char *);
+ int (*bgets) (BIO *, char *, int);
+ long (*ctrl) (BIO *, int, long, void *);
+ int (*create) (BIO *);
+ int (*destroy) (BIO *);
+ long (*callback_ctrl) (BIO *, int, bio_info_cb *);
+};
+
+extern unsigned char *(*ASN1_STRING_data)(ASN1_STRING *x);
+extern const unsigned char *(*ASN1_STRING_get0_data)(const ASN1_STRING *x);
+extern int (*ASN1_STRING_length)(const ASN1_STRING *x);
+extern int (*ASN1_STRING_to_UTF8)(unsigned char **out, const ASN1_STRING *in);
+extern int (*ASN1_STRING_type)(const ASN1_STRING *x);
+
+extern void *(*BIO_get_data)(BIO *a);
+extern int (*BIO_get_new_index)(void);
+extern int (*OPENSSL_init_ssl)(uint64_t opts, const void *settings);
+extern void (*BIO_meth_free)(BIO_METHOD *biom);
+extern int (*BIO_meth_set_create)(BIO_METHOD *biom, int (*create) (BIO *));
+extern int (*BIO_meth_set_ctrl)(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *));
+extern int (*BIO_meth_set_destroy)(BIO_METHOD *biom, int (*destroy) (BIO *));
+extern int (*BIO_meth_set_gets)(BIO_METHOD *biom, int (*gets) (BIO *, char *, int));
+extern int (*BIO_meth_set_puts)(BIO_METHOD *biom, int (*puts) (BIO *, const char *));
+extern int (*BIO_meth_set_read)(BIO_METHOD *biom, int (*read) (BIO *, char *, int));
+extern int (*BIO_meth_set_write)(BIO_METHOD *biom, int (*write) (BIO *, const char *, int));
+extern BIO_METHOD *(*BIO_meth_new)(int type, const char *name);
+extern BIO *(*BIO_new)(const BIO_METHOD *type);
+extern void (*BIO_set_data)(BIO *a, void *ptr);
+extern void (*BIO_set_init)(BIO *a, int init);
+
+extern void (*CRYPTO_free)(void *ptr, const char *file, int line);
+extern void *(*CRYPTO_malloc)(size_t num, const char *file, int line);
+extern int (*CRYPTO_num_locks)(void);
+extern void (*CRYPTO_set_locking_callback)(void (*func)(int mode, int type, const char *file, int line));
+extern int (*CRYPTO_set_mem_functions)(void *(*m)(size_t bytes), void *(*r)(void *mem, size_t size), void (*f)(void *mem));
+extern int (*CRYPTO_THREADID_set_callback)(void (*func)(CRYPTO_THREADID *id));
+extern void (*CRYPTO_THREADID_set_numeric)(CRYPTO_THREADID *id, unsigned long val);
+
+extern char *(*ERR_error_string)(unsigned long e, char *buf);
+extern void (*ERR_error_string_n)(unsigned long e, char *buf, size_t len);
+extern unsigned long (*ERR_get_error)(void);
+
+# define OPENSSL_malloc(num) CRYPTO_malloc(num, __FILE__, __LINE__)
+# define OPENSSL_free(addr) CRYPTO_free(addr, __FILE__, __LINE__)
+
+extern int (*SSL_connect)(SSL *ssl);
+extern long (*SSL_ctrl)(SSL *ssl, int cmd, long arg, void *parg);
+extern void (*SSL_free)(SSL *ssl);
+extern int (*SSL_get_error)(SSL *ssl, int ret);
+extern X509 *(*SSL_get_peer_certificate)(const SSL *ssl);
+extern long (*SSL_get_verify_result)(const SSL *ssl);
+extern int (*SSL_library_init)(void);
+extern void (*SSL_load_error_strings)(void);
+extern SSL *(*SSL_new)(SSL_CTX *ctx);
+extern int (*SSL_read)(SSL *ssl, const void *buf, int num);
+extern void (*SSL_set_bio)(SSL *ssl, BIO *rbio, BIO *wbio);
+extern int (*SSL_shutdown)(SSL *ssl);
+extern int (*SSL_write)(SSL *ssl, const void *buf, int num);
+
+# define SSL_set_tlsext_host_name(s, name) SSL_ctrl((s), SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, (char *)(name));
+
+extern long (*SSL_CTX_ctrl)(SSL_CTX *ctx, int cmd, long larg, void *parg);
+extern void (*SSL_CTX_free)(SSL_CTX *ctx);
+extern SSL_CTX *(*SSL_CTX_new)(const SSL_METHOD *method);
+extern int (*SSL_CTX_set_cipher_list)(SSL_CTX *ctx, const char *str);
+extern int (*SSL_CTX_set_default_verify_paths)(SSL_CTX *ctx);
+extern long (*SSL_CTX_set_options)(SSL_CTX *ctx, long options);
+extern void (*SSL_CTX_set_verify)(SSL_CTX *ctx, int mode, int (*verify_callback)(int, X509_STORE_CTX *));
+extern int (*SSL_CTX_load_verify_locations)(SSL_CTX *ctx, const char *CAfile, const char *CApath);
+
+# define SSL_CTX_set_mode(ctx, mode) SSL_CTX_ctrl((ctx), SSL_CTRL_MODE, (mode), NULL);
+
+extern const SSL_METHOD *(*SSLv23_method)(void);
+extern const SSL_METHOD *(*TLS_method)(void);
+
+extern ASN1_STRING *(*X509_NAME_ENTRY_get_data)(const X509_NAME_ENTRY *ne);
+extern X509_NAME_ENTRY *(*X509_NAME_get_entry)(X509_NAME *name, int loc);
+extern int (*X509_NAME_get_index_by_NID)(X509_NAME *name, int nid, int lastpos);
+extern void (*X509_free)(X509 *a);
+extern void *(*X509_get_ext_d2i)(const X509 *x, int nid, int *crit, int *idx);
+extern X509_NAME *(*X509_get_subject_name)(const X509 *x);
+
+extern int (*i2d_X509)(X509 *a, unsigned char **ppout);
+
+extern int (*OPENSSL_sk_num)(const void *sk);
+extern void *(*OPENSSL_sk_value)(const void *sk, int i);
+extern void (*OPENSSL_sk_free)(void *sk);
+
+extern int (*sk_num)(const void *sk);
+extern void *(*sk_value)(const void *sk, int i);
+extern void (*sk_free)(void *sk);
+
+extern int sk_GENERAL_NAME_num(const GENERAL_NAME *sk);
+extern GENERAL_NAME *sk_GENERAL_NAME_value(const GENERAL_NAME *sk, int i);
+extern void GENERAL_NAMES_free(GENERAL_NAME *sk);
+
+extern int git_openssl_stream_dynamic_init(void);
+
+#endif /* GIT_OPENSSL_DYNAMIC */
+
+#endif
diff --git a/src/streams/openssl_legacy.c b/src/streams/openssl_legacy.c
new file mode 100644
index 0000000..1c1ff60
--- /dev/null
+++ b/src/streams/openssl_legacy.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "streams/openssl.h"
+#include "streams/openssl_legacy.h"
+
+#include "runtime.h"
+#include "git2/sys/openssl.h"
+
+#if defined(GIT_OPENSSL) && !defined(GIT_OPENSSL_DYNAMIC)
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+# include <openssl/x509v3.h>
+# include <openssl/bio.h>
+#endif
+
+#if defined(GIT_OPENSSL_LEGACY) || defined(GIT_OPENSSL_DYNAMIC)
+
+/*
+ * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
+ * which do not exist in previous versions. We define these inline functions so
+ * we can program against the interface instead of littering the implementation
+ * with ifdefs. We do the same for OPENSSL_init_ssl.
+ */
+
+int OPENSSL_init_ssl__legacy(uint64_t opts, const void *settings)
+{
+ GIT_UNUSED(opts);
+ GIT_UNUSED(settings);
+ SSL_load_error_strings();
+ SSL_library_init();
+ return 0;
+}
+
+BIO_METHOD* BIO_meth_new__legacy(int type, const char *name)
+{
+ BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
+ if (!meth) {
+ return NULL;
+ }
+
+ meth->type = type;
+ meth->name = name;
+
+ return meth;
+}
+
+void BIO_meth_free__legacy(BIO_METHOD *biom)
+{
+ git__free(biom);
+}
+
+int BIO_meth_set_write__legacy(BIO_METHOD *biom, int (*write) (BIO *, const char *, int))
+{
+ biom->bwrite = write;
+ return 1;
+}
+
+int BIO_meth_set_read__legacy(BIO_METHOD *biom, int (*read) (BIO *, char *, int))
+{
+ biom->bread = read;
+ return 1;
+}
+
+int BIO_meth_set_puts__legacy(BIO_METHOD *biom, int (*puts) (BIO *, const char *))
+{
+ biom->bputs = puts;
+ return 1;
+}
+
+int BIO_meth_set_gets__legacy(BIO_METHOD *biom, int (*gets) (BIO *, char *, int))
+
+{
+ biom->bgets = gets;
+ return 1;
+}
+
+int BIO_meth_set_ctrl__legacy(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *))
+{
+ biom->ctrl = ctrl;
+ return 1;
+}
+
+int BIO_meth_set_create__legacy(BIO_METHOD *biom, int (*create) (BIO *))
+{
+ biom->create = create;
+ return 1;
+}
+
+int BIO_meth_set_destroy__legacy(BIO_METHOD *biom, int (*destroy) (BIO *))
+{
+ biom->destroy = destroy;
+ return 1;
+}
+
+int BIO_get_new_index__legacy(void)
+{
+ /* This exists as of 1.1 so before we'd just have 0 */
+ return 0;
+}
+
+void BIO_set_init__legacy(BIO *b, int init)
+{
+ b->init = init;
+}
+
+void BIO_set_data__legacy(BIO *a, void *ptr)
+{
+ a->ptr = ptr;
+}
+
+void *BIO_get_data__legacy(BIO *a)
+{
+ return a->ptr;
+}
+
+const unsigned char *ASN1_STRING_get0_data__legacy(const ASN1_STRING *x)
+{
+ return ASN1_STRING_data((ASN1_STRING *)x);
+}
+
+long SSL_CTX_set_options__legacy(SSL_CTX *ctx, long op)
+{
+ return SSL_CTX_ctrl(ctx, SSL_CTRL_OPTIONS, op, NULL);
+}
+
+# if defined(GIT_THREADS)
+static git_mutex *openssl_locks;
+
+static void openssl_locking_function(int mode, int n, const char *file, int line)
+{
+ int lock;
+
+ GIT_UNUSED(file);
+ GIT_UNUSED(line);
+
+ lock = mode & CRYPTO_LOCK;
+
+ if (lock)
+ (void)git_mutex_lock(&openssl_locks[n]);
+ else
+ git_mutex_unlock(&openssl_locks[n]);
+}
+
+static void shutdown_ssl_locking(void)
+{
+ int num_locks, i;
+
+ num_locks = CRYPTO_num_locks();
+ CRYPTO_set_locking_callback(NULL);
+
+ for (i = 0; i < num_locks; ++i)
+ git_mutex_free(&openssl_locks[i]);
+ git__free(openssl_locks);
+}
+
+static void threadid_cb(CRYPTO_THREADID *threadid)
+{
+ GIT_UNUSED(threadid);
+ CRYPTO_THREADID_set_numeric(threadid, git_thread_currentid());
+}
+
+int git_openssl_set_locking(void)
+{
+ int num_locks, i;
+
+#ifndef GIT_THREADS
+ git_error_set(GIT_ERROR_THREAD, "libgit2 was not built with threads");
+ return -1;
+#endif
+
+#ifdef GIT_OPENSSL_DYNAMIC
+ /*
+ * This function is required on legacy versions of OpenSSL; when building
+ * with dynamically-loaded OpenSSL, we detect whether we loaded it or not.
+ */
+ if (!CRYPTO_set_locking_callback)
+ return 0;
+#endif
+
+ CRYPTO_THREADID_set_callback(threadid_cb);
+
+ num_locks = CRYPTO_num_locks();
+ openssl_locks = git__calloc(num_locks, sizeof(git_mutex));
+ GIT_ERROR_CHECK_ALLOC(openssl_locks);
+
+ for (i = 0; i < num_locks; i++) {
+ if (git_mutex_init(&openssl_locks[i]) != 0) {
+ git_error_set(GIT_ERROR_SSL, "failed to initialize openssl locks");
+ return -1;
+ }
+ }
+
+ CRYPTO_set_locking_callback(openssl_locking_function);
+ return git_runtime_shutdown_register(shutdown_ssl_locking);
+}
+#endif /* GIT_THREADS */
+
+#endif /* GIT_OPENSSL_LEGACY || GIT_OPENSSL_DYNAMIC */
diff --git a/src/streams/openssl_legacy.h b/src/streams/openssl_legacy.h
new file mode 100644
index 0000000..1f74fd9
--- /dev/null
+++ b/src/streams/openssl_legacy.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_streams_openssl_legacy_h__
+#define INCLUDE_streams_openssl_legacy_h__
+
+#include "streams/openssl_dynamic.h"
+
+#if defined(GIT_OPENSSL) && !defined(GIT_OPENSSL_DYNAMIC)
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+# include <openssl/x509v3.h>
+# include <openssl/bio.h>
+
+# if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
+# define GIT_OPENSSL_LEGACY
+# endif
+#endif
+
+#if defined(GIT_OPENSSL_LEGACY) && !defined(GIT_OPENSSL_DYNAMIC)
+# define OPENSSL_init_ssl OPENSSL_init_ssl__legacy
+# define BIO_meth_new BIO_meth_new__legacy
+# define BIO_meth_free BIO_meth_free__legacy
+# define BIO_meth_set_write BIO_meth_set_write__legacy
+# define BIO_meth_set_read BIO_meth_set_read__legacy
+# define BIO_meth_set_puts BIO_meth_set_puts__legacy
+# define BIO_meth_set_gets BIO_meth_set_gets__legacy
+# define BIO_meth_set_ctrl BIO_meth_set_ctrl__legacy
+# define BIO_meth_set_create BIO_meth_set_create__legacy
+# define BIO_meth_set_destroy BIO_meth_set_destroy__legacy
+# define BIO_get_new_index BIO_get_new_index__legacy
+# define BIO_set_data BIO_set_data__legacy
+# define BIO_set_init BIO_set_init__legacy
+# define BIO_get_data BIO_get_data__legacy
+# define ASN1_STRING_get0_data ASN1_STRING_get0_data__legacy
+#endif
+
+#if defined(GIT_OPENSSL_LEGACY) || defined(GIT_OPENSSL_DYNAMIC)
+
+extern int OPENSSL_init_ssl__legacy(uint64_t opts, const void *settings);
+extern BIO_METHOD* BIO_meth_new__legacy(int type, const char *name);
+extern void BIO_meth_free__legacy(BIO_METHOD *biom);
+extern int BIO_meth_set_write__legacy(BIO_METHOD *biom, int (*write) (BIO *, const char *, int));
+extern int BIO_meth_set_read__legacy(BIO_METHOD *biom, int (*read) (BIO *, char *, int));
+extern int BIO_meth_set_puts__legacy(BIO_METHOD *biom, int (*puts) (BIO *, const char *));
+extern int BIO_meth_set_gets__legacy(BIO_METHOD *biom, int (*gets) (BIO *, char *, int));
+extern int BIO_meth_set_ctrl__legacy(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *));
+extern int BIO_meth_set_create__legacy(BIO_METHOD *biom, int (*create) (BIO *));
+extern int BIO_meth_set_destroy__legacy(BIO_METHOD *biom, int (*destroy) (BIO *));
+extern int BIO_get_new_index__legacy(void);
+extern void BIO_set_data__legacy(BIO *a, void *ptr);
+extern void BIO_set_init__legacy(BIO *b, int init);
+extern void *BIO_get_data__legacy(BIO *a);
+extern const unsigned char *ASN1_STRING_get0_data__legacy(const ASN1_STRING *x);
+extern long SSL_CTX_set_options__legacy(SSL_CTX *ctx, long op);
+
+#endif
+
+#endif
diff --git a/src/streams/registry.c b/src/streams/registry.c
index 3300320..e60e1cd 100644
--- a/src/streams/registry.c
+++ b/src/streams/registry.c
@@ -5,10 +5,11 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "git2/errors.h"
-
#include "common.h"
-#include "global.h"
+
+#include "streams/registry.h"
+
+#include "runtime.h"
#include "streams/tls.h"
#include "streams/mbedtls.h"
#include "streams/openssl.h"
@@ -32,8 +33,7 @@ int git_stream_registry_global_init(void)
if (git_rwlock_init(&stream_registry.lock) < 0)
return -1;
- git__on_shutdown(shutdown_stream_registry);
- return 0;
+ return git_runtime_shutdown_register(shutdown_stream_registry);
}
GIT_INLINE(void) stream_registration_cpy(
@@ -51,7 +51,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
git_stream_registration *target;
int error = GIT_ENOTFOUND;
- assert(out);
+ GIT_ASSERT_ARG(out);
switch(type) {
case GIT_STREAM_STANDARD:
@@ -61,7 +61,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
target = &stream_registry.tls_callbacks;
break;
default:
- assert(0);
+ git_error_set(GIT_ERROR_INVALID, "invalid stream type");
return -1;
}
@@ -81,7 +81,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
int git_stream_register(git_stream_t type, git_stream_registration *registration)
{
- assert(!registration || registration->init);
+ GIT_ASSERT(!registration || registration->init);
GIT_ERROR_CHECK_VERSION(registration, GIT_STREAM_VERSION, "stream_registration");
@@ -100,7 +100,7 @@ int git_stream_register(git_stream_t type, git_stream_registration *registration
return 0;
}
-
+#ifndef GIT_DEPRECATE_HARD
int git_stream_register_tls(
int GIT_CALLBACK(ctor)(git_stream **out, const char *host, const char *port))
{
@@ -116,3 +116,4 @@ int git_stream_register_tls(
return git_stream_register(GIT_STREAM_TLS, NULL);
}
}
+#endif
diff --git a/src/streams/socket.c b/src/streams/socket.c
index 33f7883..9415fe8 100644
--- a/src/streams/socket.c
+++ b/src/streams/socket.c
@@ -183,7 +183,9 @@ static int default_socket_stream_new(
{
git_socket_stream *st;
- assert(out && host && port);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(host);
+ GIT_ASSERT_ARG(port);
st = git__calloc(1, sizeof(git_socket_stream));
GIT_ERROR_CHECK_ALLOC(st);
@@ -217,7 +219,9 @@ int git_socket_stream_new(
git_stream_registration custom = {0};
int error;
- assert(out && host && port);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(host);
+ GIT_ASSERT_ARG(port);
if ((error = git_stream_registry_lookup(&custom, GIT_STREAM_STANDARD)) == 0)
init = custom.init;
diff --git a/src/streams/stransport.c b/src/streams/stransport.c
index a79d3cb..3f31d25 100644
--- a/src/streams/stransport.c
+++ b/src/streams/stransport.c
@@ -167,7 +167,7 @@ static ssize_t stransport_write(git_stream *stream, const char *data, size_t len
if ((ret = SSLWrite(st->ctx, data, data_len, &processed)) != noErr)
return stransport_error(ret);
- assert(processed < SSIZE_MAX);
+ GIT_ASSERT(processed < SSIZE_MAX);
return (ssize_t)processed;
}
@@ -251,7 +251,9 @@ static int stransport_wrap(
stransport_stream *st;
OSStatus ret;
- assert(out && in && host);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(in);
+ GIT_ASSERT_ARG(host);
st = git__calloc(1, sizeof(stransport_stream));
GIT_ERROR_CHECK_ALLOC(st);
@@ -305,7 +307,8 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po
git_stream *stream = NULL;
int error;
- assert(out && host);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(host);
error = git_socket_stream_new(&stream, host, port);
diff --git a/src/streams/tls.c b/src/streams/tls.c
index 6a25171..e063a33 100644
--- a/src/streams/tls.c
+++ b/src/streams/tls.c
@@ -8,7 +8,6 @@
#include "git2/errors.h"
#include "common.h"
-#include "global.h"
#include "streams/registry.h"
#include "streams/tls.h"
#include "streams/mbedtls.h"
@@ -21,7 +20,9 @@ int git_tls_stream_new(git_stream **out, const char *host, const char *port)
git_stream_registration custom = {0};
int error;
- assert(out && host && port);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(host);
+ GIT_ASSERT_ARG(port);
if ((error = git_stream_registry_lookup(&custom, GIT_STREAM_TLS)) == 0) {
init = custom.init;
@@ -50,7 +51,8 @@ int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host)
int (*wrap)(git_stream **, git_stream *, const char *) = NULL;
git_stream_registration custom = {0};
- assert(out && in);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(in);
if (git_stream_registry_lookup(&custom, GIT_STREAM_TLS) == 0) {
wrap = custom.wrap;
diff --git a/src/submodule.c b/src/submodule.c
index 1690e08..7cbb9fa 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -12,7 +12,6 @@
#include "git2/types.h"
#include "git2/index.h"
#include "buffer.h"
-#include "buf_text.h"
#include "vector.h"
#include "posix.h"
#include "config_backend.h"
@@ -249,24 +248,62 @@ out:
return error;
}
+int git_submodule_cache_init(git_strmap **out, git_repository *repo)
+{
+ int error = 0;
+ git_strmap *cache = NULL;
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ if ((error = git_strmap_new(&cache)) < 0)
+ return error;
+ if ((error = git_submodule__map(repo, cache)) < 0) {
+ git_submodule_cache_free(cache);
+ return error;
+ }
+ *out = cache;
+ return error;
+}
+
+int git_submodule_cache_free(git_strmap *cache)
+{
+ git_submodule *sm = NULL;
+ if (cache == NULL)
+ return 0;
+ git_strmap_foreach_value(cache, sm, {
+ git_submodule_free(sm);
+ });
+ git_strmap_free(cache);
+ return 0;
+}
+
int git_submodule_lookup(
git_submodule **out, /* NULL if user only wants to test existence */
git_repository *repo,
const char *name) /* trailing slash is allowed */
{
+ return git_submodule__lookup_with_cache(out, repo, name, repo->submodule_cache);
+}
+
+int git_submodule__lookup_with_cache(
+ git_submodule **out, /* NULL if user only wants to test existence */
+ git_repository *repo,
+ const char *name, /* trailing slash is allowed */
+ git_strmap *cache)
+{
int error;
unsigned int location;
git_submodule *sm;
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
if (repo->is_bare) {
git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
return -1;
}
- if (repo->submodule_cache != NULL) {
- if ((sm = git_strmap_get(repo->submodule_cache, name)) != NULL) {
+ if (cache != NULL) {
+ if ((sm = git_strmap_get(cache, name)) != NULL) {
if (out) {
*out = sm;
GIT_REFCOUNT_INC(*out);
@@ -342,8 +379,10 @@ int git_submodule_lookup(
/* If it's not configured, we still check if there's a repo at the path */
if (git_repository_workdir(repo)) {
git_buf path = GIT_BUF_INIT;
- if (git_buf_join3(&path,
- '/', git_repository_workdir(repo), name, DOT_GIT) < 0)
+ if (git_buf_join3(&path, '/',
+ git_repository_workdir(repo),
+ name, DOT_GIT) < 0 ||
+ git_path_validate_workdir_buf(NULL, &path) < 0)
return -1;
if (git_path_exists(path.ptr))
@@ -380,7 +419,7 @@ int git_submodule_name_is_valid(git_repository *repo, const char *name, int flag
git_buf_attach_notowned(&buf, name, strlen(name));
}
- isvalid = git_path_isvalid(repo, buf.ptr, 0, flags);
+ isvalid = git_path_validate(repo, buf.ptr, 0, flags);
git_buf_dispose(&buf);
return isvalid;
@@ -515,12 +554,13 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
int error = 0;
git_index *idx = NULL;
git_tree *head = NULL;
- const char *wd = NULL;
git_buf path = GIT_BUF_INIT;
git_submodule *sm;
git_config *mods = NULL;
+ bool has_workdir;
- assert(repo && map);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(map);
/* get sources that we will need to check */
if (git_repository_index(&idx, repo) < 0)
@@ -528,12 +568,14 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
if (git_repository_head_tree(&head, repo) < 0)
git_error_clear();
- wd = git_repository_workdir(repo);
- if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0)
+ has_workdir = git_repository_workdir(repo) != NULL;
+
+ if (has_workdir &&
+ (error = git_repository_workdir_path(&path, repo, GIT_MODULES_FILE)) < 0)
goto cleanup;
/* add submodule information from .gitmodules */
- if (wd) {
+ if (has_workdir) {
lfc_data data = { 0 };
data.map = map;
data.repo = repo;
@@ -560,7 +602,7 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
goto cleanup;
}
/* shallow scan submodules in work tree as needed */
- if (wd) {
+ if (has_workdir) {
git_strmap_foreach_value(map, sm, {
submodule_load_from_wd_lite(sm);
});
@@ -644,7 +686,7 @@ static int submodule_repo_init(
git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT;
git_repository *subrepo = NULL;
- error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path);
+ error = git_repository_workdir_path(&workdir, parent_repo, path);
if (error < 0)
goto cleanup;
@@ -698,7 +740,9 @@ int git_submodule_add_setup(
git_repository *subrepo = NULL;
bool path_occupied;
- assert(repo && url && path);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(url);
+ GIT_ASSERT_ARG(path);
/* see if there is already an entry for this submodule */
@@ -749,7 +793,7 @@ int git_submodule_add_setup(
/* init submodule repository and add origin remote as needed */
- error = git_buf_joinpath(&name, git_repository_workdir(repo), path);
+ error = git_repository_workdir_path(&name, repo, path);
if (error < 0)
goto cleanup;
@@ -799,7 +843,8 @@ int git_submodule_repo_init(
git_config *cfg = NULL;
git_buf buf = GIT_BUF_INIT;
- assert(out && sm);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(sm);
/* get the configured remote url of the submodule */
if ((error = git_buf_printf(&buf, "submodule.%s.url", sm->name)) < 0 ||
@@ -840,7 +885,7 @@ int git_submodule_clone(git_repository **out, git_submodule *submodule, const gi
git_submodule_update_options sub_opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
- assert(submodule);
+ GIT_ASSERT_ARG(submodule);
if (given_opts)
memcpy(&sub_opts, given_opts, sizeof(sub_opts));
@@ -854,10 +899,9 @@ int git_submodule_clone(git_repository **out, git_submodule *submodule, const gi
opts.remote_cb = clone_return_origin;
opts.remote_cb_payload = submodule;
- git_buf_puts(&rel_path, git_repository_workdir(git_submodule_owner(submodule)));
- git_buf_joinpath(&rel_path, git_buf_cstr(&rel_path), git_submodule_path(submodule));
-
- GIT_ERROR_CHECK_ALLOC_BUF(&rel_path);
+ error = git_repository_workdir_path(&rel_path, git_submodule_owner(submodule), git_submodule_path(submodule));
+ if (error < 0)
+ goto cleanup;
error = git_clone__submodule(&clone, git_submodule_url(submodule), git_buf_cstr(&rel_path), &opts);
if (error < 0)
@@ -879,7 +923,7 @@ int git_submodule_add_finalize(git_submodule *sm)
int error;
git_index *index;
- assert(sm);
+ GIT_ASSERT_ARG(sm);
if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 ||
(error = git_index_add_bypath(index, GIT_MODULES_FILE)) < 0)
@@ -898,15 +942,14 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
git_index_entry entry;
struct stat st;
- assert(sm);
+ GIT_ASSERT_ARG(sm);
/* force reload of wd OID by git_submodule_open */
sm->flags = sm->flags & ~GIT_SUBMODULE_STATUS__WD_OID_VALID;
if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 ||
- (error = git_buf_joinpath(
- &path, git_repository_workdir(sm->repo), sm->path)) < 0 ||
- (error = git_submodule_open(&sm_repo, sm)) < 0)
+ (error = git_repository_workdir_path(&path, sm->repo, sm->path)) < 0 ||
+ (error = git_submodule_open(&sm_repo, sm)) < 0)
goto cleanup;
/* read stat information for submodule working directory */
@@ -958,7 +1001,7 @@ cleanup:
return error;
}
-const char *git_submodule_update_to_str(git_submodule_update_t update)
+static const char *submodule_update_to_str(git_submodule_update_t update)
{
int i;
for (i = 0; i < (int)ARRAY_SIZE(_sm_update_map); ++i)
@@ -969,25 +1012,25 @@ const char *git_submodule_update_to_str(git_submodule_update_t update)
git_repository *git_submodule_owner(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
return submodule->repo;
}
const char *git_submodule_name(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
return submodule->name;
}
const char *git_submodule_path(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
return submodule->path;
}
const char *git_submodule_url(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
return submodule->url;
}
@@ -996,9 +1039,12 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
int error = 0;
git_buf normalized = GIT_BUF_INIT;
- assert(out && repo && url);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(url);
- git_buf_sanitize(out);
+ if ((error = git_buf_sanitize(out)) < 0)
+ return error;
/* We do this in all platforms in case someone on Windows created the .gitmodules */
if (strchr(url, '\\')) {
@@ -1066,28 +1112,30 @@ static int write_mapped_var(git_repository *repo, const char *name, git_configma
const char *git_submodule_branch(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
return submodule->branch;
}
int git_submodule_set_branch(git_repository *repo, const char *name, const char *branch)
{
-
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
return write_var(repo, name, "branch", branch);
}
int git_submodule_set_url(git_repository *repo, const char *name, const char *url)
{
- assert(repo && name && url);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(url);
return write_var(repo, name, "url", url);
}
const git_oid *git_submodule_index_id(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
if (submodule->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID)
return &submodule->index_oid;
@@ -1097,7 +1145,7 @@ const git_oid *git_submodule_index_id(git_submodule *submodule)
const git_oid *git_submodule_head_id(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
if (submodule->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID)
return &submodule->head_oid;
@@ -1107,7 +1155,7 @@ const git_oid *git_submodule_head_id(git_submodule *submodule)
const git_oid *git_submodule_wd_id(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
/* load unless we think we have a valid oid */
if (!(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) {
@@ -1128,28 +1176,32 @@ const git_oid *git_submodule_wd_id(git_submodule *submodule)
git_submodule_ignore_t git_submodule_ignore(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, GIT_SUBMODULE_IGNORE_UNSPECIFIED);
+
return (submodule->ignore < GIT_SUBMODULE_IGNORE_NONE) ?
GIT_SUBMODULE_IGNORE_NONE : submodule->ignore;
}
int git_submodule_set_ignore(git_repository *repo, const char *name, git_submodule_ignore_t ignore)
{
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
return write_mapped_var(repo, name, _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), "ignore", ignore);
}
git_submodule_update_t git_submodule_update_strategy(git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, GIT_SUBMODULE_UPDATE_NONE);
+
return (submodule->update < GIT_SUBMODULE_UPDATE_CHECKOUT) ?
GIT_SUBMODULE_UPDATE_CHECKOUT : submodule->update;
}
int git_submodule_set_update(git_repository *repo, const char *name, git_submodule_update_t update)
{
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
return write_mapped_var(repo, name, _sm_update_map, ARRAY_SIZE(_sm_update_map), "update", update);
}
@@ -1157,13 +1209,14 @@ int git_submodule_set_update(git_repository *repo, const char *name, git_submodu
git_submodule_recurse_t git_submodule_fetch_recurse_submodules(
git_submodule *submodule)
{
- assert(submodule);
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, GIT_SUBMODULE_RECURSE_NO);
return submodule->fetch_recurse;
}
int git_submodule_set_fetch_recurse_submodules(git_repository *repo, const char *name, git_submodule_recurse_t recurse)
{
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
return write_mapped_var(repo, name, _sm_recurse_map, ARRAY_SIZE(_sm_recurse_map), "fetchRecurseSubmodules", recurse);
}
@@ -1185,7 +1238,7 @@ static int submodule_repo_create(
GIT_REPOSITORY_INIT_RELATIVE_GITLINK;
/* Workdir: path to sub-repo working directory */
- error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path);
+ error = git_repository_workdir_path(&workdir, parent_repo, path);
if (error < 0)
goto cleanup;
@@ -1240,10 +1293,12 @@ int git_submodule_update_options_init(git_submodule_update_options *opts, unsign
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version)
{
return git_submodule_update_options_init(opts, version);
}
+#endif
int git_submodule_update(git_submodule *sm, int init, git_submodule_update_options *_update_options)
{
@@ -1258,7 +1313,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT;
- assert(sm);
+ GIT_ASSERT_ARG(sm);
if (_update_options)
memcpy(&update_options, _update_options, sizeof(git_submodule_update_options));
@@ -1401,7 +1456,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
/* write "submodule.NAME.update" if not default */
val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ?
- NULL : git_submodule_update_to_str(sm->update);
+ NULL : submodule_update_to_str(sm->update);
if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 ||
(error = git_config__update_entry(
@@ -1471,7 +1526,8 @@ static int git_submodule__open(
unsigned int flags = GIT_REPOSITORY_OPEN_NO_SEARCH;
const char *wd;
- assert(sm && subrepo);
+ GIT_ASSERT_ARG(sm);
+ GIT_ASSERT_ARG(subrepo);
if (git_repository__ensure_not_bare(
sm->repo, "open submodule repository") < 0)
@@ -1479,8 +1535,7 @@ static int git_submodule__open(
wd = git_repository_workdir(sm->repo);
- if (git_buf_joinpath(&path, wd, sm->path) < 0 ||
- git_buf_joinpath(&path, path.ptr, DOT_GIT) < 0)
+ if (git_buf_join3(&path, '/', wd, sm->path, DOT_GIT) < 0)
return -1;
sm->flags = sm->flags &
@@ -1607,7 +1662,7 @@ int git_submodule_reload(git_submodule *sm, int force)
GIT_UNUSED(force);
- assert(sm);
+ GIT_ASSERT_ARG(sm);
if ((error = git_submodule_name_is_valid(sm->repo, sm->name, 0)) <= 0)
/* This should come with a warning, but we've no API for that */
@@ -1724,7 +1779,9 @@ int git_submodule_status(unsigned int *status, git_repository *repo, const char
git_submodule *sm;
int error;
- assert(status && repo && name);
+ GIT_ASSERT_ARG(status);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
if ((error = git_submodule_lookup(&sm, repo, name)) < 0)
return error;
@@ -1737,7 +1794,8 @@ int git_submodule_status(unsigned int *status, git_repository *repo, const char
int git_submodule_location(unsigned int *location, git_submodule *sm)
{
- assert(location && sm);
+ GIT_ASSERT_ARG(location);
+ GIT_ASSERT_ARG(sm);
return git_submodule__status(
location, NULL, NULL, NULL, sm, GIT_SUBMODULE_IGNORE_ALL);
@@ -1796,6 +1854,17 @@ static void submodule_release(git_submodule *sm)
git__free(sm);
}
+int git_submodule_dup(git_submodule **out, git_submodule *source)
+{
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(source);
+
+ GIT_REFCOUNT_INC(source);
+
+ *out = source;
+ return 0;
+}
+
void git_submodule_free(git_submodule *sm)
{
if (!sm)
@@ -1838,7 +1907,7 @@ int git_submodule_parse_update(git_submodule_update_t *out, const char *value)
return 0;
}
-int git_submodule_parse_recurse(git_submodule_recurse_t *out, const char *value)
+static int submodule_parse_recurse(git_submodule_recurse_t *out, const char *value)
{
int val;
@@ -1934,7 +2003,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) {
in_config = 1;
- if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0)
+ if ((error = submodule_parse_recurse(&sm->fetch_recurse, value)) < 0)
goto cleanup;
sm->fetch_recurse_default = sm->fetch_recurse;
} else if (error != GIT_ENOTFOUND) {
@@ -2022,7 +2091,7 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
{
git_buf path = GIT_BUF_INIT;
- if (git_buf_joinpath(&path, git_repository_workdir(sm->repo), sm->path) < 0)
+ if (git_repository_workdir_path(&path, sm->repo, sm->path) < 0)
return -1;
if (git_path_isdir(path.ptr))
@@ -2042,15 +2111,14 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
*/
static int gitmodules_snapshot(git_config **snap, git_repository *repo)
{
- const char *workdir = git_repository_workdir(repo);
git_config *mods = NULL;
git_buf path = GIT_BUF_INIT;
int error;
- if (!workdir)
+ if (git_repository_workdir(repo) == NULL)
return GIT_ENOTFOUND;
- if ((error = git_buf_joinpath(&path, workdir, GIT_MODULES_FILE)) < 0)
+ if ((error = git_repository_workdir_path(&path, repo, GIT_MODULES_FILE)) < 0)
return error;
if ((error = git_config_open_ondisk(&mods, path.ptr)) < 0)
@@ -2074,12 +2142,11 @@ static git_config_backend *open_gitmodules(
git_repository *repo,
int okay_to_create)
{
- const char *workdir = git_repository_workdir(repo);
git_buf path = GIT_BUF_INIT;
git_config_backend *mods = NULL;
- if (workdir != NULL) {
- if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0)
+ if (git_repository_workdir(repo) != NULL) {
+ if (git_repository_workdir_path(&path, repo, GIT_MODULES_FILE) != 0)
return NULL;
if (okay_to_create || git_path_isfile(path.ptr)) {
@@ -2192,8 +2259,9 @@ static int get_url_base(git_buf *url, git_repository *repo)
if ((error = git_worktree_open_from_repository(&wt, repo)) < 0)
goto out;
error = git_buf_sets(url, wt->parent_path);
- } else
+ } else {
error = git_buf_sets(url, git_repository_workdir(repo));
+ }
out:
git_remote_free(remote);
diff --git a/src/submodule.h b/src/submodule.h
index 57d95c3..b01ff68 100644
--- a/src/submodule.h
+++ b/src/submodule.h
@@ -101,12 +101,6 @@ struct git_submodule {
git_oid wd_oid;
};
-/* Force revalidation of submodule data cache (alloc as needed) */
-extern int git_submodule_cache_refresh(git_repository *repo);
-
-/* Release all submodules */
-extern void git_submodule_cache_free(git_repository *repo);
-
/* Additional flags on top of public GIT_SUBMODULE_STATUS values */
enum {
GIT_SUBMODULE_STATUS__WD_SCANNED = (1u << 20),
@@ -122,9 +116,15 @@ enum {
#define GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(S) \
((S) & ~(0xFFFFFFFFu << 20))
-/* Internal lookup does not attempt to refresh cached data */
-extern int git_submodule__lookup(
- git_submodule **out, git_repository *repo, const char *path);
+/* Initialize an external submodule cache for the provided repo. */
+extern int git_submodule_cache_init(git_strmap **out, git_repository *repo);
+
+/* Release the resources of the submodule cache. */
+extern int git_submodule_cache_free(git_strmap *cache);
+
+/* Submodule lookup with an explicit cache */
+extern int git_submodule__lookup_with_cache(
+ git_submodule **out, git_repository *repo, const char *path, git_strmap *cache);
/* Internal status fn returns status and optionally the various OIDs */
extern int git_submodule__status(
diff --git a/src/sysdir.c b/src/sysdir.c
index 9e86dc8..dcbd48b 100644
--- a/src/sysdir.c
+++ b/src/sysdir.c
@@ -7,7 +7,7 @@
#include "sysdir.h"
-#include "global.h"
+#include "runtime.h"
#include "buffer.h"
#include "path.h"
#include <ctype.h>
@@ -45,7 +45,7 @@ static int get_passwd_home(git_buf *out, uid_t uid)
long buflen;
int error;
- assert(out);
+ GIT_ASSERT_ARG(out);
if ((buflen = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1)
buflen = 1024;
@@ -189,9 +189,7 @@ int git_sysdir_global_init(void)
for (i = 0; !error && i < ARRAY_SIZE(git_sysdir__dirs); i++)
error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf);
- git__on_shutdown(git_sysdir_global_shutdown);
-
- return error;
+ return git_runtime_shutdown_register(git_sysdir_global_shutdown);
}
static int git_sysdir_check_selector(git_sysdir_t which)
@@ -206,7 +204,7 @@ static int git_sysdir_check_selector(git_sysdir_t which)
int git_sysdir_get(const git_buf **out, git_sysdir_t which)
{
- assert(out);
+ GIT_ASSERT_ARG(out);
*out = NULL;
@@ -216,25 +214,6 @@ int git_sysdir_get(const git_buf **out, git_sysdir_t which)
return 0;
}
-int git_sysdir_get_str(
- char *out,
- size_t outlen,
- git_sysdir_t which)
-{
- const git_buf *path = NULL;
-
- GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which));
- GIT_ERROR_CHECK_ERROR(git_sysdir_get(&path, which));
-
- if (!out || path->size >= outlen) {
- git_error_set(GIT_ERROR_NOMEMORY, "buffer is too short for the path");
- return GIT_EBUFS;
- }
-
- git_buf_copy_cstr(out, outlen, path);
- return 0;
-}
-
#define PATH_MAGIC "$PATH"
int git_sysdir_set(git_sysdir_t which, const char *search_path)
@@ -317,8 +296,11 @@ static int git_sysdir_find_in_dirlist(
}
done:
+ if (name)
+ git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
+ else
+ git_error_set(GIT_ERROR_OS, "the %s directory doesn't exist", label);
git_buf_dispose(path);
- git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
return GIT_ENOTFOUND;
}
diff --git a/src/sysdir.h b/src/sysdir.h
index ce1b4dc..cc5599e 100644
--- a/src/sysdir.h
+++ b/src/sysdir.h
@@ -94,17 +94,6 @@ extern int git_sysdir_global_init(void);
extern int git_sysdir_get(const git_buf **out, git_sysdir_t which);
/**
- * Get search path into a preallocated buffer
- *
- * @param out String buffer to write into
- * @param outlen Size of string buffer
- * @param which Which search path to return
- * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure
- */
-
-extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which);
-
-/**
* Set search paths for global/system/xdg files
*
* The first occurrence of the magic string "$PATH" in the new value will
diff --git a/src/tag.c b/src/tag.c
index a7a005c..ee91e50 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -27,25 +27,25 @@ void git_tag__free(void *_tag)
int git_tag_target(git_object **target, const git_tag *t)
{
- assert(t);
+ GIT_ASSERT_ARG(t);
return git_object_lookup(target, t->object.repo, &t->target, t->type);
}
const git_oid *git_tag_target_id(const git_tag *t)
{
- assert(t);
+ GIT_ASSERT_ARG_WITH_RETVAL(t, NULL);
return &t->target;
}
git_object_t git_tag_target_type(const git_tag *t)
{
- assert(t);
+ GIT_ASSERT_ARG_WITH_RETVAL(t, GIT_OBJECT_INVALID);
return t->type;
}
const char *git_tag_name(const git_tag *t)
{
- assert(t);
+ GIT_ASSERT_ARG_WITH_RETVAL(t, NULL);
return t->tag_name;
}
@@ -56,7 +56,7 @@ const git_signature *git_tag_tagger(const git_tag *t)
const char *git_tag_message(const git_tag *t)
{
- assert(t);
+ GIT_ASSERT_ARG_WITH_RETVAL(t, NULL);
return t->message;
}
@@ -259,8 +259,10 @@ static int git_tag_create__internal(
int error;
- assert(repo && tag_name && target);
- assert(!create_tag_annotation || (tagger && message));
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(tag_name);
+ GIT_ASSERT_ARG(target);
+ GIT_ASSERT_ARG(!create_tag_annotation || (tagger && message));
if (git_object_owner(target) != repo) {
git_error_set(GIT_ERROR_INVALID, "the given target does not belong to this repository");
@@ -313,7 +315,12 @@ int git_tag_annotation_create(
const git_signature *tagger,
const char *message)
{
- assert(oid && repo && tag_name && target && tagger && message);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(tag_name);
+ GIT_ASSERT_ARG(target);
+ GIT_ASSERT_ARG(tagger);
+ GIT_ASSERT_ARG(message);
return write_tag_annotation(oid, repo, tag_name, target, tagger, message);
}
@@ -339,7 +346,8 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b
git_reference *new_ref = NULL;
git_buf ref_name = GIT_BUF_INIT;
- assert(oid && buffer);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(buffer);
memset(&tag, 0, sizeof(tag));
@@ -454,7 +462,8 @@ int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data)
{
tag_cb_data data;
- assert(repo && cb);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(cb);
data.cb = cb;
data.cb_data = cb_data;
@@ -493,7 +502,9 @@ int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_reposit
tag_filter_data filter;
git_vector taglist;
- assert(tag_names && repo && pattern);
+ GIT_ASSERT_ARG(tag_names);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(pattern);
if ((error = git_vector_init(&taglist, 8, NULL)) < 0)
return error;
@@ -522,9 +533,36 @@ int git_tag_peel(git_object **tag_target, const git_tag *tag)
return git_object_peel(tag_target, (const git_object *)tag, GIT_OBJECT_ANY);
}
+int git_tag_name_is_valid(int *valid, const char *name)
+{
+ git_buf ref_name = GIT_BUF_INIT;
+ int error = 0;
+
+ GIT_ASSERT(valid);
+
+ /*
+ * Discourage tag name starting with dash,
+ * https://github.com/git/git/commit/4f0accd638b8d2
+ */
+ if (!name || name[0] == '-')
+ goto done;
+
+ if ((error = git_buf_puts(&ref_name, GIT_REFS_TAGS_DIR)) < 0 ||
+ (error = git_buf_puts(&ref_name, name)) < 0)
+ goto done;
+
+ error = git_reference_name_is_valid(valid, ref_name.ptr);
+
+done:
+ git_buf_dispose(&ref_name);
+ return error;
+}
+
/* Deprecated Functions */
+#ifndef GIT_DEPRECATE_HARD
int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite)
{
return git_tag_create_from_buffer(oid, repo, buffer, allow_ref_overwrite);
}
+#endif
diff --git a/src/thread-utils.c b/src/thread-utils.c
deleted file mode 100644
index e5ec6a8..0000000
--- a/src/thread-utils.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "common.h"
-#include "thread-utils.h"
-
-#ifdef _WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-#endif
-# include <windows.h>
-#elif defined(hpux) || defined(__hpux) || defined(_hpux)
-# include <sys/pstat.h>
-#endif
-
-/*
- * By doing this in two steps we can at least get
- * the function to be somewhat coherent, even
- * with this disgusting nest of #ifdefs.
- */
-#ifndef _SC_NPROCESSORS_ONLN
-# ifdef _SC_NPROC_ONLN
-# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
-# elif defined _SC_CRAY_NCPU
-# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
-# endif
-#endif
-
-int git_online_cpus(void)
-{
-#ifdef _SC_NPROCESSORS_ONLN
- long ncpus;
-#endif
-
-#ifdef _WIN32
- SYSTEM_INFO info;
- GetSystemInfo(&info);
-
- if ((int)info.dwNumberOfProcessors > 0)
- return (int)info.dwNumberOfProcessors;
-#elif defined(hpux) || defined(__hpux) || defined(_hpux)
- struct pst_dynamic psd;
-
- if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0))
- return (int)psd.psd_proc_cnt;
-#endif
-
-#ifdef _SC_NPROCESSORS_ONLN
- if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
- return (int)ncpus;
-#endif
-
- return 1;
-}
diff --git a/src/thread-utils.h b/src/thread-utils.h
deleted file mode 100644
index 035de69..0000000
--- a/src/thread-utils.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_thread_utils_h__
-#define INCLUDE_thread_utils_h__
-
-#if defined(__GNUC__) && defined(GIT_THREADS)
-# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1))
-# error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DTHREADSAFE=OFF
-# endif
-#endif
-
-/* Common operations even if threading has been disabled */
-typedef struct {
-#if defined(GIT_WIN32)
- volatile long val;
-#else
- volatile int val;
-#endif
-} git_atomic;
-
-#ifdef GIT_ARCH_64
-
-typedef struct {
-#if defined(GIT_WIN32)
- __int64 val;
-#else
- int64_t val;
-#endif
-} git_atomic64;
-
-typedef git_atomic64 git_atomic_ssize;
-
-#define git_atomic_ssize_add git_atomic64_add
-
-#else
-
-typedef git_atomic git_atomic_ssize;
-
-#define git_atomic_ssize_add git_atomic_add
-
-#endif
-
-#ifdef GIT_THREADS
-
-#ifdef GIT_WIN32
-# include "win32/thread.h"
-#else
-# include "unix/pthread.h"
-#endif
-
-GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
-{
-#if defined(GIT_WIN32)
- InterlockedExchange(&a->val, (LONG)val);
-#elif defined(__GNUC__)
- __sync_lock_test_and_set(&a->val, val);
-#else
-# error "Unsupported architecture for atomic operations"
-#endif
-}
-
-GIT_INLINE(int) git_atomic_inc(git_atomic *a)
-{
-#if defined(GIT_WIN32)
- return InterlockedIncrement(&a->val);
-#elif defined(__GNUC__)
- return __sync_add_and_fetch(&a->val, 1);
-#else
-# error "Unsupported architecture for atomic operations"
-#endif
-}
-
-GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
-{
-#if defined(GIT_WIN32)
- return InterlockedExchangeAdd(&a->val, addend);
-#elif defined(__GNUC__)
- return __sync_add_and_fetch(&a->val, addend);
-#else
-# error "Unsupported architecture for atomic operations"
-#endif
-}
-
-GIT_INLINE(int) git_atomic_dec(git_atomic *a)
-{
-#if defined(GIT_WIN32)
- return InterlockedDecrement(&a->val);
-#elif defined(__GNUC__)
- return __sync_sub_and_fetch(&a->val, 1);
-#else
-# error "Unsupported architecture for atomic operations"
-#endif
-}
-
-GIT_INLINE(void *) git___compare_and_swap(
- void * volatile *ptr, void *oldval, void *newval)
-{
- volatile void *foundval;
-#if defined(GIT_WIN32)
- foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
-#elif defined(__GNUC__)
- foundval = __sync_val_compare_and_swap(ptr, oldval, newval);
-#else
-# error "Unsupported architecture for atomic operations"
-#endif
- return (foundval == oldval) ? oldval : newval;
-}
-
-GIT_INLINE(volatile void *) git___swap(
- void * volatile *ptr, void *newval)
-{
-#if defined(GIT_WIN32)
- return InterlockedExchangePointer(ptr, newval);
-#else
- return __sync_lock_test_and_set(ptr, newval);
-#endif
-}
-
-#ifdef GIT_ARCH_64
-
-GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
-{
-#if defined(GIT_WIN32)
- return InterlockedExchangeAdd64(&a->val, addend);
-#elif defined(__GNUC__)
- return __sync_add_and_fetch(&a->val, addend);
-#else
-# error "Unsupported architecture for atomic operations"
-#endif
-}
-
-#endif
-
-#else
-
-#define git_thread unsigned int
-#define git_thread_create(thread, start_routine, arg) 0
-#define git_thread_join(id, status) (void)0
-
-/* Pthreads Mutex */
-#define git_mutex unsigned int
-GIT_INLINE(int) git_mutex_init(git_mutex *mutex) \
- { GIT_UNUSED(mutex); return 0; }
-GIT_INLINE(int) git_mutex_lock(git_mutex *mutex) \
- { GIT_UNUSED(mutex); return 0; }
-#define git_mutex_unlock(a) (void)0
-#define git_mutex_free(a) (void)0
-
-/* Pthreads condition vars */
-#define git_cond unsigned int
-#define git_cond_init(c, a) (void)0
-#define git_cond_free(c) (void)0
-#define git_cond_wait(c, l) (void)0
-#define git_cond_signal(c) (void)0
-#define git_cond_broadcast(c) (void)0
-
-/* Pthreads rwlock */
-#define git_rwlock unsigned int
-#define git_rwlock_init(a) 0
-#define git_rwlock_rdlock(a) 0
-#define git_rwlock_rdunlock(a) (void)0
-#define git_rwlock_wrlock(a) 0
-#define git_rwlock_wrunlock(a) (void)0
-#define git_rwlock_free(a) (void)0
-#define GIT_RWLOCK_STATIC_INIT 0
-
-
-GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
-{
- a->val = val;
-}
-
-GIT_INLINE(int) git_atomic_inc(git_atomic *a)
-{
- return ++a->val;
-}
-
-GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
-{
- a->val += addend;
- return a->val;
-}
-
-GIT_INLINE(int) git_atomic_dec(git_atomic *a)
-{
- return --a->val;
-}
-
-GIT_INLINE(void *) git___compare_and_swap(
- void * volatile *ptr, void *oldval, void *newval)
-{
- if (*ptr == oldval)
- *ptr = newval;
- else
- oldval = newval;
- return oldval;
-}
-
-GIT_INLINE(volatile void *) git___swap(
- void * volatile *ptr, void *newval)
-{
- volatile void *old = *ptr;
- *ptr = newval;
- return old;
-}
-
-#ifdef GIT_ARCH_64
-
-GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
-{
- a->val += addend;
- return a->val;
-}
-
-#endif
-
-#endif
-
-GIT_INLINE(int) git_atomic_get(git_atomic *a)
-{
- return (int)a->val;
-}
-
-/* Atomically replace oldval with newval
- * @return oldval if it was replaced or newval if it was not
- */
-#define git__compare_and_swap(P,O,N) \
- git___compare_and_swap((void * volatile *)P, O, N)
-
-#define git__swap(ptr, val) (void *)git___swap((void * volatile *)&ptr, val)
-
-extern int git_online_cpus(void);
-
-#if defined(GIT_THREADS) && defined(_MSC_VER)
-# define GIT_MEMORY_BARRIER MemoryBarrier()
-#elif defined(GIT_THREADS)
-# define GIT_MEMORY_BARRIER __sync_synchronize()
-#else
-# define GIT_MEMORY_BARRIER /* noop */
-#endif
-
-#endif
diff --git a/src/thread.c b/src/thread.c
new file mode 100644
index 0000000..3171771
--- /dev/null
+++ b/src/thread.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "common.h"
+
+#if !defined(GIT_THREADS)
+
+#define TLSDATA_MAX 16
+
+typedef struct {
+ void *value;
+ void (GIT_SYSTEM_CALL *destroy_fn)(void *);
+} tlsdata_value;
+
+static tlsdata_value tlsdata_values[TLSDATA_MAX];
+static int tlsdata_cnt = 0;
+
+int git_tlsdata_init(git_tlsdata_key *key, void (GIT_SYSTEM_CALL *destroy_fn)(void *))
+{
+ if (tlsdata_cnt >= TLSDATA_MAX)
+ return -1;
+
+ tlsdata_values[tlsdata_cnt].value = NULL;
+ tlsdata_values[tlsdata_cnt].destroy_fn = destroy_fn;
+
+ *key = tlsdata_cnt;
+ tlsdata_cnt++;
+
+ return 0;
+}
+
+int git_tlsdata_set(git_tlsdata_key key, void *value)
+{
+ if (key < 0 || key > tlsdata_cnt)
+ return -1;
+
+ tlsdata_values[key].value = value;
+ return 0;
+}
+
+void *git_tlsdata_get(git_tlsdata_key key)
+{
+ if (key < 0 || key > tlsdata_cnt)
+ return NULL;
+
+ return tlsdata_values[key].value;
+}
+
+int git_tlsdata_dispose(git_tlsdata_key key)
+{
+ void *value;
+ void (*destroy_fn)(void *) = NULL;
+
+ if (key < 0 || key > tlsdata_cnt)
+ return -1;
+
+ value = tlsdata_values[key].value;
+ destroy_fn = tlsdata_values[key].destroy_fn;
+
+ tlsdata_values[key].value = NULL;
+ tlsdata_values[key].destroy_fn = NULL;
+
+ if (value && destroy_fn)
+ destroy_fn(value);
+
+ return 0;
+}
+
+#elif defined(GIT_WIN32)
+
+int git_tlsdata_init(git_tlsdata_key *key, void (GIT_SYSTEM_CALL *destroy_fn)(void *))
+{
+ DWORD fls_index = FlsAlloc(destroy_fn);
+
+ if (fls_index == FLS_OUT_OF_INDEXES)
+ return -1;
+
+ *key = fls_index;
+ return 0;
+}
+
+int git_tlsdata_set(git_tlsdata_key key, void *value)
+{
+ if (!FlsSetValue(key, value))
+ return -1;
+
+ return 0;
+}
+
+void *git_tlsdata_get(git_tlsdata_key key)
+{
+ return FlsGetValue(key);
+}
+
+int git_tlsdata_dispose(git_tlsdata_key key)
+{
+ if (!FlsFree(key))
+ return -1;
+
+ return 0;
+}
+
+#elif defined(_POSIX_THREADS)
+
+int git_tlsdata_init(git_tlsdata_key *key, void (GIT_SYSTEM_CALL *destroy_fn)(void *))
+{
+ if (pthread_key_create(key, destroy_fn) != 0)
+ return -1;
+
+ return 0;
+}
+
+int git_tlsdata_set(git_tlsdata_key key, void *value)
+{
+ if (pthread_setspecific(key, value) != 0)
+ return -1;
+
+ return 0;
+}
+
+void *git_tlsdata_get(git_tlsdata_key key)
+{
+ return pthread_getspecific(key);
+}
+
+int git_tlsdata_dispose(git_tlsdata_key key)
+{
+ if (pthread_key_delete(key) != 0)
+ return -1;
+
+ return 0;
+}
+
+#else
+# error unknown threading model
+#endif
diff --git a/src/thread.h b/src/thread.h
new file mode 100644
index 0000000..4b091c0
--- /dev/null
+++ b/src/thread.h
@@ -0,0 +1,479 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_thread_h__
+#define INCLUDE_thread_h__
+
+#if defined(GIT_THREADS)
+
+#if defined(__clang__)
+
+# if (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1))
+# error Atomic primitives do not exist on this version of clang; configure libgit2 with -DTHREADSAFE=OFF
+# else
+# define GIT_BUILTIN_ATOMIC
+# endif
+
+#elif defined(__GNUC__)
+
+# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1))
+# error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DTHREADSAFE=OFF
+# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
+# define GIT_BUILTIN_ATOMIC
+# else
+# define GIT_BUILTIN_SYNC
+# endif
+
+#endif
+
+#endif /* GIT_THREADS */
+
+/* Common operations even if threading has been disabled */
+typedef struct {
+#if defined(GIT_WIN32)
+ volatile long val;
+#else
+ volatile int val;
+#endif
+} git_atomic32;
+
+#ifdef GIT_ARCH_64
+
+typedef struct {
+#if defined(GIT_WIN32)
+ volatile __int64 val;
+#else
+ volatile int64_t val;
+#endif
+} git_atomic64;
+
+typedef git_atomic64 git_atomic_ssize;
+
+#define git_atomic_ssize_set git_atomic64_set
+#define git_atomic_ssize_add git_atomic64_add
+#define git_atomic_ssize_get git_atomic64_get
+
+#else
+
+typedef git_atomic32 git_atomic_ssize;
+
+#define git_atomic_ssize_set git_atomic32_set
+#define git_atomic_ssize_add git_atomic32_add
+#define git_atomic_ssize_get git_atomic32_get
+
+#endif
+
+#ifdef GIT_THREADS
+
+#ifdef GIT_WIN32
+# include "win32/thread.h"
+#else
+# include "unix/pthread.h"
+#endif
+
+/*
+ * Atomically sets the contents of *a to be val.
+ */
+GIT_INLINE(void) git_atomic32_set(git_atomic32 *a, int val)
+{
+#if defined(GIT_WIN32)
+ InterlockedExchange(&a->val, (LONG)val);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ __atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ __sync_lock_test_and_set(&a->val, val);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+/*
+ * Atomically increments the contents of *a by 1, and stores the result back into *a.
+ * @return the result of the operation.
+ */
+GIT_INLINE(int) git_atomic32_inc(git_atomic32 *a)
+{
+#if defined(GIT_WIN32)
+ return InterlockedIncrement(&a->val);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return __atomic_add_fetch(&a->val, 1, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_add_and_fetch(&a->val, 1);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+/*
+ * Atomically adds the contents of *a and addend, and stores the result back into *a.
+ * @return the result of the operation.
+ */
+GIT_INLINE(int) git_atomic32_add(git_atomic32 *a, int32_t addend)
+{
+#if defined(GIT_WIN32)
+ return InterlockedAdd(&a->val, addend);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_add_and_fetch(&a->val, addend);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+/*
+ * Atomically decrements the contents of *a by 1, and stores the result back into *a.
+ * @return the result of the operation.
+ */
+GIT_INLINE(int) git_atomic32_dec(git_atomic32 *a)
+{
+#if defined(GIT_WIN32)
+ return InterlockedDecrement(&a->val);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return __atomic_sub_fetch(&a->val, 1, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_sub_and_fetch(&a->val, 1);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+/*
+ * Atomically gets the contents of *a.
+ * @return the contents of *a.
+ */
+GIT_INLINE(int) git_atomic32_get(git_atomic32 *a)
+{
+#if defined(GIT_WIN32)
+ return (int)InterlockedCompareExchange(&a->val, 0, 0);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_val_compare_and_swap(&a->val, 0, 0);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+GIT_INLINE(void *) git_atomic__compare_and_swap(
+ void * volatile *ptr, void *oldval, void *newval)
+{
+#if defined(GIT_WIN32)
+ return InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ void *foundval = oldval;
+ __atomic_compare_exchange(ptr, &foundval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ return foundval;
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_val_compare_and_swap(ptr, oldval, newval);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+GIT_INLINE(volatile void *) git_atomic__swap(
+ void * volatile *ptr, void *newval)
+{
+#if defined(GIT_WIN32)
+ return InterlockedExchangePointer(ptr, newval);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ void * volatile foundval = NULL;
+ __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST);
+ return foundval;
+#elif defined(GIT_BUILTIN_SYNC)
+ return (volatile void *)__sync_lock_test_and_set(ptr, newval);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+GIT_INLINE(volatile void *) git_atomic__load(void * volatile *ptr)
+{
+#if defined(GIT_WIN32)
+ void *newval = NULL, *oldval = NULL;
+ return (volatile void *)InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return (volatile void *)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return (volatile void *)__sync_val_compare_and_swap(ptr, 0, 0);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+#ifdef GIT_ARCH_64
+
+/*
+ * Atomically adds the contents of *a and addend, and stores the result back into *a.
+ * @return the result of the operation.
+ */
+GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
+{
+#if defined(GIT_WIN32)
+ return InterlockedAdd64(&a->val, addend);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_add_and_fetch(&a->val, addend);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+/*
+ * Atomically sets the contents of *a to be val.
+ */
+GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val)
+{
+#if defined(GIT_WIN32)
+ InterlockedExchange64(&a->val, val);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ __atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ __sync_lock_test_and_set(&a->val, val);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+/*
+ * Atomically gets the contents of *a.
+ * @return the contents of *a.
+ */
+GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
+{
+#if defined(GIT_WIN32)
+ return (int64_t)InterlockedCompareExchange64(&a->val, 0, 0);
+#elif defined(GIT_BUILTIN_ATOMIC)
+ return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST);
+#elif defined(GIT_BUILTIN_SYNC)
+ return __sync_val_compare_and_swap(&a->val, 0, 0);
+#else
+# error "Unsupported architecture for atomic operations"
+#endif
+}
+
+#endif
+
+#else
+
+#define git_threads_global_init git__noop
+
+#define git_thread unsigned int
+#define git_thread_create(thread, start_routine, arg) git__noop()
+#define git_thread_join(id, status) git__noop()
+
+/* Pthreads Mutex */
+#define git_mutex unsigned int
+#define git_mutex_init(a) git__noop()
+#define git_mutex_init(a) git__noop()
+#define git_mutex_lock(a) git__noop()
+#define git_mutex_unlock(a) git__noop()
+#define git_mutex_free(a) git__noop()
+
+/* Pthreads condition vars */
+#define git_cond unsigned int
+#define git_cond_init(c) git__noop()
+#define git_cond_free(c) git__noop()
+#define git_cond_wait(c, l) git__noop()
+#define git_cond_signal(c) git__noop()
+#define git_cond_broadcast(c) git__noop()
+
+/* Pthreads rwlock */
+#define git_rwlock unsigned int
+#define git_rwlock_init(a) git__noop()
+#define git_rwlock_rdlock(a) git__noop()
+#define git_rwlock_rdunlock(a) git__noop()
+#define git_rwlock_wrlock(a) git__noop()
+#define git_rwlock_wrunlock(a) git__noop()
+#define git_rwlock_free(a) git__noop()
+#define GIT_RWLOCK_STATIC_INIT 0
+
+
+GIT_INLINE(void) git_atomic32_set(git_atomic32 *a, int val)
+{
+ a->val = val;
+}
+
+GIT_INLINE(int) git_atomic32_inc(git_atomic32 *a)
+{
+ return ++a->val;
+}
+
+GIT_INLINE(int) git_atomic32_add(git_atomic32 *a, int32_t addend)
+{
+ a->val += addend;
+ return a->val;
+}
+
+GIT_INLINE(int) git_atomic32_dec(git_atomic32 *a)
+{
+ return --a->val;
+}
+
+GIT_INLINE(int) git_atomic32_get(git_atomic32 *a)
+{
+ return (int)a->val;
+}
+
+GIT_INLINE(void *) git_atomic__compare_and_swap(
+ void * volatile *ptr, void *oldval, void *newval)
+{
+ void *foundval = *ptr;
+ if (foundval == oldval)
+ *ptr = newval;
+ return foundval;
+}
+
+GIT_INLINE(volatile void *) git_atomic__swap(
+ void * volatile *ptr, void *newval)
+{
+ volatile void *old = *ptr;
+ *ptr = newval;
+ return old;
+}
+
+GIT_INLINE(volatile void *) git_atomic__load(void * volatile *ptr)
+{
+ return *ptr;
+}
+
+#ifdef GIT_ARCH_64
+
+GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
+{
+ a->val += addend;
+ return a->val;
+}
+
+GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val)
+{
+ a->val = val;
+}
+
+GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
+{
+ return (int64_t)a->val;
+}
+
+#endif
+
+#endif
+
+/*
+ * Atomically replace the contents of *ptr (if they are equal to oldval) with
+ * newval. ptr must point to a pointer or a value that is the same size as a
+ * pointer. This is semantically compatible with:
+ *
+ * #define git_atomic_compare_and_swap(ptr, oldval, newval) \
+ * ({ \
+ * void *foundval = *ptr; \
+ * if (foundval == oldval) \
+ * *ptr = newval; \
+ * foundval; \
+ * })
+ *
+ * @return the original contents of *ptr.
+ */
+#define git_atomic_compare_and_swap(ptr, oldval, newval) \
+ git_atomic__compare_and_swap((void * volatile *)ptr, oldval, newval)
+
+/*
+ * Atomically replace the contents of v with newval. v must be the same size as
+ * a pointer. This is semantically compatible with:
+ *
+ * #define git_atomic_swap(v, newval) \
+ * ({ \
+ * volatile void *old = v; \
+ * v = newval; \
+ * old; \
+ * })
+ *
+ * @return the original contents of v.
+ */
+#define git_atomic_swap(v, newval) \
+ (void *)git_atomic__swap((void * volatile *)&(v), newval)
+
+/*
+ * Atomically reads the contents of v. v must be the same size as a pointer.
+ * This is semantically compatible with:
+ *
+ * #define git_atomic_load(v) v
+ *
+ * @return the contents of v.
+ */
+#define git_atomic_load(v) \
+ (void *)git_atomic__load((void * volatile *)&(v))
+
+#if defined(GIT_THREADS)
+
+# if defined(GIT_WIN32)
+# define GIT_MEMORY_BARRIER MemoryBarrier()
+# elif defined(GIT_BUILTIN_ATOMIC)
+# define GIT_MEMORY_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST)
+# elif defined(GIT_BUILTIN_SYNC)
+# define GIT_MEMORY_BARRIER __sync_synchronize()
+# endif
+
+#else
+
+# define GIT_MEMORY_BARRIER /* noop */
+
+#endif
+
+/* Thread-local data */
+
+#if !defined(GIT_THREADS)
+# define git_tlsdata_key int
+#elif defined(GIT_WIN32)
+# define git_tlsdata_key DWORD
+#elif defined(_POSIX_THREADS)
+# define git_tlsdata_key pthread_key_t
+#else
+# error unknown threading model
+#endif
+
+/**
+ * Create a thread-local data key. The destroy function will be
+ * called upon thread exit. On some platforms, it may be called
+ * when all threads have deleted their keys.
+ *
+ * Note that the tlsdata functions do not set an error message on
+ * failure; this is because the error handling in libgit2 is itself
+ * handled by thread-local data storage.
+ *
+ * @param key the tlsdata key
+ * @param destroy_fn function pointer called upon thread exit
+ * @return 0 on success, non-zero on failure
+ */
+int git_tlsdata_init(git_tlsdata_key *key, void (GIT_SYSTEM_CALL *destroy_fn)(void *));
+
+/**
+ * Set a the thread-local value for the given key.
+ *
+ * @param key the tlsdata key to store data on
+ * @param value the pointer to store
+ * @return 0 on success, non-zero on failure
+ */
+int git_tlsdata_set(git_tlsdata_key key, void *value);
+
+/**
+ * Get the thread-local value for the given key.
+ *
+ * @param key the tlsdata key to retrieve the value of
+ * @return the pointer stored with git_tlsdata_set
+ */
+void *git_tlsdata_get(git_tlsdata_key key);
+
+/**
+ * Delete the given thread-local key.
+ *
+ * @param key the tlsdata key to dispose
+ * @return 0 on success, non-zero on failure
+ */
+int git_tlsdata_dispose(git_tlsdata_key key);
+
+#endif
diff --git a/src/threadstate.c b/src/threadstate.c
new file mode 100644
index 0000000..6031e82
--- /dev/null
+++ b/src/threadstate.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "threadstate.h"
+#include "runtime.h"
+
+/**
+ * Handle the thread-local state
+ *
+ * `git_threadstate_global_init` will be called as part
+ * of `git_libgit2_init` (which itself must be called
+ * before calling any other function in the library).
+ *
+ * This function allocates a TLS index to store the per-
+ * thread state.
+ *
+ * Any internal method that requires thread-local state
+ * will then call `git_threadstate_get()` which returns a
+ * pointer to the thread-local state structure; this
+ * structure is lazily allocated on each thread.
+ *
+ * This mechanism will register a shutdown handler
+ * (`git_threadstate_global_shutdown`) which will free the
+ * TLS index. This shutdown handler will be called by
+ * `git_libgit2_shutdown`.
+ */
+
+static git_tlsdata_key tls_key;
+
+static void threadstate_dispose(git_threadstate *threadstate)
+{
+ if (!threadstate)
+ return;
+
+ git__free(threadstate->error_t.message);
+ threadstate->error_t.message = NULL;
+}
+
+static void GIT_SYSTEM_CALL threadstate_free(void *threadstate)
+{
+ threadstate_dispose(threadstate);
+ git__free(threadstate);
+}
+
+static void git_threadstate_global_shutdown(void)
+{
+ git_threadstate *threadstate;
+
+ threadstate = git_tlsdata_get(tls_key);
+ git_tlsdata_set(tls_key, NULL);
+
+ threadstate_dispose(threadstate);
+ git__free(threadstate);
+
+ git_tlsdata_dispose(tls_key);
+}
+
+int git_threadstate_global_init(void)
+{
+ if (git_tlsdata_init(&tls_key, &threadstate_free) != 0)
+ return -1;
+
+ return git_runtime_shutdown_register(git_threadstate_global_shutdown);
+}
+
+git_threadstate *git_threadstate_get(void)
+{
+ git_threadstate *threadstate;
+
+ if ((threadstate = git_tlsdata_get(tls_key)) != NULL)
+ return threadstate;
+
+ if ((threadstate = git__calloc(1, sizeof(git_threadstate))) == NULL ||
+ git_buf_init(&threadstate->error_buf, 0) < 0)
+ return NULL;
+
+ git_tlsdata_set(tls_key, threadstate);
+ return threadstate;
+}
diff --git a/src/threadstate.h b/src/threadstate.h
new file mode 100644
index 0000000..51810a9
--- /dev/null
+++ b/src/threadstate.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_threadstate_h__
+#define INCLUDE_threadstate_h__
+
+#include "common.h"
+
+typedef struct {
+ git_error *last_error;
+ git_error error_t;
+ git_buf error_buf;
+ char oid_fmt[GIT_OID_HEXSZ+1];
+} git_threadstate;
+
+extern int git_threadstate_global_init(void);
+extern git_threadstate *git_threadstate_get(void);
+
+#define GIT_THREADSTATE (git_threadstate_get())
+
+#endif
diff --git a/src/trace.c b/src/trace.c
index ec6a90a..efc7b01 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -8,7 +8,7 @@
#include "trace.h"
#include "buffer.h"
-#include "global.h"
+#include "runtime.h"
#include "git2/trace.h"
#ifdef GIT_TRACE
@@ -20,7 +20,7 @@ struct git_trace_data git_trace__data = {0};
int git_trace_set(git_trace_level_t level, git_trace_cb callback)
{
#ifdef GIT_TRACE
- assert(level == 0 || callback != NULL);
+ GIT_ASSERT_ARG(level == 0 || callback != NULL);
git_trace__data.level = level;
git_trace__data.callback = callback;
diff --git a/src/trace.h b/src/trace.h
index e15118e..a233aa2 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -23,28 +23,32 @@ extern struct git_trace_data git_trace__data;
GIT_INLINE(void) git_trace__write_fmt(
git_trace_level_t level,
- const char *fmt, ...)
+ const char *fmt,
+ va_list ap)
{
git_trace_cb callback = git_trace__data.callback;
git_buf message = GIT_BUF_INIT;
- va_list ap;
- va_start(ap, fmt);
git_buf_vprintf(&message, fmt, ap);
- va_end(ap);
callback(level, git_buf_cstr(&message));
git_buf_dispose(&message);
}
-#define git_trace_level() (git_trace__data.level)
-#define git_trace(l, ...) { \
- if (git_trace__data.level >= l && \
- git_trace__data.callback != NULL) { \
- git_trace__write_fmt(l, __VA_ARGS__); \
- } \
- }
+#define git_trace_level() (git_trace__data.level)
+
+GIT_INLINE(void) git_trace(git_trace_level_t level, const char *fmt, ...)
+{
+ if (git_trace__data.level >= level &&
+ git_trace__data.callback != NULL) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ git_trace__write_fmt(level, fmt, ap);
+ va_end(ap);
+ }
+}
#else
@@ -56,8 +60,8 @@ GIT_INLINE(void) git_trace__null(
GIT_UNUSED(fmt);
}
-#define git_trace_level() ((git_trace_level_t)0)
-#define git_trace git_trace__null
+#define git_trace_level() ((git_trace_level_t)0)
+#define git_trace git_trace__null
#endif
diff --git a/src/transaction.c b/src/transaction.c
index 7367d12..98fa1ba 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -57,7 +57,9 @@ struct git_transaction {
int git_transaction_config_new(git_transaction **out, git_config *cfg)
{
git_transaction *tx;
- assert(out && cfg);
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(cfg);
tx = git__calloc(1, sizeof(git_transaction));
GIT_ERROR_CHECK_ALLOC(tx);
@@ -74,9 +76,11 @@ int git_transaction_new(git_transaction **out, git_repository *repo)
git_pool pool;
git_transaction *tx = NULL;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
- git_pool_init(&pool, 1);
+ if ((error = git_pool_init(&pool, 1)) < 0)
+ goto on_error;
tx = git_pool_mallocz(&pool, sizeof(git_transaction));
if (!tx) {
@@ -108,7 +112,8 @@ int git_transaction_lock_ref(git_transaction *tx, const char *refname)
int error;
transaction_node *node;
- assert(tx && refname);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
node = git_pool_mallocz(&tx->pool, sizeof(transaction_node));
GIT_ERROR_CHECK_ALLOC(node);
@@ -175,7 +180,9 @@ int git_transaction_set_target(git_transaction *tx, const char *refname, const g
int error;
transaction_node *node;
- assert(tx && refname && target);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(target);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -194,7 +201,9 @@ int git_transaction_set_symbolic_target(git_transaction *tx, const char *refname
int error;
transaction_node *node;
- assert(tx && refname && target);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(target);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -271,7 +280,9 @@ int git_transaction_set_reflog(git_transaction *tx, const char *refname, const g
int error;
transaction_node *node;
- assert(tx && refname && reflog);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(reflog);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -319,7 +330,7 @@ int git_transaction_commit(git_transaction *tx)
transaction_node *node;
int error = 0;
- assert(tx);
+ GIT_ASSERT_ARG(tx);
if (tx->type == TRANSACTION_CONFIG) {
error = git_config_unlock(tx->cfg, true);
@@ -354,7 +365,8 @@ void git_transaction_free(git_transaction *tx)
transaction_node *node;
git_pool pool;
- assert(tx);
+ if (!tx)
+ return;
if (tx->type == TRANSACTION_CONFIG) {
if (tx->cfg) {
diff --git a/src/transport.c b/src/transport.c
index 227ee7d..e128aa6 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -148,8 +148,8 @@ int git_transport_register(
size_t i;
int error = 0;
- assert(scheme);
- assert(cb);
+ GIT_ASSERT_ARG(scheme);
+ GIT_ASSERT_ARG(cb);
if ((error = git_buf_printf(&prefix, "%s://", scheme)) < 0)
goto on_error;
@@ -186,7 +186,7 @@ int git_transport_unregister(const char *scheme)
size_t i;
int error = 0;
- assert(scheme);
+ GIT_ASSERT_ARG(scheme);
if ((error = git_buf_printf(&prefix, "%s://", scheme)) < 0)
goto done;
diff --git a/src/transports/auth_negotiate.c b/src/transports/auth_negotiate.c
index a04efce..3146993 100644
--- a/src/transports/auth_negotiate.c
+++ b/src/transports/auth_negotiate.c
@@ -65,7 +65,9 @@ static int negotiate_set_challenge(
{
http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c;
- assert(ctx && ctx->configured && challenge);
+ GIT_ASSERT_ARG(ctx);
+ GIT_ASSERT_ARG(challenge);
+ GIT_ASSERT(ctx->configured);
git__free(ctx->challenge);
@@ -108,7 +110,12 @@ static int negotiate_next_token(
size_t challenge_len;
int error = 0;
- assert(buf && ctx && ctx->configured && cred && cred->credtype == GIT_CREDENTIAL_DEFAULT);
+ GIT_ASSERT_ARG(buf);
+ GIT_ASSERT_ARG(ctx);
+ GIT_ASSERT_ARG(cred);
+
+ GIT_ASSERT(ctx->configured);
+ GIT_ASSERT(cred->credtype == GIT_CREDENTIAL_DEFAULT);
if (ctx->complete)
return 0;
@@ -202,7 +209,7 @@ static int negotiate_is_complete(git_http_auth_context *c)
{
http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c;
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
return (ctx->complete == 1);
}
diff --git a/src/transports/auth_ntlm.c b/src/transports/auth_ntlm.c
index 645aa34..742db75 100644
--- a/src/transports/auth_ntlm.c
+++ b/src/transports/auth_ntlm.c
@@ -14,7 +14,7 @@
#ifdef GIT_NTLM
-#include "ntlm.h"
+#include "ntlmclient.h"
typedef struct {
git_http_auth_context parent;
@@ -29,7 +29,8 @@ static int ntlm_set_challenge(
{
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
- assert(ctx && challenge);
+ GIT_ASSERT_ARG(ctx);
+ GIT_ASSERT_ARG(challenge);
git__free(ctx->challenge);
@@ -46,14 +47,14 @@ static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_credential *_cr
char *domain = NULL, *domainuser = NULL;
int error = 0;
- assert(_cred->credtype == GIT_CREDENTIAL_USERPASS_PLAINTEXT);
+ GIT_ASSERT(_cred->credtype == GIT_CREDENTIAL_USERPASS_PLAINTEXT);
cred = (git_credential_userpass_plaintext *)_cred;
if ((sep = strchr(cred->username, '\\')) != NULL) {
- domain = strndup(cred->username, (sep - cred->username));
+ domain = git__strndup(cred->username, (sep - cred->username));
GIT_ERROR_CHECK_ALLOC(domain);
- domainuser = strdup(sep + 1);
+ domainuser = git__strdup(sep + 1);
GIT_ERROR_CHECK_ALLOC(domainuser);
username = domainuser;
@@ -86,7 +87,10 @@ static int ntlm_next_token(
size_t challenge_len, msg_len;
int error = GIT_EAUTH;
- assert(buf && ctx && ctx->ntlm);
+ GIT_ASSERT_ARG(buf);
+ GIT_ASSERT_ARG(ctx);
+
+ GIT_ASSERT(ctx->ntlm);
challenge_len = ctx->challenge ? strlen(ctx->challenge) : 0;
@@ -162,7 +166,7 @@ static int ntlm_is_complete(git_http_auth_context *c)
{
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
- assert(ctx);
+ GIT_ASSERT_ARG(ctx);
return (ctx->complete == true);
}
diff --git a/src/transports/credential.c b/src/transports/credential.c
index 0cf50a0..6e00b02 100644
--- a/src/transports/credential.c
+++ b/src/transports/credential.c
@@ -85,7 +85,9 @@ int git_credential_userpass_plaintext_new(
{
git_credential_userpass_plaintext *c;
- assert(cred && username && password);
+ GIT_ASSERT_ARG(cred);
+ GIT_ASSERT_ARG(username);
+ GIT_ASSERT_ARG(password);
c = git__malloc(sizeof(git_credential_userpass_plaintext));
GIT_ERROR_CHECK_ALLOC(c);
@@ -233,7 +235,9 @@ static int git_credential_ssh_key_type_new(
{
git_credential_ssh_key *c;
- assert(username && cred && privatekey);
+ GIT_ASSERT_ARG(username);
+ GIT_ASSERT_ARG(cred);
+ GIT_ASSERT_ARG(privatekey);
c = git__calloc(1, sizeof(git_credential_ssh_key));
GIT_ERROR_CHECK_ALLOC(c);
@@ -269,7 +273,9 @@ int git_credential_ssh_interactive_new(
{
git_credential_ssh_interactive *c;
- assert(out && username && prompt_callback);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(username);
+ GIT_ASSERT_ARG(prompt_callback);
c = git__calloc(1, sizeof(git_credential_ssh_interactive));
GIT_ERROR_CHECK_ALLOC(c);
@@ -290,7 +296,8 @@ int git_credential_ssh_interactive_new(
int git_credential_ssh_key_from_agent(git_credential **cred, const char *username) {
git_credential_ssh_key *c;
- assert(username && cred);
+ GIT_ASSERT_ARG(username);
+ GIT_ASSERT_ARG(cred);
c = git__calloc(1, sizeof(git_credential_ssh_key));
GIT_ERROR_CHECK_ALLOC(c);
@@ -317,7 +324,8 @@ int git_credential_ssh_custom_new(
{
git_credential_ssh_custom *c;
- assert(username && cred);
+ GIT_ASSERT_ARG(username);
+ GIT_ASSERT_ARG(cred);
c = git__calloc(1, sizeof(git_credential_ssh_custom));
GIT_ERROR_CHECK_ALLOC(c);
@@ -347,7 +355,7 @@ int git_credential_default_new(git_credential **cred)
{
git_credential_default *c;
- assert(cred);
+ GIT_ASSERT_ARG(cred);
c = git__calloc(1, sizeof(git_credential_default));
GIT_ERROR_CHECK_ALLOC(c);
@@ -364,7 +372,7 @@ int git_credential_username_new(git_credential **cred, const char *username)
git_credential_username *c;
size_t len, allocsize;
- assert(cred);
+ GIT_ASSERT_ARG(cred);
len = strlen(username);
@@ -391,6 +399,7 @@ void git_credential_free(git_credential *cred)
/* Deprecated credential functions */
+#ifndef GIT_DEPRECATE_HARD
int git_cred_has_username(git_credential *cred)
{
return git_credential_has_username(cred);
@@ -474,3 +483,4 @@ void git_cred_free(git_credential *cred)
{
git_credential_free(cred);
}
+#endif
diff --git a/src/transports/credential_helpers.c b/src/transports/credential_helpers.c
index 6b975e1..6d34a4e 100644
--- a/src/transports/credential_helpers.c
+++ b/src/transports/credential_helpers.c
@@ -54,6 +54,7 @@ int git_credential_userpass(
/* Deprecated credential functions */
+#ifndef GIT_DEPRECATE_HARD
int git_cred_userpass(
git_credential **out,
const char *url,
@@ -64,3 +65,4 @@ int git_cred_userpass(
return git_credential_userpass(out, url, user_from_url,
allowed_types, payload);
}
+#endif
diff --git a/src/transports/git.c b/src/transports/git.c
index e48b7f9..7c93155 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -327,7 +327,7 @@ static int _git_close(git_smart_subtransport *subtransport)
{
git_subtransport *t = (git_subtransport *) subtransport;
- assert(!t->current_stream);
+ GIT_ASSERT(!t->current_stream);
GIT_UNUSED(t);
@@ -338,8 +338,6 @@ static void _git_free(git_smart_subtransport *subtransport)
{
git_subtransport *t = (git_subtransport *) subtransport;
- assert(!t->current_stream);
-
git__free(t);
}
diff --git a/src/transports/http.c b/src/transports/http.c
index e83d6d7..691bceb 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -14,7 +14,6 @@
#include "buffer.h"
#include "net.h"
#include "netops.h"
-#include "global.h"
#include "remote.h"
#include "git2/sys/credential.h"
#include "smart.h"
@@ -105,6 +104,11 @@ static int apply_url_credentials(
const char *username,
const char *password)
{
+ GIT_ASSERT_ARG(username);
+
+ if (!password)
+ password = "";
+
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT)
return git_credential_userpass_plaintext_new(cred, username, password);
@@ -139,8 +143,7 @@ static int handle_auth(
/* Start with URL-specified credentials, if there were any. */
if ((allowed_credtypes & GIT_CREDENTIAL_USERPASS_PLAINTEXT) &&
!server->url_cred_presented &&
- server->url.username &&
- server->url.password) {
+ server->url.username) {
error = apply_url_credentials(&server->cred, allowed_credtypes, server->url.username, server->url.password);
server->url_cred_presented = 1;
@@ -417,7 +420,7 @@ static int http_stream_read(
goto done;
}
- assert (stream->state == HTTP_STATE_RECEIVING_RESPONSE);
+ GIT_ASSERT(stream->state == HTTP_STATE_RECEIVING_RESPONSE);
error = git_http_client_read_body(transport->http_client, buffer, buffer_size);
@@ -555,7 +558,7 @@ static int http_stream_write(
goto done;
}
- assert(stream->state == HTTP_STATE_SENDING_REQUEST);
+ GIT_ASSERT(stream->state == HTTP_STATE_SENDING_REQUEST);
error = git_http_client_send_body(transport->http_client, buffer, len);
@@ -589,7 +592,7 @@ static int http_stream_read_response(
(error = handle_response(&complete, stream, &response, false)) < 0)
goto done;
- assert(complete);
+ GIT_ASSERT(complete);
stream->state = HTTP_STATE_RECEIVING_RESPONSE;
}
@@ -638,7 +641,8 @@ static int http_action(
const http_service *service;
int error;
- assert(out && t);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(t);
*out = NULL;
@@ -721,7 +725,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own
GIT_UNUSED(param);
- assert(out);
+ GIT_ASSERT_ARG(out);
transport = git__calloc(sizeof(http_subtransport), 1);
GIT_ERROR_CHECK_ALLOC(transport);
diff --git a/src/transports/http.h b/src/transports/http.h
index c02109c..5c360b8 100644
--- a/src/transports/http.h
+++ b/src/transports/http.h
@@ -9,6 +9,7 @@
#define INCLUDE_transports_http_h__
#include "buffer.h"
+#include "settings.h"
#include "httpclient.h"
#define GIT_HTTP_REPLAY_MAX 15
diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c
index d8d7227..4612b43 100644
--- a/src/transports/httpclient.c
+++ b/src/transports/httpclient.c
@@ -10,7 +10,6 @@
#include "http_parser.h"
#include "vector.h"
#include "trace.h"
-#include "global.h"
#include "httpclient.h"
#include "http.h"
#include "auth.h"
@@ -29,7 +28,18 @@ static git_http_auth_scheme auth_schemes[] = {
{ GIT_HTTP_AUTH_BASIC, "Basic", GIT_CREDENTIAL_USERPASS_PLAINTEXT, git_http_auth_basic },
};
-#define GIT_READ_BUFFER_SIZE 8192
+/*
+ * Use a 16kb read buffer to match the maximum size of a TLS packet. This
+ * is critical for compatibility with SecureTransport, which will always do
+ * a network read on every call, even if it has data buffered to return to
+ * you. That buffered data may be the _end_ of a keep-alive response, so
+ * if SecureTransport performs another network read, it will wait until the
+ * server ultimately times out before it returns that buffered data to you.
+ * Since SecureTransport only reads a single TLS packet at a time, by
+ * calling it with a read buffer that is the maximum size of a TLS packet,
+ * we ensure that it will never buffer.
+ */
+#define GIT_READ_BUFFER_SIZE (16 * 1024)
typedef struct {
git_net_url url;
@@ -135,7 +145,8 @@ bool git_http_response_is_redirect(git_http_response *response)
void git_http_response_dispose(git_http_response *response)
{
- assert(response);
+ if (!response)
+ return;
git__free(response->content_type);
git__free(response->location);
@@ -389,7 +400,7 @@ static int on_body(http_parser *parser, const char *buf, size_t len)
return 0;
}
- assert(ctx->output_size >= ctx->output_written);
+ GIT_ASSERT(ctx->output_size >= ctx->output_written);
max_len = min(ctx->output_size - ctx->output_written, len);
max_len = min(max_len, INT_MAX);
@@ -434,7 +445,7 @@ GIT_INLINE(int) client_write_request(git_http_client *client)
0);
}
-const char *name_for_method(git_http_method method)
+static const char *name_for_method(git_http_method method)
{
switch (method) {
case GIT_HTTP_METHOD_GET:
@@ -587,6 +598,7 @@ static int apply_credentials(
} else if (!token.size) {
git_error_set(GIT_ERROR_HTTP, "failed to respond to authentication challenge");
error = GIT_EAUTH;
+ error = -1;
goto done;
}
@@ -620,6 +632,26 @@ GIT_INLINE(int) apply_proxy_credentials(
request->proxy_credentials);
}
+static int puts_host_and_port(git_buf *buf, git_net_url *url, bool force_port)
+{
+ bool ipv6 = git_net_url_is_ipv6(url);
+
+ if (ipv6)
+ git_buf_putc(buf, '[');
+
+ git_buf_puts(buf, url->host);
+
+ if (ipv6)
+ git_buf_putc(buf, ']');
+
+ if (force_port || !git_net_url_is_default_port(url)) {
+ git_buf_putc(buf, ':');
+ git_buf_puts(buf, url->port);
+ }
+
+ return git_buf_oom(buf) ? -1 : 0;
+}
+
static int generate_connect_request(
git_http_client *client,
git_http_request *request)
@@ -630,14 +662,17 @@ static int generate_connect_request(
git_buf_clear(&client->request_msg);
buf = &client->request_msg;
- git_buf_printf(buf, "CONNECT %s:%s HTTP/1.1\r\n",
- client->server.url.host, client->server.url.port);
+ git_buf_puts(buf, "CONNECT ");
+ puts_host_and_port(buf, &client->server.url, true);
+ git_buf_puts(buf, " HTTP/1.1\r\n");
git_buf_puts(buf, "User-Agent: ");
git_http__user_agent(buf);
git_buf_puts(buf, "\r\n");
- git_buf_printf(buf, "Host: %s\r\n", client->proxy.url.host);
+ git_buf_puts(buf, "Host: ");
+ puts_host_and_port(buf, &client->proxy.url, false);
+ git_buf_puts(buf, "\r\n");
if ((error = apply_proxy_credentials(buf, client, request) < 0))
return -1;
@@ -647,6 +682,11 @@ static int generate_connect_request(
return git_buf_oom(buf) ? -1 : 0;
}
+static bool use_connect_proxy(git_http_client *client)
+{
+ return client->proxy.url.host && !strcmp(client->server.url.scheme, "https");
+}
+
static int generate_request(
git_http_client *client,
git_http_request *request)
@@ -655,7 +695,8 @@ static int generate_request(
size_t i;
int error;
- assert(client && request);
+ GIT_ASSERT_ARG(client);
+ GIT_ASSERT_ARG(request);
git_buf_clear(&client->request_msg);
buf = &client->request_msg;
@@ -675,11 +716,8 @@ static int generate_request(
git_http__user_agent(buf);
git_buf_puts(buf, "\r\n");
- git_buf_printf(buf, "Host: %s", request->url->host);
-
- if (!git_net_url_is_default_port(request->url))
- git_buf_printf(buf, ":%s", request->url->port);
-
+ git_buf_puts(buf, "Host: ");
+ puts_host_and_port(buf, request->url, false);
git_buf_puts(buf, "\r\n");
if (request->accept)
@@ -702,7 +740,8 @@ static int generate_request(
git_buf_printf(buf, "Expect: 100-continue\r\n");
if ((error = apply_server_credentials(buf, client, request)) < 0 ||
- (error = apply_proxy_credentials(buf, client, request)) < 0)
+ (!use_connect_proxy(client) &&
+ (error = apply_proxy_credentials(buf, client, request)) < 0))
return error;
if (request->custom_headers) {
@@ -832,7 +871,10 @@ static int setup_hosts(
{
int ret, diff = 0;
- assert(client && request && request->url);
+ GIT_ASSERT_ARG(client);
+ GIT_ASSERT_ARG(request);
+
+ GIT_ASSERT(request->url);
if ((ret = server_setup_from_url(&client->server, request->url)) < 0)
return ret;
@@ -887,7 +929,7 @@ static int proxy_connect(
int error;
if (!client->proxy_connected || !client->keepalive) {
- git_trace(GIT_TRACE_DEBUG, "Connecting to proxy %s:%s",
+ git_trace(GIT_TRACE_DEBUG, "Connecting to proxy %s port %s",
client->proxy.url.host, client->proxy.url.port);
if ((error = server_create_stream(&client->proxy)) < 0 ||
@@ -912,7 +954,7 @@ static int proxy_connect(
(error = git_http_client_skip_body(client)) < 0)
goto done;
- assert(client->state == DONE);
+ GIT_ASSERT(client->state == DONE);
if (response.status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
save_early_response(client, &response);
@@ -992,8 +1034,7 @@ static int http_client_connect(
reset_parser(client);
/* Reconnect to the proxy if necessary. */
- use_proxy = client->proxy.url.host &&
- !strcmp(client->server.url.scheme, "https");
+ use_proxy = use_connect_proxy(client);
if (use_proxy) {
if (!client->proxy_connected || !client->keepalive ||
@@ -1008,7 +1049,7 @@ static int http_client_connect(
goto on_error;
}
- git_trace(GIT_TRACE_DEBUG, "Connecting to remote %s:%s",
+ git_trace(GIT_TRACE_DEBUG, "Connecting to remote %s port %s",
client->server.url.host, client->server.url.port);
if ((error = server_connect(client)) < 0)
@@ -1027,6 +1068,7 @@ on_error:
GIT_INLINE(int) client_read(git_http_client *client)
{
+ http_parser_context *parser_context = client->parser.data;
git_stream *stream;
char *buf = client->read_buf.ptr + client->read_buf.size;
size_t max_len;
@@ -1043,6 +1085,9 @@ GIT_INLINE(int) client_read(git_http_client *client)
max_len = client->read_buf.asize - client->read_buf.size;
max_len = min(max_len, INT_MAX);
+ if (parser_context->output_size)
+ max_len = min(max_len, parser_context->output_size);
+
if (max_len == 0) {
git_error_set(GIT_ERROR_HTTP, "no room in output buffer");
return -1;
@@ -1105,11 +1150,6 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client)
return -1;
}
- if (parser->upgrade) {
- git_error_set(GIT_ERROR_HTTP, "server requested upgrade");
- return -1;
- }
-
if (ctx->parse_status == PARSE_STATUS_ERROR) {
client->connected = 0;
return ctx->error ? ctx->error : -1;
@@ -1128,7 +1168,7 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client)
* final byte when paused in a callback. Consume that byte.
* https://github.com/nodejs/http-parser/issues/97
*/
- assert(client->read_buf.size > parsed_len);
+ GIT_ASSERT(client->read_buf.size > parsed_len);
http_parser_pause(parser, 0);
@@ -1180,7 +1220,7 @@ static void complete_response_body(git_http_client *client)
/* If we're not keeping alive, don't bother. */
if (!client->keepalive) {
client->connected = 0;
- return;
+ goto done;
}
parser_context.client = client;
@@ -1194,6 +1234,9 @@ static void complete_response_body(git_http_client *client)
git_error_clear();
client->connected = 0;
}
+
+done:
+ git_buf_clear(&client->read_buf);
}
int git_http_client_send_request(
@@ -1203,7 +1246,8 @@ int git_http_client_send_request(
git_http_response response = {0};
int error = -1;
- assert(client && request);
+ GIT_ASSERT_ARG(client);
+ GIT_ASSERT_ARG(request);
/* If the client did not finish reading, clean up the stream. */
if (client->state == READING_BODY)
@@ -1274,7 +1318,7 @@ int git_http_client_send_body(
git_buf hdr = GIT_BUF_INIT;
int error;
- assert(client);
+ GIT_ASSERT_ARG(client);
/* If we're waiting for proxy auth, don't sending more requests. */
if (client->state == HAS_EARLY_RESPONSE)
@@ -1291,7 +1335,7 @@ int git_http_client_send_body(
server = &client->server;
if (client->request_body_len) {
- assert(buffer_len <= client->request_body_remain);
+ GIT_ASSERT(buffer_len <= client->request_body_remain);
if ((error = stream_write(server, buffer, buffer_len)) < 0)
goto done;
@@ -1314,7 +1358,8 @@ static int complete_request(git_http_client *client)
{
int error = 0;
- assert(client && client->state == SENDING_BODY);
+ GIT_ASSERT_ARG(client);
+ GIT_ASSERT(client->state == SENDING_BODY);
if (client->request_body_len && client->request_body_remain) {
git_error_set(GIT_ERROR_HTTP, "truncated write");
@@ -1334,7 +1379,8 @@ int git_http_client_read_response(
http_parser_context parser_context = {0};
int error;
- assert(response && client);
+ GIT_ASSERT_ARG(response);
+ GIT_ASSERT_ARG(client);
if (client->state == SENDING_BODY) {
if ((error = complete_request(client)) < 0)
@@ -1356,8 +1402,11 @@ int git_http_client_read_response(
git_http_response_dispose(response);
- git_vector_free_deep(&client->server.auth_challenges);
- git_vector_free_deep(&client->proxy.auth_challenges);
+ if (client->current_server == PROXY) {
+ git_vector_free_deep(&client->proxy.auth_challenges);
+ } else if(client->current_server == SERVER) {
+ git_vector_free_deep(&client->server.auth_challenges);
+ }
client->state = READING_RESPONSE;
client->keepalive = 0;
@@ -1371,7 +1420,7 @@ int git_http_client_read_response(
goto done;
}
- assert(client->state == READING_BODY || client->state == DONE);
+ GIT_ASSERT(client->state == READING_BODY || client->state == DONE);
done:
git_buf_dispose(&parser_context.parse_header_name);
@@ -1408,18 +1457,23 @@ int git_http_client_read_body(
client->parser.data = &parser_context;
/*
- * Clients expect to get a non-zero amount of data from us.
- * With a sufficiently small buffer, one might only read a chunk
- * length. Loop until we actually have data to return.
+ * Clients expect to get a non-zero amount of data from us,
+ * so we either block until we have data to return, until we
+ * hit EOF or there's an error. Do this in a loop, since we
+ * may end up reading only some stream metadata (like chunk
+ * information).
*/
while (!parser_context.output_written) {
error = client_read_and_parse(client);
if (error <= 0)
goto done;
+
+ if (client->state == DONE)
+ break;
}
- assert(parser_context.output_written <= INT_MAX);
+ GIT_ASSERT(parser_context.output_written <= INT_MAX);
error = (int)parser_context.output_written;
done:
@@ -1455,7 +1509,7 @@ int git_http_client_skip_body(git_http_client *client)
"unexpected data handled in callback");
error = -1;
}
- } while (!error);
+ } while (error >= 0 && client->state != DONE);
if (error < 0)
client->connected = 0;
@@ -1473,7 +1527,7 @@ int git_http_client_new(
{
git_http_client *client;
- assert(out);
+ GIT_ASSERT_ARG(out);
client = git__calloc(1, sizeof(git_http_client));
GIT_ERROR_CHECK_ALLOC(client);
diff --git a/src/transports/httpclient.h b/src/transports/httpclient.h
index 2a83bee..6d0ef9e 100644
--- a/src/transports/httpclient.h
+++ b/src/transports/httpclient.h
@@ -90,7 +90,7 @@ extern int git_http_client_new(
/*
* Sends a request to the host specified by the request URL. If the
- * method is POST, either the the content_length or the chunked flag must
+ * method is POST, either the content_length or the chunked flag must
* be specified. The body should be provided in subsequent calls to
* git_http_client_send_body.
*
diff --git a/src/transports/local.c b/src/transports/local.c
index 24af7f0..bb31b13 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -36,7 +36,7 @@ typedef struct {
char *url;
int direction;
int flags;
- git_atomic cancelled;
+ git_atomic32 cancelled;
git_repository *repo;
git_transport_message_cb progress_cb;
git_transport_message_cb error_cb;
@@ -158,7 +158,7 @@ static int store_refs(transport_local *t)
git_remote_head *head;
git_strarray ref_names = {0};
- assert(t);
+ GIT_ASSERT_ARG(t);
if (git_reference_list(&ref_names, t->repo) < 0)
goto on_error;
@@ -185,12 +185,12 @@ static int store_refs(transport_local *t)
}
t->have_refs = 1;
- git_strarray_free(&ref_names);
+ git_strarray_dispose(&ref_names);
return 0;
on_error:
git_vector_free(&t->refs);
- git_strarray_free(&ref_names);
+ git_strarray_dispose(&ref_names);
return -1;
}
@@ -671,7 +671,7 @@ static void local_cancel(git_transport *transport)
{
transport_local *t = (transport_local *)transport;
- git_atomic_set(&t->cancelled, 1);
+ git_atomic32_set(&t->cancelled, 1);
}
static int local_close(git_transport *transport)
diff --git a/src/transports/smart.c b/src/transports/smart.c
index bb4d2a2..587f143 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -18,7 +18,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
size_t old_len, bytes_read;
int error;
- assert(t->current_stream);
+ GIT_ASSERT(t->current_stream);
old_len = buf->offset;
@@ -30,7 +30,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
if (t->packetsize_cb && !t->cancelled.val) {
error = t->packetsize_cb(bytes_read, t->packetsize_payload);
if (error) {
- git_atomic_set(&t->cancelled, 1);
+ git_atomic32_set(&t->cancelled, 1);
return GIT_EUSER;
}
}
@@ -132,7 +132,7 @@ static int git_smart__set_custom_headers(
size_t i;
if (t->custom_headers.count)
- git_strarray_free(&t->custom_headers);
+ git_strarray_dispose(&t->custom_headers);
if (!custom_headers)
return 0;
@@ -226,6 +226,8 @@ static int git_smart__connect(
t->url = git__strdup(url);
GIT_ERROR_CHECK_ALLOC(t->url);
+ git_proxy_options_clear(&t->proxy);
+
if (git_proxy_options_dup(&t->proxy, proxy) < 0)
return -1;
@@ -346,7 +348,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
return error;
/* If this is a stateful implementation, the stream we get back should be the same */
- assert(t->rpc || t->current_stream == stream);
+ GIT_ASSERT(t->rpc || t->current_stream == stream);
/* Save off the current stream (i.e. socket) that we are working with */
t->current_stream = stream;
@@ -375,7 +377,7 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
return error;
/* If this is a stateful implementation, the stream we get back should be the same */
- assert(t->rpc || t->current_stream == *stream);
+ GIT_ASSERT(t->rpc || t->current_stream == *stream);
/* Save off the current stream (i.e. socket) that we are working with */
t->current_stream = *stream;
@@ -389,7 +391,7 @@ static void git_smart__cancel(git_transport *transport)
{
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
- git_atomic_set(&t->cancelled, 1);
+ git_atomic32_set(&t->cancelled, 1);
}
static int git_smart__is_connected(git_transport *transport)
@@ -465,7 +467,7 @@ static void git_smart__free(git_transport *transport)
git_vector_free(refs);
git__free((char *)t->proxy.url);
- git_strarray_free(&t->custom_headers);
+ git_strarray_dispose(&t->custom_headers);
git__free(t);
}
@@ -481,7 +483,9 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
{
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
- assert(transport && cert && hostname);
+ GIT_ASSERT_ARG(transport);
+ GIT_ASSERT_ARG(cert);
+ GIT_ASSERT_ARG(hostname);
if (!t->certificate_check_cb)
return GIT_PASSTHROUGH;
@@ -493,7 +497,8 @@ int git_transport_smart_credentials(git_credential **out, git_transport *transpo
{
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
- assert(out && transport);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(transport);
if (!t->cred_acquire_cb)
return GIT_PASSTHROUGH;
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 18e0b7e..a05d4c9 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -153,7 +153,7 @@ typedef struct {
git_vector refs;
git_vector heads;
git_vector common;
- git_atomic cancelled;
+ git_atomic32 cancelled;
packetsize_cb packetsize_cb;
void *packetsize_payload;
unsigned rpc : 1,
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index c01656d..91de163 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -64,7 +64,9 @@ int git_smart__store_refs(transport_smart *t, int flushes)
continue;
}
- gitno_consume(buf, line_end);
+ if (gitno_consume(buf, line_end) < 0)
+ return -1;
+
if (pkt->type == GIT_PKT_ERR) {
git_error_set(GIT_ERROR_NET, "remote error: %s", ((git_pkt_err *)pkt)->error);
git__free(pkt);
@@ -236,7 +238,9 @@ static int recv_pkt(git_pkt **out_pkt, git_pkt_type *out_type, gitno_buffer *buf
}
} while (error);
- gitno_consume(buf, line_end);
+ if (gitno_consume(buf, line_end) < 0)
+ return -1;
+
if (out_type != NULL)
*out_type = pkt->type;
if (out_pkt != NULL)
@@ -531,7 +535,7 @@ int git_smart__download_pack(
/* We might have something in the buffer already from negotiate_fetch */
if (t->buffer.offset > 0 && !t->cancelled.val)
if (t->packetsize_cb(t->buffer.offset, t->packetsize_payload))
- git_atomic_set(&t->cancelled, 1);
+ git_atomic32_set(&t->cancelled, 1);
}
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
@@ -791,7 +795,8 @@ static int parse_report(transport_smart *transport, git_push *push)
continue;
}
- gitno_consume(buf, line_end);
+ if (gitno_consume(buf, line_end) < 0)
+ return -1;
error = 0;
@@ -970,9 +975,10 @@ static int stream_thunk(void *buf, size_t size, void *data)
if (payload->cb) {
double current_time = git__timer();
+ double elapsed = current_time - payload->last_progress_report_time;
payload->last_bytes += size;
- if ((current_time - payload->last_progress_report_time) >= MIN_PROGRESS_UPDATE_INTERVAL) {
+ if (elapsed < 0 || elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
payload->last_progress_report_time = current_time;
error = payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload);
}
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index a605aec..efa77a7 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -11,7 +11,7 @@
#include <libssh2.h>
#endif
-#include "global.h"
+#include "runtime.h"
#include "git2.h"
#include "buffer.h"
#include "net.h"
@@ -238,7 +238,7 @@ static int ssh_stream_alloc(
{
ssh_stream *s;
- assert(stream);
+ GIT_ASSERT_ARG(stream);
s = git__calloc(sizeof(ssh_stream), 1);
GIT_ERROR_CHECK_ALLOC(s);
@@ -404,8 +404,8 @@ static int _git_ssh_authenticate_session(
case GIT_CREDENTIAL_SSH_MEMORY: {
git_credential_ssh_key *c = (git_credential_ssh_key *)cred;
- assert(c->username);
- assert(c->privatekey);
+ GIT_ASSERT(c->username);
+ GIT_ASSERT(c->privatekey);
rc = libssh2_userauth_publickey_frommemory(
session,
@@ -483,7 +483,7 @@ static int _git_ssh_session_create(
LIBSSH2_SESSION* s;
git_socket_stream *socket = GIT_CONTAINER_OF(io, git_socket_stream, parent);
- assert(session);
+ GIT_ASSERT_ARG(session);
s = libssh2_session_init();
if (!s) {
@@ -563,9 +563,46 @@ post_extract:
if (t->owner->certificate_check_cb != NULL) {
git_cert_hostkey cert = {{ 0 }}, *cert_ptr;
const char *key;
+ size_t cert_len;
+ int cert_type;
cert.parent.cert_type = GIT_CERT_HOSTKEY_LIBSSH2;
+ key = libssh2_session_hostkey(session, &cert_len, &cert_type);
+ if (key != NULL) {
+ cert.type |= GIT_CERT_SSH_RAW;
+ cert.hostkey = key;
+ cert.hostkey_len = cert_len;
+ switch (cert_type) {
+ case LIBSSH2_HOSTKEY_TYPE_RSA:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_RSA;
+ break;
+ case LIBSSH2_HOSTKEY_TYPE_DSS:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_DSS;
+ break;
+
+#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_256
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_256:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256;
+ break;
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_384:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384;
+ break;
+ case LIBSSH2_KNOWNHOST_KEY_ECDSA_521:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521;
+ break;
+#endif
+
+#ifdef LIBSSH2_HOSTKEY_TYPE_ED25519
+ case LIBSSH2_HOSTKEY_TYPE_ED25519:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ED25519;
+ break;
+#endif
+ default:
+ cert.raw_type = GIT_CERT_SSH_RAW_TYPE_UNKNOWN;
+ }
+ }
+
#ifdef LIBSSH2_HOSTKEY_HASH_SHA256
key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA256);
if (key != NULL) {
@@ -772,7 +809,7 @@ static int _ssh_close(git_smart_subtransport *subtransport)
{
ssh_subtransport *t = GIT_CONTAINER_OF(subtransport, ssh_subtransport, parent);
- assert(!t->current_stream);
+ GIT_ASSERT(!t->current_stream);
GIT_UNUSED(t);
@@ -783,8 +820,6 @@ static void _ssh_free(git_smart_subtransport *subtransport)
{
ssh_subtransport *t = GIT_CONTAINER_OF(subtransport, ssh_subtransport, parent);
- assert(!t->current_stream);
-
git__free(t->cmd_uploadpack);
git__free(t->cmd_receivepack);
git__free(t);
@@ -849,7 +884,7 @@ int git_smart_subtransport_ssh(
#ifdef GIT_SSH
ssh_subtransport *t;
- assert(out);
+ GIT_ASSERT_ARG(out);
GIT_UNUSED(param);
@@ -867,7 +902,7 @@ int git_smart_subtransport_ssh(
GIT_UNUSED(owner);
GIT_UNUSED(param);
- assert(out);
+ GIT_ASSERT_ARG(out);
*out = NULL;
git_error_set(GIT_ERROR_INVALID, "cannot create SSH transport. Library was built without SSH support");
@@ -911,7 +946,7 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
GIT_UNUSED(owner);
GIT_UNUSED(payload);
- assert(out);
+ GIT_ASSERT_ARG(out);
*out = NULL;
git_error_set(GIT_ERROR_INVALID, "cannot create SSH transport. Library was built without SSH support");
@@ -934,8 +969,7 @@ int git_transport_ssh_global_init(void)
return -1;
}
- git__on_shutdown(shutdown_ssh);
- return 0;
+ return git_runtime_shutdown_register(shutdown_ssh);
#else
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index ce1eb39..ea2195a 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -17,7 +17,6 @@
#include "smart.h"
#include "remote.h"
#include "repository.h"
-#include "global.h"
#include "http.h"
#include "git2/sys/credential.h"
@@ -41,14 +40,22 @@
#define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0
#endif
-#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS_1_1
+#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1
# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200
#endif
-#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS_1_2
+#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2
# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800
#endif
+#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3
+# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 0x00002000
+#endif
+
+#ifndef WINHTTP_NO_CLIENT_CERT_CONTEXT
+# define WINHTTP_NO_CLIENT_CERT_CONTEXT NULL
+#endif
+
#ifndef HTTP_STATUS_PERMANENT_REDIRECT
# define HTTP_STATUS_PERMANENT_REDIRECT 308
#endif
@@ -108,7 +115,8 @@ typedef struct {
DWORD post_body_len;
unsigned sent_request : 1,
received_response : 1,
- chunked : 1;
+ chunked : 1,
+ status_sending_request_reached: 1;
} winhttp_stream;
typedef struct {
@@ -265,7 +273,7 @@ static int acquire_fallback_cred(
pISM->lpVtbl->Release(pISM);
}
- /* Only unitialize if the call to CoInitializeEx was successful. */
+ /* Only uninitialize if the call to CoInitializeEx was successful. */
if (SUCCEEDED(hCoInitResult))
CoUninitialize();
}
@@ -448,8 +456,14 @@ static int winhttp_stream_connect(winhttp_stream *s)
git_buf_puts(&processed_url, t->proxy.url.scheme);
git_buf_PUTS(&processed_url, "://");
+ if (git_net_url_is_ipv6(&t->proxy.url))
+ git_buf_putc(&processed_url, '[');
+
git_buf_puts(&processed_url, t->proxy.url.host);
+ if (git_net_url_is_ipv6(&t->proxy.url))
+ git_buf_putc(&processed_url, ']');
+
if (!git_net_url_is_default_port(&t->proxy.url))
git_buf_printf(&processed_url, ":%s", t->proxy.url.port);
@@ -704,46 +718,54 @@ static void CALLBACK winhttp_status(
DWORD status;
GIT_UNUSED(connection);
- GIT_UNUSED(ctx);
GIT_UNUSED(info_len);
- if (code != WINHTTP_CALLBACK_STATUS_SECURE_FAILURE)
- return;
-
- status = *((DWORD *)info);
-
- if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID))
- git_error_set(GIT_ERROR_HTTP, "SSL certificate issued for different common name");
- else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID))
- git_error_set(GIT_ERROR_HTTP, "SSL certificate has expired");
- else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA))
- git_error_set(GIT_ERROR_HTTP, "SSL certificate signed by unknown CA");
- else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT))
- git_error_set(GIT_ERROR_HTTP, "SSL certificate is invalid");
- else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED))
- git_error_set(GIT_ERROR_HTTP, "certificate revocation check failed");
- else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED))
- git_error_set(GIT_ERROR_HTTP, "SSL certificate was revoked");
- else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR))
- git_error_set(GIT_ERROR_HTTP, "security libraries could not be loaded");
- else
- git_error_set(GIT_ERROR_HTTP, "unknown security error %lu", status);
+ switch (code) {
+ case WINHTTP_CALLBACK_STATUS_SECURE_FAILURE:
+ status = *((DWORD *)info);
+
+ if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID))
+ git_error_set(GIT_ERROR_HTTP, "SSL certificate issued for different common name");
+ else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID))
+ git_error_set(GIT_ERROR_HTTP, "SSL certificate has expired");
+ else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA))
+ git_error_set(GIT_ERROR_HTTP, "SSL certificate signed by unknown CA");
+ else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT))
+ git_error_set(GIT_ERROR_HTTP, "SSL certificate is invalid");
+ else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED))
+ git_error_set(GIT_ERROR_HTTP, "certificate revocation check failed");
+ else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED))
+ git_error_set(GIT_ERROR_HTTP, "SSL certificate was revoked");
+ else if ((status & WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR))
+ git_error_set(GIT_ERROR_HTTP, "security libraries could not be loaded");
+ else
+ git_error_set(GIT_ERROR_HTTP, "unknown security error %lu", status);
+
+ break;
+
+ case WINHTTP_CALLBACK_STATUS_SENDING_REQUEST:
+ ((winhttp_stream *) ctx)->status_sending_request_reached = 1;
+
+ break;
+ }
}
static int winhttp_connect(
winhttp_subtransport *t)
{
- wchar_t *wide_host;
+ wchar_t *wide_host = NULL;
int32_t port;
- wchar_t *wide_ua;
- git_buf ua = GIT_BUF_INIT;
+ wchar_t *wide_ua = NULL;
+ git_buf ipv6 = GIT_BUF_INIT, ua = GIT_BUF_INIT;
+ const char *host;
int error = -1;
int default_timeout = TIMEOUT_INFINITE;
int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
DWORD protocols =
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
- WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
+ WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 |
+ WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3;
t->session = NULL;
t->connection = NULL;
@@ -751,29 +773,33 @@ static int winhttp_connect(
/* Prepare port */
if (git__strntol32(&port, t->server.url.port,
strlen(t->server.url.port), NULL, 10) < 0)
- return -1;
+ goto on_error;
+
+ /* IPv6? Add braces around the host. */
+ if (git_net_url_is_ipv6(&t->server.url)) {
+ if (git_buf_printf(&ipv6, "[%s]", t->server.url.host) < 0)
+ goto on_error;
+
+ host = ipv6.ptr;
+ } else {
+ host = t->server.url.host;
+ }
/* Prepare host */
- if (git__utf8_to_16_alloc(&wide_host, t->server.url.host) < 0) {
+ if (git__utf8_to_16_alloc(&wide_host, host) < 0) {
git_error_set(GIT_ERROR_OS, "unable to convert host to wide characters");
- return -1;
+ goto on_error;
}
- if ((error = git_http__user_agent(&ua)) < 0) {
- git__free(wide_host);
- return error;
- }
+ if (git_http__user_agent(&ua) < 0)
+ goto on_error;
if (git__utf8_to_16_alloc(&wide_ua, git_buf_cstr(&ua)) < 0) {
git_error_set(GIT_ERROR_OS, "unable to convert host to wide characters");
- git__free(wide_host);
- git_buf_dispose(&ua);
- return -1;
+ goto on_error;
}
- git_buf_dispose(&ua);
-
/* Establish session */
t->session = WinHttpOpen(
wide_ua,
@@ -788,14 +814,20 @@ static int winhttp_connect(
}
/*
- * Do a best-effort attempt to enable TLS 1.2 but allow this to
- * fail; if TLS 1.2 support is not available for some reason,
+ * Do a best-effort attempt to enable TLS 1.3 and 1.2 but allow this to
+ * fail; if TLS 1.2 or 1.3 support is not available for some reason,
* ignore the failure (it will keep the default protocols).
*/
- WinHttpSetOption(t->session,
+ if (WinHttpSetOption(t->session,
WINHTTP_OPTION_SECURE_PROTOCOLS,
&protocols,
- sizeof(protocols));
+ sizeof(protocols)) == FALSE) {
+ protocols &= ~WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3;
+ WinHttpSetOption(t->session,
+ WINHTTP_OPTION_SECURE_PROTOCOLS,
+ &protocols,
+ sizeof(protocols));
+ }
if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) {
git_error_set(GIT_ERROR_OS, "failed to set timeouts for WinHTTP");
@@ -815,7 +847,12 @@ static int winhttp_connect(
goto on_error;
}
- if (WinHttpSetStatusCallback(t->connection, winhttp_status, WINHTTP_CALLBACK_FLAG_SECURE_FAILURE, 0) == WINHTTP_INVALID_STATUS_CALLBACK) {
+ if (WinHttpSetStatusCallback(
+ t->connection,
+ winhttp_status,
+ WINHTTP_CALLBACK_FLAG_SECURE_FAILURE | WINHTTP_CALLBACK_FLAG_SEND_REQUEST,
+ 0
+ ) == WINHTTP_INVALID_STATUS_CALLBACK) {
git_error_set(GIT_ERROR_OS, "failed to set status callback");
goto on_error;
}
@@ -826,6 +863,8 @@ on_error:
if (error < 0)
winhttp_close_connection(t);
+ git_buf_dispose(&ua);
+ git_buf_dispose(&ipv6);
git__free(wide_host);
git__free(wide_ua);
@@ -847,12 +886,12 @@ static int do_send_request(winhttp_stream *s, size_t len, bool chunked)
success = WinHttpSendRequest(s->request,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
- WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0);
+ WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, (DWORD_PTR)s);
} else {
success = WinHttpSendRequest(s->request,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
- (DWORD)len, 0);
+ (DWORD)len, (DWORD_PTR)s);
}
if (success || GetLastError() != (DWORD)SEC_E_BUFFER_TOO_SMALL)
@@ -864,42 +903,71 @@ static int do_send_request(winhttp_stream *s, size_t len, bool chunked)
static int send_request(winhttp_stream *s, size_t len, bool chunked)
{
- int request_failed = 0, cert_valid = 1, error = 0;
- DWORD ignore_flags;
+ int request_failed = 1, error, attempts = 0;
+ DWORD ignore_flags, send_request_error;
git_error_clear();
- if ((error = do_send_request(s, len, chunked)) < 0) {
- if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) {
- git_error_set(GIT_ERROR_OS, "failed to send request");
- return -1;
- }
- request_failed = 1;
- cert_valid = 0;
- }
+ while (request_failed && attempts++ < 3) {
+ int cert_valid = 1;
+ int client_cert_requested = 0;
+ request_failed = 0;
+ if ((error = do_send_request(s, len, chunked)) < 0) {
+ send_request_error = GetLastError();
+ request_failed = 1;
+ switch (send_request_error) {
+ case ERROR_WINHTTP_SECURE_FAILURE:
+ cert_valid = 0;
+ break;
+ case ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED:
+ client_cert_requested = 1;
+ break;
+ default:
+ git_error_set(GIT_ERROR_OS, "failed to send request");
+ return -1;
+ }
+ }
- git_error_clear();
- if ((error = certificate_check(s, cert_valid)) < 0) {
- if (!git_error_last())
- git_error_set(GIT_ERROR_OS, "user cancelled certificate check");
+ /*
+ * Only check the certificate if we were able to reach the sending request phase, or
+ * received a secure failure error. Otherwise, the server certificate won't be available
+ * since the request wasn't able to complete (e.g. proxy auth required)
+ */
+ if (!cert_valid ||
+ (!request_failed && s->status_sending_request_reached)) {
+ git_error_clear();
+ if ((error = certificate_check(s, cert_valid)) < 0) {
+ if (!git_error_last())
+ git_error_set(GIT_ERROR_OS, "user cancelled certificate check");
- return error;
- }
+ return error;
+ }
+ }
- /* if neither the request nor the certificate check returned errors, we're done */
- if (!request_failed)
- return 0;
+ /* if neither the request nor the certificate check returned errors, we're done */
+ if (!request_failed)
+ return 0;
- ignore_flags = no_check_cert_flags;
+ if (!cert_valid) {
+ ignore_flags = no_check_cert_flags;
+ if (!WinHttpSetOption(s->request, WINHTTP_OPTION_SECURITY_FLAGS, &ignore_flags, sizeof(ignore_flags))) {
+ git_error_set(GIT_ERROR_OS, "failed to set security options");
+ return -1;
+ }
+ }
- if (!WinHttpSetOption(s->request, WINHTTP_OPTION_SECURITY_FLAGS, &ignore_flags, sizeof(ignore_flags))) {
- git_error_set(GIT_ERROR_OS, "failed to set security options");
- return -1;
+ if (client_cert_requested) {
+ /*
+ * Client certificates are not supported, explicitly tell the server that
+ * (it's possible a client certificate was requested but is not required)
+ */
+ if (!WinHttpSetOption(s->request, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0)) {
+ git_error_set(GIT_ERROR_OS, "failed to set client cert context");
+ return -1;
+ }
+ }
}
- if ((error = do_send_request(s, len, chunked)) < 0)
- git_error_set(GIT_ERROR_OS, "failed to send request with unchecked certificate");
-
return error;
}
@@ -993,7 +1061,7 @@ replay:
}
if (s->chunked) {
- assert(s->verb == post_verb);
+ GIT_ASSERT(s->verb == post_verb);
/* Flush, if necessary */
if (s->chunk_buffer_len > 0 &&
@@ -1044,7 +1112,7 @@ replay:
}
len -= bytes_read;
- assert(bytes_read == bytes_written);
+ GIT_ASSERT(bytes_read == bytes_written);
}
git__free(buffer);
@@ -1156,7 +1224,7 @@ replay:
if (error < 0) {
return error;
} else if (!error) {
- assert(t->server.cred);
+ GIT_ASSERT(t->server.cred);
winhttp_stream_close(s);
goto replay;
}
@@ -1170,7 +1238,7 @@ replay:
if (error < 0) {
return error;
} else if (!error) {
- assert(t->proxy.cred);
+ GIT_ASSERT(t->proxy.cred);
winhttp_stream_close(s);
goto replay;
}
@@ -1256,7 +1324,7 @@ static int winhttp_stream_write_single(
return -1;
}
- assert((DWORD)len == bytes_written);
+ GIT_ASSERT((DWORD)len == bytes_written);
return 0;
}
@@ -1355,7 +1423,7 @@ static int winhttp_stream_write_buffered(
return -1;
}
- assert((DWORD)len == bytes_written);
+ GIT_ASSERT((DWORD)len == bytes_written);
s->post_body_len += bytes_written;
@@ -1562,7 +1630,7 @@ static int winhttp_action(
break;
default:
- assert(0);
+ GIT_ASSERT(0);
}
if (!ret)
diff --git a/src/tree.c b/src/tree.c
index 48468df..b1df79e 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -54,7 +54,7 @@ GIT_INLINE(git_filemode_t) normalize_filemode(git_filemode_t filemode)
static int valid_entry_name(git_repository *repo, const char *filename)
{
return *filename != '\0' &&
- git_path_isvalid(repo, filename, 0,
+ git_path_validate(repo, filename, 0,
GIT_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT | GIT_PATH_REJECT_SLASH);
}
@@ -228,7 +228,7 @@ int git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source)
{
git_tree_entry *cpy;
- assert(source);
+ GIT_ASSERT_ARG(source);
cpy = alloc_entry(source->filename, source->filename_len, source->oid);
if (cpy == NULL)
@@ -261,19 +261,19 @@ git_filemode_t git_tree_entry_filemode_raw(const git_tree_entry *entry)
const char *git_tree_entry_name(const git_tree_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
return entry->filename;
}
const git_oid *git_tree_entry_id(const git_tree_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
return entry->oid;
}
git_object_t git_tree_entry_type(const git_tree_entry *entry)
{
- assert(entry);
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, GIT_OBJECT_INVALID);
if (S_ISGITLINK(entry->attr))
return GIT_OBJECT_COMMIT;
@@ -288,7 +288,9 @@ int git_tree_entry_to_object(
git_repository *repo,
const git_tree_entry *entry)
{
- assert(entry && object_out);
+ GIT_ASSERT_ARG(entry);
+ GIT_ASSERT_ARG(object_out);
+
return git_object_lookup(object_out, repo, entry->oid, GIT_OBJECT_ANY);
}
@@ -306,7 +308,8 @@ static const git_tree_entry *entry_fromname(
const git_tree_entry *git_tree_entry_byname(
const git_tree *tree, const char *filename)
{
- assert(tree && filename);
+ GIT_ASSERT_ARG_WITH_RETVAL(tree, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(filename, NULL);
return entry_fromname(tree, filename, strlen(filename));
}
@@ -314,7 +317,7 @@ const git_tree_entry *git_tree_entry_byname(
const git_tree_entry *git_tree_entry_byindex(
const git_tree *tree, size_t idx)
{
- assert(tree);
+ GIT_ASSERT_ARG_WITH_RETVAL(tree, NULL);
return git_array_get(tree->entries, idx);
}
@@ -324,7 +327,7 @@ const git_tree_entry *git_tree_entry_byid(
size_t i;
const git_tree_entry *e;
- assert(tree);
+ GIT_ASSERT_ARG_WITH_RETVAL(tree, NULL);
git_array_foreach(tree->entries, i, e) {
if (memcmp(&e->oid->id, &id->id, sizeof(id->id)) == 0)
@@ -336,13 +339,13 @@ const git_tree_entry *git_tree_entry_byid(
size_t git_tree_entrycount(const git_tree *tree)
{
- assert(tree);
+ GIT_ASSERT_ARG_WITH_RETVAL(tree, 0);
return tree->entries.size;
}
size_t git_treebuilder_entrycount(git_treebuilder *bld)
{
- assert(bld);
+ GIT_ASSERT_ARG_WITH_RETVAL(bld, 0);
return git_strmap_size(bld->map);
}
@@ -489,6 +492,56 @@ static int check_entry(git_repository *repo, const char *filename, const git_oid
return 0;
}
+static int git_treebuilder__write_with_buffer(
+ git_oid *oid,
+ git_treebuilder *bld,
+ git_buf *buf)
+{
+ int error = 0;
+ size_t i, entrycount;
+ git_odb *odb;
+ git_tree_entry *entry;
+ git_vector entries = GIT_VECTOR_INIT;
+
+ git_buf_clear(buf);
+
+ entrycount = git_strmap_size(bld->map);
+ if ((error = git_vector_init(&entries, entrycount, entry_sort_cmp)) < 0)
+ goto out;
+
+ if (buf->asize == 0 &&
+ (error = git_buf_grow(buf, entrycount * 72)) < 0)
+ goto out;
+
+ git_strmap_foreach_value(bld->map, entry, {
+ if ((error = git_vector_insert(&entries, entry)) < 0)
+ goto out;
+ });
+
+ git_vector_sort(&entries);
+
+ for (i = 0; i < entries.length && !error; ++i) {
+ entry = git_vector_get(&entries, i);
+
+ git_buf_printf(buf, "%o ", entry->attr);
+ git_buf_put(buf, entry->filename, entry->filename_len + 1);
+ git_buf_put(buf, (char *)entry->oid->id, GIT_OID_RAWSZ);
+
+ if (git_buf_oom(buf)) {
+ error = -1;
+ goto out;
+ }
+ }
+
+ if ((error = git_repository_odb__weakptr(&odb, bld->repo)) == 0)
+ error = git_odb_write(oid, odb, buf->ptr, buf->size, GIT_OBJECT_TREE);
+
+out:
+ git_vector_free(&entries);
+
+ return error;
+}
+
static int append_entry(
git_treebuilder *bld,
const char *filename,
@@ -607,7 +660,7 @@ static int write_tree(
}
}
- if (git_treebuilder_write_with_buffer(oid, bld, shared_buf) < 0)
+ if (git_treebuilder__write_with_buffer(oid, bld, shared_buf) < 0)
goto on_error;
git_treebuilder_free(bld);
@@ -626,7 +679,9 @@ int git_tree__write_index(
git_buf shared_buf = GIT_BUF_INIT;
bool old_ignore_case = false;
- assert(oid && index && repo);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(index);
+ GIT_ASSERT_ARG(repo);
if (git_index_has_conflicts(index)) {
git_error_set(GIT_ERROR_INDEX,
@@ -680,7 +735,8 @@ int git_treebuilder_new(
git_treebuilder *bld;
size_t i;
- assert(builder_p && repo);
+ GIT_ASSERT_ARG(builder_p);
+ GIT_ASSERT_ARG(repo);
bld = git__calloc(1, sizeof(git_treebuilder));
GIT_ERROR_CHECK_ALLOC(bld);
@@ -723,7 +779,9 @@ int git_treebuilder_insert(
git_tree_entry *entry;
int error;
- assert(bld && id && filename);
+ GIT_ASSERT_ARG(bld);
+ GIT_ASSERT_ARG(id);
+ GIT_ASSERT_ARG(filename);
if ((error = check_entry(bld->repo, filename, id, filemode)) < 0)
return error;
@@ -751,7 +809,9 @@ int git_treebuilder_insert(
static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filename)
{
- assert(bld && filename);
+ GIT_ASSERT_ARG_WITH_RETVAL(bld, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(filename, NULL);
+
return git_strmap_get(bld->map, filename);
}
@@ -775,63 +835,10 @@ int git_treebuilder_remove(git_treebuilder *bld, const char *filename)
int git_treebuilder_write(git_oid *oid, git_treebuilder *bld)
{
- int error;
- git_buf buffer = GIT_BUF_INIT;
-
- error = git_treebuilder_write_with_buffer(oid, bld, &buffer);
-
- git_buf_dispose(&buffer);
- return error;
-}
-
-int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_buf *tree)
-{
- int error = 0;
- size_t i, entrycount;
- git_odb *odb;
- git_tree_entry *entry;
- git_vector entries = GIT_VECTOR_INIT;
-
- assert(bld);
- assert(tree);
-
- git_buf_clear(tree);
-
- entrycount = git_strmap_size(bld->map);
- if ((error = git_vector_init(&entries, entrycount, entry_sort_cmp)) < 0)
- goto out;
-
- if (tree->asize == 0 &&
- (error = git_buf_grow(tree, entrycount * 72)) < 0)
- goto out;
-
- git_strmap_foreach_value(bld->map, entry, {
- if ((error = git_vector_insert(&entries, entry)) < 0)
- goto out;
- });
-
- git_vector_sort(&entries);
+ GIT_ASSERT_ARG(oid);
+ GIT_ASSERT_ARG(bld);
- for (i = 0; i < entries.length && !error; ++i) {
- entry = git_vector_get(&entries, i);
-
- git_buf_printf(tree, "%o ", entry->attr);
- git_buf_put(tree, entry->filename, entry->filename_len + 1);
- git_buf_put(tree, (char *)entry->oid->id, GIT_OID_RAWSZ);
-
- if (git_buf_oom(tree)) {
- error = -1;
- goto out;
- }
- }
-
- if ((error = git_repository_odb__weakptr(&odb, bld->repo)) == 0)
- error = git_odb_write(oid, odb, tree->ptr, tree->size, GIT_OBJECT_TREE);
-
-out:
- git_vector_free(&entries);
-
- return error;
+ return git_treebuilder__write_with_buffer(oid, bld, &bld->write_cache);
}
int git_treebuilder_filter(
@@ -842,7 +849,8 @@ int git_treebuilder_filter(
const char *filename;
git_tree_entry *entry;
- assert(bld && filter);
+ GIT_ASSERT_ARG(bld);
+ GIT_ASSERT_ARG(filter);
git_strmap_foreach(bld->map, filename, entry, {
if (filter(entry, payload)) {
@@ -858,7 +866,7 @@ int git_treebuilder_clear(git_treebuilder *bld)
{
git_tree_entry *e;
- assert(bld);
+ GIT_ASSERT_ARG(bld);
git_strmap_foreach_value(bld->map, e, git_tree_entry_free(e));
git_strmap_clear(bld->map);
@@ -871,6 +879,7 @@ void git_treebuilder_free(git_treebuilder *bld)
if (bld == NULL)
return;
+ git_buf_dispose(&bld->write_cache);
git_treebuilder_clear(bld);
git_strmap_free(bld->map);
git__free(bld);
@@ -1174,10 +1183,10 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
for (j = 0; j < steps_up; j++) {
tree_stack_entry *current, *popped = git_array_pop(stack);
- assert(popped);
+ GIT_ASSERT(popped);
current = git_array_last(stack);
- assert(current);
+ GIT_ASSERT(current);
if ((error = create_popped_tree(current, popped, &component)) < 0)
goto cleanup;
@@ -1242,8 +1251,9 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
}
case GIT_TREE_UPDATE_REMOVE:
{
+ tree_stack_entry *last = git_array_last(stack);
char *basename = git_path_basename(update->path);
- error = git_treebuilder_remove(git_array_last(stack)->bld, basename);
+ error = git_treebuilder_remove(last->bld, basename);
git__free(basename);
break;
}
@@ -1295,3 +1305,16 @@ cleanup:
git_vector_free(&entries);
return error;
}
+
+/* Deprecated Functions */
+
+#ifndef GIT_DEPRECATE_HARD
+
+int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_buf *buf)
+{
+ GIT_UNUSED(buf);
+
+ return git_treebuilder_write(oid, bld);
+}
+
+#endif
diff --git a/src/tree.h b/src/tree.h
index 973ba15..2f3027b 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -32,6 +32,7 @@ struct git_tree {
struct git_treebuilder {
git_repository *repo;
git_strmap *map;
+ git_buf write_cache;
};
GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
diff --git a/src/tsort.c b/src/tsort.c
index 8d1ed97..045efad 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -29,8 +29,6 @@ static int binsearch(
int l, c, r;
void *lx, *cx;
- assert(size > 0);
-
l = 0;
r = (int)size - 1;
c = r >> 1;
diff --git a/src/unix/map.c b/src/unix/map.c
index 7f9076e..88f283c 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -66,8 +66,10 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset
int p_munmap(git_map *map)
{
- assert(map != NULL);
+ GIT_ASSERT_ARG(map);
munmap(map->data, map->len);
+ map->data = NULL;
+ map->len = 0;
return 0;
}
diff --git a/src/unix/posix.h b/src/unix/posix.h
index d1f9024..7b3325e 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -33,7 +33,7 @@ typedef int GIT_SOCKET;
# define st_atime_nsec st_atim.tv_nsec
# define st_mtime_nsec st_mtim.tv_nsec
# define st_ctime_nsec st_ctim.tv_nsec
-#elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NEC)
+#elif !defined(GIT_USE_STAT_MTIME_NSEC) && defined(GIT_USE_NSEC)
# error GIT_USE_NSEC defined but unknown struct stat nanosecond type
#endif
@@ -62,11 +62,23 @@ GIT_INLINE(int) p_fsync(int fd)
#define p_snprintf snprintf
#define p_mkstemp(p) mkstemp(p)
#define p_chdir(p) chdir(p)
-#define p_chmod(p,m) chmod(p, m)
#define p_rmdir(p) rmdir(p)
#define p_access(p,m) access(p,m)
#define p_ftruncate(fd, sz) ftruncate(fd, sz)
+/*
+ * Pre-Android 5 did not implement a virtual filesystem atop FAT
+ * partitions for Unix permissions, which causes chmod to fail. However,
+ * Unix permissions have no effect on Android anyway as file permissions
+ * are not actually managed this way, so treating it as a no-op across
+ * all Android is safe.
+ */
+#ifdef __ANDROID__
+# define p_chmod(p,m) 0
+#else
+# define p_chmod(p,m) chmod(p, m)
+#endif
+
/* see win32/posix.h for explanation about why this exists */
#define p_lstat_posixly(p,b) lstat(p,b)
@@ -89,4 +101,7 @@ GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
# define p_futimes futimes
#endif
+#define p_pread(f, d, s, o) pread(f, d, s, o)
+#define p_pwrite(f, d, s, o) pwrite(f, d, s, o)
+
#endif
diff --git a/src/unix/pthread.h b/src/unix/pthread.h
index 233561b..55f4ae2 100644
--- a/src/unix/pthread.h
+++ b/src/unix/pthread.h
@@ -12,7 +12,8 @@ typedef struct {
pthread_t thread;
} git_thread;
-#define git_threads_init() (void)0
+GIT_INLINE(int) git_threads_global_init(void) { return 0; }
+
#define git_thread_create(git_thread_ptr, start_routine, arg) \
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
#define git_thread_join(git_thread_ptr, status) \
diff --git a/src/utf8.c b/src/utf8.c
new file mode 100644
index 0000000..77065cb
--- /dev/null
+++ b/src/utf8.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "utf8.h"
+
+#include "common.h"
+
+/*
+ * git_utf8_iterate is taken from the utf8proc project,
+ * http://www.public-software-group.org/utf8proc
+ *
+ * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the ""Software""),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+static const uint8_t utf8proc_utf8class[256] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+static int utf8_charlen(const uint8_t *str, size_t str_len)
+{
+ uint8_t length;
+ size_t i;
+
+ length = utf8proc_utf8class[str[0]];
+ if (!length)
+ return -1;
+
+ if (str_len > 0 && length > str_len)
+ return -1;
+
+ for (i = 1; i < length; i++) {
+ if ((str[i] & 0xC0) != 0x80)
+ return -1;
+ }
+
+ return (int)length;
+}
+
+int git_utf8_iterate(uint32_t *out, const char *_str, size_t str_len)
+{
+ const uint8_t *str = (const uint8_t *)_str;
+ uint32_t uc = 0;
+ int length;
+
+ *out = 0;
+
+ if ((length = utf8_charlen(str, str_len)) < 0)
+ return -1;
+
+ switch (length) {
+ case 1:
+ uc = str[0];
+ break;
+ case 2:
+ uc = ((str[0] & 0x1F) << 6) + (str[1] & 0x3F);
+ if (uc < 0x80) uc = -1;
+ break;
+ case 3:
+ uc = ((str[0] & 0x0F) << 12) + ((str[1] & 0x3F) << 6)
+ + (str[2] & 0x3F);
+ if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
+ (uc >= 0xFDD0 && uc < 0xFDF0)) uc = -1;
+ break;
+ case 4:
+ uc = ((str[0] & 0x07) << 18) + ((str[1] & 0x3F) << 12)
+ + ((str[2] & 0x3F) << 6) + (str[3] & 0x3F);
+ if (uc < 0x10000 || uc >= 0x110000) uc = -1;
+ break;
+ default:
+ return -1;
+ }
+
+ if ((uc & 0xFFFF) >= 0xFFFE)
+ return -1;
+
+ *out = uc;
+ return length;
+}
+
+size_t git_utf8_char_length(const char *_str, size_t str_len)
+{
+ const uint8_t *str = (const uint8_t *)_str;
+ size_t offset = 0, count = 0;
+
+ while (offset < str_len) {
+ int length = utf8_charlen(str + offset, str_len - offset);
+
+ if (length < 0)
+ length = 1;
+
+ offset += length;
+ count++;
+ }
+
+ return count;
+}
+
+size_t git_utf8_valid_buf_length(const char *_str, size_t str_len)
+{
+ const uint8_t *str = (const uint8_t *)_str;
+ size_t offset = 0;
+
+ while (offset < str_len) {
+ int length = utf8_charlen(str + offset, str_len - offset);
+
+ if (length < 0)
+ break;
+
+ offset += length;
+ }
+
+ return offset;
+}
diff --git a/src/utf8.h b/src/utf8.h
new file mode 100644
index 0000000..dff91b2
--- /dev/null
+++ b/src/utf8.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_utf8_h__
+#define INCLUDE_utf8_h__
+
+#include "common.h"
+
+/*
+ * Iterate through an UTF-8 string, yielding one codepoint at a time.
+ *
+ * @param out pointer where to store the current codepoint
+ * @param str current position in the string
+ * @param str_len size left in the string
+ * @return length in bytes of the read codepoint; -1 if the codepoint was invalid
+ */
+extern int git_utf8_iterate(uint32_t *out, const char *str, size_t str_len);
+
+/**
+ * Returns the number of characters in the given string.
+ *
+ * This function will count invalid codepoints; if any given byte is
+ * not part of a valid UTF-8 codepoint, then it will be counted toward
+ * the length in characters.
+ *
+ * In other words:
+ * 0x24 (U+0024 "$") has length 1
+ * 0xc2 0xa2 (U+00A2 "¢") has length 1
+ * 0x24 0xc2 0xa2 (U+0024 U+00A2 "$¢") has length 2
+ * 0xf0 0x90 0x8d 0x88 (U+10348 "ðˆ") has length 1
+ * 0x24 0xc0 0xc1 0x34 (U+0024 <invalid> <invalid> "4) has length 4
+ *
+ * @param str string to scan
+ * @param str_len size of the string
+ * @return length in characters of the string
+ */
+extern size_t git_utf8_char_length(const char *str, size_t str_len);
+
+/**
+ * Iterate through an UTF-8 string and stops after finding any invalid UTF-8
+ * codepoints.
+ *
+ * @param str string to scan
+ * @param str_len size of the string
+ * @return length in bytes of the string that contains valid data
+ */
+extern size_t git_utf8_valid_buf_length(const char *str, size_t str_len);
+
+#endif
diff --git a/src/util.c b/src/util.c
index 859e0a8..c7af296 100644
--- a/src/util.c
+++ b/src/util.c
@@ -13,6 +13,11 @@
# include "win32/utf-conv.h"
# include "win32/w32_buffer.h"
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+
# ifdef HAVE_QSORT_S
# include <search.h>
# endif
@@ -22,57 +27,15 @@
# include <Shlwapi.h>
#endif
-void git_strarray_free(git_strarray *array)
-{
- size_t i;
-
- if (array == NULL)
- return;
-
- for (i = 0; i < array->count; ++i)
- git__free(array->strings[i]);
-
- git__free(array->strings);
-
- memset(array, 0, sizeof(*array));
-}
-
-int git_strarray_copy(git_strarray *tgt, const git_strarray *src)
-{
- size_t i;
-
- assert(tgt && src);
-
- memset(tgt, 0, sizeof(*tgt));
-
- if (!src->count)
- return 0;
-
- tgt->strings = git__calloc(src->count, sizeof(char *));
- GIT_ERROR_CHECK_ALLOC(tgt->strings);
-
- for (i = 0; i < src->count; ++i) {
- if (!src->strings[i])
- continue;
-
- tgt->strings[tgt->count] = git__strdup(src->strings[i]);
- if (!tgt->strings[tgt->count]) {
- git_strarray_free(tgt);
- memset(tgt, 0, sizeof(*tgt));
- return -1;
- }
-
- tgt->count++;
- }
-
- return 0;
-}
+#if defined(hpux) || defined(__hpux) || defined(_hpux)
+# include <sys/pstat.h>
+#endif
int git__strntol64(int64_t *result, const char *nptr, size_t nptr_len, const char **endptr, int base)
{
const char *p;
- int64_t n, nn;
- int c, ovfl, v, neg, ndig;
+ int64_t n, nn, v;
+ int c, ovfl, neg, ndig;
p = nptr;
neg = 0;
@@ -147,19 +110,11 @@ int git__strntol64(int64_t *result, const char *nptr, size_t nptr_len, const cha
if (v >= base)
break;
v = neg ? -v : v;
- if (n > INT64_MAX / base || n < INT64_MIN / base) {
- ovfl = 1;
- /* Keep on iterating until the end of this number */
- continue;
- }
- nn = n * base;
- if ((v > 0 && nn > INT64_MAX - v) ||
- (v < 0 && nn < INT64_MIN - v)) {
+ if (git__multiply_int64_overflow(&nn, n, base) || git__add_int64_overflow(&n, nn, v)) {
ovfl = 1;
/* Keep on iterating until the end of this number */
continue;
}
- n = nn + v;
}
Return:
@@ -424,35 +379,48 @@ void git__hexdump(const char *buffer, size_t len)
last_line = (len % LINE_WIDTH);
for (i = 0; i < line_count; ++i) {
+ printf("%08" PRIxZ " ", (i * LINE_WIDTH));
+
line = buffer + (i * LINE_WIDTH);
- for (j = 0; j < LINE_WIDTH; ++j, ++line)
- printf("%02X ", (unsigned char)*line & 0xFF);
+ for (j = 0; j < LINE_WIDTH; ++j, ++line) {
+ printf("%02x ", (unsigned char)*line & 0xFF);
+
+ if (j == (LINE_WIDTH / 2))
+ printf(" ");
+ }
- printf("| ");
+ printf(" |");
line = buffer + (i * LINE_WIDTH);
for (j = 0; j < LINE_WIDTH; ++j, ++line)
printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
- printf("\n");
+ printf("|\n");
}
if (last_line > 0) {
+ printf("%08" PRIxZ " ", (line_count * LINE_WIDTH));
line = buffer + (line_count * LINE_WIDTH);
- for (j = 0; j < last_line; ++j, ++line)
- printf("%02X ", (unsigned char)*line & 0xFF);
+ for (j = 0; j < last_line; ++j, ++line) {
+ printf("%02x ", (unsigned char)*line & 0xFF);
+
+ if (j == (LINE_WIDTH / 2))
+ printf(" ");
+ }
+ if (j < (LINE_WIDTH / 2))
+ printf(" ");
for (j = 0; j < (LINE_WIDTH - last_line); ++j)
- printf(" ");
+ printf(" ");
- printf("| ");
+ printf(" |");
line = buffer + (line_count * LINE_WIDTH);
for (j = 0; j < last_line; ++j, ++line)
printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
- printf("\n");
+ printf("|\n");
}
printf("\n");
@@ -711,7 +679,7 @@ typedef struct {
void *payload;
} git__qsort_r_glue;
-static int GIT_STDLIB_CALL git__qsort_r_glue_cmp(
+static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
void *payload, const void *a, const void *b)
{
git__qsort_r_glue *glue = payload;
@@ -766,123 +734,6 @@ void git__qsort_r(
#endif
}
-/*
- * git__utf8_iterate is taken from the utf8proc project,
- * http://www.public-software-group.org/utf8proc
- *
- * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the ""Software""),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-static const int8_t utf8proc_utf8class[256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-int git__utf8_charlen(const uint8_t *str, size_t str_len)
-{
- size_t length, i;
-
- length = utf8proc_utf8class[str[0]];
- if (!length)
- return -1;
-
- if (str_len > 0 && length > str_len)
- return -1;
-
- for (i = 1; i < length; i++) {
- if ((str[i] & 0xC0) != 0x80)
- return -1;
- }
-
- return (int)length;
-}
-
-int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst)
-{
- int length;
- int32_t uc = -1;
-
- *dst = -1;
- length = git__utf8_charlen(str, str_len);
- if (length < 0)
- return -1;
-
- switch (length) {
- case 1:
- uc = str[0];
- break;
- case 2:
- uc = ((str[0] & 0x1F) << 6) + (str[1] & 0x3F);
- if (uc < 0x80) uc = -1;
- break;
- case 3:
- uc = ((str[0] & 0x0F) << 12) + ((str[1] & 0x3F) << 6)
- + (str[2] & 0x3F);
- if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
- (uc >= 0xFDD0 && uc < 0xFDF0)) uc = -1;
- break;
- case 4:
- uc = ((str[0] & 0x07) << 18) + ((str[1] & 0x3F) << 12)
- + ((str[2] & 0x3F) << 6) + (str[3] & 0x3F);
- if (uc < 0x10000 || uc >= 0x110000) uc = -1;
- break;
- }
-
- if (uc < 0 || ((uc & 0xFFFF) >= 0xFFFE))
- return -1;
-
- *dst = uc;
- return length;
-}
-
-size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len)
-{
- size_t offset = 0;
-
- while (offset < str_len) {
- int length = git__utf8_charlen(str + offset, str_len - offset);
-
- if (length < 0)
- break;
-
- offset += length;
- }
-
- return offset;
-}
-
#ifdef GIT_WIN32
int git__getenv(git_buf *out, const char *name)
{
@@ -926,3 +777,43 @@ int git__getenv(git_buf *out, const char *name)
return git_buf_puts(out, val);
}
#endif
+
+/*
+ * By doing this in two steps we can at least get
+ * the function to be somewhat coherent, even
+ * with this disgusting nest of #ifdefs.
+ */
+#ifndef _SC_NPROCESSORS_ONLN
+# ifdef _SC_NPROC_ONLN
+# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+# elif defined _SC_CRAY_NCPU
+# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
+# endif
+#endif
+
+int git__online_cpus(void)
+{
+#ifdef _SC_NPROCESSORS_ONLN
+ long ncpus;
+#endif
+
+#ifdef _WIN32
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+
+ if ((int)info.dwNumberOfProcessors > 0)
+ return (int)info.dwNumberOfProcessors;
+#elif defined(hpux) || defined(__hpux) || defined(_hpux)
+ struct pst_dynamic psd;
+
+ if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0))
+ return (int)psd.psd_proc_cnt;
+#endif
+
+#ifdef _SC_NPROCESSORS_ONLN
+ if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
+ return (int)ncpus;
+#endif
+
+ return 1;
+}
diff --git a/src/util.h b/src/util.h
index b49850d..a773536 100644
--- a/src/util.h
+++ b/src/util.h
@@ -18,11 +18,11 @@
#include "buffer.h"
#include "common.h"
#include "strnlen.h"
-#include "thread-utils.h"
+#include "thread.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
-#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
+#define MSB(x, bits) ((x) & (~UINT64_C(0) << (bitsizeof(x) - (bits))))
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
#endif
@@ -169,29 +169,29 @@ extern int git__strncasecmp(const char *a, const char *b, size_t sz);
extern int git__strcasesort_cmp(const char *a, const char *b);
typedef struct {
- git_atomic refcount;
+ git_atomic32 refcount;
void *owner;
} git_refcount;
typedef void (*git_refcount_freeptr)(void *r);
#define GIT_REFCOUNT_INC(r) { \
- git_atomic_inc(&(r)->rc.refcount); \
+ git_atomic32_inc(&(r)->rc.refcount); \
}
#define GIT_REFCOUNT_DEC(_r, do_free) { \
git_refcount *r = &(_r)->rc; \
- int val = git_atomic_dec(&r->refcount); \
+ int val = git_atomic32_dec(&r->refcount); \
if (val <= 0 && r->owner == NULL) { do_free(_r); } \
}
#define GIT_REFCOUNT_OWN(r, o) { \
- (r)->rc.owner = o; \
+ (void)git_atomic_swap((r)->rc.owner, o); \
}
-#define GIT_REFCOUNT_OWNER(r) ((r)->rc.owner)
+#define GIT_REFCOUNT_OWNER(r) git_atomic_load((r)->rc.owner)
-#define GIT_REFCOUNT_VAL(r) git_atomic_get((r)->rc.refcount)
+#define GIT_REFCOUNT_VAL(r) git_atomic32_get((r)->rc.refcount)
static signed char from_hex[] = {
@@ -317,27 +317,6 @@ extern int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date);
extern size_t git__unescape(char *str);
/*
- * Iterate through an UTF-8 string, yielding one
- * codepoint at a time.
- *
- * @param str current position in the string
- * @param str_len size left in the string; -1 if the string is NULL-terminated
- * @param dst pointer where to store the current codepoint
- * @return length in bytes of the read codepoint; -1 if the codepoint was invalid
- */
-extern int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst);
-
-/*
- * Iterate through an UTF-8 string and stops after finding any invalid UTF-8
- * codepoints.
- *
- * @param str string to scan
- * @param str_len size of the string
- * @return length in bytes of the string that contains valid data
- */
-extern size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len);
-
-/*
* Safely zero-out memory, making sure that the compiler
* doesn't optimize away the operation.
*/
@@ -380,7 +359,7 @@ GIT_INLINE(double) git__timer(void)
return (double)time * scaling_factor / 1.0E9;
}
-#elif defined(AMIGA)
+#elif defined(__amigaos4__)
#include <proto/timer.h>
@@ -397,23 +376,27 @@ GIT_INLINE(double) git__timer(void)
GIT_INLINE(double) git__timer(void)
{
- struct timespec tp;
+ struct timeval tv;
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
+#ifdef CLOCK_MONOTONIC
+ struct timespec tp;
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
return (double) tp.tv_sec + (double) tp.tv_nsec / 1.0E9;
- } else {
- /* Fall back to using gettimeofday */
- struct timeval tv;
- struct timezone tz;
- gettimeofday(&tv, &tz);
- return (double)tv.tv_sec + (double)tv.tv_usec / 1.0E6;
- }
+#endif
+
+ /* Fall back to using gettimeofday */
+ gettimeofday(&tv, NULL);
+ return (double)tv.tv_sec + (double)tv.tv_usec / 1.0E6;
}
#endif
extern int git__getenv(git_buf *out, const char *name);
+extern int git__online_cpus(void);
+
+GIT_INLINE(int) git__noop(void) { return 0; }
+
#include "alloc.h"
#endif
diff --git a/src/vector.c b/src/vector.c
index b51e764..4a4bc8c 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -53,7 +53,8 @@ int git_vector_size_hint(git_vector *v, size_t size_hint)
int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp)
{
- assert(v && src);
+ GIT_ASSERT_ARG(v);
+ GIT_ASSERT_ARG(src);
v->_alloc_size = 0;
v->contents = NULL;
@@ -77,7 +78,8 @@ int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp)
void git_vector_free(git_vector *v)
{
- assert(v);
+ if (!v)
+ return;
git__free(v->contents);
v->contents = NULL;
@@ -90,7 +92,8 @@ void git_vector_free_deep(git_vector *v)
{
size_t i;
- assert(v);
+ if (!v)
+ return;
for (i = 0; i < v->length; ++i) {
git__free(v->contents[i]);
@@ -102,7 +105,7 @@ void git_vector_free_deep(git_vector *v)
int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp)
{
- assert(v);
+ GIT_ASSERT_ARG(v);
v->_alloc_size = 0;
v->_cmp = cmp;
@@ -131,7 +134,7 @@ void **git_vector_detach(size_t *size, size_t *asize, git_vector *v)
int git_vector_insert(git_vector *v, void *element)
{
- assert(v);
+ GIT_ASSERT_ARG(v);
if (v->length >= v->_alloc_size &&
resize_vector(v, compute_new_size(v)) < 0)
@@ -150,7 +153,8 @@ int git_vector_insert_sorted(
int result;
size_t pos;
- assert(v && v->_cmp);
+ GIT_ASSERT_ARG(v);
+ GIT_ASSERT(v->_cmp);
if (!git_vector_is_sorted(v))
git_vector_sort(v);
@@ -180,8 +184,6 @@ int git_vector_insert_sorted(
void git_vector_sort(git_vector *v)
{
- assert(v);
-
if (git_vector_is_sorted(v) || !v->_cmp)
return;
@@ -196,7 +198,9 @@ int git_vector_bsearch2(
git_vector_cmp key_lookup,
const void *key)
{
- assert(v && key && key_lookup);
+ GIT_ASSERT_ARG(v);
+ GIT_ASSERT_ARG(key);
+ GIT_ASSERT(key_lookup);
/* need comparison function to sort the vector */
if (!v->_cmp)
@@ -212,7 +216,9 @@ int git_vector_search2(
{
size_t i;
- assert(v && key && key_lookup);
+ GIT_ASSERT_ARG(v);
+ GIT_ASSERT_ARG(key);
+ GIT_ASSERT(key_lookup);
for (i = 0; i < v->length; ++i) {
if (key_lookup(key, v->contents[i]) == 0) {
@@ -240,7 +246,7 @@ int git_vector_remove(git_vector *v, size_t idx)
{
size_t shift_count;
- assert(v);
+ GIT_ASSERT_ARG(v);
if (idx >= v->length)
return GIT_ENOTFOUND;
@@ -303,7 +309,6 @@ void git_vector_remove_matching(
void git_vector_clear(git_vector *v)
{
- assert(v);
v->length = 0;
git_vector_set_sorted(v, 1);
}
@@ -312,8 +317,6 @@ void git_vector_swap(git_vector *a, git_vector *b)
{
git_vector t;
- assert(a && b);
-
if (a != b) {
memcpy(&t, a, sizeof(t));
memcpy(a, b, sizeof(t));
@@ -340,7 +343,8 @@ int git_vector_insert_null(git_vector *v, size_t idx, size_t insert_len)
{
size_t new_length;
- assert(insert_len > 0 && idx <= v->length);
+ GIT_ASSERT_ARG(insert_len > 0);
+ GIT_ASSERT_ARG(idx <= v->length);
GIT_ERROR_CHECK_ALLOC_ADD(&new_length, v->length, insert_len);
@@ -359,13 +363,13 @@ int git_vector_remove_range(git_vector *v, size_t idx, size_t remove_len)
{
size_t new_length = v->length - remove_len;
size_t end_idx = 0;
-
- assert(remove_len > 0);
+
+ GIT_ASSERT_ARG(remove_len > 0);
if (git__add_sizet_overflow(&end_idx, idx, remove_len))
- assert(0);
+ GIT_ASSERT(0);
- assert(end_idx <= v->length);
+ GIT_ASSERT(end_idx <= v->length);
if (end_idx < v->length)
memmove(&v->contents[idx], &v->contents[end_idx],
diff --git a/src/vector.h b/src/vector.h
index cc4c314..3dcec3d 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -26,11 +26,13 @@ typedef struct git_vector {
#define GIT_VECTOR_INIT {0}
-int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp);
+GIT_WARN_UNUSED_RESULT int git_vector_init(
+ git_vector *v, size_t initial_size, git_vector_cmp cmp);
void git_vector_free(git_vector *v);
void git_vector_free_deep(git_vector *v); /* free each entry and self */
void git_vector_clear(git_vector *v);
-int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp);
+GIT_WARN_UNUSED_RESULT int git_vector_dup(
+ git_vector *v, const git_vector *src, git_vector_cmp cmp);
void git_vector_swap(git_vector *a, git_vector *b);
int git_vector_size_hint(git_vector *v, size_t size_hint);
diff --git a/src/win32/findfile.c b/src/win32/findfile.c
index 7f077e1..f541a03 100644
--- a/src/win32/findfile.c
+++ b/src/win32/findfile.c
@@ -53,7 +53,9 @@ static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen)
{
wchar_t term, *base = path;
- assert(path && buf && buflen);
+ GIT_ASSERT_ARG_WITH_RETVAL(path, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(buf, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(buflen, NULL);
term = (*path == L'"') ? *path++ : L';';
@@ -109,7 +111,7 @@ static int win32_find_git_in_registry(
HKEY hKey;
int error = GIT_ENOTFOUND;
- assert(buf);
+ GIT_ASSERT_ARG(buf);
if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) {
DWORD dwType, cbData;
diff --git a/src/win32/git2.rc b/src/win32/git2.rc
index 3571bc6..d273afd 100644
--- a/src/win32/git2.rc
+++ b/src/win32/git2.rc
@@ -2,14 +2,29 @@
#include "../../include/git2/version.h"
#ifndef LIBGIT2_FILENAME
-# define LIBGIT2_FILENAME "git2"
+# ifdef __GNUC__
+# define LIBGIT2_FILENAME git2
+# else
+# define LIBGIT2_FILENAME "git2"
+# endif
#endif
#ifndef LIBGIT2_COMMENTS
# define LIBGIT2_COMMENTS "For more information visit http://libgit2.github.com/"
#endif
+#ifdef __GNUC__
+# define _STR(x) #x
+# define STR(x) _STR(x)
+#else
+# define STR(x) x
+#endif
+
+#ifdef __GNUC__
+VS_VERSION_INFO VERSIONINFO
+#else
VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
+#endif
FILEVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH
PRODUCTVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
@@ -29,9 +44,9 @@ BEGIN
BEGIN
VALUE "FileDescription", "libgit2 - the Git linkable library\0"
VALUE "FileVersion", LIBGIT2_VERSION "\0"
- VALUE "InternalName", LIBGIT2_FILENAME ".dll\0"
+ VALUE "InternalName", STR(LIBGIT2_FILENAME) ".dll\0"
VALUE "LegalCopyright", "Copyright (C) the libgit2 contributors. All rights reserved.\0"
- VALUE "OriginalFilename", LIBGIT2_FILENAME ".dll\0"
+ VALUE "OriginalFilename", STR(LIBGIT2_FILENAME) ".dll\0"
VALUE "ProductName", "libgit2\0"
VALUE "ProductVersion", LIBGIT2_VERSION "\0"
VALUE "Comments", LIBGIT2_COMMENTS "\0"
diff --git a/src/win32/map.c b/src/win32/map.c
index e2ce737..2aabc9b 100644
--- a/src/win32/map.c
+++ b/src/win32/map.c
@@ -117,7 +117,7 @@ int p_munmap(git_map *map)
{
int error = 0;
- assert(map != NULL);
+ GIT_ASSERT_ARG(map);
if (map->data) {
if (!UnmapViewOfFile(map->data)) {
diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h
index 4cf471f..03f9f36 100644
--- a/src/win32/msvc-compat.h
+++ b/src/win32/msvc-compat.h
@@ -23,6 +23,14 @@ typedef SSIZE_T ssize_t;
#endif
-#define GIT_STDLIB_CALL __cdecl
+/*
+ * Offer GIT_LIBGIT2_CALL for our calling conventions (__cdecl, always).
+ * This is useful for providing callbacks to userspace code.
+ *
+ * Offer GIT_SYSTEM_CALL for the system calling conventions (__stdcall on
+ * Win32). Useful for providing callbacks to system libraries.
+ */
+#define GIT_LIBGIT2_CALL __cdecl
+#define GIT_SYSTEM_CALL NTAPI
#endif
diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c
index eda85ab..e6640c8 100644
--- a/src/win32/path_w32.c
+++ b/src/win32/path_w32.c
@@ -25,6 +25,9 @@
#define path__is_unc(p) \
(((p)[0] == '\\' && (p)[1] == '\\') || ((p)[0] == '/' && (p)[1] == '/'))
+#define path__startswith_slash(p) \
+ ((p)[0] == '\\' || (p)[0] == '/')
+
GIT_INLINE(int) path__cwd(wchar_t *path, int size)
{
int len;
@@ -148,7 +151,7 @@ int git_win32_path_canonicalize(git_win32_path path)
return (int)(to - path);
}
-int git_win32_path__cwd(wchar_t *out, size_t len)
+static int win32_path_cwd(wchar_t *out, size_t len)
{
int cwd_len;
@@ -167,7 +170,7 @@ int git_win32_path__cwd(wchar_t *out, size_t len)
* '\'s, but we we add a 'UNC' specifier to the path, plus
* a trailing directory separator, plus a NUL.
*/
- if (cwd_len > MAX_PATH - 4) {
+ if (cwd_len > GIT_WIN_PATH_MAX - 4) {
errno = ENAMETOOLONG;
return -1;
}
@@ -184,7 +187,7 @@ int git_win32_path__cwd(wchar_t *out, size_t len)
* working directory. (One character for the directory separator,
* one for the null.
*/
- else if (cwd_len > MAX_PATH - 2) {
+ else if (cwd_len > GIT_WIN_PATH_MAX - 2) {
errno = ENAMETOOLONG;
return -1;
}
@@ -202,13 +205,13 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
/* See if this is an absolute path (beginning with a drive letter) */
if (git_path_is_absolute(src)) {
- if (git__utf8_to_16(dest, MAX_PATH, src) < 0)
+ if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src) < 0)
goto on_error;
}
/* File-prefixed NT-style paths beginning with \\?\ */
else if (path__is_nt_namespace(src)) {
/* Skip the NT prefix, the destination already contains it */
- if (git__utf8_to_16(dest, MAX_PATH, src + PATH__NT_NAMESPACE_LEN) < 0)
+ if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src + PATH__NT_NAMESPACE_LEN) < 0)
goto on_error;
}
/* UNC paths */
@@ -217,12 +220,12 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
dest += 4;
/* Skip the leading "\\" */
- if (git__utf8_to_16(dest, MAX_PATH - 2, src + 2) < 0)
+ if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX - 2, src + 2) < 0)
goto on_error;
}
/* Absolute paths omitting the drive letter */
- else if (src[0] == '\\' || src[0] == '/') {
- if (path__cwd(dest, MAX_PATH) < 0)
+ else if (path__startswith_slash(src)) {
+ if (path__cwd(dest, GIT_WIN_PATH_MAX) < 0)
goto on_error;
if (!git_path_is_absolute(dest)) {
@@ -231,19 +234,19 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
}
/* Skip the drive letter specification ("C:") */
- if (git__utf8_to_16(dest + 2, MAX_PATH - 2, src) < 0)
+ if (git__utf8_to_16(dest + 2, GIT_WIN_PATH_MAX - 2, src) < 0)
goto on_error;
}
/* Relative paths */
else {
int cwd_len;
- if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0)
+ if ((cwd_len = win32_path_cwd(dest, GIT_WIN_PATH_MAX)) < 0)
goto on_error;
dest[cwd_len++] = L'\\';
- if (git__utf8_to_16(dest + cwd_len, MAX_PATH - cwd_len, src) < 0)
+ if (git__utf8_to_16(dest + cwd_len, GIT_WIN_PATH_MAX - cwd_len, src) < 0)
goto on_error;
}
@@ -257,6 +260,30 @@ on_error:
return -1;
}
+int git_win32_path_relative_from_utf8(git_win32_path out, const char *src)
+{
+ wchar_t *dest = out, *p;
+ int len;
+
+ /* Handle absolute paths */
+ if (git_path_is_absolute(src) ||
+ path__is_nt_namespace(src) ||
+ path__is_unc(src) ||
+ path__startswith_slash(src)) {
+ return git_win32_path_from_utf8(out, src);
+ }
+
+ if ((len = git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src)) < 0)
+ return -1;
+
+ for (p = dest; p < (dest + len); p++) {
+ if (*p == L'/')
+ *p = L'\\';
+ }
+
+ return len;
+}
+
int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src)
{
char *out = dest;
@@ -354,14 +381,14 @@ int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path)
switch (reparse_buf->ReparseTag) {
case IO_REPARSE_TAG_SYMLINK:
- target = reparse_buf->SymbolicLinkReparseBuffer.PathBuffer +
- (reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
- target_len = reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
+ target = reparse_buf->ReparseBuffer.SymbolicLink.PathBuffer +
+ (reparse_buf->ReparseBuffer.SymbolicLink.SubstituteNameOffset / sizeof(WCHAR));
+ target_len = reparse_buf->ReparseBuffer.SymbolicLink.SubstituteNameLength / sizeof(WCHAR);
break;
case IO_REPARSE_TAG_MOUNT_POINT:
- target = reparse_buf->MountPointReparseBuffer.PathBuffer +
- (reparse_buf->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
- target_len = reparse_buf->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
+ target = reparse_buf->ReparseBuffer.MountPoint.PathBuffer +
+ (reparse_buf->ReparseBuffer.MountPoint.SubstituteNameOffset / sizeof(WCHAR));
+ target_len = reparse_buf->ReparseBuffer.MountPoint.SubstituteNameLength / sizeof(WCHAR);
break;
default:
errno = EINVAL;
@@ -465,14 +492,12 @@ size_t git_win32_path_remove_namespace(wchar_t *str, size_t len)
prefix_len = CONST_STRLEN(unc_prefix);
}
- if (remainder) {
- /*
- * Sanity check that the new string isn't longer than the old one.
- * (This could only happen due to programmer error introducing a
- * prefix longer than the namespace it replaces.)
- */
- assert(len >= remainder_len + prefix_len);
-
+ /*
+ * Sanity check that the new string isn't longer than the old one.
+ * (This could only happen due to programmer error introducing a
+ * prefix longer than the namespace it replaces.)
+ */
+ if (remainder && len >= remainder_len + prefix_len) {
if (prefix)
memmove(str, prefix, prefix_len * sizeof(wchar_t));
diff --git a/src/win32/path_w32.h b/src/win32/path_w32.h
index afd0aa1..4fadf8d 100644
--- a/src/win32/path_w32.h
+++ b/src/win32/path_w32.h
@@ -8,10 +8,11 @@
#define INCLUDE_win32_path_w32_h__
#include "common.h"
-#include "vector.h"
/**
- * Create a Win32 path (in UCS-2 format) from a UTF-8 string.
+ * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given
+ * path is relative, then it will be turned into an absolute path by having
+ * the current working directory prepended.
*
* @param dest The buffer to receive the wide string.
* @param src The UTF-8 string to convert.
@@ -20,12 +21,25 @@
extern int git_win32_path_from_utf8(git_win32_path dest, const char *src);
/**
+ * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given
+ * path is relative, then it will not be turned into an absolute path.
+ *
+ * @param dest The buffer to receive the wide string.
+ * @param src The UTF-8 string to convert.
+ * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
+ */
+extern int git_win32_path_relative_from_utf8(git_win32_path dest, const char *src);
+
+/**
* Canonicalize a Win32 UCS-2 path so that it is suitable for delivery to the
* Win32 APIs: remove multiple directory separators, squashing to a single one,
* strip trailing directory separators, ensure directory separators are all
* canonical (always backslashes, never forward slashes) and process any
* directory entries of '.' or '..'.
*
+ * Note that this is intended to be used on absolute Windows paths, those
+ * that start with `C:\`, `\\server\share`, `\\?\`, etc.
+ *
* This processes the buffer in place.
*
* @param path The buffer to process
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 29641bd..7fcc472 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -14,7 +14,6 @@
#include "utf-conv.h"
#include "repository.h"
#include "reparse.h"
-#include "global.h"
#include "buffer.h"
#include <errno.h>
#include <io.h>
@@ -447,8 +446,7 @@ int p_symlink(const char *target, const char *path)
* relative symlinks, this is not someting we want.
*/
if (git_win32_path_from_utf8(path_w, path) < 0 ||
- git__utf8_to_16(target_w, MAX_PATH, target) < 0 ||
- git_win32_path_canonicalize(target_w) < 0)
+ git_win32_path_relative_from_utf8(target_w, target) < 0)
return -1;
dwFlags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
@@ -545,6 +543,13 @@ int p_open(const char *path, int flags, ...)
mode_t mode = 0;
struct open_opts opts = {0};
+ #ifdef GIT_DEBUG_STRICT_OPEN
+ if (strstr(path, "//") != NULL) {
+ errno = EACCES;
+ return -1;
+ }
+ #endif
+
if (git_win32_path_from_utf8(wpath, path) < 0)
return -1;
@@ -983,3 +988,73 @@ int p_inet_pton(int af, const char *src, void *dst)
errno = EINVAL;
return -1;
}
+
+ssize_t p_pread(int fd, void *data, size_t size, off64_t offset)
+{
+ HANDLE fh;
+ DWORD rsize = 0;
+ OVERLAPPED ov = {0};
+ LARGE_INTEGER pos = {0};
+ off64_t final_offset = 0;
+
+ /* Fail if the final offset would have overflowed to match POSIX semantics. */
+ if (!git__is_ssizet(size) || git__add_int64_overflow(&final_offset, offset, (int64_t)size)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /*
+ * Truncate large writes to the maximum allowable size: the caller
+ * needs to always call this in a loop anyways.
+ */
+ if (size > INT32_MAX) {
+ size = INT32_MAX;
+ }
+
+ pos.QuadPart = offset;
+ ov.Offset = pos.LowPart;
+ ov.OffsetHigh = pos.HighPart;
+ fh = (HANDLE)_get_osfhandle(fd);
+
+ if (ReadFile(fh, data, (DWORD)size, &rsize, &ov)) {
+ return (ssize_t)rsize;
+ }
+
+ set_errno();
+ return -1;
+}
+
+ssize_t p_pwrite(int fd, const void *data, size_t size, off64_t offset)
+{
+ HANDLE fh;
+ DWORD wsize = 0;
+ OVERLAPPED ov = {0};
+ LARGE_INTEGER pos = {0};
+ off64_t final_offset = 0;
+
+ /* Fail if the final offset would have overflowed to match POSIX semantics. */
+ if (!git__is_ssizet(size) || git__add_int64_overflow(&final_offset, offset, (int64_t)size)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /*
+ * Truncate large writes to the maximum allowable size: the caller
+ * needs to always call this in a loop anyways.
+ */
+ if (size > INT32_MAX) {
+ size = INT32_MAX;
+ }
+
+ pos.QuadPart = offset;
+ ov.Offset = pos.LowPart;
+ ov.OffsetHigh = pos.HighPart;
+ fh = (HANDLE)_get_osfhandle(fd);
+
+ if (WriteFile(fh, data, (DWORD)size, &wsize, &ov)) {
+ return (ssize_t)wsize;
+ }
+
+ set_errno();
+ return -1;
+}
diff --git a/src/win32/precompiled.h b/src/win32/precompiled.h
index 314383d..806b169 100644
--- a/src/win32/precompiled.h
+++ b/src/win32/precompiled.h
@@ -1,6 +1,5 @@
#include "common.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/src/win32/reparse.h b/src/win32/reparse.h
index 5f7408a..2331231 100644
--- a/src/win32/reparse.h
+++ b/src/win32/reparse.h
@@ -26,18 +26,18 @@ typedef struct _GIT_REPARSE_DATA_BUFFER {
USHORT PrintNameLength;
ULONG Flags;
WCHAR PathBuffer[1];
- } SymbolicLinkReparseBuffer;
+ } SymbolicLink;
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
WCHAR PathBuffer[1];
- } MountPointReparseBuffer;
+ } MountPoint;
struct {
UCHAR DataBuffer[1];
- } GenericReparseBuffer;
- };
+ } Generic;
+ } ReparseBuffer;
} GIT_REPARSE_DATA_BUFFER;
#define REPARSE_DATA_HEADER_SIZE 8
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 42dba7f..f5cacd3 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -6,8 +6,7 @@
*/
#include "thread.h"
-
-#include "../global.h"
+#include "runtime.h"
#define CLEAN_THREAD_EXIT 0x6F012842
@@ -19,6 +18,8 @@ static win32_srwlock_fn win32_srwlock_release_shared;
static win32_srwlock_fn win32_srwlock_acquire_exclusive;
static win32_srwlock_fn win32_srwlock_release_exclusive;
+static DWORD fls_index;
+
/* The thread procedure stub used to invoke the caller's procedure
* and capture the return value for later collection. Windows will
* only hold a DWORD, but we need to be able to store an entire
@@ -28,14 +29,19 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
git_thread *thread = lpParameter;
/* Set the current thread for `git_thread_exit` */
- GIT_GLOBAL->current_thread = thread;
+ FlsSetValue(fls_index, thread);
thread->result = thread->proc(thread->param);
return CLEAN_THREAD_EXIT;
}
-int git_threads_init(void)
+static void git_threads_global_shutdown(void)
+{
+ FlsFree(fls_index);
+}
+
+int git_threads_global_init(void)
{
HMODULE hModule = GetModuleHandleW(L"kernel32");
@@ -52,7 +58,10 @@ int git_threads_init(void)
GetProcAddress(hModule, "ReleaseSRWLockExclusive");
}
- return 0;
+ if ((fls_index = FlsAlloc(NULL)) == FLS_OUT_OF_INDEXES)
+ return -1;
+
+ return git_runtime_shutdown_register(git_threads_global_shutdown);
}
int git_thread_create(
@@ -85,10 +94,7 @@ int git_thread_join(
/* Check for the thread having exited uncleanly. If exit was unclean,
* then we don't have a return value to give back to the caller. */
- if (exit != CLEAN_THREAD_EXIT) {
- assert(false);
- thread->result = NULL;
- }
+ GIT_ASSERT(exit == CLEAN_THREAD_EXIT);
if (value_ptr)
*value_ptr = thread->result;
@@ -99,8 +105,11 @@ int git_thread_join(
void git_thread_exit(void *value)
{
- assert(GIT_GLOBAL->current_thread);
- GIT_GLOBAL->current_thread->result = value;
+ git_thread *thread = FlsGetValue(fls_index);
+
+ if (thread)
+ thread->result = value;
+
ExitThread(CLEAN_THREAD_EXIT);
}
@@ -137,7 +146,7 @@ int git_cond_init(git_cond *cond)
{
/* This is an auto-reset event. */
*cond = CreateEventW(NULL, FALSE, FALSE, NULL);
- assert(*cond);
+ GIT_ASSERT(*cond);
/* If we can't create the event, claim that the reason was out-of-memory.
* The actual reason can be fetched with GetLastError(). */
@@ -152,7 +161,7 @@ int git_cond_free(git_cond *cond)
return EINVAL;
closed = CloseHandle(*cond);
- assert(closed);
+ GIT_ASSERT(closed);
GIT_UNUSED(closed);
*cond = NULL;
@@ -174,7 +183,7 @@ int git_cond_wait(git_cond *cond, git_mutex *mutex)
return error;
wait_result = WaitForSingleObject(*cond, INFINITE);
- assert(WAIT_OBJECT_0 == wait_result);
+ GIT_ASSERT(WAIT_OBJECT_0 == wait_result);
GIT_UNUSED(wait_result);
return git_mutex_lock(mutex);
@@ -188,7 +197,7 @@ int git_cond_signal(git_cond *cond)
return EINVAL;
signaled = SetEvent(*cond);
- assert(signaled);
+ GIT_ASSERT(signaled);
GIT_UNUSED(signaled);
return 0;
diff --git a/src/win32/thread.h b/src/win32/thread.h
index 41cbf01..8305036 100644
--- a/src/win32/thread.h
+++ b/src/win32/thread.h
@@ -35,7 +35,7 @@ typedef struct {
} native;
} git_rwlock;
-int git_threads_init(void);
+int git_threads_global_init(void);
int git_thread_create(git_thread *GIT_RESTRICT,
void *(*) (void *),
diff --git a/src/win32/w32_buffer.c b/src/win32/w32_buffer.c
index b78a7e6..f270a1e 100644
--- a/src/win32/w32_buffer.c
+++ b/src/win32/w32_buffer.c
@@ -32,13 +32,13 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
return -1;
}
- assert(string_w);
+ GIT_ASSERT(string_w);
/* Measure the string necessary for conversion */
if ((utf8_len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, string_w, (int)len_w, NULL, 0, NULL, NULL)) == 0)
return 0;
- assert(utf8_len > 0);
+ GIT_ASSERT(utf8_len > 0);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, (size_t)utf8_len);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
@@ -50,7 +50,7 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
CP_UTF8, WC_ERR_INVALID_CHARS, string_w, (int)len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0)
return handle_wc_error();
- assert(utf8_write_len == utf8_len);
+ GIT_ASSERT(utf8_write_len == utf8_len);
buf->size += utf8_write_len;
buf->ptr[buf->size] = '\0';
diff --git a/src/win32/w32_common.h b/src/win32/w32_common.h
index f9e74b9..c20b3e8 100644
--- a/src/win32/w32_common.h
+++ b/src/win32/w32_common.h
@@ -8,24 +8,33 @@
#ifndef INCLUDE_win32_w32_common_h__
#define INCLUDE_win32_w32_common_h__
+#include <git2/common.h>
+
+/*
+ * 4096 is the max allowed Git path. `MAX_PATH` (260) is the typical max allowed
+ * Windows path length, however win32 Unicode APIs generally allow up to 32,767
+ * if prefixed with "\\?\" (i.e. converted to an NT-style name).
+ */
+#define GIT_WIN_PATH_MAX GIT_PATH_MAX
+
/*
- * Provides a large enough buffer to support Windows paths: MAX_PATH is
- * 260, corresponding to a maximum path length of 259 characters plus a
- * NULL terminator. Prefixing with "\\?\" adds 4 characters, but if the
- * original was a UNC path, then we turn "\\server\share" into
+ * Provides a large enough buffer to support Windows Git paths:
+ * GIT_WIN_PATH_MAX is 4096, corresponding to a maximum path length of 4095
+ * characters plus a NULL terminator. Prefixing with "\\?\" adds 4 characters,
+ * but if the original was a UNC path, then we turn "\\server\share" into
* "\\?\UNC\server\share". So we replace the first two characters with
- * 8 characters, a net gain of 6, so the maximum length is MAX_PATH+6.
+ * 8 characters, a net gain of 6, so the maximum length is GIT_WIN_PATH_MAX+6.
*/
-#define GIT_WIN_PATH_UTF16 MAX_PATH+6
+#define GIT_WIN_PATH_UTF16 GIT_WIN_PATH_MAX+6
-/* Maximum size of a UTF-8 Win32 path. We remove the "\\?\" or "\\?\UNC\"
- * prefixes for presentation, bringing us back to 259 (non-NULL)
+/* Maximum size of a UTF-8 Win32 Git path. We remove the "\\?\" or "\\?\UNC\"
+ * prefixes for presentation, bringing us back to 4095 (non-NULL)
* characters. UTF-8 does have 4-byte sequences, but they are encoded in
* UTF-16 using surrogate pairs, which takes up the space of two characters.
* Two characters in the range U+0800 -> U+FFFF take up more space in UTF-8
* (6 bytes) than one surrogate pair (4 bytes).
*/
-#define GIT_WIN_PATH_UTF8 (259 * 3 + 1)
+#define GIT_WIN_PATH_UTF8 ((GIT_WIN_PATH_MAX - 1) * 3 + 1)
/*
* The length of a Windows "shortname", for 8.3 compatibility.
diff --git a/src/win32/w32_crtdbg_stacktrace.c b/src/win32/w32_crtdbg_stacktrace.c
deleted file mode 100644
index cdb5ac1..0000000
--- a/src/win32/w32_crtdbg_stacktrace.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "w32_crtdbg_stacktrace.h"
-
-#if defined(GIT_MSVC_CRTDBG)
-#include "w32_stack.h"
-
-#define CRTDBG_STACKTRACE__UID_LEN (15)
-
-/**
- * The stacktrace of an allocation can be distilled
- * to a unique id based upon the stackframe pointers
- * and ignoring any size arguments. We will use these
- * UIDs as the (char const*) __FILE__ argument we
- * give to the CRT malloc routines.
- */
-typedef struct {
- char uid[CRTDBG_STACKTRACE__UID_LEN + 1];
-} git_win32__crtdbg_stacktrace__uid;
-
-/**
- * All mallocs with the same stacktrace will be de-duped
- * and aggregated into this row.
- */
-typedef struct {
- git_win32__crtdbg_stacktrace__uid uid; /* must be first */
- git_win32__stack__raw_data raw_data;
- unsigned int count_allocs; /* times this alloc signature seen since init */
- unsigned int count_allocs_at_last_checkpoint; /* times since last mark */
- unsigned int transient_count_leaks; /* sum of leaks */
-} git_win32__crtdbg_stacktrace__row;
-
-static CRITICAL_SECTION g_crtdbg_stacktrace_cs;
-
-/**
- * CRTDBG memory leak tracking takes a "char const * const file_name"
- * and stores the pointer in the heap data (instead of allocing a copy
- * for itself). Normally, this is not a problem, since we usually pass
- * in __FILE__. But I'm going to lie to it and pass in the address of
- * the UID in place of the file_name. Also, I do not want to alloc the
- * stacktrace data (because we are called from inside our alloc routines).
- * Therefore, I'm creating a very large static pool array to store row
- * data. This also eliminates the temptation to realloc it (and move the
- * UID pointers).
- *
- * And to efficiently look for duplicates we need an index on the rows
- * so we can bsearch it. Again, without mallocing.
- *
- * If we observe more than MY_ROW_LIMIT unique malloc signatures, we
- * fall through and use the traditional __FILE__ processing and don't
- * try to de-dup them. If your testing hits this limit, just increase
- * it and try again.
- */
-
-#define MY_ROW_LIMIT (1024 * 1024)
-static git_win32__crtdbg_stacktrace__row g_cs_rows[MY_ROW_LIMIT];
-static git_win32__crtdbg_stacktrace__row *g_cs_index[MY_ROW_LIMIT];
-
-static unsigned int g_cs_end = MY_ROW_LIMIT;
-static unsigned int g_cs_ins = 0; /* insertion point == unique allocs seen */
-static unsigned int g_count_total_allocs = 0; /* number of allocs seen */
-static unsigned int g_transient_count_total_leaks = 0; /* number of total leaks */
-static unsigned int g_transient_count_dedup_leaks = 0; /* number of unique leaks */
-static bool g_limit_reached = false; /* had allocs after we filled row table */
-
-static unsigned int g_checkpoint_id = 0; /* to better label leak checkpoints */
-static bool g_transient_leaks_since_mark = false; /* payload for hook */
-
-/**
- * Compare function for bsearch on g_cs_index table.
- */
-static int row_cmp(const void *v1, const void *v2)
-{
- git_win32__stack__raw_data *d1 = (git_win32__stack__raw_data*)v1;
- git_win32__crtdbg_stacktrace__row *r2 = (git_win32__crtdbg_stacktrace__row *)v2;
-
- return (git_win32__stack_compare(d1, &r2->raw_data));
-}
-
-/**
- * Unique insert the new data into the row and index tables.
- * We have to sort by the stackframe data itself, not the uid.
- */
-static git_win32__crtdbg_stacktrace__row * insert_unique(
- const git_win32__stack__raw_data *pdata)
-{
- size_t pos;
- if (git__bsearch(g_cs_index, g_cs_ins, pdata, row_cmp, &pos) < 0) {
- /* Append new unique item to row table. */
- memcpy(&g_cs_rows[g_cs_ins].raw_data, pdata, sizeof(*pdata));
- sprintf(g_cs_rows[g_cs_ins].uid.uid, "##%08lx", g_cs_ins);
-
- /* Insert pointer to it into the proper place in the index table. */
- if (pos < g_cs_ins)
- memmove(&g_cs_index[pos+1], &g_cs_index[pos], (g_cs_ins - pos)*sizeof(g_cs_index[0]));
- g_cs_index[pos] = &g_cs_rows[g_cs_ins];
-
- g_cs_ins++;
- }
-
- g_cs_index[pos]->count_allocs++;
-
- return g_cs_index[pos];
-}
-
-/**
- * Hook function to receive leak data from the CRT. (This includes
- * both "<file_name>:(<line_number>)" data, but also each of the
- * various headers and fields.
- *
- * Scan this for the special "##<pos>" UID forms that we substituted
- * for the "<file_name>". Map <pos> back to the row data and
- * increment its leak count.
- *
- * See https://msdn.microsoft.com/en-us/library/74kabxyx.aspx
- *
- * We suppress the actual crtdbg output.
- */
-static int __cdecl report_hook(int nRptType, char *szMsg, int *retVal)
-{
- static int hook_result = TRUE; /* FALSE to get stock dump; TRUE to suppress. */
- unsigned int pos;
-
- *retVal = 0; /* do not invoke debugger */
-
- if ((szMsg[0] != '#') || (szMsg[1] != '#'))
- return hook_result;
-
- if (sscanf(&szMsg[2], "%08lx", &pos) < 1)
- return hook_result;
- if (pos >= g_cs_ins)
- return hook_result;
-
- if (g_transient_leaks_since_mark) {
- if (g_cs_rows[pos].count_allocs == g_cs_rows[pos].count_allocs_at_last_checkpoint)
- return hook_result;
- }
-
- g_cs_rows[pos].transient_count_leaks++;
-
- if (g_cs_rows[pos].transient_count_leaks == 1)
- g_transient_count_dedup_leaks++;
-
- g_transient_count_total_leaks++;
-
- return hook_result;
-}
-
-/**
- * Write leak data to all of the various places we need.
- * We force the caller to sprintf() the message first
- * because we want to avoid fprintf() because it allocs.
- */
-static void my_output(const char *buf)
-{
- fwrite(buf, strlen(buf), 1, stderr);
- OutputDebugString(buf);
-}
-
-/**
- * For each row with leaks, dump a stacktrace for it.
- */
-static void dump_summary(const char *label)
-{
- unsigned int k;
- char buf[10 * 1024];
-
- if (g_transient_count_total_leaks == 0)
- return;
-
- fflush(stdout);
- fflush(stderr);
- my_output("\n");
-
- if (g_limit_reached) {
- sprintf(buf,
- "LEAK SUMMARY: de-dup row table[%d] filled. Increase MY_ROW_LIMIT.\n",
- MY_ROW_LIMIT);
- my_output(buf);
- }
-
- if (!label)
- label = "";
-
- if (g_transient_leaks_since_mark) {
- sprintf(buf, "LEAK CHECKPOINT %d: leaks %d unique %d: %s\n",
- g_checkpoint_id, g_transient_count_total_leaks, g_transient_count_dedup_leaks, label);
- my_output(buf);
- } else {
- sprintf(buf, "LEAK SUMMARY: TOTAL leaks %d de-duped %d: %s\n",
- g_transient_count_total_leaks, g_transient_count_dedup_leaks, label);
- my_output(buf);
- }
- my_output("\n");
-
- for (k = 0; k < g_cs_ins; k++) {
- if (g_cs_rows[k].transient_count_leaks > 0) {
- sprintf(buf, "LEAK: %s leaked %d of %d times:\n",
- g_cs_rows[k].uid.uid,
- g_cs_rows[k].transient_count_leaks,
- g_cs_rows[k].count_allocs);
- my_output(buf);
-
- if (git_win32__stack_format(
- buf, sizeof(buf), &g_cs_rows[k].raw_data,
- NULL, NULL) >= 0) {
- my_output(buf);
- }
-
- my_output("\n");
- }
- }
-
- fflush(stderr);
-}
-
-void git_win32__crtdbg_stacktrace_init(void)
-{
- InitializeCriticalSection(&g_crtdbg_stacktrace_cs);
-
- EnterCriticalSection(&g_crtdbg_stacktrace_cs);
-
- _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
-
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
-
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
-
- LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
-}
-
-int git_win32__crtdbg_stacktrace__dump(
- git_win32__crtdbg_stacktrace_options opt,
- const char *label)
-{
- _CRT_REPORT_HOOK old;
- unsigned int k;
- int r = 0;
-
-#define IS_BIT_SET(o,b) (((o) & (b)) != 0)
-
- bool b_set_mark = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK);
- bool b_leaks_since_mark = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK);
- bool b_leaks_total = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL);
- bool b_quiet = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__QUIET);
-
- if (b_leaks_since_mark && b_leaks_total) {
- git_error_set(GIT_ERROR_INVALID, "cannot combine LEAKS_SINCE_MARK and LEAKS_TOTAL.");
- return GIT_ERROR;
- }
- if (!b_set_mark && !b_leaks_since_mark && !b_leaks_total) {
- git_error_set(GIT_ERROR_INVALID, "nothing to do.");
- return GIT_ERROR;
- }
-
- EnterCriticalSection(&g_crtdbg_stacktrace_cs);
-
- if (b_leaks_since_mark || b_leaks_total) {
- /* All variables with "transient" in the name are per-dump counters
- * and reset before each dump. This lets us handle checkpoints.
- */
- g_transient_count_total_leaks = 0;
- g_transient_count_dedup_leaks = 0;
- for (k = 0; k < g_cs_ins; k++) {
- g_cs_rows[k].transient_count_leaks = 0;
- }
- }
-
- g_transient_leaks_since_mark = b_leaks_since_mark;
-
- old = _CrtSetReportHook(report_hook);
- _CrtDumpMemoryLeaks();
- _CrtSetReportHook(old);
-
- if (b_leaks_since_mark || b_leaks_total) {
- r = g_transient_count_dedup_leaks;
-
- if (!b_quiet)
- dump_summary(label);
- }
-
- if (b_set_mark) {
- for (k = 0; k < g_cs_ins; k++) {
- g_cs_rows[k].count_allocs_at_last_checkpoint = g_cs_rows[k].count_allocs;
- }
-
- g_checkpoint_id++;
- }
-
- LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
-
- return r;
-}
-
-void git_win32__crtdbg_stacktrace_cleanup(void)
-{
- /* At shutdown/cleanup, dump cummulative leak info
- * with everything since startup. This might generate
- * extra noise if the caller has been doing checkpoint
- * dumps, but it might also eliminate some false
- * positives for resources previously reported during
- * checkpoints.
- */
- git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL,
- "CLEANUP");
-
- DeleteCriticalSection(&g_crtdbg_stacktrace_cs);
-}
-
-const char *git_win32__crtdbg_stacktrace(int skip, const char *file)
-{
- git_win32__stack__raw_data new_data;
- git_win32__crtdbg_stacktrace__row *row;
- const char * result = file;
-
- if (git_win32__stack_capture(&new_data, skip+1) < 0)
- return result;
-
- EnterCriticalSection(&g_crtdbg_stacktrace_cs);
-
- if (g_cs_ins < g_cs_end) {
- row = insert_unique(&new_data);
- result = row->uid.uid;
- } else {
- g_limit_reached = true;
- }
-
- g_count_total_allocs++;
-
- LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
-
- return result;
-}
-
-#endif
diff --git a/src/win32/w32_crtdbg_stacktrace.h b/src/win32/w32_crtdbg_stacktrace.h
deleted file mode 100644
index d65154b..0000000
--- a/src/win32/w32_crtdbg_stacktrace.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_win32_w32_crtdbg_stacktrace_h__
-#define INCLUDE_win32_w32_crtdbg_stacktrace_h__
-
-#include "common.h"
-
-#if defined(GIT_MSVC_CRTDBG)
-
-#include <stdlib.h>
-#include <crtdbg.h>
-
-#include "git2/errors.h"
-#include "strnlen.h"
-
-/* MSVC CRTDBG memory leak reporting.
- *
- * We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC
- * documentation because all allocs/frees in libgit2 already go through
- * the "git__" routines defined in this file. Simply using the normal
- * reporting mechanism causes all leaks to be attributed to a routine
- * here in util.h (ie, the actual call to calloc()) rather than the
- * caller of git__calloc().
- *
- * Therefore, we declare a set of "git__crtdbg__" routines to replace
- * the corresponding "git__" routines and re-define the "git__" symbols
- * as macros. This allows us to get and report the file:line info of
- * the real caller.
- *
- * We DO NOT replace the "git__free" routine because it needs to remain
- * a function pointer because it is used as a function argument when
- * setting up various structure "destructors".
- *
- * We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes
- * "free" to be remapped to "_free_dbg" and this causes problems for
- * structures which define a field named "free".
- *
- * Finally, CRTDBG must be explicitly enabled and configured at program
- * startup. See tests/main.c for an example.
- */
-
-/**
- * Initialize our memory leak tracking and de-dup data structures.
- * This should ONLY be called by git_libgit2_init().
- */
-void git_win32__crtdbg_stacktrace_init(void);
-
-/**
- * Shutdown our memory leak tracking and dump summary data.
- * This should ONLY be called by git_libgit2_shutdown().
- *
- * We explicitly call _CrtDumpMemoryLeaks() during here so
- * that we can compute summary data for the leaks. We print
- * the stacktrace of each unique leak.
- *
- * This cleanup does not happen if the app calls exit()
- * without calling the libgit2 shutdown code.
- *
- * This info we print here is independent of any automatic
- * reporting during exit() caused by _CRTDBG_LEAK_CHECK_DF.
- * Set it in your app if you also want traditional reporting.
- */
-void git_win32__crtdbg_stacktrace_cleanup(void);
-
-/**
- * Checkpoint options.
- */
-typedef enum git_win32__crtdbg_stacktrace_options {
- /**
- * Set checkpoint marker.
- */
- GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK = (1 << 0),
-
- /**
- * Dump leaks since last checkpoint marker.
- * May not be combined with __LEAKS_TOTAL.
- *
- * Note that this may generate false positives for global TLS
- * error state and other global caches that aren't cleaned up
- * until the thread/process terminates. So when using this
- * around a region of interest, also check the final (at exit)
- * dump before digging into leaks reported here.
- */
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK = (1 << 1),
-
- /**
- * Dump leaks since init. May not be combined
- * with __LEAKS_SINCE_MARK.
- */
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL = (1 << 2),
-
- /**
- * Suppress printing during dumps.
- * Just return leak count.
- */
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET = (1 << 3),
-
-} git_win32__crtdbg_stacktrace_options;
-
-/**
- * Checkpoint memory state and/or dump unique stack traces of
- * current memory leaks.
- *
- * @return number of unique leaks (relative to requested starting
- * point) or error.
- */
-GIT_EXTERN(int) git_win32__crtdbg_stacktrace__dump(
- git_win32__crtdbg_stacktrace_options opt,
- const char *label);
-
-/**
- * Construct stacktrace and append it to the global buffer.
- * Return pointer to start of this string. On any error or
- * lack of buffer space, just return the given file buffer
- * so it will behave as usual.
- *
- * This should ONLY be called by our internal memory allocations
- * routines.
- */
-const char *git_win32__crtdbg_stacktrace(int skip, const char *file);
-
-#endif
-#endif
diff --git a/src/win32/w32_leakcheck.c b/src/win32/w32_leakcheck.c
new file mode 100644
index 0000000..5c8425b
--- /dev/null
+++ b/src/win32/w32_leakcheck.c
@@ -0,0 +1,581 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "w32_leakcheck.h"
+
+#if defined(GIT_WIN32_LEAKCHECK)
+
+#include "Windows.h"
+#include "Dbghelp.h"
+#include "win32/posix.h"
+#include "hash.h"
+#include "runtime.h"
+
+/* Stack frames (for stack tracing, below) */
+
+static bool g_win32_stack_initialized = false;
+static HANDLE g_win32_stack_process = INVALID_HANDLE_VALUE;
+static git_win32_leakcheck_stack_aux_cb_alloc g_aux_cb_alloc = NULL;
+static git_win32_leakcheck_stack_aux_cb_lookup g_aux_cb_lookup = NULL;
+
+int git_win32_leakcheck_stack_set_aux_cb(
+ git_win32_leakcheck_stack_aux_cb_alloc cb_alloc,
+ git_win32_leakcheck_stack_aux_cb_lookup cb_lookup)
+{
+ g_aux_cb_alloc = cb_alloc;
+ g_aux_cb_lookup = cb_lookup;
+
+ return 0;
+}
+
+/**
+ * Load symbol table data. This should be done in the primary
+ * thread at startup (under a lock if there are other threads
+ * active).
+ */
+void git_win32_leakcheck_stack_init(void)
+{
+ if (!g_win32_stack_initialized) {
+ g_win32_stack_process = GetCurrentProcess();
+ SymSetOptions(SYMOPT_LOAD_LINES);
+ SymInitialize(g_win32_stack_process, NULL, TRUE);
+ g_win32_stack_initialized = true;
+ }
+}
+
+/**
+ * Cleanup symbol table data. This should be done in the
+ * primary thead at shutdown (under a lock if there are other
+ * threads active).
+ */
+void git_win32_leakcheck_stack_cleanup(void)
+{
+ if (g_win32_stack_initialized) {
+ SymCleanup(g_win32_stack_process);
+ g_win32_stack_process = INVALID_HANDLE_VALUE;
+ g_win32_stack_initialized = false;
+ }
+}
+
+int git_win32_leakcheck_stack_capture(git_win32_leakcheck_stack_raw_data *pdata, int skip)
+{
+ if (!g_win32_stack_initialized) {
+ git_error_set(GIT_ERROR_INVALID, "git_win32_stack not initialized.");
+ return GIT_ERROR;
+ }
+
+ memset(pdata, 0, sizeof(*pdata));
+ pdata->nr_frames = RtlCaptureStackBackTrace(
+ skip+1, GIT_WIN32_LEAKCHECK_STACK_MAX_FRAMES, pdata->frames, NULL);
+
+ /* If an "aux" data provider was registered, ask it to capture
+ * whatever data it needs and give us an "aux_id" to it so that
+ * we can refer to it later when reporting.
+ */
+ if (g_aux_cb_alloc)
+ (g_aux_cb_alloc)(&pdata->aux_id);
+
+ return 0;
+}
+
+int git_win32_leakcheck_stack_compare(
+ git_win32_leakcheck_stack_raw_data *d1,
+ git_win32_leakcheck_stack_raw_data *d2)
+{
+ return memcmp(d1, d2, sizeof(*d1));
+}
+
+int git_win32_leakcheck_stack_format(
+ char *pbuf, size_t buf_len,
+ const git_win32_leakcheck_stack_raw_data *pdata,
+ const char *prefix, const char *suffix)
+{
+#define MY_MAX_FILENAME 255
+
+ /* SYMBOL_INFO has char FileName[1] at the end. The docs say to
+ * to malloc it with extra space for your desired max filename.
+ */
+ struct {
+ SYMBOL_INFO symbol;
+ char extra[MY_MAX_FILENAME + 1];
+ } s;
+
+ IMAGEHLP_LINE64 line;
+ size_t buf_used = 0;
+ unsigned int k;
+ char detail[MY_MAX_FILENAME * 2]; /* filename plus space for function name and formatting */
+ size_t detail_len;
+
+ if (!g_win32_stack_initialized) {
+ git_error_set(GIT_ERROR_INVALID, "git_win32_stack not initialized.");
+ return GIT_ERROR;
+ }
+
+ if (!prefix)
+ prefix = "\t";
+ if (!suffix)
+ suffix = "\n";
+
+ memset(pbuf, 0, buf_len);
+
+ memset(&s, 0, sizeof(s));
+ s.symbol.MaxNameLen = MY_MAX_FILENAME;
+ s.symbol.SizeOfStruct = sizeof(SYMBOL_INFO);
+
+ memset(&line, 0, sizeof(line));
+ line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
+
+ for (k=0; k < pdata->nr_frames; k++) {
+ DWORD64 frame_k = (DWORD64)pdata->frames[k];
+ DWORD dwUnused;
+
+ if (SymFromAddr(g_win32_stack_process, frame_k, 0, &s.symbol) &&
+ SymGetLineFromAddr64(g_win32_stack_process, frame_k, &dwUnused, &line)) {
+ const char *pslash;
+ const char *pfile;
+
+ pslash = strrchr(line.FileName, '\\');
+ pfile = ((pslash) ? (pslash+1) : line.FileName);
+ p_snprintf(detail, sizeof(detail), "%s%s:%d> %s%s",
+ prefix, pfile, line.LineNumber, s.symbol.Name, suffix);
+ } else {
+ /* This happens when we cross into another module.
+ * For example, in CLAR tests, this is typically
+ * the CRT startup code. Just print an unknown
+ * frame and continue.
+ */
+ p_snprintf(detail, sizeof(detail), "%s??%s", prefix, suffix);
+ }
+ detail_len = strlen(detail);
+
+ if (buf_len < (buf_used + detail_len + 1)) {
+ /* we don't have room for this frame in the buffer, so just stop. */
+ break;
+ }
+
+ memcpy(&pbuf[buf_used], detail, detail_len);
+ buf_used += detail_len;
+ }
+
+ /* "aux_id" 0 is reserved to mean no aux data. This is needed to handle
+ * allocs that occur before the aux callbacks were registered.
+ */
+ if (pdata->aux_id > 0) {
+ p_snprintf(detail, sizeof(detail), "%saux_id: %d%s",
+ prefix, pdata->aux_id, suffix);
+ detail_len = strlen(detail);
+ if ((buf_used + detail_len + 1) < buf_len) {
+ memcpy(&pbuf[buf_used], detail, detail_len);
+ buf_used += detail_len;
+ }
+
+ /* If an "aux" data provider is still registered, ask it to append its detailed
+ * data to the end of ours using the "aux_id" it gave us when this de-duped
+ * item was created.
+ */
+ if (g_aux_cb_lookup)
+ (g_aux_cb_lookup)(pdata->aux_id, &pbuf[buf_used], (buf_len - buf_used - 1));
+ }
+
+ return GIT_OK;
+}
+
+int git_win32_leakcheck_stack(
+ char * pbuf, size_t buf_len,
+ int skip,
+ const char *prefix, const char *suffix)
+{
+ git_win32_leakcheck_stack_raw_data data;
+ int error;
+
+ if ((error = git_win32_leakcheck_stack_capture(&data, skip)) < 0)
+ return error;
+ if ((error = git_win32_leakcheck_stack_format(pbuf, buf_len, &data, prefix, suffix)) < 0)
+ return error;
+ return 0;
+}
+
+/* Strack tracing */
+
+#define STACKTRACE_UID_LEN (15)
+
+/**
+ * The stacktrace of an allocation can be distilled
+ * to a unique id based upon the stackframe pointers
+ * and ignoring any size arguments. We will use these
+ * UIDs as the (char const*) __FILE__ argument we
+ * give to the CRT malloc routines.
+ */
+typedef struct {
+ char uid[STACKTRACE_UID_LEN + 1];
+} git_win32_leakcheck_stacktrace_uid;
+
+/**
+ * All mallocs with the same stacktrace will be de-duped
+ * and aggregated into this row.
+ */
+typedef struct {
+ git_win32_leakcheck_stacktrace_uid uid; /* must be first */
+ git_win32_leakcheck_stack_raw_data raw_data;
+ unsigned int count_allocs; /* times this alloc signature seen since init */
+ unsigned int count_allocs_at_last_checkpoint; /* times since last mark */
+ unsigned int transient_count_leaks; /* sum of leaks */
+} git_win32_leakcheck_stacktrace_row;
+
+static CRITICAL_SECTION g_crtdbg_stacktrace_cs;
+
+/**
+ * CRTDBG memory leak tracking takes a "char const * const file_name"
+ * and stores the pointer in the heap data (instead of allocing a copy
+ * for itself). Normally, this is not a problem, since we usually pass
+ * in __FILE__. But I'm going to lie to it and pass in the address of
+ * the UID in place of the file_name. Also, I do not want to alloc the
+ * stacktrace data (because we are called from inside our alloc routines).
+ * Therefore, I'm creating a very large static pool array to store row
+ * data. This also eliminates the temptation to realloc it (and move the
+ * UID pointers).
+ *
+ * And to efficiently look for duplicates we need an index on the rows
+ * so we can bsearch it. Again, without mallocing.
+ *
+ * If we observe more than MY_ROW_LIMIT unique malloc signatures, we
+ * fall through and use the traditional __FILE__ processing and don't
+ * try to de-dup them. If your testing hits this limit, just increase
+ * it and try again.
+ */
+
+#define MY_ROW_LIMIT (2 * 1024 * 1024)
+static git_win32_leakcheck_stacktrace_row g_cs_rows[MY_ROW_LIMIT];
+static git_win32_leakcheck_stacktrace_row *g_cs_index[MY_ROW_LIMIT];
+
+static unsigned int g_cs_end = MY_ROW_LIMIT;
+static unsigned int g_cs_ins = 0; /* insertion point == unique allocs seen */
+static unsigned int g_count_total_allocs = 0; /* number of allocs seen */
+static unsigned int g_transient_count_total_leaks = 0; /* number of total leaks */
+static unsigned int g_transient_count_dedup_leaks = 0; /* number of unique leaks */
+static bool g_limit_reached = false; /* had allocs after we filled row table */
+
+static unsigned int g_checkpoint_id = 0; /* to better label leak checkpoints */
+static bool g_transient_leaks_since_mark = false; /* payload for hook */
+
+/**
+ * Compare function for bsearch on g_cs_index table.
+ */
+static int row_cmp(const void *v1, const void *v2)
+{
+ git_win32_leakcheck_stack_raw_data *d1 = (git_win32_leakcheck_stack_raw_data*)v1;
+ git_win32_leakcheck_stacktrace_row *r2 = (git_win32_leakcheck_stacktrace_row *)v2;
+
+ return (git_win32_leakcheck_stack_compare(d1, &r2->raw_data));
+}
+
+/**
+ * Unique insert the new data into the row and index tables.
+ * We have to sort by the stackframe data itself, not the uid.
+ */
+static git_win32_leakcheck_stacktrace_row * insert_unique(
+ const git_win32_leakcheck_stack_raw_data *pdata)
+{
+ size_t pos;
+ if (git__bsearch(g_cs_index, g_cs_ins, pdata, row_cmp, &pos) < 0) {
+ /* Append new unique item to row table. */
+ memcpy(&g_cs_rows[g_cs_ins].raw_data, pdata, sizeof(*pdata));
+ sprintf(g_cs_rows[g_cs_ins].uid.uid, "##%08lx", g_cs_ins);
+
+ /* Insert pointer to it into the proper place in the index table. */
+ if (pos < g_cs_ins)
+ memmove(&g_cs_index[pos+1], &g_cs_index[pos], (g_cs_ins - pos)*sizeof(g_cs_index[0]));
+ g_cs_index[pos] = &g_cs_rows[g_cs_ins];
+
+ g_cs_ins++;
+ }
+
+ g_cs_index[pos]->count_allocs++;
+
+ return g_cs_index[pos];
+}
+
+/**
+ * Hook function to receive leak data from the CRT. (This includes
+ * both "<file_name>:(<line_number>)" data, but also each of the
+ * various headers and fields.
+ *
+ * Scan this for the special "##<pos>" UID forms that we substituted
+ * for the "<file_name>". Map <pos> back to the row data and
+ * increment its leak count.
+ *
+ * See https://msdn.microsoft.com/en-us/library/74kabxyx.aspx
+ *
+ * We suppress the actual crtdbg output.
+ */
+static int __cdecl report_hook(int nRptType, char *szMsg, int *retVal)
+{
+ static int hook_result = TRUE; /* FALSE to get stock dump; TRUE to suppress. */
+ unsigned int pos;
+
+ *retVal = 0; /* do not invoke debugger */
+
+ if ((szMsg[0] != '#') || (szMsg[1] != '#'))
+ return hook_result;
+
+ if (sscanf(&szMsg[2], "%08lx", &pos) < 1)
+ return hook_result;
+ if (pos >= g_cs_ins)
+ return hook_result;
+
+ if (g_transient_leaks_since_mark) {
+ if (g_cs_rows[pos].count_allocs == g_cs_rows[pos].count_allocs_at_last_checkpoint)
+ return hook_result;
+ }
+
+ g_cs_rows[pos].transient_count_leaks++;
+
+ if (g_cs_rows[pos].transient_count_leaks == 1)
+ g_transient_count_dedup_leaks++;
+
+ g_transient_count_total_leaks++;
+
+ return hook_result;
+}
+
+/**
+ * Write leak data to all of the various places we need.
+ * We force the caller to sprintf() the message first
+ * because we want to avoid fprintf() because it allocs.
+ */
+static void my_output(const char *buf)
+{
+ fwrite(buf, strlen(buf), 1, stderr);
+ OutputDebugString(buf);
+}
+
+/**
+ * For each row with leaks, dump a stacktrace for it.
+ */
+static void dump_summary(const char *label)
+{
+ unsigned int k;
+ char buf[10 * 1024];
+
+ if (g_transient_count_total_leaks == 0)
+ return;
+
+ fflush(stdout);
+ fflush(stderr);
+ my_output("\n");
+
+ if (g_limit_reached) {
+ sprintf(buf,
+ "LEAK SUMMARY: de-dup row table[%d] filled. Increase MY_ROW_LIMIT.\n",
+ MY_ROW_LIMIT);
+ my_output(buf);
+ }
+
+ if (!label)
+ label = "";
+
+ if (g_transient_leaks_since_mark) {
+ sprintf(buf, "LEAK CHECKPOINT %d: leaks %d unique %d: %s\n",
+ g_checkpoint_id, g_transient_count_total_leaks, g_transient_count_dedup_leaks, label);
+ my_output(buf);
+ } else {
+ sprintf(buf, "LEAK SUMMARY: TOTAL leaks %d de-duped %d: %s\n",
+ g_transient_count_total_leaks, g_transient_count_dedup_leaks, label);
+ my_output(buf);
+ }
+ my_output("\n");
+
+ for (k = 0; k < g_cs_ins; k++) {
+ if (g_cs_rows[k].transient_count_leaks > 0) {
+ sprintf(buf, "LEAK: %s leaked %d of %d times:\n",
+ g_cs_rows[k].uid.uid,
+ g_cs_rows[k].transient_count_leaks,
+ g_cs_rows[k].count_allocs);
+ my_output(buf);
+
+ if (git_win32_leakcheck_stack_format(
+ buf, sizeof(buf), &g_cs_rows[k].raw_data,
+ NULL, NULL) >= 0) {
+ my_output(buf);
+ }
+
+ my_output("\n");
+ }
+ }
+
+ fflush(stderr);
+}
+
+/**
+ * Initialize our memory leak tracking and de-dup data structures.
+ * This should ONLY be called by git_libgit2_init().
+ */
+void git_win32_leakcheck_stacktrace_init(void)
+{
+ InitializeCriticalSection(&g_crtdbg_stacktrace_cs);
+
+ EnterCriticalSection(&g_crtdbg_stacktrace_cs);
+
+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+
+ LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
+}
+
+int git_win32_leakcheck_stacktrace_dump(
+ git_win32_leakcheck_stacktrace_options opt,
+ const char *label)
+{
+ _CRT_REPORT_HOOK old;
+ unsigned int k;
+ int r = 0;
+
+#define IS_BIT_SET(o,b) (((o) & (b)) != 0)
+
+ bool b_set_mark = IS_BIT_SET(opt, GIT_WIN32_LEAKCHECK_STACKTRACE_SET_MARK);
+ bool b_leaks_since_mark = IS_BIT_SET(opt, GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK);
+ bool b_leaks_total = IS_BIT_SET(opt, GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_TOTAL);
+ bool b_quiet = IS_BIT_SET(opt, GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET);
+
+ if (b_leaks_since_mark && b_leaks_total) {
+ git_error_set(GIT_ERROR_INVALID, "cannot combine LEAKS_SINCE_MARK and LEAKS_TOTAL.");
+ return GIT_ERROR;
+ }
+ if (!b_set_mark && !b_leaks_since_mark && !b_leaks_total) {
+ git_error_set(GIT_ERROR_INVALID, "nothing to do.");
+ return GIT_ERROR;
+ }
+
+ EnterCriticalSection(&g_crtdbg_stacktrace_cs);
+
+ if (b_leaks_since_mark || b_leaks_total) {
+ /* All variables with "transient" in the name are per-dump counters
+ * and reset before each dump. This lets us handle checkpoints.
+ */
+ g_transient_count_total_leaks = 0;
+ g_transient_count_dedup_leaks = 0;
+ for (k = 0; k < g_cs_ins; k++) {
+ g_cs_rows[k].transient_count_leaks = 0;
+ }
+ }
+
+ g_transient_leaks_since_mark = b_leaks_since_mark;
+
+ old = _CrtSetReportHook(report_hook);
+ _CrtDumpMemoryLeaks();
+ _CrtSetReportHook(old);
+
+ if (b_leaks_since_mark || b_leaks_total) {
+ r = g_transient_count_dedup_leaks;
+
+ if (!b_quiet)
+ dump_summary(label);
+ }
+
+ if (b_set_mark) {
+ for (k = 0; k < g_cs_ins; k++) {
+ g_cs_rows[k].count_allocs_at_last_checkpoint = g_cs_rows[k].count_allocs;
+ }
+
+ g_checkpoint_id++;
+ }
+
+ LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
+
+ return r;
+}
+
+/**
+ * Shutdown our memory leak tracking and dump summary data.
+ * This should ONLY be called by git_libgit2_shutdown().
+ *
+ * We explicitly call _CrtDumpMemoryLeaks() during here so
+ * that we can compute summary data for the leaks. We print
+ * the stacktrace of each unique leak.
+ *
+ * This cleanup does not happen if the app calls exit()
+ * without calling the libgit2 shutdown code.
+ *
+ * This info we print here is independent of any automatic
+ * reporting during exit() caused by _CRTDBG_LEAK_CHECK_DF.
+ * Set it in your app if you also want traditional reporting.
+ */
+void git_win32_leakcheck_stacktrace_cleanup(void)
+{
+ /* At shutdown/cleanup, dump cumulative leak info
+ * with everything since startup. This might generate
+ * extra noise if the caller has been doing checkpoint
+ * dumps, but it might also eliminate some false
+ * positives for resources previously reported during
+ * checkpoints.
+ */
+ git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_TOTAL,
+ "CLEANUP");
+
+ DeleteCriticalSection(&g_crtdbg_stacktrace_cs);
+}
+
+const char *git_win32_leakcheck_stacktrace(int skip, const char *file)
+{
+ git_win32_leakcheck_stack_raw_data new_data;
+ git_win32_leakcheck_stacktrace_row *row;
+ const char * result = file;
+
+ if (git_win32_leakcheck_stack_capture(&new_data, skip+1) < 0)
+ return result;
+
+ EnterCriticalSection(&g_crtdbg_stacktrace_cs);
+
+ if (g_cs_ins < g_cs_end) {
+ row = insert_unique(&new_data);
+ result = row->uid.uid;
+ } else {
+ g_limit_reached = true;
+ }
+
+ g_count_total_allocs++;
+
+ LeaveCriticalSection(&g_crtdbg_stacktrace_cs);
+
+ return result;
+}
+
+static void git_win32_leakcheck_global_shutdown(void)
+{
+ git_win32_leakcheck_stacktrace_cleanup();
+ git_win32_leakcheck_stack_cleanup();
+}
+
+bool git_win32_leakcheck_has_leaks(void)
+{
+ return (g_transient_count_total_leaks > 0);
+}
+
+int git_win32_leakcheck_global_init(void)
+{
+ git_win32_leakcheck_stacktrace_init();
+ git_win32_leakcheck_stack_init();
+
+ return git_runtime_shutdown_register(git_win32_leakcheck_global_shutdown);
+}
+
+#else
+
+int git_win32_leakcheck_global_init(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/src/win32/w32_leakcheck.h b/src/win32/w32_leakcheck.h
new file mode 100644
index 0000000..cb45e36
--- /dev/null
+++ b/src/win32/w32_leakcheck.h
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_win32_leakcheck_h__
+#define INCLUDE_win32_leakcheck_h__
+
+#include "common.h"
+
+/* Initialize the win32 leak checking system. */
+int git_win32_leakcheck_global_init(void);
+
+#if defined(GIT_WIN32_LEAKCHECK)
+
+#include <stdlib.h>
+#include <crtdbg.h>
+
+#include "git2/errors.h"
+#include "strnlen.h"
+
+bool git_win32_leakcheck_has_leaks(void);
+
+/* Stack frames (for stack tracing, below) */
+
+/**
+ * This type defines a callback to be used to augment a C stacktrace
+ * with "aux" data. This can be used, for example, to allow LibGit2Sharp
+ * (or other interpreted consumer libraries) to give us C# stacktrace
+ * data for the PInvoke.
+ *
+ * This callback will be called during crtdbg-instrumented allocs.
+ *
+ * @param aux_id [out] A returned "aux_id" representing a unique
+ * (de-duped at the C# layer) stacktrace. "aux_id" 0 is reserved
+ * to mean no aux stacktrace data.
+ */
+typedef void (*git_win32_leakcheck_stack_aux_cb_alloc)(unsigned int *aux_id);
+
+/**
+ * This type defines a callback to be used to augment the output of
+ * a stacktrace. This will be used to request the C# layer format
+ * the C# stacktrace associated with "aux_id" into the provided
+ * buffer.
+ *
+ * This callback will be called during leak reporting.
+ *
+ * @param aux_id The "aux_id" key associated with a stacktrace.
+ * @param aux_msg A buffer where a formatted message should be written.
+ * @param aux_msg_len The size of the buffer.
+ */
+typedef void (*git_win32_leakcheck_stack_aux_cb_lookup)(unsigned int aux_id, char *aux_msg, size_t aux_msg_len);
+
+/**
+ * Register an "aux" data provider to augment our C stacktrace data.
+ *
+ * This can be used, for example, to allow LibGit2Sharp (or other
+ * interpreted consumer libraries) to give us the C# stacktrace of
+ * the PInvoke.
+ *
+ * If you choose to use this feature, it should be registered during
+ * initialization and not changed for the duration of the process.
+ */
+int git_win32_leakcheck_stack_set_aux_cb(
+ git_win32_leakcheck_stack_aux_cb_alloc cb_alloc,
+ git_win32_leakcheck_stack_aux_cb_lookup cb_lookup);
+
+/**
+ * Maximum number of stackframes to record for a
+ * single stacktrace.
+ */
+#define GIT_WIN32_LEAKCHECK_STACK_MAX_FRAMES 30
+
+/**
+ * Wrapper containing the raw unprocessed stackframe
+ * data for a single stacktrace and any "aux_id".
+ *
+ * I put the aux_id first so leaks will be sorted by it.
+ * So, for example, if a specific callstack in C# leaks
+ * a repo handle, all of the pointers within the associated
+ * repo pointer will be grouped together.
+ */
+typedef struct {
+ unsigned int aux_id;
+ unsigned int nr_frames;
+ void *frames[GIT_WIN32_LEAKCHECK_STACK_MAX_FRAMES];
+} git_win32_leakcheck_stack_raw_data;
+
+/**
+ * Capture raw stack trace data for the current process/thread.
+ *
+ * @param skip Number of initial frames to skip. Pass 0 to
+ * begin with the caller of this routine. Pass 1 to begin
+ * with its caller. And so on.
+ */
+int git_win32_leakcheck_stack_capture(git_win32_leakcheck_stack_raw_data *pdata, int skip);
+
+/**
+ * Compare 2 raw stacktraces with the usual -1,0,+1 result.
+ * This includes any "aux_id" values in the comparison, so that
+ * our de-dup is also "aux" context relative.
+ */
+int git_win32_leakcheck_stack_compare(
+ git_win32_leakcheck_stack_raw_data *d1,
+ git_win32_leakcheck_stack_raw_data *d2);
+
+/**
+ * Format raw stacktrace data into buffer WITHOUT using any mallocs.
+ *
+ * @param prefix String written before each frame; defaults to "\t".
+ * @param suffix String written after each frame; defaults to "\n".
+ */
+int git_win32_leakcheck_stack_format(
+ char *pbuf, size_t buf_len,
+ const git_win32_leakcheck_stack_raw_data *pdata,
+ const char *prefix, const char *suffix);
+
+/**
+ * Convenience routine to capture and format stacktrace into
+ * a buffer WITHOUT using any mallocs. This is primarily a
+ * wrapper for testing.
+ *
+ * @param skip Number of initial frames to skip. Pass 0 to
+ * begin with the caller of this routine. Pass 1 to begin
+ * with its caller. And so on.
+ * @param prefix String written before each frame; defaults to "\t".
+ * @param suffix String written after each frame; defaults to "\n".
+ */
+int git_win32_leakcheck_stack(
+ char * pbuf, size_t buf_len,
+ int skip,
+ const char *prefix, const char *suffix);
+
+/* Stack tracing */
+
+/* MSVC CRTDBG memory leak reporting.
+ *
+ * We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC
+ * documentation because all allocs/frees in libgit2 already go through
+ * the "git__" routines defined in this file. Simply using the normal
+ * reporting mechanism causes all leaks to be attributed to a routine
+ * here in util.h (ie, the actual call to calloc()) rather than the
+ * caller of git__calloc().
+ *
+ * Therefore, we declare a set of "git__crtdbg__" routines to replace
+ * the corresponding "git__" routines and re-define the "git__" symbols
+ * as macros. This allows us to get and report the file:line info of
+ * the real caller.
+ *
+ * We DO NOT replace the "git__free" routine because it needs to remain
+ * a function pointer because it is used as a function argument when
+ * setting up various structure "destructors".
+ *
+ * We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes
+ * "free" to be remapped to "_free_dbg" and this causes problems for
+ * structures which define a field named "free".
+ *
+ * Finally, CRTDBG must be explicitly enabled and configured at program
+ * startup. See tests/main.c for an example.
+ */
+
+/**
+ * Checkpoint options.
+ */
+typedef enum git_win32_leakcheck_stacktrace_options {
+ /**
+ * Set checkpoint marker.
+ */
+ GIT_WIN32_LEAKCHECK_STACKTRACE_SET_MARK = (1 << 0),
+
+ /**
+ * Dump leaks since last checkpoint marker.
+ * May not be combined with _LEAKS_TOTAL.
+ *
+ * Note that this may generate false positives for global TLS
+ * error state and other global caches that aren't cleaned up
+ * until the thread/process terminates. So when using this
+ * around a region of interest, also check the final (at exit)
+ * dump before digging into leaks reported here.
+ */
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK = (1 << 1),
+
+ /**
+ * Dump leaks since init. May not be combined
+ * with _LEAKS_SINCE_MARK.
+ */
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_TOTAL = (1 << 2),
+
+ /**
+ * Suppress printing during dumps.
+ * Just return leak count.
+ */
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET = (1 << 3),
+
+} git_win32_leakcheck_stacktrace_options;
+
+/**
+ * Checkpoint memory state and/or dump unique stack traces of
+ * current memory leaks.
+ *
+ * @return number of unique leaks (relative to requested starting
+ * point) or error.
+ */
+int git_win32_leakcheck_stacktrace_dump(
+ git_win32_leakcheck_stacktrace_options opt,
+ const char *label);
+
+/**
+ * Construct stacktrace and append it to the global buffer.
+ * Return pointer to start of this string. On any error or
+ * lack of buffer space, just return the given file buffer
+ * so it will behave as usual.
+ *
+ * This should ONLY be called by our internal memory allocations
+ * routines.
+ */
+const char *git_win32_leakcheck_stacktrace(int skip, const char *file);
+
+#endif
+#endif
diff --git a/src/win32/w32_stack.c b/src/win32/w32_stack.c
deleted file mode 100644
index 78c78db..0000000
--- a/src/win32/w32_stack.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#include "w32_stack.h"
-
-#if defined(GIT_MSVC_CRTDBG)
-#include "Windows.h"
-#include "Dbghelp.h"
-#include "win32/posix.h"
-#include "hash.h"
-
-static bool g_win32_stack_initialized = false;
-static HANDLE g_win32_stack_process = INVALID_HANDLE_VALUE;
-static git_win32__stack__aux_cb_alloc g_aux_cb_alloc = NULL;
-static git_win32__stack__aux_cb_lookup g_aux_cb_lookup = NULL;
-
-int git_win32__stack__set_aux_cb(
- git_win32__stack__aux_cb_alloc cb_alloc,
- git_win32__stack__aux_cb_lookup cb_lookup)
-{
- g_aux_cb_alloc = cb_alloc;
- g_aux_cb_lookup = cb_lookup;
-
- return 0;
-}
-
-void git_win32__stack_init(void)
-{
- if (!g_win32_stack_initialized) {
- g_win32_stack_process = GetCurrentProcess();
- SymSetOptions(SYMOPT_LOAD_LINES);
- SymInitialize(g_win32_stack_process, NULL, TRUE);
- g_win32_stack_initialized = true;
- }
-}
-
-void git_win32__stack_cleanup(void)
-{
- if (g_win32_stack_initialized) {
- SymCleanup(g_win32_stack_process);
- g_win32_stack_process = INVALID_HANDLE_VALUE;
- g_win32_stack_initialized = false;
- }
-}
-
-int git_win32__stack_capture(git_win32__stack__raw_data *pdata, int skip)
-{
- if (!g_win32_stack_initialized) {
- git_error_set(GIT_ERROR_INVALID, "git_win32_stack not initialized.");
- return GIT_ERROR;
- }
-
- memset(pdata, 0, sizeof(*pdata));
- pdata->nr_frames = RtlCaptureStackBackTrace(
- skip+1, GIT_WIN32__STACK__MAX_FRAMES, pdata->frames, NULL);
-
- /* If an "aux" data provider was registered, ask it to capture
- * whatever data it needs and give us an "aux_id" to it so that
- * we can refer to it later when reporting.
- */
- if (g_aux_cb_alloc)
- (g_aux_cb_alloc)(&pdata->aux_id);
-
- return 0;
-}
-
-int git_win32__stack_compare(
- git_win32__stack__raw_data *d1,
- git_win32__stack__raw_data *d2)
-{
- return memcmp(d1, d2, sizeof(*d1));
-}
-
-int git_win32__stack_format(
- char *pbuf, size_t buf_len,
- const git_win32__stack__raw_data *pdata,
- const char *prefix, const char *suffix)
-{
-#define MY_MAX_FILENAME 255
-
- /* SYMBOL_INFO has char FileName[1] at the end. The docs say to
- * to malloc it with extra space for your desired max filename.
- */
- struct {
- SYMBOL_INFO symbol;
- char extra[MY_MAX_FILENAME + 1];
- } s;
-
- IMAGEHLP_LINE64 line;
- size_t buf_used = 0;
- unsigned int k;
- char detail[MY_MAX_FILENAME * 2]; /* filename plus space for function name and formatting */
- size_t detail_len;
-
- if (!g_win32_stack_initialized) {
- git_error_set(GIT_ERROR_INVALID, "git_win32_stack not initialized.");
- return GIT_ERROR;
- }
-
- if (!prefix)
- prefix = "\t";
- if (!suffix)
- suffix = "\n";
-
- memset(pbuf, 0, buf_len);
-
- memset(&s, 0, sizeof(s));
- s.symbol.MaxNameLen = MY_MAX_FILENAME;
- s.symbol.SizeOfStruct = sizeof(SYMBOL_INFO);
-
- memset(&line, 0, sizeof(line));
- line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
-
- for (k=0; k < pdata->nr_frames; k++) {
- DWORD64 frame_k = (DWORD64)pdata->frames[k];
- DWORD dwUnused;
-
- if (SymFromAddr(g_win32_stack_process, frame_k, 0, &s.symbol) &&
- SymGetLineFromAddr64(g_win32_stack_process, frame_k, &dwUnused, &line)) {
- const char *pslash;
- const char *pfile;
-
- pslash = strrchr(line.FileName, '\\');
- pfile = ((pslash) ? (pslash+1) : line.FileName);
- p_snprintf(detail, sizeof(detail), "%s%s:%d> %s%s",
- prefix, pfile, line.LineNumber, s.symbol.Name, suffix);
- } else {
- /* This happens when we cross into another module.
- * For example, in CLAR tests, this is typically
- * the CRT startup code. Just print an unknown
- * frame and continue.
- */
- p_snprintf(detail, sizeof(detail), "%s??%s", prefix, suffix);
- }
- detail_len = strlen(detail);
-
- if (buf_len < (buf_used + detail_len + 1)) {
- /* we don't have room for this frame in the buffer, so just stop. */
- break;
- }
-
- memcpy(&pbuf[buf_used], detail, detail_len);
- buf_used += detail_len;
- }
-
- /* "aux_id" 0 is reserved to mean no aux data. This is needed to handle
- * allocs that occur before the aux callbacks were registered.
- */
- if (pdata->aux_id > 0) {
- p_snprintf(detail, sizeof(detail), "%saux_id: %d%s",
- prefix, pdata->aux_id, suffix);
- detail_len = strlen(detail);
- if ((buf_used + detail_len + 1) < buf_len) {
- memcpy(&pbuf[buf_used], detail, detail_len);
- buf_used += detail_len;
- }
-
- /* If an "aux" data provider is still registered, ask it to append its detailed
- * data to the end of ours using the "aux_id" it gave us when this de-duped
- * item was created.
- */
- if (g_aux_cb_lookup)
- (g_aux_cb_lookup)(pdata->aux_id, &pbuf[buf_used], (buf_len - buf_used - 1));
- }
-
- return GIT_OK;
-}
-
-int git_win32__stack(
- char * pbuf, size_t buf_len,
- int skip,
- const char *prefix, const char *suffix)
-{
- git_win32__stack__raw_data data;
- int error;
-
- if ((error = git_win32__stack_capture(&data, skip)) < 0)
- return error;
- if ((error = git_win32__stack_format(pbuf, buf_len, &data, prefix, suffix)) < 0)
- return error;
- return 0;
-}
-
-#endif
diff --git a/src/win32/w32_stack.h b/src/win32/w32_stack.h
deleted file mode 100644
index c2565c2..0000000
--- a/src/win32/w32_stack.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-
-#ifndef INCLUDE_win32_w32_stack_h__
-#define INCLUDE_win32_w32_stack_h__
-
-#include "common.h"
-
-#if defined(GIT_MSVC_CRTDBG)
-
-/**
- * This type defines a callback to be used to augment a C stacktrace
- * with "aux" data. This can be used, for example, to allow LibGit2Sharp
- * (or other interpreted consumer libraries) to give us C# stacktrace
- * data for the PInvoke.
- *
- * This callback will be called during crtdbg-instrumented allocs.
- *
- * @param aux_id [out] A returned "aux_id" representing a unique
- * (de-duped at the C# layer) stacktrace. "aux_id" 0 is reserved
- * to mean no aux stacktrace data.
- */
-typedef void (*git_win32__stack__aux_cb_alloc)(unsigned int *aux_id);
-
-/**
- * This type defines a callback to be used to augment the output of
- * a stacktrace. This will be used to request the C# layer format
- * the C# stacktrace associated with "aux_id" into the provided
- * buffer.
- *
- * This callback will be called during leak reporting.
- *
- * @param aux_id The "aux_id" key associated with a stacktrace.
- * @param aux_msg A buffer where a formatted message should be written.
- * @param aux_msg_len The size of the buffer.
- */
-typedef void (*git_win32__stack__aux_cb_lookup)(unsigned int aux_id, char *aux_msg, size_t aux_msg_len);
-
-/**
- * Register an "aux" data provider to augment our C stacktrace data.
- *
- * This can be used, for example, to allow LibGit2Sharp (or other
- * interpreted consumer libraries) to give us the C# stacktrace of
- * the PInvoke.
- *
- * If you choose to use this feature, it should be registered during
- * initialization and not changed for the duration of the process.
- */
-GIT_EXTERN(int) git_win32__stack__set_aux_cb(
- git_win32__stack__aux_cb_alloc cb_alloc,
- git_win32__stack__aux_cb_lookup cb_lookup);
-
-/**
- * Maximum number of stackframes to record for a
- * single stacktrace.
- */
-#define GIT_WIN32__STACK__MAX_FRAMES 30
-
-/**
- * Wrapper containing the raw unprocessed stackframe
- * data for a single stacktrace and any "aux_id".
- *
- * I put the aux_id first so leaks will be sorted by it.
- * So, for example, if a specific callstack in C# leaks
- * a repo handle, all of the pointers within the associated
- * repo pointer will be grouped together.
- */
-typedef struct {
- unsigned int aux_id;
- unsigned int nr_frames;
- void *frames[GIT_WIN32__STACK__MAX_FRAMES];
-} git_win32__stack__raw_data;
-
-
-/**
- * Load symbol table data. This should be done in the primary
- * thread at startup (under a lock if there are other threads
- * active).
- */
-void git_win32__stack_init(void);
-
-/**
- * Cleanup symbol table data. This should be done in the
- * primary thead at shutdown (under a lock if there are other
- * threads active).
- */
-void git_win32__stack_cleanup(void);
-
-
-/**
- * Capture raw stack trace data for the current process/thread.
- *
- * @param skip Number of initial frames to skip. Pass 0 to
- * begin with the caller of this routine. Pass 1 to begin
- * with its caller. And so on.
- */
-int git_win32__stack_capture(git_win32__stack__raw_data *pdata, int skip);
-
-/**
- * Compare 2 raw stacktraces with the usual -1,0,+1 result.
- * This includes any "aux_id" values in the comparison, so that
- * our de-dup is also "aux" context relative.
- */
-int git_win32__stack_compare(
- git_win32__stack__raw_data *d1,
- git_win32__stack__raw_data *d2);
-
-/**
- * Format raw stacktrace data into buffer WITHOUT using any mallocs.
- *
- * @param prefix String written before each frame; defaults to "\t".
- * @param suffix String written after each frame; defaults to "\n".
- */
-int git_win32__stack_format(
- char *pbuf, size_t buf_len,
- const git_win32__stack__raw_data *pdata,
- const char *prefix, const char *suffix);
-
-/**
- * Convenience routine to capture and format stacktrace into
- * a buffer WITHOUT using any mallocs. This is primarily a
- * wrapper for testing.
- *
- * @param skip Number of initial frames to skip. Pass 0 to
- * begin with the caller of this routine. Pass 1 to begin
- * with its caller. And so on.
- * @param prefix String written before each frame; defaults to "\t".
- * @param suffix String written after each frame; defaults to "\n".
- */
-int git_win32__stack(
- char * pbuf, size_t buf_len,
- int skip,
- const char *prefix, const char *suffix);
-
-#endif /* GIT_MSVC_CRTDBG */
-#endif
diff --git a/src/win32/w32_util.h b/src/win32/w32_util.h
index d7f9d3d..1321d30 100644
--- a/src/win32/w32_util.h
+++ b/src/win32/w32_util.h
@@ -74,8 +74,8 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
const FILETIME *ft,
struct timespec *ts)
{
- long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
- winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
+ int64_t winTime = ((int64_t)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
+ winTime -= INT64_C(116444736000000000); /* Windows to Unix Epoch conversion */
ts->tv_sec = (time_t)(winTime / 10000000);
#ifdef GIT_USE_NSEC
ts->tv_nsec = (winTime % 10000000) * 100;
@@ -87,11 +87,11 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
GIT_INLINE(void) git_win32__timeval_to_filetime(
FILETIME *ft, const struct p_timeval tv)
{
- long long ticks = (tv.tv_sec * 10000000LL) +
- (tv.tv_usec * 10LL) + 116444736000000000LL;
+ int64_t ticks = (tv.tv_sec * INT64_C(10000000)) +
+ (tv.tv_usec * INT64_C(10)) + INT64_C(116444736000000000);
- ft->dwHighDateTime = ((ticks >> 32) & 0xffffffffLL);
- ft->dwLowDateTime = (ticks & 0xffffffffLL);
+ ft->dwHighDateTime = ((ticks >> 32) & INT64_C(0xffffffff));
+ ft->dwLowDateTime = (ticks & INT64_C(0xffffffff));
}
GIT_INLINE(void) git_win32__stat_init(
diff --git a/src/worktree.c b/src/worktree.c
index ef4ebfd..fe8db77 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -37,12 +37,13 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
size_t i, len;
int error;
- assert(wts && repo);
+ GIT_ASSERT_ARG(wts);
+ GIT_ASSERT_ARG(repo);
wts->count = 0;
wts->strings = NULL;
- if ((error = git_buf_printf(&path, "%s/worktrees/", repo->commondir)) < 0)
+ if ((error = git_buf_joinpath(&path, repo->commondir, "worktrees/")) < 0)
goto exit;
if (!git_path_exists(path.ptr) || git_path_is_empty_dir(path.ptr))
goto exit;
@@ -73,7 +74,8 @@ char *git_worktree__read_link(const char *base, const char *file)
{
git_buf path = GIT_BUF_INIT, buf = GIT_BUF_INIT;
- assert(base && file);
+ GIT_ASSERT_ARG_WITH_RETVAL(base, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(file, NULL);
if (git_buf_joinpath(&path, base, file) < 0)
goto err;
@@ -106,7 +108,9 @@ static int write_wtfile(const char *base, const char *file, const git_buf *buf)
git_buf path = GIT_BUF_INIT;
int err;
- assert(base && file && buf);
+ GIT_ASSERT_ARG(base);
+ GIT_ASSERT_ARG(file);
+ GIT_ASSERT_ARG(buf);
if ((err = git_buf_joinpath(&path, base, file)) < 0)
goto out;
@@ -131,16 +135,19 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
goto out;
}
+ if ((error = git_path_validate_workdir(NULL, dir)) < 0)
+ goto out;
+
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
error = -1;
goto out;
}
- if ((wt->name = git__strdup(name)) == NULL
- || (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL
- || (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL
- || (parent && (wt->parent_path = git__strdup(parent)) == NULL)
- || (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
+ if ((wt->name = git__strdup(name)) == NULL ||
+ (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL ||
+ (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL ||
+ (parent && (wt->parent_path = git__strdup(parent)) == NULL) ||
+ (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
error = -1;
goto out;
}
@@ -149,7 +156,10 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
goto out;
wt->gitdir_path = git_buf_detach(&gitdir);
- wt->locked = !!git_worktree_is_locked(NULL, wt);
+ if ((error = git_worktree_is_locked(NULL, wt)) < 0)
+ goto out;
+ wt->locked = !!error;
+ error = 0;
*out = wt;
@@ -167,11 +177,12 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na
git_worktree *wt = NULL;
int error;
- assert(repo && name);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
*out = NULL;
- if ((error = git_buf_printf(&path, "%s/worktrees/%s", repo->commondir, name)) < 0)
+ if ((error = git_buf_join3(&path, '/', repo->commondir, "worktrees", name)) < 0)
goto out;
if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0)
@@ -234,7 +245,7 @@ void git_worktree_free(git_worktree *wt)
int git_worktree_validate(const git_worktree *wt)
{
- assert(wt);
+ GIT_ASSERT_ARG(wt);
if (!is_worktree_dir(wt->gitdir_path)) {
git_error_set(GIT_ERROR_WORKTREE,
@@ -257,6 +268,13 @@ int git_worktree_validate(const git_worktree *wt)
return GIT_ERROR;
}
+ if (!git_path_exists(wt->worktree_path)) {
+ git_error_set(GIT_ERROR_WORKTREE,
+ "worktree directory '%s' does not exist",
+ wt->worktree_path);
+ return GIT_ERROR;
+ }
+
return 0;
}
@@ -268,11 +286,13 @@ int git_worktree_add_options_init(git_worktree_add_options *opts,
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_worktree_add_init_options(git_worktree_add_options *opts,
unsigned int version)
{
return git_worktree_add_options_init(opts, version);
}
+#endif
int git_worktree_add(git_worktree **out, git_repository *repo,
const char *name, const char *worktree,
@@ -292,7 +312,10 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
if (opts)
memcpy(&wtopts, opts, sizeof(wtopts));
- assert(out && repo && name && worktree);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(worktree);
*out = NULL;
@@ -403,20 +426,24 @@ out:
int git_worktree_lock(git_worktree *wt, const char *reason)
{
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
- int err;
+ int error;
- assert(wt);
+ GIT_ASSERT_ARG(wt);
- if ((err = git_worktree_is_locked(NULL, wt)) < 0)
+ if ((error = git_worktree_is_locked(NULL, wt)) < 0)
goto out;
+ if (error) {
+ error = GIT_ELOCKED;
+ goto out;
+ }
- if ((err = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
+ if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
goto out;
if (reason)
git_buf_attach_notowned(&buf, reason, strlen(reason));
- if ((err = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
+ if ((error = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
goto out;
wt->locked = 1;
@@ -424,16 +451,19 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
out:
git_buf_dispose(&path);
- return err;
+ return error;
}
int git_worktree_unlock(git_worktree *wt)
{
git_buf path = GIT_BUF_INIT;
+ int error;
- assert(wt);
+ GIT_ASSERT_ARG(wt);
- if (!git_worktree_is_locked(NULL, wt))
+ if ((error = git_worktree_is_locked(NULL, wt)) < 0)
+ return error;
+ if (!error)
return 1;
if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0)
@@ -454,33 +484,36 @@ int git_worktree_unlock(git_worktree *wt)
int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
{
git_buf path = GIT_BUF_INIT;
- int ret;
+ int error, locked;
- assert(wt);
+ GIT_ASSERT_ARG(wt);
if (reason)
git_buf_clear(reason);
- if ((ret = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
+ if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
+ goto out;
+ locked = git_path_exists(path.ptr);
+ if (locked && reason &&
+ (error = git_futils_readbuffer(reason, path.ptr)) < 0)
goto out;
- if ((ret = git_path_exists(path.ptr)) && reason)
- git_futils_readbuffer(reason, path.ptr);
+ error = locked;
out:
git_buf_dispose(&path);
- return ret;
+ return error;
}
const char *git_worktree_name(const git_worktree *wt)
{
- assert(wt);
+ GIT_ASSERT_ARG_WITH_RETVAL(wt, NULL);
return wt->name;
}
const char *git_worktree_path(const git_worktree *wt)
{
- assert(wt);
+ GIT_ASSERT_ARG_WITH_RETVAL(wt, NULL);
return wt->worktree_path;
}
@@ -493,16 +526,17 @@ int git_worktree_prune_options_init(
return 0;
}
-int git_worktree_pruneinit_options(git_worktree_prune_options *opts,
+#ifndef GIT_DEPRECATE_HARD
+int git_worktree_prune_init_options(git_worktree_prune_options *opts,
unsigned int version)
{
return git_worktree_prune_options_init(opts, version);
}
+#endif
int git_worktree_is_prunable(git_worktree *wt,
git_worktree_prune_options *opts)
{
- git_buf reason = GIT_BUF_INIT;
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
GIT_ERROR_CHECK_VERSION(
@@ -512,20 +546,24 @@ int git_worktree_is_prunable(git_worktree *wt,
if (opts)
memcpy(&popts, opts, sizeof(popts));
- if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0 &&
- git_worktree_is_locked(&reason, wt))
- {
- if (!reason.size)
- git_buf_attach_notowned(&reason, "no reason given", 15);
- git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
- git_buf_dispose(&reason);
+ if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) {
+ git_buf reason = GIT_BUF_INIT;
+ int error;
- return 0;
+ if ((error = git_worktree_is_locked(&reason, wt)) < 0)
+ return error;
+
+ if (error) {
+ if (!reason.size)
+ git_buf_attach_notowned(&reason, "no reason given", 15);
+ git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
+ git_buf_dispose(&reason);
+ return 0;
+ }
}
if ((popts.flags & GIT_WORKTREE_PRUNE_VALID) == 0 &&
- git_worktree_validate(wt) == 0)
- {
+ git_worktree_validate(wt) == 0) {
git_error_set(GIT_ERROR_WORKTREE, "not pruning valid working tree");
return 0;
}
@@ -554,7 +592,7 @@ int git_worktree_prune(git_worktree *wt,
}
/* Delete gitdir in parent repository */
- if ((err = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name)) < 0)
+ if ((err = git_buf_join3(&path, '/', wt->commondir_path, "worktrees", wt->name)) < 0)
goto out;
if (!git_path_exists(path.ptr))
{
diff --git a/src/zstream.c b/src/zstream.c
index 975ead2..a567567 100644
--- a/src/zstream.c
+++ b/src/zstream.c
@@ -156,7 +156,7 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
}
/* either we finished the input or we did not flush the data */
- assert(zstream->in_len > 0 || zstream->flush == Z_FINISH);
+ GIT_ASSERT(zstream->in_len > 0 || zstream->flush == Z_FINISH);
/* set out_size to number of bytes actually written to output */
*out_len = *out_len - out_remain;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6f8a18e..600c617 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,3 +1,4 @@
+SET(Python_ADDITIONAL_VERSIONS 3 2.7)
FIND_PACKAGE(PythonInterp)
IF(NOT PYTHONINTERP_FOUND)
@@ -9,6 +10,7 @@ SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/")
SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\")
+ADD_DEFINITIONS(-DCLAR_WIN32_LONGPATHS)
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
# Ensure that we do not use deprecated functions internally
diff --git a/tests/apply/apply_helpers.h b/tests/apply/apply_helpers.h
index 2d0019a..8209477 100644
--- a/tests/apply/apply_helpers.h
+++ b/tests/apply/apply_helpers.h
@@ -474,6 +474,15 @@
"-asparagus which had been laid by, boil it until these last articles are\n" \
"-sufficiently done, thicken with flour, butter and milk, and serve it up.\n"
+#define DIFF_ADD_INVALID_FILENAME \
+ "diff --git a/.git/hello_world.txt b/.git/hello_world.txt\n" \
+ "new file mode 100644\n" \
+ "index 0000000..f75ba05\n" \
+ "--- /dev/null\n" \
+ "+++ b/.git/hello_world.txt\n" \
+ "@@ -0,0 +1 @@\n" \
+ "+Hello, world.\n"
+
void validate_apply_workdir(
git_repository *repo,
struct merge_index_entry *workdir_entries,
diff --git a/tests/apply/both.c b/tests/apply/both.c
index 400df5e..1089632 100644
--- a/tests/apply/both.c
+++ b/tests/apply/both.c
@@ -734,3 +734,14 @@ void test_apply_both__cant_remove_file_twice(void)
git_diff_free(diff);
}
+
+void test_apply_both__cant_add_invalid_filename(void)
+{
+ git_diff *diff;
+
+ cl_git_pass(git_diff_from_buffer(&diff, DIFF_ADD_INVALID_FILENAME,
+ strlen(DIFF_ADD_INVALID_FILENAME)));
+ cl_git_fail(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));
+
+ git_diff_free(diff);
+}
diff --git a/tests/apply/fromdiff.c b/tests/apply/fromdiff.c
index e9329f6..69dfe09 100644
--- a/tests/apply/fromdiff.c
+++ b/tests/apply/fromdiff.c
@@ -3,7 +3,6 @@
#include "apply.h"
#include "repository.h"
-#include "buf_text.h"
#include "../patch/patch_common.h"
diff --git a/tests/apply/fromfile.c b/tests/apply/fromfile.c
index 477e283..ae519ea 100644
--- a/tests/apply/fromfile.c
+++ b/tests/apply/fromfile.c
@@ -5,7 +5,6 @@
#include "patch.h"
#include "patch_parse.h"
#include "repository.h"
-#include "buf_text.h"
#include "../patch/patch_common.h"
diff --git a/tests/apply/partial.c b/tests/apply/partial.c
index 466a927..548faaa 100644
--- a/tests/apply/partial.c
+++ b/tests/apply/partial.c
@@ -3,7 +3,6 @@
#include "apply.h"
#include "repository.h"
-#include "buf_text.h"
#include "../patch/patch_common.h"
diff --git a/tests/attr/lookup.c b/tests/attr/lookup.c
index 6063468..bfb2e87 100644
--- a/tests/attr/lookup.c
+++ b/tests/attr/lookup.c
@@ -13,7 +13,7 @@ void test_attr_lookup__simple(void)
cl_assert_equal_s(cl_fixture("attr/attr0"), file->entry->path);
cl_assert(file->rules.length == 1);
- cl_git_pass(git_attr_path__init(&path, "test", NULL, GIT_DIR_FLAG_UNKNOWN));
+ cl_git_pass(git_attr_path__init(&path, NULL, "test", NULL, GIT_DIR_FLAG_UNKNOWN));
cl_assert_equal_s("test", path.path);
cl_assert_equal_s("test", path.basename);
cl_assert(!path.is_dir);
@@ -36,7 +36,7 @@ static void run_test_cases(git_attr_file *file, struct attr_expected *cases, int
int error;
for (c = cases; c->path != NULL; c++) {
- cl_git_pass(git_attr_path__init(&path, c->path, NULL, GIT_DIR_FLAG_UNKNOWN));
+ cl_git_pass(git_attr_path__init(&path, NULL, c->path, NULL, GIT_DIR_FLAG_UNKNOWN));
if (force_dir)
path.is_dir = 1;
@@ -133,7 +133,7 @@ void test_attr_lookup__match_variants(void)
cl_assert_equal_s(cl_fixture("attr/attr1"), file->entry->path);
cl_assert(file->rules.length == 10);
- cl_git_pass(git_attr_path__init(&path, "/testing/for/pat0", NULL, GIT_DIR_FLAG_UNKNOWN));
+ cl_git_pass(git_attr_path__init(&path, NULL, "/testing/for/pat0", NULL, GIT_DIR_FLAG_UNKNOWN));
cl_assert_equal_s("pat0", path.basename);
run_test_cases(file, cases, 0);
@@ -236,6 +236,7 @@ void test_attr_lookup__check_attr_examples(void)
void test_attr_lookup__from_buffer(void)
{
git_attr_file *file;
+ git_attr_file_source source = {0};
struct attr_expected cases[] = {
{ "abc", "foo", EXPECT_TRUE, NULL },
@@ -250,7 +251,7 @@ void test_attr_lookup__from_buffer(void)
{ NULL, NULL, 0, NULL }
};
- cl_git_pass(git_attr_file__new(&file, NULL, 0));
+ cl_git_pass(git_attr_file__new(&file, NULL, &source));
cl_git_pass(git_attr_file__parse_buffer(NULL, file, "a* foo\nabc bar\n* baz", true));
diff --git a/tests/attr/repo.c b/tests/attr/repo.c
index 36beeb0..eabc033 100644
--- a/tests/attr/repo.c
+++ b/tests/attr/repo.c
@@ -71,11 +71,11 @@ void test_attr_repo__get_one(void)
}
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/attributes"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".git/info/attributes"));
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitattributes"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".gitattributes"));
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, "sub/.gitattributes"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, "sub/.gitattributes"));
}
void test_attr_repo__get_one_start_deep(void)
@@ -92,11 +92,11 @@ void test_attr_repo__get_one_start_deep(void)
}
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/attributes"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".git/info/attributes"));
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitattributes"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".gitattributes"));
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, "sub/.gitattributes"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, "sub/.gitattributes"));
}
void test_attr_repo__get_many(void)
@@ -341,7 +341,7 @@ void test_attr_repo__sysdir_with_session(void)
g_repo = cl_git_sandbox_reopen();
cl_git_pass(git_attr_session__init(&session, g_repo));
- cl_git_pass(git_attr_get_many_with_session(values, g_repo, &session, 0, "file", ARRAY_SIZE(attrs), attrs));
+ cl_git_pass(git_attr_get_many_with_session(values, g_repo, &session, NULL, "file", ARRAY_SIZE(attrs), attrs));
cl_assert_equal_s(values[0], "1");
cl_assert_equal_s(values[1], "2");
diff --git a/tests/blame/blame_helpers.c b/tests/blame/blame_helpers.c
index 61e8735..6b3ce67 100644
--- a/tests/blame/blame_helpers.c
+++ b/tests/blame/blame_helpers.c
@@ -31,13 +31,13 @@ void check_blame_hunk_index(git_repository *repo, git_blame *blame, int idx,
}
if (hunk->final_start_line_number != start_line) {
- hunk_message(idx, hunk, "mismatched start line number: expected %d, got %d",
+ hunk_message(idx, hunk, "mismatched start line number: expected %"PRIuZ", got %"PRIuZ,
start_line, hunk->final_start_line_number);
}
cl_assert_equal_i(hunk->final_start_line_number, start_line);
if (hunk->lines_in_hunk != len) {
- hunk_message(idx, hunk, "mismatched line count: expected %d, got %d",
+ hunk_message(idx, hunk, "mismatched line count: expected %"PRIuZ", got %"PRIuZ,
len, hunk->lines_in_hunk);
}
cl_assert_equal_i(hunk->lines_in_hunk, len);
diff --git a/tests/blame/blame_helpers.h b/tests/blame/blame_helpers.h
index fd5a35d..5b34b4a 100644
--- a/tests/blame/blame_helpers.h
+++ b/tests/blame/blame_helpers.h
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "blame.h"
-void hunk_message(size_t idx, const git_blame_hunk *hunk, const char *fmt, ...);
+void hunk_message(size_t idx, const git_blame_hunk *hunk, const char *fmt, ...) GIT_FORMAT_PRINTF(3, 4);
void check_blame_hunk_index(
git_repository *repo,
diff --git a/tests/blame/buffer.c b/tests/blame/buffer.c
index 340b1dc..06d5042 100644
--- a/tests/blame/buffer.c
+++ b/tests/blame/buffer.c
@@ -17,6 +17,32 @@ void test_blame_buffer__cleanup(void)
git_repository_free(g_repo);
}
+void test_blame_buffer__index(void)
+{
+ const git_blame_hunk *hunk;
+ const char *buffer = "Hello\nWorld!";
+
+ /*
+ * We need to open a different file from the ones used in other tests. Close
+ * the one opened in test_blame_buffer__initialize() to avoid a leak.
+ */
+ git_blame_free(g_fileblame);
+ g_fileblame = NULL;
+ cl_git_pass(git_blame_file(&g_fileblame, g_repo, "file.txt", NULL));
+
+ cl_git_pass(git_blame_buffer(&g_bufferblame, g_fileblame, buffer, strlen(buffer)));
+ cl_assert_equal_i(2, git_blame_get_hunk_count(g_bufferblame));
+
+ check_blame_hunk_index(g_repo, g_bufferblame, 0, 1, 1, 0, "836bc00b", "file.txt");
+ hunk = git_blame_get_hunk_byline(g_bufferblame, 1);
+ cl_assert(hunk);
+ cl_assert_equal_s("lhchavez", hunk->final_signature->name);
+ check_blame_hunk_index(g_repo, g_bufferblame, 1, 2, 1, 0, "00000000", "file.txt");
+ hunk = git_blame_get_hunk_byline(g_bufferblame, 2);
+ cl_assert(hunk);
+ cl_assert(hunk->final_signature == NULL);
+}
+
void test_blame_buffer__added_line(void)
{
const git_blame_hunk *hunk;
diff --git a/tests/blame/simple.c b/tests/blame/simple.c
index 16e7bc4..6b13ccc 100644
--- a/tests/blame/simple.c
+++ b/tests/blame/simple.c
@@ -239,6 +239,24 @@ void test_blame_simple__can_restrict_lines_min(void)
}
/*
+ * $ git blame -n c.txt
+ * orig line no final line no
+ * commit V author timestamp V
+ * 702c7aa5 1 (Carl Schwan 2020-01-29 01:52:31 +0100 4
+ */
+void test_blame_simple__can_ignore_whitespace_change(void)
+{
+ git_blame_options opts = GIT_BLAME_OPTIONS_INIT;
+
+ cl_git_pass(git_repository_open(&g_repo, cl_fixture("blametest.git")));
+
+ opts.flags |= GIT_BLAME_IGNORE_WHITESPACE;
+ cl_git_pass(git_blame_file(&g_blame, g_repo, "c.txt", &opts));
+ cl_assert_equal_i(1, git_blame_get_hunk_count(g_blame));
+ check_blame_hunk_index(g_repo, g_blame, 0, 1, 4, 0, "702c7aa5", "c.txt");
+}
+
+/*
* $ git blame -n b.txt -L ,6
* orig line no final line no
* commit V author timestamp V
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 65e13a6..4950201 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -108,7 +108,7 @@ done:
git_buf details = GIT_BUF_INIT;
git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, attrs={%s}",
git_path_basename(actual_path->ptr), systype, cd->autocrlf, cd->attrs);
- clar__fail(__FILE__, __LINE__,
+ clar__fail(__FILE__, __func__, __LINE__,
"checked out contents did not match expected", details.ptr, 0);
git_buf_dispose(&details);
}
diff --git a/tests/checkout/head.c b/tests/checkout/head.c
index 7991230..5b3a034 100644
--- a/tests/checkout/head.c
+++ b/tests/checkout/head.c
@@ -109,6 +109,32 @@ void test_checkout_head__do_not_remove_untracked_file_in_subdir(void)
cl_assert(git_path_isfile("testrepo/tracked/subdir/untracked"));
}
+void test_checkout_head__do_remove_untracked_paths(void)
+{
+ git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_index *index;
+ char *paths[] = {"tracked/untracked"};
+
+ cl_git_pass(p_mkdir("testrepo/tracked", 0755));
+ cl_git_pass(p_mkdir("testrepo/tracked/subdir", 0755));
+ cl_git_mkfile("testrepo/tracked/tracked", "tracked\n");
+ cl_git_mkfile("testrepo/tracked/untracked", "untracked\n");
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_add_bypath(index, "tracked/tracked"));
+ cl_git_pass(git_index_write(index));
+
+ git_index_free(index);
+
+ opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
+ opts.paths.strings = paths;
+ opts.paths.count = 1;
+ cl_git_pass(git_checkout_head(g_repo, &opts));
+
+ cl_assert(git_path_isfile("testrepo/tracked/tracked"));
+ cl_assert(!git_path_isfile("testrepo/tracked/untracked"));
+}
+
void test_checkout_head__do_remove_tracked_subdir(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
diff --git a/tests/checkout/index.c b/tests/checkout/index.c
index a76c471..5089753 100644
--- a/tests/checkout/index.c
+++ b/tests/checkout/index.c
@@ -89,6 +89,61 @@ void test_checkout_index__can_remove_untracked_files(void)
cl_assert_equal_i(false, git_path_isdir("./testrepo/dir"));
}
+void test_checkout_index__can_disable_pathspec_match(void)
+{
+ char *files_to_checkout[] = { "test10.txt", "test11.txt"};
+ git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_object *objects;
+ git_index *index;
+
+ /* reset to beginning of history (i.e. just a README file) */
+ opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
+
+ cl_git_pass(git_revparse_single(&objects, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));
+ cl_git_pass(git_checkout_tree(g_repo, objects, &opts));
+ cl_git_pass(git_repository_set_head_detached(g_repo, git_object_id(objects)));
+ git_object_free(objects);
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ /* We create 4 files and commit them */
+ cl_git_mkfile("testrepo/test9.txt", "original\n");
+ cl_git_mkfile("testrepo/test10.txt", "original\n");
+ cl_git_mkfile("testrepo/test11.txt", "original\n");
+ cl_git_mkfile("testrepo/test12.txt", "original\n");
+
+ cl_git_pass(git_index_add_bypath(index, "test9.txt"));
+ cl_git_pass(git_index_add_bypath(index, "test10.txt"));
+ cl_git_pass(git_index_add_bypath(index, "test11.txt"));
+ cl_git_pass(git_index_add_bypath(index, "test12.txt"));
+ cl_git_pass(git_index_write(index));
+
+ cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "commit our test files");
+
+ /* We modify the content of all 4 of our files */
+ cl_git_rewritefile("testrepo/test9.txt", "modified\n");
+ cl_git_rewritefile("testrepo/test10.txt", "modified\n");
+ cl_git_rewritefile("testrepo/test11.txt", "modified\n");
+ cl_git_rewritefile("testrepo/test12.txt", "modified\n");
+
+ /* We checkout only test10.txt and test11.txt */
+ opts.checkout_strategy =
+ GIT_CHECKOUT_FORCE |
+ GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH;
+ opts.paths.strings = files_to_checkout;
+ opts.paths.count = ARRAY_SIZE(files_to_checkout);
+ cl_git_pass(git_checkout_index(g_repo, NULL, &opts));
+
+ /* The only files that have been reverted to their original content
+ should be test10.txt and test11.txt */
+ check_file_contents("testrepo/test9.txt", "modified\n");
+ check_file_contents("testrepo/test10.txt", "original\n");
+ check_file_contents("testrepo/test11.txt", "original\n");
+ check_file_contents("testrepo/test12.txt", "modified\n");
+
+ git_index_free(index);
+}
+
void test_checkout_index__honor_the_specified_pathspecs(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 380d251..f8d9abe 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -917,7 +917,7 @@ void test_checkout_tree__extremely_long_file_name(void)
{
/* A utf-8 string with 83 characters, but 249 bytes. */
const char *longname = "\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97";
- char path[1024];
+ char path[1024] = {0};
g_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_revparse_single(&g_object, g_repo, "long-file-name"));
diff --git a/tests/clar.c b/tests/clar.c
index ead13f4..ca508d0 100644
--- a/tests/clar.c
+++ b/tests/clar.c
@@ -96,6 +96,7 @@ fixture_path(const char *base, const char *fixture_name);
struct clar_error {
const char *file;
+ const char *function;
size_t line_number;
const char *error_msg;
char *description;
@@ -140,6 +141,8 @@ static struct {
int tests_ran;
int suites_ran;
+ enum cl_output_format output_format;
+
int report_errors_only;
int exit_on_error;
int report_suite_names;
@@ -293,6 +296,7 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
const struct clar_func *test = suite->tests;
size_t i, matchlen;
struct clar_report *report;
+ int exact = 0;
if (!suite->enabled)
return;
@@ -317,6 +321,11 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
while (*filter == ':')
++filter;
matchlen = strlen(filter);
+
+ if (matchlen && filter[matchlen - 1] == '$') {
+ exact = 1;
+ matchlen--;
+ }
}
}
@@ -324,6 +333,9 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
if (filter && strncmp(test[i].name, filter, matchlen))
continue;
+ if (exact && strlen(test[i].name) != matchlen)
+ continue;
+
_clar.active_test = test[i].name;
report = calloc(1, sizeof(struct clar_report));
@@ -361,6 +373,7 @@ clar_usage(const char *arg)
printf(" -v Increase verbosity (show suite names)\n");
printf(" -q Only report tests that had an error\n");
printf(" -Q Quit as soon as a test fails\n");
+ printf(" -t Display results in tap format\n");
printf(" -l Print suite names\n");
printf(" -r[filename] Write summary file (to the optional filename)\n");
exit(-1);
@@ -376,7 +389,7 @@ clar_parse_args(int argc, char **argv)
char *argument = argv[i];
if (argument[0] != '-' || argument[1] == '\0'
- || strchr("sixvqQlr", argument[1]) == NULL) {
+ || strchr("sixvqQtlr", argument[1]) == NULL) {
clar_usage(argv[0]);
}
}
@@ -459,6 +472,10 @@ clar_parse_args(int argc, char **argv)
_clar.exit_on_error = 1;
break;
+ case 't':
+ _clar.output_format = CL_OUTPUT_TAP;
+ break;
+
case 'l': {
size_t j;
printf("Test suites (use -s<name> to run just one):\n");
@@ -487,6 +504,9 @@ clar_parse_args(int argc, char **argv)
void
clar_test_init(int argc, char **argv)
{
+ if (argc > 1)
+ clar_parse_args(argc, argv);
+
clar_print_init(
(int)_clar_callback_count,
(int)_clar_suite_count,
@@ -498,9 +518,6 @@ clar_test_init(int argc, char **argv)
_clar.summary_filename = strdup(_clar.summary_filename);
}
- if (argc > 1)
- clar_parse_args(argc, argv);
-
if (_clar.write_summary &&
!(_clar.summary = clar_summary_init(_clar.summary_filename))) {
clar_print_onabort("Failed to open the summary file\n");
@@ -596,6 +613,7 @@ void clar__skip(void)
void clar__fail(
const char *file,
+ const char *function,
size_t line,
const char *error_msg,
const char *description,
@@ -612,6 +630,7 @@ void clar__fail(
_clar.last_report->last_error = error;
error->file = file;
+ error->function = function;
error->line_number = line;
error->error_msg = error_msg;
@@ -628,6 +647,7 @@ void clar__fail(
void clar__assert(
int condition,
const char *file,
+ const char *function,
size_t line,
const char *error_msg,
const char *description,
@@ -636,11 +656,12 @@ void clar__assert(
if (condition)
return;
- clar__fail(file, line, error_msg, description, should_abort);
+ clar__fail(file, function, line, error_msg, description, should_abort);
}
void clar__assert_equal(
const char *file,
+ const char *function,
size_t line,
const char *err,
int should_abort,
@@ -751,7 +772,7 @@ void clar__assert_equal(
va_end(args);
if (!is_equal)
- clar__fail(file, line, err, buf, should_abort);
+ clar__fail(file, function, line, err, buf, should_abort);
}
void cl_set_cleanup(void (*cleanup)(void *), void *opaque)
diff --git a/tests/clar.h b/tests/clar.h
index 20ff4c8..8c22382 100644
--- a/tests/clar.h
+++ b/tests/clar.h
@@ -16,6 +16,11 @@ enum cl_test_status {
CL_TEST_NOTRUN,
};
+enum cl_output_format {
+ CL_OUTPUT_CLAP,
+ CL_OUTPUT_TAP,
+};
+
/** Setup clar environment */
void clar_test_init(int argc, char *argv[]);
int clar_test_run(void);
@@ -81,16 +86,16 @@ const char *cl_fixture_basename(const char *fixture_name);
/**
* Assertion macros with explicit error message
*/
-#define cl_must_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 1)
-#define cl_must_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 1)
-#define cl_assert_(expr, desc) clar__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 1)
+#define cl_must_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __func__, __LINE__, "Function call failed: " #expr, desc, 1)
+#define cl_must_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __func__, __LINE__, "Expected function call to fail: " #expr, desc, 1)
+#define cl_assert_(expr, desc) clar__assert((expr) != 0, __FILE__, __func__, __LINE__, "Expression is not true: " #expr, desc, 1)
/**
* Check macros with explicit error message
*/
-#define cl_check_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 0)
-#define cl_check_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 0)
-#define cl_check_(expr, desc) clar__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 0)
+#define cl_check_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __func__, __LINE__, "Function call failed: " #expr, desc, 0)
+#define cl_check_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __func__, __LINE__, "Expected function call to fail: " #expr, desc, 0)
+#define cl_check_(expr, desc) clar__assert((expr) != 0, __FILE__, __func__, __LINE__, "Expression is not true: " #expr, desc, 0)
/**
* Assertion macros with no error message
@@ -109,38 +114,39 @@ const char *cl_fixture_basename(const char *fixture_name);
/**
* Forced failure/warning
*/
-#define cl_fail(desc) clar__fail(__FILE__, __LINE__, "Test failed.", desc, 1)
-#define cl_warning(desc) clar__fail(__FILE__, __LINE__, "Warning during test execution:", desc, 0)
+#define cl_fail(desc) clar__fail(__FILE__, __func__, __LINE__, "Test failed.", desc, 1)
+#define cl_warning(desc) clar__fail(__FILE__, __func__, __LINE__, "Warning during test execution:", desc, 0)
#define cl_skip() clar__skip()
/**
* Typed assertion macros
*/
-#define cl_assert_equal_s(s1,s2) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%s", (s1), (s2))
-#define cl_assert_equal_s_(s1,s2,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%s", (s1), (s2))
+#define cl_assert_equal_s(s1,s2) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%s", (s1), (s2))
+#define cl_assert_equal_s_(s1,s2,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%s", (s1), (s2))
-#define cl_assert_equal_wcs(wcs1,wcs2) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%ls", (wcs1), (wcs2))
-#define cl_assert_equal_wcs_(wcs1,wcs2,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%ls", (wcs1), (wcs2))
+#define cl_assert_equal_wcs(wcs1,wcs2) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%ls", (wcs1), (wcs2))
+#define cl_assert_equal_wcs_(wcs1,wcs2,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%ls", (wcs1), (wcs2))
-#define cl_assert_equal_strn(s1,s2,len) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%.*s", (s1), (s2), (int)(len))
-#define cl_assert_equal_strn_(s1,s2,len,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%.*s", (s1), (s2), (int)(len))
+#define cl_assert_equal_strn(s1,s2,len) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%.*s", (s1), (s2), (int)(len))
+#define cl_assert_equal_strn_(s1,s2,len,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%.*s", (s1), (s2), (int)(len))
-#define cl_assert_equal_wcsn(wcs1,wcs2,len) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%.*ls", (wcs1), (wcs2), (int)(len))
-#define cl_assert_equal_wcsn_(wcs1,wcs2,len,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%.*ls", (wcs1), (wcs2), (int)(len))
+#define cl_assert_equal_wcsn(wcs1,wcs2,len) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%.*ls", (wcs1), (wcs2), (int)(len))
+#define cl_assert_equal_wcsn_(wcs1,wcs2,len,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%.*ls", (wcs1), (wcs2), (int)(len))
-#define cl_assert_equal_i(i1,i2) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
-#define cl_assert_equal_i_(i1,i2,note) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2 " (" #note ")", 1, "%d", (i1), (i2))
-#define cl_assert_equal_i_fmt(i1,i2,fmt) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2, 1, (fmt), (int)(i1), (int)(i2))
+#define cl_assert_equal_i(i1,i2) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
+#define cl_assert_equal_i_(i1,i2,note) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2 " (" #note ")", 1, "%d", (i1), (i2))
+#define cl_assert_equal_i_fmt(i1,i2,fmt) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2, 1, (fmt), (int)(i1), (int)(i2))
-#define cl_assert_equal_b(b1,b2) clar__assert_equal(__FILE__,__LINE__,#b1 " != " #b2, 1, "%d", (int)((b1) != 0),(int)((b2) != 0))
+#define cl_assert_equal_b(b1,b2) clar__assert_equal(__FILE__,__func__,__LINE__,#b1 " != " #b2, 1, "%d", (int)((b1) != 0),(int)((b2) != 0))
-#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2))
+#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__func__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2))
void clar__skip(void);
void clar__fail(
const char *file,
+ const char *func,
size_t line,
const char *error,
const char *description,
@@ -149,6 +155,7 @@ void clar__fail(
void clar__assert(
int condition,
const char *file,
+ const char *func,
size_t line,
const char *error,
const char *description,
@@ -156,6 +163,7 @@ void clar__assert(
void clar__assert_equal(
const char *file,
+ const char *func,
size_t line,
const char *err,
int should_abort,
diff --git a/tests/clar/fs.h b/tests/clar/fs.h
index 7c7dde6..44ede45 100644
--- a/tests/clar/fs.h
+++ b/tests/clar/fs.h
@@ -1,5 +1,19 @@
+/*
+ * By default, use a read/write loop to copy files on POSIX systems.
+ * On Linux, use sendfile by default as it's slightly faster. On
+ * macOS, we avoid fcopyfile by default because it's slightly slower.
+ */
+#undef USE_FCOPYFILE
+#define USE_SENDFILE 1
+
#ifdef _WIN32
+#ifdef CLAR_WIN32_LONGPATHS
+# define CLAR_MAX_PATH 4096
+#else
+# define CLAR_MAX_PATH MAX_PATH
+#endif
+
#define RM_RETRY_COUNT 5
#define RM_RETRY_DELAY 10
@@ -40,21 +54,48 @@ fs_rmdir_rmdir(WCHAR *_wpath)
return 0;
}
+static void translate_path(WCHAR *path, size_t path_size)
+{
+ size_t path_len, i;
+
+ if (wcsncmp(path, L"\\\\?\\", 4) == 0)
+ return;
+
+ path_len = wcslen(path);
+ cl_assert(path_size > path_len + 4);
+
+ for (i = path_len; i > 0; i--) {
+ WCHAR c = path[i - 1];
+
+ if (c == L'/')
+ path[i + 3] = L'\\';
+ else
+ path[i + 3] = path[i - 1];
+ }
+
+ path[0] = L'\\';
+ path[1] = L'\\';
+ path[2] = L'?';
+ path[3] = L'\\';
+ path[path_len + 4] = L'\0';
+}
+
static void
fs_rmdir_helper(WCHAR *_wsource)
{
- WCHAR buffer[MAX_PATH];
+ WCHAR buffer[CLAR_MAX_PATH];
HANDLE find_handle;
WIN32_FIND_DATAW find_data;
size_t buffer_prefix_len;
/* Set up the buffer and capture the length */
- wcscpy_s(buffer, MAX_PATH, _wsource);
- wcscat_s(buffer, MAX_PATH, L"\\");
+ wcscpy_s(buffer, CLAR_MAX_PATH, _wsource);
+ translate_path(buffer, CLAR_MAX_PATH);
+ wcscat_s(buffer, CLAR_MAX_PATH, L"\\");
buffer_prefix_len = wcslen(buffer);
/* FindFirstFile needs a wildcard to match multiple items */
- wcscat_s(buffer, MAX_PATH, L"*");
+ wcscat_s(buffer, CLAR_MAX_PATH, L"*");
find_handle = FindFirstFileW(buffer, &find_data);
cl_assert(INVALID_HANDLE_VALUE != find_handle);
@@ -64,7 +105,7 @@ fs_rmdir_helper(WCHAR *_wsource)
if (fs__dotordotdot(find_data.cFileName))
continue;
- wcscpy_s(buffer + buffer_prefix_len, MAX_PATH - buffer_prefix_len, find_data.cFileName);
+ wcscpy_s(buffer + buffer_prefix_len, CLAR_MAX_PATH - buffer_prefix_len, find_data.cFileName);
if (FILE_ATTRIBUTE_DIRECTORY & find_data.dwFileAttributes)
fs_rmdir_helper(buffer);
@@ -115,7 +156,7 @@ fs_rm_wait(WCHAR *_wpath)
static void
fs_rm(const char *_source)
{
- WCHAR wsource[MAX_PATH];
+ WCHAR wsource[CLAR_MAX_PATH];
DWORD attrs;
/* The input path is UTF-8. Convert it to wide characters
@@ -125,7 +166,9 @@ fs_rm(const char *_source)
_source,
-1, /* Indicates NULL termination */
wsource,
- MAX_PATH));
+ CLAR_MAX_PATH));
+
+ translate_path(wsource, CLAR_MAX_PATH);
/* Does the item exist? If not, we have no work to do */
attrs = GetFileAttributesW(wsource);
@@ -150,21 +193,23 @@ fs_rm(const char *_source)
static void
fs_copydir_helper(WCHAR *_wsource, WCHAR *_wdest)
{
- WCHAR buf_source[MAX_PATH], buf_dest[MAX_PATH];
+ WCHAR buf_source[CLAR_MAX_PATH], buf_dest[CLAR_MAX_PATH];
HANDLE find_handle;
WIN32_FIND_DATAW find_data;
size_t buf_source_prefix_len, buf_dest_prefix_len;
- wcscpy_s(buf_source, MAX_PATH, _wsource);
- wcscat_s(buf_source, MAX_PATH, L"\\");
+ wcscpy_s(buf_source, CLAR_MAX_PATH, _wsource);
+ wcscat_s(buf_source, CLAR_MAX_PATH, L"\\");
+ translate_path(buf_source, CLAR_MAX_PATH);
buf_source_prefix_len = wcslen(buf_source);
- wcscpy_s(buf_dest, MAX_PATH, _wdest);
- wcscat_s(buf_dest, MAX_PATH, L"\\");
+ wcscpy_s(buf_dest, CLAR_MAX_PATH, _wdest);
+ wcscat_s(buf_dest, CLAR_MAX_PATH, L"\\");
+ translate_path(buf_dest, CLAR_MAX_PATH);
buf_dest_prefix_len = wcslen(buf_dest);
/* Get an enumerator for the items in the source. */
- wcscat_s(buf_source, MAX_PATH, L"*");
+ wcscat_s(buf_source, CLAR_MAX_PATH, L"*");
find_handle = FindFirstFileW(buf_source, &find_data);
cl_assert(INVALID_HANDLE_VALUE != find_handle);
@@ -177,8 +222,8 @@ fs_copydir_helper(WCHAR *_wsource, WCHAR *_wdest)
if (fs__dotordotdot(find_data.cFileName))
continue;
- wcscpy_s(buf_source + buf_source_prefix_len, MAX_PATH - buf_source_prefix_len, find_data.cFileName);
- wcscpy_s(buf_dest + buf_dest_prefix_len, MAX_PATH - buf_dest_prefix_len, find_data.cFileName);
+ wcscpy_s(buf_source + buf_source_prefix_len, CLAR_MAX_PATH - buf_source_prefix_len, find_data.cFileName);
+ wcscpy_s(buf_dest + buf_dest_prefix_len, CLAR_MAX_PATH - buf_dest_prefix_len, find_data.cFileName);
if (FILE_ATTRIBUTE_DIRECTORY & find_data.dwFileAttributes)
fs_copydir_helper(buf_source, buf_dest);
@@ -197,7 +242,7 @@ fs_copydir_helper(WCHAR *_wsource, WCHAR *_wdest)
static void
fs_copy(const char *_source, const char *_dest)
{
- WCHAR wsource[MAX_PATH], wdest[MAX_PATH];
+ WCHAR wsource[CLAR_MAX_PATH], wdest[CLAR_MAX_PATH];
DWORD source_attrs, dest_attrs;
HANDLE find_handle;
WIN32_FIND_DATAW find_data;
@@ -209,14 +254,17 @@ fs_copy(const char *_source, const char *_dest)
_source,
-1,
wsource,
- MAX_PATH));
+ CLAR_MAX_PATH));
cl_assert(MultiByteToWideChar(CP_UTF8,
MB_ERR_INVALID_CHARS,
_dest,
-1,
wdest,
- MAX_PATH));
+ CLAR_MAX_PATH));
+
+ translate_path(wsource, CLAR_MAX_PATH);
+ translate_path(wdest, CLAR_MAX_PATH);
/* Check the source for existence */
source_attrs = GetFileAttributesW(wsource);
@@ -230,8 +278,8 @@ fs_copy(const char *_source, const char *_dest)
* Use FindFirstFile to parse the path */
find_handle = FindFirstFileW(wsource, &find_data);
cl_assert(INVALID_HANDLE_VALUE != find_handle);
- wcscat_s(wdest, MAX_PATH, L"\\");
- wcscat_s(wdest, MAX_PATH, find_data.cFileName);
+ wcscat_s(wdest, CLAR_MAX_PATH, L"\\");
+ wcscat_s(wdest, CLAR_MAX_PATH, find_data.cFileName);
FindClose(find_handle);
/* Check the new target for existence */
@@ -254,74 +302,213 @@ cl_fs_cleanup(void)
#include <errno.h>
#include <string.h>
+#include <limits.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(__linux__)
+# include <sys/sendfile.h>
+#endif
-static int
-shell_out(char * const argv[])
+#if defined(__APPLE__)
+# include <copyfile.h>
+#endif
+
+static void basename_r(const char **out, int *out_len, const char *in)
{
- int status, piderr;
- pid_t pid;
+ size_t in_len = strlen(in), start_pos;
+
+ for (in_len = strlen(in); in_len; in_len--) {
+ if (in[in_len - 1] != '/')
+ break;
+ }
+
+ for (start_pos = in_len; start_pos; start_pos--) {
+ if (in[start_pos - 1] == '/')
+ break;
+ }
- pid = fork();
+ cl_assert(in_len - start_pos < INT_MAX);
- if (pid < 0) {
- fprintf(stderr,
- "System error: `fork()` call failed (%d) - %s\n",
- errno, strerror(errno));
- exit(-1);
+ if (in_len - start_pos > 0) {
+ *out = &in[start_pos];
+ *out_len = (in_len - start_pos);
+ } else {
+ *out = "/";
+ *out_len = 1;
}
+}
+
+static char *joinpath(const char *dir, const char *base, int base_len)
+{
+ char *out;
+ int len;
+
+ if (base_len == -1) {
+ size_t bl = strlen(base);
- if (pid == 0) {
- execv(argv[0], argv);
+ cl_assert(bl < INT_MAX);
+ base_len = (int)bl;
}
- do {
- piderr = waitpid(pid, &status, WUNTRACED);
- } while (piderr < 0 && (errno == EAGAIN || errno == EINTR));
+ len = strlen(dir) + base_len + 2;
+ cl_assert(len > 0);
- return WEXITSTATUS(status);
+ cl_assert(out = malloc(len));
+ cl_assert(snprintf(out, len, "%s/%.*s", dir, base_len, base) < len);
+
+ return out;
}
static void
-fs_copy(const char *_source, const char *dest)
+fs_copydir_helper(const char *source, const char *dest, int dest_mode)
{
- char *argv[5];
- char *source;
- size_t source_len;
+ DIR *source_dir;
+ struct dirent *d;
- source = strdup(_source);
- source_len = strlen(source);
+ mkdir(dest, dest_mode);
- if (source[source_len - 1] == '/')
- source[source_len - 1] = 0;
+ cl_assert_(source_dir = opendir(source), "Could not open source dir");
+ while ((d = (errno = 0, readdir(source_dir))) != NULL) {
+ char *child;
- argv[0] = "/bin/cp";
- argv[1] = "-R";
- argv[2] = source;
- argv[3] = (char *)dest;
- argv[4] = NULL;
+ if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
+ continue;
- cl_must_pass_(
- shell_out(argv),
- "Failed to copy test fixtures to sandbox"
- );
+ child = joinpath(source, d->d_name, -1);
+ fs_copy(child, dest);
+ free(child);
+ }
+
+ cl_assert_(errno == 0, "Failed to iterate source dir");
- free(source);
+ closedir(source_dir);
}
static void
-fs_rm(const char *source)
+fs_copyfile_helper(const char *source, size_t source_len, const char *dest, int dest_mode)
{
- char *argv[4];
+ int in, out;
+
+ cl_must_pass((in = open(source, O_RDONLY)));
+ cl_must_pass((out = open(dest, O_WRONLY|O_CREAT|O_TRUNC, dest_mode)));
+
+#if USE_FCOPYFILE && defined(__APPLE__)
+ ((void)(source_len)); /* unused */
+ cl_must_pass(fcopyfile(in, out, 0, COPYFILE_DATA));
+#elif USE_SENDFILE && defined(__linux__)
+ {
+ ssize_t ret = 0;
+
+ while (source_len && (ret = sendfile(out, in, NULL, source_len)) > 0) {
+ source_len -= (size_t)ret;
+ }
+ cl_assert(ret >= 0);
+ }
+#else
+ {
+ char buf[131072];
+ ssize_t ret;
+
+ ((void)(source_len)); /* unused */
- argv[0] = "/bin/rm";
- argv[1] = "-Rf";
- argv[2] = (char *)source;
- argv[3] = NULL;
+ while ((ret = read(in, buf, sizeof(buf))) > 0) {
+ size_t len = (size_t)ret;
- cl_must_pass_(
- shell_out(argv),
- "Failed to cleanup the sandbox"
- );
+ while (len && (ret = write(out, buf, len)) > 0) {
+ cl_assert(ret <= (ssize_t)len);
+ len -= ret;
+ }
+ cl_assert(ret >= 0);
+ }
+ cl_assert(ret == 0);
+ }
+#endif
+
+ close(in);
+ close(out);
+}
+
+static void
+fs_copy(const char *source, const char *_dest)
+{
+ char *dbuf = NULL;
+ const char *dest = NULL;
+ struct stat source_st, dest_st;
+
+ cl_must_pass_(lstat(source, &source_st), "Failed to stat copy source");
+
+ if (lstat(_dest, &dest_st) == 0) {
+ const char *base;
+ int base_len;
+
+ /* Target exists and is directory; append basename */
+ cl_assert(S_ISDIR(dest_st.st_mode));
+
+ basename_r(&base, &base_len, source);
+ cl_assert(base_len < INT_MAX);
+
+ dbuf = joinpath(_dest, base, base_len);
+ dest = dbuf;
+ } else if (errno != ENOENT) {
+ cl_fail("Cannot copy; cannot stat destination");
+ } else {
+ dest = _dest;
+ }
+
+ if (S_ISDIR(source_st.st_mode)) {
+ fs_copydir_helper(source, dest, source_st.st_mode);
+ } else {
+ fs_copyfile_helper(source, source_st.st_size, dest, source_st.st_mode);
+ }
+
+ free(dbuf);
+}
+
+static void
+fs_rmdir_helper(const char *path)
+{
+ DIR *dir;
+ struct dirent *d;
+
+ cl_assert_(dir = opendir(path), "Could not open dir");
+ while ((d = (errno = 0, readdir(dir))) != NULL) {
+ char *child;
+
+ if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
+ continue;
+
+ child = joinpath(path, d->d_name, -1);
+ fs_rm(child);
+ free(child);
+ }
+
+ cl_assert_(errno == 0, "Failed to iterate source dir");
+ closedir(dir);
+
+ cl_must_pass_(rmdir(path), "Could not remove directory");
+}
+
+static void
+fs_rm(const char *path)
+{
+ struct stat st;
+
+ if (lstat(path, &st)) {
+ if (errno == ENOENT)
+ return;
+
+ cl_fail("Cannot copy; cannot stat destination");
+ }
+
+ if (S_ISDIR(st.st_mode)) {
+ fs_rmdir_helper(path);
+ } else {
+ cl_must_pass(unlink(path));
+ }
}
void
diff --git a/tests/clar/print.h b/tests/clar/print.h
index 2e2b620..dbfd276 100644
--- a/tests/clar/print.h
+++ b/tests/clar/print.h
@@ -1,12 +1,13 @@
+/* clap: clar protocol, the traditional clar output format */
-static void clar_print_init(int test_count, int suite_count, const char *suite_names)
+static void clar_print_clap_init(int test_count, int suite_count, const char *suite_names)
{
(void)test_count;
printf("Loaded %d suites: %s\n", (int)suite_count, suite_names);
printf("Started (test status codes: OK='.' FAILURE='F' SKIPPED='S')\n");
}
-static void clar_print_shutdown(int test_count, int suite_count, int error_count)
+static void clar_print_clap_shutdown(int test_count, int suite_count, int error_count)
{
(void)test_count;
(void)suite_count;
@@ -16,7 +17,7 @@ static void clar_print_shutdown(int test_count, int suite_count, int error_count
clar_report_all();
}
-static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error)
+static void clar_print_clap_error(int num, const struct clar_report *report, const struct clar_error *error)
{
printf(" %d) Failure:\n", num);
@@ -35,7 +36,7 @@ static void clar_print_error(int num, const struct clar_report *report, const st
fflush(stdout);
}
-static void clar_print_ontest(const char *test_name, int test_number, enum cl_test_status status)
+static void clar_print_clap_ontest(const char *test_name, int test_number, enum cl_test_status status)
{
(void)test_name;
(void)test_number;
@@ -50,7 +51,7 @@ static void clar_print_ontest(const char *test_name, int test_number, enum cl_te
fflush(stdout);
}
-static void clar_print_onsuite(const char *suite_name, int suite_index)
+static void clar_print_clap_onsuite(const char *suite_name, int suite_index)
{
if (_clar.report_suite_names)
printf("\n%s", suite_name);
@@ -58,10 +59,142 @@ static void clar_print_onsuite(const char *suite_name, int suite_index)
(void)suite_index;
}
+static void clar_print_clap_onabort(const char *fmt, va_list arg)
+{
+ vfprintf(stderr, fmt, arg);
+}
+
+/* tap: test anywhere protocol format */
+
+static void clar_print_tap_init(int test_count, int suite_count, const char *suite_names)
+{
+ (void)test_count;
+ (void)suite_count;
+ (void)suite_names;
+ printf("TAP version 13\n");
+}
+
+static void clar_print_tap_shutdown(int test_count, int suite_count, int error_count)
+{
+ (void)suite_count;
+ (void)error_count;
+
+ printf("1..%d\n", test_count);
+}
+
+static void clar_print_tap_error(int num, const struct clar_report *report, const struct clar_error *error)
+{
+ (void)num;
+ (void)report;
+ (void)error;
+}
+
+static void print_escaped(const char *str)
+{
+ char *c;
+
+ while ((c = strchr(str, '\'')) != NULL) {
+ printf("%.*s", (int)(c - str), str);
+ printf("''");
+ str = c + 1;
+ }
+
+ printf("%s", str);
+}
+
+static void clar_print_tap_ontest(const char *test_name, int test_number, enum cl_test_status status)
+{
+ const struct clar_error *error = _clar.last_report->errors;
+
+ (void)test_name;
+ (void)test_number;
+
+ switch(status) {
+ case CL_TEST_OK:
+ printf("ok %d - %s::%s\n", test_number, _clar.active_suite, test_name);
+ break;
+ case CL_TEST_FAILURE:
+ printf("not ok %d - %s::%s\n", test_number, _clar.active_suite, test_name);
+
+ printf(" ---\n");
+ printf(" reason: |\n");
+ printf(" %s\n", error->error_msg);
+
+ if (error->description)
+ printf(" %s\n", error->description);
+
+ printf(" at:\n");
+ printf(" file: '"); print_escaped(error->file); printf("'\n");
+ printf(" line: %" PRIuZ "\n", error->line_number);
+ printf(" function: '%s'\n", error->function);
+ printf(" ---\n");
+
+ break;
+ case CL_TEST_SKIP:
+ case CL_TEST_NOTRUN:
+ printf("ok %d - # SKIP %s::%s\n", test_number, _clar.active_suite, test_name);
+ break;
+ }
+
+ fflush(stdout);
+}
+
+static void clar_print_tap_onsuite(const char *suite_name, int suite_index)
+{
+ printf("# start of suite %d: %s\n", suite_index, suite_name);
+}
+
+static void clar_print_tap_onabort(const char *fmt, va_list arg)
+{
+ printf("Bail out! ");
+ vprintf(fmt, arg);
+ fflush(stdout);
+}
+
+/* indirection between protocol output selection */
+
+#define PRINT(FN, ...) do { \
+ switch (_clar.output_format) { \
+ case CL_OUTPUT_CLAP: \
+ clar_print_clap_##FN (__VA_ARGS__); \
+ break; \
+ case CL_OUTPUT_TAP: \
+ clar_print_tap_##FN (__VA_ARGS__); \
+ break; \
+ default: \
+ abort(); \
+ } \
+ } while (0)
+
+static void clar_print_init(int test_count, int suite_count, const char *suite_names)
+{
+ PRINT(init, test_count, suite_count, suite_names);
+}
+
+static void clar_print_shutdown(int test_count, int suite_count, int error_count)
+{
+ PRINT(shutdown, test_count, suite_count, error_count);
+}
+
+static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error)
+{
+ PRINT(error, num, report, error);
+}
+
+static void clar_print_ontest(const char *test_name, int test_number, enum cl_test_status status)
+{
+ PRINT(ontest, test_name, test_number, status);
+}
+
+static void clar_print_onsuite(const char *suite_name, int suite_index)
+{
+ PRINT(onsuite, suite_name, suite_index);
+}
+
static void clar_print_onabort(const char *msg, ...)
{
va_list argp;
va_start(argp, msg);
- vfprintf(stderr, msg, argp);
+ PRINT(onabort, msg, argp);
va_end(argp);
}
diff --git a/tests/clar/sandbox.h b/tests/clar/sandbox.h
index 2114819..0ba1479 100644
--- a/tests/clar/sandbox.h
+++ b/tests/clar/sandbox.h
@@ -2,7 +2,7 @@
#include <sys/syslimits.h>
#endif
-static char _clar_path[4096];
+static char _clar_path[4096 + 1];
static int
is_valid_tmp_path(const char *path)
@@ -39,7 +39,8 @@ find_tmp_path(char *buffer, size_t length)
if (length >= PATH_MAX && realpath(env, buffer) != NULL)
return 0;
#endif
- strncpy(buffer, env, length);
+ strncpy(buffer, env, length - 1);
+ buffer[length - 1] = '\0';
return 0;
}
}
@@ -50,7 +51,8 @@ find_tmp_path(char *buffer, size_t length)
if (length >= PATH_MAX && realpath("/tmp", buffer) != NULL)
return 0;
#endif
- strncpy(buffer, "/tmp", length);
+ strncpy(buffer, "/tmp", length - 1);
+ buffer[length - 1] = '\0';
return 0;
}
@@ -65,7 +67,8 @@ find_tmp_path(char *buffer, size_t length)
/* This system doesn't like us, try to use the current directory */
if (is_valid_tmp_path(".")) {
- strncpy(buffer, ".", length);
+ strncpy(buffer, ".", length - 1);
+ buffer[length - 1] = '\0';
return 0;
}
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 4723a06..c4550c3 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -4,7 +4,7 @@
#include "git2/sys/repository.h"
void cl_git_report_failure(
- int error, int expected, const char *file, int line, const char *fncall)
+ int error, int expected, const char *file, const char *func, int line, const char *fncall)
{
char msg[4096];
const git_error *last = git_error_last();
@@ -18,7 +18,7 @@ void cl_git_report_failure(
else
p_snprintf(msg, 4096, "no error, expected non-zero return");
- clar__assert(0, file, line, fncall, msg, 1);
+ clar__assert(0, file, func, line, fncall, msg, 1);
}
void cl_git_mkfile(const char *filename, const char *content)
@@ -275,7 +275,7 @@ const char* cl_git_fixture_url(const char *fixturename)
const char* cl_git_path_url(const char *path)
{
- static char url[4096];
+ static char url[4096 + 1];
const char *in_buf;
git_buf path_buf = GIT_BUF_INIT;
@@ -311,9 +311,10 @@ const char* cl_git_path_url(const char *path)
in_buf++;
}
- cl_assert(url_buf.size < 4096);
+ cl_assert(url_buf.size < sizeof(url) - 1);
- strncpy(url, git_buf_cstr(&url_buf), 4096);
+ strncpy(url, git_buf_cstr(&url_buf), sizeof(url) - 1);
+ url[sizeof(url) - 1] = '\0';
git_buf_dispose(&url_buf);
git_buf_dispose(&path_buf);
return url;
@@ -507,6 +508,7 @@ void clar__assert_equal_file(
int ignore_cr,
const char *path,
const char *file,
+ const char *func,
int line)
{
char buf[4000];
@@ -519,7 +521,7 @@ void clar__assert_equal_file(
while ((bytes = p_read(fd, buf, sizeof(buf))) != 0) {
clar__assert(
- bytes > 0, file, line, "error reading from file", path, 1);
+ bytes > 0, file, func, line, "error reading from file", path, 1);
if (ignore_cr)
bytes = strip_cr_from_buf(buf, bytes);
@@ -532,7 +534,7 @@ void clar__assert_equal_file(
buf, sizeof(buf), "file content mismatch at byte %"PRIdZ,
(ssize_t)(total_bytes + pos));
p_close(fd);
- clar__fail(file, line, path, buf, 1);
+ clar__fail(file, func, line, path, buf, 1);
}
expected_data += bytes;
@@ -541,8 +543,8 @@ void clar__assert_equal_file(
p_close(fd);
- clar__assert(!bytes, file, line, "error reading from file", path, 1);
- clar__assert_equal(file, line, "mismatched file length", 1, "%"PRIuZ,
+ clar__assert(!bytes, file, func, line, "error reading from file", path, 1);
+ clar__assert_equal(file, func, line, "mismatched file length", 1, "%"PRIuZ,
(size_t)expected_bytes, (size_t)total_bytes);
}
diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h
index 12175c6..e3b7bd9 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar_libgit2.h
@@ -12,15 +12,15 @@
*
* Use this wrapper around all `git_` library calls that return error codes!
*/
-#define cl_git_pass(expr) cl_git_expect((expr), 0, __FILE__, __LINE__)
+#define cl_git_pass(expr) cl_git_expect((expr), 0, __FILE__, __func__, __LINE__)
-#define cl_git_fail_with(error, expr) cl_git_expect((expr), error, __FILE__, __LINE__)
+#define cl_git_fail_with(error, expr) cl_git_expect((expr), error, __FILE__, __func__, __LINE__)
-#define cl_git_expect(expr, expected, file, line) do { \
+#define cl_git_expect(expr, expected, file, func, line) do { \
int _lg2_error; \
git_error_clear(); \
if ((_lg2_error = (expr)) != expected) \
- cl_git_report_failure(_lg2_error, expected, file, line, "Function call failed: " #expr); \
+ cl_git_report_failure(_lg2_error, expected, file, func, line, "Function call failed: " #expr); \
} while (0)
/**
@@ -31,7 +31,7 @@
#define cl_git_fail(expr) do { \
if ((expr) == 0) \
git_error_clear(), \
- cl_git_report_failure(0, 0, __FILE__, __LINE__, "Function call succeeded: " #expr); \
+ cl_git_report_failure(0, 0, __FILE__, __func__, __LINE__, "Function call succeeded: " #expr); \
} while (0)
/**
@@ -41,7 +41,7 @@
int _win32_res; \
if ((_win32_res = (expr)) == 0) { \
git_error_set(GIT_ERROR_OS, "Returned: %d, system error code: %lu", _win32_res, GetLastError()); \
- cl_git_report_failure(_win32_res, 0, __FILE__, __LINE__, "System call failed: " #expr); \
+ cl_git_report_failure(_win32_res, 0, __FILE__, __func__, __LINE__, "System call failed: " #expr); \
} \
} while(0)
@@ -58,22 +58,24 @@
typedef struct {
int error;
const char *file;
+ const char *func;
int line;
const char *expr;
char error_msg[4096];
} cl_git_thread_err;
#ifdef GIT_THREADS
-# define cl_git_thread_pass(threaderr, expr) cl_git_thread_pass_(threaderr, (expr), __FILE__, __LINE__)
+# define cl_git_thread_pass(threaderr, expr) cl_git_thread_pass_(threaderr, (expr), __FILE__, __func__, __LINE__)
#else
# define cl_git_thread_pass(threaderr, expr) cl_git_pass(expr)
#endif
-#define cl_git_thread_pass_(__threaderr, __expr, __file, __line) do { \
+#define cl_git_thread_pass_(__threaderr, __expr, __file, __func, __line) do { \
git_error_clear(); \
if ((((cl_git_thread_err *)__threaderr)->error = (__expr)) != 0) { \
const git_error *_last = git_error_last(); \
((cl_git_thread_err *)__threaderr)->file = __file; \
+ ((cl_git_thread_err *)__threaderr)->func = __func; \
((cl_git_thread_err *)__threaderr)->line = __line; \
((cl_git_thread_err *)__threaderr)->expr = "Function call failed: " #__expr; \
p_snprintf(((cl_git_thread_err *)__threaderr)->error_msg, 4096, "thread 0x%" PRIxZ " - error %d - %s", \
@@ -87,38 +89,39 @@ GIT_INLINE(void) cl_git_thread_check(void *data)
{
cl_git_thread_err *threaderr = (cl_git_thread_err *)data;
if (threaderr->error != 0)
- clar__assert(0, threaderr->file, threaderr->line, threaderr->expr, threaderr->error_msg, 1);
+ clar__assert(0, threaderr->file, threaderr->func, threaderr->line, threaderr->expr, threaderr->error_msg, 1);
}
-void cl_git_report_failure(int, int, const char *, int, const char *);
+void cl_git_report_failure(int, int, const char *, const char *, int, const char *);
-#define cl_assert_at_line(expr,file,line) \
- clar__assert((expr) != 0, file, line, "Expression is not true: " #expr, NULL, 1)
+#define cl_assert_at_line(expr,file,func,line) \
+ clar__assert((expr) != 0, file, func, line, "Expression is not true: " #expr, NULL, 1)
GIT_INLINE(void) clar__assert_in_range(
int lo, int val, int hi,
- const char *file, int line, const char *err, int should_abort)
+ const char *file, const char *func, int line,
+ const char *err, int should_abort)
{
if (lo > val || hi < val) {
char buf[128];
p_snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi);
- clar__fail(file, line, err, buf, should_abort);
+ clar__fail(file, func, line, err, buf, should_abort);
}
}
#define cl_assert_equal_sz(sz1,sz2) do { \
size_t __sz1 = (size_t)(sz1), __sz2 = (size_t)(sz2); \
- clar__assert_equal(__FILE__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, __sz1, __sz2); \
+ clar__assert_equal(__FILE__,__func__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, __sz1, __sz2); \
} while (0)
#define cl_assert_in_range(L,V,H) \
- clar__assert_in_range((L),(V),(H),__FILE__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1)
+ clar__assert_in_range((L),(V),(H),__FILE__,__func__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1)
#define cl_assert_equal_file(DATA,SIZE,PATH) \
- clar__assert_equal_file(DATA,SIZE,0,PATH,__FILE__,(int)__LINE__)
+ clar__assert_equal_file(DATA,SIZE,0,PATH,__FILE__,__func__,(int)__LINE__)
#define cl_assert_equal_file_ignore_cr(DATA,SIZE,PATH) \
- clar__assert_equal_file(DATA,SIZE,1,PATH,__FILE__,(int)__LINE__)
+ clar__assert_equal_file(DATA,SIZE,1,PATH,__FILE__,__func__,(int)__LINE__)
void clar__assert_equal_file(
const char *expected_data,
@@ -126,10 +129,11 @@ void clar__assert_equal_file(
int ignore_cr,
const char *path,
const char *file,
+ const char *func,
int line);
GIT_INLINE(void) clar__assert_equal_oid(
- const char *file, int line, const char *desc,
+ const char *file, const char *func, int line, const char *desc,
const git_oid *one, const git_oid *two)
{
if (git_oid_cmp(one, two)) {
@@ -138,12 +142,12 @@ GIT_INLINE(void) clar__assert_equal_oid(
git_oid_fmt(&err[1], one);
git_oid_fmt(&err[47], two);
- clar__fail(file, line, desc, err, 1);
+ clar__fail(file, func, line, desc, err, 1);
}
}
#define cl_assert_equal_oid(one, two) \
- clar__assert_equal_oid(__FILE__, __LINE__, \
+ clar__assert_equal_oid(__FILE__, __func__, __LINE__, \
"OID mismatch: " #one " != " #two, (one), (two))
/*
diff --git a/tests/clar_libgit2_trace.c b/tests/clar_libgit2_trace.c
index d4d8d2c..8eb6d4e 100644
--- a/tests/clar_libgit2_trace.c
+++ b/tests/clar_libgit2_trace.c
@@ -164,7 +164,7 @@ void _cl_trace_cb__event_handler(
switch (ev) {
case CL_TRACE__SUITE_BEGIN:
git_trace(GIT_TRACE_TRACE, "\n\n%s\n%s: Begin Suite", HR, suite_name);
-#if 0 && defined(GIT_MSVC_CRTDBG)
+#if 0 && defined(GIT_WIN32_LEAKCHECK)
git_win32__crtdbg_stacktrace__dump(
GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK,
suite_name);
@@ -172,7 +172,7 @@ void _cl_trace_cb__event_handler(
break;
case CL_TRACE__SUITE_END:
-#if 0 && defined(GIT_MSVC_CRTDBG)
+#if 0 && defined(GIT_WIN32_LEAKCHECK)
/* As an example of checkpointing, dump leaks within this suite.
* This may generate false positives for things like the global
* TLS error state and maybe the odb cache since they aren't
diff --git a/tests/clone/empty.c b/tests/clone/empty.c
index 8e59d2b..94847bc 100644
--- a/tests/clone/empty.c
+++ b/tests/clone/empty.c
@@ -2,6 +2,7 @@
#include "git2/clone.h"
#include "repository.h"
+#include "repo/repo_helpers.h"
static git_clone_options g_options;
static git_repository *g_repo;
@@ -22,6 +23,7 @@ void test_clone_empty__initialize(void)
void test_clone_empty__cleanup(void)
{
+ cl_fixture_cleanup("tmp_global_path");
cl_git_sandbox_cleanup();
}
@@ -66,6 +68,21 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
expected_tracked_branch_name));
}
+void test_clone_empty__respects_initialbranch_config(void)
+{
+ git_buf buf = GIT_BUF_INIT;
+
+ create_tmp_global_config("tmp_global_path", "init.defaultbranch", "my_default_branch");
+
+ cl_set_cleanup(&cleanup_repository, "./empty");
+
+ g_options.bare = true;
+ cl_git_pass(git_clone(&g_repo_cloned, "./empty_bare.git", "./empty", &g_options));
+ cl_git_pass(git_branch_upstream_name(&buf, g_repo_cloned, "refs/heads/my_default_branch"));
+ cl_assert_equal_s("refs/remotes/origin/my_default_branch", buf.ptr);
+ git_buf_dispose(&buf);
+}
+
void test_clone_empty__can_clone_an_empty_local_repo(void)
{
cl_set_cleanup(&cleanup_repository, "./empty");
diff --git a/tests/clone/nonetwork.c b/tests/clone/nonetwork.c
index 7ca4908..ec12fee 100644
--- a/tests/clone/nonetwork.c
+++ b/tests/clone/nonetwork.c
@@ -158,6 +158,8 @@ void test_clone_nonetwork__can_prevent_the_checkout_of_a_standard_repo(void)
void test_clone_nonetwork__can_checkout_given_branch(void)
{
+ git_reference *remote_head;
+
g_options.checkout_branch = "test";
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
@@ -167,6 +169,12 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
cl_assert_equal_s(git_reference_name(g_ref), "refs/heads/test");
cl_assert(git_path_exists("foo/readme.txt"));
+
+ cl_git_pass(git_reference_lookup(&remote_head, g_repo, "refs/remotes/origin/HEAD"));
+ cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(remote_head));
+ cl_assert_equal_s("refs/remotes/origin/master", git_reference_symbolic_target(remote_head));
+
+ git_reference_free(remote_head);
}
static int clone_cancel_fetch_transfer_progress_cb(
diff --git a/tests/config/global.c b/tests/config/global.c
index b64b716..ed47d02 100644
--- a/tests/config/global.c
+++ b/tests/config/global.c
@@ -81,7 +81,7 @@ void test_config_global__lock_missing_global_config(void)
git_config_entry *entry;
git_transaction *transaction;
- p_unlink("home/.gitconfig"); /* No global config */
+ (void)p_unlink("home/.gitconfig"); /* No global config */
cl_git_pass(git_config_open_default(&cfg));
cl_git_pass(git_config_lock(&transaction, cfg));
diff --git a/tests/config/include.c b/tests/config/include.c
index e2b0fc9..b702d62 100644
--- a/tests/config/include.c
+++ b/tests/config/include.c
@@ -178,6 +178,30 @@ void test_config_include__rewriting_include_refreshes_values(void)
cl_git_pass(p_unlink("second"));
}
+void test_config_include__rewriting_include_twice_refreshes_values(void)
+{
+ cl_git_mkfile("top-level", "[include]\npath = included");
+ cl_git_mkfile("included", "[foo]\nbar = first-value");
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "top-level"));
+ cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar"));
+
+ git_buf_clear(&buf);
+ cl_git_mkfile("included", "[foo]\nother = value2");
+ cl_git_fail(git_config_get_string_buf(&buf, cfg, "foo.bar"));
+ cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.other"));
+ cl_assert_equal_s(buf.ptr, "value2");
+
+ git_buf_clear(&buf);
+ cl_git_mkfile("included", "[foo]\nanother = bar");
+ cl_git_fail(git_config_get_string_buf(&buf, cfg, "foo.other"));
+ cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.another"));
+ cl_assert_equal_s(buf.ptr, "bar");
+
+ cl_git_pass(p_unlink("top-level"));
+ cl_git_pass(p_unlink("included"));
+}
+
void test_config_include__included_variables_cannot_be_deleted(void)
{
cl_git_mkfile("top-level", "[include]\npath = included\n");
diff --git a/tests/config/new.c b/tests/config/new.c
index 2f5d83d..22c330f 100644
--- a/tests/config/new.c
+++ b/tests/config/new.c
@@ -30,5 +30,5 @@ void test_config_new__write_new_config(void)
git_buf_dispose(&buf);
git_config_free(config);
- p_unlink(TEST_CONFIG);
+ cl_must_pass(p_unlink(TEST_CONFIG));
}
diff --git a/tests/config/read.c b/tests/config/read.c
index 008dfd9..badf511 100644
--- a/tests/config/read.c
+++ b/tests/config/read.c
@@ -849,6 +849,23 @@ void test_config_read__invalid_quoted_third_section(void)
git_config_free(cfg);
}
+void test_config_read__unreadable_file_ignored(void)
+{
+ git_buf buf = GIT_BUF_INIT;
+ git_config *cfg;
+ int ret;
+
+ cl_set_cleanup(&clean_test_config, NULL);
+ cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"] var = value");
+ cl_git_pass(p_chmod("./testconfig", 0));
+
+ ret = git_config_open_ondisk(&cfg, "./test/config");
+ cl_assert(ret == 0 || ret == GIT_ENOTFOUND);
+
+ git_config_free(cfg);
+ git_buf_dispose(&buf);
+}
+
void test_config_read__single_line(void)
{
git_buf buf = GIT_BUF_INIT;
@@ -911,3 +928,79 @@ void test_config_read__nosection(void)
git_buf_dispose(&buf);
git_config_free(cfg);
}
+
+enum {
+ MAP_TRUE = 0,
+ MAP_FALSE = 1,
+ MAP_ALWAYS = 2
+};
+
+static git_configmap _test_map1[] = {
+ {GIT_CONFIGMAP_STRING, "always", MAP_ALWAYS},
+ {GIT_CONFIGMAP_FALSE, NULL, MAP_FALSE},
+ {GIT_CONFIGMAP_TRUE, NULL, MAP_TRUE},
+};
+
+static git_configmap _test_map2[] = {
+ {GIT_CONFIGMAP_INT32, NULL, 0},
+};
+
+void test_config_read__get_mapped(void)
+{
+ git_config *cfg;
+ int val;
+ int known_good;
+
+ cl_set_cleanup(&clean_test_config, NULL);
+ cl_git_mkfile("./testconfig", "[header]\n"
+ " key1 = 1\n"
+ " key2 = true\n"
+ " key3\n"
+ " key4 = always\n"
+ " key5 = false\n"
+ " key6 = 0\n"
+ " key7 = never\n"
+ " key8 = On\n"
+ " key9 = off\n");
+ cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
+
+ /* check parsing bool and string */
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key1", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_TRUE);
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key2", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_TRUE);
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key3", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_TRUE);
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key8", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_TRUE);
+
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key4", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_ALWAYS);
+
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key5", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_FALSE);
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key6", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_FALSE);
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key9", _test_map1, ARRAY_SIZE(_test_map1)));
+ cl_assert_equal_i(val, MAP_FALSE);
+
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key7", _test_map1, ARRAY_SIZE(_test_map1)));
+
+ /* check parsing int values */
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key1", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_pass(git_config_get_int32(&known_good, cfg, "header.key1"));
+ cl_assert_equal_i(val, known_good);
+ cl_git_pass(git_config_get_mapped(&val, cfg, "header.key6", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_pass(git_config_get_int32(&known_good, cfg, "header.key6"));
+ cl_assert_equal_i(val, known_good);
+
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key2", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key3", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key4", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key5", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key7", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key8", _test_map2, ARRAY_SIZE(_test_map2)));
+ cl_git_fail(git_config_get_mapped(&val, cfg, "header.key9", _test_map2, ARRAY_SIZE(_test_map2)));
+
+ git_config_free(cfg);
+}
diff --git a/tests/config/stress.c b/tests/config/stress.c
index 28c3c4a..577452e 100644
--- a/tests/config/stress.c
+++ b/tests/config/stress.c
@@ -59,6 +59,11 @@ void test_config_stress__comments(void)
assert_config_value(config, "some.section.multi", "hi, this is a ; multiline comment # with ;\n special chars and other stuff !@#");
assert_config_value(config, "some.section.multi2", "good, this is a ; multiline comment # with ;\n special chars and other stuff !@#");
assert_config_value(config, "some.section.back", "this is \ba phrase");
+ assert_config_value(config, "some.section.dollar", "some $sign");
+ assert_config_value(config, "some.section.multiquotes", "!ls x ls # comment2 $HOME");
+ assert_config_value(config, "some.section.multiquotes2", "!ls x ls \"# comment2 $HOME\"");
+ assert_config_value(config, "some.section.multiquotes3", "hi # ho there are # more quotes");
+ assert_config_value(config, "some.section.quotecomment", "hi # ho there are # more");
git_config_free(config);
}
diff --git a/tests/core/assert.c b/tests/core/assert.c
new file mode 100644
index 0000000..ef75624
--- /dev/null
+++ b/tests/core/assert.c
@@ -0,0 +1,94 @@
+#ifdef GIT_ASSERT_HARD
+# undef GIT_ASSERT_HARD
+#endif
+
+#define GIT_ASSERT_HARD 0
+
+#include "clar_libgit2.h"
+
+static const char *hello_world = "hello, world";
+static const char *fail = "FAIL";
+
+static int dummy_fn(const char *myarg)
+{
+ GIT_ASSERT_ARG(myarg);
+ GIT_ASSERT_ARG(myarg != hello_world);
+ return 0;
+}
+
+static const char *fn_returns_string(const char *myarg)
+{
+ GIT_ASSERT_ARG_WITH_RETVAL(myarg, fail);
+ GIT_ASSERT_ARG_WITH_RETVAL(myarg != hello_world, fail);
+
+ return myarg;
+}
+
+static int bad_math(void)
+{
+ GIT_ASSERT(1 + 1 == 3);
+ return 42;
+}
+
+static const char *bad_returns_string(void)
+{
+ GIT_ASSERT_WITH_RETVAL(1 + 1 == 3, NULL);
+ return hello_world;
+}
+
+void test_core_assert__argument(void)
+{
+ cl_git_fail(dummy_fn(NULL));
+ cl_assert(git_error_last());
+ cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass);
+ cl_assert_equal_s("invalid argument: 'myarg'", git_error_last()->message);
+
+ cl_git_fail(dummy_fn(hello_world));
+ cl_assert(git_error_last());
+ cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass);
+ cl_assert_equal_s("invalid argument: 'myarg != hello_world'", git_error_last()->message);
+
+ cl_git_pass(dummy_fn("foo"));
+}
+
+void test_core_assert__argument_with_non_int_return_type(void)
+{
+ const char *foo = "foo";
+
+ cl_assert_equal_p(fail, fn_returns_string(NULL));
+ cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass);
+ cl_assert_equal_s("invalid argument: 'myarg'", git_error_last()->message);
+
+ cl_assert_equal_p(fail, fn_returns_string(hello_world));
+ cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass);
+ cl_assert_equal_s("invalid argument: 'myarg != hello_world'", git_error_last()->message);
+
+ cl_assert_equal_p(foo, fn_returns_string(foo));
+}
+
+void test_core_assert__argument_with_void_return_type(void)
+{
+ const char *foo = "foo";
+
+ git_error_clear();
+ fn_returns_string(hello_world);
+ cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass);
+ cl_assert_equal_s("invalid argument: 'myarg != hello_world'", git_error_last()->message);
+
+ git_error_clear();
+ cl_assert_equal_p(foo, fn_returns_string(foo));
+ cl_assert_equal_p(NULL, git_error_last());
+}
+
+void test_core_assert__internal(void)
+{
+ cl_git_fail(bad_math());
+ cl_assert(git_error_last());
+ cl_assert_equal_i(GIT_ERROR_INTERNAL, git_error_last()->klass);
+ cl_assert_equal_s("unrecoverable internal error: '1 + 1 == 3'", git_error_last()->message);
+
+ cl_assert_equal_p(NULL, bad_returns_string());
+ cl_assert(git_error_last());
+ cl_assert_equal_i(GIT_ERROR_INTERNAL, git_error_last()->klass);
+ cl_assert_equal_s("unrecoverable internal error: '1 + 1 == 3'", git_error_last()->message);
+}
diff --git a/tests/core/buffer.c b/tests/core/buffer.c
index 4e895af..22fa75e 100644
--- a/tests/core/buffer.c
+++ b/tests/core/buffer.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "buffer.h"
-#include "buf_text.h"
#include "git2/sys/hashsig.h"
#include "futils.h"
@@ -644,37 +643,37 @@ void test_core_buffer__11(void)
t.strings = t1;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "");
t.strings = t2;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "some");
t.strings = t3;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "");
t.strings = t4;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "happ");
t.strings = t5;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "happ");
t.strings = t6;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "");
t.strings = t7;
t.count = 3;
- cl_git_pass(git_buf_text_common_prefix(&a, &t));
+ cl_git_pass(git_buf_common_prefix(&a, &t));
cl_assert_equal_s(a.ptr, "");
git_buf_dispose(&a);
@@ -709,19 +708,19 @@ void test_core_buffer__puts_escaped(void)
git_buf a = GIT_BUF_INIT;
git_buf_clear(&a);
- cl_git_pass(git_buf_text_puts_escaped(&a, "this is a test", "", ""));
+ cl_git_pass(git_buf_puts_escaped(&a, "this is a test", "", ""));
cl_assert_equal_s("this is a test", a.ptr);
git_buf_clear(&a);
- cl_git_pass(git_buf_text_puts_escaped(&a, "this is a test", "t", "\\"));
+ cl_git_pass(git_buf_puts_escaped(&a, "this is a test", "t", "\\"));
cl_assert_equal_s("\\this is a \\tes\\t", a.ptr);
git_buf_clear(&a);
- cl_git_pass(git_buf_text_puts_escaped(&a, "this is a test", "i ", "__"));
+ cl_git_pass(git_buf_puts_escaped(&a, "this is a test", "i ", "__"));
cl_assert_equal_s("th__is__ __is__ a__ test", a.ptr);
git_buf_clear(&a);
- cl_git_pass(git_buf_text_puts_escape_regex(&a, "^match\\s*[A-Z]+.*"));
+ cl_git_pass(git_buf_puts_escape_regex(&a, "^match\\s*[A-Z]+.*"));
cl_assert_equal_s("\\^match\\\\s\\*\\[A-Z\\]\\+\\.\\*", a.ptr);
git_buf_dispose(&a);
@@ -731,7 +730,7 @@ static void assert_unescape(char *expected, char *to_unescape) {
git_buf buf = GIT_BUF_INIT;
cl_git_pass(git_buf_sets(&buf, to_unescape));
- git_buf_text_unescape(&buf);
+ git_buf_unescape(&buf);
cl_assert_equal_s(expected, buf.ptr);
cl_assert_equal_sz(strlen(expected), buf.size);
@@ -864,20 +863,20 @@ void test_core_buffer__classify_with_utf8(void)
git_buf b;
b.ptr = data0; b.size = b.asize = data0len;
- cl_assert(!git_buf_text_is_binary(&b));
- cl_assert(!git_buf_text_contains_nul(&b));
+ cl_assert(!git_buf_is_binary(&b));
+ cl_assert(!git_buf_contains_nul(&b));
b.ptr = data1; b.size = b.asize = data1len;
- cl_assert(!git_buf_text_is_binary(&b));
- cl_assert(!git_buf_text_contains_nul(&b));
+ cl_assert(!git_buf_is_binary(&b));
+ cl_assert(!git_buf_contains_nul(&b));
b.ptr = data2; b.size = b.asize = data2len;
- cl_assert(git_buf_text_is_binary(&b));
- cl_assert(git_buf_text_contains_nul(&b));
+ cl_assert(git_buf_is_binary(&b));
+ cl_assert(git_buf_contains_nul(&b));
b.ptr = data3; b.size = b.asize = data3len;
- cl_assert(!git_buf_text_is_binary(&b));
- cl_assert(!git_buf_text_contains_nul(&b));
+ cl_assert(!git_buf_is_binary(&b));
+ cl_assert(!git_buf_contains_nul(&b));
}
#define SIMILARITY_TEST_DATA_1 \
@@ -1074,80 +1073,80 @@ void test_core_buffer__lf_and_crlf_conversions(void)
git_buf_sets(&src, "lf\nlf\nlf\nlf\n");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("lf\r\nlf\r\nlf\r\nlf\r\n", tgt);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf(src.ptr, tgt);
git_buf_sets(&src, "\nlf\nlf\nlf\nlf\nlf");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("\r\nlf\r\nlf\r\nlf\r\nlf\r\nlf", tgt);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf(src.ptr, tgt);
/* CRLF source */
git_buf_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n", tgt);
git_buf_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf("crlf\ncrlf\ncrlf\ncrlf\n", tgt);
git_buf_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf", tgt);
git_buf_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf("\ncrlf\ncrlf\ncrlf\ncrlf\ncrlf", tgt);
/* CRLF in LF text */
git_buf_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("\r\nlf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\ncrlf\r\n", tgt);
git_buf_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf("\nlf\nlf\ncrlf\nlf\nlf\ncrlf\n", tgt);
/* LF in CRLF text */
git_buf_sets(&src, "\ncrlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("\r\ncrlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf", tgt);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf("\ncrlf\ncrlf\nlf\ncrlf\ncrlf", tgt);
/* bare CR test */
git_buf_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf("\rcrlf\r\nlf\r\nlf\r\ncr\rcrlf\r\nlf\r\ncr\r", tgt);
git_buf_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf("\rcrlf\nlf\nlf\ncr\rcrlf\nlf\ncr\r", tgt);
git_buf_sets(&src, "\rcr\r");
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf(src.ptr, tgt);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf("\rcr\r", tgt);
git_buf_dispose(&src);
@@ -1156,37 +1155,37 @@ void test_core_buffer__lf_and_crlf_conversions(void)
/* blob correspondence tests */
git_buf_sets(&src, ALL_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf(ALL_CRLF_TEXT_AS_CRLF, tgt);
git_buf_sets(&src, ALL_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf(ALL_CRLF_TEXT_AS_LF, tgt);
git_buf_dispose(&src);
git_buf_dispose(&tgt);
git_buf_sets(&src, ALL_LF_TEXT_RAW);
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf(ALL_LF_TEXT_AS_CRLF, tgt);
git_buf_sets(&src, ALL_LF_TEXT_RAW);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf(ALL_LF_TEXT_AS_LF, tgt);
git_buf_dispose(&src);
git_buf_dispose(&tgt);
git_buf_sets(&src, MORE_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf(MORE_CRLF_TEXT_AS_CRLF, tgt);
git_buf_sets(&src, MORE_CRLF_TEXT_RAW);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf(MORE_CRLF_TEXT_AS_LF, tgt);
git_buf_dispose(&src);
git_buf_dispose(&tgt);
git_buf_sets(&src, MORE_LF_TEXT_RAW);
- cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
+ cl_git_pass(git_buf_lf_to_crlf(&tgt, &src));
check_buf(MORE_LF_TEXT_AS_CRLF, tgt);
git_buf_sets(&src, MORE_LF_TEXT_RAW);
- cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
+ cl_git_pass(git_buf_crlf_to_lf(&tgt, &src));
check_buf(MORE_LF_TEXT_AS_LF, tgt);
git_buf_dispose(&src);
git_buf_dispose(&tgt);
diff --git a/tests/core/encoding.c b/tests/core/encoding.c
index a677afe..6cec246 100644
--- a/tests/core/encoding.c
+++ b/tests/core/encoding.c
@@ -14,7 +14,7 @@ void test_core_encoding__decode(void)
cl_assert(size == 4);
buf = (unsigned char *)"\xaa\xaa\xfe\xdc\xbaXY";
- cl_assert(git_decode_varint(buf, &size) == 1489279344088ULL);
+ cl_assert(git_decode_varint(buf, &size) == UINT64_C(1489279344088));
cl_assert(size == 6);
buf = (unsigned char *)"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xfe\xdc\xbaXY";
@@ -35,8 +35,8 @@ void test_core_encoding__encode(void)
cl_assert(git_encode_varint(buf, 100, 267869656) == 4);
cl_assert(!memcmp(buf, "\xfe\xdc\xbaX", 4));
- cl_assert(git_encode_varint(buf, 100, 1489279344088ULL) == 6);
+ cl_assert(git_encode_varint(buf, 100, UINT64_C(1489279344088)) == 6);
cl_assert(!memcmp(buf, "\xaa\xaa\xfe\xdc\xbaX", 6));
- cl_assert(git_encode_varint(buf, 1, 1489279344088ULL) == -1);
+ cl_assert(git_encode_varint(buf, 1, UINT64_C(1489279344088)) == -1);
}
diff --git a/tests/core/integer.c b/tests/core/integer.c
new file mode 100644
index 0000000..18364ba
--- /dev/null
+++ b/tests/core/integer.c
@@ -0,0 +1,253 @@
+#include "clar_libgit2.h"
+
+void test_core_integer__multiply_int64_no_overflow(void)
+{
+#if !defined(git__multiply_int64_overflow)
+ int64_t result = 0;
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(-0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(-0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(0x7fffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(-0x7fffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x0), INT64_C(-0x8000000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(0x1));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x1));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(-0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(-0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(-0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(-0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(0x7fffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(-0x7fffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(-0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x1));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(0x1));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(-0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(-0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(-0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(-0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(0x7fffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(-0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(-0x7fffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(0x4));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x4));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(-0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(-0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(0x2));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x4));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(0x4));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(-0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(-0x7ffffffffffffff)));
+ cl_assert_equal_i(result, INT64_C(0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(-0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(-0x800000000000000)));
+ cl_assert_equal_i(result, INT64_C(0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x4000000000000000)));
+ cl_assert_equal_i(result, INT64_C(-0x8000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(-0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(0x7ffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(-0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(0xffffffffffffffe));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(0x800000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(-0x2)));
+ cl_assert_equal_i(result, INT64_C(0x1000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x4000000000000000), INT64_C(0x2)));
+ cl_assert_equal_i(result, INT64_C(-0x8000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(0x7fffffffffffffff));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(0x0)));
+ cl_assert_equal_i(result, INT64_C(0x0));
+#endif
+}
+
+void test_core_integer__multiply_int64_overflow(void)
+{
+#if !defined(git__multiply_int64_overflow)
+ int64_t result = 0;
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x4000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x2), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x2), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7ffffffffffffff), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7ffffffffffffff), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x800000000000000), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x800000000000000), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x4000000000000000), INT64_C(0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(-0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x7fffffffffffffff), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(-0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x7fffffffffffffff), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(-0x2)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(-0x7ffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(-0x800000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(-0x7fffffffffffffff)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(-0x8000000000000000)));
+#endif
+}
+
+void test_core_integer__multiply_int64_edge_cases(void)
+{
+#if !defined(git__multiply_int64_overflow)
+ int64_t result = 0;
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(-0x1)));
+ cl_assert_equal_i(result, INT64_C(-0x8000000000000000));
+ cl_assert(!git__multiply_int64_overflow(&result, INT64_C(-0x1), INT64_C(-0x8000000000000000)));
+ cl_assert_equal_i(result, INT64_C(-0x8000000000000000));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(0x1), INT64_C(-0x8000000000000000)));
+ cl_assert(git__multiply_int64_overflow(&result, INT64_C(-0x8000000000000000), INT64_C(0x1)));
+#endif
+}
diff --git a/tests/core/link.c b/tests/core/link.c
index 1e5ed45..0493edf 100644
--- a/tests/core/link.c
+++ b/tests/core/link.c
@@ -123,7 +123,7 @@ static void do_junction(const char *old, const char *new)
reparse_buf = LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT, reparse_buflen);
cl_assert(reparse_buf);
- subst_utf16 = reparse_buf->MountPointReparseBuffer.PathBuffer;
+ subst_utf16 = reparse_buf->ReparseBuffer.MountPoint.PathBuffer;
print_utf16 = subst_utf16 + subst_utf16_len + 1;
ret = git__utf8_to_16(subst_utf16, subst_utf16_len + 1,
@@ -135,10 +135,10 @@ static void do_junction(const char *old, const char *new)
cl_assert_equal_i(print_utf16_len, ret);
reparse_buf->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
- reparse_buf->MountPointReparseBuffer.SubstituteNameOffset = 0;
- reparse_buf->MountPointReparseBuffer.SubstituteNameLength = subst_byte_len;
- reparse_buf->MountPointReparseBuffer.PrintNameOffset = (USHORT)(subst_byte_len + sizeof(WCHAR));
- reparse_buf->MountPointReparseBuffer.PrintNameLength = print_byte_len;
+ reparse_buf->ReparseBuffer.MountPoint.SubstituteNameOffset = 0;
+ reparse_buf->ReparseBuffer.MountPoint.SubstituteNameLength = subst_byte_len;
+ reparse_buf->ReparseBuffer.MountPoint.PrintNameOffset = (USHORT)(subst_byte_len + sizeof(WCHAR));
+ reparse_buf->ReparseBuffer.MountPoint.PrintNameLength = print_byte_len;
reparse_buf->ReparseDataLength = reparse_buflen - REPARSE_DATA_HEADER_SIZE;
cl_win32_pass(DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT,
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index ce11953..3f04c2a 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -150,10 +150,11 @@ static void cleanup_chmod_root(void *ref)
git_futils_rmdir_r("r", NULL, GIT_RMDIR_EMPTY_HIERARCHY);
}
-#define check_mode(X,A) check_mode_at_line((X), (A), __FILE__, __LINE__)
+#define check_mode(X,A) check_mode_at_line((X), (A), __FILE__, __func__, __LINE__)
static void check_mode_at_line(
- mode_t expected, mode_t actual, const char *file, int line)
+ mode_t expected, mode_t actual,
+ const char *file, const char *func, int line)
{
/* FAT filesystems don't support exec bit, nor group/world bits */
if (!cl_is_chmod_supported()) {
@@ -162,7 +163,7 @@ static void check_mode_at_line(
}
clar__assert_equal(
- file, line, "expected_mode != actual_mode", 1,
+ file, func, line, "expected_mode != actual_mode", 1,
"%07o", (int)expected, (int)(actual & 0777));
}
diff --git a/tests/core/path.c b/tests/core/path.c
index 2e5a4ab..eac3573 100644
--- a/tests/core/path.c
+++ b/tests/core/path.c
@@ -32,15 +32,6 @@ check_basename(const char *A, const char *B)
}
static void
-check_topdir(const char *A, const char *B)
-{
- const char *dir;
-
- cl_assert((dir = git_path_topdir(A)) != NULL);
- cl_assert_equal_s(B, dir);
-}
-
-static void
check_joinpath(const char *path_a, const char *path_b, const char *expected_path)
{
git_buf joined_path = GIT_BUF_INIT;
@@ -119,23 +110,6 @@ void test_core_path__01_basename(void)
check_basename(REP1024("/abc"), "abc");
}
-/* get the latest component in a path */
-void test_core_path__02_topdir(void)
-{
- check_topdir(".git/", ".git/");
- check_topdir("/.git/", ".git/");
- check_topdir("usr/local/.git/", ".git/");
- check_topdir("./.git/", ".git/");
- check_topdir("/usr/.git/", ".git/");
- check_topdir("/", "/");
- check_topdir("a/", "a/");
-
- cl_assert(git_path_topdir("/usr/.git") == NULL);
- cl_assert(git_path_topdir(".") == NULL);
- cl_assert(git_path_topdir("") == NULL);
- cl_assert(git_path_topdir("a") == NULL);
-}
-
/* properly join path components */
void test_core_path__05_joins(void)
{
@@ -285,7 +259,7 @@ void test_core_path__08_self_join(void)
cl_git_pass(git_buf_joinpath(&path, path.ptr + 4, "somethinglongenoughtorealloc"));
cl_assert_equal_s(path.ptr, "/baz/somethinglongenoughtorealloc");
cl_assert(asize < path.asize);
-
+
git_buf_dispose(&path);
}
diff --git a/tests/core/posix.c b/tests/core/posix.c
index 764ca19..1bb1e9c 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -190,6 +190,26 @@ void test_core_posix__symlink_resolves_to_correct_type(void)
git_buf_dispose(&contents);
}
+void test_core_posix__relative_symlink(void)
+{
+ git_buf contents = GIT_BUF_INIT;
+
+ if (!git_path_supports_symlinks(clar_sandbox_path()))
+ clar__skip();
+
+ cl_must_pass(git_futils_mkdir("dir", 0777, 0));
+ cl_git_mkfile("file", "contents");
+ cl_git_pass(p_symlink("../file", "dir/link"));
+ cl_git_pass(git_futils_readbuffer(&contents, "dir/link"));
+ cl_assert_equal_s(contents.ptr, "contents");
+
+ cl_must_pass(p_unlink("file"));
+ cl_must_pass(p_unlink("dir/link"));
+ cl_must_pass(p_rmdir("dir"));
+
+ git_buf_dispose(&contents);
+}
+
void test_core_posix__symlink_to_file_across_dirs(void)
{
git_buf contents = GIT_BUF_INIT;
diff --git a/tests/core/sha1.c b/tests/core/sha1.c
index f81d408..196b003 100644
--- a/tests/core/sha1.c
+++ b/tests/core/sha1.c
@@ -52,7 +52,7 @@ void test_core_sha1__detect_collision_attack(void)
git_oid oid, expected;
#ifdef GIT_SHA1_COLLISIONDETECT
- GIT_UNUSED(expected);
+ GIT_UNUSED(&expected);
cl_git_fail(sha1_file(&oid, FIXTURE_DIR "/shattered-1.pdf"));
cl_assert_equal_s("SHA1 collision attack detected", git_error_last()->message);
#else
diff --git a/tests/core/sortedcache.c b/tests/core/sortedcache.c
index 35e92ec..d5bbcea 100644
--- a/tests/core/sortedcache.c
+++ b/tests/core/sortedcache.c
@@ -54,7 +54,7 @@ void test_core_sortedcache__name_only(void)
cl_assert_equal_i(
GIT_ENOTFOUND, git_sortedcache_lookup_index(&pos, sc, "abc"));
- git_sortedcache_clear(sc, true);
+ cl_git_pass(git_sortedcache_clear(sc, true));
cl_assert_equal_sz(0, git_sortedcache_entrycount(sc));
cl_assert(git_sortedcache_entry(sc, 0) == NULL);
@@ -154,7 +154,7 @@ void test_core_sortedcache__in_memory(void)
cl_assert_equal_i(0, free_count);
- git_sortedcache_clear(sc, true);
+ cl_git_pass(git_sortedcache_clear(sc, true));
cl_assert_equal_i(5, free_count);
@@ -247,7 +247,7 @@ static void sortedcache_test_reload(git_sortedcache *sc)
cl_assert(git_sortedcache_lockandload(sc, &buf) > 0);
- git_sortedcache_clear(sc, false); /* clear once we already have lock */
+ cl_git_pass(git_sortedcache_clear(sc, false)); /* clear once we already have lock */
for (scan = buf.ptr; *scan; scan = after + 1) {
int val = strtol(scan, &after, 0);
diff --git a/tests/core/strtol.c b/tests/core/strtol.c
index 25dbe46..851b91b 100644
--- a/tests/core/strtol.c
+++ b/tests/core/strtol.c
@@ -30,8 +30,9 @@ void test_core_strtol__int32(void)
{
assert_l32_parses("123", 123, 10);
assert_l32_parses(" +123 ", 123, 10);
+ assert_l32_parses(" -123 ", -123, 10);
assert_l32_parses(" +2147483647 ", 2147483647, 10);
- assert_l32_parses(" -2147483648 ", -2147483648LL, 10);
+ assert_l32_parses(" -2147483648 ", INT64_C(-2147483648), 10);
assert_l32_parses("A", 10, 16);
assert_l32_parses("1x1", 1, 10);
@@ -46,10 +47,11 @@ void test_core_strtol__int64(void)
{
assert_l64_parses("123", 123, 10);
assert_l64_parses(" +123 ", 123, 10);
+ assert_l64_parses(" -123 ", -123, 10);
assert_l64_parses(" +2147483647 ", 2147483647, 10);
- assert_l64_parses(" -2147483648 ", -2147483648LL, 10);
- assert_l64_parses(" 2147483657 ", 2147483657LL, 10);
- assert_l64_parses(" -2147483657 ", -2147483657LL, 10);
+ assert_l64_parses(" -2147483648 ", INT64_C(-2147483648), 10);
+ assert_l64_parses(" 2147483657 ", INT64_C(2147483657), 10);
+ assert_l64_parses(" -2147483657 ", INT64_C(-2147483657), 10);
assert_l64_parses(" 9223372036854775807 ", INT64_MAX, 10);
assert_l64_parses(" -9223372036854775808 ", INT64_MIN, 10);
assert_l64_parses(" 0x7fffffffffffffff ", INT64_MAX, 16);
diff --git a/tests/core/structinit.c b/tests/core/structinit.c
index f9da823..b6377bd 100644
--- a/tests/core/structinit.c
+++ b/tests/core/structinit.c
@@ -48,7 +48,7 @@ static void options_cmp(void *one, void *two, size_t size, const char *name)
p_snprintf(desc, 1024, "Difference in %s at byte %" PRIuZ ": macro=%u / func=%u",
name, i, ((char *)one)[i], ((char *)two)[i]);
- clar__fail(__FILE__, __LINE__,
+ clar__fail(__FILE__, __func__, __LINE__,
"Difference between macro and function options initializer",
desc, 0);
return;
@@ -82,6 +82,11 @@ void test_core_structinit__compare(void)
git_blame_options, GIT_BLAME_OPTIONS_VERSION, \
GIT_BLAME_OPTIONS_INIT, git_blame_options_init);
+ /* blob_filter_options */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_blob_filter_options, GIT_BLOB_FILTER_OPTIONS_VERSION, \
+ GIT_BLOB_FILTER_OPTIONS_INIT, git_blob_filter_options_init);
+
/* checkout */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
diff --git a/tests/core/useragent.c b/tests/core/useragent.c
index c6c5220..2ce935b 100644
--- a/tests/core/useragent.c
+++ b/tests/core/useragent.c
@@ -1,5 +1,5 @@
#include "clar_libgit2.h"
-#include "global.h"
+#include "settings.h"
void test_core_useragent__get(void)
{
diff --git a/tests/core/utf8.c b/tests/core/utf8.c
new file mode 100644
index 0000000..021828e
--- /dev/null
+++ b/tests/core/utf8.c
@@ -0,0 +1,19 @@
+#include "clar_libgit2.h"
+
+void test_core_utf8__char_length(void)
+{
+ cl_assert_equal_i(0, git_utf8_char_length("", 0));
+ cl_assert_equal_i(1, git_utf8_char_length("$", 1));
+ cl_assert_equal_i(5, git_utf8_char_length("abcde", 5));
+ cl_assert_equal_i(1, git_utf8_char_length("\xc2\xa2", 2));
+ cl_assert_equal_i(2, git_utf8_char_length("\x24\xc2\xa2", 3));
+ cl_assert_equal_i(1, git_utf8_char_length("\xf0\x90\x8d\x88", 4));
+
+ /* uncontinued character counted as single characters */
+ cl_assert_equal_i(2, git_utf8_char_length("\x24\xc2", 2));
+ cl_assert_equal_i(3, git_utf8_char_length("\x24\xc2\xc2\xa2", 4));
+
+ /* invalid characters are counted as single characters */
+ cl_assert_equal_i(4, git_utf8_char_length("\x24\xc0\xc0\x34", 4));
+ cl_assert_equal_i(4, git_utf8_char_length("\x24\xf5\xfd\xc2", 4));
+}
diff --git a/tests/core/vector.c b/tests/core/vector.c
index a7e1a03..08cd2c1 100644
--- a/tests/core/vector.c
+++ b/tests/core/vector.c
@@ -8,7 +8,7 @@ void test_core_vector__0(void)
{
git_vector x;
int i;
- git_vector_init(&x, 1, NULL);
+ cl_git_pass(git_vector_init(&x, 1, NULL));
for (i = 0; i < 10; ++i) {
git_vector_insert(&x, (void*) 0xabc);
}
@@ -21,7 +21,7 @@ void test_core_vector__1(void)
{
git_vector x;
/* make initial capacity exact for our insertions. */
- git_vector_init(&x, 3, NULL);
+ cl_git_pass(git_vector_init(&x, 3, NULL));
git_vector_insert(&x, (void*) 0xabc);
git_vector_insert(&x, (void*) 0xdef);
git_vector_insert(&x, (void*) 0x123);
@@ -76,7 +76,7 @@ void test_core_vector__3(void)
{
git_vector x;
intptr_t i;
- git_vector_init(&x, 1, &compare_them);
+ cl_git_pass(git_vector_init(&x, 1, &compare_them));
for (i = 0; i < 10; i += 2) {
git_vector_insert_sorted(&x, (void*)(i + 1), NULL);
@@ -99,7 +99,7 @@ void test_core_vector__4(void)
{
git_vector x;
intptr_t i;
- git_vector_init(&x, 1, &compare_them);
+ cl_git_pass(git_vector_init(&x, 1, &compare_them));
for (i = 0; i < 10; i += 2) {
git_vector_insert_sorted(&x, (void*)(i + 1), NULL);
@@ -163,7 +163,7 @@ void test_core_vector__5(void)
git_vector x;
int i;
- git_vector_init(&x, 1, &compare_structs);
+ cl_git_pass(git_vector_init(&x, 1, &compare_structs));
for (i = 0; i < 10; i += 2)
git_vector_insert_sorted(&x, alloc_struct(i), &merge_structs);
@@ -205,7 +205,7 @@ void test_core_vector__remove_matching(void)
size_t i;
void *compare;
- git_vector_init(&x, 1, NULL);
+ cl_git_pass(git_vector_init(&x, 1, NULL));
git_vector_insert(&x, (void*) 0x001);
cl_assert(x.length == 1);
diff --git a/tests/core/wildmatch.c b/tests/core/wildmatch.c
index e7897c6..7c56ee7 100644
--- a/tests/core/wildmatch.c
+++ b/tests/core/wildmatch.c
@@ -3,21 +3,21 @@
#include "wildmatch.h"
#define assert_matches(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch) \
- assert_matches_(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch, __FILE__, __LINE__)
+ assert_matches_(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch, __FILE__, __func__, __LINE__)
static void assert_matches_(const char *string, const char *pattern,
char expected_wildmatch, char expected_iwildmatch,
char expected_pathmatch, char expected_ipathmatch,
- const char *file, size_t line)
+ const char *file, const char *func, size_t line)
{
if (wildmatch(pattern, string, WM_PATHNAME) == expected_wildmatch)
- clar__fail(file, line, "Test failed (wildmatch).", string, 1);
+ clar__fail(file, func, line, "Test failed (wildmatch).", string, 1);
if (wildmatch(pattern, string, WM_PATHNAME|WM_CASEFOLD) == expected_iwildmatch)
- clar__fail(file, line, "Test failed (iwildmatch).", string, 1);
+ clar__fail(file, func, line, "Test failed (iwildmatch).", string, 1);
if (wildmatch(pattern, string, 0) == expected_pathmatch)
- clar__fail(file, line, "Test failed (pathmatch).", string, 1);
+ clar__fail(file, func, line, "Test failed (pathmatch).", string, 1);
if (wildmatch(pattern, string, WM_CASEFOLD) == expected_ipathmatch)
- clar__fail(file, line, "Test failed (ipathmatch).", string, 1);
+ clar__fail(file, func, line, "Test failed (ipathmatch).", string, 1);
}
/*
diff --git a/tests/core/zstream.c b/tests/core/zstream.c
index bcbb45f..3cbcea1 100644
--- a/tests/core/zstream.c
+++ b/tests/core/zstream.c
@@ -9,7 +9,7 @@ static const char *data = "This is a test test test of This is a test";
static void assert_zlib_equal_(
const void *expected, size_t e_len,
const void *compressed, size_t c_len,
- const char *msg, const char *file, int line)
+ const char *msg, const char *file, const char *func, int line)
{
z_stream stream;
char *expanded = git__calloc(1, e_len + INFLATE_EXTRA);
@@ -26,21 +26,21 @@ static void assert_zlib_equal_(
inflateEnd(&stream);
clar__assert_equal(
- file, line, msg, 1,
+ file, func, line, msg, 1,
"%d", (int)stream.total_out, (int)e_len);
clar__assert_equal(
- file, line, "Buffer len was not exact match", 1,
+ file, func, line, "Buffer len was not exact match", 1,
"%d", (int)stream.avail_out, (int)INFLATE_EXTRA);
clar__assert(
memcmp(expanded, expected, e_len) == 0,
- file, line, "uncompressed data did not match", NULL, 1);
+ file, func, line, "uncompressed data did not match", NULL, 1);
git__free(expanded);
}
#define assert_zlib_equal(E,EL,C,CL) \
- assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, (int)__LINE__)
+ assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, __func__, (int)__LINE__)
void test_core_zstream__basic(void)
{
diff --git a/tests/diff/format_email.c b/tests/diff/format_email.c
index 28f840a..bdfc4ca 100644
--- a/tests/diff/format_email.c
+++ b/tests/diff/format_email.c
@@ -487,7 +487,7 @@ void test_diff_format_email__binary(void)
"Subject: [PATCH] Modified binary file\n" \
"\n" \
"---\n" \
- " binary.bin | Bin 3 -> 0 bytes\n" \
+ " binary.bin | Bin 3 -> 5 bytes\n" \
" 1 file changed, 0 insertions(+), 0 deletions(-)\n" \
"\n" \
"diff --git a/binary.bin b/binary.bin\n" \
@@ -496,7 +496,6 @@ void test_diff_format_email__binary(void)
"--\n" \
"libgit2 " LIBGIT2_VERSION "\n" \
"\n";
- /* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */
opts.summary = "Modified binary file";
diff --git a/tests/diff/parse.c b/tests/diff/parse.c
index b004d1e..6b6e664 100644
--- a/tests/diff/parse.c
+++ b/tests/diff/parse.c
@@ -2,7 +2,6 @@
#include "patch.h"
#include "patch_parse.h"
#include "diff_helpers.h"
-#include "../src/diff.h"
#include "../patch/patch_common.h"
@@ -108,6 +107,29 @@ void test_diff_parse__no_extended_headers(void)
git_diff_free(diff);
}
+void test_diff_parse__add_delete_no_index(void)
+{
+ const char *content =
+ "diff --git a/file.txt b/file.txt\n"
+ "new file mode 100644\n"
+ "--- /dev/null\n"
+ "+++ b/file.txt\n"
+ "@@ -0,0 +1,2 @@\n"
+ "+one\n"
+ "+two\n"
+ "diff --git a/otherfile.txt b/otherfile.txt\n"
+ "deleted file mode 100644\n"
+ "--- a/otherfile.txt\n"
+ "+++ /dev/null\n"
+ "@@ -1,1 +0,0 @@\n"
+ "-three\n";
+ git_diff *diff;
+
+ cl_git_pass(git_diff_from_buffer(
+ &diff, content, strlen(content)));
+ git_diff_free(diff);
+}
+
void test_diff_parse__invalid_patches_fails(void)
{
test_parse_invalid_diff(PATCH_CORRUPT_MISSING_NEW_FILE);
@@ -319,20 +341,20 @@ void test_diff_parse__patch_roundtrip_succeeds(void)
git_buf_dispose(&diffbuf);
}
-#define cl_assert_equal_i_src(i1,i2,file,line) clar__assert_equal(file,line,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
+#define cl_assert_equal_i_src(i1,i2,file,func,line) clar__assert_equal(file,func,line,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2))
-static void cl_git_assert_lineinfo_(int old_lineno, int new_lineno, int num_lines, git_patch *patch, size_t hunk_idx, size_t line_idx, const char *file, int lineno)
+static void cl_git_assert_lineinfo_(int old_lineno, int new_lineno, int num_lines, git_patch *patch, size_t hunk_idx, size_t line_idx, const char *file, const char *func, int lineno)
{
const git_diff_line *line;
- cl_git_expect(git_patch_get_line_in_hunk(&line, patch, hunk_idx, line_idx), 0, file, lineno);
- cl_assert_equal_i_src(old_lineno, line->old_lineno, file, lineno);
- cl_assert_equal_i_src(new_lineno, line->new_lineno, file, lineno);
- cl_assert_equal_i_src(num_lines, line->num_lines, file, lineno);
+ cl_git_expect(git_patch_get_line_in_hunk(&line, patch, hunk_idx, line_idx), 0, file, func, lineno);
+ cl_assert_equal_i_src(old_lineno, line->old_lineno, file, func, lineno);
+ cl_assert_equal_i_src(new_lineno, line->new_lineno, file, func, lineno);
+ cl_assert_equal_i_src(num_lines, line->num_lines, file, func, lineno);
}
#define cl_git_assert_lineinfo(old, new, num, p, h, l) \
- cl_git_assert_lineinfo_(old,new,num,p,h,l,__FILE__,__LINE__)
+ cl_git_assert_lineinfo_(old,new,num,p,h,l,__FILE__,__func__,__LINE__)
void test_diff_parse__issue4672(void)
diff --git a/tests/diff/patch.c b/tests/diff/patch.c
index 7eb3536..d288bba 100644
--- a/tests/diff/patch.c
+++ b/tests/diff/patch.c
@@ -4,7 +4,6 @@
#include "diff_helpers.h"
#include "diff.h"
#include "repository.h"
-#include "buf_text.h"
static git_repository *g_repo = NULL;
diff --git a/tests/diff/rename.c b/tests/diff/rename.c
index df32eeb..bd25d29 100644
--- a/tests/diff/rename.c
+++ b/tests/diff/rename.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "diff_helpers.h"
-#include "buf_text.h"
static git_repository *g_repo = NULL;
@@ -22,6 +21,8 @@ void test_diff_rename__cleanup(void)
#define RENAME_MODIFICATION_COMMIT "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13"
#define REWRITE_DELETE_COMMIT "84d8efa38af7ace2b302de0adbda16b1f1cd2e1b"
#define DELETE_RENAME_COMMIT "be053a189b0bbde545e0a3f59ce00b46ad29ce0d"
+#define BREAK_REWRITE_BASE_COMMIT "db98035f715427eef1f5e17f03e1801c05301e9e"
+#define BREAK_REWRITE_COMMIT "7e7bfb88ba9bc65fd700fee1819cf1c317aafa56"
/*
* Renames repo has:
@@ -513,7 +514,7 @@ void test_diff_rename__working_directory_changes(void)
cl_git_pass(
git_futils_readbuffer(&old_content, "renames/songof7cities.txt"));
cl_git_pass(
- git_buf_text_lf_to_crlf(&content, &old_content));
+ git_buf_lf_to_crlf(&content, &old_content));
cl_git_pass(
git_futils_writebuffer(&content, "renames/songof7cities.txt", 0, 0));
@@ -1978,3 +1979,56 @@ void test_diff_rename__delete_and_rename(void)
git_tree_free(old_tree);
git_tree_free(new_tree);
}
+
+/*
+ * The break_rewrite branch contains a testcase reduced from
+ * a real-world scenario, rather than being "constructed" like
+ * the above tests seem to be. There are two commits layered
+ * on top of the repo's initial commit; the base commit which
+ * clears out the files from the initial commit and installs
+ * four files. And then there's the modification commit which
+ * mutates the files in such a way as to trigger the bug in
+ * libgit2.
+ * commit db98035f715427eef1f5e17f03e1801c05301e9e
+ * serving.txt (deleted)
+ * sevencities.txt (deleted)
+ * AAA (313 lines)
+ * BBB (314 lines)
+ * CCC (704 lines)
+ * DDD (314 lines, identical to BBB)
+ * commit 7e7bfb88ba9bc65fd700fee1819cf1c317aafa56
+ * This deletes CCC and makes slight modifications
+ * to AAA, BBB, and DDD. The find_best_matches loop
+ * for git_diff_find_similar computes the following:
+ * CCC moved to AAA (similarity 91)
+ * CCC copied to AAA (similarity 91)
+ * DDD moved to BBB (similarity 52)
+ * CCC copied to BBB (similarity 90)
+ * BBB moved to DDD (similarity 52)
+ * CCC copied to DDD (similarity 90)
+ * The code to rewrite the diffs by resolving these
+ * copies/renames would resolve the BBB <-> DDD moves
+ * but then still leave BBB as a rename target for
+ * the deleted file CCC. Since the split flag on BBB
+ * was cleared, this would trigger an error.
+ */
+void test_diff_rename__break_rewrite(void)
+{
+ const char *old_sha = BREAK_REWRITE_BASE_COMMIT;
+ const char *new_sha = BREAK_REWRITE_COMMIT;
+ git_tree *old_tree, *new_tree;
+ git_diff *diff;
+ git_diff_find_options find_opts = GIT_DIFF_FIND_OPTIONS_INIT;
+
+ old_tree = resolve_commit_oid_to_tree(g_repo, old_sha);
+ new_tree = resolve_commit_oid_to_tree(g_repo, new_sha);
+
+ find_opts.flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES | GIT_DIFF_BREAK_REWRITES | GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY;
+
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, old_tree, new_tree, NULL));
+ cl_git_pass(git_diff_find_similar(diff, &find_opts));
+
+ git_diff_free(diff);
+ git_tree_free(old_tree);
+ git_tree_free(new_tree);
+}
diff --git a/tests/diff/stats.c b/tests/diff/stats.c
index 1503556..5457267 100644
--- a/tests/diff/stats.c
+++ b/tests/diff/stats.c
@@ -298,9 +298,8 @@ void test_diff_stats__binary(void)
{
git_buf buf = GIT_BUF_INIT;
const char *stat =
- " binary.bin | Bin 3 -> 0 bytes\n"
+ " binary.bin | Bin 3 -> 5 bytes\n"
" 1 file changed, 0 insertions(+), 0 deletions(-)\n";
- /* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */
diff_stats_from_commit_oid(
&_stats, "8d7523f6fcb2404257889abe0d96f093d9f524f9", false);
@@ -343,3 +342,38 @@ void test_diff_stats__mode_change(void)
cl_assert_equal_s(stat, git_buf_cstr(&buf));
git_buf_dispose(&buf);
}
+
+void test_diff_stats__new_file(void)
+{
+ git_diff *diff;
+ git_buf buf = GIT_BUF_INIT;
+
+ const char *input =
+ "---\n"
+ " Gurjeet Singh | 1 +\n"
+ " 1 file changed, 1 insertion(+)\n"
+ " create mode 100644 Gurjeet Singh\n"
+ "\n"
+ "diff --git a/Gurjeet Singh b/Gurjeet Singh\n"
+ "new file mode 100644\n"
+ "index 0000000..6d0ecfd\n"
+ "--- /dev/null\n"
+ "+++ b/Gurjeet Singh \n"
+ "@@ -0,0 +1 @@\n"
+ "+I'm about to try git send-email\n"
+ "-- \n"
+ "2.21.0\n";
+
+ const char *stat =
+ " Gurjeet Singh | 1 +\n"
+ " 1 file changed, 1 insertion(+)\n"
+ " create mode 100644 Gurjeet Singh\n";
+
+ cl_git_pass(git_diff_from_buffer(&diff, input, strlen(input)));
+ cl_git_pass(git_diff_get_stats(&_stats, diff));
+ cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY, 0));
+ cl_assert_equal_s(stat, git_buf_cstr(&buf));
+
+ git_buf_dispose(&buf);
+ git_diff_free(diff);
+}
diff --git a/tests/diff/submodules.c b/tests/diff/submodules.c
index 8899d3f..93223ef 100644
--- a/tests/diff/submodules.c
+++ b/tests/diff/submodules.c
@@ -18,7 +18,8 @@ void test_diff_submodules__cleanup(void)
#define get_buf_ptr(buf) ((buf)->asize ? (buf)->ptr : NULL)
static void check_diff_patches_at_line(
- git_diff *diff, const char **expected, const char *file, int line)
+ git_diff *diff, const char **expected,
+ const char *file, const char *func, int line)
{
const git_diff_delta *delta;
git_patch *patch = NULL;
@@ -30,34 +31,34 @@ static void check_diff_patches_at_line(
cl_assert((delta = git_patch_get_delta(patch)) != NULL);
if (delta->status == GIT_DELTA_UNMODIFIED) {
- cl_assert_at_line(expected[d] == NULL, file, line);
+ cl_assert_at_line(expected[d] == NULL, file, func, line);
continue;
}
if (expected[d] && !strcmp(expected[d], "<SKIP>"))
continue;
if (expected[d] && !strcmp(expected[d], "<UNTRACKED>")) {
- cl_assert_at_line(delta->status == GIT_DELTA_UNTRACKED, file, line);
+ cl_assert_at_line(delta->status == GIT_DELTA_UNTRACKED, file, func, line);
continue;
}
if (expected[d] && !strcmp(expected[d], "<END>")) {
cl_git_pass(git_patch_to_buf(&buf, patch));
- cl_assert_at_line(!strcmp(expected[d], "<END>"), file, line);
+ cl_assert_at_line(!strcmp(expected[d], "<END>"), file, func, line);
}
cl_git_pass(git_patch_to_buf(&buf, patch));
clar__assert_equal(
- file, line, "expected diff did not match actual diff", 1,
+ file, func, line, "expected diff did not match actual diff", 1,
"%s", expected[d], get_buf_ptr(&buf));
git_buf_dispose(&buf);
}
- cl_assert_at_line(expected[d] && !strcmp(expected[d], "<END>"), file, line);
+ cl_assert_at_line(expected[d] && !strcmp(expected[d], "<END>"), file, func, line);
}
#define check_diff_patches(diff, exp) \
- check_diff_patches_at_line(diff, exp, __FILE__, __LINE__)
+ check_diff_patches_at_line(diff, exp, __FILE__, __func__, __LINE__)
void test_diff_submodules__unmodified_submodule(void)
{
diff --git a/tests/diff/tree.c b/tests/diff/tree.c
index 2359a83..dfe4d25 100644
--- a/tests/diff/tree.c
+++ b/tests/diff/tree.c
@@ -524,3 +524,52 @@ void test_diff_tree__diff_configs(void)
cl_assert_equal_i(7, expect.line_adds);
cl_assert_equal_i(15, expect.line_dels);
}
+
+void test_diff_tree__diff_tree_with_empty_dir_entry_succeeds(void)
+{
+ const char *content = "This is a blob\n";
+ const git_diff_delta *delta;
+ git_oid empty_tree, invalid_tree, blob;
+ git_buf patch = GIT_BUF_INIT;
+ git_treebuilder *builder;
+
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
+
+ cl_git_pass(git_blob_create_from_buffer(&blob, g_repo, content, strlen(content)));
+ cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL));
+ cl_git_pass(git_treebuilder_write(&empty_tree, builder));
+ cl_git_pass(git_treebuilder_insert(NULL, builder, "empty_tree", &empty_tree, GIT_FILEMODE_TREE));
+ cl_git_pass(git_treebuilder_insert(NULL, builder, "blob", &blob, GIT_FILEMODE_BLOB));
+ cl_git_pass(git_treebuilder_write(&invalid_tree, builder));
+
+ cl_git_pass(git_tree_lookup(&a, g_repo, &empty_tree));
+ cl_git_pass(git_tree_lookup(&b, g_repo, &invalid_tree));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
+
+ cl_git_pass(git_diff_foreach(diff,
+ diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));
+ cl_assert_equal_i(1, expect.files);
+ cl_assert_equal_i(0, expect.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(1, expect.hunks);
+ cl_assert_equal_i(1, expect.lines);
+ cl_assert_equal_i(0, expect.line_ctxt);
+ cl_assert_equal_i(1, expect.line_adds);
+ cl_assert_equal_i(0, expect.line_dels);
+
+ cl_git_pass(git_diff_to_buf(&patch, diff, GIT_DIFF_FORMAT_PATCH));
+ cl_assert_equal_s(patch.ptr,
+ "diff --git a/blob b/blob\n"
+ "new file mode 100644\n"
+ "index 0000000..bbf2e80\n"
+ "--- /dev/null\n"
+ "+++ b/blob\n"
+ "@@ -0,0 +1 @@\n"
+ "+This is a blob\n");
+
+ cl_assert_equal_i(git_diff_num_deltas(diff), 1);
+ delta = git_diff_get_delta(diff, 0);
+ cl_assert_equal_s(delta->new_file.path, "blob");
+
+ git_treebuilder_free(builder);
+ git_buf_dispose(&patch);
+}
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 8b04452..00c52ff 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -1876,9 +1876,9 @@ void test_diff_workdir__binary_detection(void)
git_buf b = GIT_BUF_INIT;
int i;
git_buf data[10] = {
- { "1234567890", 0, 0 }, /* 0 - all ascii text control */
- { "\xC3\x85\xC3\xBC\xE2\x80\xA0\x48\xC3\xB8\xCF\x80\xCE\xA9", 0, 0 }, /* 1 - UTF-8 multibyte text */
- { "\xEF\xBB\xBF\xC3\x9C\xE2\xA4\x92\xC6\x92\x38\xC2\xA3\xE2\x82\xAC", 0, 0 }, /* 2 - UTF-8 with BOM */
+ { "1234567890", 0, 10 }, /* 0 - all ascii text control */
+ { "\xC3\x85\xC3\xBC\xE2\x80\xA0\x48\xC3\xB8\xCF\x80\xCE\xA9", 0, 14 }, /* 1 - UTF-8 multibyte text */
+ { "\xEF\xBB\xBF\xC3\x9C\xE2\xA4\x92\xC6\x92\x38\xC2\xA3\xE2\x82\xAC", 0, 16 }, /* 2 - UTF-8 with BOM */
{ STR999Z, 0, 1000 }, /* 3 - ASCII with NUL at 1000 */
{ STR3999Z, 0, 4000 }, /* 4 - ASCII with NUL at 4000 */
{ STR4000 STR3999Z "x", 0, 8001 }, /* 5 - ASCII with NUL at 8000 */
@@ -2160,3 +2160,81 @@ void test_diff_workdir__symlink_changed_on_non_symlink_platform(void)
git_tree_free(tree);
git_vector_free(&pathlist);
}
+
+void test_diff_workdir__order(void)
+{
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_buf patch = GIT_BUF_INIT;
+ git_oid tree_oid, blob_oid;
+ git_treebuilder *builder;
+ git_tree *tree;
+ git_diff *diff;
+
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
+
+ /* Build tree with a single file "abc.txt" */
+ cl_git_pass(git_blob_create_from_buffer(&blob_oid, g_repo, "foo\n", 4));
+ cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL));
+ cl_git_pass(git_treebuilder_insert(NULL, builder, "abc.txt", &blob_oid, GIT_FILEMODE_BLOB));
+ cl_git_pass(git_treebuilder_write(&tree_oid, builder));
+ cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_oid));
+
+ /* Create a directory that sorts before and one that sorts after "abc.txt" */
+ cl_git_mkfile("empty_standard_repo/abc.txt", "bar\n");
+ cl_must_pass(p_mkdir("empty_standard_repo/abb", 0777));
+ cl_must_pass(p_mkdir("empty_standard_repo/abd", 0777));
+
+ opts.flags = GIT_DIFF_INCLUDE_UNTRACKED;
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, tree, &opts));
+
+ cl_assert_equal_i(1, git_diff_num_deltas(diff));
+ cl_git_pass(git_diff_to_buf(&patch, diff, GIT_DIFF_FORMAT_PATCH));
+ cl_assert_equal_s(patch.ptr,
+ "diff --git a/abc.txt b/abc.txt\n"
+ "index 257cc56..5716ca5 100644\n"
+ "--- a/abc.txt\n"
+ "+++ b/abc.txt\n"
+ "@@ -1 +1 @@\n"
+ "-foo\n"
+ "+bar\n");
+
+ git_treebuilder_free(builder);
+ git_buf_dispose(&patch);
+ git_diff_free(diff);
+ git_tree_free(tree);
+}
+
+void test_diff_workdir__ignore_blank_lines(void)
+{
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_diff *diff;
+ git_patch *patch;
+ git_buf buf = GIT_BUF_INIT;
+
+ g_repo = cl_git_sandbox_init("rebase");
+ cl_git_rewritefile("rebase/gravy.txt", "GRAVY SOUP.\n\n\nGet eight pounds of coarse lean beef--wash it clean and lay it in your\n\npot, put in the same ingredients as for the shin soup, with the same\nquantity of water, and follow the process directed for that. Strain the\nsoup through a sieve, and serve it up clear, with nothing more than\ntoasted bread in it; two table-spoonsful of mushroom catsup will add a\nfine flavour to the soup!\n");
+
+ /* Perform the diff normally */
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_patch_from_diff(&patch, diff, 0));
+ cl_git_pass(git_patch_to_buf(&buf, patch));
+
+ cl_assert_equal_s("diff --git a/gravy.txt b/gravy.txt\nindex c4e6cca..3c617e6 100644\n--- a/gravy.txt\n+++ b/gravy.txt\n@@ -1,8 +1,10 @@\n GRAVY SOUP.\n \n+\n Get eight pounds of coarse lean beef--wash it clean and lay it in your\n+\n pot, put in the same ingredients as for the shin soup, with the same\n quantity of water, and follow the process directed for that. Strain the\n soup through a sieve, and serve it up clear, with nothing more than\n toasted bread in it; two table-spoonsful of mushroom catsup will add a\n-fine flavour to the soup.\n+fine flavour to the soup!\n", buf.ptr);
+
+ git_buf_dispose(&buf);
+ git_patch_free(patch);
+ git_diff_free(diff);
+
+ /* Perform the diff ignoring blank lines */
+ opts.flags |= GIT_DIFF_IGNORE_BLANK_LINES;
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_patch_from_diff(&patch, diff, 0));
+ cl_git_pass(git_patch_to_buf(&buf, patch));
+
+ cl_assert_equal_s("diff --git a/gravy.txt b/gravy.txt\nindex c4e6cca..3c617e6 100644\n--- a/gravy.txt\n+++ b/gravy.txt\n@@ -5,4 +7,4 @@ pot, put in the same ingredients as for the shin soup, with the same\n quantity of water, and follow the process directed for that. Strain the\n soup through a sieve, and serve it up clear, with nothing more than\n toasted bread in it; two table-spoonsful of mushroom catsup will add a\n-fine flavour to the soup.\n+fine flavour to the soup!\n", buf.ptr);
+
+ git_buf_dispose(&buf);
+ git_patch_free(patch);
+ git_diff_free(diff);
+}
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c
index 6cea6d1..6881af4 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/fetchhead/nonetwork.c
@@ -82,7 +82,7 @@ void test_fetchhead_nonetwork__write(void)
int equals = 0;
size_t i;
- git_vector_init(&fetchhead_vector, 6, NULL);
+ cl_git_pass(git_vector_init(&fetchhead_vector, 6, NULL));
cl_set_cleanup(&cleanup_repository, "./test1");
cl_git_pass(git_repository_init(&g_repo, "./test1", 0));
@@ -319,6 +319,16 @@ static int assert_master_for_merge(const char *ref, const char *url, const git_o
return 0;
}
+static int assert_none_for_merge(const char *ref, const char *url, const git_oid *id, unsigned int is_merge, void *data)
+{
+ GIT_UNUSED(ref);
+ GIT_UNUSED(url);
+ GIT_UNUSED(id);
+ GIT_UNUSED(data);
+
+ return is_merge ? -1 : 0;
+}
+
void test_fetchhead_nonetwork__unborn_with_upstream(void)
{
git_repository *repo;
@@ -366,6 +376,25 @@ void test_fetchhead_nonetwork__fetch_into_repo_with_symrefs(void)
cl_git_sandbox_cleanup();
}
+void test_fetchhead_nonetwork__fetch_into_repo_with_invalid_head(void)
+{
+ git_remote *remote;
+ char *strings[] = { "refs/heads/*:refs/remotes/origin/*" };
+ git_strarray refspecs = { strings, 1 };
+
+ cl_set_cleanup(&cleanup_repository, "./test1");
+ cl_git_pass(git_repository_init(&g_repo, "./test1", 0));
+
+ /* HEAD pointing to nonexistent branch */
+ cl_git_rewritefile("./test1/.git/HEAD", "ref: refs/heads/\n");
+
+ cl_git_pass(git_remote_create_anonymous(&remote, g_repo, cl_fixture("testrepo.git")));
+ cl_git_pass(git_remote_fetch(remote, &refspecs, NULL, NULL));
+ cl_git_pass(git_repository_fetchhead_foreach(g_repo, assert_none_for_merge, NULL));
+
+ git_remote_free(remote);
+}
+
void test_fetchhead_nonetwork__quote_in_branch_name(void)
{
cl_set_cleanup(&cleanup_repository, "./test1");
diff --git a/tests/filter/bare.c b/tests/filter/bare.c
index 430931e..f8e3423 100644
--- a/tests/filter/bare.c
+++ b/tests/filter/bare.c
@@ -10,7 +10,7 @@ void test_filter_bare__initialize(void)
cl_git_pass(git_repository_open(&g_repo, "crlf.git"));
filter_opts.flags |= GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES;
- filter_opts.flags |= GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD;
+ filter_opts.flags |= GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD;
}
void test_filter_bare__cleanup(void)
@@ -132,3 +132,63 @@ void test_filter_bare__sanitizes(void)
git_blob_free(blob);
}
+void test_filter_bare__from_specific_commit_one(void)
+{
+ git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
+ git_blob *blob;
+ git_buf buf = { 0 };
+ git_oid commit_id;
+
+ cl_git_pass(git_oid_fromstr(&commit_id, "b8986fec0f7bde90f78ac72706e782d82f24f2f0"));
+
+ opts.flags |= GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES;
+ opts.flags |= GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT;
+ opts.commit_id = &commit_id;
+
+ cl_git_pass(git_revparse_single(
+ (git_object **)&blob, g_repo, "055c872")); /* ident */
+
+ cl_assert_equal_s("$Id$\n", git_blob_rawcontent(blob));
+
+ cl_git_pass(git_blob_filter(&buf, blob, "ident.bin", &opts));
+ cl_assert_equal_s("$Id$\n", buf.ptr);
+
+ cl_git_pass(git_blob_filter(&buf, blob, "ident.identlf", &opts));
+ cl_assert_equal_s("$Id: 055c8729cdcc372500a08db659c045e16c4409fb $\n", buf.ptr);
+
+ git_buf_dispose(&buf);
+ git_blob_free(blob);
+}
+
+void test_filter_bare__from_specific_commit_with_no_attributes_file(void)
+{
+ git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
+ git_blob *blob;
+ git_buf buf = { 0 };
+ git_oid commit_id;
+
+ cl_git_pass(git_oid_fromstr(&commit_id, "5afb6a14a864e30787857dd92af837e8cdd2cb1b"));
+
+ opts.flags |= GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES;
+ opts.flags |= GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT;
+ opts.commit_id = &commit_id;
+
+ cl_git_pass(git_revparse_single(
+ (git_object **)&blob, g_repo, "799770d")); /* all-lf */
+
+ cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
+
+ cl_git_pass(git_blob_filter(&buf, blob, "file.bin", &opts));
+ cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+ /* we never convert CRLF -> LF on platforms that have LF */
+ cl_git_pass(git_blob_filter(&buf, blob, "file.lf", &opts));
+ cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+ /* we never convert CRLF -> LF on platforms that have LF */
+ cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", &opts));
+ cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+ git_buf_dispose(&buf);
+ git_blob_free(blob);
+}
diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c
index a266005..bc9c7f2 100644
--- a/tests/filter/crlf.c
+++ b/tests/filter/crlf.c
@@ -23,7 +23,9 @@ void test_filter_crlf__to_worktree(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = { 0 }, out = { 0 };
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_WORKTREE, 0));
@@ -33,10 +35,10 @@ void test_filter_crlf__to_worktree(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
- in.ptr = "Some text\nRight here\n";
- in.size = strlen(in.ptr);
+ in = "Some text\nRight here\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Some text\r\nRight here\r\n", out.ptr);
@@ -48,7 +50,9 @@ void test_filter_crlf__to_odb(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = { 0 }, out = { 0 };
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_ODB, 0));
@@ -58,10 +62,10 @@ void test_filter_crlf__to_odb(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
- in.ptr = "Some text\r\nRight here\r\n";
- in.size = strlen(in.ptr);
+ in = "Some text\r\nRight here\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Some text\nRight here\n", out.ptr);
@@ -73,7 +77,9 @@ void test_filter_crlf__with_safecrlf(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_repo_set_bool(g_repo, "core.safecrlf", true);
@@ -86,31 +92,31 @@ void test_filter_crlf__with_safecrlf(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
/* Normalized \r\n succeeds with safecrlf */
- in.ptr = "Normal\r\nCRLF\r\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Normal\r\nCRLF\r\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Normal\nCRLF\nline-endings.\n", out.ptr);
/* Mix of line endings fails with safecrlf */
- in.ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_fail(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_FILTER);
/* Normalized \n fails for autocrlf=true when safecrlf=true */
- in.ptr = "Normal\nLF\nonly\nline-endings.\n";
- in.size = strlen(in.ptr);
+ in = "Normal\nLF\nonly\nline-endings.\n";
+ in_len = strlen(in);
- cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_fail(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_FILTER);
/* String with \r but without \r\n does not fail with safecrlf */
- in.ptr = "Normal\nCR only\rand some more\nline-endings.\n";
- in.size = strlen(in.ptr);
+ in = "Normal\nCR only\rand some more\nline-endings.\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Normal\nCR only\rand some more\nline-endings.\n", out.ptr);
git_filter_list_free(fl);
@@ -121,7 +127,9 @@ void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_repo_set_bool(g_repo, "core.safecrlf", true);
@@ -134,25 +142,25 @@ void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
/* Normalized \r\n succeeds with safecrlf */
- in.ptr = "Normal\r\nCRLF\r\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Normal\r\nCRLF\r\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Normal\nCRLF\nline-endings.\n", out.ptr);
/* Mix of line endings fails with safecrlf, but allowed to pass */
- in.ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
/* TODO: check for warning */
cl_assert_equal_s("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n", out.ptr);
/* Normalized \n fails with safecrlf, but allowed to pass */
- in.ptr = "Normal\nLF\nonly\nline-endings.\n";
- in.size = strlen(in.ptr);
+ in = "Normal\nLF\nonly\nline-endings.\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
/* TODO: check for warning */
cl_assert_equal_s("Normal\nLF\nonly\nline-endings.\n", out.ptr);
@@ -164,7 +172,9 @@ void test_filter_crlf__no_safecrlf(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_git_pass(git_filter_list_new(
&fl, g_repo, GIT_FILTER_TO_ODB, 0));
@@ -175,24 +185,24 @@ void test_filter_crlf__no_safecrlf(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
/* Normalized \r\n succeeds with safecrlf */
- in.ptr = "Normal\r\nCRLF\r\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Normal\r\nCRLF\r\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Normal\nCRLF\nline-endings.\n", out.ptr);
/* Mix of line endings fails with safecrlf */
- in.ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n", out.ptr);
/* Normalized \n fails with safecrlf */
- in.ptr = "Normal\nLF\nonly\nline-endings.\n";
- in.size = strlen(in.ptr);
+ in = "Normal\nLF\nonly\nline-endings.\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Normal\nLF\nonly\nline-endings.\n", out.ptr);
git_filter_list_free(fl);
@@ -203,7 +213,9 @@ void test_filter_crlf__safecrlf_warn(void)
{
git_filter_list *fl;
git_filter *crlf;
- git_buf in = {0}, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_repo_set_string(g_repo, "core.safecrlf", "warn");
@@ -216,26 +228,26 @@ void test_filter_crlf__safecrlf_warn(void)
cl_git_pass(git_filter_list_push(fl, crlf, NULL));
/* Normalized \r\n succeeds with safecrlf=warn */
- in.ptr = "Normal\r\nCRLF\r\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Normal\r\nCRLF\r\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_s("Normal\nCRLF\nline-endings.\n", out.ptr);
/* Mix of line endings succeeds with safecrlf=warn */
- in.ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
- in.size = strlen(in.ptr);
+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
/* TODO: check for warning */
cl_assert_equal_s("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n", out.ptr);
/* Normalized \n is reversible, so does not fail with safecrlf=warn */
- in.ptr = "Normal\nLF\nonly\nline-endings.\n";
- in.size = strlen(in.ptr);
+ in = "Normal\nLF\nonly\nline-endings.\n";
+ in_len = strlen(in);
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
- cl_assert_equal_s(in.ptr, out.ptr);
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
+ cl_assert_equal_s(in, out.ptr);
git_filter_list_free(fl);
git_buf_dispose(&out);
diff --git a/tests/filter/custom.c b/tests/filter/custom.c
index fe2025f..57cef33 100644
--- a/tests/filter/custom.c
+++ b/tests/filter/custom.c
@@ -2,7 +2,6 @@
#include "posix.h"
#include "blob.h"
#include "filter.h"
-#include "buf_text.h"
#include "git2/sys/filter.h"
#include "git2/sys/repository.h"
#include "custom_helpers.h"
@@ -95,13 +94,17 @@ static void register_custom_filters(void)
void test_filter_custom__to_odb(void)
{
git_filter_list *fl;
- git_buf out = { 0 };
- git_buf in = GIT_BUF_INIT_CONST(workdir_data, strlen(workdir_data));
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "herofile", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ in = workdir_data;
+ in_len = strlen(workdir_data);
+
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_i(BITFLIPPED_AND_REVERSED_DATA_LEN, out.size);
@@ -115,14 +118,17 @@ void test_filter_custom__to_odb(void)
void test_filter_custom__to_workdir(void)
{
git_filter_list *fl;
- git_buf out = { 0 };
- git_buf in = GIT_BUF_INIT_CONST(
- bitflipped_and_reversed_data, BITFLIPPED_AND_REVERSED_DATA_LEN);
+ git_buf out = GIT_BUF_INIT;
+ const char *in;
+ size_t in_len;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "herofile", GIT_FILTER_TO_WORKTREE, 0));
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ in = (char *)bitflipped_and_reversed_data;
+ in_len = BITFLIPPED_AND_REVERSED_DATA_LEN;
+
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, in, in_len));
cl_assert_equal_i(strlen(workdir_data), out.size);
@@ -246,12 +252,16 @@ void test_filter_custom__erroneous_filter_fails(void)
{
git_filter_list *filters;
git_buf out = GIT_BUF_INIT;
- git_buf in = GIT_BUF_INIT_CONST(workdir_data, strlen(workdir_data));
+ const char *in;
+ size_t in_len;
cl_git_pass(git_filter_list_load(
&filters, g_repo, NULL, "villain", GIT_FILTER_TO_WORKTREE, 0));
- cl_git_fail(git_filter_list_apply_to_data(&out, filters, &in));
+ in = workdir_data;
+ in_len = strlen(workdir_data);
+
+ cl_git_fail(git_filter_list_apply_to_buffer(&out, filters, in, in_len));
git_filter_list_free(filters);
git_buf_dispose(&out);
diff --git a/tests/filter/custom_helpers.c b/tests/filter/custom_helpers.c
index d7f2afe..233ba32 100644
--- a/tests/filter/custom_helpers.c
+++ b/tests/filter/custom_helpers.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "posix.h"
#include "filter.h"
-#include "buf_text.h"
#include "git2/sys/filter.h"
#define VERY_SECURE_ENCRYPTION(b) ((b) ^ 0xff)
diff --git a/tests/filter/stream.c b/tests/filter/stream.c
index 226092c..b6a4c3c 100644
--- a/tests/filter/stream.c
+++ b/tests/filter/stream.c
@@ -2,7 +2,6 @@
#include "posix.h"
#include "blob.h"
#include "filter.h"
-#include "buf_text.h"
#include "git2/sys/filter.h"
#include "git2/sys/repository.h"
diff --git a/tests/filter/wildcard.c b/tests/filter/wildcard.c
index 3c25ea2..ca1ba1a 100644
--- a/tests/filter/wildcard.c
+++ b/tests/filter/wildcard.c
@@ -2,7 +2,6 @@
#include "posix.h"
#include "blob.h"
#include "filter.h"
-#include "buf_text.h"
#include "git2/sys/filter.h"
#include "git2/sys/repository.h"
#include "custom_helpers.h"
@@ -123,13 +122,12 @@ static git_filter *create_wildcard_filter(void)
void test_filter_wildcard__reverse(void)
{
git_filter_list *fl;
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "hero-reverse-foo", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_buf_put(&in, (char *)input, DATA_LEN));
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, (char *)input, DATA_LEN));
cl_assert_equal_i(DATA_LEN, out.size);
@@ -138,19 +136,17 @@ void test_filter_wildcard__reverse(void)
git_filter_list_free(fl);
git_buf_dispose(&out);
- git_buf_dispose(&in);
}
void test_filter_wildcard__flip(void)
{
git_filter_list *fl;
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "hero-flip-foo", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_buf_put(&in, (char *)input, DATA_LEN));
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, (char *)input, DATA_LEN));
cl_assert_equal_i(DATA_LEN, out.size);
@@ -159,19 +155,17 @@ void test_filter_wildcard__flip(void)
git_filter_list_free(fl);
git_buf_dispose(&out);
- git_buf_dispose(&in);
}
void test_filter_wildcard__none(void)
{
git_filter_list *fl;
- git_buf in = GIT_BUF_INIT, out = GIT_BUF_INIT;
+ git_buf out = GIT_BUF_INIT;
cl_git_pass(git_filter_list_load(
&fl, g_repo, NULL, "none-foo", GIT_FILTER_TO_ODB, 0));
- cl_git_pass(git_buf_put(&in, (char *)input, DATA_LEN));
- cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
+ cl_git_pass(git_filter_list_apply_to_buffer(&out, fl, (char *)input, DATA_LEN));
cl_assert_equal_i(DATA_LEN, out.size);
@@ -180,5 +174,4 @@ void test_filter_wildcard__none(void)
git_filter_list_free(fl);
git_buf_dispose(&out);
- git_buf_dispose(&in);
}
diff --git a/tests/graph/commit_graph.c b/tests/graph/commit_graph.c
new file mode 100644
index 0000000..2ff157e
--- /dev/null
+++ b/tests/graph/commit_graph.c
@@ -0,0 +1,90 @@
+#include "clar_libgit2.h"
+
+#include <git2.h>
+
+#include "commit_graph.h"
+
+void test_graph_commit_graph__parse(void)
+{
+ git_repository *repo;
+ struct git_commit_graph_file *file;
+ struct git_commit_graph_entry e, parent;
+ git_oid id;
+ git_buf commit_graph_path = GIT_BUF_INIT;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ cl_git_pass(git_buf_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph"));
+ cl_git_pass(git_commit_graph_file_open(&file, git_buf_cstr(&commit_graph_path)));
+ cl_assert_equal_i(git_commit_graph_file_needs_refresh(file, git_buf_cstr(&commit_graph_path)), 0);
+
+ cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
+ cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ));
+ cl_assert_equal_oid(&e.sha1, &id);
+ cl_git_pass(git_oid_fromstr(&id, "418382dff1ffb8bdfba833f4d8bbcde58b1e7f47"));
+ cl_assert_equal_oid(&e.tree_oid, &id);
+ cl_assert_equal_i(e.generation, 1);
+ cl_assert_equal_i(e.commit_time, UINT64_C(1273610423));
+ cl_assert_equal_i(e.parent_count, 0);
+
+ cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
+ cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ));
+ cl_assert_equal_oid(&e.sha1, &id);
+ cl_assert_equal_i(e.generation, 5);
+ cl_assert_equal_i(e.commit_time, UINT64_C(1274813907));
+ cl_assert_equal_i(e.parent_count, 2);
+
+ cl_git_pass(git_oid_fromstr(&id, "9fd738e8f7967c078dceed8190330fc8648ee56a"));
+ cl_git_pass(git_commit_graph_entry_parent(&parent, file, &e, 0));
+ cl_assert_equal_oid(&parent.sha1, &id);
+ cl_assert_equal_i(parent.generation, 4);
+
+ cl_git_pass(git_oid_fromstr(&id, "c47800c7266a2be04c571c04d5a6614691ea99bd"));
+ cl_git_pass(git_commit_graph_entry_parent(&parent, file, &e, 1));
+ cl_assert_equal_oid(&parent.sha1, &id);
+ cl_assert_equal_i(parent.generation, 3);
+
+ git_commit_graph_file_free(file);
+ git_repository_free(repo);
+ git_buf_dispose(&commit_graph_path);
+}
+
+void test_graph_commit_graph__parse_octopus_merge(void)
+{
+ git_repository *repo;
+ struct git_commit_graph_file *file;
+ struct git_commit_graph_entry e, parent;
+ git_oid id;
+ git_buf commit_graph_path = GIT_BUF_INIT;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("merge-recursive/.gitted")));
+ cl_git_pass(git_buf_joinpath(&commit_graph_path, git_repository_path(repo), "objects/info/commit-graph"));
+ cl_git_pass(git_commit_graph_file_open(&file, git_buf_cstr(&commit_graph_path)));
+
+ cl_git_pass(git_oid_fromstr(&id, "d71c24b3b113fd1d1909998c5bfe33b86a65ee03"));
+ cl_git_pass(git_commit_graph_entry_find(&e, file, &id, GIT_OID_HEXSZ));
+ cl_assert_equal_oid(&e.sha1, &id);
+ cl_git_pass(git_oid_fromstr(&id, "348f16ffaeb73f319a75cec5b16a0a47d2d5e27c"));
+ cl_assert_equal_oid(&e.tree_oid, &id);
+ cl_assert_equal_i(e.generation, 7);
+ cl_assert_equal_i(e.commit_time, UINT64_C(1447083009));
+ cl_assert_equal_i(e.parent_count, 3);
+
+ cl_git_pass(git_oid_fromstr(&id, "ad2ace9e15f66b3d1138922e6ffdc3ea3f967fa6"));
+ cl_git_pass(git_commit_graph_entry_parent(&parent, file, &e, 0));
+ cl_assert_equal_oid(&parent.sha1, &id);
+ cl_assert_equal_i(parent.generation, 6);
+
+ cl_git_pass(git_oid_fromstr(&id, "483065df53c0f4a02cdc6b2910b05d388fc17ffb"));
+ cl_git_pass(git_commit_graph_entry_parent(&parent, file, &e, 1));
+ cl_assert_equal_oid(&parent.sha1, &id);
+ cl_assert_equal_i(parent.generation, 2);
+
+ cl_git_pass(git_oid_fromstr(&id, "815b5a1c80ca749d705c7aa0cb294a00cbedd340"));
+ cl_git_pass(git_commit_graph_entry_parent(&parent, file, &e, 2));
+ cl_assert_equal_oid(&parent.sha1, &id);
+ cl_assert_equal_i(parent.generation, 6);
+
+ git_commit_graph_file_free(file);
+ git_repository_free(repo);
+ git_buf_dispose(&commit_graph_path);
+}
diff --git a/tests/graph/reachable_from_any.c b/tests/graph/reachable_from_any.c
new file mode 100644
index 0000000..5c84164
--- /dev/null
+++ b/tests/graph/reachable_from_any.c
@@ -0,0 +1,236 @@
+#include "clar_libgit2.h"
+
+#include <git2.h>
+
+#include "commit_graph.h"
+#include "bitvec.h"
+#include "vector.h"
+
+static git_repository *repo;
+
+#define TEST_REPO_PATH "merge-recursive"
+
+void test_graph_reachable_from_any__initialize(void)
+{
+ git_oid oid;
+ git_commit *commit;
+
+ repo = cl_git_sandbox_init(TEST_REPO_PATH);
+
+ git_oid_fromstr(&oid, "539bd011c4822c560c1d17cab095006b7a10f707");
+ cl_git_pass(git_commit_lookup(&commit, repo, &oid));
+ cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD, NULL));
+ git_commit_free(commit);
+}
+
+void test_graph_reachable_from_any__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_graph_reachable_from_any__returns_correct_result(void)
+{
+ git_object *branchA1, *branchA2, *branchB1, *branchB2, *branchC1, *branchC2, *branchH1,
+ *branchH2;
+ git_oid descendants[7];
+
+ cl_git_pass(git_revparse_single(&branchA1, repo, "branchA-1"));
+ cl_git_pass(git_revparse_single(&branchA2, repo, "branchA-2"));
+ cl_git_pass(git_revparse_single(&branchB1, repo, "branchB-1"));
+ cl_git_pass(git_revparse_single(&branchB2, repo, "branchB-2"));
+ cl_git_pass(git_revparse_single(&branchC1, repo, "branchC-1"));
+ cl_git_pass(git_revparse_single(&branchC2, repo, "branchC-2"));
+ cl_git_pass(git_revparse_single(&branchH1, repo, "branchH-1"));
+ cl_git_pass(git_revparse_single(&branchH2, repo, "branchH-2"));
+
+ cl_assert_equal_i(
+ git_graph_reachable_from_any(
+ repo, git_object_id(branchH1), git_object_id(branchA1), 1),
+ 0);
+ cl_assert_equal_i(
+ git_graph_reachable_from_any(
+ repo, git_object_id(branchH1), git_object_id(branchA2), 1),
+ 0);
+
+ cl_git_pass(git_oid_cpy(&descendants[0], git_object_id(branchA1)));
+ cl_git_pass(git_oid_cpy(&descendants[1], git_object_id(branchA2)));
+ cl_git_pass(git_oid_cpy(&descendants[2], git_object_id(branchB1)));
+ cl_git_pass(git_oid_cpy(&descendants[3], git_object_id(branchB2)));
+ cl_git_pass(git_oid_cpy(&descendants[4], git_object_id(branchC1)));
+ cl_git_pass(git_oid_cpy(&descendants[5], git_object_id(branchC2)));
+ cl_git_pass(git_oid_cpy(&descendants[6], git_object_id(branchH2)));
+ cl_assert_equal_i(
+ git_graph_reachable_from_any(repo, git_object_id(branchH2), descendants, 6),
+ 0);
+ cl_assert_equal_i(
+ git_graph_reachable_from_any(repo, git_object_id(branchH2), descendants, 7),
+ 1);
+
+ git_object_free(branchA1);
+ git_object_free(branchA2);
+ git_object_free(branchB1);
+ git_object_free(branchB2);
+ git_object_free(branchC1);
+ git_object_free(branchC2);
+ git_object_free(branchH1);
+ git_object_free(branchH2);
+}
+
+struct exhaustive_state {
+ git_odb *db;
+ git_vector commits;
+};
+
+/** Get all commits from the repository. */
+static int exhaustive_commits(const git_oid *id, void *payload)
+{
+ struct exhaustive_state *mc = (struct exhaustive_state *)payload;
+ size_t header_len;
+ git_object_t header_type;
+ int error = 0;
+
+ error = git_odb_read_header(&header_len, &header_type, mc->db, id);
+ if (error < 0)
+ return error;
+
+ if (header_type == GIT_OBJECT_COMMIT) {
+ git_commit *commit = NULL;
+
+ cl_git_pass(git_commit_lookup(&commit, repo, id));
+ cl_git_pass(git_vector_insert(&mc->commits, commit));
+ }
+
+ return 0;
+}
+
+/** Compare the `git_oid`s of two `git_commit` objects. */
+static int commit_id_cmp(const void *a, const void *b)
+{
+ return git_oid_cmp(
+ git_commit_id((const git_commit *)a), git_commit_id((const git_commit *)b));
+}
+
+/** Find a `git_commit` whose ID matches the provided `git_oid` key. */
+static int id_commit_id_cmp(const void *key, const void *commit)
+{
+ return git_oid_cmp((const git_oid *)key, git_commit_id((const git_commit *)commit));
+}
+
+void test_graph_reachable_from_any__exhaustive(void)
+{
+ struct exhaustive_state mc = {
+ .db = NULL,
+ .commits = GIT_VECTOR_INIT,
+ };
+ size_t child_idx, commit_count;
+ size_t n_descendants;
+ git_commit *child_commit;
+ git_bitvec reachable;
+
+ cl_git_pass(git_repository_odb(&mc.db, repo));
+ cl_git_pass(git_odb_foreach(mc.db, &exhaustive_commits, &mc));
+ git_vector_set_cmp(&mc.commits, commit_id_cmp);
+ git_vector_sort(&mc.commits);
+ cl_git_pass(git_bitvec_init(
+ &reachable,
+ git_vector_length(&mc.commits) * git_vector_length(&mc.commits)));
+
+ commit_count = git_vector_length(&mc.commits);
+ git_vector_foreach (&mc.commits, child_idx, child_commit) {
+ unsigned int parent_i;
+
+ /* We treat each commit as being able to reach itself. */
+ git_bitvec_set(&reachable, child_idx * commit_count + child_idx, true);
+
+ for (parent_i = 0; parent_i < git_commit_parentcount(child_commit); ++parent_i) {
+ size_t parent_idx = -1;
+ cl_git_pass(git_vector_bsearch2(
+ &parent_idx,
+ &mc.commits,
+ id_commit_id_cmp,
+ git_commit_parent_id(child_commit, parent_i)));
+
+ /* We have established that parent_idx is reachable from child_idx */
+ git_bitvec_set(&reachable, parent_idx * commit_count + child_idx, true);
+ }
+ }
+
+ /* Floyd-Warshall */
+ {
+ size_t i, j, k;
+ for (k = 0; k < commit_count; ++k) {
+ for (i = 0; i < commit_count; ++i) {
+ if (!git_bitvec_get(&reachable, i * commit_count + k))
+ continue;
+ for (j = 0; j < commit_count; ++j) {
+ if (!git_bitvec_get(&reachable, k * commit_count + j))
+ continue;
+ git_bitvec_set(&reachable, i * commit_count + j, true);
+ }
+ }
+ }
+ }
+
+ /* Try 1000 subsets of 1 through 10 entries each. */
+ srand(0x223ddc4b);
+ for (n_descendants = 1; n_descendants < 10; ++n_descendants) {
+ size_t test_iteration;
+ git_oid descendants[10];
+
+ for (test_iteration = 0; test_iteration < 1000; ++test_iteration) {
+ size_t descendant_i;
+ size_t child_idx, parent_idx;
+ int expected_reachable = false, actual_reachable;
+ git_commit *child_commit, *parent_commit;
+
+ parent_idx = rand() % commit_count;
+ parent_commit = (git_commit *)git_vector_get(&mc.commits, parent_idx);
+ for (descendant_i = 0; descendant_i < n_descendants; ++descendant_i) {
+ child_idx = rand() % commit_count;
+ child_commit = (git_commit *)git_vector_get(&mc.commits, child_idx);
+ expected_reachable |= git_bitvec_get(
+ &reachable, parent_idx * commit_count + child_idx);
+ git_oid_cpy(&descendants[descendant_i],
+ git_commit_id(child_commit));
+ }
+
+ actual_reachable = git_graph_reachable_from_any(
+ repo,
+ git_commit_id(parent_commit),
+ descendants,
+ n_descendants);
+ if (actual_reachable != expected_reachable) {
+ git_buf error_message_buf = GIT_BUF_INIT;
+ char parent_oidbuf[9] = {0}, child_oidbuf[9] = {0};
+
+ cl_git_pass(git_oid_nfmt(
+ parent_oidbuf, 8, git_commit_id(parent_commit)));
+ git_buf_printf(&error_message_buf,
+ "git_graph_reachable_from_any(\"%s\", %zu, "
+ "{",
+ parent_oidbuf,
+ n_descendants);
+ for (descendant_i = 0; descendant_i < n_descendants;
+ ++descendant_i) {
+ cl_git_pass(
+ git_oid_nfmt(child_oidbuf,
+ 8,
+ &descendants[descendant_i]));
+ git_buf_printf(&error_message_buf, " \"%s\"", child_oidbuf);
+ }
+ git_buf_printf(&error_message_buf,
+ " }) = %d, expected = %d",
+ actual_reachable,
+ expected_reachable);
+ cl_check_(actual_reachable == expected_reachable,
+ git_buf_cstr(&error_message_buf));
+ }
+ }
+ }
+
+ git_vector_foreach (&mc.commits, child_idx, child_commit)
+ git_commit_free(child_commit);
+ git_bitvec_free(&reachable);
+ git_vector_free(&mc.commits);
+ git_odb_free(mc.db);
+}
diff --git a/tests/ignore/path.c b/tests/ignore/path.c
index 864fba4..d55bdc5 100644
--- a/tests/ignore/path.c
+++ b/tests/ignore/path.c
@@ -17,19 +17,20 @@ void test_ignore_path__cleanup(void)
}
static void assert_is_ignored_(
- bool expected, const char *filepath, const char *file, int line)
+ bool expected, const char *filepath,
+ const char *file, const char *func, int line)
{
int is_ignored = 0;
cl_git_expect(
- git_ignore_path_is_ignored(&is_ignored, g_repo, filepath), 0, file, line);
+ git_ignore_path_is_ignored(&is_ignored, g_repo, filepath), 0, file, func, line);
clar__assert_equal(
- file, line, "expected != is_ignored", 1, "%d",
+ file, func, line, "expected != is_ignored", 1, "%d",
(int)(expected != 0), (int)(is_ignored != 0));
}
#define assert_is_ignored(expected, filepath) \
- assert_is_ignored_(expected, filepath, __FILE__, __LINE__)
+ assert_is_ignored_(expected, filepath, __FILE__, __func__, __LINE__)
void test_ignore_path__honor_temporary_rules(void)
{
@@ -255,7 +256,7 @@ void test_ignore_path__globs_without_star(void)
void test_ignore_path__skip_gitignore_directory(void)
{
cl_git_rewritefile("attr/.git/info/exclude", "/NewFolder\n/NewFolder/NewFolder");
- p_unlink("attr/.gitignore");
+ cl_must_pass(p_unlink("attr/.gitignore"));
cl_assert(!git_path_exists("attr/.gitignore"));
p_mkdir("attr/.gitignore", 0777);
cl_git_mkfile("attr/.gitignore/garbage.txt", "new_file\n");
@@ -268,12 +269,11 @@ void test_ignore_path__skip_gitignore_directory(void)
void test_ignore_path__subdirectory_gitignore(void)
{
- p_unlink("attr/.gitignore");
+ cl_must_pass(p_unlink("attr/.gitignore"));
cl_assert(!git_path_exists("attr/.gitignore"));
cl_git_mkfile(
"attr/.gitignore",
"file1\n");
- p_mkdir("attr/dir", 0777);
cl_git_mkfile(
"attr/dir/.gitignore",
"file2/\n");
@@ -575,3 +575,11 @@ void test_ignore_path__negative_prefix_rule(void)
assert_is_ignored(true, "ff");
assert_is_ignored(false, "f");
}
+
+void test_ignore_path__negative_more_specific(void)
+{
+ cl_git_rewritefile("attr/.gitignore", "*.txt\n!/dir/test.txt\n");
+ assert_is_ignored(true, "test.txt");
+ assert_is_ignored(false, "dir/test.txt");
+ assert_is_ignored(true, "outer/dir/test.txt");
+}
diff --git a/tests/ignore/status.c b/tests/ignore/status.c
index 5e67c12..83e821b 100644
--- a/tests/ignore/status.c
+++ b/tests/ignore/status.c
@@ -17,21 +17,22 @@ void test_ignore_status__cleanup(void)
}
static void assert_ignored_(
- bool expected, const char *filepath, const char *file, int line)
+ bool expected, const char *filepath,
+ const char *file, const char *func, int line)
{
int is_ignored = 0;
cl_git_expect(
- git_status_should_ignore(&is_ignored, g_repo, filepath), 0, file, line);
+ git_status_should_ignore(&is_ignored, g_repo, filepath), 0, file, func, line);
clar__assert(
(expected != 0) == (is_ignored != 0),
- file, line, "expected != is_ignored", filepath, 1);
+ file, func, line, "expected != is_ignored", filepath, 1);
}
#define assert_ignored(expected, filepath) \
- assert_ignored_(expected, filepath, __FILE__, __LINE__)
+ assert_ignored_(expected, filepath, __FILE__, __func__, __LINE__)
#define assert_is_ignored(filepath) \
- assert_ignored_(true, filepath, __FILE__, __LINE__)
+ assert_ignored_(true, filepath, __FILE__, __func__, __LINE__)
#define refute_is_ignored(filepath) \
- assert_ignored_(false, filepath, __FILE__, __LINE__)
+ assert_ignored_(false, filepath, __FILE__, __func__, __LINE__)
void test_ignore_status__0(void)
{
@@ -69,9 +70,9 @@ void test_ignore_status__0(void)
/* confirm that ignore files were cached */
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/exclude"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".git/info/exclude"));
cl_assert(git_attr_cache__is_cached(
- g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitignore"));
+ g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".gitignore"));
}
diff --git a/tests/index/addall.c b/tests/index/addall.c
index c62c3cf..6f95f63 100644
--- a/tests/index/addall.c
+++ b/tests/index/addall.c
@@ -75,7 +75,7 @@ static void check_status_at_line(
git_repository *repo,
size_t index_adds, size_t index_dels, size_t index_mods,
size_t wt_adds, size_t wt_dels, size_t wt_mods, size_t ignores,
- size_t conflicts, const char *file, int line)
+ size_t conflicts, const char *file, const char *func, int line)
{
index_status_counts vals;
@@ -84,25 +84,25 @@ static void check_status_at_line(
cl_git_pass(git_status_foreach(repo, index_status_cb, &vals));
clar__assert_equal(
- file,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds);
+ file,func,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds);
clar__assert_equal(
- file,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels);
+ file,func,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels);
clar__assert_equal(
- file,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods);
+ file,func,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods);
clar__assert_equal(
- file,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds);
+ file,func,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds);
clar__assert_equal(
- file,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels);
+ file,func,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels);
clar__assert_equal(
- file,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods);
+ file,func,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods);
clar__assert_equal(
- file,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores);
+ file,func,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores);
clar__assert_equal(
- file,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts);
+ file,func,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts);
}
#define check_status(R,IA,ID,IM,WA,WD,WM,IG,C) \
- check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__LINE__)
+ check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__func__,__LINE__)
static void check_stat_data(git_index *index, const char *path, bool match)
{
@@ -318,11 +318,9 @@ void test_index_addall__files_in_folders(void)
void test_index_addall__hidden_files(void)
{
+#ifdef GIT_WIN32
git_index *index;
- GIT_UNUSED(index);
-
-#ifdef GIT_WIN32
addall_create_test_repo(true);
cl_git_pass(git_repository_index(&index, g_repo));
diff --git a/tests/index/bypath.c b/tests/index/bypath.c
index 21d3d3e..b32a0a7 100644
--- a/tests/index/bypath.c
+++ b/tests/index/bypath.c
@@ -49,13 +49,10 @@ void test_index_bypath__add_submodule_unregistered(void)
void test_index_bypath__add_hidden(void)
{
+#ifdef GIT_WIN32
const git_index_entry *entry;
bool hidden;
- GIT_UNUSED(entry);
- GIT_UNUSED(hidden);
-
-#ifdef GIT_WIN32
cl_git_mkfile("submod2/hidden_file", "you can't see me");
cl_git_pass(git_win32__hidden(&hidden, "submod2/hidden_file"));
diff --git a/tests/index/crlf.c b/tests/index/crlf.c
index 7aa6be4..26c19d7 100644
--- a/tests/index/crlf.c
+++ b/tests/index/crlf.c
@@ -96,7 +96,7 @@ done:
git_buf details = GIT_BUF_INIT;
git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, safecrlf=%s, attrs={%s}",
basename, cd->systype, cd->autocrlf, cd->safecrlf, cd->attrs);
- clar__fail(__FILE__, __LINE__,
+ clar__fail(__FILE__, __func__, __LINE__,
"index contents did not match expected", details.ptr, 0);
git_buf_dispose(&details);
}
diff --git a/tests/index/filemodes.c b/tests/index/filemodes.c
index af1f803..3d2bb4a 100644
--- a/tests/index/filemodes.c
+++ b/tests/index/filemodes.c
@@ -51,11 +51,11 @@ static void replace_file_with_mode(
git_buf_dispose(&content);
}
-#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__LINE__)
+#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__func__,__LINE__)
static void add_and_check_mode_(
git_index *index, const char *filename, unsigned int expect_mode,
- const char *file, int line)
+ const char *file, const char *func, int line)
{
size_t pos;
const git_index_entry *entry;
@@ -63,11 +63,11 @@ static void add_and_check_mode_(
cl_git_pass(git_index_add_bypath(index, filename));
clar__assert(!git_index_find(&pos, index, filename),
- file, line, "Cannot find index entry", NULL, 1);
+ file, func, line, "Cannot find index entry", NULL, 1);
entry = git_index_get_byindex(index, pos);
- clar__assert_equal(file, line, "Expected mode does not match index",
+ clar__assert_equal(file, func, line, "Expected mode does not match index",
1, "%07o", (unsigned int)entry->mode, (unsigned int)expect_mode);
}
@@ -153,11 +153,11 @@ void test_index_filemodes__trusted(void)
git_index_free(index);
}
-#define add_entry_and_check_mode(I,FF,X) add_entry_and_check_mode_(I,FF,X,__FILE__,__LINE__)
+#define add_entry_and_check_mode(I,FF,X) add_entry_and_check_mode_(I,FF,X,__FILE__,__func__,__LINE__)
static void add_entry_and_check_mode_(
git_index *index, bool from_file, git_filemode_t mode,
- const char *file, int line)
+ const char *file, const char *func, int line)
{
size_t pos;
const git_index_entry* entry;
@@ -169,7 +169,7 @@ static void add_entry_and_check_mode_(
if (from_file)
{
clar__assert(!git_index_find(&pos, index, "exec_off"),
- file, line, "Cannot find original index entry", NULL, 1);
+ file, func, line, "Cannot find original index entry", NULL, 1);
entry = git_index_get_byindex(index, pos);
@@ -184,21 +184,21 @@ static void add_entry_and_check_mode_(
if (from_file)
{
clar__assert(!git_index_add(index, &new_entry),
- file, line, "Cannot add index entry", NULL, 1);
+ file, func, line, "Cannot add index entry", NULL, 1);
}
else
{
const char *content = "hey there\n";
clar__assert(!git_index_add_from_buffer(index, &new_entry, content, strlen(content)),
- file, line, "Cannot add index entry from buffer", NULL, 1);
+ file, func, line, "Cannot add index entry from buffer", NULL, 1);
}
clar__assert(!git_index_find(&pos, index, "filemodes/explicit_test"),
- file, line, "Cannot find new index entry", NULL, 1);
+ file, func, line, "Cannot find new index entry", NULL, 1);
entry = git_index_get_byindex(index, pos);
- clar__assert_equal(file, line, "Expected mode does not match index",
+ clar__assert_equal(file, func, line, "Expected mode does not match index",
1, "%07o", (unsigned int)entry->mode, (unsigned int)mode);
}
diff --git a/tests/index/nsec.c b/tests/index/nsec.c
index dee1509..6edcf03 100644
--- a/tests/index/nsec.c
+++ b/tests/index/nsec.c
@@ -54,7 +54,7 @@ static bool should_expect_nsecs(void)
expect = try_create_file_with_nsec_timestamp(nsec_path.ptr);
- p_unlink(nsec_path.ptr);
+ cl_must_pass(p_unlink(nsec_path.ptr));
git_buf_dispose(&nsec_path);
diff --git a/tests/index/tests.c b/tests/index/tests.c
index 4c9deaa..d9d8371 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -566,8 +566,7 @@ void test_index_tests__cannot_add_invalid_filename(void)
{
git_repository *repo;
- p_mkdir("invalid", 0700);
-
+ cl_must_pass(p_mkdir("invalid", 0700));
cl_git_pass(git_repository_init(&repo, "./invalid", 0));
cl_must_pass(p_mkdir("./invalid/subdir", 0777));
diff --git a/tests/index/version.c b/tests/index/version.c
index 3827df8..b6c0b79 100644
--- a/tests/index/version.c
+++ b/tests/index/version.c
@@ -43,6 +43,7 @@ void test_index_version__can_write_v4(void)
"xz",
"xyzzyx"
};
+ git_repository *repo;
git_index_entry entry;
git_index *index;
size_t i;
@@ -63,7 +64,8 @@ void test_index_version__can_write_v4(void)
cl_git_pass(git_index_write(index));
git_index_free(index);
- cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_repository_open(&repo, git_repository_path(g_repo)));
+ cl_git_pass(git_repository_index(&index, repo));
cl_assert(git_index_version(index) == 4);
for (i = 0; i < ARRAY_SIZE(paths); i++) {
@@ -74,6 +76,7 @@ void test_index_version__can_write_v4(void)
}
git_index_free(index);
+ git_repository_free(repo);
}
void test_index_version__v4_uses_path_compression(void)
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index 72f8bf4..82ee363 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -637,13 +637,14 @@ void test_iterator_workdir__filesystem2(void)
git_iterator_free(i);
}
-/* Lots of empty dirs, or nearly empty ones, make the old workdir
- * iterator cry. Also, segfault.
+/*
+ * Lots of empty dirs, or nearly empty ones, make the old workdir
+ * iterator cry. Also, segfault.
*/
void test_iterator_workdir__filesystem_gunk(void)
{
- git_iterator *i;
git_buf parent = GIT_BUF_INIT;
+ git_iterator *i;
int n;
if (!cl_is_env_set("GITTEST_INVASIVE_SPEED"))
@@ -653,19 +654,18 @@ void test_iterator_workdir__filesystem_gunk(void)
for (n = 0; n < 100000; n++) {
git_buf_clear(&parent);
- git_buf_printf(&parent, "%s/refs/heads/foo/%d/subdir",
- git_repository_path(g_repo), n);
- cl_assert(!git_buf_oom(&parent));
-
+ cl_git_pass(git_buf_printf(&parent, "%s/refs/heads/foo/%d/subdir", git_repository_path(g_repo), n));
cl_git_pass(git_futils_mkdir(parent.ptr, 0775, GIT_MKDIR_PATH));
}
cl_git_pass(git_iterator_for_filesystem(&i, "testrepo/.git/refs", NULL));
- /* should only have 16 items, since we're not asking for trees to be
+ /*
+ * Should only have 17 items, since we're not asking for trees to be
* returned. the goal of this test is simply to not crash.
*/
- expect_iterator_items(i, 16, NULL, 15, NULL);
+ expect_iterator_items(i, 17, NULL, 16, NULL);
+
git_iterator_free(i);
git_buf_dispose(&parent);
}
@@ -1024,7 +1024,7 @@ static void create_paths(const char *root, int depth)
int i;
cl_git_pass(git_buf_puts(&fullpath, root));
- cl_git_pass(git_buf_putc(&fullpath, '/'));
+ cl_git_pass(git_path_to_dir(&fullpath));
root_len = fullpath.size;
diff --git a/tests/mailmap/parsing.c b/tests/mailmap/parsing.c
index e2ab05c..ba3b3a2 100644
--- a/tests/mailmap/parsing.c
+++ b/tests/mailmap/parsing.c
@@ -2,7 +2,6 @@
#include "repository.h"
#include "git2/sys/repository.h"
#include "mailmap_testdata.h"
-#include "buf_text.h"
static git_repository *g_repo;
static git_mailmap *g_mailmap;
@@ -109,7 +108,7 @@ void test_mailmap_parsing__windows_string(void)
/* Parse with windows-style line endings */
git_buf_attach_notowned(&unixbuf, string_mailmap, strlen(string_mailmap));
- cl_git_pass(git_buf_text_lf_to_crlf(&winbuf, &unixbuf));
+ cl_git_pass(git_buf_lf_to_crlf(&winbuf, &unixbuf));
cl_git_pass(git_mailmap_from_buffer(&g_mailmap, winbuf.ptr, winbuf.size));
git_buf_dispose(&winbuf);
diff --git a/tests/main.c b/tests/main.c
index 00b2bae..56751c2 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -1,6 +1,10 @@
#include "clar_libgit2.h"
#include "clar_libgit2_trace.h"
+#ifdef GIT_WIN32_LEAKCHECK
+# include "win32/w32_leakcheck.h"
+#endif
+
#ifdef _WIN32
int __cdecl main(int argc, char *argv[])
#else
@@ -14,7 +18,9 @@ int main(int argc, char *argv[])
res = git_libgit2_init();
if (res < 0) {
- fprintf(stderr, "failed to init libgit2");
+ const git_error *err = git_error_last();
+ const char *msg = err ? err->message : "unknown failure";
+ fprintf(stderr, "failed to init libgit2: %s\n", msg);
return res;
}
@@ -29,6 +35,11 @@ int main(int argc, char *argv[])
cl_global_trace_disable();
git_libgit2_shutdown();
+#ifdef GIT_WIN32_LEAKCHECK
+ if (git_win32_leakcheck_has_leaks())
+ res = res || 1;
+#endif
+
at_exit_cmd = getenv("CLAR_AT_EXIT");
if (at_exit_cmd != NULL) {
int at_exit = system(at_exit_cmd);
diff --git a/tests/merge/trees/renames.c b/tests/merge/trees/renames.c
index e0b12af..eef7bc9 100644
--- a/tests/merge/trees/renames.c
+++ b/tests/merge/trees/renames.c
@@ -274,3 +274,80 @@ void test_merge_trees_renames__submodules(void)
cl_assert(merge_test_index(index, merge_index_entries, 7));
git_index_free(index);
}
+
+void test_merge_trees_renames__cache_recomputation(void)
+{
+ git_oid blob, binary, ancestor_oid, theirs_oid, ours_oid;
+ git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
+ git_buf path = GIT_BUF_INIT;
+ git_treebuilder *builder;
+ git_tree *ancestor_tree, *their_tree, *our_tree;
+ git_index *index;
+ size_t blob_size;
+ void *data;
+ size_t i;
+
+ cl_git_pass(git_oid_fromstr(&blob, "a2d8d1824c68541cca94ffb90f79291eba495921"));
+
+ /*
+ * Create a 50MB blob that consists of NUL bytes only. It is important
+ * that this blob is of a special format, most importantly it cannot
+ * contain more than four non-consecutive newlines or NUL bytes. This
+ * is because of git_hashsig's inner workings where all files with less
+ * than four "lines" are deemed to small.
+ */
+ blob_size = 50 * 1024 * 1024;
+ cl_assert(data = git__calloc(blob_size, 1));
+ cl_git_pass(git_blob_create_from_buffer(&binary, repo, data, blob_size));
+
+ /*
+ * Create the common ancestor, which has 1000 dummy blobs and the binary
+ * blob. The dummy blobs serve as potential rename targets for the
+ * dummy blob.
+ */
+ cl_git_pass(git_treebuilder_new(&builder, repo, NULL));
+ for (i = 0; i < 1000; i++) {
+ cl_git_pass(git_buf_printf(&path, "%"PRIuZ".txt", i));
+ cl_git_pass(git_treebuilder_insert(NULL, builder, path.ptr, &blob, GIT_FILEMODE_BLOB));
+ git_buf_clear(&path);
+ }
+ cl_git_pass(git_treebuilder_insert(NULL, builder, "original.bin", &binary, GIT_FILEMODE_BLOB));
+ cl_git_pass(git_treebuilder_write(&ancestor_oid, builder));
+
+ /* We now the binary blob in our tree. */
+ cl_git_pass(git_treebuilder_remove(builder, "original.bin"));
+ cl_git_pass(git_treebuilder_insert(NULL, builder, "renamed.bin", &binary, GIT_FILEMODE_BLOB));
+ cl_git_pass(git_treebuilder_write(&ours_oid, builder));
+
+ git_treebuilder_free(builder);
+
+ /* And move everything into a subdirectory in their tree. */
+ cl_git_pass(git_treebuilder_new(&builder, repo, NULL));
+ cl_git_pass(git_treebuilder_insert(NULL, builder, "subdir", &ancestor_oid, GIT_FILEMODE_TREE));
+ cl_git_pass(git_treebuilder_write(&theirs_oid, builder));
+
+ /*
+ * Now merge ancestor, ours and theirs. As `git_hashsig` refuses to
+ * create a hash signature for the 50MB binary file, we historically
+ * didn't cache the hashsig computation for it. As a result, we now
+ * started looking up the 50MB blob and scanning it at least 1000
+ * times, which takes a long time.
+ *
+ * The number of 1000 blobs is chosen in such a way that it's
+ * noticeable when the bug creeps in again, as it takes around 12
+ * minutes on my machine to compute the following merge.
+ */
+ opts.target_limit = 5000;
+ cl_git_pass(git_tree_lookup(&ancestor_tree, repo, &ancestor_oid));
+ cl_git_pass(git_tree_lookup(&their_tree, repo, &theirs_oid));
+ cl_git_pass(git_tree_lookup(&our_tree, repo, &ours_oid));
+ cl_git_pass(git_merge_trees(&index, repo, ancestor_tree, our_tree, their_tree, &opts));
+
+ git_treebuilder_free(builder);
+ git_buf_dispose(&path);
+ git_index_free(index);
+ git_tree_free(ancestor_tree);
+ git_tree_free(their_tree);
+ git_tree_free(our_tree);
+ git__free(data);
+}
diff --git a/tests/merge/workdir/setup.c b/tests/merge/workdir/setup.c
index ad29fcd..0b85f27 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/merge/workdir/setup.c
@@ -49,7 +49,7 @@ static bool test_file_contents(const char *filename, const char *expected)
git_buf file_path_buf = GIT_BUF_INIT, file_buf = GIT_BUF_INIT;
bool equals;
- git_buf_printf(&file_path_buf, "%s/%s", git_repository_path(repo), filename);
+ git_buf_joinpath(&file_path_buf, git_repository_path(repo), filename);
cl_git_pass(git_futils_readbuffer(&file_buf, file_path_buf.ptr));
equals = (strcmp(file_buf.ptr, expected) == 0);
@@ -64,7 +64,7 @@ static void write_file_contents(const char *filename, const char *output)
{
git_buf file_path_buf = GIT_BUF_INIT;
- git_buf_printf(&file_path_buf, "%s/%s", git_repository_path(repo),
+ git_buf_joinpath(&file_path_buf, git_repository_path(repo),
filename);
cl_git_rewritefile(file_path_buf.ptr, output);
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 8043080..13f0310 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -49,7 +49,7 @@ void test_network_fetchlocal__complete(void)
cl_assert_equal_i(19, (int)refnames.count);
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
}
@@ -77,7 +77,7 @@ void test_network_fetchlocal__prune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(19, (int)refnames.count);
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2"));
@@ -90,7 +90,7 @@ void test_network_fetchlocal__prune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(18, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed"));
@@ -103,7 +103,7 @@ void test_network_fetchlocal__prune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(17, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
@@ -168,7 +168,7 @@ void test_network_fetchlocal__prune_overlapping(void)
assert_ref_exists(repo, "refs/remotes/origin/pr/42");
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(20, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs"));
cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/pull/*/head:refs/remotes/origin/pr/*"));
@@ -183,7 +183,7 @@ void test_network_fetchlocal__prune_overlapping(void)
assert_ref_exists(repo, "refs/remotes/origin/pr/42");
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(20, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs"));
cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/heads/*:refs/remotes/origin/*"));
@@ -195,7 +195,7 @@ void test_network_fetchlocal__prune_overlapping(void)
cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
git_config_free(config);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
}
@@ -224,7 +224,7 @@ void test_network_fetchlocal__fetchprune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(19, (int)refnames.count);
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2"));
@@ -237,7 +237,7 @@ void test_network_fetchlocal__fetchprune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(18, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed"));
@@ -253,7 +253,7 @@ void test_network_fetchlocal__fetchprune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(17, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
@@ -333,13 +333,13 @@ void test_network_fetchlocal__partial(void)
cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(20, (int)refnames.count); /* 18 remote + 1 local */
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
}
@@ -420,7 +420,7 @@ void test_network_fetchlocal__multi_remotes(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(33, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_remote_set_url(repo, "test_with_pushurl", cl_git_fixture_url("testrepo.git")));
cl_git_pass(git_remote_lookup(&test2, repo, "test_with_pushurl"));
@@ -429,7 +429,7 @@ void test_network_fetchlocal__multi_remotes(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(45, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(test);
git_remote_free(test2);
}
diff --git a/tests/network/refspecs.c b/tests/network/refspecs.c
index 7347590..d9e0d9e 100644
--- a/tests/network/refspecs.c
+++ b/tests/network/refspecs.c
@@ -13,7 +13,7 @@ static void assert_refspec(unsigned int direction, const char *input, bool is_ex
if (is_expected_to_be_valid)
cl_assert_equal_i(0, error);
else
- cl_assert_equal_i(GIT_ERROR, error);
+ cl_assert_equal_i(GIT_EINVALIDSPEC, error);
}
void test_network_refspecs__parsing(void)
@@ -153,7 +153,7 @@ static void assert_invalid_rtransform(const char *refspec, const char *name)
git_refspec spec;
git_buf buf = GIT_BUF_INIT;
- git_refspec__parse(&spec, refspec, true);
+ cl_git_pass(git_refspec__parse(&spec, refspec, true));
cl_git_fail(git_refspec_rtransform(&buf, &spec, name));
git_buf_dispose(&buf);
diff --git a/tests/network/remote/isvalidname.c b/tests/network/remote/isvalidname.c
index c26fbd0..a3080f6 100644
--- a/tests/network/remote/isvalidname.c
+++ b/tests/network/remote/isvalidname.c
@@ -1,17 +1,24 @@
#include "clar_libgit2.h"
+static int is_valid_name(const char *name)
+{
+ int valid = 0;
+ cl_git_pass(git_remote_name_is_valid(&valid, name));
+ return valid;
+}
+
void test_network_remote_isvalidname__can_detect_invalid_formats(void)
{
- cl_assert_equal_i(false, git_remote_is_valid_name("/"));
- cl_assert_equal_i(false, git_remote_is_valid_name("//"));
- cl_assert_equal_i(false, git_remote_is_valid_name(".lock"));
- cl_assert_equal_i(false, git_remote_is_valid_name("a.lock"));
- cl_assert_equal_i(false, git_remote_is_valid_name("/no/leading/slash"));
- cl_assert_equal_i(false, git_remote_is_valid_name("no/trailing/slash/"));
+ cl_assert_equal_i(false, is_valid_name("/"));
+ cl_assert_equal_i(false, is_valid_name("//"));
+ cl_assert_equal_i(false, is_valid_name(".lock"));
+ cl_assert_equal_i(false, is_valid_name("a.lock"));
+ cl_assert_equal_i(false, is_valid_name("/no/leading/slash"));
+ cl_assert_equal_i(false, is_valid_name("no/trailing/slash/"));
}
void test_network_remote_isvalidname__wont_hopefully_choke_on_valid_formats(void)
{
- cl_assert_equal_i(true, git_remote_is_valid_name("webmatrix"));
- cl_assert_equal_i(true, git_remote_is_valid_name("yishaigalatzer/rules"));
+ cl_assert_equal_i(true, is_valid_name("webmatrix"));
+ cl_assert_equal_i(true, is_valid_name("yishaigalatzer/rules"));
}
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index a29281d..0694a6f 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -61,7 +61,7 @@ static int urlresolve_callback(git_buf *url_resolved, const char *url, int direc
cl_assert(strcmp(url, "git://github.com/libgit2/libgit2") == 0);
cl_assert(strcmp(payload, "payload") == 0);
cl_assert(url_resolved->size == 0);
-
+
if (direction == GIT_DIRECTION_PUSH)
git_buf_sets(url_resolved, "pushresolve");
if (direction == GIT_DIRECTION_FETCH)
@@ -215,11 +215,11 @@ void test_network_remote_remotes__dup(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, _remote));
cl_assert_equal_i(1, (int)array.count);
cl_assert_equal_s("+refs/heads/*:refs/remotes/test/*", array.strings[0]);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
cl_git_pass(git_remote_get_push_refspecs(&array, _remote));
cl_assert_equal_i(0, (int)array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(dup);
}
@@ -318,7 +318,7 @@ void test_network_remote_remotes__list(void)
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 5);
- git_strarray_free(&list);
+ git_strarray_dispose(&list);
cl_git_pass(git_repository_config(&cfg, _repo));
@@ -330,7 +330,7 @@ void test_network_remote_remotes__list(void)
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 7);
- git_strarray_free(&list);
+ git_strarray_dispose(&list);
git_config_free(cfg);
}
@@ -466,13 +466,13 @@ void test_network_remote_remotes__query_refspecs(void)
for (i = 0; i < 3; i++) {
cl_assert_equal_s(fetch_refspecs[i], array.strings[i]);
}
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
cl_git_pass(git_remote_get_push_refspecs(&array, remote));
for (i = 0; i < 3; i++) {
cl_assert_equal_s(push_refspecs[i], array.strings[i]);
}
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
git_remote_delete(_repo, "test");
diff --git a/tests/network/remote/rename.c b/tests/network/remote/rename.c
index 0449575..1fd2aff 100644
--- a/tests/network/remote/rename.c
+++ b/tests/network/remote/rename.c
@@ -25,7 +25,7 @@ void test_network_remote_rename__renaming_a_remote_moves_related_configuration_s
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_existence(_repo, "remote.test.fetch", false);
assert_config_entry_existence(_repo, "remote.just/renamed.fetch", true);
@@ -39,7 +39,7 @@ void test_network_remote_rename__renaming_a_remote_updates_branch_related_config
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_value(_repo, "branch.master.remote", "just/renamed");
}
@@ -50,7 +50,7 @@ void test_network_remote_rename__renaming_a_remote_updates_default_fetchrefspec(
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/heads/*:refs/remotes/just/renamed/*");
}
@@ -71,7 +71,7 @@ void test_network_remote_rename__renaming_a_remote_without_a_fetchrefspec_doesnt
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_existence(_repo, "remote.just/renamed.fetch", false);
}
@@ -90,11 +90,11 @@ void test_network_remote_rename__renaming_a_remote_notifies_of_non_default_fetch
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(1, problems.count);
cl_assert_equal_s("+refs/*:refs/*", problems.strings[0]);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/*:refs/*");
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
}
void test_network_remote_rename__new_name_can_contain_dots(void)
@@ -103,7 +103,7 @@ void test_network_remote_rename__new_name_can_contain_dots(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just.renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_existence(_repo, "remote.just.renamed.fetch", true);
}
@@ -126,7 +126,7 @@ void test_network_remote_rename__renamed_name_is_persisted(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_git_pass(git_repository_open(&another_repo, "testrepo.git"));
cl_git_pass(git_remote_lookup(&renamed, _repo, "just/renamed"));
@@ -154,7 +154,7 @@ void test_network_remote_rename__renaming_a_remote_moves_the_underlying_referenc
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&underlying, _repo, "refs/remotes/test/master"));
cl_git_pass(git_reference_lookup(&underlying, _repo, "refs/remotes/just/renamed/master"));
@@ -176,7 +176,7 @@ void test_network_remote_rename__overwrite_ref_in_target(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
/* make sure there's only one remote-tracking branch */
cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE));
@@ -214,7 +214,7 @@ void test_network_remote_rename__symref_head(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_git_pass(git_vector_init(&refs, 2, (git_vector_cmp) git_reference_cmp));
cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE));
diff --git a/tests/network/urlparse.c b/tests/network/urlparse.c
index 1570788..91c1a52 100644
--- a/tests/network/urlparse.c
+++ b/tests/network/urlparse.c
@@ -13,7 +13,9 @@ void test_network_urlparse__cleanup(void)
git_net_url_dispose(&conndata);
}
-void test_network_urlparse__trivial(void)
+/* Hostname */
+
+void test_network_urlparse__hostname_trivial(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com/resource"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -25,7 +27,7 @@ void test_network_urlparse__trivial(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__root(void)
+void test_network_urlparse__hostname_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com/"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -37,7 +39,7 @@ void test_network_urlparse__root(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__implied_root(void)
+void test_network_urlparse__hostname_implied_root(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -49,7 +51,7 @@ void test_network_urlparse__implied_root(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__implied_root_custom_port(void)
+void test_network_urlparse__hostname_implied_root_custom_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com:42"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -61,7 +63,7 @@ void test_network_urlparse__implied_root_custom_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__implied_root_empty_port(void)
+void test_network_urlparse__hostname_implied_root_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com:"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -73,7 +75,7 @@ void test_network_urlparse__implied_root_empty_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__encoded_password(void)
+void test_network_urlparse__hostname_encoded_password(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user:pass%2fis%40bad@hostname.com:1234/"));
@@ -86,7 +88,7 @@ void test_network_urlparse__encoded_password(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__user(void)
+void test_network_urlparse__hostname_user(void)
{
cl_git_pass(git_net_url_parse(&conndata,
"https://user@example.com/resource"));
@@ -99,7 +101,7 @@ void test_network_urlparse__user(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__user_pass(void)
+void test_network_urlparse__hostname_user_pass(void)
{
/* user:pass@hostname.tld/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -113,7 +115,7 @@ void test_network_urlparse__user_pass(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__port(void)
+void test_network_urlparse__hostname_port(void)
{
/* hostname.tld:port/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -127,7 +129,7 @@ void test_network_urlparse__port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__empty_port(void)
+void test_network_urlparse__hostname_empty_port(void)
{
cl_git_pass(git_net_url_parse(&conndata, "http://example.com:/resource"));
cl_assert_equal_s(conndata.scheme, "http");
@@ -139,7 +141,7 @@ void test_network_urlparse__empty_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
}
-void test_network_urlparse__user_port(void)
+void test_network_urlparse__hostname_user_port(void)
{
/* user@hostname.tld:port/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -153,7 +155,7 @@ void test_network_urlparse__user_port(void)
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
-void test_network_urlparse__user_pass_port(void)
+void test_network_urlparse__hostname_user_pass_port(void)
{
/* user:pass@hostname.tld:port/resource */
cl_git_pass(git_net_url_parse(&conndata,
@@ -166,3 +168,390 @@ void test_network_urlparse__user_pass_port(void)
cl_assert_equal_s(conndata.password, "pass");
cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
}
+
+/* IPv4 addresses */
+
+void test_network_urlparse__ipv4_trivial(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1/resource"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_root(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1/"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_implied_root(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_implied_root_custom_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1:42"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "42");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv4_implied_root_empty_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1:"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_encoded_password(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@192.168.1.1:1234/"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "1234");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_s(conndata.password, "pass/is@bad");
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv4_user(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user@192.168.1.1/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "443");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_user_pass(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user:pass@192.168.1.1/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "443");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_s(conndata.password, "pass");
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://192.168.1.1:9191/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "9191");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv4_empty_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://192.168.1.1:/resource"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv4_user_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user@192.168.1.1:9191/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "9191");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv4_user_pass_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user:pass@192.168.1.1:9191/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "192.168.1.1");
+ cl_assert_equal_s(conndata.port, "9191");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_s(conndata.password, "pass");
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+/* IPv6 addresses */
+
+void test_network_urlparse__ipv6_trivial(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]/resource"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_root(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]/"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_implied_root(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_implied_root_custom_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]:42"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "42");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv6_implied_root_empty_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]:"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_encoded_password(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@[fe80::dcad:beff:fe00:0001]:1234/"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "1234");
+ cl_assert_equal_s(conndata.path, "/");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_s(conndata.password, "pass/is@bad");
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv6_user(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user@[fe80::dcad:beff:fe00:0001]/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "443");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_user_pass(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user:pass@[fe80::dcad:beff:fe00:0001]/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "443");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_s(conndata.password, "pass");
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://[fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "9191");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv6_empty_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata, "http://[fe80::dcad:beff:fe00:0001]:/resource"));
+ cl_assert_equal_s(conndata.scheme, "http");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "80");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_p(conndata.username, NULL);
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 1);
+}
+
+void test_network_urlparse__ipv6_user_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user@[fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "9191");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_p(conndata.password, NULL);
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv6_user_pass_port(void)
+{
+ cl_git_pass(git_net_url_parse(&conndata,
+ "https://user:pass@[fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_assert_equal_s(conndata.scheme, "https");
+ cl_assert_equal_s(conndata.host, "fe80::dcad:beff:fe00:0001");
+ cl_assert_equal_s(conndata.port, "9191");
+ cl_assert_equal_s(conndata.path, "/resource");
+ cl_assert_equal_s(conndata.username, "user");
+ cl_assert_equal_s(conndata.password, "pass");
+ cl_assert_equal_i(git_net_url_is_default_port(&conndata), 0);
+}
+
+void test_network_urlparse__ipv6_invalid_addresses(void)
+{
+ /* Opening bracket missing */
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]:42"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]:"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@fe80::dcad:beff:fe00:0001]:1234/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001]/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@fe80::dcad:beff:fe00:0001]/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001]:/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001]:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@fe80::dcad:beff:fe00:0001]:9191/resource"));
+
+ /* Closing bracket missing */
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001:42"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001:"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@[fe80::dcad:beff:fe00:0001:1234/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@[fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@[fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://[fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://[fe80::dcad:beff:fe00:0001:/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@[fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@[fe80::dcad:beff:fe00:0001:9191/resource"));
+ /* Both brackets missing */
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001:42"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001:"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass%2fis%40bad@fe80::dcad:beff:fe00:0001:1234/"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@fe80::dcad:beff:fe00:0001/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "http://fe80::dcad:beff:fe00:0001:/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user@fe80::dcad:beff:fe00:0001:9191/resource"));
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata,
+ "https://user:pass@fe80::dcad:beff:fe00:0001:9191/resource"));
+
+ /* Invalid chracter inside address */
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_net_url_parse(&conndata, "http://[fe8o::dcad:beff:fe00:0001]/resource"));
+}
diff --git a/tests/notes/notes.c b/tests/notes/notes.c
index f245766..af96867 100644
--- a/tests/notes/notes.c
+++ b/tests/notes/notes.c
@@ -400,15 +400,11 @@ void test_notes_notes__can_read_a_note_from_a_commit(void)
git_note *note;
cl_git_pass(git_oid_fromstr(&oid, "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"));
-
cl_git_pass(git_note_commit_create(¬es_commit_oid, NULL, _repo, NULL, _sig, _sig, &oid, "I decorate 4a20\n", 1));
-
- git_commit_lookup(¬es_commit, _repo, ¬es_commit_oid);
-
+ cl_git_pass(git_commit_lookup(¬es_commit, _repo, ¬es_commit_oid));
cl_assert(notes_commit);
cl_git_pass(git_note_commit_read(¬e, _repo, notes_commit, &oid));
-
cl_assert_equal_s(git_note_message(note), "I decorate 4a20\n");
git_commit_free(notes_commit);
@@ -457,7 +453,7 @@ void test_notes_notes__can_insert_a_note_in_an_existing_fanout(void)
git_note *_note;
cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125"));
-
+
for (i = 0; i < MESSAGES_COUNT; i++) {
cl_git_pass(git_note_create(¬e_oid, _repo, "refs/notes/fanout", _sig, _sig, &target_oid, messages[i], 0));
cl_git_pass(git_note_read(&_note, _repo, "refs/notes/fanout", &target_oid));
@@ -511,7 +507,7 @@ void test_notes_notes__can_remove_a_note_from_commit(void)
cl_git_pass(git_note_commit_create(¬es_commit_oid, NULL, _repo, NULL, _sig, _sig, &oid, "I decorate 4a20\n", 0));
- git_commit_lookup(&existing_notes_commit, _repo, ¬es_commit_oid);
+ cl_git_pass(git_commit_lookup(&existing_notes_commit, _repo, ¬es_commit_oid));
cl_assert(existing_notes_commit);
@@ -547,7 +543,7 @@ void test_notes_notes__removing_a_note_which_doesnt_exists_returns_ENOTFOUND(voi
cl_git_pass(git_oid_fromstr(&target_oid, "8496071c1b46c854b31185ea97743be6a8774479"));
cl_git_pass(git_note_remove(_repo, "refs/notes/fanout", _sig, _sig, &target_oid));
-
+
error = git_note_remove(_repo, "refs/notes/fanout", _sig, _sig, &target_oid);
cl_git_fail(error);
cl_assert_equal_i(GIT_ENOTFOUND, error);
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c
index 0f0f484..a8e3d30 100644
--- a/tests/object/blob/filter.c
+++ b/tests/object/blob/filter.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "posix.h"
#include "blob.h"
-#include "buf_text.h"
static git_repository *g_repo = NULL;
@@ -44,9 +43,9 @@ static git_buf_text_stats g_crlf_filtered_stats[CRLF_NUM_TEST_OBJECTS] = {
{ 0, 0, 2, 2, 2, 6, 0 },
{ 0, 0, 4, 4, 1, 31, 0 },
{ 0, 1, 1, 2, 1, 9, 5 },
- { GIT_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
- { GIT_BOM_UTF8, 0, 2, 2, 2, 27, 0 },
- { GIT_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
+ { GIT_BUF_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
+ { GIT_BUF_BOM_UTF8, 0, 2, 2, 2, 27, 0 },
+ { GIT_BUF_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
};
void test_object_blob_filter__initialize(void)
@@ -97,7 +96,7 @@ void test_object_blob_filter__stats(void)
for (i = 0; i < CRLF_NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_crlf_oids[i]));
cl_git_pass(git_blob__getbuf(&buf, blob));
- git_buf_text_gather_stats(&stats, &buf, false);
+ git_buf_gather_text_stats(&stats, &buf, false);
cl_assert_equal_i(
0, memcmp(&g_crlf_filtered_stats[i], &stats, sizeof(stats)));
git_blob_free(blob);
diff --git a/tests/object/cache.c b/tests/object/cache.c
index 3ccc325..08bf036 100644
--- a/tests/object/cache.c
+++ b/tests/object/cache.c
@@ -244,15 +244,15 @@ static void *cache_quick(void *arg)
void test_object_cache__fast_thread_rush(void)
{
- int try, th, data[THREADCOUNT*2];
+ int try, th, data[THREADCOUNT];
#ifdef GIT_THREADS
- git_thread t[THREADCOUNT*2];
+ git_thread t[THREADCOUNT];
#endif
for (try = 0; try < REPEAT; ++try) {
cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
- for (th = 0; th < THREADCOUNT*2; ++th) {
+ for (th = 0; th < THREADCOUNT; ++th) {
data[th] = th;
#ifdef GIT_THREADS
cl_git_pass(
@@ -263,7 +263,7 @@ void test_object_cache__fast_thread_rush(void)
}
#ifdef GIT_THREADS
- for (th = 0; th < THREADCOUNT*2; ++th) {
+ for (th = 0; th < THREADCOUNT; ++th) {
void *rval;
cl_git_pass(git_thread_join(&t[th], &rval));
cl_assert_equal_i(th, *((int *)rval));
diff --git a/tests/object/commit/commitstagedfile.c b/tests/object/commit/commitstagedfile.c
index 63ecfee..f7ff05c 100644
--- a/tests/object/commit/commitstagedfile.c
+++ b/tests/object/commit/commitstagedfile.c
@@ -49,9 +49,9 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
* tree 2b297e643c551e76cfa1f93810c50811382f9117
* author nulltoken <emeric.fermas@gmail.com> 1323847743 +0100
* committer nulltoken <emeric.fermas@gmail.com> 1323847743 +0100
- *
+ *
* Initial commit
- *
+ *
* diff --git a/test.txt b/test.txt
* new file mode 100644
* index 0000000..9daeafb
@@ -141,14 +141,14 @@ static void assert_commit_tree_has_n_entries(git_commit *c, int count)
git_tree_free(tree);
}
-static void assert_commit_is_head_(git_commit *c, const char *file, int line)
+static void assert_commit_is_head_(git_commit *c, const char *file, const char *func, int line)
{
git_commit *head;
cl_git_pass(git_revparse_single((git_object **)&head, repo, "HEAD"));
- clar__assert(git_oid_equal(git_commit_id(c), git_commit_id(head)), file, line, "Commit is not the HEAD", NULL, 1);
+ clar__assert(git_oid_equal(git_commit_id(c), git_commit_id(head)), file, func, line, "Commit is not the HEAD", NULL, 1);
git_commit_free(head);
}
-#define assert_commit_is_head(C) assert_commit_is_head_((C),__FILE__,__LINE__)
+#define assert_commit_is_head(C) assert_commit_is_head_((C),__FILE__,__func__,__LINE__)
void test_object_commit_commitstagedfile__amend_commit(void)
{
diff --git a/tests/object/tag/list.c b/tests/object/tag/list.c
index b8d507f..d15f092 100644
--- a/tests/object/tag/list.c
+++ b/tests/object/tag/list.c
@@ -20,7 +20,7 @@ static void ensure_tag_pattern_match(git_repository *repo,
int already_found[MAX_USED_TAGS] = { 0 };
git_strarray tag_list;
int error = 0;
- size_t sucessfully_found = 0;
+ size_t successfully_found = 0;
size_t i, j;
cl_assert(data->expected_matches <= MAX_USED_TAGS);
@@ -42,15 +42,15 @@ static void ensure_tag_pattern_match(git_repository *repo,
if (!already_found[j] && !strcmp(data->expected_results[j], tag_list.strings[i]))
{
already_found[j] = 1;
- sucessfully_found++;
+ successfully_found++;
break;
}
}
}
- cl_assert_equal_i((int)sucessfully_found, (int)data->expected_matches);
+ cl_assert_equal_i((int)successfully_found, (int)data->expected_matches);
exit:
- git_strarray_free(&tag_list);
+ git_strarray_dispose(&tag_list);
cl_git_pass(error);
}
@@ -74,7 +74,7 @@ void test_object_tag_list__list_all(void)
cl_assert_equal_i((int)tag_list.count, 6);
- git_strarray_free(&tag_list);
+ git_strarray_dispose(&tag_list);
}
static const struct pattern_match_t matches[] = {
diff --git a/tests/object/tree/write.c b/tests/object/tree/write.c
index 7b0b8ca..1bc5a50 100644
--- a/tests/object/tree/write.c
+++ b/tests/object/tree/write.c
@@ -453,7 +453,8 @@ static void test_invalid_objects(bool should_allow_invalid)
git_oid valid_blob_id, invalid_blob_id, valid_tree_id, invalid_tree_id;
#define assert_allowed(expr) \
- clar__assert(!(expr) == should_allow_invalid, __FILE__, __LINE__, \
+ clar__assert(!(expr) == should_allow_invalid, \
+ __FILE__, __func__, __LINE__, \
(should_allow_invalid ? \
"Expected function call to succeed: " #expr : \
"Expected function call to fail: " #expr), \
diff --git a/tests/odb/foreach.c b/tests/odb/foreach.c
index 7a45a57..0211238 100644
--- a/tests/odb/foreach.c
+++ b/tests/odb/foreach.c
@@ -127,7 +127,7 @@ void test_odb_foreach__files_in_objects_dir(void)
cl_fixture_sandbox("testrepo.git");
cl_git_pass(git_repository_open(&repo, "testrepo.git"));
- cl_git_pass(git_buf_printf(&buf, "%s/objects/somefile", git_repository_path(repo)));
+ cl_git_pass(git_buf_joinpath(&buf, git_repository_path(repo), "objects/somefile"));
cl_git_mkfile(buf.ptr, "");
git_buf_dispose(&buf);
diff --git a/tests/odb/sorting.c b/tests/odb/sorting.c
index 6af8b0d..e027230 100644
--- a/tests/odb/sorting.c
+++ b/tests/odb/sorting.c
@@ -1,5 +1,6 @@
#include "clar_libgit2.h"
#include "git2/sys/odb_backend.h"
+#include "odb.h"
typedef struct {
git_odb_backend base;
@@ -43,6 +44,11 @@ void test_odb_sorting__cleanup(void)
{
git_odb_free(_odb);
_odb = NULL;
+
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY,
+ GIT_ODB_DEFAULT_LOOSE_PRIORITY));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_PACKED_PRIORITY,
+ GIT_ODB_DEFAULT_PACKED_PRIORITY));
}
void test_odb_sorting__basic_backends_sorting(void)
@@ -68,3 +74,26 @@ void test_odb_sorting__alternate_backends_sorting(void)
check_backend_sorting(_odb);
}
+
+void test_odb_sorting__override_default_backend_priority(void)
+{
+ git_odb *new_odb;
+ git_odb_backend *loose, *packed, *backend;
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_LOOSE_PRIORITY, 5));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ODB_PACKED_PRIORITY, 3));
+ git_odb_backend_pack(&packed, "./testrepo.git/objects");
+ git_odb_backend_loose(&loose, "./testrepo.git/objects", -1, 0, 0, 0);
+
+ cl_git_pass(git_odb_open(&new_odb, cl_fixture("testrepo.git/objects")));
+ cl_assert_equal_sz(2, git_odb_num_backends(new_odb));
+
+ cl_git_pass(git_odb_get_backend(&backend, new_odb, 0));
+ cl_assert_equal_p(loose->read, backend->read);
+
+ cl_git_pass(git_odb_get_backend(&backend, new_odb, 1));
+ cl_assert_equal_p(packed->read, backend->read);
+
+ git_odb_free(new_odb);
+ loose->free(loose);
+ packed->free(packed);
+}
diff --git a/tests/online/badssl.c b/tests/online/badssl.c
index 6524fcd..6735e9c 100644
--- a/tests/online/badssl.c
+++ b/tests/online/badssl.c
@@ -67,14 +67,9 @@ void test_online_badssl__old_cipher(void)
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
opts.fetch_opts.callbacks.certificate_check = cert_check_assert_invalid;
- /* FIXME: we don't actually reject RC4 anywhere, figure out what to tweak */
- cl_skip();
-
if (!g_has_ssl)
cl_skip();
- cl_git_fail_with(GIT_ECERTIFICATE,
- git_clone(&g_repo, "https://rc4.badssl.com/fake.git", "./fake", NULL));
- cl_git_fail_with(GIT_ECERTIFICATE,
- git_clone(&g_repo, "https://rc4.badssl.com/fake.git", "./fake", &opts));
+ cl_git_fail(git_clone(&g_repo, "https://rc4.badssl.com/fake.git", "./fake", NULL));
+ cl_git_fail(git_clone(&g_repo, "https://rc4.badssl.com/fake.git", "./fake", &opts));
}
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 034d0c2..6de687b 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -11,6 +11,7 @@
#define BB_REPO_URL "https://libgit3@bitbucket.org/libgit2/testgitrepository.git"
#define BB_REPO_URL_WITH_PASS "https://libgit3:libgit3@bitbucket.org/libgit2/testgitrepository.git"
#define BB_REPO_URL_WITH_WRONG_PASS "https://libgit3:wrong@bitbucket.org/libgit2/testgitrepository.git"
+#define GOOGLESOURCE_REPO_URL "https://chromium.googlesource.com/external/github.com/sergi/go-diff"
#define SSH_REPO_URL "ssh://github.com/libgit2/TestGitRepository"
@@ -175,7 +176,7 @@ static int fetch_progress(const git_indexer_progress *stats, void *payload)
void test_online_clone__can_checkout_a_cloned_repo(void)
{
git_buf path = GIT_BUF_INIT;
- git_reference *head;
+ git_reference *head, *remote_head;
bool checkout_progress_cb_was_called = false,
fetch_progress_cb_was_called = false;
@@ -194,9 +195,14 @@ void test_online_clone__can_checkout_a_cloned_repo(void)
cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head));
cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
+ cl_git_pass(git_reference_lookup(&remote_head, g_repo, "refs/remotes/origin/HEAD"));
+ cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(remote_head));
+ cl_assert_equal_s("refs/remotes/origin/master", git_reference_symbolic_target(remote_head));
+
cl_assert_equal_i(true, checkout_progress_cb_was_called);
cl_assert_equal_i(true, fetch_progress_cb_was_called);
+ git_reference_free(remote_head);
git_reference_free(head);
git_buf_dispose(&path);
}
@@ -463,6 +469,13 @@ void test_online_clone__bitbucket_falls_back_to_specified_creds(void)
cl_fixture_cleanup("./foo");
}
+void test_online_clone__googlesource(void)
+{
+ cl_git_pass(git_clone(&g_repo, GOOGLESOURCE_REPO_URL, "./foo", &g_options));
+ git_repository_free(g_repo); g_repo = NULL;
+ cl_fixture_cleanup("./foo");
+}
+
static int cancel_at_half(const git_indexer_progress *stats, void *payload)
{
GIT_UNUSED(payload);
@@ -856,6 +869,28 @@ void test_online_clone__proxy_credentials_in_environment(void)
git_buf_dispose(&url);
}
+void test_online_clone__proxy_credentials_in_url_https(void)
+{
+ git_buf url = GIT_BUF_INIT;
+
+ if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
+ cl_skip();
+
+ cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ _remote_proxy_scheme ? _remote_proxy_scheme : "http",
+ _remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
+
+ g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
+ g_options.fetch_opts.proxy_opts.url = url.ptr;
+ g_options.fetch_opts.proxy_opts.certificate_check = proxy_cert_cb;
+ g_options.fetch_opts.callbacks.certificate_check = ssl_cert;
+ called_proxy_creds = 0;
+ cl_git_pass(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options));
+ cl_assert(called_proxy_creds == 0);
+
+ git_buf_dispose(&url);
+}
+
void test_online_clone__proxy_auto_not_detected(void)
{
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_AUTO;
diff --git a/tests/online/fetch.c b/tests/online/fetch.c
index f939a16..67dfd69 100644
--- a/tests/online/fetch.c
+++ b/tests/online/fetch.c
@@ -3,9 +3,19 @@
static git_repository *_repo;
static int counter;
+static char *_remote_proxy_scheme = NULL;
+static char *_remote_proxy_host = NULL;
+static char *_remote_proxy_user = NULL;
+static char *_remote_proxy_pass = NULL;
+
void test_online_fetch__initialize(void)
{
cl_git_pass(git_repository_init(&_repo, "./fetch", 0));
+
+ _remote_proxy_scheme = cl_getenv("GITTEST_REMOTE_PROXY_SCHEME");
+ _remote_proxy_host = cl_getenv("GITTEST_REMOTE_PROXY_HOST");
+ _remote_proxy_user = cl_getenv("GITTEST_REMOTE_PROXY_USER");
+ _remote_proxy_pass = cl_getenv("GITTEST_REMOTE_PROXY_PASS");
}
void test_online_fetch__cleanup(void)
@@ -14,6 +24,11 @@ void test_online_fetch__cleanup(void)
_repo = NULL;
cl_fixture_cleanup("./fetch");
+
+ git__free(_remote_proxy_scheme);
+ git__free(_remote_proxy_host);
+ git__free(_remote_proxy_user);
+ git__free(_remote_proxy_pass);
}
static int update_tips(const char *refname, const git_oid *a, const git_oid *b, void *data)
@@ -207,3 +222,28 @@ void test_online_fetch__twice(void)
git_remote_free(remote);
}
+
+void test_online_fetch__proxy(void)
+{
+ git_remote *remote;
+ git_buf url = GIT_BUF_INIT;
+ git_fetch_options fetch_opts;
+
+ if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
+ cl_skip();
+
+ cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
+ _remote_proxy_scheme ? _remote_proxy_scheme : "http",
+ _remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
+
+ cl_git_pass(git_fetch_options_init(&fetch_opts, GIT_FETCH_OPTIONS_VERSION));
+ fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
+ fetch_opts.proxy_opts.url = url.ptr;
+
+ cl_git_pass(git_remote_create(&remote, _repo, "test", "https://github.com/libgit2/TestGitRepository.git"));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, &fetch_opts.proxy_opts, NULL));
+ cl_git_pass(git_remote_fetch(remote, NULL, &fetch_opts, NULL));
+
+ git_remote_free(remote);
+ git_buf_dispose(&url);
+}
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index 32e7419..b619931 100644
--- a/tests/online/fetchhead.c
+++ b/tests/online/fetchhead.c
@@ -43,7 +43,7 @@ static size_t count_references(void)
cl_git_pass(git_reference_list(&array, g_repo));
refs = array.count;
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
return refs;
}
diff --git a/tests/online/push_util.c b/tests/online/push_util.c
index fe9af2c..b39f781 100644
--- a/tests/online/push_util.c
+++ b/tests/online/push_util.c
@@ -58,12 +58,14 @@ int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *
int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, size_t heads_len)
{
git_buf del_spec = GIT_BUF_INIT;
+ int valid;
size_t i;
for (i = 0; i < heads_len; i++) {
const git_remote_head *head = heads[i];
/* Ignore malformed ref names (which also saves us from tag^{} */
- if (!git_reference_is_valid_name(head->name))
+ cl_git_pass(git_reference_name_is_valid(&valid, head->name));
+ if (!valid)
return 0;
/* Create a refspec that deletes a branch in the remote */
diff --git a/tests/online/remotes.c b/tests/online/remotes.c
index d79eb1f..f7fe414 100644
--- a/tests/online/remotes.c
+++ b/tests/online/remotes.c
@@ -32,7 +32,7 @@ void test_online_remotes__single_branch(void)
}
cl_assert_equal_i(1, count);
- git_strarray_free(&refs);
+ git_strarray_dispose(&refs);
cl_git_pass(git_remote_lookup(&remote, repo, "origin"));
cl_git_pass(git_remote_get_fetch_refspecs(&refs, remote));
@@ -40,7 +40,7 @@ void test_online_remotes__single_branch(void)
cl_assert_equal_i(1, refs.count);
cl_assert_equal_s(REFSPEC, refs.strings[0]);
- git_strarray_free(&refs);
+ git_strarray_dispose(&refs);
git_remote_free(remote);
git_repository_free(repo);
}
diff --git a/tests/pack/filelimit.c b/tests/pack/filelimit.c
new file mode 100644
index 0000000..5e0b77e
--- /dev/null
+++ b/tests/pack/filelimit.c
@@ -0,0 +1,136 @@
+#include "clar_libgit2.h"
+#include "mwindow.h"
+
+#include <git2.h>
+#include "git2/sys/commit.h"
+#include "git2/sys/mempack.h"
+
+static size_t expected_open_mwindow_files = 0;
+static size_t original_mwindow_file_limit = 0;
+
+extern git_mutex git__mwindow_mutex;
+extern git_mwindow_ctl git_mwindow__mem_ctl;
+
+void test_pack_filelimit__initialize_tiny(void)
+{
+ expected_open_mwindow_files = 1;
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, expected_open_mwindow_files));
+}
+
+void test_pack_filelimit__initialize_medium(void)
+{
+ expected_open_mwindow_files = 10;
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, expected_open_mwindow_files));
+}
+
+void test_pack_filelimit__initialize_unlimited(void)
+{
+ expected_open_mwindow_files = 15;
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, 0));
+}
+
+void test_pack_filelimit__cleanup(void)
+{
+ git_buf path = GIT_BUF_INIT;
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit));
+
+ cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git"));
+ cl_fixture_cleanup(path.ptr);
+ git_buf_dispose(&path);
+}
+
+/*
+ * Create a packfile with one commit, one tree, and two blobs. The first blob
+ * (README.md) has the same content in all commits, but the second one
+ * (file.txt) has a different content in each commit.
+ */
+void create_packfile_commit(
+ git_repository *repo,
+ git_oid *out_commit_id,
+ git_oid *parent_id,
+ size_t commit_index,
+ size_t commit_count)
+{
+ git_buf file_contents = GIT_BUF_INIT;
+ git_treebuilder *treebuilder;
+ git_packbuilder *packbuilder;
+ git_signature *s;
+ git_oid oid, tree_id, commit_id;
+ const git_oid *parents[] = { parent_id };
+ size_t parent_count = parent_id ? 1 : 0;
+
+ cl_git_pass(git_treebuilder_new(&treebuilder, repo, NULL));
+
+ cl_git_pass(git_blob_create_from_buffer(&oid, repo, "", 0));
+ cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "README.md", &oid, 0100644));
+
+ cl_git_pass(git_buf_printf(&file_contents, "Commit %zd/%zd", commit_index, commit_count));
+ cl_git_pass(git_blob_create_from_buffer(&oid, repo, file_contents.ptr, file_contents.size));
+ cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "file.txt", &oid, 0100644));
+
+ cl_git_pass(git_treebuilder_write(&tree_id, treebuilder));
+ cl_git_pass(git_signature_now(&s, "alice", "alice@example.com"));
+ cl_git_pass(git_commit_create_from_ids(&commit_id, repo, "refs/heads/master", s, s,
+ NULL, file_contents.ptr, &tree_id, parent_count, parents));
+
+ cl_git_pass(git_packbuilder_new(&packbuilder, repo));
+ cl_git_pass(git_packbuilder_insert_commit(packbuilder, &commit_id));
+ cl_git_pass(git_packbuilder_write(packbuilder, NULL, 0, NULL, NULL));
+
+ cl_git_pass(git_oid_cpy(out_commit_id, &commit_id));
+
+ git_buf_dispose(&file_contents);
+ git_treebuilder_free(treebuilder);
+ git_packbuilder_free(packbuilder);
+ git_signature_free(s);
+}
+
+void test_pack_filelimit__open_repo_with_multiple_packfiles(void)
+{
+ git_buf path = GIT_BUF_INIT;
+ git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
+ git_repository *repo;
+ git_revwalk *walk;
+ git_oid id, *parent_id = NULL;
+ size_t i;
+ const size_t commit_count = 16;
+ unsigned int open_windows;
+
+ /*
+ * Create a repository and populate it with 16 commits, each in its own
+ * packfile.
+ */
+ cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git"));
+ cl_git_pass(git_repository_init(&repo, path.ptr, true));
+ for (i = 0; i < commit_count; ++i) {
+ create_packfile_commit(repo, &id, parent_id, i + 1, commit_count);
+ parent_id = &id;
+ }
+
+ cl_git_pass(git_revwalk_new(&walk, repo));
+ cl_git_pass(git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL));
+ cl_git_pass(git_revwalk_push_ref(walk, "refs/heads/master"));
+
+ /* Walking the repository requires eventually opening each of the packfiles. */
+ i = 0;
+ while (git_revwalk_next(&id, walk) == 0)
+ ++i;
+ cl_assert_equal_i(commit_count, i);
+
+ cl_git_pass(git_mutex_lock(&git__mwindow_mutex));
+ /*
+ * Adding an assert while holding a lock will cause the whole process to
+ * deadlock. Copy the value and do the assert after releasing the lock.
+ */
+ open_windows = ctl->open_windows;
+ cl_git_pass(git_mutex_unlock(&git__mwindow_mutex));
+
+ cl_assert_equal_i(expected_open_mwindow_files, open_windows);
+
+ git_buf_dispose(&path);
+ git_revwalk_free(walk);
+ git_repository_free(repo);
+}
diff --git a/tests/pack/midx.c b/tests/pack/midx.c
new file mode 100644
index 0000000..0d7efbe
--- /dev/null
+++ b/tests/pack/midx.c
@@ -0,0 +1,46 @@
+#include "clar_libgit2.h"
+
+#include <git2.h>
+
+#include "midx.h"
+
+void test_pack_midx__parse(void)
+{
+ git_repository *repo;
+ struct git_midx_file *idx;
+ struct git_midx_entry e;
+ git_oid id;
+ git_buf midx_path = GIT_BUF_INIT;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
+ cl_git_pass(git_midx_open(&idx, git_buf_cstr(&midx_path)));
+ cl_assert_equal_i(git_midx_needs_refresh(idx, git_buf_cstr(&midx_path)), 0);
+
+ cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
+ cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ));
+ cl_assert_equal_oid(&e.sha1, &id);
+ cl_assert_equal_s(
+ (const char *)git_vector_get(&idx->packfile_names, e.pack_index),
+ "pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx");
+
+ git_midx_free(idx);
+ git_repository_free(repo);
+ git_buf_dispose(&midx_path);
+}
+
+void test_pack_midx__lookup(void)
+{
+ git_repository *repo;
+ git_commit *commit;
+ git_oid id;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+
+ cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
+ cl_git_pass(git_commit_lookup_prefix(&commit, repo, &id, GIT_OID_HEXSZ));
+ cl_assert_equal_s(git_commit_message(commit), "packed commit one\n");
+
+ git_commit_free(commit);
+ git_repository_free(repo);
+}
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index 32f0612..5f5441a 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -151,6 +151,15 @@ void test_pack_packbuilder__get_hash(void)
cl_assert_equal_s(hex, "7f5fa362c664d68ba7221259be1cbd187434b2f0");
}
+void test_pack_packbuilder__write_default_path(void)
+{
+ seed_packbuilder();
+
+ cl_git_pass(git_packbuilder_write(_packbuilder, NULL, 0, NULL, NULL));
+ cl_assert(git_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.idx"));
+ cl_assert(git_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.pack"));
+}
+
static void test_write_pack_permission(mode_t given, mode_t expected)
{
struct stat statbuf;
diff --git a/tests/pack/threadsafety.c b/tests/pack/threadsafety.c
new file mode 100644
index 0000000..fd6a61f
--- /dev/null
+++ b/tests/pack/threadsafety.c
@@ -0,0 +1,62 @@
+#include "clar_libgit2.h"
+#include "pool.h"
+
+#include <git2.h>
+#include "git2/sys/commit.h"
+#include "git2/sys/mempack.h"
+
+static size_t original_mwindow_file_limit = 0;
+
+void test_pack_threadsafety__initialize(void)
+{
+ size_t open_mwindow_files = 1;
+
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, open_mwindow_files));
+}
+
+void test_pack_threadsafety__cleanup(void)
+{
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit));
+}
+
+#ifdef GIT_THREADS
+static void *get_status(void *arg)
+{
+ const char *repo_path = (const char *)arg;
+ git_repository *repo;
+ git_status_list *status;
+
+ cl_git_pass(git_repository_open(&repo, repo_path));
+ cl_git_pass(git_status_list_new(&status, repo, NULL));
+ git_status_list_free(status);
+ git_repository_free(repo);
+
+ return NULL;
+}
+#endif
+
+void test_pack_threadsafety__open_repo_in_multiple_threads(void)
+{
+#ifdef GIT_THREADS
+ const char *repo_path = cl_fixture("../..");
+ git_repository *repo;
+ git_thread threads[8];
+ size_t i;
+
+ /* If we can't open the libgit2 repo or if it isn't a full repo
+ * with proper history, just skip this test */
+ if (git_repository_open(&repo, repo_path) < 0)
+ cl_skip();
+ if (git_repository_is_shallow(repo))
+ cl_skip();
+ git_repository_free(repo);
+
+ for (i = 0; i < ARRAY_SIZE(threads); i++)
+ git_thread_create(&threads[i], get_status, (void *)repo_path);
+ for (i = 0; i < ARRAY_SIZE(threads); i++)
+ git_thread_join(&threads[i], NULL);
+#else
+ cl_skip();
+#endif
+}
diff --git a/tests/patch/patch_common.h b/tests/patch/patch_common.h
index 7315247..1e03889 100644
--- a/tests/patch/patch_common.h
+++ b/tests/patch/patch_common.h
@@ -579,6 +579,14 @@
"rename from file.txt\n" \
"rename to newfile.txt\n"
+#define PATCH_RENAME_EXACT_WITH_MODE \
+ "diff --git a/RENAMED.md b/README.md\n" \
+ "old mode 100644\n" \
+ "new mode 100755\n" \
+ "similarity index 100%\n" \
+ "rename from RENAMED.md\n" \
+ "rename to README.md\n"
+
#define PATCH_RENAME_SIMILAR \
"diff --git a/file.txt b/newfile.txt\n" \
"similarity index 77%\n" \
diff --git a/tests/patch/print.c b/tests/patch/print.c
index c4ff479..b0a9339 100644
--- a/tests/patch/print.c
+++ b/tests/patch/print.c
@@ -107,6 +107,12 @@ void test_patch_print__rename_exact(void)
strlen(PATCH_RENAME_EXACT));
}
+void test_patch_print__rename_exact_with_mode(void)
+{
+ patch_print_from_patchfile(PATCH_RENAME_EXACT_WITH_MODE,
+ strlen(PATCH_RENAME_EXACT_WITH_MODE));
+}
+
void test_patch_print__rename_similar(void)
{
patch_print_from_patchfile(PATCH_RENAME_SIMILAR,
diff --git a/tests/path/core.c b/tests/path/core.c
index 48b518c..c875a86 100644
--- a/tests/path/core.c
+++ b/tests/path/core.c
@@ -1,6 +1,11 @@
#include "clar_libgit2.h"
#include "path.h"
+void test_path_core__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
static void test_make_relative(
const char *expected_path,
const char *path,
@@ -44,266 +49,322 @@ void test_path_core__make_relative(void)
test_make_relative("/path/to/foo.c", "/path/to/foo.c", "d:/path/to", GIT_ENOTFOUND);
test_make_relative("d:/path/to/foo.c", "d:/path/to/foo.c", "/path/to", GIT_ENOTFOUND);
-
+
test_make_relative("/path/to/foo.c", "/path/to/foo.c", "not-a-rooted-path", GIT_ENOTFOUND);
test_make_relative("not-a-rooted-path", "not-a-rooted-path", "/path/to", GIT_ENOTFOUND);
-
+
test_make_relative("/path", "/path", "pathtofoo", GIT_ENOTFOUND);
test_make_relative("path", "path", "pathtofoo", GIT_ENOTFOUND);
}
void test_path_core__isvalid_standard(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar/file.txt", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar/.file", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar/file.txt", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar/.file", 0, 0));
}
void test_path_core__isvalid_empty_dir_component(void)
{
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo//bar", 0, 0));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo//bar", 0, 0));
/* leading slash */
- cl_assert_equal_b(false, git_path_isvalid(NULL, "/", 0, 0));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "/foo", 0, 0));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "/foo/bar", 0, 0));
+ cl_assert_equal_b(false, git_path_validate(NULL, "/", 0, 0));
+ cl_assert_equal_b(false, git_path_validate(NULL, "/foo", 0, 0));
+ cl_assert_equal_b(false, git_path_validate(NULL, "/foo/bar", 0, 0));
/* trailing slash */
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/", 0, 0));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar/", 0, 0));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/", 0, 0));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar/", 0, 0));
}
void test_path_core__isvalid_dot_and_dotdot(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "./foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "./foo", 0, 0));
-
- cl_assert_equal_b(true, git_path_isvalid(NULL, "..", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "../foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/..", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "../foo", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "./foo", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/.", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "./foo", 0, GIT_PATH_REJECT_TRAVERSAL));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "..", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "../foo", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/..", 0, GIT_PATH_REJECT_TRAVERSAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "../foo", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "./foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "./foo", 0, 0));
+
+ cl_assert_equal_b(true, git_path_validate(NULL, "..", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "../foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/..", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "../foo", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, ".", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "./foo", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/.", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "./foo", 0, GIT_PATH_REJECT_TRAVERSAL));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "..", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "../foo", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/..", 0, GIT_PATH_REJECT_TRAVERSAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "../foo", 0, GIT_PATH_REJECT_TRAVERSAL));
}
void test_path_core__isvalid_dot_git(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git/foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/.git", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/.git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/.GIT/bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar/.Git", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git/foo", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/.git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/.git/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/.GIT/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar/.Git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
-
- cl_assert_equal_b(true, git_path_isvalid(NULL, "!git", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/!git", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "!git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".tig", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/.tig", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".tig/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git/foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/.git", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/.git/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/.GIT/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar/.Git", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git/foo", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/.git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/.git/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/.GIT/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar/.Git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
+
+ cl_assert_equal_b(true, git_path_validate(NULL, "!git", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/!git", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "!git/bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".tig", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/.tig", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".tig/bar", 0, 0));
}
void test_path_core__isvalid_backslash(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo\\file.txt", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar\\file.txt", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar\\", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo\\file.txt", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar\\file.txt", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar\\", 0, 0));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo\\file.txt", 0, GIT_PATH_REJECT_BACKSLASH));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar\\file.txt", 0, GIT_PATH_REJECT_BACKSLASH));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar\\", 0, GIT_PATH_REJECT_BACKSLASH));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo\\file.txt", 0, GIT_PATH_REJECT_BACKSLASH));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar\\file.txt", 0, GIT_PATH_REJECT_BACKSLASH));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar\\", 0, GIT_PATH_REJECT_BACKSLASH));
}
void test_path_core__isvalid_trailing_dot(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo...", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo./bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo.", 0, GIT_PATH_REJECT_TRAILING_DOT));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo...", 0, GIT_PATH_REJECT_TRAILING_DOT));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar.", 0, GIT_PATH_REJECT_TRAILING_DOT));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo./bar", 0, GIT_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo...", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo./bar", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo.", 0, GIT_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo...", 0, GIT_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar.", 0, GIT_PATH_REJECT_TRAILING_DOT));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo./bar", 0, GIT_PATH_REJECT_TRAILING_DOT));
}
void test_path_core__isvalid_trailing_space(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo ", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo ", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar ", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, " ", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo /bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_isvalid(NULL, " ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo /bar", 0, GIT_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo ", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo ", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar ", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, " ", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo /bar", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_path_validate(NULL, " ", 0, GIT_PATH_REJECT_TRAILING_SPACE));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo /bar", 0, GIT_PATH_REJECT_TRAILING_SPACE));
}
void test_path_core__isvalid_trailing_colon(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo:", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo/bar:", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ":", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "foo:/bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo:", 0, GIT_PATH_REJECT_TRAILING_COLON));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo/bar:", 0, GIT_PATH_REJECT_TRAILING_COLON));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ":", 0, GIT_PATH_REJECT_TRAILING_COLON));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "foo:/bar", 0, GIT_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo:", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo/bar:", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ":", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "foo:/bar", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo:", 0, GIT_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo/bar:", 0, GIT_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(false, git_path_validate(NULL, ":", 0, GIT_PATH_REJECT_TRAILING_COLON));
+ cl_assert_equal_b(false, git_path_validate(NULL, "foo:/bar", 0, GIT_PATH_REJECT_TRAILING_COLON));
}
void test_path_core__isvalid_dotgit_ntfs(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git ", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git.. .", 0, 0));
-
- cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1 ", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1.. .", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1 ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git ", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git.. .", 0, 0));
+
+ cl_assert_equal_b(true, git_path_validate(NULL, "git~1", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "git~1 ", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "git~1.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "git~1.. .", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "git~1", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "git~1 ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "git~1.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "git~1.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
}
void test_path_core__isvalid_dos_paths(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux:", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux.asdf", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux.asdf\\zippy", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux:asdf\\foobar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "con", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "prn", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "nul", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "aux", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "aux.", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "aux:", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "aux.asdf", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "aux.asdf\\zippy", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "aux:asdf\\foobar", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "con", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "prn", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "nul", 0, GIT_PATH_REJECT_DOS_PATHS));
-
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux1", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux1", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "auxn", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "aux\\foo", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux:", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux.asdf", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux.asdf\\zippy", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux:asdf\\foobar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "con", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "prn", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "nul", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "aux", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "aux.", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "aux:", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "aux.asdf", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "aux.asdf\\zippy", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "aux:asdf\\foobar", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "con", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "prn", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "nul", 0, GIT_PATH_REJECT_DOS_PATHS));
+
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux1", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux1", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "auxn", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "aux\\foo", 0, GIT_PATH_REJECT_DOS_PATHS));
}
void test_path_core__isvalid_dos_paths_withnum(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1.", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1:", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1.asdf", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1.asdf\\zippy", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1:asdf\\foobar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1\\foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "lpt1", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1.", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1:", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1.asdf", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1.asdf\\zippy", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1:asdf\\foobar", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "com1/foo", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "lpt1", 0, GIT_PATH_REJECT_DOS_PATHS));
-
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com0", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com0", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com10", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com10", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "comn", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "com1\\foo", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "lpt0", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "lpt10", 0, GIT_PATH_REJECT_DOS_PATHS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "lptn", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1.", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1:", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1.asdf", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1.asdf\\zippy", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1:asdf\\foobar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1\\foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "lpt1", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1.", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1:", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1.asdf", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1.asdf\\zippy", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1:asdf\\foobar", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "com1/foo", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "lpt1", 0, GIT_PATH_REJECT_DOS_PATHS));
+
+ cl_assert_equal_b(true, git_path_validate(NULL, "com0", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com0", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com10", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com10", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "comn", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "com1\\foo", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "lpt0", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "lpt10", 0, GIT_PATH_REJECT_DOS_PATHS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "lptn", 0, GIT_PATH_REJECT_DOS_PATHS));
}
void test_path_core__isvalid_nt_chars(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf\001foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf\037bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf<bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf>foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf:foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf\"bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf|foo", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf?bar", 0, 0));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "asdf*bar", 0, 0));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf\001foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf\037bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf<bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf>foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf:foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf\"bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf|foo", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf?bar", 0, GIT_PATH_REJECT_NT_CHARS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "asdf*bar", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf\001foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf\037bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf<bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf>foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf:foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf\"bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf|foo", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf?bar", 0, 0));
+ cl_assert_equal_b(true, git_path_validate(NULL, "asdf*bar", 0, 0));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf\001foo", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf\037bar", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf<bar", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf>foo", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf:foo", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf\"bar", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf|foo", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf?bar", 0, GIT_PATH_REJECT_NT_CHARS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "asdf*bar", 0, GIT_PATH_REJECT_NT_CHARS));
}
void test_path_core__isvalid_dotgit_with_hfs_ignorables(void)
{
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".gi\xe2\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".g\xe2\x80\x8eIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".\xe2\x80\x8fgIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "\xe2\x80\xaa.gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(false, git_path_isvalid(NULL, "\xe2\x80\xab.\xe2\x80\xacG\xe2\x80\xadI\xe2\x80\xaet", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "\xe2\x81\xab.\xe2\x80\xaaG\xe2\x81\xabI\xe2\x80\xact", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "\xe2\x81\xad.\xe2\x80\xaeG\xef\xbb\xbfIT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".g", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, " .git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "..git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".gi\xe2\x80\x8dT.", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".g\xe2\x80It", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".\xe2gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, "\xe2\x80\xaa.gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".gi\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".gi\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".g\xe2i\x80T\x8e", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git\xe2\x80\xbf", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".git\xe2\xab\x81", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".gi\xe2\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".g\xe2\x80\x8eIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".\xe2\x80\x8fgIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x80\xaa.gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+
+ cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x80\xab.\xe2\x80\xacG\xe2\x80\xadI\xe2\x80\xaet", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x81\xab.\xe2\x80\xaaG\xe2\x81\xabI\xe2\x80\xact", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, "\xe2\x81\xad.\xe2\x80\xaeG\xef\xbb\xbfIT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+
+ cl_assert_equal_b(true, git_path_validate(NULL, ".", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".g", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, " .git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "..git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".gi\xe2\x80\x8dT.", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".g\xe2\x80It", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".\xe2gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, "\xe2\x80\xaa.gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".gi\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".gi\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".g\xe2i\x80T\x8e", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git\xe2\x80\xbf", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".git\xe2\xab\x81", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
+}
+
+void test_path_core__validate_workdir(void)
+{
+ cl_must_pass(git_path_validate_workdir(NULL, "/foo/bar"));
+ cl_must_pass(git_path_validate_workdir(NULL, "C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_workdir(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_workdir(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_workdir(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
+
+#ifdef GIT_WIN32
+ /*
+ * In the absense of a repo configuration, 259 character paths
+ * succeed. >= 260 character paths fail.
+ */
+ cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
+ cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
+ cl_must_fail(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
+
+ /* count characters, not bytes */
+ cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_fail(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+#else
+ cl_must_pass(git_path_validate_workdir(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
+ cl_must_pass(git_path_validate_workdir(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
+ cl_must_pass(git_path_validate_workdir(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_pass(git_path_validate_workdir(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+#endif
+}
+
+void test_path_core__validate_workdir_with_core_longpath(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo;
+ git_config *config;
+
+ repo = cl_git_sandbox_init("empty_bare.git");
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_git_pass(git_repository_config(&config, repo));
+
+ /* fail by default */
+ cl_must_fail(git_path_validate_workdir(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ /* set core.longpaths explicitly on */
+ cl_git_pass(git_config_set_bool(config, "core.longpaths", 1));
+ cl_must_pass(git_path_validate_workdir(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ /* set core.longpaths explicitly off */
+ cl_git_pass(git_config_set_bool(config, "core.longpaths", 0));
+ cl_must_fail(git_path_validate_workdir(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ git_config_free(config);
+ git_repository_free(repo);
+#endif
}
static void test_join_unrooted(
diff --git a/tests/path/dotgit.c b/tests/path/dotgit.c
index ceb7330..2f9fcae 100644
--- a/tests/path/dotgit.c
+++ b/tests/path/dotgit.c
@@ -113,8 +113,8 @@ void test_path_dotgit__dotgit_modules(void)
void test_path_dotgit__dotgit_modules_symlink(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(true, git_path_validate(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_validate(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
}
diff --git a/tests/path/win32.c b/tests/path/win32.c
index 3ed7d7a..46b5c9f 100644
--- a/tests/path/win32.c
+++ b/tests/path/win32.c
@@ -21,6 +21,21 @@ void test_utf8_to_utf16(const char *utf8_in, const wchar_t *utf16_expected)
#endif
}
+void test_utf8_to_utf16_relative(const char* utf8_in, const wchar_t* utf16_expected)
+{
+#ifdef GIT_WIN32
+ git_win32_path path_utf16;
+ int path_utf16len;
+
+ cl_assert((path_utf16len = git_win32_path_relative_from_utf8(path_utf16, utf8_in)) >= 0);
+ cl_assert_equal_wcs(utf16_expected, path_utf16);
+ cl_assert_equal_i(wcslen(utf16_expected), path_utf16len);
+#else
+ GIT_UNUSED(utf8_in);
+ GIT_UNUSED(utf16_expected);
+#endif
+}
+
void test_path_win32__utf8_to_utf16(void)
{
#ifdef GIT_WIN32
@@ -63,13 +78,11 @@ void test_path_win32__honors_max_path(void)
#ifdef GIT_WIN32
git_win32_path path_utf16;
- test_utf8_to_utf16("C:\\This path is 259 chars and is the max length in windows\\0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij",
- L"\\\\?\\C:\\This path is 259 chars and is the max length in windows\\0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij");
- test_utf8_to_utf16("\\\\unc\\paths may also be 259 characters including the server\\123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij",
- L"\\\\?\\UNC\\unc\\paths may also be 259 characters including the server\\123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij");
+ test_utf8_to_utf16("C:\\This path is 261 characters which is fine for our path handling functions which cope with paths longer than MAX_PATH\\0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghijk",
+ L"\\\\?\\C:\\This path is 261 characters which is fine for our path handling functions which cope with paths longer than MAX_PATH\\0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghijk");
+
+ cl_check_fail(git_win32_path_from_utf8(path_utf16, "C:\\This path is 4097 chars and exceeds our maximum path length on Windows which is limited to 4096 characters\\alas\\0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij01"));
- cl_check_fail(git_win32_path_from_utf8(path_utf16, "C:\\This path is 260 chars and is sadly too long for windows\\0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij"));
- cl_check_fail(git_win32_path_from_utf8(path_utf16, "\\\\unc\\paths are also bound by 260 character restrictions\\including the server name portion\\bcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij"));
#endif
}
@@ -129,6 +142,31 @@ void test_path_win32__absolute_from_relative(void)
#endif
}
+void test_path_win32__keeps_relative(void)
+{
+#ifdef GIT_WIN32
+ /* Relative paths stay relative */
+ test_utf8_to_utf16_relative("Foo", L"Foo");
+ test_utf8_to_utf16_relative("..\\..\\Foo", L"..\\..\\Foo");
+ test_utf8_to_utf16_relative("Foo\\..", L"Foo\\..");
+ test_utf8_to_utf16_relative("Foo\\..\\..", L"Foo\\..\\..");
+ test_utf8_to_utf16_relative("Foo\\Bar", L"Foo\\Bar");
+ test_utf8_to_utf16_relative("Foo\\..\\Bar", L"Foo\\..\\Bar");
+ test_utf8_to_utf16_relative("../../Foo", L"..\\..\\Foo");
+ test_utf8_to_utf16_relative("Foo/..", L"Foo\\..");
+ test_utf8_to_utf16_relative("Foo/../..", L"Foo\\..\\..");
+ test_utf8_to_utf16_relative("Foo/Bar", L"Foo\\Bar");
+ test_utf8_to_utf16_relative("Foo/../Bar", L"Foo\\..\\Bar");
+ test_utf8_to_utf16_relative("Foo/../Bar/", L"Foo\\..\\Bar\\");
+ test_utf8_to_utf16_relative("", L"");
+
+ /* Absolute paths are canonicalized */
+ test_utf8_to_utf16_relative("\\Foo", L"\\\\?\\C:\\Foo");
+ test_utf8_to_utf16_relative("/Foo/Bar/", L"\\\\?\\C:\\Foo\\Bar");
+ test_utf8_to_utf16_relative("\\\\server\\c$\\unc\\path", L"\\\\?\\UNC\\server\\c$\\unc\\path");
+#endif
+}
+
#ifdef GIT_WIN32
static void test_canonicalize(const wchar_t *in, const wchar_t *expected)
{
@@ -203,16 +241,6 @@ void test_path_win32__canonicalize(void)
test_canonicalize(L"C:/Foo/Bar", L"C:\\Foo\\Bar");
test_canonicalize(L"C:/", L"C:\\");
- test_canonicalize(L"Foo\\\\Bar\\\\Asdf\\\\", L"Foo\\Bar\\Asdf");
- test_canonicalize(L"Foo\\\\Bar\\\\..\\\\Asdf\\", L"Foo\\Asdf");
- test_canonicalize(L"Foo\\\\Bar\\\\.\\\\Asdf\\", L"Foo\\Bar\\Asdf");
- test_canonicalize(L"Foo\\\\..\\Bar\\\\.\\\\Asdf\\", L"Bar\\Asdf");
- test_canonicalize(L"\\", L"");
- test_canonicalize(L"", L"");
- test_canonicalize(L"Foo\\..\\..\\..\\..", L"");
- test_canonicalize(L"..\\..\\..\\..", L"");
- test_canonicalize(L"\\..\\..\\..\\..", L"");
-
test_canonicalize(L"\\\\?\\C:\\Foo\\Bar", L"\\\\?\\C:\\Foo\\Bar");
test_canonicalize(L"\\\\?\\C:\\Foo\\Bar\\", L"\\\\?\\C:\\Foo\\Bar");
test_canonicalize(L"\\\\?\\C:\\\\Foo\\.\\Bar\\\\..\\", L"\\\\?\\C:\\Foo");
diff --git a/tests/refs/basic.c b/tests/refs/basic.c
index ed0c0bd..9e4c229 100644
--- a/tests/refs/basic.c
+++ b/tests/refs/basic.c
@@ -42,3 +42,44 @@ void test_refs_basic__reference_realloc(void)
git_reference_free(new_ref);
git_reference_free(ref);
}
+
+void test_refs_basic__longpaths(void)
+{
+#ifdef GIT_WIN32
+ const char *base;
+ size_t base_len, extra_len;
+ ssize_t remain_len, i;
+ git_buf refname = GIT_BUF_INIT;
+ git_reference *one = NULL, *two = NULL;
+ git_oid id;
+
+ cl_git_pass(git_oid_fromstr(&id, "099fabac3a9ea935598528c27f866e34089c2eff"));
+
+ base = git_repository_path(g_repo);
+ base_len = git_utf8_char_length(base, strlen(base));
+ extra_len = CONST_STRLEN("logs/refs/heads/") + CONST_STRLEN(".lock");
+
+ remain_len = (ssize_t)MAX_PATH - (base_len + extra_len);
+ cl_assert(remain_len > 0);
+
+ cl_git_pass(git_buf_puts(&refname, "refs/heads/"));
+
+ for (i = 0; i < remain_len; i++) {
+ cl_git_pass(git_buf_putc(&refname, 'a'));
+ }
+
+ /*
+ * The full path to the reflog lockfile is 260 characters,
+ * this is permitted.
+ */
+ cl_git_pass(git_reference_create(&one, g_repo, refname.ptr, &id, 0, NULL));
+
+ /* Adding one more character gives us a path that is too long. */
+ cl_git_pass(git_buf_putc(&refname, 'z'));
+ cl_git_fail(git_reference_create(&two, g_repo, refname.ptr, &id, 0, NULL));
+
+ git_reference_free(one);
+ git_reference_free(two);
+ git_buf_dispose(&refname);
+#endif
+}
diff --git a/tests/refs/branches/name.c b/tests/refs/branches/name.c
index 176f836..290916e 100644
--- a/tests/refs/branches/name.c
+++ b/tests/refs/branches/name.c
@@ -43,3 +43,20 @@ void test_refs_branches_name__error_when_ref_is_no_branch(void)
cl_git_pass(git_reference_lookup(&ref,repo,"refs/notes/fanout"));
cl_git_fail(git_branch_name(&name,ref));
}
+
+static int name_is_valid(const char *name)
+{
+ int valid;
+ cl_git_pass(git_branch_name_is_valid(&valid, name));
+ return valid;
+}
+
+void test_refs_branches_is_name_valid(void)
+{
+ cl_assert_equal_i(true, name_is_valid("master"));
+ cl_assert_equal_i(true, name_is_valid("test/master"));
+
+ cl_assert_equal_i(false, name_is_valid(""));
+ cl_assert_equal_i(false, name_is_valid("HEAD"));
+ cl_assert_equal_i(false, name_is_valid("-dash"));
+}
diff --git a/tests/refs/branches/upstream.c b/tests/refs/branches/upstream.c
index 928a9ff..919705e 100644
--- a/tests/refs/branches/upstream.c
+++ b/tests/refs/branches/upstream.c
@@ -71,6 +71,31 @@ void test_refs_branches_upstream__upstream_remote(void)
git_buf_dispose(&buf);
}
+void test_refs_branches_upstream__upstream_merge(void)
+{
+ git_reference *branch;
+ git_repository *repository;
+ git_buf buf = GIT_BUF_INIT;
+
+ repository = cl_git_sandbox_init("testrepo.git");
+
+ /* check repository */
+ cl_git_pass(git_reference_lookup(&branch, repository, "refs/heads/test"));
+ cl_git_pass(git_branch_set_upstream(branch, "test/master"));
+
+ assert_config_entry_value(repository, "branch.test.remote", "test");
+ assert_config_entry_value(repository, "branch.test.merge", "refs/heads/master");
+
+ git_reference_free(branch);
+
+ /* check merge branch */
+ cl_git_pass(git_branch_upstream_merge(&buf, repository, "refs/heads/test"));
+ cl_assert_equal_s("refs/heads/master", buf.ptr);
+ git_buf_dispose(&buf);
+
+ cl_git_sandbox_cleanup();
+}
+
void test_refs_branches_upstream__upstream_remote_empty_value(void)
{
git_repository *repository;
diff --git a/tests/refs/create.c b/tests/refs/create.c
index 20ac579..01eb62a 100644
--- a/tests/refs/create.c
+++ b/tests/refs/create.c
@@ -212,17 +212,12 @@ void test_refs_create__oid_unknown_fails_by_default(void)
void test_refs_create__propagate_eexists(void)
{
- int error;
git_oid oid;
- git_reference *ref;
/* Make sure it works for oid and for symbolic both */
- git_oid_fromstr(&oid, current_master_tip);
- error = git_reference_create(&ref, g_repo, current_head_target, &oid, false, NULL);
- cl_assert(error == GIT_EEXISTS);
-
- error = git_reference_symbolic_create(&ref, g_repo, "HEAD", current_head_target, false, NULL);
- cl_assert(error == GIT_EEXISTS);
+ cl_git_pass(git_oid_fromstr(&oid, current_master_tip));
+ cl_git_fail_with(GIT_EEXISTS, git_reference_create(NULL, g_repo, current_head_target, &oid, false, NULL));
+ cl_git_fail_with(GIT_EEXISTS, git_reference_symbolic_create(NULL, g_repo, "HEAD", current_head_target, false, NULL));
}
void test_refs_create__existing_dir_propagates_edirectory(void)
diff --git a/tests/refs/isvalidname.c b/tests/refs/isvalidname.c
index 65c70ba..063f0f7 100644
--- a/tests/refs/isvalidname.c
+++ b/tests/refs/isvalidname.c
@@ -1,31 +1,38 @@
#include "clar_libgit2.h"
+static bool is_valid_name(const char *name)
+{
+ int valid;
+ cl_git_pass(git_reference_name_is_valid(&valid, name));
+ return valid;
+}
+
void test_refs_isvalidname__can_detect_invalid_formats(void)
{
- cl_assert_equal_i(false, git_reference_is_valid_name("refs/tags/0.17.0^{}"));
- cl_assert_equal_i(false, git_reference_is_valid_name("TWO/LEVELS"));
- cl_assert_equal_i(false, git_reference_is_valid_name("ONE.LEVEL"));
- cl_assert_equal_i(false, git_reference_is_valid_name("HEAD/"));
- cl_assert_equal_i(false, git_reference_is_valid_name("NO_TRAILING_UNDERSCORE_"));
- cl_assert_equal_i(false, git_reference_is_valid_name("_NO_LEADING_UNDERSCORE"));
- cl_assert_equal_i(false, git_reference_is_valid_name("HEAD/aa"));
- cl_assert_equal_i(false, git_reference_is_valid_name("lower_case"));
- cl_assert_equal_i(false, git_reference_is_valid_name("/stupid/name/master"));
- cl_assert_equal_i(false, git_reference_is_valid_name("/"));
- cl_assert_equal_i(false, git_reference_is_valid_name("//"));
- cl_assert_equal_i(false, git_reference_is_valid_name(""));
- cl_assert_equal_i(false, git_reference_is_valid_name("refs/heads/sub.lock/webmatrix"));
+ cl_assert_equal_i(false, is_valid_name("refs/tags/0.17.0^{}"));
+ cl_assert_equal_i(false, is_valid_name("TWO/LEVELS"));
+ cl_assert_equal_i(false, is_valid_name("ONE.LEVEL"));
+ cl_assert_equal_i(false, is_valid_name("HEAD/"));
+ cl_assert_equal_i(false, is_valid_name("NO_TRAILING_UNDERSCORE_"));
+ cl_assert_equal_i(false, is_valid_name("_NO_LEADING_UNDERSCORE"));
+ cl_assert_equal_i(false, is_valid_name("HEAD/aa"));
+ cl_assert_equal_i(false, is_valid_name("lower_case"));
+ cl_assert_equal_i(false, is_valid_name("/stupid/name/master"));
+ cl_assert_equal_i(false, is_valid_name("/"));
+ cl_assert_equal_i(false, is_valid_name("//"));
+ cl_assert_equal_i(false, is_valid_name(""));
+ cl_assert_equal_i(false, is_valid_name("refs/heads/sub.lock/webmatrix"));
}
void test_refs_isvalidname__wont_hopefully_choke_on_valid_formats(void)
{
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/tags/0.17.0"));
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/LEVELS"));
- cl_assert_equal_i(true, git_reference_is_valid_name("HEAD"));
- cl_assert_equal_i(true, git_reference_is_valid_name("ONE_LEVEL"));
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/stash"));
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/remotes/origin/bim_with_3d@11296"));
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/master{yesterday"));
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/master}yesterday"));
- cl_assert_equal_i(true, git_reference_is_valid_name("refs/master{yesterday}"));
+ cl_assert_equal_i(true, is_valid_name("refs/tags/0.17.0"));
+ cl_assert_equal_i(true, is_valid_name("refs/LEVELS"));
+ cl_assert_equal_i(true, is_valid_name("HEAD"));
+ cl_assert_equal_i(true, is_valid_name("ONE_LEVEL"));
+ cl_assert_equal_i(true, is_valid_name("refs/stash"));
+ cl_assert_equal_i(true, is_valid_name("refs/remotes/origin/bim_with_3d@11296"));
+ cl_assert_equal_i(true, is_valid_name("refs/master{yesterday"));
+ cl_assert_equal_i(true, is_valid_name("refs/master}yesterday"));
+ cl_assert_equal_i(true, is_valid_name("refs/master{yesterday}"));
}
diff --git a/tests/refs/list.c b/tests/refs/list.c
index 725d381..8085ff8 100644
--- a/tests/refs/list.c
+++ b/tests/refs/list.c
@@ -38,7 +38,7 @@ void test_refs_list__all(void)
* loose, but we only list it once */
cl_assert_equal_i((int)ref_list.count, 19);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void)
@@ -53,5 +53,5 @@ void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_exten
cl_git_pass(git_reference_list(&ref_list, g_repo));
cl_assert_equal_i((int)ref_list.count, 19);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
diff --git a/tests/refs/listall.c b/tests/refs/listall.c
index c696fbb..9da8d1a 100644
--- a/tests/refs/listall.c
+++ b/tests/refs/listall.c
@@ -16,7 +16,7 @@ static void ensure_no_refname_starts_with_a_forward_slash(const char *path)
for (i = 0; i < ref_list.count; i++)
cl_assert(git__prefixcmp(ref_list.strings[i], "/") != 0);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
git_repository_free(repo);
}
@@ -42,6 +42,6 @@ void test_refs_listall__from_repository_with_no_trailing_newline(void)
cl_assert(ref_list.count > 0);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
git_repository_free(repo);
}
diff --git a/tests/refs/namespaces.c b/tests/refs/namespaces.c
index bb6bb1c..19456b5 100644
--- a/tests/refs/namespaces.c
+++ b/tests/refs/namespaces.c
@@ -32,5 +32,5 @@ void test_refs_namespaces__namespace_doesnt_show_normal_refs(void)
cl_git_pass(git_repository_set_namespace(g_repo, "namespace"));
cl_git_pass(git_reference_list(&ref_list, g_repo));
cl_assert_equal_i(0, ref_list.count);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
diff --git a/tests/refs/races.c b/tests/refs/races.c
index 04a1bc1..4767893 100644
--- a/tests/refs/races.c
+++ b/tests/refs/races.c
@@ -22,6 +22,24 @@ void test_refs_races__cleanup(void)
cl_git_sandbox_cleanup();
}
+void test_refs_races__create_matching_zero_old(void)
+{
+ git_reference *ref;
+ git_oid id, zero_id;
+
+ git_oid_fromstr(&id, commit_id);
+ git_oid_fromstr(&zero_id, "0000000000000000000000000000000000000000");
+
+ cl_git_fail(git_reference_create_matching(&ref, g_repo, refname, &id, 1, &zero_id, NULL));
+ git_reference_free(ref);
+
+ cl_git_pass(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL));
+ git_reference_free(ref);
+
+ cl_git_fail(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL));
+ git_reference_free(ref);
+}
+
void test_refs_races__create_matching(void)
{
git_reference *ref, *ref2, *ref3;
diff --git a/tests/refs/reflog/messages.c b/tests/refs/reflog/messages.c
index 43f59a8..53b8c6f 100644
--- a/tests/refs/reflog/messages.c
+++ b/tests/refs/reflog/messages.c
@@ -24,11 +24,8 @@ void test_refs_reflog_messages__cleanup(void)
void test_refs_reflog_messages__setting_head_updates_reflog(void)
{
git_object *tag;
- git_signature *sig;
git_annotated_commit *annotated;
- cl_git_pass(git_signature_now(&sig, "me", "foo@example.com"));
-
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/haacked")); /* 4 */
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/unborn"));
cl_git_pass(git_revparse_single(&tag, g_repo, "tags/test"));
@@ -68,7 +65,6 @@ void test_refs_reflog_messages__setting_head_updates_reflog(void)
git_annotated_commit_free(annotated);
git_object_free(tag);
- git_signature_free(sig);
}
void test_refs_reflog_messages__setting_head_to_same_target_ignores_reflog(void)
@@ -87,12 +83,9 @@ void test_refs_reflog_messages__setting_head_to_same_target_ignores_reflog(void)
void test_refs_reflog_messages__detaching_writes_reflog(void)
{
- git_signature *sig;
git_oid id;
const char *msg;
- cl_git_pass(git_signature_now(&sig, "me", "foo@example.com"));
-
msg = "checkout: moving from master to e90810b8df3e80c413d903f631643c716887138d";
git_oid_fromstr(&id, "e90810b8df3e80c413d903f631643c716887138d");
cl_git_pass(git_repository_set_head_detached(g_repo, &id));
@@ -107,8 +100,6 @@ void test_refs_reflog_messages__detaching_writes_reflog(void)
"e90810b8df3e80c413d903f631643c716887138d",
"258f0e2a959a364e40ed6603d5d44fbb24765b10",
NULL, msg);
-
- git_signature_free(sig);
}
void test_refs_reflog_messages__orphan_branch_does_not_count(void)
diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/refs/reflog/reflog_helpers.c
index 6eba8ec..aecb78b 100644
--- a/tests/refs/reflog/reflog_helpers.c
+++ b/tests/refs/reflog/reflog_helpers.c
@@ -29,7 +29,8 @@ size_t reflog_entrycount(git_repository *repo, const char *name)
void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx,
const char *old_spec, const char *new_spec,
- const char *email, const char *message, const char *file, int line)
+ const char *email, const char *message,
+ const char *file, const char *func, int line)
{
git_reflog *log;
const git_reflog_entry *entry;
@@ -38,7 +39,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
cl_git_pass(git_reflog_read(&log, repo, reflog));
entry = git_reflog_entry_byindex(log, idx);
if (entry == NULL)
- clar__fail(file, line, "Reflog has no such entry", NULL, 1);
+ clar__fail(file, func, line, "Reflog has no such entry", NULL, 1);
if (old_spec) {
git_object *obj = NULL;
@@ -92,7 +93,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
git_buf_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
}
if (git_buf_len(&result) != 0)
- clar__fail(file, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
+ clar__fail(file, func, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
git_buf_dispose(&result);
git_reflog_free(log);
diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c
index 3c4ed9a..bc6e0a4 100644
--- a/tests/refs/revparse.c
+++ b/tests/refs/revparse.c
@@ -50,7 +50,7 @@ static void test_id_inrepo(
const char *spec,
const char *expected_left,
const char *expected_right,
- git_revparse_mode_t expected_flags,
+ git_revspec_t expected_flags,
git_repository *repo)
{
git_revspec revspec;
@@ -90,7 +90,7 @@ static void test_object_and_ref(const char *spec, const char *expected_oid, cons
static void test_rangelike(const char *rangelike,
const char *expected_left,
const char *expected_right,
- git_revparse_mode_t expected_revparseflags)
+ git_revspec_t expected_revparseflags)
{
char objstr[64] = {0};
git_revspec revspec;
@@ -117,7 +117,7 @@ static void test_id(
const char *spec,
const char *expected_left,
const char *expected_right,
- git_revparse_mode_t expected_flags)
+ git_revspec_t expected_flags)
{
test_id_inrepo(spec, expected_left, expected_right, expected_flags, g_repo);
}
@@ -735,53 +735,53 @@ void test_refs_revparse__range(void)
test_rangelike("be3563a^1..be3563a",
"9fd738e8f7967c078dceed8190330fc8648ee56a",
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
- GIT_REVPARSE_RANGE);
+ GIT_REVSPEC_RANGE);
test_rangelike("be3563a^1...be3563a",
"9fd738e8f7967c078dceed8190330fc8648ee56a",
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
- GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE);
+ GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE);
test_rangelike("be3563a^1.be3563a", NULL, NULL, 0);
}
void test_refs_revparse__parses_range_operator(void)
{
- test_id("HEAD", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", NULL, GIT_REVPARSE_SINGLE);
+ test_id("HEAD", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", NULL, GIT_REVSPEC_SINGLE);
test_id("HEAD~3..HEAD",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
- GIT_REVPARSE_RANGE);
+ GIT_REVSPEC_RANGE);
test_id("HEAD~3...HEAD",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
- GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE);
+ GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE);
test_id("HEAD~3..",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
- GIT_REVPARSE_RANGE);
+ GIT_REVSPEC_RANGE);
test_id("HEAD~3...",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
- GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE);
+ GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE);
test_id("..HEAD~3",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045",
- GIT_REVPARSE_RANGE);
+ GIT_REVSPEC_RANGE);
test_id("...HEAD~3",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045",
- GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE);
+ GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE);
test_id("...",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
- GIT_REVPARSE_RANGE | GIT_REVPARSE_MERGE_BASE);
+ GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE);
test_invalid_revspec("..");
}
diff --git a/tests/refs/tags/name.c b/tests/refs/tags/name.c
new file mode 100644
index 0000000..0ca5df7
--- /dev/null
+++ b/tests/refs/tags/name.c
@@ -0,0 +1,17 @@
+#include "clar_libgit2.h"
+
+static int name_is_valid(const char *name)
+{
+ int valid;
+ cl_git_pass(git_tag_name_is_valid(&valid, name));
+ return valid;
+}
+
+void test_refs_tags_is_name_valid(void)
+{
+ cl_assert_equal_i(true, name_is_valid("sometag"));
+ cl_assert_equal_i(true, name_is_valid("test/sometag"));
+
+ cl_assert_equal_i(false, name_is_valid(""));
+ cl_assert_equal_i(false, name_is_valid("-dash"));
+}
diff --git a/tests/remote/create.c b/tests/remote/create.c
index 5109623..f92be9d 100644
--- a/tests/remote/create.c
+++ b/tests/remote/create.c
@@ -117,7 +117,7 @@ void test_remote_create__with_fetchspec(void)
cl_assert_equal_i(1, array.count);
cl_assert_equal_i(section_count + 2, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -132,7 +132,7 @@ void test_remote_create__with_empty_fetchspec(void)
cl_assert_equal_i(0, array.count);
cl_assert_equal_i(section_count + 1, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -167,7 +167,7 @@ void test_remote_create__anonymous(void)
cl_assert_equal_i(0, array.count);
cl_assert_equal_i(section_count, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -195,7 +195,7 @@ void test_remote_create__detached(void)
cl_assert_equal_i(0, array.count);
cl_assert_equal_i(section_count, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -225,7 +225,7 @@ void test_remote_create__with_opts_named(void)
cl_assert_equal_i(1, array.count);
cl_assert_equal_s("+refs/heads/*:refs/remotes/test-new/*", array.strings[0]);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -248,7 +248,7 @@ void test_remote_create__with_opts_named_and_fetchspec(void)
cl_assert_equal_i(1, array.count);
cl_assert_equal_s("+refs/*:refs/*", array.strings[0]);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -270,7 +270,7 @@ void test_remote_create__with_opts_named_no_fetchspec(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -290,7 +290,7 @@ void test_remote_create__with_opts_anonymous(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -308,7 +308,7 @@ void test_remote_create__with_opts_detached(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
@@ -320,7 +320,7 @@ void test_remote_create__with_opts_detached(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
diff --git a/tests/remote/fetch.c b/tests/remote/fetch.c
new file mode 100644
index 0000000..7e825ca
--- /dev/null
+++ b/tests/remote/fetch.c
@@ -0,0 +1,169 @@
+#include "../clar_libgit2.h"
+
+#include "remote.h"
+#include "repository.h"
+
+static git_repository *repo1;
+static git_repository *repo2;
+static char* repo1_path;
+static char* repo2_path;
+
+static const char *REPO1_REFNAME = "refs/heads/main";
+static const char *REPO2_REFNAME = "refs/remotes/repo1/main";
+static char *FORCE_FETCHSPEC = "+refs/heads/main:refs/remotes/repo1/main";
+static char *NON_FORCE_FETCHSPEC = "refs/heads/main:refs/remotes/repo1/main";
+
+void test_remote_fetch__initialize(void) {
+ git_config *c;
+ git_buf repo1_path_buf = GIT_BUF_INIT;
+ git_buf repo2_path_buf = GIT_BUF_INIT;
+ const char *sandbox = clar_sandbox_path();
+
+ cl_git_pass(git_buf_joinpath(&repo1_path_buf, sandbox, "fetchtest_repo1"));
+ repo1_path = git_buf_detach(&repo1_path_buf);
+ cl_git_pass(git_repository_init(&repo1, repo1_path, true));
+
+ cl_git_pass(git_buf_joinpath(&repo2_path_buf, sandbox, "fetchtest_repo2"));
+ repo2_path = git_buf_detach(&repo2_path_buf);
+ cl_git_pass(git_repository_init(&repo2, repo2_path, true));
+
+ cl_git_pass(git_repository_config(&c, repo1));
+ cl_git_pass(git_config_set_string(c, "user.email", "some@email"));
+ cl_git_pass(git_config_set_string(c, "user.name", "some@name"));
+ git_config_free(c);
+ git_buf_dispose(&repo1_path_buf);
+ git_buf_dispose(&repo2_path_buf);
+}
+
+void test_remote_fetch__cleanup(void) {
+ git_repository_free(repo1);
+ git_repository_free(repo2);
+
+ cl_git_pass(git_futils_rmdir_r(repo1_path, NULL, GIT_RMDIR_REMOVE_FILES));
+ free(repo1_path);
+
+ cl_git_pass(git_futils_rmdir_r(repo2_path, NULL, GIT_RMDIR_REMOVE_FILES));
+ free(repo2_path);
+}
+
+
+/**
+ * This checks that the '+' flag on fetchspecs is respected. We create a
+ * repository that has a reference to two commits, one a child of the other.
+ * We fetch this repository into a second repository. Then we reset the
+ * reference in the first repository and run the fetch again. If the '+' flag
+ * is used then the reference in the second repository will change, but if it
+ * is not then it should stay the same.
+ *
+ * @param commit1id A pointer to an OID which will be populated with the first
+ * commit.
+ * @param commit2id A pointer to an OID which will be populated with the second
+ * commit, which is a descendant of the first.
+ * @param force Whether to use a spec with '+' prefixed to force the refs
+ * to update
+ */
+void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
+ bool force) {
+ char *refspec_strs = {
+ force ? FORCE_FETCHSPEC : NON_FORCE_FETCHSPEC,
+ };
+ git_strarray refspecs = {
+ .count = 1,
+ .strings = &refspec_strs,
+ };
+
+ /* create two commits in repo 1 and a reference to them */
+ {
+ git_oid empty_tree_id;
+ git_tree *empty_tree;
+ git_signature *sig;
+ git_treebuilder *tb;
+ cl_git_pass(git_treebuilder_new(&tb, repo1, NULL));
+ cl_git_pass(git_treebuilder_write(&empty_tree_id, tb));
+ cl_git_pass(git_tree_lookup(&empty_tree, repo1, &empty_tree_id));
+ cl_git_pass(git_signature_default(&sig, repo1));
+ cl_git_pass(git_commit_create(commit1id, repo1, REPO1_REFNAME, sig,
+ sig, NULL, "one", empty_tree, 0, NULL));
+ cl_git_pass(git_commit_create_v(commit2id, repo1, REPO1_REFNAME, sig,
+ sig, NULL, "two", empty_tree, 1, commit1id));
+
+ git_tree_free(empty_tree);
+ git_signature_free(sig);
+ git_treebuilder_free(tb);
+ }
+
+ /* fetch the reference via the remote */
+ {
+ git_remote *remote;
+
+ cl_git_pass(git_remote_create_anonymous(&remote, repo2,
+ git_repository_path(repo1)));
+ cl_git_pass(git_remote_fetch(remote, &refspecs, NULL, "some message"));
+
+ git_remote_free(remote);
+ }
+
+ /* assert that repo2 references the second commit */
+ {
+ const git_oid *target;
+ git_reference *ref;
+ cl_git_pass(git_reference_lookup(&ref, repo2, REPO2_REFNAME));
+ target = git_reference_target(ref);
+ cl_assert_equal_b(git_oid_cmp(target, commit2id), 0);
+ git_reference_free(ref);
+ }
+
+ /* set the reference in repo1 to point to the older commit */
+ {
+ git_reference *ref;
+ git_reference *ref2;
+ cl_git_pass(git_reference_lookup(&ref, repo1, REPO1_REFNAME));
+ cl_git_pass(git_reference_set_target(&ref2, ref, commit1id,
+ "rollback"));
+ git_reference_free(ref);
+ git_reference_free(ref2);
+ }
+
+ /* fetch the reference again */
+ {
+ git_remote *remote;
+
+ cl_git_pass(git_remote_create_anonymous(&remote, repo2,
+ git_repository_path(repo1)));
+ cl_git_pass(git_remote_fetch(remote, &refspecs, NULL, "some message"));
+
+ git_remote_free(remote);
+ }
+}
+
+void test_remote_fetch__dont_update_refs_if_not_descendant_and_not_force(void) {
+ const git_oid *target;
+ git_oid commit1id;
+ git_oid commit2id;
+ git_reference *ref;
+
+ do_time_travelling_fetch(&commit1id, &commit2id, false);
+
+ /* assert that the reference in repo2 has not changed */
+ cl_git_pass(git_reference_lookup(&ref, repo2, REPO2_REFNAME));
+ target = git_reference_target(ref);
+ cl_assert_equal_b(git_oid_cmp(target, &commit2id), 0);
+
+ git_reference_free(ref);
+}
+
+void test_remote_fetch__do_update_refs_if_not_descendant_and_force(void) {
+ const git_oid *target;
+ git_oid commit1id;
+ git_oid commit2id;
+ git_reference *ref;
+
+ do_time_travelling_fetch(&commit1id, &commit2id, true);
+
+ /* assert that the reference in repo2 has changed */
+ cl_git_pass(git_reference_lookup(&ref, repo2, REPO2_REFNAME));
+ target = git_reference_target(ref);
+ cl_assert_equal_b(git_oid_cmp(target, &commit1id), 0);
+
+ git_reference_free(ref);
+}
diff --git a/tests/remote/list.c b/tests/remote/list.c
index 5abb951..4a6be3d 100644
--- a/tests/remote/list.c
+++ b/tests/remote/list.c
@@ -25,17 +25,17 @@ void test_remote_list__always_checks_disk_config(void)
cl_git_pass(git_remote_list(&remotes, _repo));
cl_assert_equal_sz(remotes.count, 1);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
cl_git_pass(git_remote_create(&remote, _repo, "valid-name", TEST_URL));
cl_git_pass(git_remote_list(&remotes, _repo));
cl_assert_equal_sz(remotes.count, 2);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
cl_git_pass(git_remote_list(&remotes, repo));
cl_assert_equal_sz(remotes.count, 2);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
git_repository_free(repo);
git_remote_free(remote);
diff --git a/tests/repo/env.c b/tests/repo/env.c
index 0246616..43defc1 100644
--- a/tests/repo/env.c
+++ b/tests/repo/env.c
@@ -53,44 +53,44 @@ static int GIT_FORMAT_PRINTF(2, 3) cl_setenv_printf(const char *name, const char
* from the caller rather than those of the helper. The expression strings
* distinguish between the possible failures within the helper. */
-static void env_pass_(const char *path, const char *file, int line)
+static void env_pass_(const char *path, const char *file, const char *func, int line)
{
git_repository *repo;
- cl_git_expect(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line);
- cl_git_expect(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line);
- cl_assert_at_line(git__suffixcmp(git_repository_path(repo), "attr/.git/") == 0, file, line);
- cl_assert_at_line(git__suffixcmp(git_repository_workdir(repo), "attr/") == 0, file, line);
- cl_assert_at_line(!git_repository_is_bare(repo), file, line);
+ cl_git_expect(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line);
+ cl_git_expect(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line);
+ cl_assert_at_line(git__suffixcmp(git_repository_path(repo), "attr/.git/") == 0, file, func, line);
+ cl_assert_at_line(git__suffixcmp(git_repository_workdir(repo), "attr/") == 0, file, func, line);
+ cl_assert_at_line(!git_repository_is_bare(repo), file, func, line);
git_repository_free(repo);
}
-#define env_pass(path) env_pass_((path), __FILE__, __LINE__)
+#define env_pass(path) env_pass_((path), __FILE__, __func__, __LINE__)
-#define cl_git_fail_at_line(expr, file, line) clar__assert((expr) < 0, file, line, "Expected function call to fail: " #expr, NULL, 1)
+#define cl_git_fail_at_line(expr, file, func, line) clar__assert((expr) < 0, file, func, line, "Expected function call to fail: " #expr, NULL, 1)
-static void env_fail_(const char *path, const char *file, int line)
+static void env_fail_(const char *path, const char *file, const char *func, int line)
{
git_repository *repo;
- cl_git_fail_at_line(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, line);
- cl_git_fail_at_line(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, line);
+ cl_git_fail_at_line(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, func, line);
+ cl_git_fail_at_line(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, func, line);
}
-#define env_fail(path) env_fail_((path), __FILE__, __LINE__)
+#define env_fail(path) env_fail_((path), __FILE__, __func__, __LINE__)
static void env_cd_(
const char *path,
- void (*passfail_)(const char *, const char *, int),
- const char *file, int line)
+ void (*passfail_)(const char *, const char *, const char *, int),
+ const char *file, const char *func, int line)
{
git_buf cwd_buf = GIT_BUF_INIT;
cl_git_pass(git_path_prettify_dir(&cwd_buf, ".", NULL));
cl_must_pass(p_chdir(path));
- passfail_(NULL, file, line);
+ passfail_(NULL, file, func, line);
cl_must_pass(p_chdir(git_buf_cstr(&cwd_buf)));
git_buf_dispose(&cwd_buf);
}
-#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __LINE__)
-#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __LINE__)
+#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __func__, __LINE__)
+#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __func__, __LINE__)
-static void env_check_objects_(bool a, bool t, bool p, const char *file, int line)
+static void env_check_objects_(bool a, bool t, bool p, const char *file, const char *func, int line)
{
git_repository *repo;
git_oid oid_a, oid_t, oid_p;
@@ -98,32 +98,32 @@ static void env_check_objects_(bool a, bool t, bool p, const char *file, int lin
cl_git_pass(git_oid_fromstr(&oid_a, "45141a79a77842c59a63229403220a4e4be74e3d"));
cl_git_pass(git_oid_fromstr(&oid_t, "1385f264afb75a56a5bec74243be9b367ba4ca08"));
cl_git_pass(git_oid_fromstr(&oid_p, "0df1a5865c8abfc09f1f2182e6a31be550e99f07"));
- cl_git_expect(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line);
+ cl_git_expect(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line);
if (a) {
- cl_git_expect(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), 0, file, line);
+ cl_git_expect(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), 0, file, func, line);
git_object_free(object);
} else {
- cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), file, line);
+ cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), file, func, line);
}
if (t) {
- cl_git_expect(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), 0, file, line);
+ cl_git_expect(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), 0, file, func, line);
git_object_free(object);
} else {
- cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), file, line);
+ cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), file, func, line);
}
if (p) {
- cl_git_expect(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), 0, file, line);
+ cl_git_expect(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), 0, file, func, line);
git_object_free(object);
} else {
- cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), file, line);
+ cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), file, func, line);
}
git_repository_free(repo);
}
-#define env_check_objects(a, t, t2) env_check_objects_((a), (t), (t2), __FILE__, __LINE__)
+#define env_check_objects(a, t, t2) env_check_objects_((a), (t), (t2), __FILE__, __func__, __LINE__)
void test_repo_env__open(void)
{
diff --git a/tests/repo/getters.c b/tests/repo/getters.c
index b8ede12..d401bb8 100644
--- a/tests/repo/getters.c
+++ b/tests/repo/getters.c
@@ -1,4 +1,5 @@
#include "clar_libgit2.h"
+#include "repo/repo_helpers.h"
void test_repo_getters__is_empty_correctly_deals_with_pristine_looking_repos(void)
{
@@ -23,6 +24,18 @@ void test_repo_getters__is_empty_can_detect_used_repositories(void)
git_repository_free(repo);
}
+void test_repo_getters__is_empty_can_detect_repositories_with_defaultbranch_config_empty(void)
+{
+ git_repository *repo;
+
+ create_tmp_global_config("tmp_global_path", "init.defaultBranch", "");
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ cl_assert_equal_i(false, git_repository_is_empty(repo));
+
+ git_repository_free(repo);
+}
+
void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
{
git_odb *odb;
diff --git a/tests/repo/init.c b/tests/repo/init.c
index 5a95229..1aa326f 100644
--- a/tests/repo/init.c
+++ b/tests/repo/init.c
@@ -11,30 +11,30 @@ enum repo_mode {
BARE_REPOSITORY = 1
};
-static git_repository *_repo = NULL;
-static git_buf _global_path = GIT_BUF_INIT;
+static git_repository *g_repo = NULL;
+static git_buf g_global_path = GIT_BUF_INIT;
void test_repo_init__initialize(void)
{
- _repo = NULL;
+ g_repo = NULL;
git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
- &_global_path);
+ &g_global_path);
}
void test_repo_init__cleanup(void)
{
git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
- _global_path.ptr);
- git_buf_dispose(&_global_path);
+ g_global_path.ptr);
+ git_buf_dispose(&g_global_path);
cl_fixture_cleanup("tmp_global_path");
}
static void cleanup_repository(void *path)
{
- git_repository_free(_repo);
- _repo = NULL;
+ git_repository_free(g_repo);
+ g_repo = NULL;
cl_fixture_cleanup((const char *)path);
}
@@ -49,9 +49,9 @@ static void ensure_repository_init(
cl_assert(!git_path_isdir(working_directory));
- cl_git_pass(git_repository_init(&_repo, working_directory, is_bare));
+ cl_git_pass(git_repository_init(&g_repo, working_directory, is_bare));
- workdir = git_repository_workdir(_repo);
+ workdir = git_repository_workdir(g_repo);
if (workdir != NULL || expected_working_directory != NULL) {
cl_assert(
git__suffixcmp(workdir, expected_working_directory) == 0
@@ -59,19 +59,19 @@ static void ensure_repository_init(
}
cl_assert(
- git__suffixcmp(git_repository_path(_repo), expected_path_repository) == 0
+ git__suffixcmp(git_repository_path(g_repo), expected_path_repository) == 0
);
- cl_assert(git_repository_is_bare(_repo) == is_bare);
+ cl_assert(git_repository_is_bare(g_repo) == is_bare);
#ifdef GIT_WIN32
if (!is_bare) {
- DWORD fattrs = GetFileAttributes(git_repository_path(_repo));
+ DWORD fattrs = GetFileAttributes(git_repository_path(g_repo));
cl_assert((fattrs & FILE_ATTRIBUTE_HIDDEN) != 0);
}
#endif
- cl_assert(git_repository_is_empty(_repo));
+ cl_assert(git_repository_is_empty(g_repo));
}
void test_repo_init__standard_repo(void)
@@ -112,13 +112,14 @@ void test_repo_init__bare_repo_escaping_current_workdir(void)
cl_git_pass(chdir(git_buf_cstr(&path_repository)));
/* Initialize a bare repo with a relative path escaping out of the current working directory */
- cl_git_pass(git_repository_init(&_repo, "../d/e.git", 1));
- cl_git_pass(git__suffixcmp(git_repository_path(_repo), "/a/b/d/e.git/"));
+ cl_git_pass(git_repository_init(&g_repo, "../d/e.git", 1));
+ cl_git_pass(git__suffixcmp(git_repository_path(g_repo), "/a/b/d/e.git/"));
- git_repository_free(_repo);
+ git_repository_free(g_repo);
+ g_repo = NULL;
/* Open a bare repo with a relative path escaping out of the current working directory */
- cl_git_pass(git_repository_open(&_repo, "../d/e.git"));
+ cl_git_pass(git_repository_open(&g_repo, "../d/e.git"));
cl_git_pass(chdir(git_buf_cstr(&path_current_workdir)));
@@ -133,11 +134,12 @@ void test_repo_init__reinit_bare_repo(void)
cl_set_cleanup(&cleanup_repository, "reinit.git");
/* Initialize the repository */
- cl_git_pass(git_repository_init(&_repo, "reinit.git", 1));
- git_repository_free(_repo);
+ cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1));
+ git_repository_free(g_repo);
+ g_repo = NULL;
/* Reinitialize the repository */
- cl_git_pass(git_repository_init(&_repo, "reinit.git", 1));
+ cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1));
}
void test_repo_init__reinit_too_recent_bare_repo(void)
@@ -145,8 +147,8 @@ void test_repo_init__reinit_too_recent_bare_repo(void)
git_config *config;
/* Initialize the repository */
- cl_git_pass(git_repository_init(&_repo, "reinit.git", 1));
- git_repository_config(&config, _repo);
+ cl_git_pass(git_repository_init(&g_repo, "reinit.git", 1));
+ git_repository_config(&config, g_repo);
/*
* Hack the config of the repository to make it look like it has
@@ -155,10 +157,11 @@ void test_repo_init__reinit_too_recent_bare_repo(void)
cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 42));
git_config_free(config);
- git_repository_free(_repo);
+ git_repository_free(g_repo);
+ g_repo = NULL;
/* Try to reinitialize the repository */
- cl_git_fail(git_repository_init(&_repo, "reinit.git", 1));
+ cl_git_fail(git_repository_init(&g_repo, "reinit.git", 1));
cl_fixture_cleanup("reinit.git");
}
@@ -172,15 +175,15 @@ void test_repo_init__additional_templates(void)
ensure_repository_init("tester", 0, "tester/.git/", "tester/");
cl_git_pass(
- git_buf_joinpath(&path, git_repository_path(_repo), "description"));
+ git_buf_joinpath(&path, git_repository_path(g_repo), "description"));
cl_assert(git_path_isfile(git_buf_cstr(&path)));
cl_git_pass(
- git_buf_joinpath(&path, git_repository_path(_repo), "info/exclude"));
+ git_buf_joinpath(&path, git_repository_path(g_repo), "info/exclude"));
cl_assert(git_path_isfile(git_buf_cstr(&path)));
cl_git_pass(
- git_buf_joinpath(&path, git_repository_path(_repo), "hooks"));
+ git_buf_joinpath(&path, git_repository_path(g_repo), "hooks"));
cl_assert(git_path_isdir(git_buf_cstr(&path)));
/* won't confirm specific contents of hooks dir since it may vary */
@@ -197,9 +200,9 @@ static void assert_config_entry_on_init_bytype(
cl_set_cleanup(&cleanup_repository, "config_entry");
- cl_git_pass(git_repository_init(&_repo, repo_path, is_bare));
+ cl_git_pass(git_repository_init(&g_repo, repo_path, is_bare));
- cl_git_pass(git_repository_config(&config, _repo));
+ cl_git_pass(git_repository_config(&config, g_repo));
error = git_config_get_bool(¤t_value, config, config_key);
git_config_free(config);
@@ -215,7 +218,8 @@ static void assert_config_entry_on_init(
const char *config_key, int expected_value)
{
assert_config_entry_on_init_bytype(config_key, expected_value, true);
- git_repository_free(_repo);
+ git_repository_free(g_repo);
+ g_repo = NULL;
assert_config_entry_on_init_bytype(config_key, expected_value, false);
}
@@ -262,10 +266,10 @@ void test_repo_init__symlinks_win32_enabled_by_global_config(void)
* Create a new repository (can't use `assert_config_on_init` since we
* want to examine configuration levels with more granularity.)
*/
- cl_git_pass(git_repository_init(&_repo, "config_entry/test.non.bare.git", false));
+ cl_git_pass(git_repository_init(&g_repo, "config_entry/test.non.bare.git", false));
/* Ensure that core.symlinks remains set (via the global config). */
- cl_git_pass(git_repository_config(&config, _repo));
+ cl_git_pass(git_repository_config(&config, g_repo));
cl_git_pass(git_config_get_bool(&val, config, "core.symlinks"));
cl_assert_equal_i(1, val);
@@ -278,6 +282,9 @@ void test_repo_init__symlinks_win32_enabled_by_global_config(void)
git_config_free(repo_config);
git_config_free(config);
+
+ git_repository_free(g_repo);
+ g_repo = NULL;
#endif
}
@@ -324,18 +331,18 @@ void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
/* Init a new repo */
cl_set_cleanup(&cleanup_repository, "not.overwrite.git");
- cl_git_pass(git_repository_init(&_repo, "not.overwrite.git", 1));
+ cl_git_pass(git_repository_init(&g_repo, "not.overwrite.git", 1));
/* Change the "core.ignorecase" config value to something unlikely */
- git_repository_config(&config, _repo);
+ git_repository_config(&config, g_repo);
git_config_set_int32(config, "core.ignorecase", 42);
git_config_free(config);
- git_repository_free(_repo);
- _repo = NULL;
+ git_repository_free(g_repo);
+ g_repo = NULL;
/* Reinit the repository */
- cl_git_pass(git_repository_init(&_repo, "not.overwrite.git", 1));
- git_repository_config(&config, _repo);
+ cl_git_pass(git_repository_init(&g_repo, "not.overwrite.git", 1));
+ git_repository_config(&config, g_repo);
/* Ensure the "core.ignorecase" config value hasn't been updated */
cl_git_pass(git_config_get_int32(¤t_value, config, "core.ignorecase"));
@@ -350,26 +357,26 @@ void test_repo_init__reinit_overwrites_filemode(void)
/* Init a new repo */
cl_set_cleanup(&cleanup_repository, "overwrite.git");
- cl_git_pass(git_repository_init(&_repo, "overwrite.git", 1));
+ cl_git_pass(git_repository_init(&g_repo, "overwrite.git", 1));
/* Change the "core.filemode" config value to something unlikely */
- cl_repo_set_bool(_repo, "core.filemode", !expected);
+ cl_repo_set_bool(g_repo, "core.filemode", !expected);
- git_repository_free(_repo);
- _repo = NULL;
+ git_repository_free(g_repo);
+ g_repo = NULL;
/* Reinit the repository */
- cl_git_pass(git_repository_init(&_repo, "overwrite.git", 1));
+ cl_git_pass(git_repository_init(&g_repo, "overwrite.git", 1));
/* Ensure the "core.filemode" config value has been reset */
- current_value = cl_repo_get_bool(_repo, "core.filemode");
+ current_value = cl_repo_get_bool(g_repo, "core.filemode");
cl_assert_equal_i(expected, current_value);
}
void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
{
assert_config_entry_on_init_bytype("core.logallrefupdates", GIT_ENOTFOUND, true);
- git_repository_free(_repo);
+ git_repository_free(g_repo);
assert_config_entry_on_init_bytype("core.logallrefupdates", true, false);
}
@@ -378,16 +385,16 @@ void test_repo_init__extended_0(void)
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
/* without MKDIR this should fail */
- cl_git_fail(git_repository_init_ext(&_repo, "extended", &opts));
+ cl_git_fail(git_repository_init_ext(&g_repo, "extended", &opts));
/* make the directory first, then it should succeed */
cl_git_pass(git_futils_mkdir("extended", 0775, 0));
- cl_git_pass(git_repository_init_ext(&_repo, "extended", &opts));
+ cl_git_pass(git_repository_init_ext(&g_repo, "extended", &opts));
- cl_assert(!git__suffixcmp(git_repository_workdir(_repo), "/extended/"));
- cl_assert(!git__suffixcmp(git_repository_path(_repo), "/extended/.git/"));
- cl_assert(!git_repository_is_bare(_repo));
- cl_assert(git_repository_is_empty(_repo));
+ cl_assert(!git__suffixcmp(git_repository_workdir(g_repo), "/extended/"));
+ cl_assert(!git__suffixcmp(git_repository_path(g_repo), "/extended/.git/"));
+ cl_assert(!git_repository_is_bare(g_repo));
+ cl_assert(git_repository_is_empty(g_repo));
cleanup_repository("extended");
}
@@ -407,33 +414,33 @@ void test_repo_init__extended_1(void)
opts.initial_head = "development";
opts.origin_url = "https://github.com/libgit2/libgit2.git";
- cl_git_pass(git_repository_init_ext(&_repo, "root/b/c.git", &opts));
+ cl_git_pass(git_repository_init_ext(&g_repo, "root/b/c.git", &opts));
- cl_assert(!git__suffixcmp(git_repository_workdir(_repo), "/c_wd/"));
- cl_assert(!git__suffixcmp(git_repository_path(_repo), "/c.git/"));
+ cl_assert(!git__suffixcmp(git_repository_workdir(g_repo), "/c_wd/"));
+ cl_assert(!git__suffixcmp(git_repository_path(g_repo), "/c.git/"));
cl_assert(git_path_isfile("root/b/c_wd/.git"));
- cl_assert(!git_repository_is_bare(_repo));
+ cl_assert(!git_repository_is_bare(g_repo));
/* repo will not be counted as empty because we set head to "development" */
- cl_assert(!git_repository_is_empty(_repo));
+ cl_assert(!git_repository_is_empty(g_repo));
- cl_git_pass(git_path_lstat(git_repository_path(_repo), &st));
+ cl_git_pass(git_path_lstat(git_repository_path(g_repo), &st));
cl_assert(S_ISDIR(st.st_mode));
if (cl_is_chmod_supported())
cl_assert((S_ISGID & st.st_mode) == S_ISGID);
else
cl_assert((S_ISGID & st.st_mode) == 0);
- cl_git_pass(git_reference_lookup(&ref, _repo, "HEAD"));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
cl_assert(git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC);
cl_assert_equal_s("refs/heads/development", git_reference_symbolic_target(ref));
git_reference_free(ref);
- cl_git_pass(git_remote_lookup(&remote, _repo, "origin"));
+ cl_git_pass(git_remote_lookup(&remote, g_repo, "origin"));
cl_assert_equal_s("origin", git_remote_name(remote));
cl_assert_equal_s(opts.origin_url, git_remote_url(remote));
git_remote_free(remote);
- git_repository_free(_repo);
+ git_repository_free(g_repo);
cl_fixture_cleanup("root");
}
@@ -449,17 +456,17 @@ void test_repo_init__relative_gitdir(void)
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR;
/* make the directory first, then it should succeed */
- cl_git_pass(git_repository_init_ext(&_repo, "root/b/my_repository", &opts));
+ cl_git_pass(git_repository_init_ext(&g_repo, "root/b/my_repository", &opts));
- cl_assert(!git__suffixcmp(git_repository_workdir(_repo), "root/b/c_wd/"));
- cl_assert(!git__suffixcmp(git_repository_path(_repo), "root/b/my_repository/"));
- cl_assert(!git_repository_is_bare(_repo));
- cl_assert(git_repository_is_empty(_repo));
+ cl_assert(!git__suffixcmp(git_repository_workdir(g_repo), "root/b/c_wd/"));
+ cl_assert(!git__suffixcmp(git_repository_path(g_repo), "root/b/my_repository/"));
+ cl_assert(!git_repository_is_bare(g_repo));
+ cl_assert(git_repository_is_empty(g_repo));
/* Verify that the gitlink and worktree entries are relative */
/* Verify worktree */
- assert_config_entry_value(_repo, "core.worktree", "../c_wd/");
+ assert_config_entry_value(g_repo, "core.worktree", "../c_wd/");
/* Verify gitlink */
cl_git_pass(git_futils_readbuffer(&dot_git_content, "root/b/c_wd/.git"));
@@ -485,18 +492,18 @@ void test_repo_init__relative_gitdir_2(void)
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR;
/* make the directory first, then it should succeed */
- cl_git_pass(git_repository_init_ext(&_repo, "root/b/my_repository", &opts));
+ cl_git_pass(git_repository_init_ext(&g_repo, "root/b/my_repository", &opts));
git_buf_dispose(&full_path);
- cl_assert(!git__suffixcmp(git_repository_workdir(_repo), "root/b/c_wd/"));
- cl_assert(!git__suffixcmp(git_repository_path(_repo), "root/b/my_repository/"));
- cl_assert(!git_repository_is_bare(_repo));
- cl_assert(git_repository_is_empty(_repo));
+ cl_assert(!git__suffixcmp(git_repository_workdir(g_repo), "root/b/c_wd/"));
+ cl_assert(!git__suffixcmp(git_repository_path(g_repo), "root/b/my_repository/"));
+ cl_assert(!git_repository_is_bare(g_repo));
+ cl_assert(git_repository_is_empty(g_repo));
/* Verify that the gitlink and worktree entries are relative */
/* Verify worktree */
- assert_config_entry_value(_repo, "core.worktree", "../c_wd/");
+ assert_config_entry_value(g_repo, "core.worktree", "../c_wd/");
/* Verify gitlink */
cl_git_pass(git_futils_readbuffer(&dot_git_content, "root/b/c_wd/.git"));
@@ -513,11 +520,11 @@ void test_repo_init__can_reinit_an_initialized_repository(void)
cl_set_cleanup(&cleanup_repository, "extended");
cl_git_pass(git_futils_mkdir("extended", 0775, 0));
- cl_git_pass(git_repository_init(&_repo, "extended", false));
+ cl_git_pass(git_repository_init(&g_repo, "extended", false));
cl_git_pass(git_repository_init(&reinit, "extended", false));
- cl_assert_equal_s(git_repository_path(_repo), git_repository_path(reinit));
+ cl_assert_equal_s(git_repository_path(g_repo), git_repository_path(reinit));
git_repository_free(reinit);
}
@@ -529,10 +536,10 @@ void test_repo_init__init_with_initial_commit(void)
cl_set_cleanup(&cleanup_repository, "committed");
/* Initialize the repository */
- cl_git_pass(git_repository_init(&_repo, "committed", 0));
+ cl_git_pass(git_repository_init(&g_repo, "committed", 0));
/* Index will be automatically created when requested for a new repo */
- cl_git_pass(git_repository_index(&index, _repo));
+ cl_git_pass(git_repository_index(&index, g_repo));
/* Create a file so we can commit it
*
@@ -558,7 +565,7 @@ void test_repo_init__init_with_initial_commit(void)
/* Make sure we're ready to use git_signature_default :-) */
{
git_config *cfg, *local;
- cl_git_pass(git_repository_config(&cfg, _repo));
+ cl_git_pass(git_repository_config(&cfg, g_repo));
cl_git_pass(git_config_open_level(&local, cfg, GIT_CONFIG_LEVEL_LOCAL));
cl_git_pass(git_config_set_string(local, "user.name", "Test User"));
cl_git_pass(git_config_set_string(local, "user.email", "t@example.com"));
@@ -572,12 +579,12 @@ void test_repo_init__init_with_initial_commit(void)
git_oid tree_id, commit_id;
git_tree *tree;
- cl_git_pass(git_signature_default(&sig, _repo));
+ cl_git_pass(git_signature_default(&sig, g_repo));
cl_git_pass(git_index_write_tree(&tree_id, index));
- cl_git_pass(git_tree_lookup(&tree, _repo, &tree_id));
+ cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
cl_git_pass(git_commit_create_v(
- &commit_id, _repo, "HEAD", sig, sig,
+ &commit_id, g_repo, "HEAD", sig, sig,
NULL, "First", tree, 0));
git_tree_free(tree);
@@ -665,3 +672,67 @@ void test_repo_init__unwriteable_directory(void)
clar__skip();
#endif
}
+
+void test_repo_init__defaultbranch_config(void)
+{
+ git_reference *head;
+
+ cl_set_cleanup(&cleanup_repository, "repo");
+
+ create_tmp_global_config("tmp_global_path", "init.defaultbranch", "my_default_branch");
+
+ cl_git_pass(git_repository_init(&g_repo, "repo", 0));
+ cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
+
+ cl_assert_equal_s("refs/heads/my_default_branch", git_reference_symbolic_target(head));
+
+ git_reference_free(head);
+}
+
+void test_repo_init__defaultbranch_config_empty(void)
+{
+ git_reference *head;
+
+ cl_set_cleanup(&cleanup_repository, "repo");
+
+ create_tmp_global_config("tmp_global_path", "init.defaultbranch", "");
+
+ cl_git_pass(git_repository_init(&g_repo, "repo", 0));
+ cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
+
+ cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));
+
+ git_reference_free(head);
+}
+
+void test_repo_init__longpath(void)
+{
+#ifdef GIT_WIN32
+ size_t padding = CONST_STRLEN("objects/pack/pack-.pack.lock") + GIT_OID_HEXSZ;
+ size_t max, i;
+ git_buf path = GIT_BUF_INIT;
+ git_repository *one = NULL, *two = NULL;
+
+ /*
+ * Files within repositories need to fit within MAX_PATH;
+ * that means a repo path must be at most (MAX_PATH - 18).
+ */
+ cl_git_pass(git_buf_puts(&path, clar_sandbox_path()));
+ cl_git_pass(git_buf_putc(&path, '/'));
+
+ max = ((MAX_PATH) - path.size) - padding;
+
+ for (i = 0; i < max - 1; i++)
+ cl_git_pass(git_buf_putc(&path, 'a'));
+
+ cl_git_pass(git_repository_init(&one, path.ptr, 1));
+
+ /* Paths longer than this are rejected */
+ cl_git_pass(git_buf_putc(&path, 'z'));
+ cl_git_fail(git_repository_init(&two, path.ptr, 1));
+
+ git_repository_free(one);
+ git_repository_free(two);
+ git_buf_dispose(&path);
+#endif
+}
diff --git a/tests/repo/open.c b/tests/repo/open.c
index 448ccdc..881a23d 100644
--- a/tests/repo/open.c
+++ b/tests/repo/open.c
@@ -35,7 +35,53 @@ void test_repo_open__format_version_1(void)
git_config_free(config);
git_repository_free(repo);
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_assert(git_repository_path(repo) != NULL);
+ cl_assert(git__suffixcmp(git_repository_path(repo), "/") == 0);
+ git_repository_free(repo);
+}
+
+void test_repo_open__format_version_1_with_valid_extension(void)
+{
+ git_repository *repo;
+ git_config *config;
+
+ repo = cl_git_sandbox_init("empty_bare.git");
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_git_pass(git_repository_config(&config, repo));
+
+ cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1));
+ cl_git_pass(git_config_set_int32(config, "extensions.noop", 1));
+
+ git_config_free(config);
+ git_repository_free(repo);
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_assert(git_repository_path(repo) != NULL);
+ cl_assert(git__suffixcmp(git_repository_path(repo), "/") == 0);
+ git_repository_free(repo);
+}
+
+void test_repo_open__format_version_1_with_invalid_extension(void)
+{
+ git_repository *repo;
+ git_config *config;
+
+ repo = cl_git_sandbox_init("empty_bare.git");
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_git_pass(git_repository_config(&config, repo));
+
+ cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1));
+ cl_git_pass(git_config_set_int32(config, "extensions.invalid", 1));
+
+ git_config_free(config);
+ git_repository_free(repo);
+
cl_git_fail(git_repository_open(&repo, "empty_bare.git"));
+ git_repository_free(repo);
}
void test_repo_open__standard_empty_repo_through_gitdir(void)
diff --git a/tests/resources/blametest.git/objects/1d/81379086fd6d91ee027e883cf6f4703a107dfb b/tests/resources/blametest.git/objects/1d/81379086fd6d91ee027e883cf6f4703a107dfb
new file mode 100644
index 0000000..a35dd56
Binary files /dev/null and b/tests/resources/blametest.git/objects/1d/81379086fd6d91ee027e883cf6f4703a107dfb differ
diff --git a/tests/resources/blametest.git/objects/34/73c3e21e76492d09b80b7c75569edc275dffcf b/tests/resources/blametest.git/objects/34/73c3e21e76492d09b80b7c75569edc275dffcf
new file mode 100644
index 0000000..887deff
Binary files /dev/null and b/tests/resources/blametest.git/objects/34/73c3e21e76492d09b80b7c75569edc275dffcf differ
diff --git a/tests/resources/blametest.git/objects/40/fcae7fb84378fdb037dc6a3ccbb33669c3f26d b/tests/resources/blametest.git/objects/40/fcae7fb84378fdb037dc6a3ccbb33669c3f26d
new file mode 100644
index 0000000..27fc76b
Binary files /dev/null and b/tests/resources/blametest.git/objects/40/fcae7fb84378fdb037dc6a3ccbb33669c3f26d differ
diff --git a/tests/resources/blametest.git/objects/46/ef45f4ae55c1f5dca64b9e1d7ca77c1798069b b/tests/resources/blametest.git/objects/46/ef45f4ae55c1f5dca64b9e1d7ca77c1798069b
new file mode 100644
index 0000000..487ac57
Binary files /dev/null and b/tests/resources/blametest.git/objects/46/ef45f4ae55c1f5dca64b9e1d7ca77c1798069b differ
diff --git a/tests/resources/blametest.git/objects/4b/0ca755f5bfd69ed6074f268b05bb0542a42c68 b/tests/resources/blametest.git/objects/4b/0ca755f5bfd69ed6074f268b05bb0542a42c68
new file mode 100644
index 0000000..698f5b1
Binary files /dev/null and b/tests/resources/blametest.git/objects/4b/0ca755f5bfd69ed6074f268b05bb0542a42c68 differ
diff --git a/tests/resources/blametest.git/objects/4d/8400b7ce2d15ef5045c2775ed33e82a326786e b/tests/resources/blametest.git/objects/4d/8400b7ce2d15ef5045c2775ed33e82a326786e
new file mode 100644
index 0000000..6e754df
Binary files /dev/null and b/tests/resources/blametest.git/objects/4d/8400b7ce2d15ef5045c2775ed33e82a326786e differ
diff --git a/tests/resources/blametest.git/objects/6b/52ee554131a5e7bacd15553fbd22408c5a8a6f b/tests/resources/blametest.git/objects/6b/52ee554131a5e7bacd15553fbd22408c5a8a6f
new file mode 100644
index 0000000..b53aa04
Binary files /dev/null and b/tests/resources/blametest.git/objects/6b/52ee554131a5e7bacd15553fbd22408c5a8a6f differ
diff --git a/tests/resources/blametest.git/objects/70/2c7aa5250abc42be69ef78ee8fa47a346cb2ce b/tests/resources/blametest.git/objects/70/2c7aa5250abc42be69ef78ee8fa47a346cb2ce
new file mode 100644
index 0000000..1f6f2da
Binary files /dev/null and b/tests/resources/blametest.git/objects/70/2c7aa5250abc42be69ef78ee8fa47a346cb2ce differ
diff --git a/tests/resources/blametest.git/objects/77/c796837eb003c81d2cd8a6577ef4e7edc61222 b/tests/resources/blametest.git/objects/77/c796837eb003c81d2cd8a6577ef4e7edc61222
new file mode 100644
index 0000000..ae5f740
Binary files /dev/null and b/tests/resources/blametest.git/objects/77/c796837eb003c81d2cd8a6577ef4e7edc61222 differ
diff --git a/tests/resources/blametest.git/objects/7e/135d94af53b6c5edbae6a77df8a0f09375e823 b/tests/resources/blametest.git/objects/7e/135d94af53b6c5edbae6a77df8a0f09375e823
new file mode 100644
index 0000000..b374ed1
Binary files /dev/null and b/tests/resources/blametest.git/objects/7e/135d94af53b6c5edbae6a77df8a0f09375e823 differ
diff --git a/tests/resources/blametest.git/objects/83/6bc00b06cb60eb0f629e237ad2b58adb2cfc7e b/tests/resources/blametest.git/objects/83/6bc00b06cb60eb0f629e237ad2b58adb2cfc7e
new file mode 100644
index 0000000..71f9c98
--- /dev/null
+++ b/tests/resources/blametest.git/objects/83/6bc00b06cb60eb0f629e237ad2b58adb2cfc7e
@@ -0,0 +1,3 @@
+xK
+1D]çÙÍB$ODÁ{¤{:Œà¢Oï€Ì¬Õ£àA·y¾uíìú"¢RA‘ˆÌ4Ö1„œØf/‰Å“]UϲȣëÔêX
+ŒM¬ÖÈ–,–sFc8©òêS[ô}⩼å£78p›OÚ„.%§÷fZÛua—\uùÝ®ƒú’JF€
\ No newline at end of file
diff --git a/tests/resources/blametest.git/objects/92/5bddd7a536a66eecb32faa41abd5bc9c192311 b/tests/resources/blametest.git/objects/92/5bddd7a536a66eecb32faa41abd5bc9c192311
new file mode 100644
index 0000000..aba34fa
Binary files /dev/null and b/tests/resources/blametest.git/objects/92/5bddd7a536a66eecb32faa41abd5bc9c192311 differ
diff --git a/tests/resources/blametest.git/objects/a3/4ead35680be7b9704fc4c6d750d182e228e02b b/tests/resources/blametest.git/objects/a3/4ead35680be7b9704fc4c6d750d182e228e02b
new file mode 100644
index 0000000..121934e
Binary files /dev/null and b/tests/resources/blametest.git/objects/a3/4ead35680be7b9704fc4c6d750d182e228e02b differ
diff --git a/tests/resources/blametest.git/objects/a4/641ad869ffad601aa8347e0770e949bb6d90df b/tests/resources/blametest.git/objects/a4/641ad869ffad601aa8347e0770e949bb6d90df
new file mode 100644
index 0000000..e54827c
Binary files /dev/null and b/tests/resources/blametest.git/objects/a4/641ad869ffad601aa8347e0770e949bb6d90df differ
diff --git a/tests/resources/blametest.git/objects/a8/ba8436b5d8ccbdfd5be597c194e7bb8e0a092f b/tests/resources/blametest.git/objects/a8/ba8436b5d8ccbdfd5be597c194e7bb8e0a092f
new file mode 100644
index 0000000..0bab0ef
--- /dev/null
+++ b/tests/resources/blametest.git/objects/a8/ba8436b5d8ccbdfd5be597c194e7bb8e0a092f
@@ -0,0 +1 @@
+x+)JMU04¶`040031QHÔ+©(aàÙµåJü5¹Ð…'3ëçÏÙP%ô0Ī ¬à½Ñ}_ՉΓÍE{þ4ºÙ©œrª -3'¬æ§šý^ÃuUÛ'Ëݘ’¿aÝn®ÏP5¥é5÷æ?ŽŸÉöp¦‡ÍÑ9íÊÚ_$*£Û\9ˆ
\ No newline at end of file
diff --git a/tests/resources/blametest.git/objects/ba/9089263dce882885ad84513f31495bf9d31132 b/tests/resources/blametest.git/objects/ba/9089263dce882885ad84513f31495bf9d31132
new file mode 100644
index 0000000..4610c26
Binary files /dev/null and b/tests/resources/blametest.git/objects/ba/9089263dce882885ad84513f31495bf9d31132 differ
diff --git a/tests/resources/blametest.git/objects/c3/8d3c99946b74173f9b037279f07d505195563f b/tests/resources/blametest.git/objects/c3/8d3c99946b74173f9b037279f07d505195563f
new file mode 100644
index 0000000..04fd9cc
Binary files /dev/null and b/tests/resources/blametest.git/objects/c3/8d3c99946b74173f9b037279f07d505195563f differ
diff --git a/tests/resources/blametest.git/objects/c4/c13c153a611418325c70d6e630fed373546c4d b/tests/resources/blametest.git/objects/c4/c13c153a611418325c70d6e630fed373546c4d
new file mode 100644
index 0000000..ba52060
Binary files /dev/null and b/tests/resources/blametest.git/objects/c4/c13c153a611418325c70d6e630fed373546c4d differ
diff --git a/tests/resources/blametest.git/objects/d2/bc4f27cbb72260eeec350087d81a60a122efe9 b/tests/resources/blametest.git/objects/d2/bc4f27cbb72260eeec350087d81a60a122efe9
new file mode 100644
index 0000000..b4d6c6d
Binary files /dev/null and b/tests/resources/blametest.git/objects/d2/bc4f27cbb72260eeec350087d81a60a122efe9 differ
diff --git a/tests/resources/blametest.git/objects/d3/c7316f0075debfe53b25e58f56b0a4b46e18c3 b/tests/resources/blametest.git/objects/d3/c7316f0075debfe53b25e58f56b0a4b46e18c3
new file mode 100644
index 0000000..73f00ee
--- /dev/null
+++ b/tests/resources/blametest.git/objects/d3/c7316f0075debfe53b25e58f56b0a4b46e18c3
@@ -0,0 +1,4 @@
+xm“ÉΣH„çÌSÔÝš†b©*¤îQ³Û`³c7öÅl¿—§wæÖyH)?)R©PF1].Ý ƒ…¿–¹ª@ž‰YÄ•EEKˆ•„ Ws…¼KBŽ¥®Ù\@Hàêšg9ÈU¹P|ª!/p"Ì!ÉD$Š„a
+LeëÒN3Ч ÈÙ ø^OÓÏ9ËéRLóõ[1]þP +ˆP€`Ã@†¡>ôsàRÍ@ÉæEûÈFð½ø?µûoðZÿ m®Í½kÀß¿JÖŒ
\ÃÁΰ¥0òµßœè¼Ý[–$Y‘¤Rï4Mß«Ë9?ò¶{·–·äÙ.µÅ)æuià>$¥9{ÿs
+¤X€w‰¦Oçi®&EÔ4‘<ÏVWr}fJ¥ewHÖÄ}«ü™eo¦ÖÖ
£}ȼ1<ñrï'ÆÝG§‹Þ„·Ä"î';LëkÞDNoÕ¢sÙ0Ú݃4+ºnŸò¸¯
XõUÒyð%èUUùaïŸlkñò°¬§MrzûvìÙuvÌCØ{”âñn6t¨?ýÙ“^I2:ÉgNG+§z©Ï®µš=WÌ=#Ì©ßÅæHbNj솇}Æøq(ƒ˜»Ž¯\)p×½ƒ·Cóôã\rÝ%+‡¡¹±e÷"Ùn§g $w¤3z¢>M•ˆ˜F`Òe¤R€N¢Îƒú»9´Èæ·*=O&]t6È{Îa²žõR~Ìñ›°ËpiSÊNÃ’ Ý:ø@úu*ëBÏÖ¸ÛùÊ8²¸9^Ïr„)Ü´V
+ÈÉü†¯Ý÷ ×:»lÛãM1`ˆØÏ|\k¸Kõ£©JÍh ¤ÜHpÖHzs%‹åRçûˆ÷v94Øóv_MAª(½E+QÑöf¥QsgA÷Jî»6ÆFÎú/—xcòÒ+ߟհ«qœiäËáK苬Š_Æç'ÕÄÑŒG»UeÍQÀºÅy?!îkëØ{+0Æ’}7|cí^Cíż·£/FקXÖ( 29zÂ\6‡M`Ô£b¹ÏsÝ™F1½ÆÓcÞ¢ñËãt÷ƒ?y¨ÿ2£ÙêŸCIe òoËs¡þæÌIª
\ No newline at end of file
diff --git a/tests/resources/blametest.git/objects/d6/7268771ef5244f4aa224df29d4e4ae0bed2fd8 b/tests/resources/blametest.git/objects/d6/7268771ef5244f4aa224df29d4e4ae0bed2fd8
new file mode 100644
index 0000000..ee48478
Binary files /dev/null and b/tests/resources/blametest.git/objects/d6/7268771ef5244f4aa224df29d4e4ae0bed2fd8 differ
diff --git a/tests/resources/blametest.git/objects/d6/afeea2c4657c743dedab24a8a62da96f63547d b/tests/resources/blametest.git/objects/d6/afeea2c4657c743dedab24a8a62da96f63547d
new file mode 100644
index 0000000..f3e52be
Binary files /dev/null and b/tests/resources/blametest.git/objects/d6/afeea2c4657c743dedab24a8a62da96f63547d differ
diff --git a/tests/resources/blametest.git/objects/d9/3e87a0863c7ec5e772f99e72ca9efddf0ca718 b/tests/resources/blametest.git/objects/d9/3e87a0863c7ec5e772f99e72ca9efddf0ca718
new file mode 100644
index 0000000..e1c0f00
Binary files /dev/null and b/tests/resources/blametest.git/objects/d9/3e87a0863c7ec5e772f99e72ca9efddf0ca718 differ
diff --git a/tests/resources/blametest.git/objects/f0/5190494260c2f6b6d045ac9bf27cb6d7e0abcc b/tests/resources/blametest.git/objects/f0/5190494260c2f6b6d045ac9bf27cb6d7e0abcc
new file mode 100644
index 0000000..6df7d34
Binary files /dev/null and b/tests/resources/blametest.git/objects/f0/5190494260c2f6b6d045ac9bf27cb6d7e0abcc differ
diff --git a/tests/resources/blametest.git/objects/f4/f4b926582a2c23c6e3ba05309eaa89244c1d68 b/tests/resources/blametest.git/objects/f4/f4b926582a2c23c6e3ba05309eaa89244c1d68
new file mode 100644
index 0000000..32c1cdf
Binary files /dev/null and b/tests/resources/blametest.git/objects/f4/f4b926582a2c23c6e3ba05309eaa89244c1d68 differ
diff --git a/tests/resources/blametest.git/objects/f9/264f7fbd31ae7a18b7931ed8946fb0aebb0af3 b/tests/resources/blametest.git/objects/f9/264f7fbd31ae7a18b7931ed8946fb0aebb0af3
new file mode 100644
index 0000000..942a7ee
Binary files /dev/null and b/tests/resources/blametest.git/objects/f9/264f7fbd31ae7a18b7931ed8946fb0aebb0af3 differ
diff --git a/tests/resources/blametest.git/objects/fa/01940156471352d5483b4f26b7c849dfaa7eef b/tests/resources/blametest.git/objects/fa/01940156471352d5483b4f26b7c849dfaa7eef
new file mode 100644
index 0000000..b392e44
Binary files /dev/null and b/tests/resources/blametest.git/objects/fa/01940156471352d5483b4f26b7c849dfaa7eef differ
diff --git a/tests/resources/blametest.git/refs/heads/master b/tests/resources/blametest.git/refs/heads/master
index d1bc4ca..9d17158 100644
--- a/tests/resources/blametest.git/refs/heads/master
+++ b/tests/resources/blametest.git/refs/heads/master
@@ -1 +1 @@
-6653ff42313eb5c82806f145391b18a9699800c7
+d93e87a0863c7ec5e772f99e72ca9efddf0ca718
diff --git a/tests/resources/config/config12 b/tests/resources/config/config12
index 6917880..2e92762 100644
--- a/tests/resources/config/config12
+++ b/tests/resources/config/config12
@@ -11,3 +11,13 @@ and other stuff !@#"
multiline comment # with ;\n special chars \
and other stuff !@#" #^^^
back = "this is \ba phrase"
+ dollar = some $sign
+ multiquotes = !ls "x" \
+ ls "# comment2" \
+ $HOME
+ multiquotes2 = !ls "x" \
+ ls "\"# comment2" \
+ $HOME\"
+ multiquotes3 = hi "# ho" there "are #" more \
+quotes
+ quotecomment = hi "# ho" there "are #" more # and a real comment
diff --git a/tests/resources/crlf.git/objects/05/5c8729cdcc372500a08db659c045e16c4409fb b/tests/resources/crlf.git/objects/05/5c8729cdcc372500a08db659c045e16c4409fb
new file mode 100644
index 0000000..44076ca
Binary files /dev/null and b/tests/resources/crlf.git/objects/05/5c8729cdcc372500a08db659c045e16c4409fb differ
diff --git a/tests/resources/crlf.git/objects/1e/c507638b806aba45d6142082885f2a9e88322d b/tests/resources/crlf.git/objects/1e/c507638b806aba45d6142082885f2a9e88322d
new file mode 100644
index 0000000..ca97967
Binary files /dev/null and b/tests/resources/crlf.git/objects/1e/c507638b806aba45d6142082885f2a9e88322d differ
diff --git a/tests/resources/crlf.git/objects/44/b0be18671a284f1156117b6338edac2663341c b/tests/resources/crlf.git/objects/44/b0be18671a284f1156117b6338edac2663341c
new file mode 100644
index 0000000..0576e62
Binary files /dev/null and b/tests/resources/crlf.git/objects/44/b0be18671a284f1156117b6338edac2663341c differ
diff --git a/tests/resources/crlf.git/objects/55/1b8fce462bba005ab6d34a2244d8a3f6b03dd0 b/tests/resources/crlf.git/objects/55/1b8fce462bba005ab6d34a2244d8a3f6b03dd0
new file mode 100644
index 0000000..7501c88
Binary files /dev/null and b/tests/resources/crlf.git/objects/55/1b8fce462bba005ab6d34a2244d8a3f6b03dd0 differ
diff --git a/tests/resources/crlf.git/objects/b8/986fec0f7bde90f78ac72706e782d82f24f2f0 b/tests/resources/crlf.git/objects/b8/986fec0f7bde90f78ac72706e782d82f24f2f0
new file mode 100644
index 0000000..d745d20
--- /dev/null
+++ b/tests/resources/crlf.git/objects/b8/986fec0f7bde90f78ac72706e782d82f24f2f0
@@ -0,0 +1,3 @@
+x¥M
+Â0…]çs%3ÓDtá
¼À$™bÁ6¥F¼¾Q¼»÷ï¥2McònSWU`Ž6*ö¾C¡žÄ½Gì¢w®×,‰|SŒÉ,²ê\‰¦à˜Ù#‹ôYö®8t);
qÈÁȳÞÊ
+—ü’5ÃõV¦G™á -ý¨“~‹ŸÛ¥2=ù`ÑÁÖ²µ¦¥mlÕ?1æœ3Ècn¶
ºHã]aïjÞ@U
\ No newline at end of file
diff --git a/tests/resources/crlf.git/refs/heads/ident b/tests/resources/crlf.git/refs/heads/ident
new file mode 100644
index 0000000..8732f0c
--- /dev/null
+++ b/tests/resources/crlf.git/refs/heads/ident
@@ -0,0 +1 @@
+b8986fec0f7bde90f78ac72706e782d82f24f2f0
diff --git a/tests/resources/crlf.git/refs/heads/no-ident b/tests/resources/crlf.git/refs/heads/no-ident
new file mode 100644
index 0000000..fa9a673
--- /dev/null
+++ b/tests/resources/crlf.git/refs/heads/no-ident
@@ -0,0 +1 @@
+1ec507638b806aba45d6142082885f2a9e88322d
diff --git a/tests/resources/merge-recursive/.gitted/objects/info/commit-graph b/tests/resources/merge-recursive/.gitted/objects/info/commit-graph
new file mode 100644
index 0000000..da055f1
Binary files /dev/null and b/tests/resources/merge-recursive/.gitted/objects/info/commit-graph differ
diff --git a/tests/resources/renames/.gitted/ORIG_HEAD b/tests/resources/renames/.gitted/ORIG_HEAD
new file mode 100644
index 0000000..642c319
--- /dev/null
+++ b/tests/resources/renames/.gitted/ORIG_HEAD
@@ -0,0 +1 @@
+19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13
diff --git a/tests/resources/renames/.gitted/index b/tests/resources/renames/.gitted/index
index 72363c0..5882a8d 100644
Binary files a/tests/resources/renames/.gitted/index and b/tests/resources/renames/.gitted/index differ
diff --git a/tests/resources/renames/.gitted/logs/HEAD b/tests/resources/renames/.gitted/logs/HEAD
index e697922..e6da678 100644
--- a/tests/resources/renames/.gitted/logs/HEAD
+++ b/tests/resources/renames/.gitted/logs/HEAD
@@ -2,3 +2,8 @@
31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 2bc7f351d20b53f1c72c16c4b036e491c478c49a Russell Belfer <rb@github.com> 1351024817 -0700 commit: copy and rename with no change
2bc7f351d20b53f1c72c16c4b036e491c478c49a 1c068dee5790ef1580cfc4cd670915b48d790084 Russell Belfer <rb@github.com> 1361485758 -0800 commit: rewrites, copies with changes, etc.
1c068dee5790ef1580cfc4cd670915b48d790084 19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13 Russell Belfer <rb@github.com> 1361486360 -0800 commit: more renames and smallish modifications
+19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 Kartikaya Gupta <kats@pancake.staktrace.com> 1618486966 -0400 checkout: moving from master to break_rewrite
+31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 db98035f715427eef1f5e17f03e1801c05301e9e Kartikaya Gupta <kats@pancake.staktrace.com> 1618487039 -0400 commit: This test needs to start with a minimum of four files
+db98035f715427eef1f5e17f03e1801c05301e9e 7e7bfb88ba9bc65fd700fee1819cf1c317aafa56 Kartikaya Gupta <kats@pancake.staktrace.com> 1618487097 -0400 commit: Copy/modify files around
+7e7bfb88ba9bc65fd700fee1819cf1c317aafa56 19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13 Kartikaya Gupta <kats@pancake.staktrace.com> 1618487105 -0400 checkout: moving from break_rewrite to master
+19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13 19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13 Kartikaya Gupta <kats@pancake.staktrace.com> 1618487271 -0400 reset: moving to HEAD
diff --git a/tests/resources/renames/.gitted/objects/41/2a2eaf2c13103ea976b3b02c17abee7a358432 b/tests/resources/renames/.gitted/objects/41/2a2eaf2c13103ea976b3b02c17abee7a358432
new file mode 100644
index 0000000..d0d3334
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/41/2a2eaf2c13103ea976b3b02c17abee7a358432 differ
diff --git a/tests/resources/renames/.gitted/objects/5a/71babaaac78a758b52576a60cea3c218c8b546 b/tests/resources/renames/.gitted/objects/5a/71babaaac78a758b52576a60cea3c218c8b546
new file mode 100644
index 0000000..e685bfa
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/5a/71babaaac78a758b52576a60cea3c218c8b546 differ
diff --git a/tests/resources/renames/.gitted/objects/7e/7bfb88ba9bc65fd700fee1819cf1c317aafa56 b/tests/resources/renames/.gitted/objects/7e/7bfb88ba9bc65fd700fee1819cf1c317aafa56
new file mode 100644
index 0000000..e53c843
--- /dev/null
+++ b/tests/resources/renames/.gitted/objects/7e/7bfb88ba9bc65fd700fee1819cf1c317aafa56
@@ -0,0 +1,2 @@
+x¥ŽKn„0³ö)ú™éö)Š"e1‹9EcÚ
+bÀÈ4nî0ËWR•^®Ë2)ØŽ>´‰€'ËV¸ØLŽÐ ÷±Ü€×Ž<ˆDv!ygÍÆMV…qèºP"o£H¡„b¹TJHƒC’^úW<¹é4óÉð86eøšY÷Ÿ×̳ÜvåYg¹åº|u”|ŠØGøDh.z½Uy·c~ëvÞ—:Nå„2½dnõXGó©T´
\ No newline at end of file
diff --git a/tests/resources/renames/.gitted/objects/bf/102db0c9c0c1513909a90e0611b5dddfc87c93 b/tests/resources/renames/.gitted/objects/bf/102db0c9c0c1513909a90e0611b5dddfc87c93
new file mode 100644
index 0000000..69ddd68
--- /dev/null
+++ b/tests/resources/renames/.gitted/objects/bf/102db0c9c0c1513909a90e0611b5dddfc87c93
@@ -0,0 +1,2 @@
+x+)JMU042a040031Qpttd83ƒÿ×Ñ–fÓ®œ-°[yéï³ÚËéPi'''†¨Â]»Vï*í
+ÏJ8·øĉnPiggg†×›·¯—U=á©«Ÿ”¡vR%bû¹¿ Pi¬º¼:6Ž
\ No newline at end of file
diff --git a/tests/resources/renames/.gitted/objects/cc/980ffac5f1393696d4cd703ea9d2fde67dd367 b/tests/resources/renames/.gitted/objects/cc/980ffac5f1393696d4cd703ea9d2fde67dd367
new file mode 100644
index 0000000..ac7a005
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/cc/980ffac5f1393696d4cd703ea9d2fde67dd367 differ
diff --git a/tests/resources/renames/.gitted/objects/db/98035f715427eef1f5e17f03e1801c05301e9e b/tests/resources/renames/.gitted/objects/db/98035f715427eef1f5e17f03e1801c05301e9e
new file mode 100644
index 0000000..48bc2e1
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/db/98035f715427eef1f5e17f03e1801c05301e9e differ
diff --git a/tests/resources/renames/.gitted/objects/eb/b3b7af1d25c8492d2f626826c92458b7cefd60 b/tests/resources/renames/.gitted/objects/eb/b3b7af1d25c8492d2f626826c92458b7cefd60
new file mode 100644
index 0000000..813e7ad
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/eb/b3b7af1d25c8492d2f626826c92458b7cefd60 differ
diff --git a/tests/resources/renames/.gitted/objects/ed/2a95c4a6c295b9afcea50baff63ec544ccf600 b/tests/resources/renames/.gitted/objects/ed/2a95c4a6c295b9afcea50baff63ec544ccf600
new file mode 100644
index 0000000..4f439e2
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/ed/2a95c4a6c295b9afcea50baff63ec544ccf600 differ
diff --git a/tests/resources/renames/.gitted/objects/f6/7e2f70efe89665e829ea0d77c46965ad1307e4 b/tests/resources/renames/.gitted/objects/f6/7e2f70efe89665e829ea0d77c46965ad1307e4
new file mode 100644
index 0000000..1cad213
Binary files /dev/null and b/tests/resources/renames/.gitted/objects/f6/7e2f70efe89665e829ea0d77c46965ad1307e4 differ
diff --git a/tests/resources/renames/.gitted/refs/heads/break_rewrite b/tests/resources/renames/.gitted/refs/heads/break_rewrite
new file mode 100644
index 0000000..d170915
--- /dev/null
+++ b/tests/resources/renames/.gitted/refs/heads/break_rewrite
@@ -0,0 +1 @@
+7e7bfb88ba9bc65fd700fee1819cf1c317aafa56
diff --git a/tests/resources/testrepo.git/objects/info/commit-graph b/tests/resources/testrepo.git/objects/info/commit-graph
new file mode 100644
index 0000000..2ef31d8
Binary files /dev/null and b/tests/resources/testrepo.git/objects/info/commit-graph differ
diff --git a/tests/resources/testrepo.git/objects/pack/multi-pack-index b/tests/resources/testrepo.git/objects/pack/multi-pack-index
new file mode 100644
index 0000000..95102ae
Binary files /dev/null and b/tests/resources/testrepo.git/objects/pack/multi-pack-index differ
diff --git a/tests/revwalk/basic.c b/tests/revwalk/basic.c
index ee70ec6..2c8d885 100644
--- a/tests/revwalk/basic.c
+++ b/tests/revwalk/basic.c
@@ -530,7 +530,7 @@ void test_revwalk_basic__big_timestamp(void)
cl_git_pass(git_reference_peel((git_object **) &tip, head, GIT_OBJECT_COMMIT));
/* Commit with a far-ahead timestamp, we should be able to parse it in the revwalk */
- cl_git_pass(git_signature_new(&sig, "Joe", "joe@example.com", 2399662595ll, 0));
+ cl_git_pass(git_signature_new(&sig, "Joe", "joe@example.com", INT64_C(2399662595), 0));
cl_git_pass(git_commit_tree(&tree, tip));
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1,
diff --git a/tests/status/status_helpers.h b/tests/status/status_helpers.h
index 242076c..464266a 100644
--- a/tests/status/status_helpers.h
+++ b/tests/status/status_helpers.h
@@ -9,6 +9,7 @@ typedef struct {
const char** expected_paths;
int expected_entry_count;
const char *file;
+ const char *func;
int line;
bool debug;
} status_entry_counts;
@@ -18,6 +19,7 @@ typedef struct {
(counts).expected_statuses = (statuses); \
(counts).expected_paths = (paths); \
(counts).file = __FILE__; \
+ (counts).func = __func__; \
(counts).line = __LINE__; \
} while (0)
diff --git a/tests/status/submodules.c b/tests/status/submodules.c
index 12edce2..38a3947 100644
--- a/tests/status/submodules.c
+++ b/tests/status/submodules.c
@@ -71,12 +71,12 @@ static int cb_status__match(const char *p, unsigned int s, void *payload)
int idx = counts->entry_count++;
clar__assert_equal(
- counts->file, counts->line,
+ counts->file, counts->func, counts->line,
"Status path mismatch", 1,
"%s", counts->expected_paths[idx], p);
clar__assert_equal(
- counts->file, counts->line,
+ counts->file, counts->func, counts->line,
"Status code mismatch", 1,
"%o", counts->expected_statuses[idx], s);
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index 7711b2d..d9fce44 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -605,6 +605,45 @@ void test_status_worktree__filemode_changes(void)
cl_assert_equal_i(0, counts.wrong_sorted_path);
}
+void test_status_worktree__filemode_non755(void)
+{
+ git_repository *repo = cl_git_sandbox_init("filemodes");
+ status_entry_counts counts;
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
+ git_buf executable_path = GIT_BUF_INIT;
+ git_buf nonexecutable_path = GIT_BUF_INIT;
+
+ if (!cl_is_chmod_supported())
+ return;
+
+ opts.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED |
+ GIT_STATUS_OPT_INCLUDE_IGNORED |
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
+
+ git_buf_joinpath(&executable_path, git_repository_workdir(repo), "exec_on");
+ cl_must_pass(p_chmod(git_buf_cstr(&executable_path), 0744));
+ git_buf_dispose(&executable_path);
+
+ git_buf_joinpath(&nonexecutable_path, git_repository_workdir(repo), "exec_off");
+
+ cl_must_pass(p_chmod(git_buf_cstr(&nonexecutable_path), 0655));
+ git_buf_dispose(&nonexecutable_path);
+
+ memset(&counts, 0, sizeof(counts));
+ counts.expected_entry_count = filemode_count;
+ counts.expected_paths = filemode_paths;
+ counts.expected_statuses = filemode_statuses;
+
+ cl_git_pass(
+ git_status_foreach_ext(repo, &opts, cb_status__normal, &counts)
+ );
+
+ cl_assert_equal_i(counts.expected_entry_count, counts.entry_count);
+ cl_assert_equal_i(0, counts.wrong_status_flags_count);
+ cl_assert_equal_i(0, counts.wrong_sorted_path);
+}
+
+
static int cb_status__interrupt(const char *p, unsigned int s, void *payload)
{
volatile int *count = (int *)payload;
@@ -949,7 +988,7 @@ void test_status_worktree__sorting_by_case(void)
void test_status_worktree__long_filenames(void)
{
- char path[260*4+1];
+ char path[260*4+1] = {0};
const char *expected_paths[] = {path};
const unsigned int expected_statuses[] = {GIT_STATUS_WT_NEW};
diff --git a/tests/stream/deprecated.c b/tests/stream/deprecated.c
index 2c2bbfd..fecd1be 100644
--- a/tests/stream/deprecated.c
+++ b/tests/stream/deprecated.c
@@ -1,19 +1,18 @@
-#undef GIT_DEPRECATE_HARD
-
#include "clar_libgit2.h"
#include "git2/sys/stream.h"
#include "streams/tls.h"
#include "streams/socket.h"
#include "stream.h"
-static git_stream test_stream;
-static int ctor_called;
-
void test_stream_deprecated__cleanup(void)
{
cl_git_pass(git_stream_register(GIT_STREAM_TLS | GIT_STREAM_STANDARD, NULL));
}
+#ifndef GIT_DEPRECATE_HARD
+static git_stream test_stream;
+static int ctor_called;
+
static int test_stream_init(git_stream **out, const char *host, const char *port)
{
GIT_UNUSED(host);
@@ -24,9 +23,11 @@ static int test_stream_init(git_stream **out, const char *host, const char *port
return 0;
}
+#endif
void test_stream_deprecated__register_tls(void)
{
+#ifndef GIT_DEPRECATE_HARD
git_stream *stream;
int error;
@@ -55,4 +56,5 @@ void test_stream_deprecated__register_tls(void)
cl_assert(&test_stream != stream);
git_stream_free(stream);
+#endif
}
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index f4d1e3b..fc458f8 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -90,7 +90,7 @@ void test_submodule_add__url_relative(void)
/* make sure we don't default to origin - rename origin -> test_remote */
cl_git_pass(git_remote_rename(&problems, g_repo, "origin", "test_remote"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_git_fail(git_remote_lookup(&remote, g_repo, "origin"));
cl_git_pass(
diff --git a/tests/submodule/lookup.c b/tests/submodule/lookup.c
index 6f7506d..f49ebb4 100644
--- a/tests/submodule/lookup.c
+++ b/tests/submodule/lookup.c
@@ -42,6 +42,46 @@ void test_submodule_lookup__simple_lookup(void)
assert_submodule_exists(g_repo, "sm_added_and_uncommited/");
}
+void test_submodule_lookup__can_be_dupped(void)
+{
+ git_submodule *sm;
+ git_submodule *sm_duplicate;
+ const char *oid = "480095882d281ed676fe5b863569520e54a7d5c0";
+
+ /* Check original */
+ cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
+ cl_assert(git_submodule_owner(sm) == g_repo);
+ cl_assert_equal_s("sm_unchanged", git_submodule_name(sm));
+ cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0);
+ cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0);
+
+ cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
+
+ cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE);
+ cl_assert(git_submodule_update_strategy(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT);
+
+ /* Duplicate and free original */
+ cl_assert(git_submodule_dup(&sm_duplicate, sm) == 0);
+ git_submodule_free(sm);
+
+ /* Check duplicate */
+ cl_assert(git_submodule_owner(sm_duplicate) == g_repo);
+ cl_assert_equal_s("sm_unchanged", git_submodule_name(sm_duplicate));
+ cl_assert(git__suffixcmp(git_submodule_path(sm_duplicate), "sm_unchanged") == 0);
+ cl_assert(git__suffixcmp(git_submodule_url(sm_duplicate), "/submod2_target") == 0);
+
+ cl_assert(git_oid_streq(git_submodule_index_id(sm_duplicate), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_head_id(sm_duplicate), oid) == 0);
+ cl_assert(git_oid_streq(git_submodule_wd_id(sm_duplicate), oid) == 0);
+
+ cl_assert(git_submodule_ignore(sm_duplicate) == GIT_SUBMODULE_IGNORE_NONE);
+ cl_assert(git_submodule_update_strategy(sm_duplicate) == GIT_SUBMODULE_UPDATE_CHECKOUT);
+
+ git_submodule_free(sm_duplicate);
+}
+
void test_submodule_lookup__accessors(void)
{
git_submodule *sm;
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index 4bb0648..1d47596 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -199,22 +199,22 @@ git_repository *setup_fixture_submodule_with_path(void)
void assert__submodule_exists(
git_repository *repo, const char *name,
- const char *msg, const char *file, int line)
+ const char *msg, const char *file, const char *func, int line)
{
git_submodule *sm;
int error = git_submodule_lookup(&sm, repo, name);
if (error)
- cl_git_report_failure(error, 0, file, line, msg);
- cl_assert_at_line(sm != NULL, file, line);
+ cl_git_report_failure(error, 0, file, func, line, msg);
+ cl_assert_at_line(sm != NULL, file, func, line);
git_submodule_free(sm);
}
void refute__submodule_exists(
git_repository *repo, const char *name, int expected_error,
- const char *msg, const char *file, int line)
+ const char *msg, const char *file, const char *func, int line)
{
clar__assert_equal(
- file, line, msg, 1, "%i",
+ file, func, line, msg, 1, "%i",
expected_error, (int)(git_submodule_lookup(NULL, repo, name)));
}
diff --git a/tests/submodule/submodule_helpers.h b/tests/submodule/submodule_helpers.h
index d112b0c..3c3f062 100644
--- a/tests/submodule/submodule_helpers.h
+++ b/tests/submodule/submodule_helpers.h
@@ -10,16 +10,16 @@ extern git_repository *setup_fixture_submodule_with_path(void);
extern unsigned int get_submodule_status(git_repository *, const char *);
-extern void assert__submodule_exists(
- git_repository *, const char *, const char *, const char *, int);
+extern void assert__submodule_exists(git_repository *, const char *,
+ const char *, const char *, const char *, int);
#define assert_submodule_exists(repo,name) \
- assert__submodule_exists(repo, name, "git_submodule_lookup(" #name ") failed", __FILE__, __LINE__)
+ assert__submodule_exists(repo, name, "git_submodule_lookup(" #name ") failed", __FILE__, __func__, __LINE__)
-extern void refute__submodule_exists(
- git_repository *, const char *, int err, const char *, const char *, int);
+extern void refute__submodule_exists(git_repository *, const char *,
+ int err, const char *, const char *, const char *, int);
#define refute_submodule_exists(repo,name,code) \
- refute__submodule_exists(repo, name, code, "expected git_submodule_lookup(" #name ") to fail with error " #code, __FILE__, __LINE__)
+ refute__submodule_exists(repo, name, code, "expected git_submodule_lookup(" #name ") to fail with error " #code, __FILE__, __func__, __LINE__)
extern void dump_submodules(git_repository *repo);
diff --git a/tests/threads/atomic.c b/tests/threads/atomic.c
new file mode 100644
index 0000000..4d04a77
--- /dev/null
+++ b/tests/threads/atomic.c
@@ -0,0 +1,125 @@
+#include "clar_libgit2.h"
+
+void test_threads_atomic__atomic32_set(void)
+{
+ git_atomic32 v = {0};
+ git_atomic32_set(&v, 1);
+ cl_assert_equal_i(v.val, 1);
+}
+
+void test_threads_atomic__atomic32_get(void)
+{
+ git_atomic32 v = {1};
+ cl_assert_equal_i(git_atomic32_get(&v), 1);
+}
+
+void test_threads_atomic__atomic32_inc(void)
+{
+ git_atomic32 v = {0};
+ cl_assert_equal_i(git_atomic32_inc(&v), 1);
+ cl_assert_equal_i(v.val, 1);
+}
+
+void test_threads_atomic__atomic32_add(void)
+{
+ git_atomic32 v = {0};
+ cl_assert_equal_i(git_atomic32_add(&v, 1), 1);
+ cl_assert_equal_i(v.val, 1);
+}
+
+void test_threads_atomic__atomic32_dec(void)
+{
+ git_atomic32 v = {1};
+ cl_assert_equal_i(git_atomic32_dec(&v), 0);
+ cl_assert_equal_i(v.val, 0);
+}
+
+void test_threads_atomic__atomic64_set(void)
+{
+#ifndef GIT_ARCH_64
+ cl_skip();
+#else
+ git_atomic64 v = {0};
+ git_atomic64_set(&v, 1);
+ cl_assert_equal_i(v.val, 1);
+#endif
+}
+
+void test_threads_atomic__atomic64_get(void)
+{
+#ifndef GIT_ARCH_64
+ cl_skip();
+#else
+ git_atomic64 v = {1};
+ cl_assert_equal_i(git_atomic64_get(&v), 1);
+#endif
+}
+
+void test_threads_atomic__atomic64_add(void)
+{
+#ifndef GIT_ARCH_64
+ cl_skip();
+#else
+ git_atomic64 v = {0};
+ cl_assert_equal_i(git_atomic64_add(&v, 1), 1);
+ cl_assert_equal_i(v.val, 1);
+#endif
+}
+
+void test_threads_atomic__cas_pointer(void)
+{
+ int *value = NULL;
+ int newvalue1 = 1, newvalue2 = 2;
+
+ /* value is updated */
+ cl_assert_equal_p(git_atomic_compare_and_swap(&value, NULL, &newvalue1), NULL);
+ cl_assert_equal_p(value, &newvalue1);
+
+ /* value is not updated */
+ cl_assert_equal_p(git_atomic_compare_and_swap(&value, NULL, &newvalue2), &newvalue1);
+ cl_assert_equal_p(value, &newvalue1);
+}
+
+void test_threads_atomic__cas_intptr(void)
+{
+ intptr_t value = 0;
+ intptr_t oldvalue;
+ intptr_t newvalue;
+
+ /* value is updated */
+ oldvalue = 0;
+ newvalue = 1;
+ cl_assert_equal_i((intptr_t)git_atomic_compare_and_swap(&value, (void *)oldvalue, (void *)newvalue), 0);
+ cl_assert_equal_i(value, 1);
+
+ /* value is not updated */
+ oldvalue = 0;
+ newvalue = 2;
+ cl_assert_equal_i((intptr_t)git_atomic_compare_and_swap(&value, (void *)oldvalue, (void *)newvalue), 1);
+ cl_assert_equal_i(value, 1);
+}
+
+void test_threads_atomic__swap(void)
+{
+ int *value = NULL;
+ int newvalue = 1;
+
+ cl_assert_equal_p(git_atomic_swap(value, &newvalue), NULL);
+ cl_assert_equal_p(value, &newvalue);
+
+ cl_assert_equal_p(git_atomic_swap(value, NULL), &newvalue);
+ cl_assert_equal_p(value, NULL);
+}
+
+void test_threads_atomic__load_ptr(void)
+{
+ int value = 1;
+ int *ptr = &value;
+ cl_assert_equal_p(git_atomic_load(ptr), &value);
+}
+
+void test_threads_atomic__load_intptr(void)
+{
+ intptr_t value = 1;
+ cl_assert_equal_i((intptr_t)git_atomic_load(value), 1);
+}
diff --git a/tests/threads/basic.c b/tests/threads/basic.c
index ed4fd2f..2d7ddc2 100644
--- a/tests/threads/basic.c
+++ b/tests/threads/basic.c
@@ -54,6 +54,12 @@ static void *return_normally(void *param)
{
return param;
}
+
+static void *exit_abruptly(void *param)
+{
+ git_thread_exit(param);
+ return NULL;
+}
#endif
void test_threads_basic__exit(void)
@@ -70,7 +76,7 @@ void test_threads_basic__exit(void)
cl_assert_equal_sz(424242, (size_t)result);
/* Ensure that the return value of `git_thread_exit` is returned. */
- cl_git_pass(git_thread_create(&thread, return_normally, (void *)232323));
+ cl_git_pass(git_thread_create(&thread, exit_abruptly, (void *)232323));
cl_git_pass(git_thread_join(&thread, &result));
cl_assert_equal_sz(232323, (size_t)result);
#endif
diff --git a/tests/threads/diff.c b/tests/threads/diff.c
index 6996427..04c8cb9 100644
--- a/tests/threads/diff.c
+++ b/tests/threads/diff.c
@@ -17,7 +17,7 @@
static git_repository *_repo;
static git_tree *_a, *_b;
-static git_atomic _counts[4];
+static git_atomic32 _counts[4];
static int _check_counts;
#ifdef GIT_WIN32
static int _retries;
@@ -66,10 +66,10 @@ static void free_trees(void)
git_tree_free(_b); _b = NULL;
if (_check_counts) {
- cl_assert_equal_i(288, git_atomic_get(&_counts[0]));
- cl_assert_equal_i(112, git_atomic_get(&_counts[1]));
- cl_assert_equal_i( 80, git_atomic_get(&_counts[2]));
- cl_assert_equal_i( 96, git_atomic_get(&_counts[3]));
+ cl_assert_equal_i(288, git_atomic32_get(&_counts[0]));
+ cl_assert_equal_i(112, git_atomic32_get(&_counts[1]));
+ cl_assert_equal_i( 80, git_atomic32_get(&_counts[2]));
+ cl_assert_equal_i( 96, git_atomic32_get(&_counts[3]));
}
}
@@ -107,14 +107,14 @@ static void *run_index_diffs(void *arg)
/* keep some diff stats to make sure results are as expected */
i = git_diff_num_deltas(diff);
- git_atomic_add(&_counts[0], (int32_t)i);
+ git_atomic32_add(&_counts[0], (int32_t)i);
exp[0] = (int)i;
while (i > 0) {
switch (git_diff_get_delta(diff, --i)->status) {
- case GIT_DELTA_MODIFIED: exp[1]++; git_atomic_inc(&_counts[1]); break;
- case GIT_DELTA_ADDED: exp[2]++; git_atomic_inc(&_counts[2]); break;
- case GIT_DELTA_DELETED: exp[3]++; git_atomic_inc(&_counts[3]); break;
+ case GIT_DELTA_MODIFIED: exp[1]++; git_atomic32_inc(&_counts[1]); break;
+ case GIT_DELTA_ADDED: exp[2]++; git_atomic32_inc(&_counts[2]); break;
+ case GIT_DELTA_DELETED: exp[3]++; git_atomic32_inc(&_counts[3]); break;
default: break;
}
}
diff --git a/tests/threads/thread_helpers.h b/tests/threads/thread_helpers.h
index 3c13cfb..0f23a4c 100644
--- a/tests/threads/thread_helpers.h
+++ b/tests/threads/thread_helpers.h
@@ -1,4 +1,4 @@
-#include "thread-utils.h"
+#include "thread.h"
void run_in_parallel(
int repeats,
diff --git a/tests/threads/tlsdata.c b/tests/threads/tlsdata.c
new file mode 100644
index 0000000..7c69b44
--- /dev/null
+++ b/tests/threads/tlsdata.c
@@ -0,0 +1,65 @@
+#include "clar_libgit2.h"
+
+#include "thread_helpers.h"
+
+void test_threads_tlsdata__can_set_and_get(void)
+{
+ git_tlsdata_key key_one, key_two, key_three;
+
+ cl_git_pass(git_tlsdata_init(&key_one, NULL));
+ cl_git_pass(git_tlsdata_init(&key_two, NULL));
+ cl_git_pass(git_tlsdata_init(&key_three, NULL));
+
+ cl_git_pass(git_tlsdata_set(key_one, (void *)(size_t)42424242));
+ cl_git_pass(git_tlsdata_set(key_two, (void *)(size_t)0xdeadbeef));
+ cl_git_pass(git_tlsdata_set(key_three, (void *)(size_t)98761234));
+
+ cl_assert_equal_sz((size_t)42424242, git_tlsdata_get(key_one));
+ cl_assert_equal_sz((size_t)0xdeadbeef, git_tlsdata_get(key_two));
+ cl_assert_equal_sz((size_t)98761234, git_tlsdata_get(key_three));
+
+ cl_git_pass(git_tlsdata_dispose(key_one));
+ cl_git_pass(git_tlsdata_dispose(key_two));
+ cl_git_pass(git_tlsdata_dispose(key_three));
+}
+
+#ifdef GIT_THREADS
+
+static void *set_and_get(void *param)
+{
+ git_tlsdata_key *tlsdata_key = (git_tlsdata_key *)param;
+ int val;
+
+ if (git_tlsdata_set(*tlsdata_key, &val) != 0 ||
+ git_tlsdata_get(*tlsdata_key) != &val)
+ return (void *)0;
+
+ return (void *)1;
+}
+
+#endif
+
+#define THREAD_COUNT 10
+
+void test_threads_tlsdata__threads(void)
+{
+#ifdef GIT_THREADS
+ git_thread thread[THREAD_COUNT];
+ git_tlsdata_key tlsdata;
+ int i;
+
+ cl_git_pass(git_tlsdata_init(&tlsdata, NULL));
+
+ for (i = 0; i < THREAD_COUNT; i++)
+ cl_git_pass(git_thread_create(&thread[i], set_and_get, &tlsdata));
+
+ for (i = 0; i < THREAD_COUNT; i++) {
+ void *result;
+
+ cl_git_pass(git_thread_join(&thread[i], &result));
+ cl_assert_equal_sz(1, (size_t)result);
+ }
+
+ cl_git_pass(git_tlsdata_dispose(tlsdata));
+#endif
+}
diff --git a/tests/trace/windows/stacktrace.c b/tests/trace/windows/stacktrace.c
index 756ac68..0a77ef9 100644
--- a/tests/trace/windows/stacktrace.c
+++ b/tests/trace/windows/stacktrace.c
@@ -1,13 +1,12 @@
#include "clar_libgit2.h"
-#include "win32/w32_stack.h"
-#include "win32/w32_crtdbg_stacktrace.h"
+#include "win32/w32_leakcheck.h"
-#if defined(GIT_MSVC_CRTDBG)
+#if defined(GIT_WIN32_LEAKCHECK)
static void a(void)
{
char buf[10000];
- cl_assert(git_win32__stack(buf, sizeof(buf), 0, NULL, NULL) == 0);
+ cl_assert(git_win32_leakcheck_stack(buf, sizeof(buf), 0, NULL, NULL) == 0);
#if 0
fprintf(stderr, "Stacktrace from [%s:%d]:\n%s\n", __FILE__, __LINE__, buf);
@@ -27,7 +26,7 @@ static void c(void)
void test_trace_windows_stacktrace__basic(void)
{
-#if defined(GIT_MSVC_CRTDBG)
+#if defined(GIT_WIN32_LEAKCHECK)
c();
#endif
}
@@ -35,7 +34,7 @@ void test_trace_windows_stacktrace__basic(void)
void test_trace_windows_stacktrace__leaks(void)
{
-#if defined(GIT_MSVC_CRTDBG)
+#if defined(GIT_WIN32_LEAKCHECK)
void * p1;
void * p2;
void * p3;
@@ -47,84 +46,85 @@ void test_trace_windows_stacktrace__leaks(void)
/* remember outstanding leaks due to set setup
* and set mark/checkpoint.
*/
- before = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL |
- GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK,
+ before = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_TOTAL |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_SET_MARK,
NULL);
p1 = git__malloc(5);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"p1");
- cl_assert((leaks == 1));
+ cl_assert_equal_i(1, leaks);
p2 = git__malloc(5);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"p1,p2");
- cl_assert((leaks == 2));
+ cl_assert_equal_i(2, leaks);
p3 = git__malloc(5);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"p1,p2,p3");
- cl_assert((leaks == 3));
+ cl_assert_equal_i(3, leaks);
git__free(p2);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"p1,p3");
- cl_assert((leaks == 2));
+ cl_assert_equal_i(2, leaks);
/* move the mark. only new leaks should appear afterwards */
- error = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK,
+ error = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_SET_MARK,
NULL);
- cl_assert((error == 0));
+ /* cannot use cl_git_pass() since that may allocate memory. */
+ cl_assert_equal_i(0, error);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"not_p1,not_p3");
- cl_assert((leaks == 0));
+ cl_assert_equal_i(0, leaks);
p4 = git__malloc(5);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"p4,not_p1,not_p3");
- cl_assert((leaks == 1));
+ cl_assert_equal_i(1, leaks);
git__free(p1);
git__free(p3);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"p4");
- cl_assert((leaks == 1));
+ cl_assert_equal_i(1, leaks);
git__free(p4);
- leaks = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK,
+ leaks = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_SINCE_MARK,
"end");
- cl_assert((leaks == 0));
+ cl_assert_equal_i(0, leaks);
/* confirm current absolute leaks count matches beginning value. */
- after = git_win32__crtdbg_stacktrace__dump(
- GIT_WIN32__CRTDBG_STACKTRACE__QUIET |
- GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL,
+ after = git_win32_leakcheck_stacktrace_dump(
+ GIT_WIN32_LEAKCHECK_STACKTRACE_QUIET |
+ GIT_WIN32_LEAKCHECK_STACKTRACE_LEAKS_TOTAL,
"total");
- cl_assert((before == after));
+ cl_assert_equal_i(before, after);
#endif
}
-#if defined(GIT_MSVC_CRTDBG)
+#if defined(GIT_WIN32_LEAKCHECK)
static void aux_cb_alloc__1(unsigned int *aux_id)
{
static unsigned int aux_counter = 0;
@@ -141,12 +141,12 @@ static void aux_cb_lookup__1(unsigned int aux_id, char *aux_msg, size_t aux_msg_
void test_trace_windows_stacktrace__aux1(void)
{
-#if defined(GIT_MSVC_CRTDBG)
- git_win32__stack__set_aux_cb(aux_cb_alloc__1, aux_cb_lookup__1);
+#if defined(GIT_WIN32_LEAKCHECK)
+ git_win32_leakcheck_stack_set_aux_cb(aux_cb_alloc__1, aux_cb_lookup__1);
c();
c();
c();
c();
- git_win32__stack__set_aux_cb(NULL, NULL);
+ git_win32_leakcheck_stack_set_aux_cb(NULL, NULL);
#endif
}
diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c
index 80ae08d..ebfcc4d 100644
--- a/tests/win32/longpath.c
+++ b/tests/win32/longpath.c
@@ -4,9 +4,12 @@
#include "clone.h"
#include "buffer.h"
#include "futils.h"
+#include "repository.h"
static git_buf path = GIT_BUF_INIT;
+#define LONG_FILENAME "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt"
+
void test_win32_longpath__initialize(void)
{
#ifdef GIT_WIN32
@@ -29,34 +32,61 @@ void test_win32_longpath__initialize(void)
void test_win32_longpath__cleanup(void)
{
git_buf_dispose(&path);
+ cl_git_sandbox_cleanup();
}
-#ifdef GIT_WIN32
-void assert_name_too_long(void)
+void test_win32_longpath__errmsg_on_checkout(void)
{
- const git_error *err;
- size_t expected_len, actual_len;
- char *expected_msg;
+#ifdef GIT_WIN32
+ git_repository *repo;
- err = git_error_last();
- actual_len = strlen(err->message);
+ cl_git_fail(git_clone(&repo, cl_fixture("testrepo.git"), path.ptr, NULL));
+ cl_assert(git__prefixcmp(git_error_last()->message, "path too long") == 0);
+#endif
+}
- expected_msg = git_win32_get_error_message(ERROR_FILENAME_EXCED_RANGE);
- expected_len = strlen(expected_msg);
+void test_win32_longpath__workdir_path_validated(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo = cl_git_sandbox_init("testrepo");
+ git_buf out = GIT_BUF_INIT;
- /* check the suffix */
- cl_assert_equal_s(expected_msg, err->message + (actual_len - expected_len));
+ cl_git_pass(git_repository_workdir_path(&out, repo, "a.txt"));
- git__free(expected_msg);
-}
+ /* even if the repo path is a drive letter, this is too long */
+ cl_git_fail(git_repository_workdir_path(&out, repo, LONG_FILENAME));
+ cl_assert(git__prefixcmp(git_error_last()->message, "path too long") == 0);
+
+ cl_repo_set_bool(repo, "core.longpaths", true);
+ cl_git_pass(git_repository_workdir_path(&out, repo, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt"));
+ cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
+ git_buf_dispose(&out);
#endif
+}
-void test_win32_longpath__errmsg_on_checkout(void)
+void test_win32_longpath__status_and_add(void)
{
#ifdef GIT_WIN32
- git_repository *repo;
+ git_repository *repo = cl_git_sandbox_init("testrepo");
+ git_index *index;
+ git_buf out = GIT_BUF_INIT;
+ unsigned int status_flags;
- cl_git_fail(git_clone(&repo, cl_fixture("testrepo.git"), path.ptr, NULL));
- assert_name_too_long();
+ cl_repo_set_bool(repo, "core.longpaths", true);
+ cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
+
+ cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
+
+ cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
+ cl_assert_equal_i(GIT_STATUS_WT_NEW, status_flags);
+
+ cl_git_pass(git_repository_index(&index, repo));
+ cl_git_pass(git_index_add_bypath(index, LONG_FILENAME));
+
+ cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
+ cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status_flags);
+
+ git_index_free(index);
+ git_buf_dispose(&out);
#endif
}
diff --git a/tests/worktree/bare.c b/tests/worktree/bare.c
index 2a0e882..7234dff 100644
--- a/tests/worktree/bare.c
+++ b/tests/worktree/bare.c
@@ -28,7 +28,7 @@ void test_worktree_bare__list(void)
cl_git_pass(git_worktree_list(&wts, g_repo));
cl_assert_equal_i(wts.count, 0);
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
}
void test_worktree_bare__add(void)
@@ -48,7 +48,7 @@ void test_worktree_bare__add(void)
cl_assert_equal_i(0, git_repository_is_bare(wtrepo));
cl_assert_equal_i(1, git_repository_is_worktree(wtrepo));
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
git_worktree_free(wt);
git_repository_free(wtrepo);
}
diff --git a/tests/worktree/merge.c b/tests/worktree/merge.c
index 4b74382..2a12060 100644
--- a/tests/worktree/merge.c
+++ b/tests/worktree/merge.c
@@ -70,9 +70,9 @@ void test_worktree_merge__merge_setup(void)
ours, (const git_annotated_commit **)&theirs, 1));
for (i = 0; i < ARRAY_SIZE(merge_files); i++) {
- git_buf_clear(&path);
- cl_git_pass(git_buf_printf(&path, "%s/%s",
- fixture.worktree->gitdir, merge_files[i]));
+ cl_git_pass(git_buf_joinpath(&path,
+ fixture.worktree->gitdir,
+ merge_files[i]));
cl_assert(git_path_exists(path.ptr));
}
diff --git a/tests/worktree/refs.c b/tests/worktree/refs.c
index e62149d..27dc667 100644
--- a/tests/worktree/refs.c
+++ b/tests/worktree/refs.c
@@ -56,8 +56,8 @@ void test_worktree_refs__list(void)
}
exit:
- git_strarray_free(&refs);
- git_strarray_free(&wtrefs);
+ git_strarray_dispose(&refs);
+ git_strarray_dispose(&wtrefs);
cl_git_pass(error);
}
@@ -163,7 +163,10 @@ void test_worktree_refs__renaming_reference_updates_worktree_heads(void)
cl_git_pass(git_branch_lookup(&branch, fixture.repo,
"testrepo-worktree", GIT_BRANCH_LOCAL));
cl_git_pass(git_reference_rename(&renamed, branch, "refs/heads/renamed", 0, NULL));
- cl_git_pass(git_repository_head(&head, fixture.worktree));
+
+ cl_git_pass(git_reference_lookup(&head, fixture.worktree, GIT_HEAD_FILE));
+ cl_assert_equal_i(git_reference_type(head), GIT_REFERENCE_SYMBOLIC);
+ cl_assert_equal_s(git_reference_symbolic_target(head), "refs/heads/renamed");
git_reference_free(head);
git_reference_free(branch);
diff --git a/tests/worktree/repository.c b/tests/worktree/repository.c
index ca56413..c4eeadd 100644
--- a/tests/worktree/repository.c
+++ b/tests/worktree/repository.c
@@ -50,9 +50,12 @@ void test_worktree_repository__head_detached(void)
cl_assert(git_repository_head_detached(fixture.worktree));
cl_assert(git_repository_head_detached_for_worktree(fixture.repo, "testrepo-worktree"));
- cl_git_fail(git_repository_head_for_worktree(&head, fixture.repo, "testrepo-worktree"));
+ cl_git_pass(git_repository_head_for_worktree(&head, fixture.repo, "testrepo-worktree"));
+
+ cl_assert_equal_oid(&ref->target.oid, &head->target.oid);
git_reference_free(ref);
+ git_reference_free(head);
}
void test_worktree_repository__head_detached_fails_for_invalid_worktree(void)
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c
index 5e99dbf..9b87bfa 100644
--- a/tests/worktree/worktree.c
+++ b/tests/worktree/worktree.c
@@ -30,7 +30,7 @@ void test_worktree_worktree__list(void)
cl_assert_equal_i(wts.count, 1);
cl_assert_equal_s(wts.strings[0], "testrepo-worktree");
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
}
void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
@@ -44,8 +44,9 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
git_strarray wts;
size_t i, j, len;
- cl_git_pass(git_buf_printf(&path, "%s/worktrees/invalid",
- fixture.repo->commondir));
+ cl_git_pass(git_buf_joinpath(&path,
+ fixture.repo->commondir,
+ "worktrees/invalid"));
cl_git_pass(p_mkdir(path.ptr, 0755));
len = path.size;
@@ -61,7 +62,7 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
cl_git_pass(git_worktree_list(&wts, fixture.worktree));
cl_assert_equal_i(wts.count, 1);
cl_assert_equal_s(wts.strings[0], "testrepo-worktree");
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
for (j = 0; j < ARRAY_SIZE(filesets[i]); j++) {
git_buf_truncate(&path, len);
@@ -81,7 +82,7 @@ void test_worktree_worktree__list_in_worktree_repo(void)
cl_assert_equal_i(wts.count, 1);
cl_assert_equal_s(wts.strings[0], "testrepo-worktree");
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
}
void test_worktree_worktree__list_without_worktrees(void)
@@ -145,9 +146,9 @@ void test_worktree_worktree__open_invalid_commondir(void)
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/commondir"));
- cl_git_pass(git_buf_printf(&path,
- "%s/worktrees/testrepo-worktree/commondir",
- fixture.repo->commondir));
+ cl_git_pass(git_buf_joinpath(&path,
+ fixture.repo->commondir,
+ "worktrees/testrepo-worktree/commondir"));
cl_git_pass(git_futils_writebuffer(&buf, path.ptr, O_RDWR, 0644));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
@@ -165,9 +166,9 @@ void test_worktree_worktree__open_invalid_gitdir(void)
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
cl_git_pass(git_buf_sets(&buf, "/path/to/nonexistent/gitdir"));
- cl_git_pass(git_buf_printf(&path,
- "%s/worktrees/testrepo-worktree/gitdir",
- fixture.repo->commondir));
+ cl_git_pass(git_buf_joinpath(&path,
+ fixture.repo->commondir,
+ "worktrees/testrepo-worktree/gitdir"));
cl_git_pass(git_futils_writebuffer(&buf, path.ptr, O_RDWR, 0644));
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
@@ -380,7 +381,7 @@ void test_worktree_worktree__name(void)
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_assert_equal_s(git_worktree_name(wt), "testrepo-worktree");
-
+
git_worktree_free(wt);
}
@@ -581,45 +582,44 @@ void test_worktree_worktree__prune_worktree(void)
git_worktree_free(wt);
}
-static int read_head_ref(git_repository *repo, const char *path, void *payload)
+static int foreach_worktree_cb(git_repository *worktree, void *payload)
{
- git_vector *refs = (git_vector *) payload;
- git_reference *head;
-
- GIT_UNUSED(repo);
+ int *counter = (int *)payload;
- cl_git_pass(git_reference__read_head(&head, repo, path));
+ switch (*counter) {
+ case 0:
+ cl_assert_equal_s(git_repository_path(fixture.repo),
+ git_repository_path(worktree));
+ cl_assert(!git_repository_is_worktree(worktree));
+ break;
+ case 1:
+ cl_assert_equal_s(git_repository_path(fixture.worktree),
+ git_repository_path(worktree));
+ cl_assert(git_repository_is_worktree(worktree));
+ break;
+ default:
+ cl_fail("more worktrees found than expected");
+ }
- git_vector_insert(refs, head);
+ (*counter)++;
return 0;
}
-void test_worktree_worktree__foreach_head_gives_same_results_in_wt_and_repo(void)
+void test_worktree_worktree__foreach_worktree_lists_all_worktrees(void)
{
- git_vector repo_refs = GIT_VECTOR_INIT, worktree_refs = GIT_VECTOR_INIT;
- git_reference *heads[2];
- size_t i;
-
- cl_git_pass(git_reference_lookup(&heads[0], fixture.repo, GIT_HEAD_FILE));
- cl_git_pass(git_reference_lookup(&heads[1], fixture.worktree, GIT_HEAD_FILE));
-
- cl_git_pass(git_repository_foreach_head(fixture.repo, read_head_ref, 0, &repo_refs));
- cl_git_pass(git_repository_foreach_head(fixture.worktree, read_head_ref, 0, &worktree_refs));
-
- cl_assert_equal_i(repo_refs.length, ARRAY_SIZE(heads));
- cl_assert_equal_i(worktree_refs.length, ARRAY_SIZE(heads));
+ int counter = 0;
+ cl_git_pass(git_repository_foreach_worktree(fixture.repo, foreach_worktree_cb, &counter));
+}
- for (i = 0; i < ARRAY_SIZE(heads); i++) {
- cl_assert_equal_s(heads[i]->name, ((git_reference *) repo_refs.contents[i])->name);
- cl_assert_equal_s(heads[i]->name, ((git_reference *) repo_refs.contents[i])->name);
- cl_assert_equal_s(heads[i]->name, ((git_reference *) worktree_refs.contents[i])->name);
+void test_worktree_worktree__validate_invalid_worktreedir(void)
+{
+ git_worktree *wt;
- git_reference_free(heads[i]);
- git_reference_free(repo_refs.contents[i]);
- git_reference_free(worktree_refs.contents[i]);
- }
+ cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
+ p_rename("testrepo-worktree", "testrepo-worktree-tmp");
+ cl_git_fail(git_worktree_validate(wt));
+ p_rename("testrepo-worktree-tmp", "testrepo-worktree");
- git_vector_free(&repo_refs);
- git_vector_free(&worktree_refs);
+ git_worktree_free(wt);
}