Commit 3315782cb4f2b683c66a53c93aa81de501c5a4ab

Vicent Marti 2010-08-08T14:12:17

Redesigned the walking/object lookup interface The old 'git_revpool' object has been removed and split into two distinct objects with separate functionality, in order to have separate methods for object management and object walking. * A new object 'git_repository' does the high-level management of a repository's objects (commits, trees, tags, etc) on top of a 'git_odb'. Eventually, it will also manage other repository attributes (e.g. tag resolution, references, etc). See: src/git/repository.h * A new external method 'git_repository_lookup(repo, oid, type)' has been added to the 'git_repository' API. All object lookups (git_XXX_lookup()) are now wrappers to this method, and duplicated code has been removed. The method does automatic type checking and returns a generic 'git_revpool_object' that can be cast to any specific object. See: src/git/repository.h * The external methods for object parsing of repository objects (git_XXX_parse()) have been removed. Loading objects from the repository is now managed through the 'lookup' functions. These objects are loaded with minimal information, and the relevant parsing is done automatically when the user requests any of the parsed attributes through accessor methods. An attribute has been added to 'git_repository' in order to force the parsing of all the repository objects immediately after lookup. See: src/git/commit.h See: src/git/tag.h See: src/git/tree.h * The previous walking functionality of the revpool is now found in 'git_revwalk', which does the actual revision walking on a repository; the attributes when walking through commits in a database have been decoupled from the actual commit objects. This increases performance when accessing commits during the walk and allows to have several 'git_revwalk' instances working at the same time on top of the same repository, without having to load commits in memory several times. See: src/git/revwalk.h * The old 'git_revpool_table' has been renamed to 'git_hashtable' and now works as a generic hashtable with support for any kind of object and custom hash functions. See: src/hashtable.h * All the relevant unit tests have been updated, renamed and grouped accordingly. Signed-off-by: Vicent Marti <tanoku@gmail.com>

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
diff --git a/src/commit.c b/src/commit.c
index 4199e8e..1ffbc72 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -27,6 +27,7 @@
 #include "commit.h"
 #include "revwalk.h"
 #include "git/odb.h"
+#include "git/repository.h"
 
 #define COMMIT_PRINT(commit) {\
 	char oid[41]; oid[40] = 0;\
@@ -34,9 +35,23 @@
 	printf("Oid: %s | In degree: %d | Time: %u\n", oid, commit->in_degree, commit->commit_time);\
 }
 
+static void clear_parents(git_commit *commit)
+{
+	git_commit_parents *node, *next_node;
+
+	node = commit->parents;
+	while (node) {
+		next_node = node->next;
+		free(node);
+		node = next_node;
+	}
+
+	commit->parents = NULL;
+}
+
 void git_commit__free(git_commit *commit)
 {
-	git_commit_list_clear(&commit->parents, 0);
+	clear_parents(commit);
 
 	if (commit->odb_open)
 		git_obj_close(&commit->odb_object);
@@ -53,47 +68,12 @@ const git_oid *git_commit_id(git_commit *c)
 	return &c->object.id;
 }
 
