repository: Change ownership semantics The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
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
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 2783741..b99c40e 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -92,7 +92,7 @@ GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, in
*
* @param db database pointer to close. If NULL no action is taken.
*/
-GIT_EXTERN(void) git_odb_close(git_odb *db);
+GIT_EXTERN(void) git_odb_free(git_odb *db);
/**
* Read an object from the database.
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 43bbe9e..2bc2d16 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -39,7 +39,7 @@ GIT_BEGIN_DECL
* @param name the remote's name
* @return GIT_SUCCESS or an error code
*/
-int git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
+GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
/**
* Get the information for a particular remote
@@ -49,7 +49,7 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons
* @param name the remote's name
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_remote_get(struct git_remote **out, struct git_config *cfg, const char *name);
+GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
/**
* Get the remote's name
@@ -57,7 +57,7 @@ GIT_EXTERN(int) git_remote_get(struct git_remote **out, struct git_config *cfg,
* @param remote the remote
* @return a pointer to the name
*/
-GIT_EXTERN(const char *) git_remote_name(struct git_remote *remote);
+GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
/**
* Get the remote's url
@@ -65,7 +65,7 @@ GIT_EXTERN(const char *) git_remote_name(struct git_remote *remote);
* @param remote the remote
* @return a pointer to the url
*/
-GIT_EXTERN(const char *) git_remote_url(struct git_remote *remote);
+GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
/**
* Get the fetch refspec
@@ -73,7 +73,7 @@ GIT_EXTERN(const char *) git_remote_url(struct git_remote *remote);
* @param remote the remote
* @return a pointer to the fetch refspec or NULL if it doesn't exist
*/
-GIT_EXTERN(const git_refspec *) git_remote_fetchspec(struct git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
/**
* Get the push refspec
@@ -82,7 +82,7 @@ GIT_EXTERN(const git_refspec *) git_remote_fetchspec(struct git_remote *remote);
* @return a pointer to the push refspec or NULL if it doesn't exist
*/
-GIT_EXTERN(const git_refspec *) git_remote_pushspec(struct git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
/**
* Open a connection to a remote
@@ -95,7 +95,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(struct git_remote *remote);
* @param direction whether you want to receive or send data
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_remote_connect(struct git_remote *remote, int direction);
+GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
/**
* Get a list of refs at the remote
@@ -149,7 +149,7 @@ GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
*
* @param remote the remote to free
*/
-GIT_EXTERN(void) git_remote_free(struct git_remote *remote);
+GIT_EXTERN(void) git_remote_free(git_remote *remote);
/**
* Update the tips to the new state
@@ -159,7 +159,7 @@ GIT_EXTERN(void) git_remote_free(struct git_remote *remote);
*
* @param remote the remote to update
*/
-GIT_EXTERN(int) git_remote_update_tips(struct git_remote *remote);
+GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
/** @} */
GIT_END_DECL
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 2e9baf6..bacb481 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -23,21 +23,11 @@ GIT_BEGIN_DECL
/**
* Open a git repository.
*
- * The 'path' argument must point to an existing git repository
- * folder, e.g.
+ * The 'path' argument must point to either a git repository
+ * folder, or an existing work dir.
*
- * /path/to/my_repo/.git/ (normal repository)
- * objects/
- * index
- * HEAD
- *
- * /path/to/bare_repo/ (bare repository)
- * objects/
- * index
- * HEAD
- *
- * The method will automatically detect if 'path' is a normal
- * or bare repository or fail is 'path' is neither.
+ * The method will automatically detect if 'path' is a normal
+ * or bare repository or fail is 'path' is neither.
*
* @param repository pointer to the repo which will be opened
* @param path the path to the repository
@@ -45,130 +35,40 @@ GIT_BEGIN_DECL
*/
GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
-
-/**
- * Open a git repository by manually specifying all its paths
- *
- * @param repository pointer to the repo which will be opened
- *
- * @param git_dir The full path to the repository folder
- * e.g. a '.git' folder for live repos, any folder for bare
- * Equivalent to $GIT_DIR.
- * Cannot be NULL.
- *
- * @param git_object_directory The full path to the ODB folder.
- * the folder where all the loose and packed objects are stored
- * Equivalent to $GIT_OBJECT_DIRECTORY.
- * If NULL, "$GIT_DIR/objects/" is assumed.
- *
- * @param git_index_file The full path to the index (dircache) file
- * Equivalent to $GIT_INDEX_FILE.
- * If NULL, "$GIT_DIR/index" is assumed.
- *
- * @param git_work_tree The full path to the working tree of the repository,
- * if the repository is not bare.
- * Equivalent to $GIT_WORK_TREE.
- * If NULL, the repository is assumed to be bare.
- *
- * @return GIT_SUCCESS or an error code
- */
-GIT_EXTERN(int) git_repository_open2(git_repository **repository,
- const char *git_dir,
- const char *git_object_directory,
- const char *git_index_file,
- const char *git_work_tree);
-
-
-/**
- * Open a git repository by manually specifying its paths and
- * the object database it will use.
- *
- * @param repository pointer to the repo which will be opened
- *
- * @param git_dir The full path to the repository folder
- * e.g. a '.git' folder for live repos, any folder for bare
- * Equivalent to $GIT_DIR.
- * Cannot be NULL.
- *
- * @param object_database A pointer to a git_odb created & initialized
- * by the user (e.g. with custom backends). This object database
- * will be owned by the repository and will be automatically free'd.
- * It should not be manually free'd by the user, or this
- * git_repository object will become invalid.
- *
- * @param git_index_file The full path to the index (dircache) file
- * Equivalent to $GIT_INDEX_FILE.
- * If NULL, "$GIT_DIR/index" is assumed.
- *
- * @param git_work_tree The full path to the working tree of the repository,
- * if the repository is not bare.
- * Equivalent to $GIT_WORK_TREE.
- * If NULL, the repository is assumed to be bare.
- *
- * @return GIT_SUCCESS or an error code
- */
-
-GIT_EXTERN(int) git_repository_open3(git_repository **repository,
- const char *git_dir,
- git_odb *object_database,
- const char *git_index_file,
- const char *git_work_tree);
-
/**
- * Look for a git repository and copy its path in the given buffer. The lookup start
- * from base_path and walk across parent directories if nothing has been found. The
- * lookup ends when the first repository is found, or when reaching a directory
- * referenced in ceiling_dirs or when the filesystem changes (in case across_fs
- * is true).
+ * Look for a git repository and copy its path in the given buffer.
+ * The lookup start from base_path and walk across parent directories
+ * if nothing has been found. The lookup ends when the first repository
+ * is found, or when reaching a directory referenced in ceiling_dirs
+ * or when the filesystem changes (in case across_fs is true).
*
- * The method will automatically detect if the repository is bare (if there is
- * a repository).
+ * The method will automatically detect if the repository is bare
+ * (if there is a repository).
*
- * @param repository_path The user allocated buffer which will contain the found path.
+ * @param repository_path The user allocated buffer which will
+ * contain the found path.
*
* @param size repository_path size
*
* @param start_path The base path where the lookup starts.
*
- * @param across_fs If true, then the lookup will not stop when a filesystem device change
- * is detected while exploring parent directories.
+ * @param across_fs If true, then the lookup will not stop when a
+ * filesystem device change is detected while exploring parent directories.
*
- * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of absolute symbolic link
- * free paths. The lookup will stop when any of this paths is reached. Note that the
- * lookup always performs on start_path no matter start_path appears in ceiling_dirs
- * ceiling_dirs might be NULL (which is equivalent to an empty string)
+ * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of
+ * absolute symbolic link free paths. The lookup will stop when any
+ * of this paths is reached. Note that the lookup always performs on
+ * start_path no matter start_path appears in ceiling_dirs ceiling_dirs
+ * might be NULL (which is equivalent to an empty string)
*
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_repository_discover(char *repository_path, size_t size, const char *start_path, int across_fs, const char *ceiling_dirs);
-
-/**
- * Get the object database behind a Git repository
- *
- * @param repo a repository object
- * @return a pointer to the object db
- */
-GIT_EXTERN(git_odb *) git_repository_database(git_repository *repo);
-
-/**
- * Open the Index file of a Git repository
- *
- * This returns a new and unique `git_index` object representing the
- * active index for the repository.
- *
- * This method may be called more than once (e.g. on different threads).
- *
- * Each returned `git_index` object is independent and suffers no race
- * conditions: synchronization is done at the FS level.
- *
- * Each returned `git_index` object must be manually freed by the user,
- * using `git_index_free`.
- *
- * @param index Pointer where to store the index
- * @param repo a repository object
- * @return GIT_SUCCESS or an error code
- */
-GIT_EXTERN(int) git_repository_index(git_index **index, git_repository *repo);
+GIT_EXTERN(int) git_repository_discover(
+ char *repository_path,
+ size_t size,
+ const char *start_path,
+ int across_fs,
+ const char *ceiling_dirs);
/**
* Free a previously allocated repository
@@ -246,32 +146,9 @@ GIT_EXTERN(int) git_repository_head_orphan(git_repository *repo);
*/
GIT_EXTERN(int) git_repository_is_empty(git_repository *repo);
-/**
- * Internal path identifiers for a repository
- */
-typedef enum {
- GIT_REPO_PATH,
- GIT_REPO_PATH_INDEX,
- GIT_REPO_PATH_ODB,
- GIT_REPO_PATH_WORKDIR
-} git_repository_pathid;
-
-/**
- * Get one of the paths to the repository
- *
- * Possible values for `id`:
- *
- * GIT_REPO_PATH: return the path to the repository
- * GIT_REPO_PATH_INDEX: return the path to the index
- * GIT_REPO_PATH_ODB: return the path to the ODB
- * GIT_REPO_PATH_WORKDIR: return the path to the working
- * directory
- *
- * @param repo a repository object
- * @param id The ID of the path to return
- * @return absolute path of the requested id
- */
-GIT_EXTERN(const char *) git_repository_path(git_repository *repo, git_repository_pathid id);
+GIT_EXTERN(const char *) git_repository_path(git_repository *repo);
+GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo);
+GIT_EXTERN(int) git_repository_set_workdir(git_repository *repo, const char *workdir);
/**
* Check if a repository is bare
@@ -281,53 +158,14 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo, git_repositor
*/
GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
-/**
- * Retrieve the relevant configuration for a repository
- *
- * If either the `global_config_path` or `system_config_path`
- * variables are not NULL, the given config files will be also
- * included in the configuration set. The global configuration file is
- * located in $HOME/.gitconfig. On most UNIX systems, the system
- * config file file may be found on `$sysconfdir/gitconfig`.
- *
- * The resulting `git_config` instance will query the files in the following
- * order:
- *
- * - Repository configuration file
- * - Global configuration file
- * - System configuration file
- *
- * The method will fail if any of the given config files can't be
- * found or accessed.
- *
- * The returned `git_config` instance is owned by the caller and must
- * be manually free'd once it's no longer on use.
- *
- * @param out the repository's configuration
- * @param repo the repository for which to get the config
- * @param system_config_path Path to the global config file
- * @param system_config_path Path to the system-wide config file
- */
+GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
+GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
-GIT_EXTERN(int) git_repository_config(git_config **out,
- git_repository *repo,
- const char *global_config_path,
- const char *system_config_path);
+GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
+GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
-/**
- * Automatically load the configuration files
- *
- * A wrapper around `git_repository_config` that tries to guess where
- * the global and system config files are located. No error is
- * reported if either of these files are missing at the guessed
- * locations.
- *
- * @param out the repository's configuration
- * @param repo the repository for which to get the config
- */
-GIT_EXTERN(int) git_repository_config_autoload(
- git_config **out,
- git_repository *repo);
+GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
+GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
/** @} */
GIT_END_DECL
diff --git a/src/blob.c b/src/blob.c
index f13a5be..5fd0fd6 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -41,9 +41,14 @@ int git_blob__parse(git_blob *blob, git_odb_object *odb_obj)
int git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *buffer, size_t len)
{
int error;
+ git_odb *odb;
git_odb_stream *stream;
- if ((error = git_odb_open_wstream(&stream, repo->db, len, GIT_OBJ_BLOB)) < GIT_SUCCESS)
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ if ((error = git_odb_open_wstream(&stream, odb, len, GIT_OBJ_BLOB)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to create blob");
if ((error = stream->write(stream, buffer, len)) < GIT_SUCCESS) {
@@ -69,11 +74,14 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
git_off_t size;
git_odb_stream *stream;
struct stat st;
+ const char *workdir;
+ git_odb *odb;
- if (repo->path_workdir == NULL)
+ workdir = git_repository_workdir(repo);
+ if (workdir == NULL)
return git__throw(GIT_ENOTFOUND, "Failed to create blob. (No working directory found)");
- git_path_join(full_path, repo->path_workdir, path);
+ git_path_join(full_path, workdir, path);
error = p_lstat(full_path, &st);
if (error < 0) {
@@ -83,11 +91,16 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
islnk = S_ISLNK(st.st_mode);
size = st.st_size;
- if (!islnk)
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ if (!islnk) {
if ((fd = p_open(full_path, O_RDONLY)) < 0)
return git__throw(GIT_ENOTFOUND, "Failed to create blob. Could not open '%s'", full_path);
+ }
- if ((error = git_odb_open_wstream(&stream, repo->db, (size_t)size, GIT_OBJ_BLOB)) < GIT_SUCCESS) {
+ if ((error = git_odb_open_wstream(&stream, odb, (size_t)size, GIT_OBJ_BLOB)) < GIT_SUCCESS) {
if (!islnk)
p_close(fd);
return git__rethrow(error, "Failed to create blob");
diff --git a/src/commit.c b/src/commit.c
index 83bc9fc..bf6ca78 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -103,6 +103,7 @@ int git_commit_create(
{
git_buf commit = GIT_BUF_INIT;
int error, i;
+ git_odb *odb;
if (git_object_owner((const git_object *)tree) != repo)
return git__throw(GIT_EINVALIDARGS, "The given tree does not belong to this repository");
@@ -132,7 +133,11 @@ int git_commit_create(
goto cleanup;
}
- error = git_odb_write(oid, git_repository_database(repo), commit.ptr, commit.size, GIT_OBJ_COMMIT);
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS)
+ goto cleanup;
+
+ error = git_odb_write(oid, odb, commit.ptr, commit.size, GIT_OBJ_COMMIT);
git_buf_free(&commit);
if (error == GIT_SUCCESS && update_ref != NULL) {
diff --git a/src/common.h b/src/common.h
index 727a08e..3531601 100644
--- a/src/common.h
+++ b/src/common.h
@@ -60,4 +60,5 @@ extern void git___rethrow(const char *, ...) GIT_FORMAT_PRINTF(1, 2);
#include "util.h"
+
#endif /* INCLUDE_common_h__ */
diff --git a/src/config.c b/src/config.c
index 4e48ff7..a8e1540 100644
--- a/src/config.c
+++ b/src/config.c
@@ -22,15 +22,12 @@ typedef struct {
int priority;
} file_internal;
-void git_config_free(git_config *cfg)
+static void config_free(git_config *cfg)
{
unsigned int i;
git_config_file *file;
file_internal *internal;
- if (cfg == NULL)
- return;
-
for(i = 0; i < cfg->files.length; ++i){
internal = git_vector_get(&cfg->files, i);
file = internal->file;
@@ -42,6 +39,14 @@ void git_config_free(git_config *cfg)
git__free(cfg);
}
+void git_config_free(git_config *cfg)
+{
+ if (cfg == NULL)
+ return;
+
+ GIT_REFCOUNT_DEC(cfg, config_free);
+}
+
static int config_backend_cmp(const void *a, const void *b)
{
const file_internal *bk_a = (const file_internal *)(a);
@@ -66,7 +71,7 @@ int git_config_new(git_config **out)
}
*out = cfg;
-
+ GIT_REFCOUNT_INC(cfg);
return GIT_SUCCESS;
}
diff --git a/src/config.h b/src/config.h
index 43574a5..7f3494e 100644
--- a/src/config.h
+++ b/src/config.h
@@ -17,8 +17,8 @@
#define GIT_CONFIG_FILE_MODE 0666
struct git_config {
+ git_refcount rc;
git_vector files;
- git_repository *repo;
};
#endif
diff --git a/src/config_file.c b/src/config_file.c
index 5e862d4..7a58652 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -256,6 +256,7 @@ static int config_open(git_config_file *cfg)
diskfile_backend *b = (diskfile_backend *)cfg;
error = git_futils_readbuffer(&b->reader.buffer, b->file_path);
+
/* It's fine if the file doesn't exist */
if (error == GIT_ENOTFOUND)
return GIT_SUCCESS;
@@ -269,7 +270,7 @@ static int config_open(git_config_file *cfg)
git_futils_freebuffer(&b->reader.buffer);
- return error;
+ return GIT_SUCCESS;
cleanup:
cvar_list_free(&b->var_list);
diff --git a/src/fetch.c b/src/fetch.c
index a427329..93f0980 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -24,7 +24,7 @@ static int filter_wants(git_remote *remote)
git_headarray refs;
git_remote_head *head;
git_transport *t = remote->transport;
- git_repository *repo = remote->repo;
+ git_odb *odb = NULL;
const git_refspec *spec;
int error;
unsigned int i = 0;
@@ -39,6 +39,10 @@ static int filter_wants(git_remote *remote)
goto cleanup;
}
+ error = git_repository_odb__weakptr(&odb, remote->repo);
+ if (error < GIT_SUCCESS)
+ goto cleanup;
+
/*
* The fetch refspec can be NULL, and what this means is that the
* user didn't specify one. This is fine, as it means that we're
@@ -53,7 +57,7 @@ static int filter_wants(git_remote *remote)
*/
head = refs.heads[0];
if (refs.len > 0 && !strcmp(head->name, GIT_HEAD_FILE)) {
- if (git_odb_exists(repo->db, &head->oid))
+ if (git_odb_exists(odb, &head->oid))
head->local = 1;
else
remote->need_pack = 1;
@@ -77,7 +81,7 @@ static int filter_wants(git_remote *remote)
}
/* If we have the object, mark it so we don't ask for it */
- if (git_odb_exists(repo->db, &head->oid))
+ if (git_odb_exists(odb, &head->oid))
head->local = 1;
else
remote->need_pack = 1;
diff --git a/src/index.c b/src/index.c
index aad1171..d01262b 100644
--- a/src/index.c
+++ b/src/index.c
@@ -31,6 +31,8 @@ static const unsigned int INDEX_HEADER_SIG = 0x44495243;
static const char INDEX_EXT_TREECACHE_SIG[] = {'T', 'R', 'E', 'E'};
static const char INDEX_EXT_UNMERGED_SIG[] = {'R', 'E', 'U', 'C'};
+#define INDEX_OWNER(idx) ((git_repository *)(GIT_REFCOUNT_OWNER(idx)))
+
struct index_header {
uint32_t signature;
uint32_t version;
@@ -124,7 +126,7 @@ static unsigned int index_create_mode(unsigned int mode)
return S_IFREG | ((mode & 0100) ? 0755 : 0644);
}
-static int index_initialize(git_index **index_out, git_repository *owner, const char *index_path)
+int git_index_open(git_index **index_out, const char *index_path)
{
git_index *index;
@@ -142,8 +144,6 @@ static int index_initialize(git_index **index_out, git_repository *owner, const
return GIT_ENOMEM;
}
- index->repository = owner;
-
git_vector_init(&index->entries, 32, index_cmp);
/* Check if index file is stored on disk already */
@@ -151,23 +151,18 @@ static int index_initialize(git_index **index_out, git_repository *owner, const
index->on_disk = 1;
*index_out = index;
+ GIT_REFCOUNT_INC(index);
return git_index_read(index);
}
-int git_index_open(git_index **index_out, const char *index_path)
+static void index_free(git_index *index)
{
- return index_initialize(index_out, NULL, index_path);
-}
-
-/*
- * Moved from `repository.c`
- */
-int git_repository_index(git_index **index_out, git_repository *repo)
-{
- if (repo->is_bare)
- return git__throw(GIT_EBAREINDEX, "Failed to open index. Repository is bare");
+ git_index_clear(index);
+ git_vector_free(&index->entries);
+ git_vector_free(&index->unmerged);
- return index_initialize(index_out, repo, repo->path_index);
+ git__free(index->index_file_path);
+ git__free(index);
}
void git_index_free(git_index *index)
@@ -175,12 +170,7 @@ void git_index_free(git_index *index)
if (index == NULL)
return;
- git_index_clear(index);
- git_vector_free(&index->entries);
- git_vector_free(&index->unmerged);
-
- git__free(index->index_file_path);
- git__free(index);
+ GIT_REFCOUNT_DEC(index, index_free);
}
void git_index_clear(git_index *index)
@@ -298,20 +288,29 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const
struct stat st;
git_oid oid;
int error;
+ const char *workdir;
+
+ if (INDEX_OWNER(index) == NULL)
+ return git__throw(GIT_EBAREINDEX,
+ "Failed to initialize entry. Repository is bare");
- if (index->repository == NULL)
- return git__throw(GIT_EBAREINDEX, "Failed to initialize entry. Repository is bare");
+ workdir = git_repository_workdir(INDEX_OWNER(index));
+ if (workdir == NULL)
+ return git__throw(GIT_EBAREINDEX,
+ "Failed to initialize entry. Cannot resolved workdir");
- git_path_join(full_path, index->repository->path_workdir, rel_path);
+ git_path_join(full_path, workdir, rel_path);
if (p_lstat(full_path, &st) < 0)
- return git__throw(GIT_ENOTFOUND, "Failed to initialize entry. '%s' cannot be opened", full_path);
+ return git__throw(GIT_ENOTFOUND,
+ "Failed to initialize entry. '%s' cannot be opened", full_path);
if (stage < 0 || stage > 3)
- return git__throw(GIT_ERROR, "Failed to initialize entry. Invalid stage %i", stage);
+ return git__throw(GIT_ERROR,
+ "Failed to initialize entry. Invalid stage %i", stage);
/* write the blob to disk and get the oid */
- if ((error = git_blob_create_fromfile(&oid, index->repository, rel_path)) < GIT_SUCCESS)
+ if ((error = git_blob_create_fromfile(&oid, INDEX_OWNER(index), rel_path)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to initialize index entry");
entry = git__malloc(sizeof(git_index_entry));
diff --git a/src/index.h b/src/index.h
index a1cd340..9464afb 100644
--- a/src/index.h
+++ b/src/index.h
@@ -18,7 +18,8 @@
#define GIT_INDEX_FILE_MODE 0666
struct git_index {
- git_repository *repository;
+ git_refcount rc;
+
char *index_file_path;
time_t last_modified;
diff --git a/src/object.c b/src/object.c
index c84e94b..12947f0 100644
--- a/src/object.c
+++ b/src/object.c
@@ -77,9 +77,15 @@ static int create_object(git_object **object_out, git_otype type)
return GIT_SUCCESS;
}
-int git_object_lookup_prefix(git_object **object_out, git_repository *repo, const git_oid *id, unsigned int len, git_otype type)
+int git_object_lookup_prefix(
+ git_object **object_out,
+ git_repository *repo,
+ const git_oid *id,
+ unsigned int len,
+ git_otype type)
{
git_object *object = NULL;
+ git_odb *odb = NULL;
git_odb_object *odb_obj;
int error = GIT_SUCCESS;
@@ -89,6 +95,10 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
return git__throw(GIT_EAMBIGUOUSOIDPREFIX,
"Failed to lookup object. Prefix length is lower than %d.", GIT_OID_MINPREFIXLEN);
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS)
+ return error;
+
if (len > GIT_OID_HEXSZ)
len = GIT_OID_HEXSZ;
@@ -98,10 +108,11 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
*/
object = git_cache_get(&repo->objects, id);
if (object != NULL) {
- if (type != GIT_OBJ_ANY && type != object->type)
- {
+ if (type != GIT_OBJ_ANY && type != object->type) {
git_object_close(object);
- return git__throw(GIT_EINVALIDTYPE, "Failed to lookup object. The given type does not match the type on the ODB");
+ return git__throw(GIT_EINVALIDTYPE,
+ "Failed to lookup object. "
+ "The given type does not match the type on the ODB");
}
*object_out = object;
@@ -113,7 +124,7 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
* it is the same cost for packed and loose object backends,
* but it may be much more costly for sqlite and hiredis.
*/
- error = git_odb_read(&odb_obj, repo->db, id);
+ error = git_odb_read(&odb_obj, odb, id);
} else {
git_oid short_oid;
@@ -133,7 +144,7 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
* - We never explore the cache, go right to exploring the backends
* We chose the latter : we explore directly the backends.
*/
- error = git_odb_read_prefix(&odb_obj, repo->db, &short_oid, len);
+ error = git_odb_read_prefix(&odb_obj, odb, &short_oid, len);
}
if (error < GIT_SUCCESS)
diff --git a/src/odb.c b/src/odb.c
index 69fdba0..9b72e7f 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -275,6 +275,7 @@ int git_odb_new(git_odb **out)
}
*out = db;
+ GIT_REFCOUNT_INC(db);
return GIT_SUCCESS;
}
@@ -405,17 +406,14 @@ int git_odb_open(git_odb **out, const char *objects_dir)
return GIT_SUCCESS;
cleanup:
- git_odb_close(db);
+ git_odb_free(db);
return error; /* error already set - pass through */
}
-void git_odb_close(git_odb *db)
+static void odb_free(git_odb *db)
{
unsigned int i;
- if (db == NULL)
- return;
-
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *backend = internal->backend;
@@ -431,6 +429,14 @@ void git_odb_close(git_odb *db)
git__free(db);
}
+void git_odb_free(git_odb *db)
+{
+ if (db == NULL)
+ return;
+
+ GIT_REFCOUNT_DEC(db, odb_free);
+}
+
int git_odb_exists(git_odb *db, const git_oid *id)
{
git_odb_object *object;
diff --git a/src/odb.h b/src/odb.h
index 833739e..b815330 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -33,7 +33,7 @@ struct git_odb_object {
/* EXPORT */
struct git_odb {
- void *_internal;
+ git_refcount rc;
git_vector backends;
git_cache cache;
};
diff --git a/src/refs.c b/src/refs.c
index 2374cc7..4c45fec 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1195,7 +1195,8 @@ cleanup:
*/
int git_reference_set_oid(git_reference *ref, const git_oid *id)
{
- int error = GIT_SUCCESS;
+ int error = GIT_SUCCESS, exists;
+ git_odb *odb = NULL;
if ((ref->flags & GIT_REF_OID) == 0)
return git__throw(GIT_EINVALIDREFSTATE,
@@ -1203,23 +1204,29 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id)
assert(ref->owner);
+ error = git_repository_odb__weakptr(&odb, ref->owner);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ exists = git_odb_exists(odb, id);
+
+ git_odb_free(odb);
+
/* Don't let the user create references to OIDs that
* don't exist in the ODB */
- if (!git_odb_exists(git_repository_database(ref->owner), id))
+ if (!exists)
return git__throw(GIT_ENOTFOUND,
"Failed to set OID target of reference. OID doesn't exist in ODB");
/* Update the OID value on `ref` */
git_oid_cpy(&ref->target.oid, id);
+ /* Write back to disk */
error = loose_write(ref);
if (error < GIT_SUCCESS)
- goto cleanup;
+ return git__rethrow(error, "Failed to set OID target of reference");
return GIT_SUCCESS;
-
-cleanup:
- return git__rethrow(error, "Failed to set OID target of reference");
}
/*
diff --git a/src/remote.c b/src/remote.c
index a222023..c6a9173 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -88,14 +88,19 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons
return GIT_SUCCESS;
}
-int git_remote_get(git_remote **out, git_config *cfg, const char *name)
+int git_remote_load(git_remote **out, git_repository *repo, const char *name)
{
git_remote *remote;
char *buf = NULL;
const char *val;
int ret, error, buf_len;
+ git_config *config;
- assert(out && cfg && name);
+ assert(out && repo && name);
+
+ error = git_repository_config__weakptr(&config, repo);
+ if (error < GIT_SUCCESS)
+ return error;
remote = git__malloc(sizeof(git_remote));
if (remote == NULL)
@@ -122,13 +127,13 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
goto cleanup;
}
- error = git_config_get_string(cfg, buf, &val);
+ error = git_config_get_string(config, buf, &val);
if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Remote's url doesn't exist");
goto cleanup;
}
- remote->repo = cfg->repo;
+ remote->repo = repo;
remote->url = git__strdup(val);
if (remote->url == NULL) {
error = GIT_ENOMEM;
@@ -141,7 +146,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
goto cleanup;
}
- error = parse_remote_refspec(cfg, &remote->fetch, buf);
+ error = parse_remote_refspec(config, &remote->fetch, buf);
if (error < GIT_SUCCESS) {
error = git__rethrow(error, "Failed to get fetch refspec");
goto cleanup;
@@ -153,7 +158,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
goto cleanup;
}
- error = parse_remote_refspec(cfg, &remote->push, buf);
+ error = parse_remote_refspec(config, &remote->push, buf);
/* Not finding push is fine */
if (error == GIT_ENOTFOUND)
error = GIT_SUCCESS;
@@ -165,6 +170,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
cleanup:
git__free(buf);
+
if (error < GIT_SUCCESS)
git_remote_free(remote);
diff --git a/src/repository.c b/src/repository.c
index f8195e2..7bac1b2 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -24,118 +24,57 @@
#define GIT_BRANCH_MASTER "master"
-/*
- * Git repository open methods
- *
- * Open a repository object from its path
- */
-static int assign_repository_dirs(
- git_repository *repo,
- const char *git_dir,
- const char *git_object_directory,
- const char *git_index_file,
- const char *git_work_tree)
-{
- char path_aux[GIT_PATH_MAX];
- int error = GIT_SUCCESS;
-
- assert(repo);
-
- if (git_dir == NULL)
- return git__throw(GIT_ENOTFOUND, "Failed to open repository. Git dir not found");
- error = git_path_prettify_dir(path_aux, git_dir, NULL);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to open repository");
-
- /* store GIT_DIR */
- repo->path_repository = git__strdup(path_aux);
- if (repo->path_repository == NULL)
- return GIT_ENOMEM;
-
- /* path to GIT_OBJECT_DIRECTORY */
- if (git_object_directory == NULL)
- git_path_join(path_aux, repo->path_repository, GIT_OBJECTS_DIR);
- else {
- error = git_path_prettify_dir(path_aux, git_object_directory, NULL);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to open repository");
+static void drop_odb(git_repository *repo)
+{
+ if (repo->_odb != NULL) {
+ GIT_REFCOUNT_OWN(repo->_odb, NULL);
+ git_odb_free(repo->_odb);
+ repo->_odb = NULL;
}
+}
- /* Store GIT_OBJECT_DIRECTORY */
- repo->path_odb = git__strdup(path_aux);
- if (repo->path_odb == NULL)
- return GIT_ENOMEM;
-
- /* path to GIT_WORK_TREE */
- if (git_work_tree == NULL)
- repo->is_bare = 1;
- else {
- error = git_path_prettify_dir(path_aux, git_work_tree, NULL);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to open repository");
-
- /* Store GIT_WORK_TREE */
- repo->path_workdir = git__strdup(path_aux);
- if (repo->path_workdir == NULL)
- return GIT_ENOMEM;
-
- /* Path to GIT_INDEX_FILE */
- if (git_index_file == NULL)
- git_path_join(path_aux, repo->path_repository, GIT_INDEX_FILE);
- else {
- error = git_path_prettify(path_aux, git_index_file, NULL);
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to open repository");
- }
-
- /* store GIT_INDEX_FILE */
- repo->path_index = git__strdup(path_aux);
- if (repo->path_index == NULL)
- return GIT_ENOMEM;
+static void drop_config(git_repository *repo)
+{
+ if (repo->_config != NULL) {
+ GIT_REFCOUNT_OWN(repo->_config, NULL);
+ git_config_free(repo->_config);
+ repo->_config = NULL;
}
-
- return GIT_SUCCESS;
}
-static int check_repository_dirs(git_repository *repo)
+static void drop_index(git_repository *repo)
{
- char path_aux[GIT_PATH_MAX];
-
- if (git_futils_isdir(repo->path_repository) < GIT_SUCCESS)
- return git__throw(GIT_ENOTAREPO, "`%s` is not a folder", repo->path_repository);
-
- /* Ensure GIT_OBJECT_DIRECTORY exists */
- if (git_futils_isdir(repo->path_odb) < GIT_SUCCESS)
- return git__throw(GIT_ENOTAREPO, "`%s` does not exist", repo->path_odb);
-
- /* Ensure HEAD file exists */
- git_path_join(path_aux, repo->path_repository, GIT_HEAD_FILE);
- if (git_futils_isfile(path_aux) < 0)
- return git__throw(GIT_ENOTAREPO, "HEAD file is missing");
-
- return GIT_SUCCESS;
+ if (repo->_index != NULL) {
+ GIT_REFCOUNT_OWN(repo->_index, NULL);
+ git_index_free(repo->_index);
+ repo->_index = NULL;
+ }
}
-static int guess_repository_dirs(git_repository *repo, const char *repository_path)
+void git_repository_free(git_repository *repo)
{
- char buffer[GIT_PATH_MAX];
- const char *path_work_tree = NULL;
+ if (repo == NULL)
+ return;
- /* Git directory name */
- if (git_path_basename_r(buffer, sizeof(buffer), repository_path) < 0)
- return git__throw(GIT_EINVALIDPATH, "Unable to parse folder name from `%s`", repository_path);
+ git_cache_free(&repo->objects);
+ git_repository__refcache_free(&repo->references);
- if (strcmp(buffer, DOT_GIT) == 0) {
- /* Path to working dir */
- if (git_path_dirname_r(buffer, sizeof(buffer), repository_path) < 0)
- return git__throw(GIT_EINVALIDPATH, "Unable to parse parent folder name from `%s`", repository_path);
- path_work_tree = buffer;
- }
+ git__free(repo->path_repository);
+ git__free(repo->workdir);
- return assign_repository_dirs(repo, repository_path, NULL, NULL, path_work_tree);
+ drop_config(repo);
+ drop_index(repo);
+ drop_odb(repo);
+
+ git__free(repo);
}
+/*
+ * Git repository open methods
+ *
+ * Open a repository object from its path
+ */
static int quickcheck_repository_dir(const char *repository_path)
{
char path_aux[GIT_PATH_MAX];
@@ -156,6 +95,7 @@ static int quickcheck_repository_dir(const char *repository_path)
return GIT_SUCCESS;
}
+
static git_repository *repository_alloc(void)
{
int error;
@@ -175,94 +115,95 @@ static git_repository *repository_alloc(void)
return repo;
}
-static int init_odb(git_repository *repo)
+static int load_config_data(git_repository *repo)
{
- return git_odb_open(&repo->db, repo->path_odb);
-}
+ int error, is_bare;
+ git_config *config;
-int git_repository_open3(git_repository **repo_out,
- const char *git_dir,
- git_odb *object_database,
- const char *git_index_file,
- const char *git_work_tree)
-{
- git_repository *repo;
- int error = GIT_SUCCESS;
-
- assert(repo_out);
+ error = git_repository_config__weakptr(&config, repo);
+ if (error < GIT_SUCCESS)
+ return error;
- if (object_database == NULL)
- return git__throw(GIT_EINVALIDARGS, "Failed to open repository. `object_database` can't be null");
+ error = git_config_get_bool(config, "core.bare", &is_bare);
+ if (error == GIT_SUCCESS)
+ repo->is_bare = is_bare;
- repo = repository_alloc();
- if (repo == NULL)
- return GIT_ENOMEM;
+ return GIT_SUCCESS;
+}
- error = assign_repository_dirs(repo,
- git_dir,
- NULL,
- git_index_file,
- git_work_tree);
+static int load_workdir(git_repository *repo)
+{
+ if (!repo->is_bare) {
+ char workdir_buf[GIT_PATH_MAX];
- if (error < GIT_SUCCESS)
- goto cleanup;
+ if (git_path_dirname_r(workdir_buf, sizeof(workdir_buf), repo->path_repository) < 0)
+ return git__throw(GIT_EOSERR,
+ "Failed to resolved working directory");
- error = check_repository_dirs(repo);
- if (error < GIT_SUCCESS)
- goto cleanup;
+ git_path_join(workdir_buf, workdir_buf, "");
- repo->db = object_database;
+ repo->workdir = git__strdup(workdir_buf);
+ if (repo->workdir == NULL)
+ return GIT_ENOMEM;
+ }
- *repo_out = repo;
return GIT_SUCCESS;
-
-cleanup:
- git_repository_free(repo);
- return git__rethrow(error, "Failed to open repository");
}
-
-int git_repository_open2(git_repository **repo_out,
- const char *git_dir,
- const char *git_object_directory,
- const char *git_index_file,
- const char *git_work_tree)
+int git_repository_open(git_repository **repo_out, const char *path)
{
- git_repository *repo;
int error = GIT_SUCCESS;
+ char path_buf[GIT_PATH_MAX];
+ size_t path_len;
+ git_repository *repo = NULL;
+
+ error = git_path_prettify_dir(path_buf, path, NULL);
+ if (error < GIT_SUCCESS)
+ return git__rethrow(error, "Failed to open repository");
- assert(repo_out);
+ path_len = strlen(path_buf);
+
+ /**
+ * Check if the path we've been given is actually the path
+ * of the working dir, by testing if it contains a `.git`
+ * folder inside of it.
+ */
+ git_path_join(path_buf, path_buf, DOT_GIT);
+ if (git_futils_isdir(path_buf) < GIT_SUCCESS) {
+ path_buf[path_len] = 0;
+ }
+
+ if (quickcheck_repository_dir(path_buf) < GIT_SUCCESS)
+ return git__throw(GIT_ENOTAREPO,
+ "The given path is not a valid Git repository");
repo = repository_alloc();
if (repo == NULL)
return GIT_ENOMEM;
- error = assign_repository_dirs(repo,
- git_dir,
- git_object_directory,
- git_index_file,
- git_work_tree);
-
- if (error < GIT_SUCCESS)
- goto cleanup;
+ repo->path_repository = git__strdup(path_buf);
+ if (repo->path_repository == NULL) {
+ git_repository_free(repo);
+ return GIT_ENOMEM;
+ }
- error = check_repository_dirs(repo);
- if (error < GIT_SUCCESS)
- goto cleanup;
+ error = load_config_data(repo);
+ if (error < GIT_SUCCESS) {
+ git_repository_free(repo);
+ return error;
+ }
- error = init_odb(repo);
- if (error < GIT_SUCCESS)
- goto cleanup;
+ error = load_workdir(repo);
+ if (error < GIT_SUCCESS) {
+ git_repository_free(repo);
+ return error;
+ }
*repo_out = repo;
return GIT_SUCCESS;
-
-cleanup:
- git_repository_free(repo);
- return git__rethrow(error, "Failed to open repository");
}
-int git_repository_config(
+static int load_config(
git_config **out,
git_repository *repo,
const char *global_config_path,
@@ -270,98 +211,178 @@ int git_repository_config(
{
char config_path[GIT_PATH_MAX];
int error;
+ git_config *cfg = NULL;
- assert(out && repo);
+ assert(repo && out);
- error = git_config_new(out);
+ error = git_config_new(&cfg);
if (error < GIT_SUCCESS)
return error;
git_path_join(config_path, repo->path_repository, GIT_CONFIG_FILENAME_INREPO);
- error = git_config_add_file_ondisk(*out, config_path, 3);
+ error = git_config_add_file_ondisk(cfg, config_path, 3);
if (error < GIT_SUCCESS)
goto cleanup;
if (global_config_path != NULL) {
- error = git_config_add_file_ondisk(*out, global_config_path, 2);
+ error = git_config_add_file_ondisk(cfg, global_config_path, 2);
if (error < GIT_SUCCESS)
goto cleanup;
}
if (system_config_path != NULL) {
- error = git_config_add_file_ondisk(*out, system_config_path, 1);
+ error = git_config_add_file_ondisk(cfg, system_config_path, 1);
if (error < GIT_SUCCESS)
goto cleanup;
}
- (*out)->repo = repo;
+ *out = cfg;
return GIT_SUCCESS;
cleanup:
- git_config_free(*out);
+ git_config_free(cfg);
+ *out = NULL;
return error;
}
-int git_repository_config_autoload(
- git_config **out,
- git_repository *repo)
+int git_repository_config__weakptr(git_config **out, git_repository *repo)
{
- char global[GIT_PATH_MAX], system[GIT_PATH_MAX];
- char *global_path, *system_path;
- int error;
+ if (repo->_config == NULL) {
+ int error;
+
+ char buf_global[GIT_PATH_MAX], buf_system[GIT_PATH_MAX];
+
+ const char *global_config_path = NULL;
+ const char *system_config_path = NULL;
+ if (git_config_find_global(buf_global) == GIT_SUCCESS)
+ global_config_path = buf_global;
- error = git_config_find_global(global);
- global_path = error < GIT_SUCCESS ? NULL : global;
+ if (git_config_find_system(buf_system) == GIT_SUCCESS)
+ system_config_path = buf_system;
- error = git_config_find_system(system);
- system_path = error < GIT_SUCCESS ? NULL : system;
+ error = load_config(&repo->_config, repo, global_config_path, system_config_path);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ GIT_REFCOUNT_OWN(repo->_config, repo);
+ }
- return git_repository_config(out, repo, global_path, system_path);
+ *out = repo->_config;
+ return GIT_SUCCESS;
}
-static int discover_repository_dirs(git_repository *repo, const char *path)
+int git_repository_config(git_config **out, git_repository *repo)
{
- int error;
+ int error = git_repository_config__weakptr(out, repo);
- error = guess_repository_dirs(repo, path);
- if (error < GIT_SUCCESS)
- return error;
+ if (error == GIT_SUCCESS) {
+ GIT_REFCOUNT_INC(*out);
+ }
- error = check_repository_dirs(repo);
- if (error < GIT_SUCCESS)
- return error;
+ return error;
+}
+
+void git_repository_set_config(git_repository *repo, git_config *config)
+{
+ assert(repo && config);
+
+ drop_config(repo);
+
+ repo->_config = config;
+ GIT_REFCOUNT_OWN(repo->_config, repo);
+}
+
+int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
+{
+ assert(repo && out);
+
+ if (repo->_odb == NULL) {
+ int error;
+ char odb_path[GIT_PATH_MAX];
+
+ git_path_join(odb_path, repo->path_repository, GIT_OBJECTS_DIR);
+
+ error = git_odb_open(&repo->_odb, odb_path);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ GIT_REFCOUNT_OWN(repo->_odb, repo);
+ }
+ GIT_REFCOUNT_INC(repo->_odb);
+ *out = repo->_odb;
return GIT_SUCCESS;
}
-int git_repository_open(git_repository **repo_out, const char *path)
+int git_repository_odb(git_odb **out, git_repository *repo)
{
- git_repository *repo;
- int error = GIT_SUCCESS;
+ int error = git_repository_odb__weakptr(out, repo);
- assert(repo_out && path);
+ if (error == GIT_SUCCESS) {
+ GIT_REFCOUNT_INC(*out);
+ }
- repo = repository_alloc();
- if (repo == NULL)
- return GIT_ENOMEM;
+ return error;
+}
- error = discover_repository_dirs(repo, path);
- if (error < GIT_SUCCESS)
- goto cleanup;
+void git_repository_set_odb(git_repository *repo, git_odb *odb)
+{
+ assert(repo && odb);
- error = init_odb(repo);
- if (error < GIT_SUCCESS)
- goto cleanup;
+ drop_odb(repo);
- *repo_out = repo;
+ repo->_odb = odb;
+ GIT_REFCOUNT_OWN(repo->_odb, repo);
+}
+
+int git_repository_index__weakptr(git_index **out, git_repository *repo)
+{
+ assert(out && repo);
+
+ if (repo->is_bare)
+ return git__throw(GIT_EBAREINDEX, "Cannot open index in bare repository");
+
+ if (repo->_index == NULL) {
+ int error;
+ char index_path[GIT_PATH_MAX];
+
+ git_path_join(index_path, repo->path_repository, GIT_INDEX_FILE);
+
+ error = git_index_open(&repo->_index, index_path);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ GIT_REFCOUNT_OWN(repo->_index, repo);
+ }
+
+ GIT_REFCOUNT_INC(repo->_index);
+ *out = repo->_index;
return GIT_SUCCESS;
+}
-cleanup:
- git_repository_free(repo);
- return git__rethrow(error, "Failed to open repository");
+int git_repository_index(git_index **out, git_repository *repo)
+{
+ int error = git_repository_index__weakptr(out, repo);
+
+ if (error == GIT_SUCCESS) {
+ GIT_REFCOUNT_INC(*out);
+ }
+
+ return error;
}
+void git_repository_set_index(git_repository *repo, git_index *index)
+{
+ assert(repo && index);
+
+ drop_index(repo);
+
+ repo->_index = index;
+ GIT_REFCOUNT_OWN(repo->_index, repo);
+}
+
+
static int retrieve_device(dev_t *device_out, const char *path)
{
struct stat path_info;
@@ -460,34 +481,12 @@ static int read_gitfile(char *path_out, const char *file_path, const char *base_
return git__throw(GIT_EOBJCORRUPTED, "The `.git` file points to an inexisting path");
}
-static void git_repository__free_dirs(git_repository *repo)
-{
- git__free(repo->path_workdir);
- repo->path_workdir = NULL;
- git__free(repo->path_index);
- repo->path_index = NULL;
- git__free(repo->path_repository);
- repo->path_repository = NULL;
- git__free(repo->path_odb);
- repo->path_odb = NULL;
-}
-
-void git_repository_free(git_repository *repo)
-{
- if (repo == NULL)
- return;
-
- git_cache_free(&repo->objects);
- git_repository__refcache_free(&repo->references);
- git_repository__free_dirs(repo);
-
- if (repo->db != NULL)
- git_odb_close(repo->db);
-
- git__free(repo);
-}
-
-int git_repository_discover(char *repository_path, size_t size, const char *start_path, int across_fs, const char *ceiling_dirs)
+int git_repository_discover(
+ char *repository_path,
+ size_t size,
+ const char *start_path,
+ int across_fs,
+ const char *ceiling_dirs)
{
int error, ceiling_offset;
char bare_path[GIT_PATH_MAX];
@@ -519,11 +518,13 @@ int git_repository_discover(char *repository_path, size_t size, const char *star
error = read_gitfile(repository_path, normal_path, bare_path);
if (error < GIT_SUCCESS)
- return git__rethrow(error, "Unable to read git file `%s`", normal_path);
+ return git__rethrow(error,
+ "Unable to read git file `%s`", normal_path);
error = quickcheck_repository_dir(repository_path);
if (error < GIT_SUCCESS)
- return git__throw(GIT_ENOTFOUND, "The `.git` file found at '%s' points"
+ return git__throw(GIT_ENOTFOUND,
+ "The `.git` file found at '%s' points"
"to an inexisting Git folder", normal_path);
return GIT_SUCCESS;
@@ -558,7 +559,8 @@ int git_repository_discover(char *repository_path, size_t size, const char *star
error = retrieve_device(&new_device, normal_path);
if (error < GIT_SUCCESS || current_device != new_device) {
- return git__throw(GIT_ENOTAREPO,"Not a git repository (or any parent up to mount parent %s)\n"
+ return git__throw(GIT_ENOTAREPO,
+ "Not a git repository (or any parent up to mount parent %s)\n"
"Stopping at filesystem boundary.", bare_path);
}
current_device = new_device;
@@ -569,43 +571,81 @@ int git_repository_discover(char *repository_path, size_t size, const char *star
// nothing has been found, lets try the parent directory
if (bare_path[ceiling_offset] == '\0') {
- return git__throw(GIT_ENOTAREPO,"Not a git repository (or any of the parent directories): %s", start_path);
+ return git__throw(GIT_ENOTAREPO,
+ "Not a git repository (or any of the parent directories): %s", start_path);
}
}
if (size < strlen(found_path) + 2) {
- return git__throw(GIT_ESHORTBUFFER, "The repository buffer is not long enough to handle the repository path `%s`", found_path);
+ return git__throw(GIT_ESHORTBUFFER,
+ "The repository buffer is not long enough to handle the repository path `%s`", found_path);
}
git_path_join(repository_path, found_path, "");
return GIT_SUCCESS;
}
-git_odb *git_repository_database(git_repository *repo)
-{
- assert(repo);
- return repo->db;
-}
-
static int repo_init_reinit(const char *repository_path, int is_bare)
{
/* TODO: reinit the repository */
return git__throw(GIT_ENOTIMPLEMENTED,
"Failed to reinitialize the %srepository at '%s'. "
"This feature is not yet implemented",
- is_bare ? "bare" : "", repository_path);
+ is_bare ? "bare " : "", repository_path);
}
-static int repo_init_createhead(git_repository *repo)
+static int repo_init_createhead(const char *git_dir)
{
- int error;
- git_reference *head_reference;
+ char ref_path[GIT_PATH_MAX];
+ git_filebuf ref = GIT_FILEBUF_INIT;
+
+ git_path_join(ref_path, git_dir, GIT_HEAD_FILE);
+
+ git_filebuf_open(&ref, ref_path, 0);
+ git_filebuf_printf(&ref, "ref: refs/heads/master\n");
+
+ return git_filebuf_commit(&ref, GIT_REFS_FILE_MODE);
+}
+
+static int repo_init_config(const char *git_dir, int is_bare)
+{
+ char cfg_path[GIT_PATH_MAX];
+ git_filebuf cfg = GIT_FILEBUF_INIT;
+
+ git_path_join(cfg_path, git_dir, GIT_CONFIG_FILENAME_INREPO);
- error = git_reference_create_symbolic(&head_reference, repo, GIT_HEAD_FILE, GIT_REFS_HEADS_MASTER_FILE, 0);
+ git_filebuf_open(&cfg, cfg_path, 0);
+ git_filebuf_printf(&cfg, "[core]\n");
+ git_filebuf_printf(&cfg, "\tbare = %s\n", is_bare ? "true" : "false");
+ git_filebuf_printf(&cfg, "\trepositoryformatversion = 0\n");
- git_reference_free(head_reference);
+ return git_filebuf_commit(&cfg, GIT_REFS_FILE_MODE);
+ /* TODO: use the config backend to write this */
+#if 0
+ git_config *config;
+ int error = GIT_SUCCESS;
+
+#define SET_REPO_CONFIG(type, name, val) {\
+ error = git_config_set_##type(config, name, val);\
+ if (error < GIT_SUCCESS)\
+ goto cleanup;\
+}
+
+ git_path_join(cfg_path, git_dir, GIT_CONFIG_FILENAME_INREPO);
+
+ error = git_config_open_ondisk(&config, cfg_path);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ SET_REPO_CONFIG(bool, "core.bare", is_bare);
+ SET_REPO_CONFIG(int32, "core.repositoryformatversion", 0);
+ /* TODO: what other defaults? */
+
+cleanup:
+ git_config_free(config);
return error;
+#endif
}
static int repo_init_structure(const char *git_dir, int is_bare)
@@ -674,31 +714,15 @@ int git_repository_init(git_repository **repo_out, const char *path, unsigned is
if (error < GIT_SUCCESS)
goto cleanup;
- repo = repository_alloc();
- if (repo == NULL) {
- error = GIT_ENOMEM;
- goto cleanup;
- }
-
- error = guess_repository_dirs(repo, repository_path);
+ error = repo_init_config(repository_path, is_bare);
if (error < GIT_SUCCESS)
goto cleanup;
- assert(repo->is_bare == is_bare);
-
- error = init_odb(repo);
- if (error < GIT_SUCCESS)
- goto cleanup;
-
- error = repo_init_createhead(repo);
+ error = repo_init_createhead(repository_path);
if (error < GIT_SUCCESS)
goto cleanup;
- /* should never fail */
- assert(check_repository_dirs(repo) == GIT_SUCCESS);
-
- *repo_out = repo;
- return GIT_SUCCESS;
+ return git_repository_open(repo_out, repository_path);
cleanup:
git_repository_free(repo);
@@ -709,8 +733,13 @@ int git_repository_head_detached(git_repository *repo)
{
git_reference *ref;
int error;
- size_t GIT_UNUSED(_size);
+ size_t _size;
git_otype type;
+ git_odb *odb = NULL;
+
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS)
+ return error;
error = git_reference_lookup(&ref, repo, GIT_HEAD_FILE);
if (error < GIT_SUCCESS)
@@ -721,7 +750,7 @@ int git_repository_head_detached(git_repository *repo)
return 0;
}
- error = git_odb_read_header(&_size, &type, repo->db, git_reference_oid(ref));
+ error = git_odb_read_header(&_size, &type, odb, git_reference_oid(ref));
git_reference_free(ref);
@@ -797,26 +826,34 @@ int git_repository_is_empty(git_repository *repo)
return error == GIT_ENOTFOUND ? 1 : error;
}
-const char *git_repository_path(git_repository *repo, git_repository_pathid id)
+const char *git_repository_path(git_repository *repo)
{
assert(repo);
+ return repo->path_repository;
+}
- switch (id) {
- case GIT_REPO_PATH:
- return repo->path_repository;
+const char *git_repository_workdir(git_repository *repo)
+{
+ assert(repo);
- case GIT_REPO_PATH_INDEX:
- return repo->path_index;
+ if (repo->is_bare)
+ return NULL;
- case GIT_REPO_PATH_ODB:
- return repo->path_odb;
+ return repo->workdir;
+}
- case GIT_REPO_PATH_WORKDIR:
- return repo->path_workdir;
+int git_repository_set_workdir(git_repository *repo, const char *workdir)
+{
+ assert(repo && workdir);
- default:
- return NULL;
- }
+ free(repo->workdir);
+
+ repo->workdir = git__strdup(workdir);
+ if (repo->workdir == NULL)
+ return GIT_ENOMEM;
+
+ repo->is_bare = 0;
+ return GIT_SUCCESS;
}
int git_repository_is_bare(git_repository *repo)
diff --git a/src/repository.h b/src/repository.h
index 0c17958..c3a9a5c 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -32,15 +32,15 @@ struct git_object {
};
struct git_repository {
- git_odb *db;
+ git_odb *_odb;
+ git_config *_config;
+ git_index *_index;
git_cache objects;
git_refcache references;
char *path_repository;
- char *path_index;
- char *path_odb;
- char *path_workdir;
+ char *workdir;
unsigned is_bare:1;
unsigned int lru_counter;
@@ -53,4 +53,8 @@ void git_object__free(void *object);
int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header);
void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
+int git_repository_config__weakptr(git_config **out, git_repository *repo);
+int git_repository_odb__weakptr(git_odb **out, git_repository *repo);
+int git_repository_index__weakptr(git_index **out, git_repository *repo);
+
#endif
diff --git a/src/revwalk.c b/src/revwalk.c
index 7e31650..6477564 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -34,6 +34,7 @@ typedef struct commit_list {
struct git_revwalk {
git_repository *repo;
+ git_odb *odb;
git_hashtable *commits;
@@ -225,7 +226,7 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
if (commit->parsed)
return GIT_SUCCESS;
- if ((error = git_odb_read(&obj, walk->repo->db, &commit->oid)) < GIT_SUCCESS)
+ if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to parse commit. Can't read object");
if (obj->raw.type != GIT_OBJ_COMMIT) {
@@ -429,6 +430,7 @@ static int prepare_walk(git_revwalk *walk)
int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
{
+ int error;
git_revwalk *walk;
walk = git__malloc(sizeof(git_revwalk));
@@ -455,6 +457,12 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
walk->repo = repo;
+ error = git_repository_odb(&walk->odb, repo);
+ if (error < GIT_SUCCESS) {
+ git_revwalk_free(walk);
+ return error;
+ }
+
*revwalk_out = walk;
return GIT_SUCCESS;
}
@@ -469,6 +477,7 @@ void git_revwalk_free(git_revwalk *walk)
return;
git_revwalk_reset(walk);
+ git_odb_free(walk->odb);
/* if the parent has more than PARENTS_PER_COMMIT parents,
* we had to allocate a separate array for those parents.
diff --git a/src/status.c b/src/status.c
index d50199d..d09abfd 100644
--- a/src/status.c
+++ b/src/status.c
@@ -410,9 +410,15 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
unsigned int i;
git_tree *tree;
struct status_entry *e;
+ const char *workdir;
- if ((error = git_repository_index(&index, repo)) < GIT_SUCCESS) {
- return git__rethrow(error, "Failed to determine statuses. Index can't be opened");
+ if ((workdir = git_repository_workdir(repo)) == NULL)
+ return git__throw(GIT_ERROR,
+ "Cannot retrieve status on a bare repository");
+
+ if ((error = git_repository_index__weakptr(&index, repo)) < GIT_SUCCESS) {
+ return git__rethrow(error,
+ "Failed to determine statuses. Index can't be opened");
}
if ((error = retrieve_head_tree(&tree, repo)) < GIT_SUCCESS) {
@@ -422,7 +428,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
git_vector_init(&entries, DEFAULT_SIZE, status_cmp);
- dirent_st.workdir_path_len = strlen(repo->path_workdir);
+ dirent_st.workdir_path_len = strlen(workdir);
dirent_st.tree_position = 0;
dirent_st.index_position = 0;
dirent_st.tree = tree;
@@ -432,18 +438,29 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
dirent_st.head_tree_relative_path_len = 0;
dirent_st.is_dir = 1;
- strcpy(temp_path, repo->path_workdir);
+ strcpy(temp_path, workdir);
if (git_futils_isdir(temp_path)) {
- error = git__throw(GIT_EINVALIDPATH, "Failed to determine status of file '%s'. Provided path doesn't lead to a folder", temp_path);
+ error = git__throw(GIT_EINVALIDPATH,
+ "Failed to determine status of file '%s'. "
+ "The given path doesn't lead to a folder", temp_path);
goto exit;
}
- if ((error = alphasorted_futils_direach(temp_path, sizeof(temp_path), dirent_cb, &dirent_st)) < GIT_SUCCESS)
- error = git__rethrow(error, "Failed to determine statuses. An error occured while processing the working directory");
+ error = alphasorted_futils_direach(
+ temp_path, sizeof(temp_path),
+ dirent_cb, &dirent_st
+ );
+
+ if (error < GIT_SUCCESS)
+ error = git__rethrow(error,
+ "Failed to determine statuses. "
+ "An error occured while processing the working directory");
if ((error == GIT_SUCCESS) && ((error = dirent_cb(&dirent_st, NULL)) < GIT_SUCCESS))
- error = git__rethrow(error, "Failed to determine statuses. An error occured while post-processing the HEAD tree and the index");
+ error = git__rethrow(error,
+ "Failed to determine statuses. "
+ "An error occured while post-processing the HEAD tree and the index");
for (i = 0; i < entries.length; ++i) {
e = (struct status_entry *)git_vector_get(&entries, i);
@@ -451,7 +468,8 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
if (error == GIT_SUCCESS) {
error = callback(e->path, e->status_flags, payload);
if (error < GIT_SUCCESS)
- error = git__rethrow(error, "Failed to determine statuses. User callback failed");
+ error = git__rethrow(error,
+ "Failed to determine statuses. User callback failed");
}
git__free(e);
@@ -460,7 +478,6 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
exit:
git_vector_free(&entries);
git_tree_close(tree);
- git_index_free(index);
return error;
}
@@ -506,12 +523,19 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
char temp_path[GIT_PATH_MAX];
int error = GIT_SUCCESS;
git_tree *tree = NULL;
+ const char *workdir;
assert(status_flags && repo && path);
- git_path_join(temp_path, repo->path_workdir, path);
+ if ((workdir = git_repository_workdir(repo)) == NULL)
+ return git__throw(GIT_ERROR,
+ "Cannot retrieve status on a bare repository");
+
+ git_path_join(temp_path, workdir, path);
if (git_futils_isdir(temp_path) == GIT_SUCCESS)
- return git__throw(GIT_EINVALIDPATH, "Failed to determine status of file '%s'. Provided path leads to a folder, not a file", path);
+ return git__throw(GIT_EINVALIDPATH,
+ "Failed to determine status of file '%s'. "
+ "Given path leads to a folder, not a file", path);
e = status_entry_new(NULL, path);
if (e == NULL)
@@ -524,16 +548,18 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
}
/* Find file in Index */
- if ((error = git_repository_index(&index, repo)) < GIT_SUCCESS) {
- error = git__rethrow(error, "Failed to determine status of file '%s'. Index can't be opened", path);
+ if ((error = git_repository_index__weakptr(&index, repo)) < GIT_SUCCESS) {
+ error = git__rethrow(error,
+ "Failed to determine status of file '%s'."
+ "Index can't be opened", path);
goto exit;
}
status_entry_update_from_index(e, index);
- git_index_free(index);
if ((error = retrieve_head_tree(&tree, repo)) < GIT_SUCCESS) {
- error = git__rethrow(error, "Failed to determine status of file '%s'", path);
+ error = git__rethrow(error,
+ "Failed to determine status of file '%s'", path);
goto exit;
}
@@ -543,7 +569,9 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
error = recurse_tree_entry(tree, e, temp_path);
if (error < GIT_SUCCESS) {
- error = git__rethrow(error, "Failed to determine status of file '%s'. An error occured while processing the tree", path);
+ error = git__rethrow(error,
+ "Failed to determine status of file '%s'. "
+ "An error occured while processing the tree", path);
goto exit;
}
}
diff --git a/src/tag.c b/src/tag.c
index 7372e68..fd79dc3 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -175,6 +175,7 @@ static int write_tag_annotation(
{
int error = GIT_SUCCESS;
git_buf tag = GIT_BUF_INIT;
+ git_odb *odb;
git_oid__writebuf(&tag, "object ", git_object_id(target));
git_buf_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target)));
@@ -188,7 +189,13 @@ static int write_tag_annotation(
return git__throw(GIT_ENOMEM, "Not enough memory to build the tag data");
}
- error = git_odb_write(oid, git_repository_database(repo), tag.ptr, tag.size, GIT_OBJ_TAG);
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS) {
+ git_buf_free(&tag);
+ return error;
+ }
+
+ error = git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG);
git_buf_free(&tag);
if (error < GIT_SUCCESS)
@@ -286,6 +293,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
{
git_tag tag;
int error, should_update_ref = 0;
+ git_odb *odb;
git_odb_stream *stream;
git_odb_object *target_obj;
@@ -296,12 +304,16 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
memset(&tag, 0, sizeof(tag));
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS)
+ return error;
+
/* validate the buffer */
if ((error = parse_tag_buffer(&tag, buffer, buffer + strlen(buffer))) < GIT_SUCCESS)
return git__rethrow(error, "Failed to create tag");
/* validate the target */
- if ((error = git_odb_read(&target_obj, repo->db, &tag.target)) < GIT_SUCCESS)
+ if ((error = git_odb_read(&target_obj, odb, &tag.target)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to create tag");
if (tag.type != target_obj->raw.type)
@@ -334,7 +346,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
}
/* write the buffer */
- if ((error = git_odb_open_wstream(&stream, repo->db, strlen(buffer), GIT_OBJ_TAG)) < GIT_SUCCESS) {
+ if ((error = git_odb_open_wstream(&stream, odb, strlen(buffer), GIT_OBJ_TAG)) < GIT_SUCCESS) {
git_reference_free(new_ref);
return git__rethrow(error, "Failed to create tag");
}
diff --git a/src/tree.c b/src/tree.c
index 92ca5ab..ec44d24 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -300,9 +300,15 @@ static int append_entry(git_treebuilder *bld, const char *filename, const git_oi
return GIT_SUCCESS;
}
-static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsigned int start)
+static int write_tree(
+ git_oid *oid,
+ git_repository *repo,
+ git_index *index,
+ const char *dirname,
+ unsigned int start)
{
git_treebuilder *bld = NULL;
+
unsigned int i, entries = git_index_entrycount(index);
int error;
size_t dirname_len = strlen(dirname);
@@ -358,7 +364,7 @@ static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsig
}
/* Write out the subtree */
- written = write_tree(&sub_oid, index, subdir, i);
+ written = write_tree(&sub_oid, repo, index, subdir, i);
if (written < 0) {
error = git__rethrow(written, "Failed to write subtree %s", subdir);
} else {
@@ -391,7 +397,7 @@ static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsig
}
}
- error = git_treebuilder_write(oid, index->repository, bld);
+ error = git_treebuilder_write(oid, repo, bld);
if (error < GIT_SUCCESS)
error = git__rethrow(error, "Failed to write tree to db");
@@ -406,10 +412,15 @@ static int write_tree(git_oid *oid, git_index *index, const char *dirname, unsig
int git_tree_create_fromindex(git_oid *oid, git_index *index)
{
+ git_repository *repo;
int error;
- if (index->repository == NULL)
- return git__throw(GIT_EBAREINDEX, "Failed to create tree. The index file is not backed up by an existing repository");
+ repo = (git_repository *)GIT_REFCOUNT_OWNER(index);
+
+ if (repo == NULL)
+ return git__throw(GIT_EBAREINDEX,
+ "Failed to create tree. "
+ "The index file is not backed up by an existing repository");
if (index->tree != NULL && index->tree->entries >= 0) {
git_oid_cpy(oid, &index->tree->oid);
@@ -417,7 +428,7 @@ int git_tree_create_fromindex(git_oid *oid, git_index *index)
}
/* The tree cache didn't help us */
- error = write_tree(oid, index, "", 0);
+ error = write_tree(oid, repo, index, "", 0);
return (error < GIT_SUCCESS) ? git__rethrow(error, "Failed to create tree") : GIT_SUCCESS;
}
@@ -546,6 +557,7 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
unsigned int i;
int error;
git_buf tree = GIT_BUF_INIT;
+ git_odb *odb;
assert(bld);
@@ -570,7 +582,13 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
return git__throw(GIT_ENOMEM, "Not enough memory to build the tree data");
}
- error = git_odb_write(oid, git_repository_database(repo), tree.ptr, tree.size, GIT_OBJ_TREE);
+ error = git_repository_odb__weakptr(&odb, repo);
+ if (error < GIT_SUCCESS) {
+ git_buf_free(&tree);
+ return error;
+ }
+
+ error = git_odb_write(oid, odb, tree.ptr, tree.size, GIT_OBJ_TREE);
git_buf_free(&tree);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to write tree");
diff --git a/src/util.h b/src/util.h
index fbf9012..2b239a0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -129,4 +129,28 @@ extern void **git__bsearch(const void *key, void **base, size_t nmemb,
extern int git__strcmp_cb(const void *a, const void *b);
+typedef struct {
+ short refcount;
+ void *owner;
+} git_refcount;
+
+typedef void (*git_refcount_freeptr)(void *r);
+
+#define GIT_REFCOUNT_INC(r) { \
+ ((git_refcount *)(r))->refcount++; \
+}
+
+#define GIT_REFCOUNT_DEC(_r, do_free) { \
+ git_refcount *r = (git_refcount *)(_r); \
+ r->refcount--; \
+ if (r->refcount == 0 && r->owner == NULL) { do_free(_r); } \
+}
+
+#define GIT_REFCOUNT_OWN(r, o) { \
+ ((git_refcount *)(r))->owner = o; \
+}
+
+#define GIT_REFCOUNT_OWNER(r) (((git_refcount *)(r))->owner)
+
+
#endif /* INCLUDE_util_h__ */
diff --git a/tests-clay/clay.h b/tests-clay/clay.h
index 3db9600..b05a824 100644
--- a/tests-clay/clay.h
+++ b/tests-clay/clay.h
@@ -59,10 +59,30 @@ void cl_fixture_cleanup(const char *fixture_name);
*/
extern void test_buf_basic__printf(void);
extern void test_buf_basic__resize(void);
+extern void test_config_add__cleanup(void);
+extern void test_config_add__initialize(void);
+extern void test_config_add__to_existing_section(void);
+extern void test_config_add__to_new_section(void);
extern void test_config_new__write_new_config(void);
+extern void test_config_read__blank_lines(void);
+extern void test_config_read__case_sensitive(void);
+extern void test_config_read__empty_files(void);
+extern void test_config_read__header_in_last_line(void);
+extern void test_config_read__invalid_ext_headers(void);
+extern void test_config_read__lone_variable(void);
+extern void test_config_read__multiline_value(void);
+extern void test_config_read__number_suffixes(void);
+extern void test_config_read__prefixes(void);
+extern void test_config_read__simple_read(void);
+extern void test_config_read__subsection_header(void);
extern void test_config_stress__cleanup(void);
extern void test_config_stress__dont_break_on_invalid_input(void);
extern void test_config_stress__initialize(void);
+extern void test_config_write__cleanup(void);
+extern void test_config_write__delete_inexistent(void);
+extern void test_config_write__delete_value(void);
+extern void test_config_write__initialize(void);
+extern void test_config_write__replace_value(void);
extern void test_core_dirent__dont_traverse_dot(void);
extern void test_core_dirent__dont_traverse_empty_folders(void);
extern void test_core_dirent__traverse_slash_terminated_folder(void);
@@ -133,6 +153,31 @@ extern void test_object_tree_frompath__fail_when_processing_an_invalid_path(void
extern void test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment(void);
extern void test_object_tree_frompath__initialize(void);
extern void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void);
+extern void test_odb_loose__cleanup(void);
+extern void test_odb_loose__exists(void);
+extern void test_odb_loose__initialize(void);
+extern void test_odb_loose__simple_reads(void);
+extern void test_odb_packed__cleanup(void);
+extern void test_odb_packed__initialize(void);
+extern void test_odb_packed__mass_read(void);
+extern void test_odb_packed__read_header_0(void);
+extern void test_odb_packed__read_header_1(void);
+extern void test_odb_sorting__alternate_backends_sorting(void);
+extern void test_odb_sorting__basic_backends_sorting(void);
+extern void test_odb_sorting__cleanup(void);
+extern void test_odb_sorting__initialize(void);
+extern void test_repo_getters__cleanup(void);
+extern void test_repo_getters__empty(void);
+extern void test_repo_getters__head_detached(void);
+extern void test_repo_getters__head_orphan(void);
+extern void test_repo_getters__initialize(void);
+extern void test_repo_init__bare_repo(void);
+extern void test_repo_init__bare_repo_noslash(void);
+extern void test_repo_init__initialize(void);
+extern void test_repo_init__standard_repo(void);
+extern void test_repo_init__standard_repo_noslash(void);
+extern void test_repo_open__bare_empty_repo(void);
+extern void test_repo_open__standard_empty_repo(void);
extern void test_status_single__hash_single_file(void);
extern void test_status_worktree__cleanup(void);
extern void test_status_worktree__empty_repository(void);
diff --git a/tests-clay/clay_main.c b/tests-clay/clay_main.c
index 2f9a49d..5c97057 100644
--- a/tests-clay/clay_main.c
+++ b/tests-clay/clay_main.c
@@ -108,12 +108,34 @@ static const struct clay_func _clay_cb_buf_basic[] = {
{"printf", &test_buf_basic__printf},
{"resize", &test_buf_basic__resize}
};
+static const struct clay_func _clay_cb_config_add[] = {
+ {"to_existing_section", &test_config_add__to_existing_section},
+ {"to_new_section", &test_config_add__to_new_section}
+};
static const struct clay_func _clay_cb_config_new[] = {
{"write_new_config", &test_config_new__write_new_config}
};
+static const struct clay_func _clay_cb_config_read[] = {
+ {"blank_lines", &test_config_read__blank_lines},
+ {"case_sensitive", &test_config_read__case_sensitive},
+ {"empty_files", &test_config_read__empty_files},
+ {"header_in_last_line", &test_config_read__header_in_last_line},
+ {"invalid_ext_headers", &test_config_read__invalid_ext_headers},
+ {"lone_variable", &test_config_read__lone_variable},
+ {"multiline_value", &test_config_read__multiline_value},
+ {"number_suffixes", &test_config_read__number_suffixes},
+ {"prefixes", &test_config_read__prefixes},
+ {"simple_read", &test_config_read__simple_read},
+ {"subsection_header", &test_config_read__subsection_header}
+};
static const struct clay_func _clay_cb_config_stress[] = {
{"dont_break_on_invalid_input", &test_config_stress__dont_break_on_invalid_input}
};
+static const struct clay_func _clay_cb_config_write[] = {
+ {"delete_inexistent", &test_config_write__delete_inexistent},
+ {"delete_value", &test_config_write__delete_value},
+ {"replace_value", &test_config_write__replace_value}
+};
static const struct clay_func _clay_cb_core_dirent[] = {
{"dont_traverse_dot", &test_core_dirent__dont_traverse_dot},
{"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders},
@@ -216,6 +238,34 @@ static const struct clay_func _clay_cb_object_tree_frompath[] = {
{"fail_when_processing_an_unknown_tree_segment", &test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment},
{"retrieve_tree_from_path_to_treeentry", &test_object_tree_frompath__retrieve_tree_from_path_to_treeentry}
};
+static const struct clay_func _clay_cb_odb_loose[] = {
+ {"exists", &test_odb_loose__exists},
+ {"simple_reads", &test_odb_loose__simple_reads}
+};
+static const struct clay_func _clay_cb_odb_packed[] = {
+ {"mass_read", &test_odb_packed__mass_read},
+ {"read_header_0", &test_odb_packed__read_header_0},
+ {"read_header_1", &test_odb_packed__read_header_1}
+};
+static const struct clay_func _clay_cb_odb_sorting[] = {
+ {"alternate_backends_sorting", &test_odb_sorting__alternate_backends_sorting},
+ {"basic_backends_sorting", &test_odb_sorting__basic_backends_sorting}
+};
+static const struct clay_func _clay_cb_repo_getters[] = {
+ {"empty", &test_repo_getters__empty},
+ {"head_detached", &test_repo_getters__head_detached},
+ {"head_orphan", &test_repo_getters__head_orphan}
+};
+static const struct clay_func _clay_cb_repo_init[] = {
+ {"bare_repo", &test_repo_init__bare_repo},
+ {"bare_repo_noslash", &test_repo_init__bare_repo_noslash},
+ {"standard_repo", &test_repo_init__standard_repo},
+ {"standard_repo_noslash", &test_repo_init__standard_repo_noslash}
+};
+static const struct clay_func _clay_cb_repo_open[] = {
+ {"bare_empty_repo", &test_repo_open__bare_empty_repo},
+ {"standard_empty_repo", &test_repo_open__standard_empty_repo}
+};
static const struct clay_func _clay_cb_status_single[] = {
{"hash_single_file", &test_status_single__hash_single_file}
};
@@ -232,18 +282,36 @@ static const struct clay_suite _clay_suites[] = {
_clay_cb_buf_basic, 2
},
{
+ "config::add",
+ {"initialize", &test_config_add__initialize},
+ {"cleanup", &test_config_add__cleanup},
+ _clay_cb_config_add, 2
+ },
+ {
"config::new",
{NULL, NULL},
{NULL, NULL},
_clay_cb_config_new, 1
},
{
+ "config::read",
+ {NULL, NULL},
+ {NULL, NULL},
+ _clay_cb_config_read, 11
+ },
+ {
"config::stress",
{"initialize", &test_config_stress__initialize},
{"cleanup", &test_config_stress__cleanup},
_clay_cb_config_stress, 1
},
{
+ "config::write",
+ {"initialize", &test_config_write__initialize},
+ {"cleanup", &test_config_write__cleanup},
+ _clay_cb_config_write, 3
+ },
+ {
"core::dirent",
{NULL, NULL},
{NULL, NULL},
@@ -358,6 +426,42 @@ static const struct clay_suite _clay_suites[] = {
_clay_cb_object_tree_frompath, 3
},
{
+ "odb::loose",
+ {"initialize", &test_odb_loose__initialize},
+ {"cleanup", &test_odb_loose__cleanup},
+ _clay_cb_odb_loose, 2
+ },
+ {
+ "odb::packed",
+ {"initialize", &test_odb_packed__initialize},
+ {"cleanup", &test_odb_packed__cleanup},
+ _clay_cb_odb_packed, 3
+ },
+ {
+ "odb::sorting",
+ {"initialize", &test_odb_sorting__initialize},
+ {"cleanup", &test_odb_sorting__cleanup},
+ _clay_cb_odb_sorting, 2
+ },
+ {
+ "repo::getters",
+ {"initialize", &test_repo_getters__initialize},
+ {"cleanup", &test_repo_getters__cleanup},
+ _clay_cb_repo_getters, 3
+ },
+ {
+ "repo::init",
+ {"initialize", &test_repo_init__initialize},
+ {NULL, NULL},
+ _clay_cb_repo_init, 4
+ },
+ {
+ "repo::open",
+ {NULL, NULL},
+ {NULL, NULL},
+ _clay_cb_repo_open, 2
+ },
+ {
"status::single",
{NULL, NULL},
{NULL, NULL},
@@ -371,8 +475,8 @@ static const struct clay_suite _clay_suites[] = {
}
};
-static size_t _clay_suite_count = 24;
-static size_t _clay_callback_count = 71;
+static size_t _clay_suite_count = 33;
+static size_t _clay_callback_count = 103;
/* Core test functions */
static void
diff --git a/tests-clay/config/add.c b/tests-clay/config/add.c
new file mode 100644
index 0000000..de549af
--- /dev/null
+++ b/tests-clay/config/add.c
@@ -0,0 +1,37 @@
+#include "clay_libgit2.h"
+
+void test_config_add__initialize(void)
+{
+ cl_fixture_sandbox("config/config10");
+}
+
+void test_config_add__cleanup(void)
+{
+ cl_fixture_cleanup("config10");
+}
+
+void test_config_add__to_existing_section(void)
+{
+ git_config *cfg;
+ int32_t i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config10"));
+ cl_git_pass(git_config_set_int32(cfg, "empty.tmp", 5));
+ cl_git_pass(git_config_get_int32(cfg, "empty.tmp", &i));
+ cl_assert(i == 5);
+ cl_git_pass(git_config_delete(cfg, "empty.tmp"));
+ git_config_free(cfg);
+}
+
+void test_config_add__to_new_section(void)
+{
+ git_config *cfg;
+ int32_t i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config10"));
+ cl_git_pass(git_config_set_int32(cfg, "section.tmp", 5));
+ cl_git_pass(git_config_get_int32(cfg, "section.tmp", &i));
+ cl_assert(i == 5);
+ cl_git_pass(git_config_delete(cfg, "section.tmp"));
+ git_config_free(cfg);
+}
diff --git a/tests-clay/config/read.c b/tests-clay/config/read.c
new file mode 100644
index 0000000..08dc03a
--- /dev/null
+++ b/tests-clay/config/read.c
@@ -0,0 +1,209 @@
+#include "clay_libgit2.h"
+
+void test_config_read__simple_read(void)
+{
+ git_config *cfg;
+ int32_t i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config0")));
+
+ cl_git_pass(git_config_get_int32(cfg, "core.repositoryformatversion", &i));
+ cl_assert(i == 0);
+ cl_git_pass(git_config_get_bool(cfg, "core.filemode", &i));
+ cl_assert(i == 1);
+ cl_git_pass(git_config_get_bool(cfg, "core.bare", &i));
+ cl_assert(i == 0);
+ cl_git_pass(git_config_get_bool(cfg, "core.logallrefupdates", &i));
+ cl_assert(i == 1);
+
+ git_config_free(cfg);
+}
+
+void test_config_read__case_sensitive(void)
+{
+ git_config *cfg;
+ int i;
+ const char *str;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config1")));
+
+ cl_git_pass(git_config_get_string(cfg, "this.that.other", &str));
+ cl_assert(!strcmp(str, "true"));
+ cl_git_pass(git_config_get_string(cfg, "this.That.other", &str));
+ cl_assert(!strcmp(str, "yes"));
+
+ cl_git_pass(git_config_get_bool(cfg, "this.that.other", &i));
+ cl_assert(i == 1);
+ cl_git_pass(git_config_get_bool(cfg, "this.That.other", &i));
+ cl_assert(i == 1);
+
+ /* This one doesn't exist */
+ cl_must_fail(git_config_get_bool(cfg, "this.thaT.other", &i));
+
+ git_config_free(cfg);
+}
+
+/*
+ * If \ is the last non-space character on the line, we read the next
+ * one, separating each line with SP.
+ */
+void test_config_read__multiline_value(void)
+{
+ git_config *cfg;
+ const char *str;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config2")));
+
+ cl_git_pass(git_config_get_string(cfg, "this.That.and", &str));
+ cl_assert(!strcmp(str, "one one one two two three three"));
+
+ git_config_free(cfg);
+}
+
+/*
+ * This kind of subsection declaration is case-insensitive
+ */
+void test_config_read__subsection_header(void)
+{
+ git_config *cfg;
+ const char *str;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config3")));
+
+ cl_git_pass(git_config_get_string(cfg, "section.subsection.var", &str));
+ cl_assert(!strcmp(str, "hello"));
+
+ /* The subsection is transformed to lower-case */
+ cl_must_fail(git_config_get_string(cfg, "section.subSectIon.var", &str));
+
+ git_config_free(cfg);
+}
+
+void test_config_read__lone_variable(void)
+{
+ git_config *cfg;
+ const char *str;
+ int i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config4")));
+
+ cl_git_pass(git_config_get_string(cfg, "some.section.variable", &str));
+ cl_assert(str == NULL);
+
+ cl_git_pass(git_config_get_bool(cfg, "some.section.variable", &i));
+ cl_assert(i == 1);
+
+ git_config_free(cfg);
+}
+
+void test_config_read__number_suffixes(void)
+{
+ git_config *cfg;
+ int64_t i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config5")));
+
+ cl_git_pass(git_config_get_int64(cfg, "number.simple", &i));
+ cl_assert(i == 1);
+
+ cl_git_pass(git_config_get_int64(cfg, "number.k", &i));
+ cl_assert(i == 1 * 1024);
+
+ cl_git_pass(git_config_get_int64(cfg, "number.kk", &i));
+ cl_assert(i == 1 * 1024);
+
+ cl_git_pass(git_config_get_int64(cfg, "number.m", &i));
+ cl_assert(i == 1 * 1024 * 1024);
+
+ cl_git_pass(git_config_get_int64(cfg, "number.mm", &i));
+ cl_assert(i == 1 * 1024 * 1024);
+
+ cl_git_pass(git_config_get_int64(cfg, "number.g", &i));
+ cl_assert(i == 1 * 1024 * 1024 * 1024);
+
+ cl_git_pass(git_config_get_int64(cfg, "number.gg", &i));
+ cl_assert(i == 1 * 1024 * 1024 * 1024);
+
+ git_config_free(cfg);
+}
+
+void test_config_read__blank_lines(void)
+{
+ git_config *cfg;
+ int i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config6")));
+
+ cl_git_pass(git_config_get_bool(cfg, "valid.subsection.something", &i));
+ cl_assert(i == 1);
+
+ cl_git_pass(git_config_get_bool(cfg, "something.else.something", &i));
+ cl_assert(i == 0);
+
+ git_config_free(cfg);
+}
+
+void test_config_read__invalid_ext_headers(void)
+{
+ git_config *cfg;
+ cl_must_fail(git_config_open_ondisk(&cfg, cl_fixture("config/config7")));
+}
+
+void test_config_read__empty_files(void)
+{
+ git_config *cfg;
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config8")));
+ git_config_free(cfg);
+}
+
+void test_config_read__header_in_last_line(void)
+{
+ git_config *cfg;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config10")));
+ git_config_free(cfg);
+}
+
+void test_config_read__prefixes(void)
+{
+ git_config *cfg;
+ const char *str;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9")));
+ cl_git_pass(git_config_get_string(cfg, "remote.ab.url", &str));
+ cl_assert(strcmp(str, "http://example.com/git/ab") == 0);
+
+ cl_git_pass(git_config_get_string(cfg, "remote.abba.url", &str));
+ cl_assert(strcmp(str, "http://example.com/git/abba") == 0);
+
+ git_config_free(cfg);
+}
+
+#if 0
+
+BEGIN_TEST(config10, "a repo's config overrides the global config")
+ git_repository *repo;
+ git_config *cfg;
+ int32_t version;
+
+ cl_git_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ cl_git_pass(git_repository_config(&cfg, repo, GLOBAL_CONFIG, NULL));
+ cl_git_pass(git_config_get_int32(cfg, "core.repositoryformatversion", &version));
+ cl_assert(version == 0);
+ git_config_free(cfg);
+ git_repository_free(repo);
+END_TEST
+
+BEGIN_TEST(config11, "fall back to the global config")
+ git_repository *repo;
+ git_config *cfg;
+ int32_t num;
+
+ cl_git_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ cl_git_pass(git_repository_config(&cfg, repo, GLOBAL_CONFIG, NULL));
+ cl_git_pass(git_config_get_int32(cfg, "core.something", &num));
+ cl_assert(num == 2);
+ git_config_free(cfg);
+ git_repository_free(repo);
+END_TEST
+#endif
diff --git a/tests-clay/config/stress.c b/tests-clay/config/stress.c
index 8323215..b48ed39 100644
--- a/tests-clay/config/stress.c
+++ b/tests-clay/config/stress.c
@@ -4,23 +4,21 @@
#include "fileops.h"
#include "posix.h"
-#define TEST_CONFIG "git-test-config"
-
void test_config_stress__initialize(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
- git_filebuf_open(&file, TEST_CONFIG, 0);
+ cl_git_pass(git_filebuf_open(&file, "git-test-config", 0));
git_filebuf_printf(&file, "[color]\n\tui = auto\n");
git_filebuf_printf(&file, "[core]\n\teditor = \n");
- git_filebuf_commit(&file, 0666);
+ cl_git_pass(git_filebuf_commit(&file, 0666));
}
void test_config_stress__cleanup(void)
{
- p_unlink(TEST_CONFIG);
+ p_unlink("git-test-config");
}
void test_config_stress__dont_break_on_invalid_input(void)
@@ -29,8 +27,8 @@ void test_config_stress__dont_break_on_invalid_input(void)
struct git_config_file *file;
git_config *config;
- cl_git_pass(git_futils_exists(TEST_CONFIG));
- cl_git_pass(git_config_file__ondisk(&file, TEST_CONFIG));
+ cl_git_pass(git_futils_exists("git-test-config"));
+ cl_git_pass(git_config_file__ondisk(&file, "git-test-config"));
cl_git_pass(git_config_new(&config));
cl_git_pass(git_config_add_file(config, file, 0));
diff --git a/tests-clay/config/write.c b/tests-clay/config/write.c
new file mode 100644
index 0000000..57610ab
--- /dev/null
+++ b/tests-clay/config/write.c
@@ -0,0 +1,77 @@
+#include "clay_libgit2.h"
+
+void test_config_write__initialize(void)
+{
+ cl_fixture_sandbox("config/config9");
+}
+
+void test_config_write__cleanup(void)
+{
+ cl_fixture_cleanup("config9");
+}
+
+void test_config_write__replace_value(void)
+{
+ git_config *cfg;
+ int i;
+ int64_t l, expected = +9223372036854775803;
+
+ /* By freeing the config, we make sure we flush the values */
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_set_int32(cfg, "core.dummy", 5));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_get_int32(cfg, "core.dummy", &i));
+ cl_assert(i == 5);
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_set_int64(cfg, "core.verylong", expected));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_get_int64(cfg, "core.verylong", &l));
+ cl_assert(l == expected);
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_must_fail(git_config_get_int32(cfg, "core.verylong", &i));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_set_int64(cfg, "core.verylong", 1));
+ git_config_free(cfg);
+}
+
+void test_config_write__delete_value(void)
+{
+ git_config *cfg;
+ int32_t i;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_set_int32(cfg, "core.dummy", 5));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_git_pass(git_config_delete(cfg, "core.dummy"));
+ git_config_free(cfg);
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_assert(git_config_get_int32(cfg, "core.dummy", &i) == GIT_ENOTFOUND);
+ cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1));
+ git_config_free(cfg);
+}
+
+void test_config_write__delete_inexistent(void)
+{
+ git_config *cfg;
+
+ cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
+ cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND);
+ git_config_free(cfg);
+}
diff --git a/tests-clay/network/remotes.c b/tests-clay/network/remotes.c
index a7cc742..2c3a32e 100644
--- a/tests-clay/network/remotes.c
+++ b/tests-clay/network/remotes.c
@@ -1,45 +1,43 @@
#include "clay_libgit2.h"
-#define REPOSITORY_FOLDER "testrepo.git"
-
-static git_remote *remote;
-static git_repository *repo;
-static git_config *cfg;
-static const git_refspec *refspec;
+static git_remote *_remote;
+static git_repository *_repo;
+static const git_refspec *_refspec;
void test_network_remotes__initialize(void)
{
- cl_fixture_sandbox(REPOSITORY_FOLDER);
- cl_git_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- cl_git_pass(git_repository_config(&cfg, repo, NULL, NULL));
- cl_git_pass(git_remote_get(&remote, cfg, "test"));
- refspec = git_remote_fetchspec(remote);
- cl_assert(refspec != NULL);
+ cl_fixture_sandbox("testrepo.git");
+
+ cl_git_pass(git_repository_open(&_repo, "testrepo.git"));
+ cl_git_pass(git_remote_load(&_remote, _repo, "test"));
+
+ _refspec = git_remote_fetchspec(_remote);
+ cl_assert(_refspec != NULL);
}
void test_network_remotes__cleanup(void)
{
- git_config_free(cfg);
- git_repository_free(repo);
- git_remote_free(remote);
+ git_remote_free(_remote);
+ git_repository_free(_repo);
+ cl_fixture_cleanup("testrepo.git");
}
void test_network_remotes__parsing(void)
{
- cl_assert(!strcmp(git_remote_name(remote), "test"));
- cl_assert(!strcmp(git_remote_url(remote), "git://github.com/libgit2/libgit2"));
+ cl_assert(!strcmp(git_remote_name(_remote), "test"));
+ cl_assert(!strcmp(git_remote_url(_remote), "git://github.com/libgit2/libgit2"));
}
void test_network_remotes__refspec_parsing(void)
{
- cl_assert(!strcmp(git_refspec_src(refspec), "refs/heads/*"));
- cl_assert(!strcmp(git_refspec_dst(refspec), "refs/remotes/test/*"));
+ cl_assert(!strcmp(git_refspec_src(_refspec), "refs/heads/*"));
+ cl_assert(!strcmp(git_refspec_dst(_refspec), "refs/remotes/test/*"));
}
void test_network_remotes__fnmatch(void)
{
- cl_git_pass(git_refspec_src_match(refspec, "refs/heads/master"));
- cl_git_pass(git_refspec_src_match(refspec, "refs/heads/multi/level/branch"));
+ cl_git_pass(git_refspec_src_match(_refspec, "refs/heads/master"));
+ cl_git_pass(git_refspec_src_match(_refspec, "refs/heads/multi/level/branch"));
}
void test_network_remotes__transform(void)
@@ -47,6 +45,6 @@ void test_network_remotes__transform(void)
char ref[1024];
memset(ref, 0x0, sizeof(ref));
- cl_git_pass(git_refspec_transform(ref, sizeof(ref), refspec, "refs/heads/master"));
+ cl_git_pass(git_refspec_transform(ref, sizeof(ref), _refspec, "refs/heads/master"));
cl_assert(!strcmp(ref, "refs/remotes/test/master"));
}
diff --git a/tests-clay/object/tree/frompath.c b/tests-clay/object/tree/frompath.c
index 1effcb1..7d6f42d 100644
--- a/tests-clay/object/tree/frompath.c
+++ b/tests-clay/object/tree/frompath.c
@@ -1,7 +1,5 @@
#include "clay_libgit2.h"
-#define REPOSITORY_FOLDER "testrepo.git"
-
static git_repository *repo;
const char *tree_with_subtrees_oid = "ae90f12eea699729ed24555e40b9fd669da12a12";
static git_tree *tree;
@@ -10,8 +8,8 @@ void test_object_tree_frompath__initialize(void)
{
git_oid id;
- cl_fixture_sandbox(REPOSITORY_FOLDER);
- cl_git_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ cl_fixture_sandbox("testrepo.git");
+ cl_git_pass(git_repository_open(&repo, "testrepo.git"));
cl_assert(repo != NULL);
cl_git_pass(git_oid_fromstr(&id, tree_with_subtrees_oid));
@@ -23,6 +21,7 @@ void test_object_tree_frompath__cleanup(void)
{
git_tree_close(tree);
git_repository_free(repo);
+ cl_fixture_cleanup("testrepo.git");
}
static void assert_tree_from_path(git_tree *root, const char *path, git_error expected_result, const char *expected_raw_oid)
diff --git a/tests-clay/odb/loose.c b/tests-clay/odb/loose.c
new file mode 100644
index 0000000..756a157
--- /dev/null
+++ b/tests-clay/odb/loose.c
@@ -0,0 +1,84 @@
+#include "clay_libgit2.h"
+#include "odb.h"
+#include "posix.h"
+#include "loose_data.h"
+
+static void write_object_files(object_data *d)
+{
+ int fd;
+
+ if (p_mkdir(d->dir, GIT_OBJECT_DIR_MODE) < 0)
+ cl_assert(errno == EEXIST);
+
+ cl_assert((fd = p_creat(d->file, S_IREAD | S_IWRITE)) >= 0);
+ cl_must_pass(p_write(fd, d->bytes, d->blen));
+
+ p_close(fd);
+}
+
+static void cmp_objects(git_rawobj *o, object_data *d)
+{
+ cl_assert(o->type == git_object_string2type(d->type));
+ cl_assert(o->len == d->dlen);
+
+ if (o->len > 0)
+ cl_assert(memcmp(o->data, d->data, o->len) == 0);
+}
+
+static void test_read_object(object_data *data)
+{
+ git_oid id;
+ git_odb_object *obj;
+ git_odb *odb;
+
+ write_object_files(data);
+
+ cl_git_pass(git_odb_open(&odb, "test-objects"));
+ cl_git_pass(git_oid_fromstr(&id, data->id));
+ cl_git_pass(git_odb_read(&obj, odb, &id));
+
+ cmp_objects((git_rawobj *)&obj->raw, data);
+
+ git_odb_object_close(obj);
+ git_odb_free(odb);
+}
+
+void test_odb_loose__initialize(void)
+{
+ cl_must_pass(p_mkdir("test-objects", GIT_OBJECT_DIR_MODE));
+}
+
+void test_odb_loose__cleanup(void)
+{
+ cl_fixture_cleanup("test-objects");
+}
+
+void test_odb_loose__exists(void)
+{
+ git_oid id, id2;
+ git_odb *odb;
+
+ write_object_files(&one);
+ cl_git_pass(git_odb_open(&odb, "test-objects"));
+
+ cl_git_pass(git_oid_fromstr(&id, one.id));
+
+ cl_assert(git_odb_exists(odb, &id));
+
+ /* Test for a non-existant object */
+ cl_git_pass(git_oid_fromstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
+ cl_assert(!git_odb_exists(odb, &id2));
+
+ git_odb_free(odb);
+}
+
+void test_odb_loose__simple_reads(void)
+{
+ test_read_object(&commit);
+ test_read_object(&tree);
+ test_read_object(&tag);
+ test_read_object(&zero);
+ test_read_object(&one);
+ test_read_object(&two);
+ test_read_object(&some);
+}
diff --git a/tests-clay/odb/loose_data.h b/tests-clay/odb/loose_data.h
new file mode 100644
index 0000000..c10c9bc
--- /dev/null
+++ b/tests-clay/odb/loose_data.h
@@ -0,0 +1,522 @@
+typedef struct object_data {
+ unsigned char *bytes; /* (compressed) bytes stored in object store */
+ size_t blen; /* length of data in object store */
+ char *id; /* object id (sha1) */
+ char *type; /* object type */
+ char *dir; /* object store (fan-out) directory name */
+ char *file; /* object store filename */
+ unsigned char *data; /* (uncompressed) object data */
+ size_t dlen; /* length of (uncompressed) object data */
+} object_data;
+
+/* one == 8b137891791fe96927ad78e64b0aad7bded08bdc */
+static unsigned char one_bytes[] = {
+ 0x31, 0x78, 0x9c, 0xe3, 0x02, 0x00, 0x00, 0x0b,
+ 0x00, 0x0b,
+};
+
+static unsigned char one_data[] = {
+ 0x0a,
+};
+
+static object_data one = {
+ one_bytes,
+ sizeof(one_bytes),
+ "8b137891791fe96927ad78e64b0aad7bded08bdc",
+ "blob",
+ "test-objects/8b",
+ "test-objects/8b/137891791fe96927ad78e64b0aad7bded08bdc",
+ one_data,
+ sizeof(one_data),
+};
+
+
+/* commit == 3d7f8a6af076c8c3f20071a8935cdbe8228594d1 */
+static unsigned char commit_bytes[] = {
+ 0x78, 0x01, 0x85, 0x50, 0xc1, 0x6a, 0xc3, 0x30,
+ 0x0c, 0xdd, 0xd9, 0x5f, 0xa1, 0xfb, 0x96, 0x12,
+ 0xbb, 0x29, 0x71, 0x46, 0x19, 0x2b, 0x3d, 0x97,
+ 0x1d, 0xd6, 0x7d, 0x80, 0x1d, 0xcb, 0x89, 0x21,
+ 0xb6, 0x82, 0xed, 0x40, 0xf3, 0xf7, 0xf3, 0x48,
+ 0x29, 0x3b, 0x6d, 0xd2, 0xe5, 0xbd, 0x27, 0xbd,
+ 0x27, 0x50, 0x4f, 0xde, 0xbb, 0x0c, 0xfb, 0x43,
+ 0xf3, 0x94, 0x23, 0x22, 0x18, 0x6b, 0x85, 0x51,
+ 0x5d, 0xad, 0xc5, 0xa1, 0x41, 0xae, 0x51, 0x4b,
+ 0xd9, 0x19, 0x6e, 0x4b, 0x0b, 0x29, 0x35, 0x72,
+ 0x59, 0xef, 0x5b, 0x29, 0x8c, 0x65, 0x6a, 0xc9,
+ 0x23, 0x45, 0x38, 0xc1, 0x17, 0x5c, 0x7f, 0xc0,
+ 0x71, 0x13, 0xde, 0xf1, 0xa6, 0xfc, 0x3c, 0xe1,
+ 0xae, 0x27, 0xff, 0x06, 0x5c, 0x88, 0x56, 0xf2,
+ 0x46, 0x74, 0x2d, 0x3c, 0xd7, 0xa5, 0x58, 0x51,
+ 0xcb, 0xb9, 0x8c, 0x11, 0xce, 0xf0, 0x01, 0x97,
+ 0x0d, 0x1e, 0x1f, 0xea, 0x3f, 0x6e, 0x76, 0x02,
+ 0x0a, 0x58, 0x4d, 0x2e, 0x20, 0x6c, 0x1e, 0x48,
+ 0x8b, 0xf7, 0x2a, 0xae, 0x8c, 0x5d, 0x47, 0x04,
+ 0x4d, 0x66, 0x05, 0xb2, 0x90, 0x0b, 0xbe, 0xcf,
+ 0x3d, 0xa6, 0xa4, 0x06, 0x7c, 0x29, 0x3c, 0x64,
+ 0xe5, 0x82, 0x0b, 0x03, 0xd8, 0x25, 0x96, 0x8d,
+ 0x08, 0x78, 0x9b, 0x27, 0x15, 0x54, 0x76, 0x14,
+ 0xd8, 0xdd, 0x35, 0x2f, 0x71, 0xa6, 0x84, 0x8f,
+ 0x90, 0x51, 0x85, 0x01, 0x13, 0xb8, 0x90, 0x23,
+ 0x99, 0xa5, 0x47, 0x03, 0x7a, 0xfd, 0x15, 0xbf,
+ 0x63, 0xec, 0xd3, 0x0d, 0x01, 0x4d, 0x45, 0xb6,
+ 0xd2, 0xeb, 0xeb, 0xdf, 0xef, 0x60, 0xdf, 0xef,
+ 0x1f, 0x78, 0x35,
+};
+
+static unsigned char commit_data[] = {
+ 0x74, 0x72, 0x65, 0x65, 0x20, 0x64, 0x66, 0x66,
+ 0x32, 0x64, 0x61, 0x39, 0x30, 0x62, 0x32, 0x35,
+ 0x34, 0x65, 0x31, 0x62, 0x65, 0x62, 0x38, 0x38,
+ 0x39, 0x64, 0x31, 0x66, 0x31, 0x66, 0x31, 0x32,
+ 0x38, 0x38, 0x62, 0x65, 0x31, 0x38, 0x30, 0x33,
+ 0x37, 0x38, 0x32, 0x64, 0x66, 0x0a, 0x61, 0x75,
+ 0x74, 0x68, 0x6f, 0x72, 0x20, 0x41, 0x20, 0x55,
+ 0x20, 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61,
+ 0x75, 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78,
+ 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
+ 0x6d, 0x3e, 0x20, 0x31, 0x32, 0x32, 0x37, 0x38,
+ 0x31, 0x34, 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30,
+ 0x30, 0x30, 0x30, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
+ 0x69, 0x74, 0x74, 0x65, 0x72, 0x20, 0x43, 0x20,
+ 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
+ 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
+ 0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
+ 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
+ 0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
+ 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
+ 0x30, 0x0a, 0x0a, 0x41, 0x20, 0x6f, 0x6e, 0x65,
+ 0x2d, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x63, 0x6f,
+ 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x75, 0x6d,
+ 0x6d, 0x61, 0x72, 0x79, 0x0a, 0x0a, 0x54, 0x68,
+ 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x6f,
+ 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
+ 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x6d, 0x65, 0x73,
+ 0x73, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67,
+ 0x20, 0x66, 0x75, 0x72, 0x74, 0x68, 0x65, 0x72,
+ 0x20, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x6f, 0x66, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x72, 0x70,
+ 0x6f, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67,
+ 0x65, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x72, 0x6f,
+ 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d,
+ 0x6d, 0x69, 0x74, 0x2e, 0x0a, 0x0a, 0x53, 0x69,
+ 0x67, 0x6e, 0x65, 0x64, 0x2d, 0x6f, 0x66, 0x2d,
+ 0x62, 0x79, 0x3a, 0x20, 0x41, 0x20, 0x55, 0x20,
+ 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61, 0x75,
+ 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78, 0x61,
+ 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x3e, 0x0a,
+};
+
+static object_data commit = {
+ commit_bytes,
+ sizeof(commit_bytes),
+ "3d7f8a6af076c8c3f20071a8935cdbe8228594d1",
+ "commit",
+ "test-objects/3d",
+ "test-objects/3d/7f8a6af076c8c3f20071a8935cdbe8228594d1",
+ commit_data,
+ sizeof(commit_data),
+};
+
+/* tree == dff2da90b254e1beb889d1f1f1288be1803782df */
+static unsigned char tree_bytes[] = {
+ 0x78, 0x01, 0x2b, 0x29, 0x4a, 0x4d, 0x55, 0x30,
+ 0x34, 0x32, 0x63, 0x30, 0x34, 0x30, 0x30, 0x33,
+ 0x31, 0x51, 0xc8, 0xcf, 0x4b, 0x65, 0xe8, 0x16,
+ 0xae, 0x98, 0x58, 0x29, 0xff, 0x32, 0x53, 0x7d,
+ 0x6d, 0xc5, 0x33, 0x6f, 0xae, 0xb5, 0xd5, 0xf7,
+ 0x2e, 0x74, 0xdf, 0x81, 0x4a, 0x17, 0xe7, 0xe7,
+ 0xa6, 0x32, 0xfc, 0x6d, 0x31, 0xd8, 0xd3, 0xe6,
+ 0xf3, 0xe7, 0xea, 0x47, 0xbe, 0xd0, 0x09, 0x3f,
+ 0x96, 0xb8, 0x3f, 0x90, 0x9e, 0xa2, 0xfd, 0x0f,
+ 0x2a, 0x5f, 0x52, 0x9e, 0xcf, 0x50, 0x31, 0x43,
+ 0x52, 0x29, 0xd1, 0x5a, 0xeb, 0x77, 0x82, 0x2a,
+ 0x8b, 0xfe, 0xb7, 0xbd, 0xed, 0x5d, 0x07, 0x67,
+ 0xfa, 0xb5, 0x42, 0xa5, 0xab, 0x52, 0x8b, 0xf2,
+ 0x19, 0x9e, 0xcd, 0x7d, 0x34, 0x7b, 0xd3, 0xc5,
+ 0x6b, 0xce, 0xde, 0xdd, 0x9a, 0xeb, 0xca, 0xa3,
+ 0x6e, 0x1c, 0x7a, 0xd2, 0x13, 0x3c, 0x11, 0x00,
+ 0xe2, 0xaa, 0x38, 0x57,
+};
+
+static unsigned char tree_data[] = {
+ 0x31, 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x6f,
+ 0x6e, 0x65, 0x00, 0x8b, 0x13, 0x78, 0x91, 0x79,
+ 0x1f, 0xe9, 0x69, 0x27, 0xad, 0x78, 0xe6, 0x4b,
+ 0x0a, 0xad, 0x7b, 0xde, 0xd0, 0x8b, 0xdc, 0x31,
+ 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x73, 0x6f,
+ 0x6d, 0x65, 0x00, 0xfd, 0x84, 0x30, 0xbc, 0x86,
+ 0x4c, 0xfc, 0xd5, 0xf1, 0x0e, 0x55, 0x90, 0xf8,
+ 0xa4, 0x47, 0xe0, 0x1b, 0x94, 0x2b, 0xfe, 0x31,
+ 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x74, 0x77,
+ 0x6f, 0x00, 0x78, 0x98, 0x19, 0x22, 0x61, 0x3b,
+ 0x2a, 0xfb, 0x60, 0x25, 0x04, 0x2f, 0xf6, 0xbd,
+ 0x87, 0x8a, 0xc1, 0x99, 0x4e, 0x85, 0x31, 0x30,
+ 0x30, 0x36, 0x34, 0x34, 0x20, 0x7a, 0x65, 0x72,
+ 0x6f, 0x00, 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1,
+ 0xd6, 0x43, 0x4b, 0x8b, 0x29, 0xae, 0x77, 0x5a,
+ 0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91,
+};
+
+static object_data tree = {
+ tree_bytes,
+ sizeof(tree_bytes),
+ "dff2da90b254e1beb889d1f1f1288be1803782df",
+ "tree",
+ "test-objects/df",
+ "test-objects/df/f2da90b254e1beb889d1f1f1288be1803782df",
+ tree_data,
+ sizeof(tree_data),
+};
+
+/* tag == 09d373e1dfdc16b129ceec6dd649739911541e05 */
+static unsigned char tag_bytes[] = {
+ 0x78, 0x01, 0x35, 0x4e, 0xcb, 0x0a, 0xc2, 0x40,
+ 0x10, 0xf3, 0xbc, 0x5f, 0x31, 0x77, 0xa1, 0xec,
+ 0xa3, 0xed, 0x6e, 0x41, 0x44, 0xf0, 0x2c, 0x5e,
+ 0xfc, 0x81, 0xe9, 0x76, 0xb6, 0xad, 0xb4, 0xb4,
+ 0x6c, 0x07, 0xd1, 0xbf, 0x77, 0x44, 0x0d, 0x39,
+ 0x84, 0x10, 0x92, 0x30, 0xf6, 0x60, 0xbc, 0xdb,
+ 0x2d, 0xed, 0x9d, 0x22, 0x83, 0xeb, 0x7c, 0x0a,
+ 0x58, 0x63, 0xd2, 0xbe, 0x8e, 0x21, 0xba, 0x64,
+ 0xb5, 0xf6, 0x06, 0x43, 0xe3, 0xaa, 0xd8, 0xb5,
+ 0x14, 0xac, 0x0d, 0x55, 0x53, 0x76, 0x46, 0xf1,
+ 0x6b, 0x25, 0x88, 0xcb, 0x3c, 0x8f, 0xac, 0x58,
+ 0x3a, 0x1e, 0xba, 0xd0, 0x85, 0xd8, 0xd8, 0xf7,
+ 0x94, 0xe1, 0x0c, 0x57, 0xb8, 0x8c, 0xcc, 0x22,
+ 0x0f, 0xdf, 0x90, 0xc8, 0x13, 0x3d, 0x71, 0x5e,
+ 0x27, 0x2a, 0xc4, 0x39, 0x82, 0xb1, 0xd6, 0x07,
+ 0x53, 0xda, 0xc6, 0xc3, 0x5e, 0x0b, 0x94, 0xba,
+ 0x0d, 0xe3, 0x06, 0x42, 0x1e, 0x08, 0x3e, 0x95,
+ 0xbf, 0x4b, 0x69, 0xc9, 0x90, 0x69, 0x22, 0xdc,
+ 0xe8, 0xbf, 0xf2, 0x06, 0x42, 0x9a, 0x36, 0xb1,
+};
+
+static unsigned char tag_data[] = {
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x33,
+ 0x64, 0x37, 0x66, 0x38, 0x61, 0x36, 0x61, 0x66,
+ 0x30, 0x37, 0x36, 0x63, 0x38, 0x63, 0x33, 0x66,
+ 0x32, 0x30, 0x30, 0x37, 0x31, 0x61, 0x38, 0x39,
+ 0x33, 0x35, 0x63, 0x64, 0x62, 0x65, 0x38, 0x32,
+ 0x32, 0x38, 0x35, 0x39, 0x34, 0x64, 0x31, 0x0a,
+ 0x74, 0x79, 0x70, 0x65, 0x20, 0x63, 0x6f, 0x6d,
+ 0x6d, 0x69, 0x74, 0x0a, 0x74, 0x61, 0x67, 0x20,
+ 0x76, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x0a, 0x74,
+ 0x61, 0x67, 0x67, 0x65, 0x72, 0x20, 0x43, 0x20,
+ 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
+ 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
+ 0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
+ 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
+ 0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
+ 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
+ 0x30, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20,
+ 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
+ 0x61, 0x67, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65,
+ 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x76, 0x30,
+ 0x2e, 0x30, 0x2e, 0x31, 0x0a,
+};
+
+static object_data tag = {
+ tag_bytes,
+ sizeof(tag_bytes),
+ "09d373e1dfdc16b129ceec6dd649739911541e05",
+ "tag",
+ "test-objects/09",
+ "test-objects/09/d373e1dfdc16b129ceec6dd649739911541e05",
+ tag_data,
+ sizeof(tag_data),
+};
+
+/* zero == e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 */
+static unsigned char zero_bytes[] = {
+ 0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30,
+ 0x60, 0x00, 0x00, 0x09, 0xb0, 0x01, 0xf0,
+};
+
+static unsigned char zero_data[] = {
+ 0x00 /* dummy data */
+};
+
+static object_data zero = {
+ zero_bytes,
+ sizeof(zero_bytes),
+ "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
+ "blob",
+ "test-objects/e6",
+ "test-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391",
+ zero_data,
+ 0,
+};
+
+/* two == 78981922613b2afb6025042ff6bd878ac1994e85 */
+static unsigned char two_bytes[] = {
+ 0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30,
+ 0x62, 0x48, 0xe4, 0x02, 0x00, 0x0e, 0x64, 0x02,
+ 0x5d,
+};
+
+static unsigned char two_data[] = {
+ 0x61, 0x0a,
+};
+
+static object_data two = {
+ two_bytes,
+ sizeof(two_bytes),
+ "78981922613b2afb6025042ff6bd878ac1994e85",
+ "blob",
+ "test-objects/78",
+ "test-objects/78/981922613b2afb6025042ff6bd878ac1994e85",
+ two_data,
+ sizeof(two_data),
+};
+
+/* some == fd8430bc864cfcd5f10e5590f8a447e01b942bfe */
+static unsigned char some_bytes[] = {
+ 0x78, 0x01, 0x7d, 0x54, 0xc1, 0x4e, 0xe3, 0x30,
+ 0x10, 0xdd, 0x33, 0x5f, 0x31, 0xc7, 0x5d, 0x94,
+ 0xa5, 0x84, 0xd5, 0x22, 0xad, 0x7a, 0x0a, 0x15,
+ 0x85, 0x48, 0xd0, 0x56, 0x49, 0x2a, 0xd4, 0xa3,
+ 0x13, 0x4f, 0x88, 0x85, 0x63, 0x47, 0xb6, 0x43,
+ 0xc9, 0xdf, 0xef, 0x8c, 0x69, 0x17, 0x56, 0x0b,
+ 0x7b, 0xaa, 0x62, 0x7b, 0xde, 0xbc, 0xf7, 0xe6,
+ 0x4d, 0x6b, 0x6d, 0x6b, 0x48, 0xd3, 0xcb, 0x5f,
+ 0x5f, 0x66, 0xa7, 0x27, 0x70, 0x0a, 0x55, 0xa7,
+ 0x3c, 0xb4, 0x4a, 0x23, 0xf0, 0xaf, 0x43, 0x04,
+ 0x6f, 0xdb, 0xb0, 0x17, 0x0e, 0xe7, 0x30, 0xd9,
+ 0x11, 0x1a, 0x61, 0xc0, 0xa1, 0x54, 0x3e, 0x38,
+ 0x55, 0x8f, 0x81, 0x9e, 0x05, 0x10, 0x46, 0xce,
+ 0xac, 0x83, 0xde, 0x4a, 0xd5, 0x4e, 0x0c, 0x42,
+ 0x67, 0xa3, 0x91, 0xe8, 0x20, 0x74, 0x08, 0x01,
+ 0x5d, 0xef, 0xc1, 0xb6, 0xf1, 0xe3, 0x66, 0xb5,
+ 0x85, 0x1b, 0x34, 0xe8, 0x84, 0x86, 0xcd, 0x58,
+ 0x6b, 0xd5, 0xc0, 0x9d, 0x6a, 0xd0, 0x78, 0x4c,
+ 0xe0, 0x19, 0x9d, 0x57, 0xd6, 0xc0, 0x45, 0xc2,
+ 0x18, 0xc2, 0xc3, 0xc0, 0x0f, 0x7c, 0x87, 0x12,
+ 0xea, 0x29, 0x56, 0x2f, 0x99, 0x4f, 0x79, 0xe0,
+ 0x03, 0x4b, 0x4b, 0x4d, 0x44, 0xa0, 0x92, 0x33,
+ 0x2a, 0xe0, 0x9a, 0xdc, 0x80, 0x90, 0x52, 0xf1,
+ 0x11, 0x04, 0x1b, 0x4b, 0x06, 0xea, 0xae, 0x3c,
+ 0xe3, 0x7a, 0x50, 0x74, 0x4a, 0x84, 0xfe, 0xc3,
+ 0x81, 0x41, 0xf8, 0x89, 0x18, 0x43, 0x67, 0x9d,
+ 0x87, 0x47, 0xf5, 0x8c, 0x51, 0xf6, 0x68, 0xb4,
+ 0xea, 0x55, 0x20, 0x2a, 0x6f, 0x80, 0xdc, 0x42,
+ 0x2b, 0xf3, 0x14, 0x2b, 0x1a, 0xdb, 0x0f, 0xe4,
+ 0x9a, 0x64, 0x84, 0xa3, 0x90, 0xa8, 0xf9, 0x8f,
+ 0x9d, 0x86, 0x9e, 0xd3, 0xab, 0x5a, 0x99, 0xc8,
+ 0xd9, 0xc3, 0x5e, 0x85, 0x0e, 0x2c, 0xb5, 0x73,
+ 0x30, 0x38, 0xfb, 0xe8, 0x44, 0xef, 0x5f, 0x95,
+ 0x1b, 0xc9, 0xd0, 0xef, 0x3c, 0x26, 0x32, 0x1e,
+ 0xff, 0x2d, 0xb6, 0x23, 0x7b, 0x3f, 0xd1, 0x3c,
+ 0x78, 0x1a, 0x0d, 0xcb, 0xe6, 0xf6, 0xd4, 0x44,
+ 0x99, 0x47, 0x1a, 0x9e, 0xed, 0x23, 0xb5, 0x91,
+ 0x6a, 0xdf, 0x53, 0x39, 0x03, 0xf8, 0x5a, 0xb1,
+ 0x0f, 0x1f, 0xce, 0x81, 0x11, 0xde, 0x01, 0x7a,
+ 0x90, 0x16, 0xc4, 0x30, 0xe8, 0x89, 0xed, 0x7b,
+ 0x65, 0x4b, 0xd7, 0x03, 0x36, 0xc1, 0xcf, 0xa1,
+ 0xa5, 0xb1, 0xe3, 0x8b, 0xe8, 0x07, 0x4d, 0xf3,
+ 0x23, 0x25, 0x13, 0x35, 0x27, 0xf5, 0x8c, 0x11,
+ 0xd3, 0xa0, 0x9a, 0xa8, 0xf5, 0x38, 0x7d, 0xce,
+ 0x55, 0xc2, 0x71, 0x79, 0x13, 0xc7, 0xa3, 0xda,
+ 0x77, 0x68, 0xc0, 0xd8, 0x10, 0xdd, 0x24, 0x8b,
+ 0x15, 0x59, 0xc5, 0x10, 0xe2, 0x20, 0x99, 0x8e,
+ 0xf0, 0x05, 0x9b, 0x31, 0x88, 0x5a, 0xe3, 0xd9,
+ 0x37, 0xba, 0xe2, 0xdb, 0xbf, 0x92, 0xfa, 0x66,
+ 0x16, 0x97, 0x47, 0xd9, 0x9d, 0x1d, 0x28, 0x7c,
+ 0x9d, 0x08, 0x1c, 0xc7, 0xbd, 0xd2, 0x1a, 0x6a,
+ 0x04, 0xf2, 0xa2, 0x1d, 0x75, 0x02, 0x14, 0x5d,
+ 0xc6, 0x78, 0xc8, 0xab, 0xdb, 0xf5, 0xb6, 0x82,
+ 0x6c, 0xb5, 0x83, 0x87, 0xac, 0x28, 0xb2, 0x55,
+ 0xb5, 0x9b, 0xc7, 0xc1, 0xb0, 0xb7, 0xf8, 0x4c,
+ 0xbc, 0x38, 0x0e, 0x8a, 0x04, 0x2a, 0x62, 0x41,
+ 0x6b, 0xe0, 0x84, 0x09, 0x13, 0xe9, 0xe1, 0xea,
+ 0xfb, 0xeb, 0x62, 0x71, 0x4b, 0x25, 0xd9, 0x55,
+ 0x7e, 0x97, 0x57, 0x3b, 0x20, 0x33, 0x96, 0x79,
+ 0xb5, 0xba, 0x2e, 0x4b, 0x58, 0xae, 0x0b, 0xc8,
+ 0x60, 0x93, 0x15, 0x55, 0xbe, 0xd8, 0xde, 0x65,
+ 0x05, 0x6c, 0xb6, 0xc5, 0x66, 0x5d, 0x5e, 0x93,
+ 0xf7, 0x25, 0x65, 0x98, 0x41, 0x29, 0x86, 0x0c,
+ 0xf2, 0xf1, 0x14, 0xa2, 0xb3, 0xbd, 0x75, 0x08,
+ 0x12, 0x83, 0x50, 0xda, 0x1f, 0x23, 0xbe, 0xa3,
+ 0x1d, 0xf4, 0x9d, 0x1d, 0xb5, 0x84, 0x4e, 0x50,
+ 0x38, 0x1d, 0x36, 0x48, 0x21, 0x95, 0xd1, 0xac,
+ 0x81, 0x99, 0x1d, 0xc1, 0x3f, 0x41, 0xe6, 0x9e,
+ 0x42, 0x5b, 0x0a, 0x48, 0xcc, 0x5f, 0xe0, 0x7d,
+ 0x3f, 0xc4, 0x6f, 0x0e, 0xfe, 0xc0, 0x2d, 0xfe,
+ 0x01, 0x2c, 0xd6, 0x9b, 0x5d, 0xbe, 0xba, 0x21,
+ 0xca, 0x79, 0xcb, 0xe3, 0x49, 0x60, 0xef, 0x68,
+ 0x05, 0x28, 0x9b, 0x8c, 0xc1, 0x12, 0x3e, 0xdb,
+ 0xc7, 0x04, 0x7e, 0xa6, 0x74, 0x29, 0xcc, 0x13,
+ 0xed, 0x07, 0x94, 0x81, 0xd6, 0x96, 0xaa, 0x97,
+ 0xaa, 0xa5, 0xc0, 0x2f, 0xb5, 0xb5, 0x2e, 0xe6,
+ 0xfc, 0xca, 0xfa, 0x60, 0x4d, 0x02, 0xf7, 0x19,
+ 0x9c, 0x5f, 0xa4, 0xe9, 0xf9, 0xf7, 0xf4, 0xc7,
+ 0x79, 0x9a, 0xc0, 0xb6, 0xcc, 0x58, 0xec, 0xec,
+ 0xe4, 0x37, 0x22, 0xfa, 0x8b, 0x53,
+};
+
+static unsigned char some_data[] = {
+ 0x2f, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x54, 0x68,
+ 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20,
+ 0x69, 0x73, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20,
+ 0x73, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
+ 0x3b, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61,
+ 0x6e, 0x20, 0x72, 0x65, 0x64, 0x69, 0x73, 0x74,
+ 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x69,
+ 0x74, 0x20, 0x61, 0x6e, 0x64, 0x2f, 0x6f, 0x72,
+ 0x20, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0a,
+ 0x20, 0x2a, 0x20, 0x69, 0x74, 0x20, 0x75, 0x6e,
+ 0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x74, 0x65, 0x72, 0x6d, 0x73, 0x20, 0x6f, 0x66,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55,
+ 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
+ 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
+ 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2c,
+ 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
+ 0x20, 0x32, 0x2c, 0x0a, 0x20, 0x2a, 0x20, 0x61,
+ 0x73, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73,
+ 0x68, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20,
+ 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
+ 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x2a, 0x0a,
+ 0x20, 0x2a, 0x20, 0x49, 0x6e, 0x20, 0x61, 0x64,
+ 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
+ 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x65,
+ 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e,
+ 0x73, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x47, 0x4e, 0x55, 0x20, 0x47, 0x65, 0x6e,
+ 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62,
+ 0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69, 0x63, 0x65,
+ 0x6e, 0x73, 0x65, 0x2c, 0x0a, 0x20, 0x2a, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x61, 0x75, 0x74, 0x68,
+ 0x6f, 0x72, 0x73, 0x20, 0x67, 0x69, 0x76, 0x65,
+ 0x20, 0x79, 0x6f, 0x75, 0x20, 0x75, 0x6e, 0x6c,
+ 0x69, 0x6d, 0x69, 0x74, 0x65, 0x64, 0x20, 0x70,
+ 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
+ 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x69, 0x6e,
+ 0x6b, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
+ 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x0a, 0x20,
+ 0x2a, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,
+ 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69,
+ 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x69,
+ 0x6e, 0x74, 0x6f, 0x20, 0x63, 0x6f, 0x6d, 0x62,
+ 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
+ 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6f, 0x74,
+ 0x68, 0x65, 0x72, 0x20, 0x70, 0x72, 0x6f, 0x67,
+ 0x72, 0x61, 0x6d, 0x73, 0x2c, 0x0a, 0x20, 0x2a,
+ 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20,
+ 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
+ 0x74, 0x65, 0x20, 0x74, 0x68, 0x6f, 0x73, 0x65,
+ 0x20, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x77, 0x69,
+ 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x61, 0x6e,
+ 0x79, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x2a,
+ 0x20, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x20,
+ 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20,
+ 0x74, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c,
+ 0x65, 0x2e, 0x20, 0x20, 0x28, 0x54, 0x68, 0x65,
+ 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
+ 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
+ 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x0a,
+ 0x20, 0x2a, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72,
+ 0x69, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20,
+ 0x64, 0x6f, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x79,
+ 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x74, 0x68, 0x65,
+ 0x72, 0x20, 0x72, 0x65, 0x73, 0x70, 0x65, 0x63,
+ 0x74, 0x73, 0x3b, 0x20, 0x66, 0x6f, 0x72, 0x20,
+ 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2c,
+ 0x20, 0x74, 0x68, 0x65, 0x79, 0x20, 0x63, 0x6f,
+ 0x76, 0x65, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x6d,
+ 0x6f, 0x64, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2c,
+ 0x20, 0x61, 0x6e, 0x64, 0x20, 0x64, 0x69, 0x73,
+ 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f,
+ 0x6e, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x6e,
+ 0x6f, 0x74, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x65,
+ 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x0a, 0x20,
+ 0x2a, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x62,
+ 0x69, 0x6e, 0x65, 0x64, 0x20, 0x65, 0x78, 0x65,
+ 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e,
+ 0x29, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20,
+ 0x54, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c,
+ 0x65, 0x20, 0x69, 0x73, 0x20, 0x64, 0x69, 0x73,
+ 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64,
+ 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x68, 0x6f, 0x70, 0x65, 0x20, 0x74, 0x68, 0x61,
+ 0x74, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x6c,
+ 0x6c, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65,
+ 0x66, 0x75, 0x6c, 0x2c, 0x20, 0x62, 0x75, 0x74,
+ 0x0a, 0x20, 0x2a, 0x20, 0x57, 0x49, 0x54, 0x48,
+ 0x4f, 0x55, 0x54, 0x20, 0x41, 0x4e, 0x59, 0x20,
+ 0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x59,
+ 0x3b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75,
+ 0x74, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x69,
+ 0x65, 0x64, 0x20, 0x77, 0x61, 0x72, 0x72, 0x61,
+ 0x6e, 0x74, 0x79, 0x20, 0x6f, 0x66, 0x0a, 0x20,
+ 0x2a, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41,
+ 0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54,
+ 0x59, 0x20, 0x6f, 0x72, 0x20, 0x46, 0x49, 0x54,
+ 0x4e, 0x45, 0x53, 0x53, 0x20, 0x46, 0x4f, 0x52,
+ 0x20, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49,
+ 0x43, 0x55, 0x4c, 0x41, 0x52, 0x20, 0x50, 0x55,
+ 0x52, 0x50, 0x4f, 0x53, 0x45, 0x2e, 0x20, 0x20,
+ 0x53, 0x65, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x47, 0x4e, 0x55, 0x0a, 0x20, 0x2a, 0x20, 0x47,
+ 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50,
+ 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69,
+ 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x66, 0x6f,
+ 0x72, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x64,
+ 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x0a,
+ 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x59, 0x6f,
+ 0x75, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64,
+ 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x72, 0x65,
+ 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x20, 0x61,
+ 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55,
+ 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
+ 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
+ 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x0a,
+ 0x20, 0x2a, 0x20, 0x61, 0x6c, 0x6f, 0x6e, 0x67,
+ 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68,
+ 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72,
+ 0x61, 0x6d, 0x3b, 0x20, 0x73, 0x65, 0x65, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65,
+ 0x20, 0x43, 0x4f, 0x50, 0x59, 0x49, 0x4e, 0x47,
+ 0x2e, 0x20, 0x20, 0x49, 0x66, 0x20, 0x6e, 0x6f,
+ 0x74, 0x2c, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65,
+ 0x20, 0x74, 0x6f, 0x0a, 0x20, 0x2a, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20,
+ 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
+ 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x35, 0x31, 0x20,
+ 0x46, 0x72, 0x61, 0x6e, 0x6b, 0x6c, 0x69, 0x6e,
+ 0x20, 0x53, 0x74, 0x72, 0x65, 0x65, 0x74, 0x2c,
+ 0x20, 0x46, 0x69, 0x66, 0x74, 0x68, 0x20, 0x46,
+ 0x6c, 0x6f, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x2a,
+ 0x20, 0x42, 0x6f, 0x73, 0x74, 0x6f, 0x6e, 0x2c,
+ 0x20, 0x4d, 0x41, 0x20, 0x30, 0x32, 0x31, 0x31,
+ 0x30, 0x2d, 0x31, 0x33, 0x30, 0x31, 0x2c, 0x20,
+ 0x55, 0x53, 0x41, 0x2e, 0x0a, 0x20, 0x2a, 0x2f,
+ 0x0a,
+};
+
+static object_data some = {
+ some_bytes,
+ sizeof(some_bytes),
+ "fd8430bc864cfcd5f10e5590f8a447e01b942bfe",
+ "blob",
+ "test-objects/fd",
+ "test-objects/fd/8430bc864cfcd5f10e5590f8a447e01b942bfe",
+ some_data,
+ sizeof(some_data),
+};
diff --git a/tests-clay/odb/pack_data.h b/tests-clay/odb/pack_data.h
new file mode 100644
index 0000000..e6371be
--- /dev/null
+++ b/tests-clay/odb/pack_data.h
@@ -0,0 +1,151 @@
+
+static const char *packed_objects[] = {
+ "0266163a49e280c4f5ed1e08facd36a2bd716bcf",
+ "53fc32d17276939fc79ed05badaef2db09990016",
+ "6336846bd5c88d32f93ae57d846683e61ab5c530",
+ "6dcf9bf7541ee10456529833502442f385010c3d",
+ "bed08a0b30b72a9d4aed7f1af8c8ca124e8d64b9",
+ "e90810b8df3e80c413d903f631643c716887138d",
+ "fc3c3a2083e9f6f89e6bd53e9420e70d1e357c9b",
+ "fc58168adf502d0c0ef614c3111a7038fc8c09c8",
+ "fd0ec0333948dfe23265ac46be0205a436a8c3a5",
+ "fd8430bc864cfcd5f10e5590f8a447e01b942bfe",
+ "fd899f45951c15c1c5f7c34b1c864e91bd6556c6",
+ "fda23b974899e7e1f938619099280bfda13bdca9",
+ "fdbec189efb657c8325962b494875987881a356b",
+ "fe1ca6bd22b5d8353ce6c2f3aba80805c438a7a5",
+ "fe3a6a42c87ff1239370c741a265f3997add87c1",
+ "deb106bfd2d36ecf9f0079224c12022201a39ad1",
+ "dec93efc79e60f2680de3e666755d335967eec30",
+ "def425bf8568b9c1e20879bf5be6f9c52b7361c4",
+ "df48000ac4f48570054e3a71a81916357997b680",
+ "dfae6ed8f6dd8acc3b40a31811ea316239223559",
+ "dff79e27d3d2cdc09790ded80fe2ea8ff5d61034",
+ "e00e46abe4c542e17c8bc83d72cf5be8018d7b0e",
+ "e01b107b4f77f8f98645adac0206a504f2d29d7c",
+ "e032d863f512c47b479bd984f8b6c8061f66b7d4",
+ "e044baa468a1c74f9f9da36805445f6888358b49",
+ "e04529998989ba8ae3419538dd57969af819b241",
+ "e0637ddfbea67c8d7f557c709e095af8906e9176",
+ "e0743ad4031231e71700abdc6fdbe94f189d20e5",
+ "cf33ac7a3d8b2b8f6bb266518aadbf59de397608",
+ "cf5f7235b9c9689b133f6ea12015720b411329bd",
+ "cf6cccf1297284833a9a03138a1f5738fa1c6c94",
+ "cf7992bde17ce7a79cab5f0c1fcbe8a0108721ed",
+ "cfe3a027ab12506d4144ee8a35669ae8fc4b7ab1",
+ "cfe96f31dfad7bab49977aa1df7302f7fafcb025",
+ "cff54d138945ef4de384e9d2759291d0c13ea90a",
+ "d01f7573ac34c2f502bd1cf18cde73480c741151",
+ "d03f567593f346a1ca96a57f8191def098d126e3",
+ "d047b47aadf88501238f36f5c17dd0a50dc62087",
+ "d0a0d63086fae3b0682af7261df21f7d0f7f066d",
+ "d0a44bd6ed0be21b725a96c0891bbc79bc1a540c",
+ "d0d7e736e536a41bcb885005f8bf258c61cad682",
+ "d0e7959d4b95ffec6198df6f5a7ae259b23a5f50",
+ "bf2fe2acca17d13356ce802ba9dc8343f710dfb7",
+ "bf55f407d6d9418e51f42ea7a3a6aadf17388349",
+ "bf92206f8b633b88a66dca4a911777630b06fbac",
+ "bfaf8c42eb8842abe206179fee864cfba87e3ca9",
+ "bfe05675d4e8f6b59d50932add8790f1a06b10ee",
+ "bff8618112330763327cfa6ce6e914db84f51ddf",
+ "bff873e9853ed99fed52c25f7ad29f78b27dcec2",
+ "c01c3fae7251098d7af1b459bcd0786e81d4616d",
+ "c0220fca67f48b8a5d4163d53b1486224be3a198",
+ "c02d0b160b82ee72469c269f13de4c26a7ea09cb",
+ "c059510ad1b45ab58390e042d7dee1ac46703854",
+ "c07204a1897aeeaa3c248d29dbfa9b033baf9755",
+ "c073337a4dd7276931b4b3fdbc3f0040e9441793",
+ "0fd7e4bfba5b3a82be88d1057757ca8b2c5e6d26",
+ "100746511cc45c9f1ad6721c4ef5be49222fee4d",
+ "1088490171d9b984d68b8b9be9ca003f4eafff59",
+ "1093c8ff4cb78fcf5f79dbbeedcb6e824bd4e253",
+ "10aa3fa72afab7ee31e116ae06442fe0f7b79df2",
+ "10b759e734e8299aa0dca08be935d95d886127b6",
+ "111d5ccf0bb010c4e8d7af3eedfa12ef4c5e265b",
+ "11261fbff21758444d426356ff6327ee01e90752",
+ "112998d425717bb922ce74e8f6f0f831d8dc4510",
+ "2ef4e5d838b6507bd61d457cf6466662b791c5c0",
+ "2ef4faa0f82efa00eeac6cae9e8b2abccc8566ee",
+ "2f06098183b0d7be350acbe39cdbaccff2df0c4a",
+ "2f1c5d509ac5bffb3c62f710a1c2c542e126dfd1",
+ "2f205b20fc16423c42b3ba51b2ea78d7b9ff3578",
+ "2f9b6b6e3d9250ba09360734aa47973a993b59d1",
+ "30c62a2d5a8d644f1311d4f7fe3f6a788e4c8188",
+ "31438e245492d85fd6da4d1406eba0fbde8332a4",
+ "3184a3abdfea231992254929ff4e275898e5bbf6",
+ "3188ffdbb3a3d52e0f78f30c484533899224436e",
+ "32581d0093429770d044a60eb0e9cc0462bedb13",
+ "32679a9544d83e5403202c4d5efb61ad02492847",
+ "4e7e9f60b7e2049b7f5697daf133161a18ef688f",
+ "4e8cda27ddc8be7db875ceb0f360c37734724c6d",
+ "4ea481c61c59ab55169b7cbaae536ad50b49d6f0",
+ "4f0adcd0e61eabe06fe32be66b16559537124b7a",
+ "4f1355c91100d12f9e7202f91b245df0c110867c",
+ "4f6eadeb08b9d0d1e8b1b3eac8a34940adf29a2d",
+ "4f9339df943c53117a5fc8e86e2f38716ff3a668",
+ "4fc3874b118752e40de556b1c3e7b4a9f1737d00",
+ "4ff1dd0992dd6baafdb5e166be6f9f23b59bdf87",
+ "5018a35e0b7e2eec7ce5050baf9c7343f3f74164",
+ "50298f44a45eda3a29dae82dbe911b5aa176ac07",
+ "502acd164fb115768d723144da2e7bb5a24891bb",
+ "50330c02bd4fd95c9db1fcf2f97f4218e42b7226",
+ "5052bf355d9f8c52446561a39733a8767bf31e37",
+ "6f2cd729ae42988c1dd43588d3a6661ba48ad7a0",
+ "6f4e2c42d9138bfbf3e0f908f1308828cc6f2178",
+ "6f6a17db05a83620cef4572761831c20a70ba9b9",
+ "6faad60901e36538634f0d8b8ff3f21f83503c71",
+ "6fc72e46de3df0c3842dab302bbacf697a63abab",
+ "6fdccd49f442a7204399ca9b418f017322dbded8",
+ "6fe7568fc3861c334cb008fd85d57d9647249ef5",
+ "700f55d91d7b55665594676a4bada1f1457a0598",
+ "702bd70595a7b19afc48a1f784a6505be68469d4",
+ "7033f9ee0e52b08cb5679cd49b7b7999eaf9eaf8",
+ "70957110ce446c4e250f865760fb3da513cdcc92",
+ "8ec696a4734f16479d091bc70574d23dd9fe7443",
+ "8ed341c55ed4d6f4cdc8bf4f0ca18a08c93f6962",
+ "8edc2805f1f11b63e44bf81f4557f8b473612b69",
+ "8ef9060a954118a698fc10e20acdc430566a100f",
+ "8f0c4b543f4bb6eb1518ecfc3d4699e43108d393",
+ "8fac94df3035405c2e60b3799153ce7c428af6b9",
+ "904c0ac12b23548de524adae712241b423d765a3",
+ "90bbaa9a809c3a768d873a9cc7d52b4f3bf3d1b9",
+ "90d4d2f0fc362beabbbf76b4ffda0828229c198d",
+ "90f9ff6755330b685feff6c3d81782ee3592ab04",
+ "91822c50ebe4f9bf5bbb8308ecf9f6557062775c",
+ "91d973263a55708fa8255867b3202d81ef9c2868",
+ "af292c99c6148d772af3315a1c74e83330e7ead7",
+ "af3b99d5be330dbbce0b9250c3a5fb05911908cc",
+ "af55d0cdeb280af2db8697e5afa506e081012719",
+ "af795e498d411142ddb073e8ca2c5447c3295a4c",
+ "afadc73a392f8cc8e2cc77dd62a7433dd3bafa8c",
+ "affd84ed8ec7ce67612fe3c12a80f8164b101f6a",
+ "b0941f9c70ffe67f0387a827b338e64ecf3190f0",
+ "b0a3077f9ef6e093f8d9869bdb0c07095bd722cb",
+ "b0a8568a7614806378a54db5706ee3b06ae58693",
+ "b0fb7372f242233d1d35ce7d8e74d3990cbc5841",
+ "b10489944b9ead17427551759d180d10203e06ba",
+ "b196a807b323f2748ffc6b1d42cd0812d04c9a40",
+ "b1bb1d888f0c5e19278536d49fa77db035fac7ae"
+};
+
+static const char *loose_objects[] = {
+ "45b983be36b73c0788dc9cbcb76cbb80fc7bb057",
+ "a8233120f6ad708f843d861ce2b7228ec4e3dec6",
+ "fd093bff70906175335656e6ce6ae05783708765",
+ "c47800c7266a2be04c571c04d5a6614691ea99bd",
+ "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd",
+ "8496071c1b46c854b31185ea97743be6a8774479",
+ "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
+ "814889a078c031f61ed08ab5fa863aea9314344d",
+ "5b5b025afb0b4c913b4c338a42934a3863bf3644",
+ "1385f264afb75a56a5bec74243be9b367ba4ca08",
+ "f60079018b664e4e79329a7ef9559c8d9e0378d1",
+ "be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
+ "75057dd4114e74cca1d750d0aee1647c903cb60a",
+ "fa49b077972391ad58037050f2a75f74e3671e92",
+ "9fd738e8f7967c078dceed8190330fc8648ee56a",
+ "1810dff58d8a660512d4832e740f692884338ccd",
+ "181037049a54a1eb5fab404658a3a250b44335d7",
+ "a4a7dce85cf63874e984719f4fdd239f5145052f",
+ "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"
+};
diff --git a/tests-clay/odb/packed.c b/tests-clay/odb/packed.c
new file mode 100644
index 0000000..e50bca6
--- /dev/null
+++ b/tests-clay/odb/packed.c
@@ -0,0 +1,77 @@
+#include "clay_libgit2.h"
+#include "odb.h"
+#include "pack_data.h"
+
+static git_odb *_odb;
+
+void test_odb_packed__initialize(void)
+{
+ cl_git_pass(git_odb_open(&_odb, cl_fixture("testrepo.git/objects")));
+}
+
+void test_odb_packed__cleanup(void)
+{
+ git_odb_free(_odb);
+}
+
+void test_odb_packed__mass_read(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
+ git_oid id;
+ git_odb_object *obj;
+
+ cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
+ cl_assert(git_odb_exists(_odb, &id) == 1);
+ cl_git_pass(git_odb_read(&obj, _odb, &id));
+
+ git_odb_object_close(obj);
+ }
+}
+
+void test_odb_packed__read_header_0(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
+ git_oid id;
+ git_odb_object *obj;
+ size_t len;
+ git_otype type;
+
+ cl_git_pass(git_oid_fromstr(&id, packed_objects[i]));
+
+ cl_git_pass(git_odb_read(&obj, _odb, &id));
+ cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
+
+ cl_assert(obj->raw.len == len);
+ cl_assert(obj->raw.type == type);
+
+ git_odb_object_close(obj);
+ }
+}
+
+void test_odb_packed__read_header_1(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(loose_objects); ++i) {
+ git_oid id;
+ git_odb_object *obj;
+ size_t len;
+ git_otype type;
+
+ cl_git_pass(git_oid_fromstr(&id, loose_objects[i]));
+
+ cl_assert(git_odb_exists(_odb, &id) == 1);
+
+ cl_git_pass(git_odb_read(&obj, _odb, &id));
+ cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
+
+ cl_assert(obj->raw.len == len);
+ cl_assert(obj->raw.type == type);
+
+ git_odb_object_close(obj);
+ }
+}
diff --git a/tests-clay/odb/sorting.c b/tests-clay/odb/sorting.c
new file mode 100644
index 0000000..7796607
--- /dev/null
+++ b/tests-clay/odb/sorting.c
@@ -0,0 +1,71 @@
+#include "clay_libgit2.h"
+#include "git2/odb_backend.h"
+#include "odb.h"
+
+typedef struct {
+ git_odb_backend base;
+ int position;
+} fake_backend;
+
+static git_odb_backend *new_backend(int position)
+{
+ fake_backend *b;
+
+ b = git__malloc(sizeof(fake_backend));
+ if (b == NULL)
+ return NULL;
+
+ memset(b, 0x0, sizeof(fake_backend));
+ b->position = position;
+ return (git_odb_backend *)b;
+}
+
+static void check_backend_sorting(git_odb *odb)
+{
+ unsigned int i;
+
+ for (i = 0; i < odb->backends.length; ++i) {
+ fake_backend *internal =
+ *((fake_backend **)git_vector_get(&odb->backends, i));
+
+ cl_assert(internal != NULL);
+ cl_assert(internal->position == (int)i);
+ }
+}
+
+static git_odb *_odb;
+
+void test_odb_sorting__initialize(void)
+{
+ cl_git_pass(git_odb_new(&_odb));
+}
+
+void test_odb_sorting__cleanup(void)
+{
+ git_odb_free(_odb);
+ _odb = NULL;
+}
+
+void test_odb_sorting__basic_backends_sorting(void)
+{
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(0), 5));
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(2), 3));
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(1), 4));
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(3), 1));
+
+ check_backend_sorting(_odb);
+}
+
+void test_odb_sorting__alternate_backends_sorting(void)
+{
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(0), 5));
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(2), 3));
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(1), 4));
+ cl_git_pass(git_odb_add_backend(_odb, new_backend(3), 1));
+ cl_git_pass(git_odb_add_alternate(_odb, new_backend(4), 5));
+ cl_git_pass(git_odb_add_alternate(_odb, new_backend(6), 3));
+ cl_git_pass(git_odb_add_alternate(_odb, new_backend(5), 4));
+ cl_git_pass(git_odb_add_alternate(_odb, new_backend(7), 1));
+
+ check_backend_sorting(_odb);
+}
diff --git a/tests-clay/repo/getters.c b/tests-clay/repo/getters.c
new file mode 100644
index 0000000..3acdb75
--- /dev/null
+++ b/tests-clay/repo/getters.c
@@ -0,0 +1,68 @@
+#include "clay_libgit2.h"
+
+void test_repo_getters__initialize(void)
+{
+ cl_fixture_sandbox("testrepo.git");
+}
+
+void test_repo_getters__cleanup(void)
+{
+ cl_fixture_cleanup("testrepo.git");
+}
+
+void test_repo_getters__empty(void)
+{
+ git_repository *repo_empty, *repo_normal;
+
+ cl_git_pass(git_repository_open(&repo_normal, cl_fixture("testrepo.git")));
+ cl_assert(git_repository_is_empty(repo_normal) == 0);
+ git_repository_free(repo_normal);
+
+ cl_git_pass(git_repository_open(&repo_empty, cl_fixture("empty_bare.git")));
+ cl_assert(git_repository_is_empty(repo_empty) == 1);
+ git_repository_free(repo_empty);
+}
+
+void test_repo_getters__head_detached(void)
+{
+ git_repository *repo;
+ git_reference *ref;
+ git_oid oid;
+
+ cl_git_pass(git_repository_open(&repo, "testrepo.git"));
+
+ cl_assert(git_repository_head_detached(repo) == 0);
+
+ /* detach the HEAD */
+ git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd");
+ cl_git_pass(git_reference_create_oid(&ref, repo, "HEAD", &oid, 1));
+ cl_assert(git_repository_head_detached(repo) == 1);
+
+ /* take the reop back to it's original state */
+ cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
+ cl_assert(git_repository_head_detached(repo) == 0);
+
+ git_reference_free(ref);
+ git_repository_free(repo);
+}
+
+void test_repo_getters__head_orphan(void)
+{
+ git_repository *repo;
+ git_reference *ref;
+
+ cl_git_pass(git_repository_open(&repo, "testrepo.git"));
+
+ cl_assert(git_repository_head_orphan(repo) == 0);
+
+ /* orphan HEAD */
+ cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/orphan", 1));
+ cl_assert(git_repository_head_orphan(repo) == 1);
+
+ /* take the reop back to it's original state */
+ cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
+ cl_assert(git_repository_head_orphan(repo) == 0);
+
+ git_reference_free(ref);
+ git_repository_free(repo);
+}
diff --git a/tests-clay/repo/init.c b/tests-clay/repo/init.c
new file mode 100644
index 0000000..95cd704
--- /dev/null
+++ b/tests-clay/repo/init.c
@@ -0,0 +1,104 @@
+#include "clay_libgit2.h"
+#include "fileops.h"
+
+enum repo_mode {
+ STANDARD_REPOSITORY = 0,
+ BARE_REPOSITORY = 1
+};
+
+static git_repository *_repo;
+
+void test_repo_init__initialize(void)
+{
+ _repo = NULL;
+}
+
+static void cleanup_repository(void *path)
+{
+ git_repository_free(_repo);
+ cl_fixture_cleanup((const char *)path);
+}
+
+static void ensure_repository_init(
+ const char *working_directory,
+ int is_bare,
+ const char *expected_path_repository,
+ const char *expected_working_directory)
+{
+ const char *workdir;
+
+ cl_git_pass(git_repository_init(&_repo, working_directory, is_bare));
+
+ workdir = git_repository_workdir(_repo);
+ if (workdir != NULL || expected_working_directory != NULL) {
+ cl_assert(
+ git__suffixcmp(workdir, expected_working_directory) == 0
+ );
+ }
+
+ cl_assert(
+ git__suffixcmp(git_repository_path(_repo), expected_path_repository) == 0
+ );
+
+ cl_assert(git_repository_is_bare(_repo) == is_bare);
+
+#ifdef GIT_WIN32
+ if (!is_bare) {
+ cl_assert((GetFileAttributes(_repo->path_repository) & FILE_ATTRIBUTE_HIDDEN) != 0);
+ }
+#endif
+
+ cl_assert(git_repository_is_empty(_repo));
+}
+
+void test_repo_init__standard_repo(void)
+{
+ cl_set_cleanup(&cleanup_repository, "testrepo");
+ ensure_repository_init("testrepo/", 0, "testrepo/.git/", "testrepo/");
+}
+
+void test_repo_init__standard_repo_noslash(void)
+{
+ cl_set_cleanup(&cleanup_repository, "testrepo");
+ ensure_repository_init("testrepo", 0, "testrepo/.git/", "testrepo/");
+}
+
+void test_repo_init__bare_repo(void)
+{
+ cl_set_cleanup(&cleanup_repository, "testrepo.git");
+ ensure_repository_init("testrepo.git/", 1, "testrepo.git/", NULL);
+}
+
+void test_repo_init__bare_repo_noslash(void)
+{
+ cl_set_cleanup(&cleanup_repository, "testrepo.git");
+ ensure_repository_init("testrepo.git", 1, "testrepo.git/", NULL);
+}
+
+#if 0
+BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory")
+ char path_repository[GIT_PATH_MAX];
+ char current_workdir[GIT_PATH_MAX];
+ const mode_t mode = 0777;
+ git_repository* repo;
+
+ must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
+
+ git_path_join(path_repository, TEMP_REPO_FOLDER, "a/b/c/");
+ must_pass(git_futils_mkdir_r(path_repository, mode));
+
+ must_pass(chdir(path_repository));
+
+ must_pass(git_repository_init(&repo, "../d/e.git", 1));
+ must_pass(git__suffixcmp(repo->path_repository, "/a/b/d/e.git/"));
+
+ git_repository_free(repo);
+
+ must_pass(git_repository_open(&repo, "../d/e.git"));
+
+ git_repository_free(repo);
+
+ must_pass(chdir(current_workdir));
+ must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
+END_TEST
+#endif
diff --git a/tests-clay/repo/open.c b/tests-clay/repo/open.c
new file mode 100644
index 0000000..235af14
--- /dev/null
+++ b/tests-clay/repo/open.c
@@ -0,0 +1,54 @@
+#include "clay_libgit2.h"
+#include "posix.h"
+
+void test_repo_open__bare_empty_repo(void)
+{
+ git_repository *repo;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("empty_bare.git")));
+ cl_assert(git_repository_path(repo) != NULL);
+ cl_assert(git_repository_workdir(repo) == NULL);
+
+ git_repository_free(repo);
+}
+
+void test_repo_open__standard_empty_repo(void)
+{
+ git_repository *repo;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("empty_standard_repo/.gitted")));
+ cl_assert(git_repository_path(repo) != NULL);
+ cl_assert(git_repository_workdir(repo) != NULL);
+
+ git_repository_free(repo);
+}
+
+/* TODO TODO */
+#if 0
+BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of the current working directory")
+ char new_current_workdir[GIT_PATH_MAX];
+ char current_workdir[GIT_PATH_MAX];
+ char path_repository[GIT_PATH_MAX];
+
+ const mode_t mode = 0777;
+ git_repository* repo;
+
+ /* Setup the repository to open */
+ must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
+ strcpy(path_repository, current_workdir);
+ git_path_join_n(path_repository, 3, path_repository, TEMP_REPO_FOLDER, "a/d/e.git");
+ must_pass(copydir_recurs(REPOSITORY_FOLDER, path_repository));
+
+ /* Change the current working directory */
+ git_path_join(new_current_workdir, TEMP_REPO_FOLDER, "a/b/c/");
+ must_pass(git_futils_mkdir_r(new_current_workdir, mode));
+ must_pass(chdir(new_current_workdir));
+
+ must_pass(git_repository_open(&repo, "../../d/e.git"));
+
+ git_repository_free(repo);
+
+ must_pass(chdir(current_workdir));
+ must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
+END_TEST
+#endif
diff --git a/tests/t02-data.h b/tests/t02-data.h
deleted file mode 100644
index 705a2d7..0000000
--- a/tests/t02-data.h
+++ /dev/null
@@ -1,515 +0,0 @@
-
-static char *odb_dir = "test-objects";
-
-/* one == 8b137891791fe96927ad78e64b0aad7bded08bdc */
-static unsigned char one_bytes[] = {
- 0x31, 0x78, 0x9c, 0xe3, 0x02, 0x00, 0x00, 0x0b,
- 0x00, 0x0b,
-};
-
-static unsigned char one_data[] = {
- 0x0a,
-};
-
-static object_data one = {
- one_bytes,
- sizeof(one_bytes),
- "8b137891791fe96927ad78e64b0aad7bded08bdc",
- "blob",
- "test-objects/8b",
- "test-objects/8b/137891791fe96927ad78e64b0aad7bded08bdc",
- one_data,
- sizeof(one_data),
-};
-
-
-/* commit == 3d7f8a6af076c8c3f20071a8935cdbe8228594d1 */
-static unsigned char commit_bytes[] = {
- 0x78, 0x01, 0x85, 0x50, 0xc1, 0x6a, 0xc3, 0x30,
- 0x0c, 0xdd, 0xd9, 0x5f, 0xa1, 0xfb, 0x96, 0x12,
- 0xbb, 0x29, 0x71, 0x46, 0x19, 0x2b, 0x3d, 0x97,
- 0x1d, 0xd6, 0x7d, 0x80, 0x1d, 0xcb, 0x89, 0x21,
- 0xb6, 0x82, 0xed, 0x40, 0xf3, 0xf7, 0xf3, 0x48,
- 0x29, 0x3b, 0x6d, 0xd2, 0xe5, 0xbd, 0x27, 0xbd,
- 0x27, 0x50, 0x4f, 0xde, 0xbb, 0x0c, 0xfb, 0x43,
- 0xf3, 0x94, 0x23, 0x22, 0x18, 0x6b, 0x85, 0x51,
- 0x5d, 0xad, 0xc5, 0xa1, 0x41, 0xae, 0x51, 0x4b,
- 0xd9, 0x19, 0x6e, 0x4b, 0x0b, 0x29, 0x35, 0x72,
- 0x59, 0xef, 0x5b, 0x29, 0x8c, 0x65, 0x6a, 0xc9,
- 0x23, 0x45, 0x38, 0xc1, 0x17, 0x5c, 0x7f, 0xc0,
- 0x71, 0x13, 0xde, 0xf1, 0xa6, 0xfc, 0x3c, 0xe1,
- 0xae, 0x27, 0xff, 0x06, 0x5c, 0x88, 0x56, 0xf2,
- 0x46, 0x74, 0x2d, 0x3c, 0xd7, 0xa5, 0x58, 0x51,
- 0xcb, 0xb9, 0x8c, 0x11, 0xce, 0xf0, 0x01, 0x97,
- 0x0d, 0x1e, 0x1f, 0xea, 0x3f, 0x6e, 0x76, 0x02,
- 0x0a, 0x58, 0x4d, 0x2e, 0x20, 0x6c, 0x1e, 0x48,
- 0x8b, 0xf7, 0x2a, 0xae, 0x8c, 0x5d, 0x47, 0x04,
- 0x4d, 0x66, 0x05, 0xb2, 0x90, 0x0b, 0xbe, 0xcf,
- 0x3d, 0xa6, 0xa4, 0x06, 0x7c, 0x29, 0x3c, 0x64,
- 0xe5, 0x82, 0x0b, 0x03, 0xd8, 0x25, 0x96, 0x8d,
- 0x08, 0x78, 0x9b, 0x27, 0x15, 0x54, 0x76, 0x14,
- 0xd8, 0xdd, 0x35, 0x2f, 0x71, 0xa6, 0x84, 0x8f,
- 0x90, 0x51, 0x85, 0x01, 0x13, 0xb8, 0x90, 0x23,
- 0x99, 0xa5, 0x47, 0x03, 0x7a, 0xfd, 0x15, 0xbf,
- 0x63, 0xec, 0xd3, 0x0d, 0x01, 0x4d, 0x45, 0xb6,
- 0xd2, 0xeb, 0xeb, 0xdf, 0xef, 0x60, 0xdf, 0xef,
- 0x1f, 0x78, 0x35,
-};
-
-static unsigned char commit_data[] = {
- 0x74, 0x72, 0x65, 0x65, 0x20, 0x64, 0x66, 0x66,
- 0x32, 0x64, 0x61, 0x39, 0x30, 0x62, 0x32, 0x35,
- 0x34, 0x65, 0x31, 0x62, 0x65, 0x62, 0x38, 0x38,
- 0x39, 0x64, 0x31, 0x66, 0x31, 0x66, 0x31, 0x32,
- 0x38, 0x38, 0x62, 0x65, 0x31, 0x38, 0x30, 0x33,
- 0x37, 0x38, 0x32, 0x64, 0x66, 0x0a, 0x61, 0x75,
- 0x74, 0x68, 0x6f, 0x72, 0x20, 0x41, 0x20, 0x55,
- 0x20, 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61,
- 0x75, 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78,
- 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
- 0x6d, 0x3e, 0x20, 0x31, 0x32, 0x32, 0x37, 0x38,
- 0x31, 0x34, 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30,
- 0x30, 0x30, 0x30, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
- 0x69, 0x74, 0x74, 0x65, 0x72, 0x20, 0x43, 0x20,
- 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
- 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
- 0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
- 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
- 0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
- 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
- 0x30, 0x0a, 0x0a, 0x41, 0x20, 0x6f, 0x6e, 0x65,
- 0x2d, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x63, 0x6f,
- 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x75, 0x6d,
- 0x6d, 0x61, 0x72, 0x79, 0x0a, 0x0a, 0x54, 0x68,
- 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x6f,
- 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
- 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x6d, 0x65, 0x73,
- 0x73, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x63, 0x6f,
- 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67,
- 0x20, 0x66, 0x75, 0x72, 0x74, 0x68, 0x65, 0x72,
- 0x20, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61,
- 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x6f, 0x66, 0x20,
- 0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x72, 0x70,
- 0x6f, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74,
- 0x68, 0x65, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67,
- 0x65, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x72, 0x6f,
- 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79,
- 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d,
- 0x6d, 0x69, 0x74, 0x2e, 0x0a, 0x0a, 0x53, 0x69,
- 0x67, 0x6e, 0x65, 0x64, 0x2d, 0x6f, 0x66, 0x2d,
- 0x62, 0x79, 0x3a, 0x20, 0x41, 0x20, 0x55, 0x20,
- 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61, 0x75,
- 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78, 0x61,
- 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
- 0x3e, 0x0a,
-};
-
-static object_data commit = {
- commit_bytes,
- sizeof(commit_bytes),
- "3d7f8a6af076c8c3f20071a8935cdbe8228594d1",
- "commit",
- "test-objects/3d",
- "test-objects/3d/7f8a6af076c8c3f20071a8935cdbe8228594d1",
- commit_data,
- sizeof(commit_data),
-};
-
-/* tree == dff2da90b254e1beb889d1f1f1288be1803782df */
-static unsigned char tree_bytes[] = {
- 0x78, 0x01, 0x2b, 0x29, 0x4a, 0x4d, 0x55, 0x30,
- 0x34, 0x32, 0x63, 0x30, 0x34, 0x30, 0x30, 0x33,
- 0x31, 0x51, 0xc8, 0xcf, 0x4b, 0x65, 0xe8, 0x16,
- 0xae, 0x98, 0x58, 0x29, 0xff, 0x32, 0x53, 0x7d,
- 0x6d, 0xc5, 0x33, 0x6f, 0xae, 0xb5, 0xd5, 0xf7,
- 0x2e, 0x74, 0xdf, 0x81, 0x4a, 0x17, 0xe7, 0xe7,
- 0xa6, 0x32, 0xfc, 0x6d, 0x31, 0xd8, 0xd3, 0xe6,
- 0xf3, 0xe7, 0xea, 0x47, 0xbe, 0xd0, 0x09, 0x3f,
- 0x96, 0xb8, 0x3f, 0x90, 0x9e, 0xa2, 0xfd, 0x0f,
- 0x2a, 0x5f, 0x52, 0x9e, 0xcf, 0x50, 0x31, 0x43,
- 0x52, 0x29, 0xd1, 0x5a, 0xeb, 0x77, 0x82, 0x2a,
- 0x8b, 0xfe, 0xb7, 0xbd, 0xed, 0x5d, 0x07, 0x67,
- 0xfa, 0xb5, 0x42, 0xa5, 0xab, 0x52, 0x8b, 0xf2,
- 0x19, 0x9e, 0xcd, 0x7d, 0x34, 0x7b, 0xd3, 0xc5,
- 0x6b, 0xce, 0xde, 0xdd, 0x9a, 0xeb, 0xca, 0xa3,
- 0x6e, 0x1c, 0x7a, 0xd2, 0x13, 0x3c, 0x11, 0x00,
- 0xe2, 0xaa, 0x38, 0x57,
-};
-
-static unsigned char tree_data[] = {
- 0x31, 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x6f,
- 0x6e, 0x65, 0x00, 0x8b, 0x13, 0x78, 0x91, 0x79,
- 0x1f, 0xe9, 0x69, 0x27, 0xad, 0x78, 0xe6, 0x4b,
- 0x0a, 0xad, 0x7b, 0xde, 0xd0, 0x8b, 0xdc, 0x31,
- 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x73, 0x6f,
- 0x6d, 0x65, 0x00, 0xfd, 0x84, 0x30, 0xbc, 0x86,
- 0x4c, 0xfc, 0xd5, 0xf1, 0x0e, 0x55, 0x90, 0xf8,
- 0xa4, 0x47, 0xe0, 0x1b, 0x94, 0x2b, 0xfe, 0x31,
- 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x74, 0x77,
- 0x6f, 0x00, 0x78, 0x98, 0x19, 0x22, 0x61, 0x3b,
- 0x2a, 0xfb, 0x60, 0x25, 0x04, 0x2f, 0xf6, 0xbd,
- 0x87, 0x8a, 0xc1, 0x99, 0x4e, 0x85, 0x31, 0x30,
- 0x30, 0x36, 0x34, 0x34, 0x20, 0x7a, 0x65, 0x72,
- 0x6f, 0x00, 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1,
- 0xd6, 0x43, 0x4b, 0x8b, 0x29, 0xae, 0x77, 0x5a,
- 0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91,
-};
-
-static object_data tree = {
- tree_bytes,
- sizeof(tree_bytes),
- "dff2da90b254e1beb889d1f1f1288be1803782df",
- "tree",
- "test-objects/df",
- "test-objects/df/f2da90b254e1beb889d1f1f1288be1803782df",
- tree_data,
- sizeof(tree_data),
-};
-
-/* tag == 09d373e1dfdc16b129ceec6dd649739911541e05 */
-static unsigned char tag_bytes[] = {
- 0x78, 0x01, 0x35, 0x4e, 0xcb, 0x0a, 0xc2, 0x40,
- 0x10, 0xf3, 0xbc, 0x5f, 0x31, 0x77, 0xa1, 0xec,
- 0xa3, 0xed, 0x6e, 0x41, 0x44, 0xf0, 0x2c, 0x5e,
- 0xfc, 0x81, 0xe9, 0x76, 0xb6, 0xad, 0xb4, 0xb4,
- 0x6c, 0x07, 0xd1, 0xbf, 0x77, 0x44, 0x0d, 0x39,
- 0x84, 0x10, 0x92, 0x30, 0xf6, 0x60, 0xbc, 0xdb,
- 0x2d, 0xed, 0x9d, 0x22, 0x83, 0xeb, 0x7c, 0x0a,
- 0x58, 0x63, 0xd2, 0xbe, 0x8e, 0x21, 0xba, 0x64,
- 0xb5, 0xf6, 0x06, 0x43, 0xe3, 0xaa, 0xd8, 0xb5,
- 0x14, 0xac, 0x0d, 0x55, 0x53, 0x76, 0x46, 0xf1,
- 0x6b, 0x25, 0x88, 0xcb, 0x3c, 0x8f, 0xac, 0x58,
- 0x3a, 0x1e, 0xba, 0xd0, 0x85, 0xd8, 0xd8, 0xf7,
- 0x94, 0xe1, 0x0c, 0x57, 0xb8, 0x8c, 0xcc, 0x22,
- 0x0f, 0xdf, 0x90, 0xc8, 0x13, 0x3d, 0x71, 0x5e,
- 0x27, 0x2a, 0xc4, 0x39, 0x82, 0xb1, 0xd6, 0x07,
- 0x53, 0xda, 0xc6, 0xc3, 0x5e, 0x0b, 0x94, 0xba,
- 0x0d, 0xe3, 0x06, 0x42, 0x1e, 0x08, 0x3e, 0x95,
- 0xbf, 0x4b, 0x69, 0xc9, 0x90, 0x69, 0x22, 0xdc,
- 0xe8, 0xbf, 0xf2, 0x06, 0x42, 0x9a, 0x36, 0xb1,
-};
-
-static unsigned char tag_data[] = {
- 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x33,
- 0x64, 0x37, 0x66, 0x38, 0x61, 0x36, 0x61, 0x66,
- 0x30, 0x37, 0x36, 0x63, 0x38, 0x63, 0x33, 0x66,
- 0x32, 0x30, 0x30, 0x37, 0x31, 0x61, 0x38, 0x39,
- 0x33, 0x35, 0x63, 0x64, 0x62, 0x65, 0x38, 0x32,
- 0x32, 0x38, 0x35, 0x39, 0x34, 0x64, 0x31, 0x0a,
- 0x74, 0x79, 0x70, 0x65, 0x20, 0x63, 0x6f, 0x6d,
- 0x6d, 0x69, 0x74, 0x0a, 0x74, 0x61, 0x67, 0x20,
- 0x76, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x0a, 0x74,
- 0x61, 0x67, 0x67, 0x65, 0x72, 0x20, 0x43, 0x20,
- 0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
- 0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
- 0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
- 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
- 0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
- 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
- 0x30, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20,
- 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
- 0x61, 0x67, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
- 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65,
- 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x76, 0x30,
- 0x2e, 0x30, 0x2e, 0x31, 0x0a,
-};
-
-static object_data tag = {
- tag_bytes,
- sizeof(tag_bytes),
- "09d373e1dfdc16b129ceec6dd649739911541e05",
- "tag",
- "test-objects/09",
- "test-objects/09/d373e1dfdc16b129ceec6dd649739911541e05",
- tag_data,
- sizeof(tag_data),
-};
-
-/* zero == e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 */
-static unsigned char zero_bytes[] = {
- 0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30,
- 0x60, 0x00, 0x00, 0x09, 0xb0, 0x01, 0xf0,
-};
-
-static unsigned char zero_data[] = {
- 0x00 /* dummy data */
-};
-
-static object_data zero = {
- zero_bytes,
- sizeof(zero_bytes),
- "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
- "blob",
- "test-objects/e6",
- "test-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391",
- zero_data,
- 0,
-};
-
-/* two == 78981922613b2afb6025042ff6bd878ac1994e85 */
-static unsigned char two_bytes[] = {
- 0x78, 0x01, 0x4b, 0xca, 0xc9, 0x4f, 0x52, 0x30,
- 0x62, 0x48, 0xe4, 0x02, 0x00, 0x0e, 0x64, 0x02,
- 0x5d,
-};
-
-static unsigned char two_data[] = {
- 0x61, 0x0a,
-};
-
-static object_data two = {
- two_bytes,
- sizeof(two_bytes),
- "78981922613b2afb6025042ff6bd878ac1994e85",
- "blob",
- "test-objects/78",
- "test-objects/78/981922613b2afb6025042ff6bd878ac1994e85",
- two_data,
- sizeof(two_data),
-};
-
-/* some == fd8430bc864cfcd5f10e5590f8a447e01b942bfe */
-static unsigned char some_bytes[] = {
- 0x78, 0x01, 0x7d, 0x54, 0xc1, 0x4e, 0xe3, 0x30,
- 0x10, 0xdd, 0x33, 0x5f, 0x31, 0xc7, 0x5d, 0x94,
- 0xa5, 0x84, 0xd5, 0x22, 0xad, 0x7a, 0x0a, 0x15,
- 0x85, 0x48, 0xd0, 0x56, 0x49, 0x2a, 0xd4, 0xa3,
- 0x13, 0x4f, 0x88, 0x85, 0x63, 0x47, 0xb6, 0x43,
- 0xc9, 0xdf, 0xef, 0x8c, 0x69, 0x17, 0x56, 0x0b,
- 0x7b, 0xaa, 0x62, 0x7b, 0xde, 0xbc, 0xf7, 0xe6,
- 0x4d, 0x6b, 0x6d, 0x6b, 0x48, 0xd3, 0xcb, 0x5f,
- 0x5f, 0x66, 0xa7, 0x27, 0x70, 0x0a, 0x55, 0xa7,
- 0x3c, 0xb4, 0x4a, 0x23, 0xf0, 0xaf, 0x43, 0x04,
- 0x6f, 0xdb, 0xb0, 0x17, 0x0e, 0xe7, 0x30, 0xd9,
- 0x11, 0x1a, 0x61, 0xc0, 0xa1, 0x54, 0x3e, 0x38,
- 0x55, 0x8f, 0x81, 0x9e, 0x05, 0x10, 0x46, 0xce,
- 0xac, 0x83, 0xde, 0x4a, 0xd5, 0x4e, 0x0c, 0x42,
- 0x67, 0xa3, 0x91, 0xe8, 0x20, 0x74, 0x08, 0x01,
- 0x5d, 0xef, 0xc1, 0xb6, 0xf1, 0xe3, 0x66, 0xb5,
- 0x85, 0x1b, 0x34, 0xe8, 0x84, 0x86, 0xcd, 0x58,
- 0x6b, 0xd5, 0xc0, 0x9d, 0x6a, 0xd0, 0x78, 0x4c,
- 0xe0, 0x19, 0x9d, 0x57, 0xd6, 0xc0, 0x45, 0xc2,
- 0x18, 0xc2, 0xc3, 0xc0, 0x0f, 0x7c, 0x87, 0x12,
- 0xea, 0x29, 0x56, 0x2f, 0x99, 0x4f, 0x79, 0xe0,
- 0x03, 0x4b, 0x4b, 0x4d, 0x44, 0xa0, 0x92, 0x33,
- 0x2a, 0xe0, 0x9a, 0xdc, 0x80, 0x90, 0x52, 0xf1,
- 0x11, 0x04, 0x1b, 0x4b, 0x06, 0xea, 0xae, 0x3c,
- 0xe3, 0x7a, 0x50, 0x74, 0x4a, 0x84, 0xfe, 0xc3,
- 0x81, 0x41, 0xf8, 0x89, 0x18, 0x43, 0x67, 0x9d,
- 0x87, 0x47, 0xf5, 0x8c, 0x51, 0xf6, 0x68, 0xb4,
- 0xea, 0x55, 0x20, 0x2a, 0x6f, 0x80, 0xdc, 0x42,
- 0x2b, 0xf3, 0x14, 0x2b, 0x1a, 0xdb, 0x0f, 0xe4,
- 0x9a, 0x64, 0x84, 0xa3, 0x90, 0xa8, 0xf9, 0x8f,
- 0x9d, 0x86, 0x9e, 0xd3, 0xab, 0x5a, 0x99, 0xc8,
- 0xd9, 0xc3, 0x5e, 0x85, 0x0e, 0x2c, 0xb5, 0x73,
- 0x30, 0x38, 0xfb, 0xe8, 0x44, 0xef, 0x5f, 0x95,
- 0x1b, 0xc9, 0xd0, 0xef, 0x3c, 0x26, 0x32, 0x1e,
- 0xff, 0x2d, 0xb6, 0x23, 0x7b, 0x3f, 0xd1, 0x3c,
- 0x78, 0x1a, 0x0d, 0xcb, 0xe6, 0xf6, 0xd4, 0x44,
- 0x99, 0x47, 0x1a, 0x9e, 0xed, 0x23, 0xb5, 0x91,
- 0x6a, 0xdf, 0x53, 0x39, 0x03, 0xf8, 0x5a, 0xb1,
- 0x0f, 0x1f, 0xce, 0x81, 0x11, 0xde, 0x01, 0x7a,
- 0x90, 0x16, 0xc4, 0x30, 0xe8, 0x89, 0xed, 0x7b,
- 0x65, 0x4b, 0xd7, 0x03, 0x36, 0xc1, 0xcf, 0xa1,
- 0xa5, 0xb1, 0xe3, 0x8b, 0xe8, 0x07, 0x4d, 0xf3,
- 0x23, 0x25, 0x13, 0x35, 0x27, 0xf5, 0x8c, 0x11,
- 0xd3, 0xa0, 0x9a, 0xa8, 0xf5, 0x38, 0x7d, 0xce,
- 0x55, 0xc2, 0x71, 0x79, 0x13, 0xc7, 0xa3, 0xda,
- 0x77, 0x68, 0xc0, 0xd8, 0x10, 0xdd, 0x24, 0x8b,
- 0x15, 0x59, 0xc5, 0x10, 0xe2, 0x20, 0x99, 0x8e,
- 0xf0, 0x05, 0x9b, 0x31, 0x88, 0x5a, 0xe3, 0xd9,
- 0x37, 0xba, 0xe2, 0xdb, 0xbf, 0x92, 0xfa, 0x66,
- 0x16, 0x97, 0x47, 0xd9, 0x9d, 0x1d, 0x28, 0x7c,
- 0x9d, 0x08, 0x1c, 0xc7, 0xbd, 0xd2, 0x1a, 0x6a,
- 0x04, 0xf2, 0xa2, 0x1d, 0x75, 0x02, 0x14, 0x5d,
- 0xc6, 0x78, 0xc8, 0xab, 0xdb, 0xf5, 0xb6, 0x82,
- 0x6c, 0xb5, 0x83, 0x87, 0xac, 0x28, 0xb2, 0x55,
- 0xb5, 0x9b, 0xc7, 0xc1, 0xb0, 0xb7, 0xf8, 0x4c,
- 0xbc, 0x38, 0x0e, 0x8a, 0x04, 0x2a, 0x62, 0x41,
- 0x6b, 0xe0, 0x84, 0x09, 0x13, 0xe9, 0xe1, 0xea,
- 0xfb, 0xeb, 0x62, 0x71, 0x4b, 0x25, 0xd9, 0x55,
- 0x7e, 0x97, 0x57, 0x3b, 0x20, 0x33, 0x96, 0x79,
- 0xb5, 0xba, 0x2e, 0x4b, 0x58, 0xae, 0x0b, 0xc8,
- 0x60, 0x93, 0x15, 0x55, 0xbe, 0xd8, 0xde, 0x65,
- 0x05, 0x6c, 0xb6, 0xc5, 0x66, 0x5d, 0x5e, 0x93,
- 0xf7, 0x25, 0x65, 0x98, 0x41, 0x29, 0x86, 0x0c,
- 0xf2, 0xf1, 0x14, 0xa2, 0xb3, 0xbd, 0x75, 0x08,
- 0x12, 0x83, 0x50, 0xda, 0x1f, 0x23, 0xbe, 0xa3,
- 0x1d, 0xf4, 0x9d, 0x1d, 0xb5, 0x84, 0x4e, 0x50,
- 0x38, 0x1d, 0x36, 0x48, 0x21, 0x95, 0xd1, 0xac,
- 0x81, 0x99, 0x1d, 0xc1, 0x3f, 0x41, 0xe6, 0x9e,
- 0x42, 0x5b, 0x0a, 0x48, 0xcc, 0x5f, 0xe0, 0x7d,
- 0x3f, 0xc4, 0x6f, 0x0e, 0xfe, 0xc0, 0x2d, 0xfe,
- 0x01, 0x2c, 0xd6, 0x9b, 0x5d, 0xbe, 0xba, 0x21,
- 0xca, 0x79, 0xcb, 0xe3, 0x49, 0x60, 0xef, 0x68,
- 0x05, 0x28, 0x9b, 0x8c, 0xc1, 0x12, 0x3e, 0xdb,
- 0xc7, 0x04, 0x7e, 0xa6, 0x74, 0x29, 0xcc, 0x13,
- 0xed, 0x07, 0x94, 0x81, 0xd6, 0x96, 0xaa, 0x97,
- 0xaa, 0xa5, 0xc0, 0x2f, 0xb5, 0xb5, 0x2e, 0xe6,
- 0xfc, 0xca, 0xfa, 0x60, 0x4d, 0x02, 0xf7, 0x19,
- 0x9c, 0x5f, 0xa4, 0xe9, 0xf9, 0xf7, 0xf4, 0xc7,
- 0x79, 0x9a, 0xc0, 0xb6, 0xcc, 0x58, 0xec, 0xec,
- 0xe4, 0x37, 0x22, 0xfa, 0x8b, 0x53,
-};
-
-static unsigned char some_data[] = {
- 0x2f, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x54, 0x68,
- 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20,
- 0x69, 0x73, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20,
- 0x73, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
- 0x3b, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61,
- 0x6e, 0x20, 0x72, 0x65, 0x64, 0x69, 0x73, 0x74,
- 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x69,
- 0x74, 0x20, 0x61, 0x6e, 0x64, 0x2f, 0x6f, 0x72,
- 0x20, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0a,
- 0x20, 0x2a, 0x20, 0x69, 0x74, 0x20, 0x75, 0x6e,
- 0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
- 0x74, 0x65, 0x72, 0x6d, 0x73, 0x20, 0x6f, 0x66,
- 0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55,
- 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
- 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
- 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2c,
- 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
- 0x20, 0x32, 0x2c, 0x0a, 0x20, 0x2a, 0x20, 0x61,
- 0x73, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73,
- 0x68, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
- 0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20,
- 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
- 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x2a, 0x0a,
- 0x20, 0x2a, 0x20, 0x49, 0x6e, 0x20, 0x61, 0x64,
- 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
- 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x65,
- 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e,
- 0x73, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
- 0x20, 0x47, 0x4e, 0x55, 0x20, 0x47, 0x65, 0x6e,
- 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62,
- 0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69, 0x63, 0x65,
- 0x6e, 0x73, 0x65, 0x2c, 0x0a, 0x20, 0x2a, 0x20,
- 0x74, 0x68, 0x65, 0x20, 0x61, 0x75, 0x74, 0x68,
- 0x6f, 0x72, 0x73, 0x20, 0x67, 0x69, 0x76, 0x65,
- 0x20, 0x79, 0x6f, 0x75, 0x20, 0x75, 0x6e, 0x6c,
- 0x69, 0x6d, 0x69, 0x74, 0x65, 0x64, 0x20, 0x70,
- 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
- 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x69, 0x6e,
- 0x6b, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
- 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x0a, 0x20,
- 0x2a, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,
- 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69,
- 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x69,
- 0x6e, 0x74, 0x6f, 0x20, 0x63, 0x6f, 0x6d, 0x62,
- 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
- 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6f, 0x74,
- 0x68, 0x65, 0x72, 0x20, 0x70, 0x72, 0x6f, 0x67,
- 0x72, 0x61, 0x6d, 0x73, 0x2c, 0x0a, 0x20, 0x2a,
- 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20,
- 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
- 0x74, 0x65, 0x20, 0x74, 0x68, 0x6f, 0x73, 0x65,
- 0x20, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61,
- 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x77, 0x69,
- 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x61, 0x6e,
- 0x79, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69,
- 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x2a,
- 0x20, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x20,
- 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65,
- 0x20, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20,
- 0x74, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c,
- 0x65, 0x2e, 0x20, 0x20, 0x28, 0x54, 0x68, 0x65,
- 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
- 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
- 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x0a,
- 0x20, 0x2a, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72,
- 0x69, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20,
- 0x64, 0x6f, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x79,
- 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x74, 0x68, 0x65,
- 0x72, 0x20, 0x72, 0x65, 0x73, 0x70, 0x65, 0x63,
- 0x74, 0x73, 0x3b, 0x20, 0x66, 0x6f, 0x72, 0x20,
- 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2c,
- 0x20, 0x74, 0x68, 0x65, 0x79, 0x20, 0x63, 0x6f,
- 0x76, 0x65, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x6d,
- 0x6f, 0x64, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74,
- 0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2c,
- 0x20, 0x61, 0x6e, 0x64, 0x20, 0x64, 0x69, 0x73,
- 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f,
- 0x6e, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x6e,
- 0x6f, 0x74, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x65,
- 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x0a, 0x20,
- 0x2a, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x62,
- 0x69, 0x6e, 0x65, 0x64, 0x20, 0x65, 0x78, 0x65,
- 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e,
- 0x29, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20,
- 0x54, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c,
- 0x65, 0x20, 0x69, 0x73, 0x20, 0x64, 0x69, 0x73,
- 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64,
- 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20,
- 0x68, 0x6f, 0x70, 0x65, 0x20, 0x74, 0x68, 0x61,
- 0x74, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x6c,
- 0x6c, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65,
- 0x66, 0x75, 0x6c, 0x2c, 0x20, 0x62, 0x75, 0x74,
- 0x0a, 0x20, 0x2a, 0x20, 0x57, 0x49, 0x54, 0x48,
- 0x4f, 0x55, 0x54, 0x20, 0x41, 0x4e, 0x59, 0x20,
- 0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x59,
- 0x3b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75,
- 0x74, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x74,
- 0x68, 0x65, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x69,
- 0x65, 0x64, 0x20, 0x77, 0x61, 0x72, 0x72, 0x61,
- 0x6e, 0x74, 0x79, 0x20, 0x6f, 0x66, 0x0a, 0x20,
- 0x2a, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41,
- 0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54,
- 0x59, 0x20, 0x6f, 0x72, 0x20, 0x46, 0x49, 0x54,
- 0x4e, 0x45, 0x53, 0x53, 0x20, 0x46, 0x4f, 0x52,
- 0x20, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49,
- 0x43, 0x55, 0x4c, 0x41, 0x52, 0x20, 0x50, 0x55,
- 0x52, 0x50, 0x4f, 0x53, 0x45, 0x2e, 0x20, 0x20,
- 0x53, 0x65, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20,
- 0x47, 0x4e, 0x55, 0x0a, 0x20, 0x2a, 0x20, 0x47,
- 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50,
- 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69,
- 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x66, 0x6f,
- 0x72, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x64,
- 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x0a,
- 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x59, 0x6f,
- 0x75, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64,
- 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x72, 0x65,
- 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x20, 0x61,
- 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66,
- 0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55,
- 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
- 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
- 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x0a,
- 0x20, 0x2a, 0x20, 0x61, 0x6c, 0x6f, 0x6e, 0x67,
- 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68,
- 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72,
- 0x61, 0x6d, 0x3b, 0x20, 0x73, 0x65, 0x65, 0x20,
- 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65,
- 0x20, 0x43, 0x4f, 0x50, 0x59, 0x49, 0x4e, 0x47,
- 0x2e, 0x20, 0x20, 0x49, 0x66, 0x20, 0x6e, 0x6f,
- 0x74, 0x2c, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65,
- 0x20, 0x74, 0x6f, 0x0a, 0x20, 0x2a, 0x20, 0x74,
- 0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20,
- 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
- 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74,
- 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x35, 0x31, 0x20,
- 0x46, 0x72, 0x61, 0x6e, 0x6b, 0x6c, 0x69, 0x6e,
- 0x20, 0x53, 0x74, 0x72, 0x65, 0x65, 0x74, 0x2c,
- 0x20, 0x46, 0x69, 0x66, 0x74, 0x68, 0x20, 0x46,
- 0x6c, 0x6f, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x2a,
- 0x20, 0x42, 0x6f, 0x73, 0x74, 0x6f, 0x6e, 0x2c,
- 0x20, 0x4d, 0x41, 0x20, 0x30, 0x32, 0x31, 0x31,
- 0x30, 0x2d, 0x31, 0x33, 0x30, 0x31, 0x2c, 0x20,
- 0x55, 0x53, 0x41, 0x2e, 0x0a, 0x20, 0x2a, 0x2f,
- 0x0a,
-};
-
-static object_data some = {
- some_bytes,
- sizeof(some_bytes),
- "fd8430bc864cfcd5f10e5590f8a447e01b942bfe",
- "blob",
- "test-objects/fd",
- "test-objects/fd/8430bc864cfcd5f10e5590f8a447e01b942bfe",
- some_data,
- sizeof(some_data),
-};
-
diff --git a/tests/t02-objread.c b/tests/t02-objread.c
deleted file mode 100644
index 4bcff27..0000000
--- a/tests/t02-objread.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file. (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "test_lib.h"
-#include "test_helpers.h"
-#include "odb.h"
-
-#include "t02-data.h"
-#include "t02-oids.h"
-
-
-BEGIN_TEST(existsloose0, "check if a loose object exists on the odb")
- git_odb *db;
- git_oid id, id2;
-
- must_pass(write_object_files(odb_dir, &one));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, one.id));
-
- must_be_true(git_odb_exists(db, &id));
-
- /* Test for a non-existant object */
- must_pass(git_oid_fromstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
- must_be_true(0 == git_odb_exists(db, &id2));
-
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &one));
-END_TEST
-
-BEGIN_TEST(readloose0, "read a loose commit")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &commit));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, commit.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects((git_rawobj *)&obj->raw, &commit));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &commit));
-END_TEST
-
-BEGIN_TEST(readloose1, "read a loose tree")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &tree));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, tree.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects((git_rawobj *)&obj->raw, &tree));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &tree));
-END_TEST
-
-BEGIN_TEST(readloose2, "read a loose tag")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &tag));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, tag.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects((git_rawobj *)&obj->raw, &tag));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &tag));
-END_TEST
-
-BEGIN_TEST(readloose3, "read a loose zero-bytes object")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &zero));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, zero.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects((git_rawobj *)&obj->raw, &zero));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &zero));
-END_TEST
-
-BEGIN_TEST(readloose4, "read a one-byte long loose object")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &one));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, one.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects(&obj->raw, &one));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &one));
-END_TEST
-
-BEGIN_TEST(readloose5, "read a two-bytes long loose object")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &two));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, two.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects(&obj->raw, &two));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &two));
-END_TEST
-
-BEGIN_TEST(readloose6, "read a loose object which is several bytes long")
- git_odb *db;
- git_oid id;
- git_odb_object *obj;
-
- must_pass(write_object_files(odb_dir, &some));
- must_pass(git_odb_open(&db, odb_dir));
- must_pass(git_oid_fromstr(&id, some.id));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(cmp_objects(&obj->raw, &some));
-
- git_odb_object_close(obj);
- git_odb_close(db);
- must_pass(remove_object_files(odb_dir, &some));
-END_TEST
-
-BEGIN_TEST(readpack0, "read several packed objects")
- unsigned int i;
- git_odb *db;
-
- must_pass(git_odb_open(&db, ODB_FOLDER));
-
- for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
- git_oid id;
- git_odb_object *obj;
-
- must_pass(git_oid_fromstr(&id, packed_objects[i]));
- must_be_true(git_odb_exists(db, &id) == 1);
- must_pass(git_odb_read(&obj, db, &id));
-
- git_odb_object_close(obj);
- }
-
- git_odb_close(db);
-END_TEST
-
-BEGIN_TEST(readheader0, "read only the header of several packed objects")
- unsigned int i;
- git_odb *db;
-
- must_pass(git_odb_open(&db, ODB_FOLDER));
-
- for (i = 0; i < ARRAY_SIZE(packed_objects); ++i) {
- git_oid id;
- git_odb_object *obj;
- size_t len;
- git_otype type;
-
- must_pass(git_oid_fromstr(&id, packed_objects[i]));
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(git_odb_read_header(&len, &type, db, &id));
-
- must_be_true(obj->raw.len == len);
- must_be_true(obj->raw.type == type);
-
- git_odb_object_close(obj);
- }
-
- git_odb_close(db);
-END_TEST
-
-BEGIN_TEST(readheader1, "read only the header of several loose objects")
- unsigned int i;
- git_odb *db;
-
- must_pass(git_odb_open(&db, ODB_FOLDER));
-
- for (i = 0; i < ARRAY_SIZE(loose_objects); ++i) {
- git_oid id;
- git_odb_object *obj;
- size_t len;
- git_otype type;
-
- must_pass(git_oid_fromstr(&id, loose_objects[i]));
-
- must_be_true(git_odb_exists(db, &id) == 1);
-
- must_pass(git_odb_read(&obj, db, &id));
- must_pass(git_odb_read_header(&len, &type, db, &id));
-
- must_be_true(obj->raw.len == len);
- must_be_true(obj->raw.type == type);
-
- git_odb_object_close(obj);
- }
-
- git_odb_close(db);
-END_TEST
-
-BEGIN_SUITE(objread)
- ADD_TEST(existsloose0);
-
- ADD_TEST(readloose0);
- ADD_TEST(readloose1);
- ADD_TEST(readloose2);
- ADD_TEST(readloose3);
- ADD_TEST(readloose4);
- ADD_TEST(readloose5);
- ADD_TEST(readloose6);
-
-/*
- ADD_TEST(readloose_enc0);
- ADD_TEST(readloose_enc1);
- ADD_TEST(readloose_enc2);
- ADD_TEST(readloose_enc3);
- ADD_TEST(readloose_enc4);
- ADD_TEST(readloose_enc5);
- ADD_TEST(readloose_enc6);
-*/
-
- ADD_TEST(readpack0);
-
- ADD_TEST(readheader0);
- ADD_TEST(readheader1);
-END_SUITE
diff --git a/tests/t02-oids.h b/tests/t02-oids.h
deleted file mode 100644
index 1a5ed5d..0000000
--- a/tests/t02-oids.h
+++ /dev/null
@@ -1,152 +0,0 @@
-
-static const char *packed_objects[] = {
- "0266163a49e280c4f5ed1e08facd36a2bd716bcf",
- "53fc32d17276939fc79ed05badaef2db09990016",
- "6336846bd5c88d32f93ae57d846683e61ab5c530",
- "6dcf9bf7541ee10456529833502442f385010c3d",
- "bed08a0b30b72a9d4aed7f1af8c8ca124e8d64b9",
- "e90810b8df3e80c413d903f631643c716887138d",
- "fc3c3a2083e9f6f89e6bd53e9420e70d1e357c9b",
- "fc58168adf502d0c0ef614c3111a7038fc8c09c8",
- "fd0ec0333948dfe23265ac46be0205a436a8c3a5",
- "fd8430bc864cfcd5f10e5590f8a447e01b942bfe",
- "fd899f45951c15c1c5f7c34b1c864e91bd6556c6",
- "fda23b974899e7e1f938619099280bfda13bdca9",
- "fdbec189efb657c8325962b494875987881a356b",
- "fe1ca6bd22b5d8353ce6c2f3aba80805c438a7a5",
- "fe3a6a42c87ff1239370c741a265f3997add87c1",
- "deb106bfd2d36ecf9f0079224c12022201a39ad1",
- "dec93efc79e60f2680de3e666755d335967eec30",
- "def425bf8568b9c1e20879bf5be6f9c52b7361c4",
- "df48000ac4f48570054e3a71a81916357997b680",
- "dfae6ed8f6dd8acc3b40a31811ea316239223559",
- "dff79e27d3d2cdc09790ded80fe2ea8ff5d61034",
- "e00e46abe4c542e17c8bc83d72cf5be8018d7b0e",
- "e01b107b4f77f8f98645adac0206a504f2d29d7c",
- "e032d863f512c47b479bd984f8b6c8061f66b7d4",
- "e044baa468a1c74f9f9da36805445f6888358b49",
- "e04529998989ba8ae3419538dd57969af819b241",
- "e0637ddfbea67c8d7f557c709e095af8906e9176",
- "e0743ad4031231e71700abdc6fdbe94f189d20e5",
- "cf33ac7a3d8b2b8f6bb266518aadbf59de397608",
- "cf5f7235b9c9689b133f6ea12015720b411329bd",
- "cf6cccf1297284833a9a03138a1f5738fa1c6c94",
- "cf7992bde17ce7a79cab5f0c1fcbe8a0108721ed",
- "cfe3a027ab12506d4144ee8a35669ae8fc4b7ab1",
- "cfe96f31dfad7bab49977aa1df7302f7fafcb025",
- "cff54d138945ef4de384e9d2759291d0c13ea90a",
- "d01f7573ac34c2f502bd1cf18cde73480c741151",
- "d03f567593f346a1ca96a57f8191def098d126e3",
- "d047b47aadf88501238f36f5c17dd0a50dc62087",
- "d0a0d63086fae3b0682af7261df21f7d0f7f066d",
- "d0a44bd6ed0be21b725a96c0891bbc79bc1a540c",
- "d0d7e736e536a41bcb885005f8bf258c61cad682",
- "d0e7959d4b95ffec6198df6f5a7ae259b23a5f50",
- "bf2fe2acca17d13356ce802ba9dc8343f710dfb7",
- "bf55f407d6d9418e51f42ea7a3a6aadf17388349",
- "bf92206f8b633b88a66dca4a911777630b06fbac",
- "bfaf8c42eb8842abe206179fee864cfba87e3ca9",
- "bfe05675d4e8f6b59d50932add8790f1a06b10ee",
- "bff8618112330763327cfa6ce6e914db84f51ddf",
- "bff873e9853ed99fed52c25f7ad29f78b27dcec2",
- "c01c3fae7251098d7af1b459bcd0786e81d4616d",
- "c0220fca67f48b8a5d4163d53b1486224be3a198",
- "c02d0b160b82ee72469c269f13de4c26a7ea09cb",
- "c059510ad1b45ab58390e042d7dee1ac46703854",
- "c07204a1897aeeaa3c248d29dbfa9b033baf9755",
- "c073337a4dd7276931b4b3fdbc3f0040e9441793",
- "0fd7e4bfba5b3a82be88d1057757ca8b2c5e6d26",
- "100746511cc45c9f1ad6721c4ef5be49222fee4d",
- "1088490171d9b984d68b8b9be9ca003f4eafff59",
- "1093c8ff4cb78fcf5f79dbbeedcb6e824bd4e253",
- "10aa3fa72afab7ee31e116ae06442fe0f7b79df2",
- "10b759e734e8299aa0dca08be935d95d886127b6",
- "111d5ccf0bb010c4e8d7af3eedfa12ef4c5e265b",
- "11261fbff21758444d426356ff6327ee01e90752",
- "112998d425717bb922ce74e8f6f0f831d8dc4510",
- "2ef4e5d838b6507bd61d457cf6466662b791c5c0",
- "2ef4faa0f82efa00eeac6cae9e8b2abccc8566ee",
- "2f06098183b0d7be350acbe39cdbaccff2df0c4a",
- "2f1c5d509ac5bffb3c62f710a1c2c542e126dfd1",
- "2f205b20fc16423c42b3ba51b2ea78d7b9ff3578",
- "2f9b6b6e3d9250ba09360734aa47973a993b59d1",
- "30c62a2d5a8d644f1311d4f7fe3f6a788e4c8188",
- "31438e245492d85fd6da4d1406eba0fbde8332a4",
- "3184a3abdfea231992254929ff4e275898e5bbf6",
- "3188ffdbb3a3d52e0f78f30c484533899224436e",
- "32581d0093429770d044a60eb0e9cc0462bedb13",
- "32679a9544d83e5403202c4d5efb61ad02492847",
- "4e7e9f60b7e2049b7f5697daf133161a18ef688f",
- "4e8cda27ddc8be7db875ceb0f360c37734724c6d",
- "4ea481c61c59ab55169b7cbaae536ad50b49d6f0",
- "4f0adcd0e61eabe06fe32be66b16559537124b7a",
- "4f1355c91100d12f9e7202f91b245df0c110867c",
- "4f6eadeb08b9d0d1e8b1b3eac8a34940adf29a2d",
- "4f9339df943c53117a5fc8e86e2f38716ff3a668",
- "4fc3874b118752e40de556b1c3e7b4a9f1737d00",
- "4ff1dd0992dd6baafdb5e166be6f9f23b59bdf87",
- "5018a35e0b7e2eec7ce5050baf9c7343f3f74164",
- "50298f44a45eda3a29dae82dbe911b5aa176ac07",
- "502acd164fb115768d723144da2e7bb5a24891bb",
- "50330c02bd4fd95c9db1fcf2f97f4218e42b7226",
- "5052bf355d9f8c52446561a39733a8767bf31e37",
- "6f2cd729ae42988c1dd43588d3a6661ba48ad7a0",
- "6f4e2c42d9138bfbf3e0f908f1308828cc6f2178",
- "6f6a17db05a83620cef4572761831c20a70ba9b9",
- "6faad60901e36538634f0d8b8ff3f21f83503c71",
- "6fc72e46de3df0c3842dab302bbacf697a63abab",
- "6fdccd49f442a7204399ca9b418f017322dbded8",
- "6fe7568fc3861c334cb008fd85d57d9647249ef5",
- "700f55d91d7b55665594676a4bada1f1457a0598",
- "702bd70595a7b19afc48a1f784a6505be68469d4",
- "7033f9ee0e52b08cb5679cd49b7b7999eaf9eaf8",
- "70957110ce446c4e250f865760fb3da513cdcc92",
- "8ec696a4734f16479d091bc70574d23dd9fe7443",
- "8ed341c55ed4d6f4cdc8bf4f0ca18a08c93f6962",
- "8edc2805f1f11b63e44bf81f4557f8b473612b69",
- "8ef9060a954118a698fc10e20acdc430566a100f",
- "8f0c4b543f4bb6eb1518ecfc3d4699e43108d393",
- "8fac94df3035405c2e60b3799153ce7c428af6b9",
- "904c0ac12b23548de524adae712241b423d765a3",
- "90bbaa9a809c3a768d873a9cc7d52b4f3bf3d1b9",
- "90d4d2f0fc362beabbbf76b4ffda0828229c198d",
- "90f9ff6755330b685feff6c3d81782ee3592ab04",
- "91822c50ebe4f9bf5bbb8308ecf9f6557062775c",
- "91d973263a55708fa8255867b3202d81ef9c2868",
- "af292c99c6148d772af3315a1c74e83330e7ead7",
- "af3b99d5be330dbbce0b9250c3a5fb05911908cc",
- "af55d0cdeb280af2db8697e5afa506e081012719",
- "af795e498d411142ddb073e8ca2c5447c3295a4c",
- "afadc73a392f8cc8e2cc77dd62a7433dd3bafa8c",
- "affd84ed8ec7ce67612fe3c12a80f8164b101f6a",
- "b0941f9c70ffe67f0387a827b338e64ecf3190f0",
- "b0a3077f9ef6e093f8d9869bdb0c07095bd722cb",
- "b0a8568a7614806378a54db5706ee3b06ae58693",
- "b0fb7372f242233d1d35ce7d8e74d3990cbc5841",
- "b10489944b9ead17427551759d180d10203e06ba",
- "b196a807b323f2748ffc6b1d42cd0812d04c9a40",
- "b1bb1d888f0c5e19278536d49fa77db035fac7ae"
-};
-
-static const char *loose_objects[] = {
- "45b983be36b73c0788dc9cbcb76cbb80fc7bb057",
- "a8233120f6ad708f843d861ce2b7228ec4e3dec6",
- "fd093bff70906175335656e6ce6ae05783708765",
- "c47800c7266a2be04c571c04d5a6614691ea99bd",
- "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd",
- "8496071c1b46c854b31185ea97743be6a8774479",
- "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
- "814889a078c031f61ed08ab5fa863aea9314344d",
- "5b5b025afb0b4c913b4c338a42934a3863bf3644",
- "1385f264afb75a56a5bec74243be9b367ba4ca08",
- "f60079018b664e4e79329a7ef9559c8d9e0378d1",
- "be3563ae3f795b2b4353bcce3a527ad0a4f7f644",
- "75057dd4114e74cca1d750d0aee1647c903cb60a",
- "fa49b077972391ad58037050f2a75f74e3671e92",
- "9fd738e8f7967c078dceed8190330fc8648ee56a",
- "1810dff58d8a660512d4832e740f692884338ccd",
- "181037049a54a1eb5fab404658a3a250b44335d7",
- "a4a7dce85cf63874e984719f4fdd239f5145052f",
- "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"
-};
-
diff --git a/tests/t03-objwrite.c b/tests/t03-objwrite.c
index 7563d0e..6cf3834 100644
--- a/tests/t03-objwrite.c
+++ b/tests/t03-objwrite.c
@@ -114,7 +114,7 @@ BEGIN_TEST(write0, "write loose commit object")
must_pass(cmp_objects(&obj->raw, &commit_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&commit));
END_TEST
@@ -135,7 +135,7 @@ BEGIN_TEST(write1, "write loose tree object")
must_pass(cmp_objects(&obj->raw, &tree_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&tree));
END_TEST
@@ -156,7 +156,7 @@ BEGIN_TEST(write2, "write loose tag object")
must_pass(cmp_objects(&obj->raw, &tag_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&tag));
END_TEST
@@ -177,7 +177,7 @@ BEGIN_TEST(write3, "write zero-length object")
must_pass(cmp_objects(&obj->raw, &zero_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&zero));
END_TEST
@@ -198,7 +198,7 @@ BEGIN_TEST(write4, "write one-byte long object")
must_pass(cmp_objects(&obj->raw, &one_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&one));
END_TEST
@@ -219,7 +219,7 @@ BEGIN_TEST(write5, "write two-byte long object")
must_pass(cmp_objects(&obj->raw, &two_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&two));
END_TEST
@@ -240,7 +240,7 @@ BEGIN_TEST(write6, "write an object which is several bytes long")
must_pass(cmp_objects(&obj->raw, &some_obj));
git_odb_object_close(obj);
- git_odb_close(db);
+ git_odb_free(db);
must_pass(remove_object_files(&some));
END_TEST
diff --git a/tests/t12-repo.c b/tests/t12-repo.c
index 47dc852..acf8b74 100644
--- a/tests/t12-repo.c
+++ b/tests/t12-repo.c
@@ -29,288 +29,8 @@
#include "git2/odb_backend.h"
#include "repository.h"
-typedef struct {
- git_odb_backend base;
- int position;
-} fake_backend;
-
-static git_odb_backend *new_backend(int position)
-{
- fake_backend *b;
-
- b = git__malloc(sizeof(fake_backend));
- if (b == NULL)
- return NULL;
-
- memset(b, 0x0, sizeof(fake_backend));
- b->position = position;
- return (git_odb_backend *)b;
-}
-
-static int test_backend_sorting(git_odb *odb)
-{
- unsigned int i;
-
- for (i = 0; i < odb->backends.length; ++i) {
- fake_backend *internal = *((fake_backend **)git_vector_get(&odb->backends, i));
-
- if (internal == NULL)
- return GIT_ERROR;
-
- if (internal->position != (int)i)
- return GIT_ERROR;
- }
-
- return GIT_SUCCESS;
-}
-
-BEGIN_TEST(odb0, "assure that ODB backends are properly sorted")
- git_odb *odb;
- must_pass(git_odb_new(&odb));
- must_pass(git_odb_add_backend(odb, new_backend(0), 5));
- must_pass(git_odb_add_backend(odb, new_backend(2), 3));
- must_pass(git_odb_add_backend(odb, new_backend(1), 4));
- must_pass(git_odb_add_backend(odb, new_backend(3), 1));
- must_pass(test_backend_sorting(odb));
- git_odb_close(odb);
-END_TEST
-
-BEGIN_TEST(odb1, "assure that alternate backends are properly sorted")
- git_odb *odb;
- must_pass(git_odb_new(&odb));
- must_pass(git_odb_add_backend(odb, new_backend(0), 5));
- must_pass(git_odb_add_backend(odb, new_backend(2), 3));
- must_pass(git_odb_add_backend(odb, new_backend(1), 4));
- must_pass(git_odb_add_backend(odb, new_backend(3), 1));
- must_pass(git_odb_add_alternate(odb, new_backend(4), 5));
- must_pass(git_odb_add_alternate(odb, new_backend(6), 3));
- must_pass(git_odb_add_alternate(odb, new_backend(5), 4));
- must_pass(git_odb_add_alternate(odb, new_backend(7), 1));
- must_pass(test_backend_sorting(odb));
- git_odb_close(odb);
-END_TEST
-
-
-#define STANDARD_REPOSITORY 0
-#define BARE_REPOSITORY 1
-
-static int ensure_repository_init(
- const char *working_directory,
- int repository_kind,
- const char *expected_path_index,
- const char *expected_path_repository,
- const char *expected_working_directory)
-{
- char path_odb[GIT_PATH_MAX];
- git_repository *repo;
-
- if (git_futils_isdir(working_directory) == GIT_SUCCESS)
- return GIT_ERROR;
-
- git_path_join(path_odb, expected_path_repository, GIT_OBJECTS_DIR);
-
- if (git_repository_init(&repo, working_directory, repository_kind) < GIT_SUCCESS)
- return GIT_ERROR;
-
- if (repo->path_workdir != NULL || expected_working_directory != NULL) {
- if (git__suffixcmp(repo->path_workdir, expected_working_directory) != 0)
- goto cleanup;
- }
-
- if (git__suffixcmp(repo->path_odb, path_odb) != 0)
- goto cleanup;
-
- if (git__suffixcmp(repo->path_repository, expected_path_repository) != 0)
- goto cleanup;
-
- if (repo->path_index != NULL || expected_path_index != NULL) {
- if (git__suffixcmp(repo->path_index, expected_path_index) != 0)
- goto cleanup;
-
-#ifdef GIT_WIN32
- if ((GetFileAttributes(repo->path_repository) & FILE_ATTRIBUTE_HIDDEN) == 0)
- goto cleanup;
-#endif
-
- if (git_repository_is_bare(repo) == 1)
- goto cleanup;
- } else if (git_repository_is_bare(repo) == 0)
- goto cleanup;
-
- if (git_repository_is_empty(repo) == 0)
- goto cleanup;
-
- git_repository_free(repo);
- git_futils_rmdir_r(working_directory, 1);
-
- return GIT_SUCCESS;
-
-cleanup:
- git_repository_free(repo);
- git_futils_rmdir_r(working_directory, 1);
- return GIT_ERROR;
-}
-
-BEGIN_TEST(init0, "initialize a standard repo")
- char path_index[GIT_PATH_MAX], path_repository[GIT_PATH_MAX];
-
- git_path_join(path_repository, TEMP_REPO_FOLDER, GIT_DIR);
- git_path_join(path_index, path_repository, GIT_INDEX_FILE);
-
- must_pass(ensure_repository_init(TEMP_REPO_FOLDER, STANDARD_REPOSITORY, path_index, path_repository, TEMP_REPO_FOLDER));
- must_pass(ensure_repository_init(TEMP_REPO_FOLDER_NS, STANDARD_REPOSITORY, path_index, path_repository, TEMP_REPO_FOLDER));
-END_TEST
-
-BEGIN_TEST(init1, "initialize a bare repo")
- char path_repository[GIT_PATH_MAX];
-
- git_path_join(path_repository, TEMP_REPO_FOLDER, "");
-
- must_pass(ensure_repository_init(TEMP_REPO_FOLDER, BARE_REPOSITORY, NULL, path_repository, NULL));
- must_pass(ensure_repository_init(TEMP_REPO_FOLDER_NS, BARE_REPOSITORY, NULL, path_repository, NULL));
-END_TEST
-
-BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory")
- char path_repository[GIT_PATH_MAX];
- char current_workdir[GIT_PATH_MAX];
- const mode_t mode = 0777;
- git_repository* repo;
-
- must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
-
- git_path_join(path_repository, TEMP_REPO_FOLDER, "a/b/c/");
- must_pass(git_futils_mkdir_r(path_repository, mode));
-
- must_pass(chdir(path_repository));
-
- must_pass(git_repository_init(&repo, "../d/e.git", 1));
- must_pass(git__suffixcmp(repo->path_repository, "/a/b/d/e.git/"));
-
- git_repository_free(repo);
-
- must_pass(git_repository_open(&repo, "../d/e.git"));
-
- git_repository_free(repo);
-
- must_pass(chdir(current_workdir));
- must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
-END_TEST
-
#define EMPTY_BARE_REPOSITORY_FOLDER TEST_RESOURCES "/empty_bare.git/"
-BEGIN_TEST(open0, "Open a bare repository that has just been initialized by git")
- git_repository *repo;
-
- must_pass(copydir_recurs(EMPTY_BARE_REPOSITORY_FOLDER, TEMP_REPO_FOLDER));
- must_pass(remove_placeholders(TEMP_REPO_FOLDER, "dummy-marker.txt"));
-
- must_pass(git_repository_open(&repo, TEMP_REPO_FOLDER));
- must_be_true(git_repository_path(repo, GIT_REPO_PATH) != NULL);
- must_be_true(git_repository_path(repo, GIT_REPO_PATH_WORKDIR) == NULL);
-
- git_repository_free(repo);
- must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
-END_TEST
-
-BEGIN_TEST(open1, "Open a standard repository that has just been initialized by git")
- git_repository *repo;
-
- must_pass(copydir_recurs(EMPTY_REPOSITORY_FOLDER, TEST_STD_REPO_FOLDER));
- must_pass(remove_placeholders(TEST_STD_REPO_FOLDER, "dummy-marker.txt"));
-
- must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER));
- must_be_true(git_repository_path(repo, GIT_REPO_PATH) != NULL);
- must_be_true(git_repository_path(repo, GIT_REPO_PATH_WORKDIR) != NULL);
-
- git_repository_free(repo);
- must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
-END_TEST
-
-
-BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of the current working directory")
- char new_current_workdir[GIT_PATH_MAX];
- char current_workdir[GIT_PATH_MAX];
- char path_repository[GIT_PATH_MAX];
-
- const mode_t mode = 0777;
- git_repository* repo;
-
- /* Setup the repository to open */
- must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
- strcpy(path_repository, current_workdir);
- git_path_join_n(path_repository, 3, path_repository, TEMP_REPO_FOLDER, "a/d/e.git");
- must_pass(copydir_recurs(REPOSITORY_FOLDER, path_repository));
-
- /* Change the current working directory */
- git_path_join(new_current_workdir, TEMP_REPO_FOLDER, "a/b/c/");
- must_pass(git_futils_mkdir_r(new_current_workdir, mode));
- must_pass(chdir(new_current_workdir));
-
- must_pass(git_repository_open(&repo, "../../d/e.git"));
-
- git_repository_free(repo);
-
- must_pass(chdir(current_workdir));
- must_pass(git_futils_rmdir_r(TEMP_REPO_FOLDER, 1));
-END_TEST
-
-BEGIN_TEST(empty0, "test if a repository is empty or not")
-
- git_repository *repo_empty, *repo_normal;
-
- must_pass(git_repository_open(&repo_normal, REPOSITORY_FOLDER));
- must_be_true(git_repository_is_empty(repo_normal) == 0);
- git_repository_free(repo_normal);
-
- must_pass(git_repository_open(&repo_empty, EMPTY_BARE_REPOSITORY_FOLDER));
- must_be_true(git_repository_is_empty(repo_empty) == 1);
- git_repository_free(repo_empty);
-END_TEST
-
-BEGIN_TEST(detached0, "test if HEAD is detached")
- git_repository *repo;
- git_reference *ref;
- git_oid oid;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
-
- must_be_true(git_repository_head_detached(repo) == 0);
-
- /* detach the HEAD */
- git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd");
- must_pass(git_reference_create_oid(&ref, repo, "HEAD", &oid, 1));
- must_be_true(git_repository_head_detached(repo) == 1);
-
- /* take the reop back to it's original state */
- must_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
- must_be_true(git_repository_head_detached(repo) == 0);
-
- git_repository_free(repo);
-
- git_reference_free(ref);
-END_TEST
-
-BEGIN_TEST(orphan0, "test if HEAD is orphan")
- git_repository *repo;
- git_reference *ref;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
-
- must_be_true(git_repository_head_orphan(repo) == 0);
-
- /* orphan HEAD */
- must_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/orphan", 1));
- must_be_true(git_repository_head_orphan(repo) == 1);
-
- /* take the reop back to it's original state */
- must_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
- must_be_true(git_repository_head_orphan(repo) == 0);
-
- git_repository_free(repo);
-
- git_reference_free(ref);
-END_TEST
-
#define DISCOVER_FOLDER TEMP_REPO_FOLDER "discover.git"
#define SUB_REPOSITORY_FOLDER_NAME "sub_repo"
@@ -449,17 +169,6 @@ BEGIN_TEST(discover0, "test discover")
END_TEST
BEGIN_SUITE(repository)
- ADD_TEST(odb0);
- ADD_TEST(odb1);
- ADD_TEST(init0);
- ADD_TEST(init1);
- ADD_TEST(init2);
- ADD_TEST(open0);
- ADD_TEST(open1);
- ADD_TEST(open2);
- ADD_TEST(empty0);
- ADD_TEST(detached0);
- ADD_TEST(orphan0);
ADD_TEST(discover0);
END_SUITE
diff --git a/tests/t15-config.c b/tests/t15-config.c
deleted file mode 100644
index 9f0deb3..0000000
--- a/tests/t15-config.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file. (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "test_lib.h"
-#include "test_helpers.h"
-
-#include <git2.h>
-#include <posix.h>
-#include "filebuf.h"
-
-#define CONFIG_BASE TEST_RESOURCES "/config"
-#define GLOBAL_CONFIG CONFIG_BASE "/.gitconfig"
-
-/*
- * This one is so we know the code isn't completely broken
- */
-BEGIN_TEST(config0, "read a simple configuration")
- git_config *cfg;
- int32_t i;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config0"));
- must_pass(git_config_get_int32(cfg, "core.repositoryformatversion", &i));
- must_be_true(i == 0);
- must_pass(git_config_get_bool(cfg, "core.filemode", &i));
- must_be_true(i == 1);
- must_pass(git_config_get_bool(cfg, "core.bare", &i));
- must_be_true(i == 0);
- must_pass(git_config_get_bool(cfg, "core.logallrefupdates", &i));
- must_be_true(i == 1);
-
- git_config_free(cfg);
-END_TEST
-
-/*
- * [this "that"] and [this "That] are different namespaces. Make sure
- * each returns the correct one.
- */
-BEGIN_TEST(config1, "case sensitivity")
- git_config *cfg;
- int i;
- const char *str;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config1"));
-
- must_pass(git_config_get_string(cfg, "this.that.other", &str));
- must_be_true(!strcmp(str, "true"));
- must_pass(git_config_get_string(cfg, "this.That.other", &str));
- must_be_true(!strcmp(str, "yes"));
-
- must_pass(git_config_get_bool(cfg, "this.that.other", &i));
- must_be_true(i == 1);
- must_pass(git_config_get_bool(cfg, "this.That.other", &i));
- must_be_true(i == 1);
-
- /* This one doesn't exist */
- must_fail(git_config_get_bool(cfg, "this.thaT.other", &i));
-
- git_config_free(cfg);
-END_TEST
-
-/*
- * If \ is the last non-space character on the line, we read the next
- * one, separating each line with SP.
- */
-BEGIN_TEST(config2, "parse a multiline value")
- git_config *cfg;
- const char *str;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config2"));
-
- must_pass(git_config_get_string(cfg, "this.That.and", &str));
- must_be_true(!strcmp(str, "one one one two two three three"));
-
- git_config_free(cfg);
-END_TEST
-
-/*
- * This kind of subsection declaration is case-insensitive
- */
-BEGIN_TEST(config3, "parse a [section.subsection] header")
- git_config *cfg;
- const char *str;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config3"));
-
- must_pass(git_config_get_string(cfg, "section.subsection.var", &str));
- must_be_true(!strcmp(str, "hello"));
-
- /* The subsection is transformed to lower-case */
- must_fail(git_config_get_string(cfg, "section.subSectIon.var", &str));
-
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config4, "a variable name on its own is valid")
- git_config *cfg;
-const char *str;
-int i;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config4"));
-
- must_pass(git_config_get_string(cfg, "some.section.variable", &str));
- must_be_true(str == NULL);
-
- must_pass(git_config_get_bool(cfg, "some.section.variable", &i));
- must_be_true(i == 1);
-
-
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config5, "test number suffixes")
- git_config *cfg;
- int64_t i;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config5"));
-
- must_pass(git_config_get_int64(cfg, "number.simple", &i));
- must_be_true(i == 1);
-
- must_pass(git_config_get_int64(cfg, "number.k", &i));
- must_be_true(i == 1 * 1024);
-
- must_pass(git_config_get_int64(cfg, "number.kk", &i));
- must_be_true(i == 1 * 1024);
-
- must_pass(git_config_get_int64(cfg, "number.m", &i));
- must_be_true(i == 1 * 1024 * 1024);
-
- must_pass(git_config_get_int64(cfg, "number.mm", &i));
- must_be_true(i == 1 * 1024 * 1024);
-
- must_pass(git_config_get_int64(cfg, "number.g", &i));
- must_be_true(i == 1 * 1024 * 1024 * 1024);
-
- must_pass(git_config_get_int64(cfg, "number.gg", &i));
- must_be_true(i == 1 * 1024 * 1024 * 1024);
-
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config6, "test blank lines")
- git_config *cfg;
- int i;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config6"));
-
- must_pass(git_config_get_bool(cfg, "valid.subsection.something", &i));
- must_be_true(i == 1);
-
- must_pass(git_config_get_bool(cfg, "something.else.something", &i));
- must_be_true(i == 0);
-
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config7, "test for invalid ext headers")
- git_config *cfg;
-
- must_fail(git_config_open_ondisk(&cfg, CONFIG_BASE "/config7"));
-
-END_TEST
-
-BEGIN_TEST(config8, "don't fail on empty files")
- git_config *cfg;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config8"));
-
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config9, "replace a value")
- git_config *cfg;
- int i;
- int64_t l, expected = +9223372036854775803;
-
- /* By freeing the config, we make sure we flush the values */
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_set_int32(cfg, "core.dummy", 5));
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_get_int32(cfg, "core.dummy", &i));
- must_be_true(i == 5);
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_set_int32(cfg, "core.dummy", 1));
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_set_int64(cfg, "core.verylong", expected));
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_get_int64(cfg, "core.verylong", &l));
- must_be_true(l == expected);
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_fail(git_config_get_int32(cfg, "core.verylong", &i));
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_set_int64(cfg, "core.verylong", 1));
- git_config_free(cfg);
-
-END_TEST
-
-BEGIN_TEST(config10, "a repo's config overrides the global config")
- git_repository *repo;
- git_config *cfg;
- int32_t version;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- must_pass(git_repository_config(&cfg, repo, GLOBAL_CONFIG, NULL));
- must_pass(git_config_get_int32(cfg, "core.repositoryformatversion", &version));
- must_be_true(version == 0);
- git_config_free(cfg);
- git_repository_free(repo);
-END_TEST
-
-BEGIN_TEST(config11, "fall back to the global config")
- git_repository *repo;
- git_config *cfg;
- int32_t num;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- must_pass(git_repository_config(&cfg, repo, GLOBAL_CONFIG, NULL));
- must_pass(git_config_get_int32(cfg, "core.something", &num));
- must_be_true(num == 2);
- git_config_free(cfg);
- git_repository_free(repo);
-END_TEST
-
-BEGIN_TEST(config12, "delete a value")
- git_config *cfg;
- int32_t i;
-
- /* By freeing the config, we make sure we flush the values */
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_set_int32(cfg, "core.dummy", 5));
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_delete(cfg, "core.dummy"));
- git_config_free(cfg);
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_be_true(git_config_get_int32(cfg, "core.dummy", &i) == GIT_ENOTFOUND);
- must_pass(git_config_set_int32(cfg, "core.dummy", 1));
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config13, "can't delete a non-existent value")
- git_config *cfg;
-
- /* By freeing the config, we make sure we flush the values */
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_be_true(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND);
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config14, "don't fail horribly if a section header is in the last line")
- git_config *cfg;
-
- /* By freeing the config, we make sure we flush the values */
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config10"));
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config15, "add a variable in an existing section")
- git_config *cfg;
- int32_t i;
-
- /* By freeing the config, we make sure we flush the values */
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config10"));
- must_pass(git_config_set_int32(cfg, "empty.tmp", 5));
- must_pass(git_config_get_int32(cfg, "empty.tmp", &i));
- must_be_true(i == 5);
- must_pass(git_config_delete(cfg, "empty.tmp"));
- git_config_free(cfg);
-END_TEST
-
-BEGIN_TEST(config16, "add a variable in a new section")
- git_config *cfg;
- int32_t i;
- git_filebuf buf = GIT_FILEBUF_INIT;
-
- /* By freeing the config, we make sure we flush the values */
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config10"));
- must_pass(git_config_set_int32(cfg, "section.tmp", 5));
- must_pass(git_config_get_int32(cfg, "section.tmp", &i));
- must_be_true(i == 5);
- must_pass(git_config_delete(cfg, "section.tmp"));
- git_config_free(cfg);
-
- /* As the section wasn't removed, owerwrite the file */
- must_pass(git_filebuf_open(&buf, CONFIG_BASE "/config10", 0));
- must_pass(git_filebuf_write(&buf, "[empty]\n", strlen("[empty]\n")));
- must_pass(git_filebuf_commit(&buf, 0666));
-END_TEST
-
-BEGIN_TEST(config17, "prefixes aren't broken")
- git_config *cfg;
- const char *str;
-
- must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9"));
- must_pass(git_config_get_string(cfg, "remote.ab.url", &str));
- must_be_true(strcmp(str, "http://example.com/git/ab") == 0);
-
- must_pass(git_config_get_string(cfg, "remote.abba.url", &str));
- must_be_true(strcmp(str, "http://example.com/git/abba") == 0);
-
- git_config_free(cfg);
-END_TEST
-
-BEGIN_SUITE(config)
- ADD_TEST(config0);
- ADD_TEST(config1);
- ADD_TEST(config2);
- ADD_TEST(config3);
- ADD_TEST(config4);
- ADD_TEST(config5);
- ADD_TEST(config6);
- ADD_TEST(config7);
- ADD_TEST(config8);
- ADD_TEST(config9);
- ADD_TEST(config10);
- ADD_TEST(config11);
- ADD_TEST(config12);
- ADD_TEST(config13);
- ADD_TEST(config14);
- ADD_TEST(config15);
- ADD_TEST(config16);
- ADD_TEST(config17);
-END_SUITE
diff --git a/tests/t16-remotes.c b/tests/t16-remotes.c
deleted file mode 100644
index ac98bdf..0000000
--- a/tests/t16-remotes.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file. (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "test_lib.h"
-#include "test_helpers.h"
-
-#include <git2.h>
-#include <posix.h>
-
-BEGIN_TEST(remotes0, "remote parsing works")
- git_remote *remote;
- git_repository *repo;
- git_config *cfg;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- must_pass(git_repository_config(&cfg, repo, NULL, NULL));
- must_pass(git_remote_get(&remote, cfg, "test"));
- must_be_true(!strcmp(git_remote_name(remote), "test"));
- must_be_true(!strcmp(git_remote_url(remote), "git://github.com/libgit2/libgit2"));
-
- git_remote_free(remote);
- git_config_free(cfg);
- git_repository_free(repo);
-END_TEST
-
-BEGIN_TEST(refspec0, "remote with refspec works")
- git_remote *remote;
- git_repository *repo;
- git_config *cfg;
- const git_refspec *refspec = NULL;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- must_pass(git_repository_config(&cfg, repo, NULL, NULL));
- must_pass(git_remote_get(&remote, cfg, "test"));
- refspec = git_remote_fetchspec(remote);
- must_be_true(refspec != NULL);
- must_be_true(!strcmp(git_refspec_src(refspec), "refs/heads/*"));
- must_be_true(!strcmp(git_refspec_dst(refspec), "refs/remotes/test/*"));
- git_remote_free(remote);
- git_config_free(cfg);
- git_repository_free(repo);
-END_TEST
-
-BEGIN_TEST(refspec1, "remote fnmatch works as expected")
- git_remote *remote;
- git_repository *repo;
- git_config *cfg;
- const git_refspec *refspec = NULL;
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- must_pass(git_repository_config(&cfg, repo, NULL, NULL));
- must_pass(git_remote_get(&remote, cfg, "test"));
- refspec = git_remote_fetchspec(remote);
- must_be_true(refspec != NULL);
- must_pass(git_refspec_src_match(refspec, "refs/heads/master"));
- must_pass(git_refspec_src_match(refspec, "refs/heads/multi/level/branch"));
- git_remote_free(remote);
- git_config_free(cfg);
- git_repository_free(repo);
-END_TEST
-
-BEGIN_TEST(refspec2, "refspec transform")
- git_remote *remote;
- git_repository *repo;
- git_config *cfg;
- const git_refspec *refspec = NULL;
- char ref[1024] = {0};
-
- must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
- must_pass(git_repository_config(&cfg, repo, NULL, NULL));
- must_pass(git_remote_get(&remote, cfg, "test"));
- refspec = git_remote_fetchspec(remote);
- must_be_true(refspec != NULL);
- must_pass(git_refspec_transform(ref, sizeof(ref), refspec, "refs/heads/master"));
- must_be_true(!strcmp(ref, "refs/remotes/test/master"));
- git_remote_free(remote);
- git_config_free(cfg);
- git_repository_free(repo);
-END_TEST
-
-BEGIN_SUITE(remotes)
- ADD_TEST(remotes0)
- ADD_TEST(refspec0)
- ADD_TEST(refspec1)
- ADD_TEST(refspec2)
-END_SUITE
diff --git a/tests/test_main.c b/tests/test_main.c
index 9961ffd..1ebb222 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -33,7 +33,6 @@
DECLARE_SUITE(core);
DECLARE_SUITE(rawobjects);
-DECLARE_SUITE(objread);
DECLARE_SUITE(objwrite);
DECLARE_SUITE(commit);
DECLARE_SUITE(revwalk);
@@ -44,15 +43,12 @@ DECLARE_SUITE(tree);
DECLARE_SUITE(refs);
DECLARE_SUITE(repository);
DECLARE_SUITE(threads);
-DECLARE_SUITE(config);
-DECLARE_SUITE(remotes);
DECLARE_SUITE(buffers);
DECLARE_SUITE(status);
static libgit2_suite suite_methods[]= {
SUITE_NAME(core),
SUITE_NAME(rawobjects),
- SUITE_NAME(objread),
SUITE_NAME(objwrite),
SUITE_NAME(commit),
SUITE_NAME(revwalk),
@@ -63,8 +59,6 @@ static libgit2_suite suite_methods[]= {
SUITE_NAME(refs),
SUITE_NAME(repository),
SUITE_NAME(threads),
- SUITE_NAME(config),
- SUITE_NAME(remotes),
SUITE_NAME(buffers),
SUITE_NAME(status),
};