-void git_commit__mark_uninteresting(git_commit *commit)
-{
-	git_commit_node *parents;
-
-	if (commit == NULL)
-		return;
-
-	parents = commit->parents.head;
-
-	commit->uninteresting = 1;
-
-	while (parents) {
-		parents->commit->uninteresting = 1;
-		parents = parents->next;
-	}
-}
-
-git_commit *git_commit_parse(git_revpool *pool, const git_oid *id)
-{
-	git_commit *commit = NULL;
-
-	if ((commit = git_commit_lookup(pool, id)) == NULL)
-		return NULL;
-
-	if (git_commit__parse_basic(commit) < 0)
-		goto error_cleanup;
-
-	return commit;
-
-error_cleanup:
-	/* FIXME: do not free; the commit is owned by the revpool */
-	free(commit);
-	return NULL;
-}
-
 int git_commit__parse(git_commit *commit, unsigned int parse_flags, int close_db_object)
 {
 	int error = 0;
 
 	if (!commit->odb_open) {
-		error = git_odb_read(&commit->odb_object, commit->object.pool->db, &commit->object.id);
+		error = git_odb_read(&commit->odb_object, commit->object.repo->db, &commit->object.id);
 		if (error < 0)
 			return error;
 
@@ -133,32 +113,9 @@ int git_commit__parse_basic(git_commit *commit)
 	return 0;
 }
 
-git_commit *git_commit_lookup(git_revpool *pool, const git_oid *id)
+git_commit *git_commit_lookup(git_repository *repo, const git_oid *id)
 {
-	git_commit *commit = NULL;
-
-	if (pool == NULL)
-		return NULL;
-
-	commit = (git_commit *)git_revpool_table_lookup(pool->objects, id);
-	if (commit != NULL)
-		return commit;
-
-	commit = git__malloc(sizeof(git_commit));
-
-	if (commit == NULL)
-		return NULL;
-
-	memset(commit, 0x0, sizeof(git_commit));
-
-	/* Initialize parent object */
-	git_oid_cpy(&commit->object.id, id);
-	commit->object.pool = pool;
-	commit->object.type = GIT_OBJ_COMMIT;
-
-	git_revpool_table_insert(pool->objects, (git_revpool_object *)commit);
-
-	return commit;
+	return (git_commit *)git_repository_lookup(repo, id, GIT_OBJ_COMMIT);
 }
 
 int git__parse_person(git_person *person, char **buffer_out,
@@ -257,30 +214,31 @@ int git_commit__parse_buffer(git_commit *commit, void *data, size_t len, unsigne
 		return GIT_EOBJCORRUPTED;
 
 	if (parse_flags & GIT_COMMIT_TREE)
-		commit->tree = git_tree_lookup(commit->object.pool, &oid);
+		commit->tree = git_tree_lookup(commit->object.repo, &oid);
 
 	/*
 	 * TODO: commit grafts!
 	 */
 
 	if (parse_flags & GIT_COMMIT_PARENTS)
-		git_commit_list_clear(&commit->parents, 0);
+		clear_parents(commit);
 
 	while (git__parse_oid(&oid, &buffer, buffer_end, "parent ") == 0) {
 		git_commit *parent;
+		git_commit_parents *node;
 
 		if ((parse_flags & GIT_COMMIT_PARENTS) == 0)
 			continue;
 
-		if ((parent = git_commit_lookup(commit->object.pool, &oid)) == NULL)
+		if ((parent = git_commit_lookup(commit->object.repo, &oid)) == NULL)
 			return GIT_ENOTFOUND;
 
-		/* Inherit uninteresting flag */
-		if (commit->uninteresting)
-			parent->uninteresting = 1;
-
-		if (git_commit_list_push_back(&commit->parents, parent) < 0)
+		if ((node = git__malloc(sizeof(git_commit_parents))) == NULL)
 			return GIT_ENOMEM;
+
+		node->commit = parent;
+		node->next = commit->parents;
+		commit->parents = node;
 	}
 
 	if (git__parse_person(&person, &buffer, buffer_end, "author ") < 0)
@@ -391,200 +349,3 @@ const char *git_commit_message_short(git_commit *commit)
 	git_commit__parse(commit, GIT_COMMIT_MESSAGE_SHORT, 0);
 	return commit->message_short;
 }
-
-
-
-int git_commit_list_push_back(git_commit_list *list, git_commit *commit)
-{
-	git_commit_node *node = NULL;
-
-	node = git__malloc(sizeof(git_commit_list));
-
-	if (node == NULL)
-		return GIT_ENOMEM;
-
-	node->commit = commit;
-	node->next = NULL;
-	node->prev = list->tail;
-
-	if (list->tail == NULL) {
-		list->head = list->tail = node;
-	} else {
-		list->tail->next = node;
-		list->tail = node;
-	}
-
-	list->size++;
-	return 0;
-}
-
-int git_commit_list_push_front(git_commit_list *list, git_commit *commit)
-{
-	git_commit_node *node = NULL;
-
-	node = git__malloc(sizeof(git_commit_list));
-
-	if (node == NULL)
-		return GIT_ENOMEM;
-
-	node->commit = commit;
-	node->next = list->head;
-	node->prev = NULL;
-
-	if (list->head == NULL) {
-		list->head = list->tail = node;
-	} else {
-		list->head->prev = node;
-		list->head = node;
-	}
-
-	list->size++;
-	return 0;
-}
-
-
-git_commit *git_commit_list_pop_back(git_commit_list *list)
-{
-	git_commit_node *node;
-	git_commit *commit;
-
-	if (list->tail == NULL)
-		return NULL;
-
-	node = list->tail;
-	list->tail = list->tail->prev;
-	if (list->tail == NULL)
-		list->head = NULL;
-
-	commit = node->commit;
-	free(node);
-
-	list->size--;
-
-	return commit;
-}
-
-git_commit *git_commit_list_pop_front(git_commit_list *list)
-{
-	git_commit_node *node;
-	git_commit *commit;
-
-	if (list->head == NULL)
-		return NULL;
-
-	node = list->head;
-	list->head = list->head->next;
-	if (list->head == NULL)
-		list->tail = NULL;
-
-	commit = node->commit;
-	free(node);
-
-	list->size--;
-
-	return commit;
-}
-
-void git_commit_list_clear(git_commit_list *list, int free_commits)
-{
-	git_commit_node *node, *next_node;
-
-	node = list->head;
-	while (node) {
-		if (free_commits)
-			free(node->commit);
-
-		next_node = node->next;
-		free(node);
-		node = next_node;
-	}
-
-	list->head = list->tail = NULL;
-	list->size = 0;
-}
-
-void git_commit_list_timesort(git_commit_list *list)
-{
-	git_commit_node *p, *q, *e;
-	int in_size, p_size, q_size, merge_count, i;
-
-	if (list->head == NULL)
-		return;
-
-	in_size = 1;
-
-	do {
-		p = list->head;
-		list->tail = NULL;
-		merge_count = 0;
-
-		while (p != NULL) {
-			merge_count++;
-			q = p;
-			p_size = 0;
-			q_size = in_size;
-
-			for (i = 0; i < in_size && q; ++i, q = q->next)
-				p_size++;
-
-			while (p_size > 0 || (q_size > 0 && q)) {
-
-				if (p_size == 0)
-					e = q, q = q->next, q_size--;
-
-				else if (q_size == 0 || q == NULL ||
-						p->commit->commit_time >= q->commit->commit_time)
-					e = p, p = p->next, p_size--;
-
-				else
-					e = q, q = q->next, q_size--;
-
-				if (list->tail != NULL)
-					list->tail->next = e;
-				else
-					list->head = e;
-
-				e->prev = list->tail;
-				list->tail = e;
-			}
-
-			p = q;
-		}
-
-		list->tail->next = NULL;
-		in_size *= 2;
-
-	} while (merge_count > 1);
-}
-
-void git_commit_list_toposort(git_commit_list *list)
-{
-	git_commit *commit;
-	git_commit_list topo;
-	memset(&topo, 0x0, sizeof(git_commit_list));
-
-	while ((commit = git_commit_list_pop_back(list)) != NULL) {
-		git_commit_node *p;
-
-		if (commit->in_degree > 0) {
-			commit->topo_delay = 1;
-			continue;
-		}
-
-		for (p = commit->parents.head; p != NULL; p = p->next) {
-			p->commit->in_degree--;
-
-			if (p->commit->in_degree == 0 && p->commit->topo_delay) {
-				p->commit->topo_delay = 0;
-				git_commit_list_push_back(list, p->commit);
-			}
-		}
-
-		git_commit_list_push_back(&topo, commit);
-	}
-
-	list->head = topo.head;
-	list->tail = topo.tail;
-	list->size = topo.size;
-}
-
diff --git a/src/commit.h b/src/commit.h
index 028c837..60e1d11 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -3,26 +3,10 @@
 
 #include "git/commit.h"
 #include "tree.h"
-#include "revobject.h"
+#include "repository.h"
 
 #include <time.h>
 
-struct git_commit_node {
-	struct git_commit *commit;
-
-	struct git_commit_node *next;
-	struct git_commit_node *prev;
-};
-
-struct git_commit_list {
-	struct git_commit_node *head;
-	struct git_commit_node *tail;
-	size_t size;
-};
-
-typedef struct git_commit_list git_commit_list;
-typedef struct git_commit_node git_commit_node;
-
 #define GIT_COMMIT_TREE		(1 << 1)
 #define GIT_COMMIT_PARENTS	(1 << 2)
 #define GIT_COMMIT_AUTHOR	(1 << 3)
@@ -32,12 +16,17 @@ typedef struct git_commit_node git_commit_node;
 #define GIT_COMMIT_MESSAGE_SHORT (1 << 7)
 #define GIT_COMMIT_FOOTERS	(1 << 8)
 
+typedef struct git_commit_parents {
+	git_commit *commit;
+	struct git_commit_parents *next;
+} git_commit_parents;
+
 struct git_commit {
-	git_revpool_object object;
+	git_repository_object object;
 	git_obj odb_object;
 
 	time_t commit_time;
-	git_commit_list parents;
+	git_commit_parents *parents;
 
 	git_tree *tree;
 	git_person *author;
@@ -46,13 +35,8 @@ struct git_commit {
 	char *message;
 	char *message_short;
 
-	unsigned short in_degree;
 	unsigned basic_parse:1,
-			 odb_open:1,
-			 seen:1,
-			 uninteresting:1,
-			 topo_delay:1,
-			 flags:25;
+			 odb_open:1;
 };
 
 void git_commit__free(git_commit *c);
@@ -64,15 +48,5 @@ void git_commit__mark_uninteresting(git_commit *commit);
 int git__parse_oid(git_oid *oid, char **buffer_out, const char *buffer_end, const char *header);
 int git__parse_person(git_person *person, char **buffer_out, const char *buffer_end, const char *header);
 
-int git_commit_list_push_back(git_commit_list *list, git_commit *commit);
-int git_commit_list_push_front(git_commit_list *list, git_commit *commit);
-
-git_commit *git_commit_list_pop_back(git_commit_list *list);
-git_commit *git_commit_list_pop_front(git_commit_list *list);
-
-void git_commit_list_clear(git_commit_list *list, int free_commits);
-
-void git_commit_list_timesort(git_commit_list *list);
-void git_commit_list_toposort(git_commit_list *list);
 
 #endif
diff --git a/src/git/commit.h b/src/git/commit.h
index 89f0929..56243c5 100644
--- a/src/git/commit.h
+++ b/src/git/commit.h
@@ -4,6 +4,7 @@
 #include "common.h"
 #include "oid.h"
 #include "tree.h"
+#include "repository.h"
 
 /**
  * @file git/commit.h
@@ -18,31 +19,16 @@ GIT_BEGIN_DECL
 typedef struct git_commit git_commit;
 
 /**
- * Locate a reference to a commit without loading it.
+ * Lookup a commit object from a repository.
  * The generated commit object is owned by the revision
- * pool and shall not be freed by the user.
+ * repo and shall not be freed by the user.
  *
- * @param pool the pool to use when locating the commit.
+ * @param repo the repo to use when locating the commit.
  * @param id identity of the commit to locate.  If the object is
  *        an annotated tag it will be peeled back to the commit.
  * @return the commit; NULL if the commit could not be created
  */
-GIT_EXTERN(git_commit *) git_commit_lookup(git_revpool *pool, const git_oid *id);
-
-/**
- * Locate a reference to a commit, and try to load and parse it it from
- * the commit cache or the object database.
- * The generated commit object is owned by the revision
- * pool and shall not be freed by the user.
- *
- * @param pool the pool to use when parsing/caching the commit.
- * @param id identity of the commit to locate.  If the object is
- *        an annotated tag it will be peeled back to the commit.
- * @return the commit; NULL if the commit does not exist in the
- *         pool's git_odb, or if the commit is present but is
- *         too malformed to be parsed successfully.
- */
-GIT_EXTERN(git_commit *) git_commit_parse(git_revpool *pool, const git_oid *id);
+GIT_EXTERN(git_commit *) git_commit_lookup(git_repository *repo, const git_oid *id);
 
 /**
  * Get the id of a commit.
diff --git a/src/git/common.h b/src/git/common.h
index 09972aa..b43f4ee 100644
--- a/src/git/common.h
+++ b/src/git/common.h
@@ -85,8 +85,14 @@
 
 GIT_BEGIN_DECL
 
-/** A revision traversal pool. */
-typedef struct git_revpool git_revpool;
+/** 
+ * Representation of an existing git repository,
+ * including all its object contents 
+ */
+typedef struct git_repository git_repository;
+
+/* Representation of a generic object in a repository */
+typedef struct git_repository_object git_repository_object;
 
 /** Parsed representation of a person */
 typedef struct git_person {
diff --git a/src/git/odb.h b/src/git/odb.h
index 58b9326..5d105ba 100644
--- a/src/git/odb.h
+++ b/src/git/odb.h
@@ -35,6 +35,7 @@ GIT_EXTERN(void) git_odb_close(git_odb *db);
 
 /** Basic type (loose or packed) of any Git object. */
 typedef enum {
+	GIT_OBJ_ANY = -2,		/**< Object can be any of the following */
 	GIT_OBJ_BAD = -1,       /**< Object is invalid. */
 	GIT_OBJ__EXT1 = 0,      /**< Reserved for future use. */
 	GIT_OBJ_COMMIT = 1,     /**< A commit object. */
diff --git a/src/git/repository.h b/src/git/repository.h
new file mode 100644
index 0000000..3b6981d
--- /dev/null
+++ b/src/git/repository.h
@@ -0,0 +1,60 @@
+#ifndef INCLUDE_git_repository_h__
+#define INCLUDE_git_repository_h__
+
+#include "common.h"
+#include "odb.h"
+#include "commit.h"
+
+/**
+ * @file git/repository.h
+ * @brief Git revision object management routines
+ * @defgroup git_repository Git revision object management routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Allocate a new repository object.
+ *
+ * TODO: specify the repository's path instead
+ * of its object database
+ *
+ * @param odb an existing object database to back the repo
+ * @return the new repository handle; NULL on error 
+ */
+GIT_EXTERN(git_repository *) git_repository_alloc(git_odb *odb);
+
+
+/**
+ * Lookup a reference to one of the objects in the repostory.
+ * 
+ * The generated reference is owned by the repository and
+ * should not be freed by the user.
+ * The generated reference should be cast back to the
+ * expected type; e.g.
+ *
+ *	git_commit *c = (git_commit *)
+ *		git_repository_lookup(repo, id, GIT_OBJ_COMMIT);
+ *
+ * The 'type' parameter must match the type of the object
+ * in the odb; the method will fail otherwise.
+ * The special value 'GIT_OBJ_ANY' may be passed to let
+ * the method guess the object's type.
+ *
+ * @param repo the repository to look up the object
+ * @param id the unique identifier for the object
+ * @param type the type of the object
+ * @return a reference to the object
+ */
+GIT_EXTERN(git_repository_object *) git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type);
+
+/**
+ * Free a previously allocated repository
+ * @param repo repository handle to close. If NULL nothing occurs.
+ */
+GIT_EXTERN(void) git_repository_free(git_repository *repo);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/src/git/revwalk.h b/src/git/revwalk.h
index 7aa92d4..842503d 100644
--- a/src/git/revwalk.h
+++ b/src/git/revwalk.h
@@ -15,87 +15,87 @@
 GIT_BEGIN_DECL
 
 /**
- * Sort the revpool contents in no particular ordering;
+ * Sort the repository contents in no particular ordering;
  * this sorting is arbritary, implementation-specific
  * and subject to change at any time.
- * This is the default sorting for new revision pools.
+ * This is the default sorting for new walkers.
  */
-#define GIT_RPSORT_NONE         (0)
+#define GIT_SORT_NONE         (0)
 
 /**
- * Sort the revpool contents in topological order
+ * Sort the repository contents in topological order
  * (parents before children); this sorting mode
  * can be combined with time sorting.
  */
-#define GIT_RPSORT_TOPOLOGICAL  (1 << 0)
+#define GIT_SORT_TOPOLOGICAL  (1 << 0)
 
 /**
- * Sort the revpool contents by commit time;
+ * Sort the repository contents by commit time;
  * this sorting mode can be combined with
  * topological sorting.
  */
-#define GIT_RPSORT_TIME         (1 << 1)
+#define GIT_SORT_TIME         (1 << 1)
 
 /**
- * Iterate through the revpool contents in reverse
+ * Iterate through the repository contents in reverse
  * order; this sorting mode can be combined with
  * any of the above.
  */
-#define GIT_RPSORT_REVERSE      (1 << 2)
+#define GIT_SORT_REVERSE      (1 << 2)
+
+typedef struct git_revwalk git_revwalk;
 
 /**
- * Allocate a new revision traversal pool.
- *
- * The configuration is copied during allocation.  Changes
- * to the configuration after allocation do not affect the pool
- * returned by this function.  Callers may safely free the
- * passed configuration after the function completes.
+ * Allocate a new revision walker to iterate through a repo.
  *
- * @param db the database objects are read from.
- * @return the new traversal handle; NULL if memory is exhausted.
+ * @param repo the repo to walk through
+ * @return the new walker handle; NULL if memory is exhausted.
  */
-GIT_EXTERN(git_revpool *) gitrp_alloc(git_odb *db);
+GIT_EXTERN(git_revwalk *) git_revwalk_alloc(git_repository *repo);
 
 /**
- * Reset the traversal machinary for reuse.
- * @param pool traversal handle to reset.
+ * Reset the walking machinary for reuse.
+ * @param walker handle to reset.
  */
-GIT_EXTERN(void) gitrp_reset(git_revpool *pool);
+GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
 
 /**
- * Mark an object to start traversal from.
- * @param pool the pool being used for the traversal.
+ * Mark a commit to start traversal from.
+ * The commit object must belong to the repo which is being walked through.
+ *
+ * @param walker the walker being used for the traversal.
  * @param commit the commit to start from.
  */
-GIT_EXTERN(int) gitrp_push(git_revpool *pool, git_commit *commit);
+GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, git_commit *commit);
 
 /**
  * Mark a commit (and its ancestors) uninteresting for the output.
- * @param pool the pool being used for the traversal.
+ * @param walker the walker being used for the traversal.
  * @param commit the commit that will be ignored during the traversal
  */
-GIT_EXTERN(int) gitrp_hide(git_revpool *pool, git_commit *commit);
+GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, git_commit *commit);
 
 /**
  * Get the next commit from the revision traversal.
- * @param pool the pool to pop the commit from.
+ * @param walk the walker to pop the commit from.
  * @return next commit; NULL if there is no more output.
  */
-GIT_EXTERN(git_commit *) gitrp_next(git_revpool *pool);
+GIT_EXTERN(git_commit *) git_revwalk_next(git_revwalk *walk);
 
 /**
  * Change the sorting mode when iterating through the
- * revision pool's contents.
- * @param pool the pool being used for the traversal.
+ * repository's contents.
+ * Changing the sorting mode resets the walker.
+ * @param walk the walker being used for the traversal.
  * @param sort_mode combination of GIT_RPSORT_XXX flags
  */
-GIT_EXTERN(void) gitrp_sorting(git_revpool *pool, unsigned int sort_mode);
+GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
 
 /**
  * Free a revwalk previously allocated.
- * @param pool traversal handle to close.  If NULL nothing occurs.
+ * @param walk traversal handle to close.  If NULL nothing occurs.
  */
-GIT_EXTERN(void) gitrp_free(git_revpool *pool);
+GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk);
 
 /** @} */
 GIT_END_DECL
diff --git a/src/git/tag.h b/src/git/tag.h
index 509d2f0..d94083b 100644
--- a/src/git/tag.h
+++ b/src/git/tag.h
@@ -4,6 +4,7 @@
 #include "common.h"
 #include "oid.h"
 #include "tree.h"
+#include "repository.h"
 
 /**
  * @file git/tag.h
@@ -18,29 +19,15 @@ GIT_BEGIN_DECL
 typedef struct git_tag git_tag;
 
 /**
- * Locate a reference to a tag without loading it.
+ * Lookup a tag object from the repository.
  * The generated tag object is owned by the revision
- * pool and shall not be freed by the user.
+ * repo and shall not be freed by the user.
  *
- * @param pool the pool to use when locating the tag.
+ * @param repo the repo to use when locating the tag.
  * @param id identity of the tag to locate.
  * @return the tag; NULL if the tag could not be created
  */
-GIT_EXTERN(git_tag *) git_tag_lookup(git_revpool *pool, const git_oid *id);
-
-/**
- * Locate a reference to a tag, and try to load and parse it it from
- * the object cache or the object database.
- * The generated tag object is owned by the revision
- * pool and shall not be freed by the user.
- *
- * @param pool the pool to use when parsing/caching the tag.
- * @param id identity of the tag to locate.  
- * @return the tag; NULL if the tag does not exist in the
- *         pool's git_odb, or if the tag is present but is
- *         too malformed to be parsed successfully.
- */
-GIT_EXTERN(git_tag *) git_tag_parse(git_revpool *pool, const git_oid *id);
+GIT_EXTERN(git_tag *) git_tag_lookup(git_repository *repo, const git_oid *id);
 
 /**
  * Get the id of a tag.
diff --git a/src/git/tree.h b/src/git/tree.h
index 9a4973b..95b2330 100644
--- a/src/git/tree.h
+++ b/src/git/tree.h
@@ -3,6 +3,7 @@
 
 #include "common.h"
 #include "oid.h"
+#include "repository.h"
 
 /**
  * @file git/tree.h
@@ -17,27 +18,15 @@ GIT_BEGIN_DECL
 typedef struct git_tree git_tree;
 
 /**
- * Locate a reference to a tree without loading it.
+ * Lookup a tree object from the repository.
  * The generated tree object is owned by the revision
- * pool and shall not be freed by the user.
+ * repo and shall not be freed by the user.
  *
- * @param pool the pool to use when locating the tree.
+ * @param repo the repo to use when locating the tree.
  * @param id identity of the tree to locate.
  * @return the tree; NULL if the tree could not be created
  */
-GIT_EXTERN(git_tree *) git_tree_lookup(git_revpool *pool, const git_oid *id);
-
-/**
- * Locate a reference to a tree object and parse its
- * contents.
- * The generated tree object is owned by the revision
- * pool and shall not be freed by the user.
- *
- * @param pool the pool to use when locating the tree.
- * @param id identity of the tree to locate.
- * @return the tree; NULL if the tree could not be created
- */
-GIT_EXTERN(git_tree *) git_tree_parse(git_revpool *pool, const git_oid *id);
+GIT_EXTERN(git_tree *) git_tree_lookup(git_repository *repo, const git_oid *id);
 
 /**
  * Get the id of a tree.
diff --git a/src/hashtable.c b/src/hashtable.c
new file mode 100644
index 0000000..4006a87
--- /dev/null
+++ b/src/hashtable.c
@@ -0,0 +1,218 @@
+/*
+ * 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 "common.h"
+#include "repository.h"
+#include "commit.h"
+
+static const int default_table_size = 32;
+static const double max_load_factor = 0.65;
+
+static void hashtable_resize(git_hashtable *table)
+{
+	git_hashtable_node **new_nodes;
+	unsigned int new_size, i;
+
+	assert(table);
+
+	new_size = (table->size_mask + 1) * 2;
+
+	new_nodes = git__malloc(new_size * sizeof(git_hashtable_node *));
+	if (new_nodes == NULL)
+		return;
+
+	memset(new_nodes, 0x0, new_size * sizeof(git_hashtable_node *));
+
+	for (i = 0; i <= table->size_mask; ++i) {
+		git_hashtable_node *n;
+		unsigned int index;
+
+		while ((n = table->nodes[i]) != NULL) {
+			table->nodes[i] = n->next;
+			index = n->hash & (new_size - 1);
+			n->next = new_nodes[index];
+			new_nodes[index] = n;
+		}
+	}
+
+	free(table->nodes);
+	table->nodes = new_nodes;
+	table->size_mask = (new_size - 1);
+	table->max_count = (unsigned int)(new_size * max_load_factor);
+}
+
+git_hashtable *git_hashtable_alloc(unsigned int min_size, 
+		git_hash_ptr hash,
+		git_hash_keyeq_ptr key_eq)
+{
+	unsigned int i;
+	git_hashtable *table;
+
+	assert(hash && key_eq);
+
+	if ((table = git__malloc(sizeof(git_hashtable))) == NULL)
+		return NULL;
+
+	/* round up size to closest power of 2 */
+	min_size--;
+	min_size |= min_size >> 1;
+	min_size |= min_size >> 2;
+	min_size |= min_size >> 4;
+	min_size |= min_size >> 8;
+	min_size |= min_size >> 16;
+
+	table->size_mask = min_size;
+	table->count = 0;
+	table->max_count = (unsigned int)((min_size + 1) * max_load_factor);
+
+	table->hash = hash;
+	table->key_equal = key_eq;
+
+	table->nodes = git__malloc((min_size + 1) * sizeof(git_hashtable_node *));
+
+	if (table->nodes == NULL) {
+		free(table);
+		return NULL;
+	}
+
+	for (i = 0; i <= min_size; ++i)
+		table->nodes[i] = NULL;
+
+	return table;
+}
+
+void git_hashtable_clear(git_hashtable *table)
+{
+	unsigned int index;
+
+	assert(table);
+
+	for (index = 0; index <= table->size_mask; ++index) {
+		git_hashtable_node *node, *next_node;
+
+		node = table->nodes[index];
+		while (node != NULL) {
+			next_node = node->next;
+			free(node);
+			node = next_node;
+		}
+
+		table->nodes[index] = NULL;
+	}
+
+	table->count = 0;
+}
+
+void git_hashtable_free(git_hashtable *table)
+{
+	assert(table);
+
+	git_hashtable_clear(table);
+	free(table->nodes);
+	free(table);
+}
+
+
+int git_hashtable_insert(git_hashtable *table, const void *key, void *value)
+{
+	git_hashtable_node *node;
+	uint32_t index, hash;
+
+	assert(table);
+
+	if (table->count + 1 > table->max_count)
+		hashtable_resize(table);
+
+	node = git__malloc(sizeof(git_hashtable_node));
+	if (node == NULL)
+		return GIT_ENOMEM;
+
+	hash = table->hash(key);
+	index = (hash & table->size_mask);
+
+	node->object = value;
+	node->hash = hash;
+	node->next = table->nodes[index];
+
+	table->nodes[index] = node;
+	table->count++;
+
+	return GIT_SUCCESS;
+}
+
+void *git_hashtable_lookup(git_hashtable *table, const void *key)
+{
+	git_hashtable_node *node;
+	uint32_t index, hash;
+
+	assert(table);
+
+	hash = table->hash(key);
+	index = (hash & table->size_mask);
+	node = table->nodes[index];
+
+	while (node != NULL) {
+		if (node->hash == hash && table->key_equal(node->object, key))
+			return node->object;
+
+		node = node->next;
+	}
+
+	return NULL;
+}
+
+
+
+void git_hashtable_iterator_init(git_hashtable *table, git_hashtable_iterator *it)
+{
+	assert(table && it);
+
+	memset(it, 0x0, sizeof(git_hashtable_iterator));
+
+	it->nodes = table->nodes;
+	it->current_node = NULL;
+	it->current_pos = 0;
+	it->size = table->size_mask + 1;
+}
+
+void *git_hashtable_iterator_next(git_hashtable_iterator *it)
+{
+	git_hashtable_node *next = NULL;
+
+	assert(it);
+
+	while (it->current_node == NULL) {
+		if (it->current_pos >= it->size)
+			return NULL;
+
+		it->current_node = it->nodes[it->current_pos++];
+	}
+
+	next = it->current_node;
+	it->current_node = it->current_node->next;
+
+	return next->object;
+}
+
diff --git a/src/hashtable.h b/src/hashtable.h
new file mode 100644
index 0000000..622a260
--- /dev/null
+++ b/src/hashtable.h
@@ -0,0 +1,51 @@
+#ifndef INCLUDE_hashtable_h__
+#define INCLUDE_hashtable_h__
+
+#include "git/common.h"
+#include "git/oid.h"
+#include "git/odb.h"
+
+
+typedef uint32_t (*git_hash_ptr)(const void *);
+typedef int (*git_hash_keyeq_ptr)(void *obj, const void *obj_key);
+
+struct git_hashtable_node {
+	void *object;
+	uint32_t hash;
+	struct git_hashtable_node *next;
+};
+
+struct git_hashtable {
+	struct git_hashtable_node **nodes;
+
+	unsigned int size_mask;
+	unsigned int count;
+	unsigned int max_count;
+
+	git_hash_ptr hash;
+	git_hash_keyeq_ptr key_equal;
+};
+
+struct git_hashtable_iterator {
+	struct git_hashtable_node **nodes;
+	struct git_hashtable_node *current_node;
+	unsigned int current_pos;
+	unsigned int size;
+};
+
+typedef struct git_hashtable_node git_hashtable_node;
+typedef struct git_hashtable git_hashtable;
+typedef struct git_hashtable_iterator git_hashtable_iterator;
+
+git_hashtable *git_hashtable_alloc(unsigned int min_size, 
+		git_hash_ptr hash,
+		git_hash_keyeq_ptr key_eq);
+int git_hashtable_insert(git_hashtable *h, const void *key, void *value);
+void *git_hashtable_lookup(git_hashtable *h, const void *key);
+void git_hashtable_free(git_hashtable *h);
+void git_hashtable_clear(git_hashtable *h);
+
+void *git_hashtable_iterator_next(git_hashtable_iterator *it);
+void git_hashtable_iterator_init(git_hashtable *h, git_hashtable_iterator *it);
+
+#endif
diff --git a/src/repository.c b/src/repository.c
new file mode 100644
index 0000000..dd5b5f7
--- /dev/null
+++ b/src/repository.c
@@ -0,0 +1,143 @@
+/*
+ * 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 "common.h"
+#include "repository.h"
+#include "commit.h"
+#include "tag.h"
+
+static const int default_table_size = 32;
+static const double max_load_factor = 0.65;
+
+uint32_t git_repository_object_hash(const void *key)
+{
+	uint32_t r;
+	git_oid *id;
+
+	id = (git_oid *)key;
+	memcpy(&r, id->id, sizeof(r));
+	return r;
+}
+
+int git_repository_object_haskey(void *object, const void *key)
+{
+	git_repository_object *obj;
+	git_oid *oid;
+
+	obj = (git_repository_object *)object;
+	oid = (git_oid *)key;
+
+	return (git_oid_cmp(oid, &obj->id) == 0);
+}
+
+git_repository *git_repository_alloc(git_odb *odb)
+{
+	git_repository *repo = git__malloc(sizeof(git_repository));
+	if (!repo)
+		return NULL;
+
+	memset(repo, 0x0, sizeof(git_repository));
+
+	repo->objects = git_hashtable_alloc(
+			default_table_size, 
+			git_repository_object_hash,
+			git_repository_object_haskey);
+
+	if (repo->objects == NULL) {
+		free(repo);
+		return NULL;
+	}
+
+	repo->db = odb; /* TODO: create ODB manually! */
+
+	return repo;
+}
+
+void git_repository_free(git_repository *repo)
+{
+	git_hashtable_iterator it;
+	git_repository_object *object;
+
+	git_hashtable_iterator_init(repo->objects, &it);
+
+	while ((object = (git_repository_object *)
+				git_hashtable_iterator_next(&it)) != NULL) {
+	
+		switch (object->type) {
+		case GIT_OBJ_COMMIT:
+			git_commit__free((git_commit *)object);
+			break;
+
+		case GIT_OBJ_TREE:
+			git_tree__free((git_tree *)object);
+			break;
+
+		case GIT_OBJ_TAG:
+			git_tag__free((git_tag *)object);
+			break;
+
+		default:
+			free(object);
+			break;
+		}
+	}
+
+	git_hashtable_free(repo->objects);
+	/* TODO: free odb */
+	free(repo);
+}
+
+git_repository_object *git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type)
+{
+	git_repository_object *object = NULL;
+	git_obj obj_file;
+
+	assert(repo);
+
+	object = git_hashtable_lookup(repo->objects, id);
+	if (object != NULL)
+		return object;
+
+	if (git_odb_read(&obj_file, repo->db, id) < 0 ||
+		(type != GIT_OBJ_ANY && type != obj_file.type))
+		return NULL;
+
+	object = git__malloc(sizeof(git_commit));
+
+	if (object == NULL)
+		return NULL;
+
+	memset(object, 0x0, sizeof(git_commit));
+
+	/* Initialize parent object */
+	git_oid_cpy(&object->id, id);
+	object->repo = repo;
+	object->type = obj_file.type;
+
+	git_hashtable_insert(repo->objects, &object->id, object);
+	git_obj_close(&obj_file);
+
+	return object;
+}
diff --git a/src/repository.h b/src/repository.h
new file mode 100644
index 0000000..5db5987
--- /dev/null
+++ b/src/repository.h
@@ -0,0 +1,25 @@
+#ifndef INCLUDE_repository_h__
+#define INCLUDE_repository_h__
+
+#include "git/common.h"
+#include "git/oid.h"
+#include "git/odb.h"
+#include "git/repository.h"
+
+#include "hashtable.h"
+
+struct git_repository_object {
+	git_oid id;
+	git_repository *repo;
+	git_otype type;
+};
+
+struct git_repository {
+	git_odb *db;
+	git_hashtable *objects;
+};
+
+int git_repository__insert(git_repository *repo, git_repository_object *obj);
+git_repository_object *git_repository__lookup(git_repository *repo, const git_oid *id);
+
+#endif
diff --git a/src/revobject.c b/src/revobject.c
deleted file mode 100644
index 47d75e0..0000000
--- a/src/revobject.c
+++ /dev/null
@@ -1,210 +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 "common.h"
-#include "revobject.h"
-
-static const double max_load_factor = 0.65;
-
-static unsigned int git_revpool_table__hash(const git_oid *id)
-{
-	unsigned int r;
-	memcpy(&r, id->id, sizeof(r));
-	return r;
-}
-
-git_revpool_table *git_revpool_table_create(unsigned int min_size)
-{
-	git_revpool_table *table;
-	unsigned int i;
-
-	table = git__malloc(sizeof(*table));
-
-	if (table == NULL)
-		return NULL;
-
-	/* round up size to closest power of 2 */
-	min_size--;
-	min_size |= min_size >> 1;
-	min_size |= min_size >> 2;
-	min_size |= min_size >> 4;
-	min_size |= min_size >> 8;
-	min_size |= min_size >> 16;
-
-	table->size_mask = min_size;
-	table->count = 0;
-	table->max_count = (unsigned int)((min_size + 1) * max_load_factor);
-
-	table->nodes = git__malloc((min_size + 1) * sizeof(git_revpool_node *));
-
-	if (table->nodes == NULL) {
-		free(table);
-		return NULL;
-	}
-
-	for (i = 0; i <= min_size; ++i)
-		table->nodes[i] = NULL;
-
-	return table;
-}
-
-int git_revpool_table_insert(git_revpool_table *table, git_revpool_object *object)
-{
-	git_revpool_node *node;
-	unsigned int index, hash;
-
-	if (table == NULL)
-		return GIT_ERROR;
-
-	if (table->count + 1 > table->max_count)
-		git_revpool_table_resize(table);
-
-	node = git__malloc(sizeof(git_revpool_node));
-	if (node == NULL)
-		return GIT_ENOMEM;
-
-	hash = git_revpool_table__hash(&object->id);
-	index = (hash & table->size_mask);
-
-	node->object = object;
-	node->hash = hash;
-	node->next = table->nodes[index];
-
-	table->nodes[index] = node;
-	table->count++;
-
-	return 0;
-}
-
-git_revpool_object *git_revpool_table_lookup(git_revpool_table *table, const git_oid *id)
-{
-	git_revpool_node *node;
-	unsigned int index, hash;
-
-	if (table == NULL)
-		return NULL;
-
-	hash = git_revpool_table__hash(id);
-	index = (hash & table->size_mask);
-	node = table->nodes[index];
-
-	while (node != NULL) {
-		if (node->hash == hash && git_oid_cmp(id, &node->object->id) == 0)
-			return node->object;
-
-		node = node->next;
-	}
-
-	return NULL;
-}
-
-void git_revpool_table_resize(git_revpool_table *table)
-{
-	git_revpool_node **new_nodes;
-	unsigned int new_size, i;
-
-	new_size = (table->size_mask + 1) * 2;
-
-	new_nodes = git__malloc(new_size * sizeof(git_revpool_node *));
-	if (new_nodes == NULL)
-		return;
-
-	memset(new_nodes, 0x0, new_size * sizeof(git_revpool_node *));
-
-	for (i = 0; i <= table->size_mask; ++i) {
-		git_revpool_node *n;
-		unsigned int index;
-
-		while ((n = table->nodes[i]) != NULL) {
-			table->nodes[i] = n->next;
-			index = n->hash & (new_size - 1);
-			n->next = new_nodes[index];
-			new_nodes[index] = n;
-		}
-	}
-
-	free(table->nodes);
-	table->nodes = new_nodes;
-	table->size_mask = (new_size - 1);
-	table->max_count = (unsigned int)(new_size * max_load_factor);
-}
-
-
-void git_revpool_table_free(git_revpool_table *table)
-{
-	unsigned int index;
-
-	for (index = 0; index <= table->size_mask; ++index) {
-		git_revpool_node *node, *next_node;
-
-		node = table->nodes[index];
-		while (node != NULL) {
-			next_node = node->next;
-			free(node);
-			node = next_node;
-		}
-	}
-
-	free(table->nodes);
-	free(table);
-}
-
-void git_revpool_tableit_init(git_revpool_table *table, git_revpool_tableit *it)
-{
-	memset(it, 0x0, sizeof(git_revpool_tableit));
-
-	it->nodes = table->nodes;
-	it->current_node = NULL;
-	it->current_pos = 0;
-	it->size = table->size_mask + 1;
-}
-
-git_revpool_object *git_revpool_tableit_next(git_revpool_tableit *it)
-{
-	git_revpool_node *next = NULL;
-
-	while (it->current_node == NULL) {
-		if (it->current_pos >= it->size)
-			return NULL;
-
-		it->current_node = it->nodes[it->current_pos++];
-	}
-
-	next = it->current_node;
-	it->current_node = it->current_node->next;
-
-	return next->object;
-}
-
-git_revpool_object *git_revpool_tableit_nextfilter(git_revpool_tableit *it, git_otype type)
-{
-	git_revpool_object *obj;
-
-	do {
-		obj = git_revpool_tableit_next(it);
-	} while (obj != NULL && obj->type != type);
-
-	return obj;
-}
diff --git a/src/revobject.h b/src/revobject.h
deleted file mode 100644
index d76d8a6..0000000
--- a/src/revobject.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef INCLUDE_objecttable_h__
-#define INCLUDE_objecttable_h__
-
-#include "git/common.h"
-#include "git/oid.h"
-#include "git/odb.h"
-
-struct git_revpool_object {
-	git_oid id;
-	git_revpool *pool;
-	git_otype type;
-};
-
-struct git_revpool_node {
-	struct git_revpool_object *object;
-	unsigned int hash;
-	struct git_revpool_node *next;
-};
-
-struct git_revpool_table {
-	struct git_revpool_node **nodes;
-
-	unsigned int size_mask;
-	unsigned int count;
-	unsigned int max_count;
-};
-
-struct git_revpool_tableit {
-	struct git_revpool_node **nodes;
-	struct git_revpool_node *current_node;
-	unsigned int current_pos;
-	unsigned int size;
-};
-
-
-typedef struct git_revpool_node git_revpool_node;
-typedef struct git_revpool_object git_revpool_object;
-typedef struct git_revpool_table git_revpool_table;
-typedef struct git_revpool_tableit git_revpool_tableit;
-
-git_revpool_table *git_revpool_table_create(unsigned int min_size);
-int git_revpool_table_insert(git_revpool_table *table, git_revpool_object *object);
-git_revpool_object *git_revpool_table_lookup(git_revpool_table *table, const git_oid *id);
-void git_revpool_table_resize(git_revpool_table *table);
-void git_revpool_table_free(git_revpool_table *table);
-
-
-git_revpool_object *git_revpool_tableit_next(git_revpool_tableit *it);
-git_revpool_object *git_revpool_tableit_nextfilter(git_revpool_tableit *it, git_otype type);
-void git_revpool_tableit_init(git_revpool_table *table, git_revpool_tableit *it);
-
-#endif
diff --git a/src/revwalk.c b/src/revwalk.c
index d4627ae..ca00884 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -26,187 +26,417 @@
 #include "common.h"
 #include "commit.h"
 #include "revwalk.h"
+#include "hashtable.h"
 
-static const int default_table_size = 32;
+uint32_t git_revwalk_commit_hash(const void *key)
+{
+	uint32_t r;
+	git_commit *commit;
 
-git_revpool *gitrp_alloc(git_odb *db)
+	commit = (git_commit *)key;
+	memcpy(&r, commit->object.id.id, sizeof(r));
+	return r;
+}
+
+int git_revwalk_commit_haskey(void *object, const void *key)
 {
-	git_revpool *walk = git__malloc(sizeof(*walk));
-	if (!walk)
+	git_revwalk_commit *walk_commit;
+	git_commit *commit_object;
+
+	walk_commit = (git_revwalk_commit *)object;
+	commit_object = (git_commit *)key;
+
+	return (walk_commit->commit_object == commit_object);
+}
+
+
+git_revwalk *git_revwalk_alloc(git_repository *repo)
+{
+	git_revwalk *walk;
+
+	walk = git__malloc(sizeof(git_revwalk));
+	if (walk == NULL)
 		return NULL;
 
-	memset(walk, 0x0, sizeof(git_revpool));
+	memset(walk, 0x0, sizeof(git_revwalk));
 
-	walk->objects = git_revpool_table_create(default_table_size);
+	walk->commits = git_hashtable_alloc(64,
+			git_revwalk_commit_hash,
+			git_revwalk_commit_haskey);
+
+	if (walk->commits == NULL) {
+		free(walk);
+		return NULL;
+	}
 
-	walk->db = db;
+	walk->repo = repo;
 	return walk;
 }
 
-void gitrp_free(git_revpool *walk)
+void git_revwalk_free(git_revwalk *walk)
 {
-	git_revpool_object *obj;
-	git_revpool_tableit it;
+	git_revwalk_reset(walk);
+	git_hashtable_free(walk->commits);
+	free(walk);
+}
 
-	git_commit_list_clear(&(walk->iterator), 0);
-	git_commit_list_clear(&(walk->roots), 0);
+void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
+{
+	if (walk->walking)
+		return;
 
-	git_revpool_tableit_init(walk->objects, &it);
+	walk->sorting = sort_mode;
+	git_revwalk_reset(walk);
+}
 
-	while ((obj = git_revpool_tableit_next(&it)) != NULL) {
-		switch (obj->type) {
+static git_revwalk_commit *commit_to_walkcommit(git_revwalk *walk, git_commit *commit_object)
+{
+	git_revwalk_commit *commit;
 
-		case GIT_OBJ_COMMIT:
-			git_commit__free((git_commit *)obj);
-			break;
+	commit = (git_revwalk_commit *)git_hashtable_lookup(walk->commits, commit_object);
 
-		case GIT_OBJ_TREE:
-			git_tree__free((git_tree *)obj);
-			break;
+	if (commit != NULL)
+		return commit;
 
-		default:
-			free(obj);
-			break;
-		}
+	if (!commit_object->basic_parse) {
+		if (git_commit__parse_basic(commit_object) < 0)
+			return NULL;
 	}
 
-	git_revpool_table_free(walk->objects);
+	commit = git__malloc(sizeof(git_revwalk_commit));
+	if (commit == NULL)
+		return NULL;
 
-	free(walk);
+	memset(commit, 0x0, sizeof(git_revwalk_commit));
+
+	commit->commit_object = commit_object;
+
+	git_hashtable_insert(walk->commits, commit_object, commit);
+
+	return commit;
 }
 
-void gitrp_sorting(git_revpool *pool, unsigned int sort_mode)
+static git_revwalk_commit *insert_commit(git_revwalk *walk, git_commit *commit_object)
 {
-	if (pool->walking)
-		return;
+	git_revwalk_commit *commit;
+	git_commit_parents *parents;
+
+	assert(walk && commit_object);
+
+	if (commit_object->object.repo != walk->repo || walk->walking)
+		return NULL;
+
+	commit = commit_to_walkcommit(walk, commit_object);
+	if (commit == NULL)
+		return NULL;
 
-	pool->sorting = sort_mode;
-	gitrp_reset(pool);
+	if (commit->seen)
+		return commit;
+
+	commit->seen = 1;
+
+	assert(commit->commit_object->basic_parse);
+
+	for (parents = commit->commit_object->parents; parents != NULL; parents = parents->next) {
+		git_revwalk_commit *parent;
+
+		if ((parent = commit_to_walkcommit(walk, parents->commit)) == NULL)
+			return NULL;
+
+		parent = insert_commit(walk, parents->commit);
+		if (parent == NULL)
+			return NULL;
+
+		parent->in_degree++;
+
+		git_revwalk_list_push_back(&commit->parents, parent);
+	}
+
+	if (git_revwalk_list_push_back(&walk->iterator, commit))
+		return NULL;
+
+	return commit;
 }
 
-int gitrp_push(git_revpool *pool, git_commit *commit)
+int git_revwalk_push(git_revwalk *walk, git_commit *commit)
 {
-	if (commit == NULL || commit->seen)
-		return GIT_ENOTFOUND;
+	return insert_commit(walk, commit) ? GIT_SUCCESS : GIT_ERROR;
+}
 
-	if (commit->object.pool != pool || pool->walking)
-		return GIT_ERROR;
+static void mark_uninteresting(git_revwalk_commit *commit)
+{
+	git_revwalk_listnode *parent;
+
+	if (commit == NULL)
+		return;
 
-	if (!commit->basic_parse) {
-		int error = git_commit__parse_basic(commit);
+	commit->uninteresting = 1;
+	parent = commit->parents.head;
 
-		if (error < 0)
-			return error;
+	while (parent) {
+		mark_uninteresting(parent->walk_commit);
+		parent = parent->next;
 	}
+}
+
+int git_revwalk_hide(git_revwalk *walk, git_commit *commit)
+{
+	git_revwalk_commit *hide;
+	
+	hide = insert_commit(walk, commit);
+	if (hide == NULL)
+		return GIT_ERROR;
 
-	/*
-	 * Sanity check: make sure that if the commit
-	 * has been manually marked as uninteresting,
-	 * all the parent commits are too.
-	 */
-	if (commit->uninteresting)
-		git_commit__mark_uninteresting(commit);
+	mark_uninteresting(hide);
+	return GIT_SUCCESS;
+}
 
-	if (git_commit_list_push_back(&pool->roots, commit) < 0)
-		return GIT_ENOMEM;
 
-	return 0;
+static void prepare_walk(git_revwalk *walk)
+{
+	if (walk->sorting & GIT_SORT_TIME)
+		git_revwalk_list_timesort(&walk->iterator);
+
+	if (walk->sorting & GIT_SORT_TOPOLOGICAL)
+		git_revwalk_list_toposort(&walk->iterator);
+
+	if (walk->sorting & GIT_SORT_REVERSE)
+		walk->next = &git_revwalk_list_pop_back;
+	else
+		walk->next = &git_revwalk_list_pop_front;
+
+	walk->walking = 1;
 }
 
-int gitrp_hide(git_revpool *pool, git_commit *commit)
+git_commit *git_revwalk_next(git_revwalk *walk)
 {
-	if (pool->walking)
-		return GIT_ERROR;
+	git_revwalk_commit *next;
 
-	git_commit__mark_uninteresting(commit);
-	return gitrp_push(pool, commit);
+	if (!walk->walking)
+		prepare_walk(walk);
+
+	while ((next = walk->next(&walk->iterator)) != NULL) {
+		if (!next->uninteresting)
+			return next->commit_object;
+	}
+
+	/* No commits left to iterate */
+	git_revwalk_reset(walk);
+	return NULL;
 }
 
-int gitrp__enroot(git_revpool *pool, git_commit *commit)
+void git_revwalk_reset(git_revwalk *walk)
 {
-	int error;
-	git_commit_node *parents;
+	git_hashtable_iterator it;
+	git_revwalk_commit *commit;
 
-	if (commit->seen)
-		return 0;
+	git_hashtable_iterator_init(walk->commits, &it);
 
-	if (!commit->basic_parse) {
-		error = git_commit__parse_basic(commit);
-		if (error < 0)
-			return error;
+	while ((commit = (git_revwalk_commit *)
+				git_hashtable_iterator_next(&it)) != NULL) {
+		git_revwalk_list_clear(&commit->parents);
+		free(commit);
 	}
 
-	commit->seen = 1;
+	git_hashtable_clear(walk->commits);
+	git_revwalk_list_clear(&walk->iterator);
+	walk->walking = 0;
+}
+
+
+
+
+
+
+int git_revwalk_list_push_back(git_revwalk_list *list, git_revwalk_commit *commit)
+{
+	git_revwalk_listnode *node = NULL;
+
+	node = git__malloc(sizeof(git_revwalk_listnode));
+
+	if (node == NULL)
+		return GIT_ENOMEM;
 
-	for (parents = commit->parents.head; parents != NULL; parents = parents->next) {
-		parents->commit->in_degree++;
+	node->walk_commit = commit;
+	node->next = NULL;
+	node->prev = list->tail;
 
-		error = gitrp__enroot(pool, parents->commit);
-		if (error < 0)
-			return error;
+	if (list->tail == NULL) {
+		list->head = list->tail = node;
+	} else {
+		list->tail->next = node;
+		list->tail = node;
 	}
 
-	if (git_commit_list_push_back(&pool->iterator, commit))
+	list->size++;
+	return 0;
+}
+
+int git_revwalk_list_push_front(git_revwalk_list *list, git_revwalk_commit *commit)
+{
+	git_revwalk_listnode *node = NULL;
+
+	node = git__malloc(sizeof(git_revwalk_listnode));
+
+	if (node == NULL)
 		return GIT_ENOMEM;
 
+	node->walk_commit = commit;
+	node->next = list->head;
+	node->prev = NULL;
+
+	if (list->head == NULL) {
+		list->head = list->tail = node;
+	} else {
+		list->head->prev = node;
+		list->head = node;
+	}
+
+	list->size++;
 	return 0;
 }
 
-void gitrp__prepare_walk(git_revpool *pool)
+
+git_revwalk_commit *git_revwalk_list_pop_back(git_revwalk_list *list)
 {
-	git_commit_node *it;
+	git_revwalk_listnode *node;
+	git_revwalk_commit *commit;
 
-	for (it = pool->roots.head; it != NULL; it = it->next)
-		gitrp__enroot(pool, it->commit);
+	if (list->tail == NULL)
+		return NULL;
 
-	if (pool->sorting & GIT_RPSORT_TIME)
-		git_commit_list_timesort(&pool->iterator);
+	node = list->tail;
+	list->tail = list->tail->prev;
+	if (list->tail == NULL)
+		list->head = NULL;
 
-	if (pool->sorting & GIT_RPSORT_TOPOLOGICAL)
-		git_commit_list_toposort(&pool->iterator);
+	commit = node->walk_commit;
+	free(node);
 
-	if (pool->sorting & GIT_RPSORT_REVERSE)
-		pool->next_commit = &git_commit_list_pop_back;
-	else
-		pool->next_commit = &git_commit_list_pop_front;
+	list->size--;
 
-	pool->walking = 1;
+	return commit;
 }
 
-git_commit *gitrp_next(git_revpool *pool)
+git_revwalk_commit *git_revwalk_list_pop_front(git_revwalk_list *list)
 {
-	git_commit *next;
+	git_revwalk_listnode *node;
+	git_revwalk_commit *commit;
+
+	if (list->head == NULL)
+		return NULL;
 
-	if (!pool->walking)
-		gitrp__prepare_walk(pool);
+	node = list->head;
+	list->head = list->head->next;
+	if (list->head == NULL)
+		list->tail = NULL;
 
-	while ((next = pool->next_commit(&pool->iterator)) != NULL) {
-		if (!next->uninteresting)
-			return next;
+	commit = node->walk_commit;
+	free(node);
+
+	list->size--;
+
+	return commit;
+}
+
+void git_revwalk_list_clear(git_revwalk_list *list)
+{
+	git_revwalk_listnode *node, *next_node;
+
+	node = list->head;
+	while (node) {
+		next_node = node->next;
+		free(node);
+		node = next_node;
 	}
 
-	/* No commits left to iterate */
-	gitrp_reset(pool);
-	return NULL;
+	list->head = list->tail = NULL;
+	list->size = 0;
 }
 
-void gitrp_reset(git_revpool *pool)
+void git_revwalk_list_timesort(git_revwalk_list *list)
 {
-	git_commit *commit;
-	git_revpool_tableit it;
+	git_revwalk_listnode *p, *q, *e;
+	int in_size, p_size, q_size, merge_count, i;
+
+	if (list->head == NULL)
+		return;
+
+	in_size = 1;
+
+	do {
+		p = list->head;
+		list->tail = NULL;
+		merge_count = 0;
+
+		while (p != NULL) {
+			merge_count++;
+			q = p;
+			p_size = 0;
+			q_size = in_size;
+
+			for (i = 0; i < in_size && q; ++i, q = q->next)
+				p_size++;
+
+			while (p_size > 0 || (q_size > 0 && q)) {
 
-	git_revpool_tableit_init(pool->objects, &it);
+				if (p_size == 0)
+					e = q, q = q->next, q_size--;
 
-	while ((commit =
-			(git_commit *)git_revpool_tableit_nextfilter(
-				&it, GIT_OBJ_COMMIT)) != NULL) {
+				else if (q_size == 0 || q == NULL ||
+						p->walk_commit->commit_object->commit_time >= 
+						q->walk_commit->commit_object->commit_time)
+					e = p, p = p->next, p_size--;
+
+				else
+					e = q, q = q->next, q_size--;
+
+				if (list->tail != NULL)
+					list->tail->next = e;
+				else
+					list->head = e;
+
+				e->prev = list->tail;
+				list->tail = e;
+			}
+
+			p = q;
+		}
+
+		list->tail->next = NULL;
+		in_size *= 2;
+
+	} while (merge_count > 1);
+}
+
+void git_revwalk_list_toposort(git_revwalk_list *list)
+{
+	git_revwalk_commit *commit;
+	git_revwalk_list topo;
+	memset(&topo, 0x0, sizeof(git_revwalk_list));
+
+	while ((commit = git_revwalk_list_pop_back(list)) != NULL) {
+		git_revwalk_listnode *p;
+
+		if (commit->in_degree > 0) {
+			commit->topo_delay = 1;
+			continue;
+		}
+
+		for (p = commit->parents.head; p != NULL; p = p->next) {
+			p->walk_commit->in_degree--;
+
+			if (p->walk_commit->in_degree == 0 && p->walk_commit->topo_delay) {
+				p->walk_commit->topo_delay = 0;
+				git_revwalk_list_push_back(list, p->walk_commit);
+			}
+		}
 
-		commit->seen = 0;
-		commit->topo_delay = 0;
-		commit->in_degree = 0;
+		git_revwalk_list_push_back(&topo, commit);
 	}
 
-	git_commit_list_clear(&pool->iterator, 0);
-	pool->walking = 0;
+	list->head = topo.head;
+	list->tail = topo.tail;
+	list->size = topo.size;
 }
 
diff --git a/src/revwalk.h b/src/revwalk.h
index 270eb8c..d97e5ce 100644
--- a/src/revwalk.h
+++ b/src/revwalk.h
@@ -5,21 +5,63 @@
 #include "git/revwalk.h"
 
 #include "commit.h"
+#include "repository.h"
+#include "hashtable.h"
 
-struct git_revpool {
-	git_odb *db;
+struct git_revwalk_commit;
 
-	git_commit_list iterator;
-	git_commit *(*next_commit)(git_commit_list *);
+typedef struct git_revwalk_listnode {
+	struct git_revwalk_commit *walk_commit;
+	struct git_revwalk_listnode *next;
+	struct git_revwalk_listnode *prev;
+} git_revwalk_listnode;
 
-	git_commit_list roots;
-	git_revpool_table *objects;
+typedef struct git_revwalk_list {
+	struct git_revwalk_listnode *head;
+	struct git_revwalk_listnode *tail;
+	size_t size;
+} git_revwalk_list;
+
+
+struct git_revwalk_commit {
+
+	git_commit *commit_object;
+	git_revwalk_list parents;
+
+	unsigned short in_degree;
+	unsigned seen:1,
+			 uninteresting:1,
+			 topo_delay:1,
+			 flags:25;
+};
+
+typedef struct git_revwalk_commit git_revwalk_commit;
+
+struct git_revwalk {
+	git_repository *repo;
+
+	git_hashtable *commits;
+	git_revwalk_list iterator;
+
+	git_revwalk_commit *(*next)(git_revwalk_list *);
 
 	unsigned walking:1;
 	unsigned int sorting;
 };
 
-void gitrp__prepare_walk(git_revpool *pool);
-int gitrp__enroot(git_revpool *pool, git_commit *commit);
+
+void git_revwalk__prepare_walk(git_revwalk *walk);
+int git_revwalk__enroot(git_revwalk *walk, git_commit *commit);
+
+int git_revwalk_list_push_back(git_revwalk_list *list, git_revwalk_commit *commit);
+int git_revwalk_list_push_front(git_revwalk_list *list, git_revwalk_commit *obj);
+
+git_revwalk_commit *git_revwalk_list_pop_back(git_revwalk_list *list);
+git_revwalk_commit *git_revwalk_list_pop_front(git_revwalk_list *list);
+
+void git_revwalk_list_clear(git_revwalk_list *list);
+
+void git_revwalk_list_timesort(git_revwalk_list *list);
+void git_revwalk_list_toposort(git_revwalk_list *list);
 
 #endif /* INCLUDE_revwalk_h__ */
diff --git a/src/tag.c b/src/tag.c
index 803cfa1..ea2e4e7 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -28,7 +28,7 @@
 #include "tag.h"
 #include "revwalk.h"
 #include "git/odb.h"
-
+#include "git/repository.h"
 
 void git_tag__free(git_tag *tag)
 {
@@ -43,7 +43,7 @@ const git_oid *git_tag_id(git_tag *t)
 	return &t->object.id;
 }
 
-const git_revpool_object *git_tag_target(git_tag *t)
+const git_repository_object *git_tag_target(git_tag *t)
 {
 	if (t->target)
 		return t->target;
@@ -183,7 +183,7 @@ int git_tag__parse(git_tag *tag)
 	int error = 0;
 	git_obj odb_object;
 
-	error = git_odb_read(&odb_object, tag->object.pool->db, &tag->object.id);
+	error = git_odb_read(&odb_object, tag->object.repo->db, &tag->object.id);
 	if (error < 0)
 		return error;
 
@@ -199,30 +199,7 @@ cleanup:
 	return error;
 }
 
-git_tag *git_tag_lookup(git_revpool *pool, const git_oid *id)
+git_tag *git_tag_lookup(git_repository *repo, const git_oid *id)
 {
-	git_tag *tag = NULL;
-
-	if (pool == NULL)
-		return NULL;
-
-	tag = (git_tag *)git_revpool_table_lookup(pool->objects, id);
-	if (tag != NULL)
-		return tag;
-
-	tag = git__malloc(sizeof(git_tag));
-
-	if (tag == NULL)
-		return NULL;
-
-	memset(tag, 0x0, sizeof(git_tag));
-
-	/* Initialize parent object */
-	git_oid_cpy(&tag->object.id, id);
-	tag->object.pool = pool;
-	tag->object.type = GIT_OBJ_TAG;
-
-	git_revpool_table_insert(pool->objects, (git_revpool_object *)tag);
-
-	return tag;
+	return (git_tag *)git_repository_lookup(repo, id, GIT_OBJ_TAG);
 }
diff --git a/src/tag.h b/src/tag.h
index 5b1f5e2..df03e2a 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -2,12 +2,12 @@
 #define INCLUDE_tag_h__
 
 #include "git/tag.h"
-#include "revobject.h"
+#include "repository.h"
 
 struct git_tag {
-	git_revpool_object object;
+	git_repository_object object;
 
-	git_revpool_object *target;
+	git_repository_object *target;
 	git_otype type;
 	char *tag_name;
 	git_person *tagger;
diff --git a/src/tree.c b/src/tree.c
index 47b0273..15603e7 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -27,6 +27,7 @@
 #include "commit.h"
 #include "revwalk.h"
 #include "tree.h"
+#include "git/repository.h"
 
 void git_tree__free(git_tree *tree)
 {
@@ -38,51 +39,9 @@ const git_oid *git_tree_id(git_tree *tree)
 	return &tree->object.id;
 }
 
-git_tree *git_tree_lookup(git_revpool *pool, const git_oid *id)
+git_tree *git_tree_lookup(git_repository *repo, const git_oid *id)
 {
-	git_tree *tree = NULL;
-
-	if (pool == NULL)
-		return NULL;
-
-	tree = (git_tree *)git_revpool_table_lookup(pool->objects, id);
-	if (tree != NULL)
-		return tree;
-
-	tree = git__malloc(sizeof(git_tree));
-
-	if (tree == NULL)
-		return NULL;
-
-	memset(tree, 0x0, sizeof(git_tree));
-
-	/* Initialize parent object */
-	git_oid_cpy(&tree->object.id, id);
-	tree->object.pool = pool;
-	tree->object.type = GIT_OBJ_TREE;
-
-	git_revpool_table_insert(pool->objects, (git_revpool_object *)tree);
-
-	return tree;
-}
-
-
-git_tree *git_tree_parse(git_revpool *pool, const git_oid *id)
-{
-	git_tree *tree = NULL;
-
-	if ((tree = git_tree_lookup(pool, id)) == NULL)
-		return NULL;
-
-	if (git_tree__parse(tree) < 0)
-		goto error_cleanup;
-
-	return tree;
-
-error_cleanup:
-	/* FIXME: do not free; the tree is owned by the revpool */
-	free(tree);
-	return NULL;
+	return (git_tree *)git_repository_lookup(repo, id, GIT_OBJ_TREE);
 }
 
 int git_tree__parse(git_tree *tree)
@@ -93,7 +52,7 @@ int git_tree__parse(git_tree *tree)
 	git_obj odb_object;
 	char *buffer, *buffer_end;
 
-	error = git_odb_read(&odb_object, tree->object.pool->db, &tree->object.id);
+	error = git_odb_read(&odb_object, tree->object.repo->db, &tree->object.id);
 	if (error < 0)
 		return error;
 
diff --git a/src/tree.h b/src/tree.h
index 3733456..f216685 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -2,7 +2,7 @@
 #define INCLUDE_tree_h__
 
 #include <git/tree.h>
-#include "revobject.h"
+#include "repository.h"
 
 struct git_tree_entry {
 
@@ -16,7 +16,7 @@ struct git_tree_entry {
 typedef struct git_tree_entry git_tree_entry;
 
 struct git_tree {
-	git_revpool_object object;
+	git_repository_object object;
 
 	size_t byte_size;
 	git_tree_entry *entries;
diff --git a/tests/t0401-parse.c b/tests/t0401-parse.c
index f301182..d9b3a2a 100644
--- a/tests/t0401-parse.c
+++ b/tests/t0401-parse.c
@@ -72,7 +72,7 @@ a simple commit which works\n",
 
 /* simple commit, 1 parents */
 "tree f6c0dad3c7b3481caa9d73db21f91964894a945b\n\
-parent 05452d6349abcd67aa396dfb28660d765d8b2a36\n\
+parent a4a7dce85cf63874e984719f4fdd239f5145052f\n\
 author Vicent Marti <tanoku@gmail.com> 1273848544 +0200\n\
 committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200\n\
 \n\
@@ -216,17 +216,23 @@ BEGIN_TEST(parse_buffer_test)
 	const int broken_commit_count = sizeof(test_commits_broken) / sizeof(*test_commits_broken);
 	const int working_commit_count = sizeof(test_commits_working) / sizeof(*test_commits_working);
 
-	const unsigned int default_flags = 0xFF; /* parse everything */
+	const unsigned int default_flags = 
+		GIT_COMMIT_AUTHOR | 
+		GIT_COMMIT_COMMITTER | 
+		GIT_COMMIT_TIME |
+		GIT_COMMIT_MESSAGE |
+		GIT_COMMIT_MESSAGE_SHORT; /* parse everything */
 
 	int i;
+	git_repository *repo = git_repository_alloc(NULL);
 
-	git_revpool *pool = gitrp_alloc(NULL);
+	must_be_true(repo != NULL);
 
 	for (i = 0; i < broken_commit_count; ++i) {
 		git_commit *commit;
 		commit = git__malloc(sizeof(git_commit));
 		memset(commit, 0x0, sizeof(git_commit));
-		commit->object.pool = pool;
+		commit->object.repo = repo;
 
 		must_fail(git_commit__parse_buffer(
 					commit,
@@ -242,7 +248,7 @@ BEGIN_TEST(parse_buffer_test)
 		git_commit *commit;
 		commit = git__malloc(sizeof(git_commit));
 		memset(commit, 0x0, sizeof(git_commit));
-		commit->object.pool = pool;
+		commit->object.repo = repo;
 
 		must_pass(git_commit__parse_buffer(
 					commit,
@@ -254,6 +260,6 @@ BEGIN_TEST(parse_buffer_test)
 		git_commit__free(commit);
 	}
 
-	gitrp_free(pool);
+	git_repository_free(repo);
 
 END_TEST
diff --git a/tests/t0402-details.c b/tests/t0402-details.c
index df4a074..7da50b1 100644
--- a/tests/t0402-details.c
+++ b/tests/t0402-details.c
@@ -21,12 +21,12 @@ BEGIN_TEST(query_details_test)
 
 	unsigned int i;
 	git_odb *db;
-	git_revpool *pool;
+	git_repository *repo;
 
 	must_pass(git_odb_open(&db, odb_dir));
 
-	pool = gitrp_alloc(db);
-	must_be_true(pool != NULL);
+	repo = git_repository_alloc(db);
+	must_be_true(repo != NULL);
 
 	for (i = 0; i < commit_count; ++i) {
 		git_oid id;
@@ -38,7 +38,7 @@ BEGIN_TEST(query_details_test)
 
 		git_oid_mkstr(&id, commit_ids[i]);
 
-		commit = git_commit_parse(pool, &id);
+		commit = git_commit_lookup(repo, &id);
 		must_be_true(commit != NULL);
 
 		message = git_commit_message(commit);
@@ -56,6 +56,6 @@ BEGIN_TEST(query_details_test)
 		must_be_true(commit_time > 0);
 	}
 
-	gitrp_free(pool);
+	git_repository_free(repo);
 	git_odb_close(db);
 END_TEST
diff --git a/tests/t0403-lists.c b/tests/t0403-lists.c
deleted file mode 100644
index ed473e2..0000000
--- a/tests/t0403-lists.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "test_lib.h"
-#include "test_helpers.h"
-#include "commit.h"
-#include <git/odb.h>
-#include <git/commit.h>
-
-BEGIN_TEST(list_timesort_test)
-
-	git_commit_list list;
-	git_commit_node *n;
-	int i, t;
-	time_t previous_time;
-
-#define TEST_SORTED() \
-		previous_time = INT_MAX;\
-	for (n = list.head; n != NULL; n = n->next) {\
-		must_be_true(n->commit->commit_time <= previous_time);\
-		previous_time = n->commit->commit_time;\
-	}
-
-	memset(&list, 0x0, sizeof(git_commit_list));
-	srand((unsigned int)time(NULL));
-
-	for (t = 0; t < 20; ++t) {
-		const int test_size = rand() % 500 + 500;
-
-		/* Purely random sorting test */
-		for (i = 0; i < test_size; ++i) {
-			git_commit *c = git__malloc(sizeof(git_commit));
-			c->commit_time = (time_t)rand();
-
-			git_commit_list_push_back(&list, c);
-		}
-
-		git_commit_list_timesort(&list);
-		TEST_SORTED();
-		git_commit_list_clear(&list, 1);
-	}
-
-	/* Try to sort list with all dates equal. */
-	for (i = 0; i < 200; ++i) {
-		git_commit *c = git__malloc(sizeof(git_commit));
-		c->commit_time = 0;
-
-		git_commit_list_push_back(&list, c);
-	}
-
-	git_commit_list_timesort(&list);
-	TEST_SORTED();
-	git_commit_list_clear(&list, 1);
-
-	/* Try to sort empty list */
-	git_commit_list_timesort(&list);
-	TEST_SORTED();
-
-END_TEST
diff --git a/tests/t0501-walk.c b/tests/t0501-walk.c
index f15336f..c1b9a90 100644
--- a/tests/t0501-walk.c
+++ b/tests/t0501-walk.c
@@ -29,49 +29,106 @@ static const char *commit_ids[] = {
 	"5b5b025afb0b4c913b4c338a42934a3863bf3644", /* 5 */
 };
 
-static const int commit_sorting_topo[] = {0, 1, 2, 3, 5, 4};
-static const int commit_sorting_time[] = {0, 3, 1, 2, 5, 4};
-static const int commit_sorting_topo_reverse[] = {4, 5, 3, 2, 1, 0};
-static const int commit_sorting_time_reverse[] = {4, 5, 2, 1, 3, 0};
-static const int commit_sorting_topo_time[] = {0};
+/* Careful: there are two possible topological sorts */
+static const int commit_sorting_topo[][6] = {
+	{0, 1, 2, 3, 5, 4}, {0, 3, 1, 2, 5, 4}
+};
+
+static const int commit_sorting_time[][6] = {
+	{0, 3, 1, 2, 5, 4}
+};
+
+static const int commit_sorting_topo_reverse[][6] = {
+	{4, 5, 3, 2, 1, 0}, {4, 5, 2, 1, 3, 0}
+};
+
+static const int commit_sorting_time_reverse[][6] = {
+	{4, 5, 2, 1, 3, 0}
+};
+
+static const int commit_count = 6;
+static const int result_bytes = 24;
+
+
+static int get_commit_index(git_commit *commit)
+{
+	int i;
+	char oid[40];
+
+	git_oid_fmt(oid, &commit->object.id);
+	
+	for (i = 0; i < commit_count; ++i)
+		if (memcmp(oid, commit_ids[i], 40) == 0)
+			return i;
+
+	return -1;
+}
+
+static int test_walk(git_revwalk *walk, git_commit *start_from,
+		int flags, const int possible_results[][6], int results_count)
+{
+	git_commit *commit = NULL;
+
+	int i;
+	int result_array[commit_count];
+
+	git_revwalk_sorting(walk, flags);
+	git_revwalk_push(walk, start_from);
+
+	for (i = 0; i < commit_count; ++i)
+		result_array[i] = -1;
+
+	i = 0;
+	while ((commit = git_revwalk_next(walk)) != NULL)
+		result_array[i++] = get_commit_index(commit);
+
+	for (i = 0; i < results_count; ++i) 
+		if (memcmp(possible_results[i],
+				result_array, result_bytes) == 0)
+			return GIT_SUCCESS;
+
+	return GIT_ERROR;
+}
 
 BEGIN_TEST(simple_walk_test)
 	git_odb *db;
 	git_oid id;
-	git_revpool *pool;
+	git_repository *repo;
+	git_revwalk *walk;
 	git_commit *head = NULL;
 
 	must_pass(git_odb_open(&db, odb_dir));
 
-	pool = gitrp_alloc(db);
-	must_be_true(pool != NULL);
+	repo = git_repository_alloc(db);
+	must_be_true(repo != NULL);
+
+	walk = git_revwalk_alloc(repo);
+	must_be_true(walk != NULL);
 
 	git_oid_mkstr(&id, commit_head);
 
-	head = git_commit_parse(pool, &id);
+	head = git_commit_lookup(repo, &id);
 	must_be_true(head != NULL);
 
-	gitrp_push(pool, head);
-
-#define TEST_WALK(sort_flags, result_array) {\
-	char oid[40]; int i = 0;\
-	git_commit *commit = NULL;\
-	gitrp_sorting(pool, sort_flags);\
-	while ((commit = gitrp_next(pool)) != NULL) {\
-		git_oid_fmt(oid, &commit->object.id);\
-		must_be_true(memcmp(oid, commit_ids[result_array[i++]], 40) == 0);\
-	}\
-	must_be_true(i == sizeof(result_array)/sizeof(int));\
-	gitrp_reset(pool);\
-}
 
-	TEST_WALK(GIT_RPSORT_TIME, commit_sorting_time);
-	TEST_WALK(GIT_RPSORT_TOPOLOGICAL, commit_sorting_topo);
-	TEST_WALK(GIT_RPSORT_TIME | GIT_RPSORT_REVERSE, commit_sorting_time_reverse);
-	TEST_WALK(GIT_RPSORT_TOPOLOGICAL | GIT_RPSORT_REVERSE, commit_sorting_topo_reverse);
+	must_pass(test_walk(walk, head,
+				GIT_SORT_TIME,
+				commit_sorting_time, 1));
+
+	must_pass(test_walk(walk, head,
+				GIT_SORT_TOPOLOGICAL,
+				commit_sorting_topo, 2));
+
+	must_pass(test_walk(walk, head,
+				GIT_SORT_TIME | GIT_SORT_REVERSE,
+				commit_sorting_time_reverse, 1));
+
+	must_pass(test_walk(walk, head,
+				GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE,
+				commit_sorting_topo_reverse, 2));
 
-#undef TEST_WALK
 
-	gitrp_free(pool);
+	git_revwalk_free(walk);
+	git_repository_free(repo);
 	git_odb_close(db);
 END_TEST
diff --git a/tests/t0502-list.c b/tests/t0502-list.c
new file mode 100644
index 0000000..8308099
--- /dev/null
+++ b/tests/t0502-list.c
@@ -0,0 +1,70 @@
+#include "test_lib.h"
+#include "test_helpers.h"
+#include "commit.h"
+#include "revwalk.h"
+#include <git/odb.h>
+#include <git/commit.h>
+
+BEGIN_TEST(list_timesort_test)
+
+	git_revwalk_list list;
+	git_revwalk_listnode *n;
+	int i, t;
+	time_t previous_time;
+
+#define TEST_SORTED() \
+		previous_time = INT_MAX;\
+	for (n = list.head; n != NULL; n = n->next) {\
+		must_be_true(n->walk_commit->commit_object->commit_time <= previous_time);\
+		previous_time = n->walk_commit->commit_object->commit_time;\
+	}
+
+#define CLEAR_LIST() \
+	for (n = list.head; n != NULL; n = n->next) {\
+		free(n->walk_commit->commit_object);\
+		free(n->walk_commit);\
+	}\
+	git_revwalk_list_clear(&list);
+
+	memset(&list, 0x0, sizeof(git_revwalk_list));
+	srand((unsigned int)time(NULL));
+
+	for (t = 0; t < 20; ++t) {
+		const int test_size = rand() % 500 + 500;
+
+		/* Purely random sorting test */
+		for (i = 0; i < test_size; ++i) {
+			git_commit *c = git__malloc(sizeof(git_commit));
+			git_revwalk_commit *rc = git__malloc(sizeof(git_revwalk_commit));
+
+			c->commit_time = (time_t)rand();
+			rc->commit_object = c;
+
+			git_revwalk_list_push_back(&list, rc);
+		}
+
+		git_revwalk_list_timesort(&list);
+		TEST_SORTED();
+		CLEAR_LIST();
+	}
+
+	/* Try to sort list with all dates equal. */
+	for (i = 0; i < 200; ++i) {
+		git_commit *c = git__malloc(sizeof(git_commit));
+		git_revwalk_commit *rc = git__malloc(sizeof(git_revwalk_commit));
+
+		c->commit_time = 0;
+		rc->commit_object = c;
+
+		git_revwalk_list_push_back(&list, rc);
+	}
+
+	git_revwalk_list_timesort(&list);
+	TEST_SORTED();
+	CLEAR_LIST();
+
+	/* Try to sort empty list */
+	git_revwalk_list_timesort(&list);
+	TEST_SORTED();
+
+END_TEST
diff --git a/tests/t0502-table.c b/tests/t0502-table.c
deleted file mode 100644
index f68f0b1..0000000
--- a/tests/t0502-table.c
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "test_lib.h"
-#include "test_helpers.h"
-#include "commit.h"
-#include "revobject.h"
-#include "hash.h"
-
-
-BEGIN_TEST(table_create)
-
-	git_revpool_table *table = NULL;
-
-	table = git_revpool_table_create(55);
-	must_be_true(table != NULL);
-	must_be_true(table->size_mask + 1 == 64);
-
-	git_revpool_table_free(table);
-
-END_TEST
-
-BEGIN_TEST(table_populate)
-
-	const int objects_n = 32;
-	int i;
-	git_revpool_object *objects;
-	git_revpool_table *table = NULL;
-
-	table = git_revpool_table_create(objects_n * 2);
-	must_be_true(table != NULL);
-
-	objects = git__malloc(objects_n * sizeof(git_revpool_object));
-	memset(objects, 0x0, objects_n * sizeof(git_revpool_object));
-
-	/* populate the hash table */
-	for (i = 0; i < objects_n; ++i) {
-		git_hash_buf(&(objects[i].id), &i, sizeof(int));
-		must_pass(git_revpool_table_insert(table, &(objects[i])));
-	}
-
-	/* make sure all the inserted objects can be found */
-	for (i = 0; i < objects_n; ++i) {
-		git_oid id;
-		git_revpool_object *ob;
-
-		git_hash_buf(&id, &i, sizeof(int));
-		ob = git_revpool_table_lookup(table, &id);
-
-		must_be_true(ob != NULL);
-		must_be_true(ob == &(objects[i]));
-	}
-
-	/* make sure we cannot find inexisting objects */
-	for (i = 0; i < 50; ++i) {
-		int hash_id;
-		git_oid id;
-
-		hash_id = (rand() % 50000) + objects_n;
-		git_hash_buf(&id, &hash_id, sizeof(int));
-		must_be_true(git_revpool_table_lookup(table, &id) == NULL);
-	}
-
-	git_revpool_table_free(table);
-	free(objects);
-
-END_TEST
-
-
-BEGIN_TEST(table_resize)
-
-	const int objects_n = 64;
-	int i;
-	unsigned int old_size;
-	git_revpool_object *objects;
-	git_revpool_table *table = NULL;
-
-	table = git_revpool_table_create(objects_n);
-	must_be_true(table != NULL);
-
-	objects = git__malloc(objects_n * sizeof(git_revpool_object));
-	memset(objects, 0x0, objects_n * sizeof(git_revpool_object));
-
-	old_size = table->size_mask + 1;
-
-	/* populate the hash table -- should be automatically resized */
-	for (i = 0; i < objects_n; ++i) {
-		git_hash_buf(&(objects[i].id), &i, sizeof(int));
-		must_pass(git_revpool_table_insert(table, &(objects[i])));
-	}
-
-	must_be_true(table->size_mask > old_size);
-
-	/* make sure all the inserted objects can be found */
-	for (i = 0; i < objects_n; ++i) {
-		git_oid id;
-		git_revpool_object *ob;
-
-		git_hash_buf(&id, &i, sizeof(int));
-		ob = git_revpool_table_lookup(table, &id);
-
-		must_be_true(ob != NULL);
-		must_be_true(ob == &(objects[i]));
-	}
-
-	/* force another resize */
-	old_size = table->size_mask + 1;
-	git_revpool_table_resize(table);
-	must_be_true(table->size_mask > old_size);
-
-	/* make sure all the inserted objects can be found */
-	for (i = 0; i < objects_n; ++i) {
-		git_oid id;
-		git_revpool_object *ob;
-
-		git_hash_buf(&id, &i, sizeof(int));
-		ob = git_revpool_table_lookup(table, &id);
-
-		must_be_true(ob != NULL);
-		must_be_true(ob == &(objects[i]));
-	}
-
-	git_revpool_table_free(table);
-	free(objects);
-
-END_TEST
diff --git a/tests/t0503-tableit.c b/tests/t0503-tableit.c
deleted file mode 100644
index 8e9e1e4..0000000
--- a/tests/t0503-tableit.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "test_lib.h"
-#include "test_helpers.h"
-#include "commit.h"
-#include "revobject.h"
-#include "hash.h"
-
-typedef struct _aux_object {
-	git_revpool_object object;
-	int visited;
-} aux_object;
-
-
-BEGIN_TEST(table_iterator)
-
-	const int objects_n = 32;
-	int i;
-	aux_object *objects, *ob;
-
-	git_revpool_table *table = NULL;
-	git_revpool_tableit iterator;
-
-	table = git_revpool_table_create(objects_n * 2);
-	must_be_true(table != NULL);
-
-	objects = git__malloc(objects_n * sizeof(aux_object));
-	memset(objects, 0x0, objects_n * sizeof(aux_object));
-
-	/* populate the hash table */
-	for (i = 0; i < objects_n; ++i) {
-		git_hash_buf(&(objects[i].object.id), &i, sizeof(int));
-		must_pass(git_revpool_table_insert(table, (git_revpool_object *)&(objects[i])));
-	}
-
-	git_revpool_tableit_init(table, &iterator);
-
-	/* iterate through all nodes, mark as visited */
-	while ((ob = (aux_object *)git_revpool_tableit_next(&iterator)) != NULL)
-		ob->visited = 1;
-
-	/* make sure all nodes have been visited */
-	for (i = 0; i < objects_n; ++i)
-		must_be_true(objects[i].visited);
-
-	git_revpool_table_free(table);
-	free(objects);
-
-END_TEST
diff --git a/tests/t0701-table.c b/tests/t0701-table.c
new file mode 100644
index 0000000..21d57a6
--- /dev/null
+++ b/tests/t0701-table.c
@@ -0,0 +1,134 @@
+#include "test_lib.h"
+#include "test_helpers.h"
+#include "commit.h"
+#include "hash.h"
+#include "hashtable.h"
+
+typedef struct table_item
+{
+	int __bulk;
+	git_oid id;
+} table_item;
+
+
+uint32_t hash_func(const void *key)
+{
+	uint32_t r;
+	git_oid *id;
+
+	id = (git_oid *)key;
+	memcpy(&r, id->id, sizeof(r));
+	return r;
+}
+
+int hash_haskey(void *item, const void *key)
+{
+	table_item *obj;
+	git_oid *oid;
+
+	obj = (table_item *)item;
+	oid = (git_oid *)key;
+
+	return (git_oid_cmp(oid, &obj->id) == 0);
+}
+
+BEGIN_TEST(table_create)
+
+	git_hashtable *table = NULL;
+
+	table = git_hashtable_alloc(55, hash_func, hash_haskey);
+	must_be_true(table != NULL);
+	must_be_true(table->size_mask + 1 == 64);
+
+	git_hashtable_free(table);
+
+END_TEST
+
+BEGIN_TEST(table_populate)
+
+	const int objects_n = 32;
+	int i;
+
+	table_item *objects;
+	git_hashtable *table = NULL;
+
+	table = git_hashtable_alloc(objects_n * 2, hash_func, hash_haskey);
+	must_be_true(table != NULL);
+
+	objects = git__malloc(objects_n * sizeof(table_item));
+	memset(objects, 0x0, objects_n * sizeof(table_item));
+
+	/* populate the hash table */
+	for (i = 0; i < objects_n; ++i) {
+		git_hash_buf(&(objects[i].id), &i, sizeof(int));
+		must_pass(git_hashtable_insert(table, &(objects[i].id), &(objects[i])));
+	}
+
+	/* make sure all the inserted objects can be found */
+	for (i = 0; i < objects_n; ++i) {
+		git_oid id;
+		table_item *ob;
+
+		git_hash_buf(&id, &i, sizeof(int));
+		ob = (table_item *)git_hashtable_lookup(table, &id);
+
+		must_be_true(ob != NULL);
+		must_be_true(ob == &(objects[i]));
+	}
+
+	/* make sure we cannot find inexisting objects */
+	for (i = 0; i < 50; ++i) {
+		int hash_id;
+		git_oid id;
+
+		hash_id = (rand() % 50000) + objects_n;
+		git_hash_buf(&id, &hash_id, sizeof(int));
+		must_be_true(git_hashtable_lookup(table, &id) == NULL);
+	}
+
+	git_hashtable_free(table);
+	free(objects);
+
+END_TEST
+
+
+BEGIN_TEST(table_resize)
+
+	const int objects_n = 64;
+	int i;
+	unsigned int old_size;
+	table_item *objects;
+	git_hashtable *table = NULL;
+
+	table = git_hashtable_alloc(objects_n, hash_func, hash_haskey);
+	must_be_true(table != NULL);
+
+	objects = git__malloc(objects_n * sizeof(table_item));
+	memset(objects, 0x0, objects_n * sizeof(table_item));
+
+	old_size = table->size_mask + 1;
+
+	/* populate the hash table -- should be automatically resized */
+	for (i = 0; i < objects_n; ++i) {
+		git_hash_buf(&(objects[i].id), &i, sizeof(int));
+		must_pass(git_hashtable_insert(table, &(objects[i].id), &(objects[i])));
+	}
+
+	must_be_true(table->size_mask > old_size);
+
+	/* make sure all the inserted objects can be found */
+	for (i = 0; i < objects_n; ++i) {
+		git_oid id;
+		table_item *ob;
+
+		git_hash_buf(&id, &i, sizeof(int));
+		ob = (table_item *)git_hashtable_lookup(table, &id);
+
+		must_be_true(ob != NULL);
+		must_be_true(ob == &(objects[i]));
+	}
+
+	git_hashtable_free(table);
+	free(objects);
+
+END_TEST
diff --git a/tests/t0702-tableit.c b/tests/t0702-tableit.c
new file mode 100644
index 0000000..30aeb2b
--- /dev/null
+++ b/tests/t0702-tableit.c
@@ -0,0 +1,69 @@
+#include "test_lib.h"
+#include "test_helpers.h"
+#include "commit.h"
+#include "hashtable.h"
+#include "hash.h"
+
+typedef struct _aux_object {
+	int __bulk;
+	git_oid id;
+	int visited;
+} table_item;
+
+uint32_t hash_func(const void *key)
+{
+	uint32_t r;
+	git_oid *id;
+
+	id = (git_oid *)key;
+	memcpy(&r, id->id, sizeof(r));
+	return r;
+}
+
+int hash_haskey(void *item, const void *key)
+{
+	table_item *obj;
+	git_oid *oid;
+
+	obj = (table_item *)item;
+	oid = (git_oid *)key;
+
+	return (git_oid_cmp(oid, &obj->id) == 0);
+}
+
+
+BEGIN_TEST(table_iterator)
+
+	const int objects_n = 32;
+	int i;
+	table_item *objects, *ob;
+
+	git_hashtable *table = NULL;
+	git_hashtable_iterator iterator;
+
+	table = git_hashtable_alloc(objects_n * 2, hash_func, hash_haskey);
+	must_be_true(table != NULL);
+
+	objects = git__malloc(objects_n * sizeof(table_item));
+	memset(objects, 0x0, objects_n * sizeof(table_item));
+
+	/* populate the hash table */
+	for (i = 0; i < objects_n; ++i) {
+		git_hash_buf(&(objects[i].id), &i, sizeof(int));
+		must_pass(git_hashtable_insert(table, &(objects[i].id), &(objects[i])));
+	}
+
+	git_hashtable_iterator_init(table, &iterator);
+
+	/* iterate through all nodes, mark as visited */
+	while ((ob = (table_item *)git_hashtable_iterator_next(&iterator)) != NULL)
+		ob->visited = 1;
+
+	/* make sure all nodes have been visited */
+	for (i = 0; i < objects_n; ++i)
+		must_be_true(objects[i].visited);
+
+	git_hashtable_free(table);
+	free(objects);
+
+END_TEST