Commit 00e43380a0beee3ac40935c45d4aa67fbfc27fbb

Brad Morgan 2013-05-07T14:30:35

Merge remote-tracking branch 'origin/development' into ssh_transport

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
diff --git a/.mailmap b/.mailmap
index 582dae0..3f5a087 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1,3 +1,18 @@
-Vicent Martí <vicent@github.com> Vicent Marti <tanoku@gmail.com> 
+Vicent Martí <vicent@github.com> Vicent Marti <tanoku@gmail.com>
 Vicent Martí <vicent@github.com> Vicent Martí <tanoku@gmail.com>
 Michael Schubert <schu@schu.io> schu <schu-github@schulog.org>
+Ben Straub <bs@github.com> Ben Straub <ben@straubnet.net>
+Ben Straub <bs@github.com> Ben Straub <bstraub@github.com>
+Carlos Martín Nieto <cmn@dwim.me> <carlos@cmartin.tk>
+Carlos Martín Nieto <cmn@dwim.me> <cmn@elego.de>
+nulltoken <emeric.fermas@gmail.com> <emeric.fermas@gmail.com>
+Scott J. Goldman <scottjg@github.com> <scottjgo@gmail.com>
+Martin Woodward <martin.woodward@microsoft.com> <martinwo@microsoft.com>
+Peter Drahoš <drahosp@gmail.com> <drahosp@gmail.com>
+Adam Roben <adam@github.com> <adam@roben.org>
+Adam Roben <adam@github.com> <adam@github.com>
+Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.ca>
+Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.tk>
+Sascha Cunz <sascha@babbelbox.org> <Sascha@BabbelBox.org>
+Authmillenon <authmillenon@googlemail.com> <martin@ucsmail.de>
+Authmillenon <authmillenon@googlemail.com> <authmillenon@googlemail.com>
diff --git a/.travis.yml b/.travis.yml
index ad1172d..0d5746f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,6 +25,10 @@ install:
 
 # Run the Build script
 script:
+ - mkdir _temp
+ - git init --bare _temp/test.git
+ - git daemon --listen=localhost --export-all --enable=receive-pack --base-path=_temp _temp 2>/dev/null &
+ - export GITTEST_REMOTE_URL="git://localhost/test.git"
  - mkdir _build
  - cd _build
  - cmake .. -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 20d63fe..cdecd18 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -288,6 +288,15 @@ ELSE()
 ENDIF()
 FILE(GLOB SRC_GIT2 src/*.c src/transports/*.c src/xdiff/*.c)
 
+# Determine architecture of the machine
+IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
+	ADD_DEFINITIONS(-DGIT_ARCH_64)
+ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
+	ADD_DEFINITIONS(-DGIT_ARCH_32)
+ELSE()
+	message(FATAL_ERROR "Unsupported architecture")
+ENDIF()
+
 # Compile and link libgit2
 ADD_LIBRARY(git2 ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SHA1} ${WIN_RC})
 TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
@@ -296,7 +305,7 @@ TARGET_OS_LIBRARIES(git2)
 
 # Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
 # Win64+MSVC+static libs = linker error
-IF(MSVC AND NOT BUILD_SHARED_LIBS AND (${CMAKE_SIZEOF_VOID_P} MATCHES "8") )
+IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
   SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
 ENDIF()
 
diff --git a/README.md b/README.md
index 790e202..a2a1876 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@ release its source code.
     * Archives: <http://librelist.com/browser/libgit2/>
 * Website: <http://libgit2.github.com>
 * API documentation: <http://libgit2.github.com/libgit2>
+* IRC: #libgit2 on irc.freenode.net.
 
 What It Can Do
 ==================================
@@ -139,7 +140,7 @@ Here are the bindings to libgit2 that are currently available:
 * Parrot Virtual Machine
     * parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
 * Perl
-    * git-xs-pm <https://github.com/ingydotnet/git-xs-pm>
+    * Git-Raw <https://github.com/ghedo/p5-Git-Raw>
 * PHP
     * php-git <https://github.com/libgit2/php-git>
 * Python
@@ -155,15 +156,7 @@ we can add it to the list.
 How Can I Contribute?
 ==================================
 
-Fork libgit2/libgit2 on GitHub, add your improvement, push it to a branch
-in your fork named for the topic, send a pull request. If you change the
-API or make other large changes, make a note of it in docs/rel-notes/ in a
-file named after the next release.
-
-You can also file bugs or feature requests under the libgit2 project on
-GitHub, or join us on the mailing list by sending an email to:
-
-libgit2@librelist.com
+Check the [contribution guidelines](CONTRIBUTING.md).
 
 
 License
diff --git a/docs/merge-df_conflicts.txt b/docs/merge-df_conflicts.txt
new file mode 100644
index 0000000..09780ee
--- /dev/null
+++ b/docs/merge-df_conflicts.txt
@@ -0,0 +1,41 @@
+Anc / Our / Thr represent the ancestor / ours / theirs side of a merge
+from branch "branch" into HEAD.  Workdir represents the expected files in
+the working directory.  Index represents the expected files in the index,
+with stage markers.
+
+    Anc  Our  Thr    Workdir             Index
+1   D    D
+               D/F   D/F                 D/F [0]
+
+2   D    D+          D~HEAD (mod/del)    D/F [0]
+               D/F   D/F                 D [1]
+                                         D [2]
+
+3   D          D     D/F                 D/F [0]
+         D/F
+
+4   D          D+    D~branch (mod/del)  D/F [0]
+         D/F         D/F                 D [1]
+                                         D [3]
+
+5   D                D/F (add/add)       D/F [2]
+         D/F                             D/F [3]
+               D/F
+
+6   D/F  D/F         D                   D [0]
+               D
+
+7   D/F  D/F+        D/F (mod/del)       D/F [1]
+               D     D~branch (fil/dir)  D/F [2]
+                                         D [3]
+
+8   D/F        D/F   D                   D [0]
+         D
+
+9   D/F        D/F+  D/F (mod/del)       D/F [1]
+         D           D~HEAD (fil/dir)    D [2]
+                                         D/F [3]
+
+10  D/F              D/F (fil/dir)       D/F [0]
+         D           D~HEAD              D [2]
+               D
diff --git a/examples/network/git2.c b/examples/network/git2.c
index ecb1663..5b32ac8 100644
--- a/examples/network/git2.c
+++ b/examples/network/git2.c
@@ -54,6 +54,8 @@ int main(int argc, char **argv)
 		exit(EXIT_FAILURE);
 	}
 
+	git_threads_init();
+
 	for (i = 0; commands[i].name != NULL; ++i) {
 		if (!strcmp(argv[1], commands[i].name))
 			return run_command(commands[i].fn, --argc, ++argv);
diff --git a/include/git2/attr.h b/include/git2/attr.h
index dea44f0..f099245 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -228,7 +228,7 @@ GIT_EXTERN(void) git_attr_cache_flush(
  * function allows you to add others.  For example, to add the default
  * macro, you would call:
  *
- *    git_attr_add_macro(repo, "binary", "-diff -crlf");
+ *     git_attr_add_macro(repo, "binary", "-diff -crlf");
  */
 GIT_EXTERN(int) git_attr_add_macro(
 	git_repository *repo,
diff --git a/include/git2/blob.h b/include/git2/blob.h
index 0a2aa9d..8fca489 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -29,10 +29,7 @@ GIT_BEGIN_DECL
  * @param id identity of the blob to locate.
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id)
-{
-	return git_object_lookup((git_object **)blob, repo, id, GIT_OBJ_BLOB);
-}
+GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id);
 
 /**
  * Lookup a blob object from a repository,
@@ -46,10 +43,7 @@ GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git
  * @param len the length of the short identifier
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, size_t len)
-{
-	return git_object_lookup_prefix((git_object **)blob, repo, id, len, GIT_OBJ_BLOB);
-}
+GIT_EXTERN(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, size_t len);
 
 /**
  * Close an open blob
@@ -62,11 +56,7 @@ GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, co
  *
  * @param blob the blob to close
  */
-
-GIT_INLINE(void) git_blob_free(git_blob *blob)
-{
-	git_object_free((git_object *) blob);
-}
+GIT_EXTERN(void) git_blob_free(git_blob *blob);
 
 /**
  * Get the id of a blob.
@@ -74,11 +64,15 @@ GIT_INLINE(void) git_blob_free(git_blob *blob)
  * @param blob a previously loaded blob.
  * @return SHA1 hash for this blob.
  */
-GIT_INLINE(const git_oid *) git_blob_id(const git_blob *blob)
-{
-	return git_object_id((const git_object *)blob);
-}
+GIT_EXTERN(const git_oid *) git_blob_id(const git_blob *blob);
 
+/**
+ * Get the repository that contains the blob.
+ *
+ * @param blob A previously loaded blob.
+ * @return Repository that contains this blob.
+ */
+GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob);
 
 /**
  * Get a read-only buffer with the raw content of a blob.
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 764053e..f536ac7 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -30,10 +30,7 @@ GIT_BEGIN_DECL
  *		an annotated tag it will be peeled back to the commit.
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id)
-{
-	return git_object_lookup((git_object **)commit, repo, id, GIT_OBJ_COMMIT);
-}
+GIT_EXTERN(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id);
 
 /**
  * Lookup a commit object from a repository,
@@ -48,10 +45,7 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
  * @param len the length of the short identifier
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *repo, const git_oid *id, size_t len)
-{
-	return git_object_lookup_prefix((git_object **)commit, repo, id, len, GIT_OBJ_COMMIT);
-}
+GIT_EXTERN(int) git_commit_lookup_prefix(git_commit **commit, git_repository *repo, const git_oid *id, size_t len);
 
 /**
  * Close an open commit
@@ -65,10 +59,7 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re
  * @param commit the commit to close
  */
 
-GIT_INLINE(void) git_commit_free(git_commit *commit)
-{
-	git_object_free((git_object *) commit);
-}
+GIT_EXTERN(void) git_commit_free(git_commit *commit);
 
 /**
  * Get the id of a commit.
@@ -76,10 +67,7 @@ GIT_INLINE(void) git_commit_free(git_commit *commit)
  * @param commit a previously loaded commit.
  * @return object identity for the commit.
  */
-GIT_INLINE(const git_oid *) git_commit_id(const git_commit *commit)
-{
-	return git_object_id((const git_object *)commit);
-}
+GIT_EXTERN(const git_oid *) git_commit_id(const git_commit *commit);
 
 /**
  * Get the encoding for the message of a commit,
@@ -201,14 +189,12 @@ GIT_EXTERN(int) git_commit_nth_gen_ancestor(
 	unsigned int n);
 
 /**
- * Create a new commit in the repository using `git_object`
- * instances as parameters.
+ * Create new commit in the repository from a list of `git_object` pointers
  *
- * The message will not be cleaned up. This can be achieved
- * through `git_message_prettify()`.
+ * The message will not be cleaned up automatically. You can do that with
+ * the `git_message_prettify()` function.
  *
- * @param id Pointer where to store the OID of the
- *	newly created commit
+ * @param id Pointer in which to store the OID of the newly created commit
  *
  * @param repo Repository where to store the commit
  *
@@ -219,73 +205,69 @@ GIT_EXTERN(int) git_commit_nth_gen_ancestor(
  *	make it point to this commit. If the reference doesn't
  *	exist yet, it will be created.
  *
- * @param author Signature representing the author and the authory
- *	time of this commit
+ * @param author Signature with author and author time of commit
  *
- * @param committer Signature representing the committer and the
- * commit time of this commit
+ * @param committer Signature with committer and * commit time of commit
  *
  * @param message_encoding The encoding for the message in the
- * commit, represented with a standard encoding name.
- * E.g. "UTF-8". If NULL, no encoding header is written and
- * UTF-8 is assumed.
+ *  commit, represented with a standard encoding name.
+ *  E.g. "UTF-8". If NULL, no encoding header is written and
+ *  UTF-8 is assumed.
  *
  * @param message Full message for this commit
  *
  * @param tree An instance of a `git_tree` object that will
- * be used as the tree for the commit. This tree object must
- * also be owned by the given `repo`.
+ *  be used as the tree for the commit. This tree object must
+ *  also be owned by the given `repo`.
  *
  * @param parent_count Number of parents for this commit
  *
  * @param parents[] Array of `parent_count` pointers to `git_commit`
- * objects that will be used as the parents for this commit. This
- * array may be NULL if `parent_count` is 0 (root commit). All the
- * given commits must be owned by the `repo`.
+ *  objects that will be used as the parents for this commit. This
+ *  array may be NULL if `parent_count` is 0 (root commit). All the
+ *  given commits must be owned by the `repo`.
  *
  * @return 0 or an error code
  *	The created commit will be written to the Object Database and
  *	the given reference will be updated to point to it
  */
 GIT_EXTERN(int) git_commit_create(
-		git_oid *id,
-		git_repository *repo,
-		const char *update_ref,
-		const git_signature *author,
-		const git_signature *committer,
-		const char *message_encoding,
-		const char *message,
-		const git_tree *tree,
-		int parent_count,
-		const git_commit *parents[]);
+	git_oid *id,
+	git_repository *repo,
+	const char *update_ref,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message,
+	const git_tree *tree,
+	int parent_count,
+	const git_commit *parents[]);
 
 /**
- * Create a new commit in the repository using a variable
- * argument list.
+ * Create new commit in the repository using a variable argument list.
  *
- * The message will be cleaned up from excess whitespace
- * it will be made sure that the last line ends with a '\n'.
+ * The message will be cleaned up from excess whitespace and it will be made
+ * sure that the last line ends with a '\n'.
  *
- * The parents for the commit are specified as a variable
- * list of pointers to `const git_commit *`. Note that this
- * is a convenience method which may not be safe to export
- * for certain languages or compilers
+ * The parents for the commit are specified as a variable list of pointers
+ * to `const git_commit *`. Note that this is a convenience method which may
+ * not be safe to export for certain languages or compilers
  *
- * All other parameters remain the same
+ * All other parameters remain the same at `git_commit_create()`.
  *
  * @see git_commit_create
  */
 GIT_EXTERN(int) git_commit_create_v(
-		git_oid *id,
-		git_repository *repo,
-		const char *update_ref,
-		const git_signature *author,
-		const git_signature *committer,
-		const char *message_encoding,
-		const char *message,
-		const git_tree *tree,
-		int parent_count,
-		...);
+	git_oid *id,
+	git_repository *repo,
+	const char *update_ref,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message,
+	const git_tree *tree,
+	int parent_count,
+	...);
 
 /** @} */
 GIT_END_DECL
diff --git a/include/git2/common.h b/include/git2/common.h
index 5318e66..f9e9929 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -131,8 +131,10 @@ enum {
 	GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
 	GIT_OPT_GET_SEARCH_PATH,
 	GIT_OPT_SET_SEARCH_PATH,
-	GIT_OPT_GET_ODB_CACHE_SIZE,
-	GIT_OPT_SET_ODB_CACHE_SIZE,
+	GIT_OPT_SET_CACHE_OBJECT_LIMIT,
+	GIT_OPT_SET_CACHE_MAX_SIZE,
+	GIT_OPT_ENABLE_CACHING,
+	GIT_OPT_GET_CACHED_MEMORY
 };
 
 /**
@@ -140,43 +142,42 @@ enum {
  *
  * Available options:
  *
- *	opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
- *		Get the maximum mmap window size
+ *	* opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
  *
- *	opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
- *		Set the maximum mmap window size
+ *		> Get the maximum mmap window size
  *
- *	opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
- *		Get the maximum memory that will be mapped in total by the library
+ *	* opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
  *
- *	opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
- *		Set the maximum amount of memory that can be mapped at any time
+ *		> Set the maximum mmap window size
+ *
+ *	* opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
+ *
+ *		> Get the maximum memory that will be mapped in total by the library
+ *
+ *	* opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
+ *
+ *		>Set the maximum amount of memory that can be mapped at any time
  *		by the library
  *
- *	opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
- *		Get the search path for a given level of config data.  "level" must
- *		be one of GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL, or
- *		GIT_CONFIG_LEVEL_XDG.  The search path is written to the `out`
- *		buffer up to size `len`.  Returns GIT_EBUFS if buffer is too small.
- *
- *	opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
- *		Set the search path for a level of config data.  The search path
- *		applied to shared attributes and ignore files, too.
- *      - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
- *		  Pass NULL to reset to the default (generally based on environment
- *		  variables).  Use magic path `$PATH` to include the old value
- *		  of the path (if you want to prepend or append, for instance).
- *		- `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
- *		  or GIT_CONFIG_LEVEL_XDG.
- *
- *	opts(GIT_OPT_GET_ODB_CACHE_SIZE):
- *		Get the size of the libgit2 odb cache.
- *
- *	opts(GIT_OPT_SET_ODB_CACHE_SIZE):
- *		Set the size of the of the libgit2 odb cache. This needs
- *		to be done before git_repository_open is called, since
- *		git_repository_open initializes the odb layer. Defaults
- *		to 128.
+ *	* opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
+ *
+ *		> Get the search path for a given level of config data.  "level" must
+ *		> be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or
+ *		> `GIT_CONFIG_LEVEL_XDG`.  The search path is written to the `out`
+ *		> buffer up to size `len`.  Returns GIT_EBUFS if buffer is too small.
+ *
+ *	* opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
+ *
+ *		> Set the search path for a level of config data.  The search path
+ *		> applied to shared attributes and ignore files, too.
+ *		>
+ *		> - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
+ *		>   Pass NULL to reset to the default (generally based on environment
+ *		>   variables).  Use magic path `$PATH` to include the old value
+ *		>   of the path (if you want to prepend or append, for instance).
+ *		>
+ *		> - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
+ *		>   or GIT_CONFIG_LEVEL_XDG.
  *
  * @param option Option key
  * @param ... value to set the option
diff --git a/include/git2/config.h b/include/git2/config.h
index 19d4cb7..5a2f956 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -43,29 +43,6 @@ typedef struct {
 
 typedef int  (*git_config_foreach_cb)(const git_config_entry *, void *);
 
-
-/**
- * Generic backend that implements the interface to
- * access a configuration file
- */
-struct git_config_backend {
-	unsigned int version;
-	struct git_config *cfg;
-
-	/* Open means open the file/database and parse if necessary */
-	int (*open)(struct git_config_backend *, unsigned int level);
-	int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
-	int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
-	int (*set)(struct git_config_backend *, const char *key, const char *value);
-	int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
-	int (*del)(struct git_config_backend *, const char *key);
-	int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
-	int (*refresh)(struct git_config_backend *);
-	void (*free)(struct git_config_backend *);
-};
-#define GIT_CONFIG_BACKEND_VERSION 1
-#define GIT_CONFIG_BACKEND_INIT {GIT_CONFIG_BACKEND_VERSION}
-
 typedef enum {
 	GIT_CVAR_FALSE = 0,
 	GIT_CVAR_TRUE = 1,
@@ -154,30 +131,6 @@ GIT_EXTERN(int) git_config_open_default(git_config **out);
 GIT_EXTERN(int) git_config_new(git_config **out);
 
 /**
- * Add a generic config file instance to an existing config
- *
- * Note that the configuration object will free the file
- * automatically.
- *
- * Further queries on this config object will access each
- * of the config file instances in order (instances with
- * a higher priority level will be accessed first).
- *
- * @param cfg the configuration to add the file to
- * @param file the configuration file (backend) to add
- * @param level the priority level of the backend
- * @param force if a config file already exists for the given
- *  priority level, replace it
- * @return 0 on success, GIT_EEXISTS when adding more than one file
- *  for a given priority level (and force_replace set to 0), or error code
- */
-GIT_EXTERN(int) git_config_add_backend(
-	git_config *cfg,
-	git_config_backend *file,
-	unsigned int level,
-	int force);
-
-/**
  * Add an on-disk config file instance to an existing config
  *
  * The on-disk file pointed at by `path` will be opened and
@@ -192,10 +145,9 @@ GIT_EXTERN(int) git_config_add_backend(
  * a higher priority level will be accessed first).
  *
  * @param cfg the configuration to add the file to
- * @param path path to the configuration file (backend) to add
+ * @param path path to the configuration file to add
  * @param level the priority level of the backend
- * @param force if a config file already exists for the given
- *  priority level, replace it
+ * @param force replace config file at the given priority level
  * @return 0 on success, GIT_EEXISTS when adding more than one file
  *  for a given priority level (and force_replace set to 0),
  *  GIT_ENOTFOUND when the file doesn't exist or error code
diff --git a/include/git2/cred_helpers.h b/include/git2/cred_helpers.h
index e3eb91d..5d93cf4 100644
--- a/include/git2/cred_helpers.h
+++ b/include/git2/cred_helpers.h
@@ -30,11 +30,11 @@ typedef struct git_cred_userpass_payload {
 /**
  * Stock callback usable as a git_cred_acquire_cb.  This calls
  * git_cred_userpass_plaintext_new unless the protocol has not specified
- * GIT_CREDTYPE_USERPASS_PLAINTEXT as an allowed type.
+ * `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type.
  *
  * @param cred The newly created credential object.
  * @param url The resource for which we are demanding a credential.
- * @param username_from_url The username that was embedded in a "user@host"
+ * @param user_from_url The username that was embedded in a "user@host"
  *                          remote url, or NULL if not included.
  * @param allowed_types A bitmask stating which cred types are OK to return.
  * @param payload The payload provided when specifying this callback.  (This is
diff --git a/include/git2/diff.h b/include/git2/diff.h
index d9ceadf..0ef47c0 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -88,42 +88,61 @@ typedef enum {
 	GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
 	/** Include unmodified files in the diff list */
 	GIT_DIFF_INCLUDE_UNMODIFIED = (1 << 9),
+
 	/** Even with GIT_DIFF_INCLUDE_UNTRACKED, an entire untracked directory
 	 *  will be marked with only a single entry in the diff list; this flag
 	 *  adds all files under the directory as UNTRACKED entries, too.
 	 */
 	GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1 << 10),
+
 	/** If the pathspec is set in the diff options, this flags means to
 	 *  apply it as an exact match instead of as an fnmatch pattern.
 	 */
 	GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1 << 11),
+
 	/** Use case insensitive filename comparisons */
 	GIT_DIFF_DELTAS_ARE_ICASE = (1 << 12),
+
 	/** When generating patch text, include the content of untracked files */
 	GIT_DIFF_INCLUDE_UNTRACKED_CONTENT = (1 << 13),
+
 	/** Disable updating of the `binary` flag in delta records.  This is
 	 *  useful when iterating over a diff if you don't need hunk and data
 	 *  callbacks and want to avoid having to load file completely.
 	 */
 	GIT_DIFF_SKIP_BINARY_CHECK = (1 << 14),
+
 	/** Normally, a type change between files will be converted into a
 	 *  DELETED record for the old and an ADDED record for the new; this
 	 *  options enabled the generation of TYPECHANGE delta records.
 	 */
 	GIT_DIFF_INCLUDE_TYPECHANGE = (1 << 15),
+
 	/** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still
 	 *  generally show as a DELETED blob.  This flag tries to correctly
 	 *  label blob->tree transitions as TYPECHANGE records with new_file's
 	 *  mode set to tree.  Note: the tree SHA will not be available.
 	 */
 	GIT_DIFF_INCLUDE_TYPECHANGE_TREES  = (1 << 16),
+
 	/** Ignore file mode changes */
 	GIT_DIFF_IGNORE_FILEMODE = (1 << 17),
+
 	/** Even with GIT_DIFF_INCLUDE_IGNORED, an entire ignored directory
 	 *  will be marked with only a single entry in the diff list; this flag
 	 *  adds all files under the directory as IGNORED entries, too.
 	 */
 	GIT_DIFF_RECURSE_IGNORED_DIRS = (1 << 18),
+
+	/** Core Git scans inside untracked directories, labeling them IGNORED
+	 *  if they are empty or only contain ignored files; a directory is
+	 *  consider UNTRACKED only if it has an actual untracked file in it.
+	 *  This scan is extra work for a case you often don't care about.  This
+	 *  flag makes libgit2 immediately label an untracked directory as
+	 *  UNTRACKED without looking insde it (which differs from core Git).
+	 *  Of course, ignore rules are still checked for the directory itself.
+	 */
+	GIT_DIFF_FAST_UNTRACKED_DIRS = (1 << 19),
 } git_diff_option_t;
 
 /**
diff --git a/include/git2/index.h b/include/git2/index.h
index 3d4bd15..d23c3a8 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -84,13 +84,6 @@ typedef struct git_index_entry {
 	char *path;
 } git_index_entry;
 
-/** Representation of a resolve undo entry in the index. */
-typedef struct git_index_reuc_entry {
-	unsigned int mode[3];
-	git_oid oid[3];
-	char *path;
-} git_index_reuc_entry;
-
 /** Capabilities of system that affect index actions. */
 enum {
 	GIT_INDEXCAP_IGNORE_CASE = 1,
@@ -478,102 +471,6 @@ GIT_EXTERN(int) git_index_has_conflicts(const git_index *index);
 
 /**@}*/
 
-/** @name Resolve Undo (REUC) index entry manipulation.
- *
- * These functions work on the Resolve Undo index extension and contains
- * data about the original files that led to a merge conflict.
- */
-/**@{*/
-
-/**
- * Get the count of resolve undo entries currently in the index.
- *
- * @param index an existing index object
- * @return integer of count of current resolve undo entries
- */
-GIT_EXTERN(unsigned int) git_index_reuc_entrycount(git_index *index);
-
-/**
- * Finds the resolve undo entry that points to the given path in the Git
- * index.
- *
- * @param at_pos the address to which the position of the reuc entry is written (optional)
- * @param index an existing index object
- * @param path path to search
- * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
- */
-GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
-
-/**
- * Get a resolve undo entry from the index.
- *
- * The returned entry is read-only and should not be modified
- * or freed by the caller.
- *
- * @param index an existing index object
- * @param path path to search
- * @return the resolve undo entry; NULL if not found
- */
-GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
-
-/**
- * Get a resolve undo entry from the index.
- *
- * The returned entry is read-only and should not be modified
- * or freed by the caller.
- *
- * @param index an existing index object
- * @param n the position of the entry
- * @return a pointer to the resolve undo entry; NULL if out of bounds
- */
-GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
-
-/**
- * Adds a resolve undo entry for a file based on the given parameters.
- *
- * The resolve undo entry contains the OIDs of files that were involved
- * in a merge conflict after the conflict has been resolved.  This allows
- * conflicts to be re-resolved later.
- *
- * If there exists a resolve undo entry for the given path in the index,
- * it will be removed.
- *
- * This method will fail in bare index instances.
- *
- * @param index an existing index object
- * @param path filename to add
- * @param ancestor_mode mode of the ancestor file
- * @param ancestor_id oid of the ancestor file
- * @param our_mode mode of our file
- * @param our_id oid of our file
- * @param their_mode mode of their file
- * @param their_id oid of their file
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
-	int ancestor_mode, git_oid *ancestor_id,
-	int our_mode, git_oid *our_id,
-	int their_mode, git_oid *their_id);
-
-/**
- * Remove an resolve undo entry from the index
- *
- * @param index an existing index object
- * @param n position of the resolve undo entry to remove
- * @return 0 or an error code
- */
-GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
-
-/**
- * Remove all resolve undo entries from the index
- *
- * @param index an existing index object
- * @return 0 or an error code
- */
-GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
-
-/**@}*/
-
 /** @} */
 GIT_END_DECL
 #endif
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index dfe6ae5..262dcd1 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -8,31 +8,11 @@
 #define _INCLUDE_git_indexer_h__
 
 #include "common.h"
+#include "types.h"
 #include "oid.h"
 
 GIT_BEGIN_DECL
 
-/**
- * This is passed as the first argument to the callback to allow the
- * user to see the progress.
- */
-typedef struct git_transfer_progress {
-	unsigned int total_objects;
-	unsigned int indexed_objects;
-	unsigned int received_objects;
-	size_t received_bytes;
-} git_transfer_progress;
-
-
-/**
- * Type for progress callbacks during indexing.  Return a value less than zero
- * to cancel the transfer.
- *
- * @param stats Structure containing information about the state of the transfer
- * @param payload Payload provided by caller
- */
-typedef int (*git_transfer_progress_callback)(const git_transfer_progress *stats, void *payload);
-
 typedef struct git_indexer_stream git_indexer_stream;
 
 /**
diff --git a/include/git2/merge.h b/include/git2/merge.h
index f4c5d98..8ca90b9 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -7,20 +7,65 @@
 #ifndef INCLUDE_git_merge_h__
 #define INCLUDE_git_merge_h__
 
-#include "common.h"
-#include "types.h"
-#include "oid.h"
+#include "git2/common.h"
+#include "git2/types.h"
+#include "git2/oid.h"
+#include "git2/checkout.h"
+#include "git2/index.h"
 
 /**
  * @file git2/merge.h
- * @brief Git merge-base routines
- * @defgroup git_revwalk Git merge-base routines
+ * @brief Git merge routines
+ * @defgroup git_merge Git merge routines
  * @ingroup Git
  * @{
  */
 GIT_BEGIN_DECL
 
 /**
+ * Flags for tree_many diff options.  A combination of these flags can be
+ * passed in via the `flags` value in the `git_diff_tree_many_options`.
+ */
+typedef enum {
+	/** Detect renames */
+	GIT_MERGE_TREE_FIND_RENAMES = (1 << 0),
+} git_merge_tree_flags;
+
+/**
+ * Automerge options for `git_merge_trees_opts`.
+ */ 
+typedef enum {
+	GIT_MERGE_AUTOMERGE_NORMAL = 0,
+	GIT_MERGE_AUTOMERGE_NONE = 1,
+	GIT_MERGE_AUTOMERGE_FAVOR_OURS = 2,
+	GIT_MERGE_AUTOMERGE_FAVOR_THEIRS = 3,
+} git_merge_automerge_flags;
+
+
+typedef struct {
+	unsigned int version;
+	git_merge_tree_flags flags;
+	
+	/** Similarity to consider a file renamed (default 50) */
+	unsigned int rename_threshold;
+	
+	/** Maximum similarity sources to examine (overrides the
+	 * `merge.renameLimit` config) (default 200)
+	 */
+	unsigned int target_limit;
+
+    /** Pluggable similarity metric; pass NULL to use internal metric */
+	git_diff_similarity_metric *metric;
+	
+	/** Flags for automerging content. */
+	git_merge_automerge_flags automerge_flags;
+} git_merge_tree_opts;
+
+#define GIT_MERGE_TREE_OPTS_VERSION 1
+#define GIT_MERGE_TREE_OPTS_INIT {GIT_MERGE_TREE_OPTS_VERSION}
+
+
+/**
  * Find a merge base between two commits
  *
  * @param out the OID of a merge base between 'one' and 'two'
@@ -50,6 +95,28 @@ GIT_EXTERN(int) git_merge_base_many(
 	const git_oid input_array[],
 	size_t length);
 
+/**
+ * Merge two trees, producing a `git_index` that reflects the result of
+ * the merge.
+ *
+ * The returned index must be freed explicitly with `git_index_free`.
+ *
+ * @param out pointer to store the index result in
+ * @param repo repository that contains the given trees
+ * @param ancestor_tree the common ancestor between the trees (or null if none)
+ * @param our_tree the tree that reflects the destination tree
+ * @param their_tree the tree to merge in to `our_tree`
+ * @param opts the merge tree options (or null for defaults)
+ * @return zero on success, -1 on failure.
+ */
+GIT_EXTERN(int) git_merge_trees(
+	git_index **out,
+	git_repository *repo,
+	const git_tree *ancestor_tree,
+	const git_tree *our_tree,
+	const git_tree *their_tree,
+	const git_merge_tree_opts *opts);
+
 /** @} */
 GIT_END_DECL
 #endif
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 8fd1a95..b64436c 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -10,8 +10,6 @@
 #include "common.h"
 #include "types.h"
 #include "oid.h"
-#include "odb_backend.h"
-#include "indexer.h"
 
 /**
  * @file git2/odb.h
@@ -23,6 +21,11 @@
 GIT_BEGIN_DECL
 
 /**
+ * Function type for callbacks from git_odb_foreach.
+ */
+typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
+
+/**
  * Create a new object database with no backends.
  *
  * Before the ODB can be used for read/writing, a custom database
@@ -53,42 +56,6 @@ GIT_EXTERN(int) git_odb_new(git_odb **out);
 GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
 
 /**
- * Add a custom backend to an existing Object DB
- *
- * The backends are checked in relative ordering, based on the
- * value of the `priority` parameter.
- *
- * Read <odb_backends.h> for more information.
- *
- * @param odb database to add the backend to
- * @param backend pointer to a git_odb_backend instance
- * @param priority Value for ordering the backends queue
- * @return 0 on success; error code otherwise
- */
-GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
-
-/**
- * Add a custom backend to an existing Object DB; this
- * backend will work as an alternate.
- *
- * Alternate backends are always checked for objects *after*
- * all the main backends have been exhausted.
- *
- * The backends are checked in relative ordering, based on the
- * value of the `priority` parameter.
- *
- * Writing is disabled on alternate backends.
- *
- * Read <odb_backends.h> for more information.
- *
- * @param odb database to add the backend to
- * @param backend pointer to a git_odb_backend instance
- * @param priority Value for ordering the backends queue
- * @return 0 on success; error code otherwise
- */
-GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
-
-/**
  * Add an on-disk alternate to an existing Object DB.
  *
  * Note that the added path must point to an `objects`, not
@@ -406,6 +373,60 @@ GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
  */
 GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
 
+/**
+ * Add a custom backend to an existing Object DB
+ *
+ * The backends are checked in relative ordering, based on the
+ * value of the `priority` parameter.
+ *
+ * Read <odb_backends.h> for more information.
+ *
+ * @param odb database to add the backend to
+ * @param backend pointer to a git_odb_backend instance
+ * @param priority Value for ordering the backends queue
+ * @return 0 on success; error code otherwise
+ */
+GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
+
+/**
+ * Add a custom backend to an existing Object DB; this
+ * backend will work as an alternate.
+ *
+ * Alternate backends are always checked for objects *after*
+ * all the main backends have been exhausted.
+ *
+ * The backends are checked in relative ordering, based on the
+ * value of the `priority` parameter.
+ *
+ * Writing is disabled on alternate backends.
+ *
+ * Read <odb_backends.h> for more information.
+ *
+ * @param odb database to add the backend to
+ * @param backend pointer to a git_odb_backend instance
+ * @param priority Value for ordering the backends queue
+ * @return 0 on success; error code otherwise
+ */
+GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
+
+/**
+ * Get the number of ODB backend objects
+ *
+ * @param odb object database
+ * @return number of backends in the ODB
+ */
+GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb);
+
+/**
+ * Lookup an ODB backend object by index
+ *
+ * @param out output pointer to ODB backend at pos
+ * @param odb object database
+ * @param pos index into object database backend list
+ * @return 0 on success; GIT_ENOTFOUND if pos is invalid; other errors < 0
+ */
+GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos);
+
 /** @} */
 GIT_END_DECL
 #endif
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index dbc3981..4c2493a 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -7,106 +7,56 @@
 #ifndef INCLUDE_git_odb_backend_h__
 #define INCLUDE_git_odb_backend_h__
 
-#include "common.h"
-#include "types.h"
-#include "oid.h"
-#include "indexer.h"
+#include "git2/common.h"
+#include "git2/types.h"
 
 /**
  * @file git2/backend.h
  * @brief Git custom backend functions
- * @defgroup git_backend Git custom backend API
+ * @defgroup git_odb Git object database routines
  * @ingroup Git
  * @{
  */
 GIT_BEGIN_DECL
 
-struct git_odb_stream;
-struct git_odb_writepack;
+/*
+ * Constructors for in-box ODB backends.
+ */
 
 /**
- * Function type for callbacks from git_odb_foreach.
+ * Create a backend for the packfiles.
+ *
+ * @param out location to store the odb backend pointer
+ * @param objects_dir the Git repository's objects directory
+ *
+ * @return 0 or an error code
  */
-typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
+GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir);
 
 /**
- * An instance for a custom backend
+ * Create a backend for loose objects
+ *
+ * @param out location to store the odb backend pointer
+ * @param objects_dir the Git repository's objects directory
+ * @param compression_level zlib compression level to use
+ * @param do_fsync whether to do an fsync() after writing (currently ignored)
+ *
+ * @return 0 or an error code
  */
-struct git_odb_backend {
-	unsigned int version;
-	git_odb *odb;
-
-	/* read and read_prefix each return to libgit2 a buffer which
-	 * will be freed later. The buffer should be allocated using
-	 * the function git_odb_backend_malloc to ensure that it can
-	 * be safely freed later. */
-	int (* read)(
-			void **, size_t *, git_otype *,
-			struct git_odb_backend *,
-			const git_oid *);
-
-	/* To find a unique object given a prefix
-	 * of its oid.
-	 * The oid given must be so that the
-	 * remaining (GIT_OID_HEXSZ - len)*4 bits
-	 * are 0s.
-	 */
-	int (* read_prefix)(
-			git_oid *,
-			void **, size_t *, git_otype *,
-			struct git_odb_backend *,
-			const git_oid *,
-			size_t);
-
-	int (* read_header)(
-			size_t *, git_otype *,
-			struct git_odb_backend *,
-			const git_oid *);
-
-	/* The writer may assume that the object
-	 * has already been hashed and is passed
-	 * in the first parameter.
-	 */
-	int (* write)(
-			git_oid *,
-			struct git_odb_backend *,
-			const void *,
-			size_t,
-			git_otype);
-
-	int (* writestream)(
-			struct git_odb_stream **,
-			struct git_odb_backend *,
-			size_t,
-			git_otype);
-
-	int (* readstream)(
-			struct git_odb_stream **,
-			struct git_odb_backend *,
-			const git_oid *);
-
-	int (* exists)(
-			struct git_odb_backend *,
-			const git_oid *);
-
-	int (* refresh)(struct git_odb_backend *);
-
-	int (* foreach)(
-			struct git_odb_backend *,
-			git_odb_foreach_cb cb,
-			void *payload);
-
-	int (* writepack)(
-			struct git_odb_writepack **,
-			struct git_odb_backend *,
-			git_transfer_progress_callback progress_cb,
-			void *progress_payload);
-
-	void (* free)(struct git_odb_backend *);
-};
+GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **out, const char *objects_dir, int compression_level, int do_fsync);
 
-#define GIT_ODB_BACKEND_VERSION 1
-#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION}
+/**
+ * Create a backend out of a single packfile
+ *
+ * This can be useful for inspecting the contents of a single
+ * packfile.
+ *
+ * @param out location to store the odb backend pointer
+ * @param index_file path to the packfile's .idx file
+ *
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file);
 
 /** Streaming mode */
 enum {
@@ -117,33 +67,24 @@ enum {
 
 /** A stream to read/write from a backend */
 struct git_odb_stream {
-	struct git_odb_backend *backend;
+	git_odb_backend *backend;
 	unsigned int mode;
 
-	int (*read)(struct git_odb_stream *stream, char *buffer, size_t len);
-	int (*write)(struct git_odb_stream *stream, const char *buffer, size_t len);
-	int (*finalize_write)(git_oid *oid_p, struct git_odb_stream *stream);
-	void (*free)(struct git_odb_stream *stream);
+	int (*read)(git_odb_stream *stream, char *buffer, size_t len);
+	int (*write)(git_odb_stream *stream, const char *buffer, size_t len);
+	int (*finalize_write)(git_oid *oid_p, git_odb_stream *stream);
+	void (*free)(git_odb_stream *stream);
 };
 
 /** A stream to write a pack file to the ODB */
 struct git_odb_writepack {
-	struct git_odb_backend *backend;
+	git_odb_backend *backend;
 
-	int (*add)(struct git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
-	int (*commit)(struct git_odb_writepack *writepack, git_transfer_progress *stats);
-	void (*free)(struct git_odb_writepack *writepack);
+	int (*add)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
+	int (*commit)(git_odb_writepack *writepack, git_transfer_progress *stats);
+	void (*free)(git_odb_writepack *writepack);
 };
 
-GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
-
-/**
- * Constructors for in-box ODB backends.
- */
-GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir);
-GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **out, const char *objects_dir, int compression_level, int do_fsync);
-GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file);
-
 GIT_END_DECL
 
 #endif
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 862f4b2..b20bb22 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -145,19 +145,7 @@ GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src);
  * @param b second oid structure.
  * @return <0, 0, >0 if a < b, a == b, a > b.
  */
-GIT_INLINE(int) git_oid_cmp(const git_oid *a, const git_oid *b)
-{
-	const unsigned char *sha1 = a->id;
-	const unsigned char *sha2 = b->id;
-	int i;
-
-	for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
-		if (*sha1 != *sha2)
-			return *sha1 - *sha2;
-	}
-
-	return 0;
-}
+GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
 
 /**
  * Compare two oid structures for equality
@@ -193,6 +181,16 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len);
 GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str);
 
 /**
+ * Compare an oid to an hex formatted object id.
+ *
+ * @param id oid structure.
+ * @param str input hex string of an object id.
+ * @return -1 if str is not valid, <0 if id sorts before str,
+ *         0 if id matches str, >0 if id sorts after str.
+ */
+GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
+
+/**
  * Check is an oid is all zeros.
  *
  * @return 1 if all zeros, 0 otherwise.
diff --git a/include/git2/pack.h b/include/git2/pack.h
index 2f033be..118b8d5 100644
--- a/include/git2/pack.h
+++ b/include/git2/pack.h
@@ -95,6 +95,18 @@ GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *id, c
 GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *id);
 
 /**
+ * Insert a commit object
+ * 
+ * This will add a commit as well as the completed referenced tree.
+ * 
+ * @param pb The packbuilder
+ * @param id The oid of the commit
+ * 
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id);
+
+/**
  * Write the new pack and the corresponding index to path
  *
  * @param pb The packbuilder
diff --git a/include/git2/refdb.h b/include/git2/refdb.h
index 0586b11..a315876 100644
--- a/include/git2/refdb.h
+++ b/include/git2/refdb.h
@@ -22,22 +22,6 @@
 GIT_BEGIN_DECL
 
 /**
- * Create a new reference.  Either an oid or a symbolic target must be
- * specified.
- *
- * @param refdb the reference database to associate with this reference
- * @param name the reference name
- * @param oid the object id for a direct reference
- * @param symbolic the target for a symbolic reference
- * @return the created git_reference or NULL on error
- */
-GIT_EXTERN(git_reference *) git_reference__alloc(
-	git_refdb *refdb,
-	const char *name,
-	const git_oid *oid,
-	const char *symbolic);
-
-/**
  * Create a new reference database with no backends.
  *
  * Before the Ref DB can be used for read/writing, a custom database
@@ -78,20 +62,6 @@ GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);
  */
 GIT_EXTERN(void) git_refdb_free(git_refdb *refdb);
 
-/**
- * Sets the custom backend to an existing reference DB
- *
- * Read <refdb_backends.h> for more information.
- *
- * @param refdb database to add the backend to
- * @param backend pointer to a git_refdb_backend instance
- * @param priority Value for ordering the backends queue
- * @return 0 on success; error code otherwise
- */
-GIT_EXTERN(int) git_refdb_set_backend(
-	git_refdb *refdb,
-	git_refdb_backend *backend);
-
 /** @} */
 GIT_END_DECL
 
diff --git a/include/git2/refdb_backend.h b/include/git2/refdb_backend.h
deleted file mode 100644
index bf33817..0000000
--- a/include/git2/refdb_backend.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_git_refdb_backend_h__
-#define INCLUDE_git_refdb_backend_h__
-
-#include "common.h"
-#include "types.h"
-#include "oid.h"
-
-/**
- * @file git2/refdb_backend.h
- * @brief Git custom refs backend functions
- * @defgroup git_refdb_backend Git custom refs backend API
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-/** An instance for a custom backend */
-struct git_refdb_backend {
-    unsigned int version;
-
-	/**
-	 * Queries the refdb backend to determine if the given ref_name
-	 * exists.  A refdb implementation must provide this function.
-	 */
-	int (*exists)(
-		int *exists,
-		struct git_refdb_backend *backend,
-		const char *ref_name);
-
-	/**
-	 * Queries the refdb backend for a given reference.  A refdb
-	 * implementation must provide this function.
-	 */
-	int (*lookup)(
-		git_reference **out,
-		struct git_refdb_backend *backend,
-		const char *ref_name);
-
-	/**
-	 * Enumerates each reference in the refdb.  A refdb implementation must
-	 * provide this function.
-	 */
-	int (*foreach)(
-		struct git_refdb_backend *backend,
-		unsigned int list_flags,
-		git_reference_foreach_cb callback,
-		void *payload);
-
-	/**
-	 * Enumerates each reference in the refdb that matches the given
-	 * glob string.  A refdb implementation may provide this function;
-	 * if it is not provided, foreach will be used and the results filtered
-	 * against the glob.
-	 */
-	int (*foreach_glob)(
-		struct git_refdb_backend *backend,
-		const char *glob,
-		unsigned int list_flags,
-		git_reference_foreach_cb callback,
-		void *payload);
-
-	/**
-	 * Writes the given reference to the refdb.  A refdb implementation
-	 * must provide this function.
-	 */
-	int (*write)(struct git_refdb_backend *backend, const git_reference *ref);
-
-	/**
-	 * Deletes the given reference from the refdb.  A refdb implementation
-	 * must provide this function.
-	 */
-	int (*delete)(struct git_refdb_backend *backend, const git_reference *ref);
-
-	/**
-	 * Suggests that the given refdb compress or optimize its references.
-	 * This mechanism is implementation specific.  (For on-disk reference
-	 * databases, this may pack all loose references.)    A refdb
-	 * implementation may provide this function; if it is not provided,
-	 * nothing will be done.
-	 */
-	int (*compress)(struct git_refdb_backend *backend);
-
-	/**
-	 * Frees any resources held by the refdb.  A refdb implementation may
-	 * provide this function; if it is not provided, nothing will be done.
-	 */
-	void (*free)(struct git_refdb_backend *backend);
-};
-
-#define GIT_ODB_BACKEND_VERSION 1
-#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION}
-
-/**
- * Constructors for default refdb backends.
- */
-GIT_EXTERN(int) git_refdb_backend_fs(
-	struct git_refdb_backend **backend_out,
-	git_repository *repo,
-	git_refdb *refdb);
-
-GIT_END_DECL
-
-#endif
diff --git a/include/git2/refs.h b/include/git2/refs.h
index e0451ba..e1d4253 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -133,6 +133,17 @@ GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo, 
 GIT_EXTERN(const git_oid *) git_reference_target(const git_reference *ref);
 
 /**
+ * Return the peeled OID target of this reference.
+ *
+ * This peeled OID only applies to direct references that point to
+ * a hard Tag object: it is the result of peeling such Tag.
+ *
+ * @param ref The reference
+ * @return a pointer to the oid if available, NULL otherwise
+ */
+GIT_EXTERN(const git_oid *) git_reference_target_peel(const git_reference *ref);
+
+/**
  * Get full name to the reference pointed to by a symbolic reference.
  *
  * Only available if the reference is symbolic.
@@ -411,6 +422,13 @@ typedef enum {
 	 * (e.g., foo/<star>/bar but not foo/bar<star>).
 	 */
 	GIT_REF_FORMAT_REFSPEC_PATTERN = (1 << 1),
+
+	/**
+	 * Interpret the name as part of a refspec in shorthand form
+	 * so the `ONELEVEL` naming rules aren't enforced and 'master'
+	 * becomes a valid name.
+	 */
+	GIT_REF_FORMAT_REFSPEC_SHORTHAND = (1 << 2),
 } git_reference_normalize_t;
 
 /**
diff --git a/include/git2/refspec.h b/include/git2/refspec.h
index ec7830b..c0b410c 100644
--- a/include/git2/refspec.h
+++ b/include/git2/refspec.h
@@ -9,6 +9,7 @@
 
 #include "common.h"
 #include "types.h"
+#include "net.h"
 
 /**
  * @file git2/refspec.h
@@ -36,6 +37,14 @@ GIT_EXTERN(const char *) git_refspec_src(const git_refspec *refspec);
 GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
 
 /**
+ * Get the refspec's string
+ *
+ * @param refspec the refspec
+ * @returns the refspec's original string
+ */
+GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec);
+
+/**
  * Get the force update setting
  *
  * @param refspec the refspec
@@ -44,6 +53,14 @@ GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
 GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec);
 
 /**
+ * Get the refspec's direction.
+ *
+ * @param the refspec
+ * @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH
+ */
+GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec);
+
+/**
  * Check if a refspec's source descriptor matches a reference 
  *
  * @param refspec the refspec
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 6f36a39..2aa384a 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -142,39 +142,79 @@ GIT_EXTERN(int) git_remote_set_url(git_remote *remote, const char* url);
 GIT_EXTERN(int) git_remote_set_pushurl(git_remote *remote, const char* url);
 
 /**
- * Set the remote's fetch refspec
+ * Add a fetch refspec to the remote
  *
  * @param remote the remote
- * @apram spec the new fetch refspec
+ * @apram refspec the new fetch refspec
  * @return 0 or an error value
  */
-GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
+GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec);
 
 /**
- * Get the fetch refspec
+ * Get the remote's list of fetch refspecs
  *
- * @param remote the remote
- * @return a pointer to the fetch refspec or NULL if it doesn't exist
+ * The memory is owned by the user and should be freed with
+ * `git_strarray_free`.
+ *
+ * @param array pointer to the array in which to store the strings
+ * @param remote the remote to query
  */
-GIT_EXTERN(const git_refspec *) git_remote_fetchspec(const git_remote *remote);
+GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, git_remote *remote);
 
 /**
- * Set the remote's push refspec
+ * Add a push refspec to the remote
  *
  * @param remote the remote
- * @param spec the new push refspec
+ * @param refspec the new push refspec
  * @return 0 or an error value
  */
-GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
+GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec);
+
+/**
+ * Get the remote's list of push refspecs
+ *
+ * The memory is owned by the user and should be freed with
+ * `git_strarray_free`.
+ *
+ * @param array pointer to the array in which to store the strings
+ * @param remote the remote to query
+ */
+GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, git_remote *remote);
+
+/**
+ * Clear the refspecs
+ *
+ * Remove all configured fetch and push refspecs from the remote.
+ *
+ * @param remote the remote
+ */
+GIT_EXTERN(void) git_remote_clear_refspecs(git_remote *remote);
 
 /**
- * Get the push refspec
+ * Get the number of refspecs for a remote
  *
  * @param remote the remote
- * @return a pointer to the push refspec or NULL if it doesn't exist
+ * @return the amount of refspecs configured in this remote
+ */
+GIT_EXTERN(size_t) git_remote_refspec_count(git_remote *remote);
+
+/**
+ * Get a refspec from the remote
+ *
+ * @param remote the remote to query
+ * @param n the refspec to get
+ * @return the nth refspec
  */
+GIT_EXTERN(const git_refspec *)git_remote_get_refspec(git_remote *remote, size_t n);
 
-GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
+/**
+ * Remove a refspec from the remote
+ *
+ * @param remote the remote to query
+ * @param n the refspec to remove
+ * @return 0 or GIT_ENOTFOUND
+ */
+GIT_EXTERN(int) git_remote_remove_refspec(git_remote *remote, size_t n);
 
 /**
  * Open a connection to a remote
@@ -184,7 +224,8 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
  * starts up a specific binary which can only do the one or the other.
  *
  * @param remote the remote to connect to
- * @param direction whether you want to receive or send data
+ * @param direction GIT_DIRECTION_FETCH if you want to fetch or
+ * GIT_DIRECTION_PUSH if you want to push
  * @return 0 or an error code
  */
 GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
diff --git a/include/git2/repository.h b/include/git2/repository.h
index e75c8b1..cd238e1 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -124,6 +124,19 @@ GIT_EXTERN(int) git_repository_open_ext(
 	const char *ceiling_dirs);
 
 /**
+ * Open a bare repository on the serverside.
+ *
+ * This is a fast open for bare repositories that will come in handy
+ * if you're e.g. hosting git repositories and need to access them
+ * efficiently
+ *
+ * @param out Pointer to the repo which will be opened.
+ * @param bare_path Direct path to the bare repository
+ * @return 0 on success, or an error code
+ */
+GIT_EXTERN(int) git_repository_open_bare(git_repository **out, const char *bare_path);
+
+/**
  * Free a previously allocated repository
  *
  * Note that after a repository is free'd, all the objects it has spawned
@@ -388,21 +401,6 @@ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
 GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
 
 /**
- * Set the configuration file for this repository
- *
- * This configuration file will be used for all configuration
- * queries involving this repository.
- *
- * The repository will keep a reference to the config file;
- * the user must still free the config after setting it
- * to the repository, or it will leak.
- *
- * @param repo A repository object
- * @param config A Config object
- */
-GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
-
-/**
  * Get the Object Database for this repository.
  *
  * If a custom ODB has not been set, the default
@@ -419,21 +417,6 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con
 GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
 
 /**
- * Set the Object Database for this repository
- *
- * The ODB will be used for all object-related operations
- * involving this repository.
- *
- * The repository will keep a reference to the ODB; the user
- * must still free the ODB object after setting it to the
- * repository, or it will leak.
- *
- * @param repo A repository object
- * @param odb An ODB object
- */
-GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
-
-/**
  * Get the Reference Database Backend for this repository.
  *
  * If a custom refsdb has not been set, the default database for
@@ -450,23 +433,6 @@ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
 GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo);
 
 /**
- * Set the Reference Database Backend for this repository
- *
- * The refdb will be used for all reference related operations
- * involving this repository.
- *
- * The repository will keep a reference to the refdb; the user
- * must still free the refdb object after setting it to the
- * repository, or it will leak.
- *
- * @param repo A repository object
- * @param refdb An refdb object
- */
-GIT_EXTERN(void) git_repository_set_refdb(
-	git_repository *repo,
-	git_refdb *refdb);
-
-/**
  * Get the Index file for this repository.
  *
  * If a custom index has not been set, the default
@@ -483,21 +449,6 @@ GIT_EXTERN(void) git_repository_set_refdb(
 GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
 
 /**
- * Set the index file for this repository
- *
- * This index will be used for all index-related operations
- * involving this repository.
- *
- * The repository will keep a reference to the index file;
- * the user must still free the index after setting it
- * to the repository, or it will leak.
- *
- * @param repo A repository object
- * @param index An index object
- */
-GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
-
-/**
  * Retrieve git's prepared message
  *
  * Operations such as git revert/cherry-pick/merge with the -n option
@@ -675,6 +626,28 @@ typedef enum {
  */
 GIT_EXTERN(int) git_repository_state(git_repository *repo);
 
+/**
+ * Sets the active namespace for this Git Repository
+ *
+ * This namespace affects all reference operations for the repo.
+ * See `man gitnamespaces`
+ *
+ * @param repo The repo
+ * @param nmspace The namespace. This should not include the refs
+ *	folder, e.g. to namespace all references under `refs/namespaces/foo/`,
+ *	use `foo` as the namespace.
+ *	@return 0 on success, -1 on error
+ */
+GIT_EXTERN(int) git_repository_set_namespace(git_repository *repo, const char *nmspace);
+
+/**
+ * Get the currently active namespace for this repository
+ *
+ * @param repo The repo
+ * @return the active namespace, or NULL if there isn't one
+ */
+GIT_EXTERN(const char *) git_repository_get_namespace(git_repository *repo);
+
 /** @} */
 GIT_END_DECL
 #endif
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index 40934b3..0046650 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -103,20 +103,20 @@ typedef enum {
  * * WD_UNTRACKED      - wd contains untracked files
  */
 typedef enum {
-	 GIT_SUBMODULE_STATUS_IN_HEAD           = (1u << 0),
-	 GIT_SUBMODULE_STATUS_IN_INDEX          = (1u << 1),
-	 GIT_SUBMODULE_STATUS_IN_CONFIG         = (1u << 2),
-	 GIT_SUBMODULE_STATUS_IN_WD             = (1u << 3),
-	 GIT_SUBMODULE_STATUS_INDEX_ADDED       = (1u << 4),
-	 GIT_SUBMODULE_STATUS_INDEX_DELETED     = (1u << 5),
-	 GIT_SUBMODULE_STATUS_INDEX_MODIFIED    = (1u << 6),
-	 GIT_SUBMODULE_STATUS_WD_UNINITIALIZED  = (1u << 7),
-	 GIT_SUBMODULE_STATUS_WD_ADDED          = (1u << 8),
-	 GIT_SUBMODULE_STATUS_WD_DELETED        = (1u << 9),
-	 GIT_SUBMODULE_STATUS_WD_MODIFIED       = (1u << 10),
-	 GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = (1u << 11),
-	 GIT_SUBMODULE_STATUS_WD_WD_MODIFIED    = (1u << 12),
-	 GIT_SUBMODULE_STATUS_WD_UNTRACKED      = (1u << 13),
+	GIT_SUBMODULE_STATUS_IN_HEAD           = (1u << 0),
+	GIT_SUBMODULE_STATUS_IN_INDEX          = (1u << 1),
+	GIT_SUBMODULE_STATUS_IN_CONFIG         = (1u << 2),
+	GIT_SUBMODULE_STATUS_IN_WD             = (1u << 3),
+	GIT_SUBMODULE_STATUS_INDEX_ADDED       = (1u << 4),
+	GIT_SUBMODULE_STATUS_INDEX_DELETED     = (1u << 5),
+	GIT_SUBMODULE_STATUS_INDEX_MODIFIED    = (1u << 6),
+	GIT_SUBMODULE_STATUS_WD_UNINITIALIZED  = (1u << 7),
+	GIT_SUBMODULE_STATUS_WD_ADDED          = (1u << 8),
+	GIT_SUBMODULE_STATUS_WD_DELETED        = (1u << 9),
+	GIT_SUBMODULE_STATUS_WD_MODIFIED       = (1u << 10),
+	GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = (1u << 11),
+	GIT_SUBMODULE_STATUS_WD_WD_MODIFIED    = (1u << 12),
+	GIT_SUBMODULE_STATUS_WD_UNTRACKED      = (1u << 13),
 } git_submodule_status_t;
 
 #define GIT_SUBMODULE_STATUS__IN_FLAGS \
diff --git a/include/git2/sys/commit.h b/include/git2/sys/commit.h
new file mode 100644
index 0000000..096e028
--- /dev/null
+++ b/include/git2/sys/commit.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_commit_h__
+#define INCLUDE_sys_git_commit_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+#include "git2/oid.h"
+
+/**
+ * @file git2/sys/commit.h
+ * @brief Low-level Git commit creation
+ * @defgroup git_backend Git custom backend APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Create new commit in the repository from a list of `git_oid` values
+ *
+ * See documentation for `git_commit_create()` for information about the
+ * parameters, as the meaning is identical excepting that `tree` and
+ * `parents` now take `git_oid`.  This is a dangerous API in that the
+ * `parents` list of `git_oid`s in not checked for validity.
+ */
+GIT_EXTERN(int) git_commit_create_from_oids(
+	git_oid *oid,
+	git_repository *repo,
+	const char *update_ref,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message,
+	const git_oid *tree,
+	int parent_count,
+	const git_oid *parents[]);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h
new file mode 100644
index 0000000..1c9deba
--- /dev/null
+++ b/include/git2/sys/config.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_config_backend_h__
+#define INCLUDE_sys_git_config_backend_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+#include "git2/config.h"
+
+/**
+ * @file git2/sys/config.h
+ * @brief Git config backend routines
+ * @defgroup git_backend Git custom backend APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Generic backend that implements the interface to
+ * access a configuration file
+ */
+struct git_config_backend {
+	unsigned int version;
+	struct git_config *cfg;
+
+	/* Open means open the file/database and parse if necessary */
+	int (*open)(struct git_config_backend *, unsigned int level);
+	int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
+	int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
+	int (*set)(struct git_config_backend *, const char *key, const char *value);
+	int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
+	int (*del)(struct git_config_backend *, const char *key);
+	int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
+	int (*refresh)(struct git_config_backend *);
+	void (*free)(struct git_config_backend *);
+};
+#define GIT_CONFIG_BACKEND_VERSION 1
+#define GIT_CONFIG_BACKEND_INIT {GIT_CONFIG_BACKEND_VERSION}
+
+/**
+ * Add a generic config file instance to an existing config
+ *
+ * Note that the configuration object will free the file
+ * automatically.
+ *
+ * Further queries on this config object will access each
+ * of the config file instances in order (instances with
+ * a higher priority level will be accessed first).
+ *
+ * @param cfg the configuration to add the file to
+ * @param file the configuration file (backend) to add
+ * @param level the priority level of the backend
+ * @param force if a config file already exists for the given
+ *  priority level, replace it
+ * @return 0 on success, GIT_EEXISTS when adding more than one file
+ *  for a given priority level (and force_replace set to 0), or error code
+ */
+GIT_EXTERN(int) git_config_add_backend(
+	git_config *cfg,
+	git_config_backend *file,
+	unsigned int level,
+	int force);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/sys/index.h b/include/git2/sys/index.h
new file mode 100644
index 0000000..f74637f
--- /dev/null
+++ b/include/git2/sys/index.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_index_h__
+#define INCLUDE_sys_git_index_h__
+
+/**
+ * @file git2/sys/index.h
+ * @brief Low-level Git index manipulation routines
+ * @defgroup git_backend Git custom backend APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/** Representation of a rename conflict entry in the index. */
+typedef struct git_index_name_entry {
+	char *ancestor;
+	char *ours;
+	char *theirs;
+} git_index_name_entry;
+
+/** Representation of a resolve undo entry in the index. */
+typedef struct git_index_reuc_entry {
+	unsigned int mode[3];
+	git_oid oid[3];
+	char *path;
+} git_index_reuc_entry;
+
+/** @name Conflict Name entry functions
+ *
+ * These functions work on rename conflict entries.
+ */
+/**@{*/
+
+/**
+ * Get the count of filename conflict entries currently in the index.
+ *
+ * @param index an existing index object
+ * @return integer of count of current filename conflict entries
+ */
+GIT_EXTERN(unsigned int) git_index_name_entrycount(git_index *index);
+
+/**
+ * Get a filename conflict entry from the index.
+ *
+ * The returned entry is read-only and should not be modified
+ * or freed by the caller.
+ *
+ * @param index an existing index object
+ * @param n the position of the entry
+ * @return a pointer to the filename conflict entry; NULL if out of bounds
+ */
+GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex(
+	git_index *index, size_t n);
+
+/**
+ * Record the filenames involved in a rename conflict.
+ *
+ * @param index an existing index object
+ * @param ancestor the path of the file as it existed in the ancestor
+ * @param ours the path of the file as it existed in our tree
+ * @param theirs the path of the file as it existed in their tree
+ */
+GIT_EXTERN(int) git_index_name_add(git_index *index,
+	const char *ancestor, const char *ours, const char *theirs);
+
+/**
+ * Remove all filename conflict entries.
+ *
+ * @param index an existing index object
+ * @return 0 or an error code
+ */
+GIT_EXTERN(void) git_index_name_clear(git_index *index);
+
+/**@}*/
+
+/** @name Resolve Undo (REUC) index entry manipulation.
+ *
+ * These functions work on the Resolve Undo index extension and contains
+ * data about the original files that led to a merge conflict.
+ */
+/**@{*/
+
+/**
+ * Get the count of resolve undo entries currently in the index.
+ *
+ * @param index an existing index object
+ * @return integer of count of current resolve undo entries
+ */
+GIT_EXTERN(unsigned int) git_index_reuc_entrycount(git_index *index);
+
+/**
+ * Finds the resolve undo entry that points to the given path in the Git
+ * index.
+ *
+ * @param at_pos the address to which the position of the reuc entry is written (optional)
+ * @param index an existing index object
+ * @param path path to search
+ * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
+ */
+GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
+
+/**
+ * Get a resolve undo entry from the index.
+ *
+ * The returned entry is read-only and should not be modified
+ * or freed by the caller.
+ *
+ * @param index an existing index object
+ * @param path path to search
+ * @return the resolve undo entry; NULL if not found
+ */
+GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
+
+/**
+ * Get a resolve undo entry from the index.
+ *
+ * The returned entry is read-only and should not be modified
+ * or freed by the caller.
+ *
+ * @param index an existing index object
+ * @param n the position of the entry
+ * @return a pointer to the resolve undo entry; NULL if out of bounds
+ */
+GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
+
+/**
+ * Adds a resolve undo entry for a file based on the given parameters.
+ *
+ * The resolve undo entry contains the OIDs of files that were involved
+ * in a merge conflict after the conflict has been resolved.  This allows
+ * conflicts to be re-resolved later.
+ *
+ * If there exists a resolve undo entry for the given path in the index,
+ * it will be removed.
+ *
+ * This method will fail in bare index instances.
+ *
+ * @param index an existing index object
+ * @param path filename to add
+ * @param ancestor_mode mode of the ancestor file
+ * @param ancestor_id oid of the ancestor file
+ * @param our_mode mode of our file
+ * @param our_id oid of our file
+ * @param their_mode mode of their file
+ * @param their_id oid of their file
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
+	int ancestor_mode, const git_oid *ancestor_id,
+	int our_mode, const git_oid *our_id,
+	int their_mode, const git_oid *their_id);
+
+/**
+ * Remove an resolve undo entry from the index
+ *
+ * @param index an existing index object
+ * @param n position of the resolve undo entry to remove
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
+
+/**
+ * Remove all resolve undo entries from the index
+ *
+ * @param index an existing index object
+ * @return 0 or an error code
+ */
+GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
+
+/**@}*/
+
+/** @} */
+GIT_END_DECL
+#endif
+
diff --git a/include/git2/sys/odb_backend.h b/include/git2/sys/odb_backend.h
new file mode 100644
index 0000000..3cd2734
--- /dev/null
+++ b/include/git2/sys/odb_backend.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_odb_backend_h__
+#define INCLUDE_sys_git_odb_backend_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+#include "git2/oid.h"
+#include "git2/odb.h"
+
+/**
+ * @file git2/sys/backend.h
+ * @brief Git custom backend implementors functions
+ * @defgroup git_backend Git custom backend APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * An instance for a custom backend
+ */
+struct git_odb_backend {
+	unsigned int version;
+	git_odb *odb;
+
+	/* read and read_prefix each return to libgit2 a buffer which
+	 * will be freed later. The buffer should be allocated using
+	 * the function git_odb_backend_malloc to ensure that it can
+	 * be safely freed later. */
+	int (* read)(
+		void **, size_t *, git_otype *, git_odb_backend *, const git_oid *);
+
+	/* To find a unique object given a prefix
+	 * of its oid.
+	 * The oid given must be so that the
+	 * remaining (GIT_OID_HEXSZ - len)*4 bits
+	 * are 0s.
+	 */
+	int (* read_prefix)(
+		git_oid *, void **, size_t *, git_otype *,
+		git_odb_backend *, const git_oid *, size_t);
+
+	int (* read_header)(
+		size_t *, git_otype *, git_odb_backend *, const git_oid *);
+
+	/* The writer may assume that the object
+	 * has already been hashed and is passed
+	 * in the first parameter.
+	 */
+	int (* write)(
+		git_oid *, git_odb_backend *, const void *, size_t, git_otype);
+
+	int (* writestream)(
+		git_odb_stream **, git_odb_backend *, size_t, git_otype);
+
+	int (* readstream)(
+		git_odb_stream **, git_odb_backend *, const git_oid *);
+
+	int (* exists)(
+		git_odb_backend *, const git_oid *);
+
+	int (* refresh)(git_odb_backend *);
+
+	int (* foreach)(
+		git_odb_backend *, git_odb_foreach_cb cb, void *payload);
+
+	int (* writepack)(
+		git_odb_writepack **, git_odb_backend *,
+		git_transfer_progress_callback progress_cb, void *progress_payload);
+
+	void (* free)(git_odb_backend *);
+};
+
+#define GIT_ODB_BACKEND_VERSION 1
+#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION}
+
+GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
+
+GIT_END_DECL
+
+#endif
diff --git a/include/git2/sys/refdb_backend.h b/include/git2/sys/refdb_backend.h
new file mode 100644
index 0000000..d5f599f
--- /dev/null
+++ b/include/git2/sys/refdb_backend.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_refdb_backend_h__
+#define INCLUDE_sys_git_refdb_backend_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+#include "git2/oid.h"
+
+/**
+ * @file git2/refdb_backend.h
+ * @brief Git custom refs backend functions
+ * @defgroup git_refdb_backend Git custom refs backend API
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/** An instance for a custom backend */
+struct git_refdb_backend {
+    unsigned int version;
+
+	/**
+	 * Queries the refdb backend to determine if the given ref_name
+	 * exists.  A refdb implementation must provide this function.
+	 */
+	int (*exists)(
+		int *exists,
+		git_refdb_backend *backend,
+		const char *ref_name);
+
+	/**
+	 * Queries the refdb backend for a given reference.  A refdb
+	 * implementation must provide this function.
+	 */
+	int (*lookup)(
+		git_reference **out,
+		git_refdb_backend *backend,
+		const char *ref_name);
+
+	/**
+	 * Enumerates each reference in the refdb.  A refdb implementation must
+	 * provide this function.
+	 */
+	int (*foreach)(
+		git_refdb_backend *backend,
+		unsigned int list_flags,
+		git_reference_foreach_cb callback,
+		void *payload);
+
+	/**
+	 * Enumerates each reference in the refdb that matches the given
+	 * glob string.  A refdb implementation may provide this function;
+	 * if it is not provided, foreach will be used and the results filtered
+	 * against the glob.
+	 */
+	int (*foreach_glob)(
+		git_refdb_backend *backend,
+		const char *glob,
+		unsigned int list_flags,
+		git_reference_foreach_cb callback,
+		void *payload);
+
+	/**
+	 * Writes the given reference to the refdb.  A refdb implementation
+	 * must provide this function.
+	 */
+	int (*write)(git_refdb_backend *backend, const git_reference *ref);
+
+	/**
+	 * Deletes the given reference from the refdb.  A refdb implementation
+	 * must provide this function.
+	 */
+	int (*delete)(git_refdb_backend *backend, const git_reference *ref);
+
+	/**
+	 * Suggests that the given refdb compress or optimize its references.
+	 * This mechanism is implementation specific.  (For on-disk reference
+	 * databases, this may pack all loose references.)    A refdb
+	 * implementation may provide this function; if it is not provided,
+	 * nothing will be done.
+	 */
+	int (*compress)(git_refdb_backend *backend);
+
+	/**
+	 * Frees any resources held by the refdb.  A refdb implementation may
+	 * provide this function; if it is not provided, nothing will be done.
+	 */
+	void (*free)(git_refdb_backend *backend);
+};
+
+#define GIT_ODB_BACKEND_VERSION 1
+#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION}
+
+/**
+ * Constructors for default filesystem-based refdb backend
+ *
+ * Under normal usage, this is called for you when the repository is
+ * opened / created, but you can use this to explicitly construct a
+ * filesystem refdb backend for a repository.
+ *
+ * @param backend_out Output pointer to the git_refdb_backend object
+ * @param repo Git repository to access
+ * @return 0 on success, <0 error code on failure
+ */
+GIT_EXTERN(int) git_refdb_backend_fs(
+	git_refdb_backend **backend_out,
+	git_repository *repo);
+
+/**
+ * Sets the custom backend to an existing reference DB
+ *
+ * The `git_refdb` will take ownership of the `git_refdb_backend` so you
+ * should NOT free it after calling this function.
+ *
+ * @param refdb database to add the backend to
+ * @param backend pointer to a git_refdb_backend instance
+ * @return 0 on success; error code otherwise
+ */
+GIT_EXTERN(int) git_refdb_set_backend(
+	git_refdb *refdb,
+	git_refdb_backend *backend);
+
+GIT_END_DECL
+
+#endif
diff --git a/include/git2/sys/refs.h b/include/git2/sys/refs.h
new file mode 100644
index 0000000..8596325
--- /dev/null
+++ b/include/git2/sys/refs.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_refdb_h__
+#define INCLUDE_sys_git_refdb_h__
+
+#include "git2/common.h"
+#include "git2/types.h"
+#include "git2/oid.h"
+
+/**
+ * Create a new direct reference from an OID.
+ *
+ * @param name the reference name
+ * @param oid the object id for a direct reference
+ * @param symbolic the target for a symbolic reference
+ * @return the created git_reference or NULL on error
+ */
+GIT_EXTERN(git_reference *) git_reference__alloc(
+	const char *name,
+	const git_oid *oid,
+	const git_oid *peel);
+
+/**
+ * Create a new symbolic reference.
+ *
+ * @param name the reference name
+ * @param symbolic the target for a symbolic reference
+ * @return the created git_reference or NULL on error
+ */
+GIT_EXTERN(git_reference *) git_reference__alloc_symbolic(
+	const char *name,
+	const char *target);
+
+#endif
diff --git a/include/git2/sys/repository.h b/include/git2/sys/repository.h
new file mode 100644
index 0000000..ba3d65a
--- /dev/null
+++ b/include/git2/sys/repository.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_sys_git_repository_h__
+#define INCLUDE_sys_git_repository_h__
+
+/**
+ * @file git2/sys/repository.h
+ * @brief Git repository custom implementation routines
+ * @defgroup git_backend Git custom backend APIs
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Create a new repository with neither backends nor config object
+ *
+ * Note that this is only useful if you wish to associate the repository
+ * with a non-filesystem-backed object database and config store.
+ *
+ * @param out The blank repository
+ * @return 0 on success, or an error code
+ */
+GIT_EXTERN(int) git_repository_new(git_repository **out);
+
+
+/**
+ * Reset all the internal state in a repository.
+ *
+ * This will free all the mapped memory and internal objects
+ * of the repository and leave it in a "blank" state.
+ *
+ * There's no need to call this function directly unless you're
+ * trying to aggressively cleanup the repo before its
+ * deallocation. `git_repository_free` already performs this operation
+ * before deallocation the repo.
+ */
+GIT_EXTERN(void) git_repository__cleanup(git_repository *repo);
+
+/**
+ * Set the configuration file for this repository
+ *
+ * This configuration file will be used for all configuration
+ * queries involving this repository.
+ *
+ * The repository will keep a reference to the config file;
+ * the user must still free the config after setting it
+ * to the repository, or it will leak.
+ *
+ * @param repo A repository object
+ * @param config A Config object
+ */
+GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
+
+/**
+ * Set the Object Database for this repository
+ *
+ * The ODB will be used for all object-related operations
+ * involving this repository.
+ *
+ * The repository will keep a reference to the ODB; the user
+ * must still free the ODB object after setting it to the
+ * repository, or it will leak.
+ *
+ * @param repo A repository object
+ * @param odb An ODB object
+ */
+GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
+
+/**
+ * Set the Reference Database Backend for this repository
+ *
+ * The refdb will be used for all reference related operations
+ * involving this repository.
+ *
+ * The repository will keep a reference to the refdb; the user
+ * must still free the refdb object after setting it to the
+ * repository, or it will leak.
+ *
+ * @param repo A repository object
+ * @param refdb An refdb object
+ */
+GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb);
+
+/**
+ * Set the index file for this repository
+ *
+ * This index will be used for all index-related operations
+ * involving this repository.
+ *
+ * The repository will keep a reference to the index file;
+ * the user must still free the index after setting it
+ * to the repository, or it will leak.
+ *
+ * @param repo A repository object
+ * @param index An index object
+ */
+GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/tag.h b/include/git2/tag.h
index 84c954c..469b1d7 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -30,12 +30,8 @@ GIT_BEGIN_DECL
  * @param id identity of the tag to locate.
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_tag_lookup(
-	git_tag **out, git_repository *repo, const git_oid *id)
-{
-	return git_object_lookup(
-		(git_object **)out, repo, id, (git_otype)GIT_OBJ_TAG);
-}
+GIT_EXTERN(int) git_tag_lookup(
+	git_tag **out, git_repository *repo, const git_oid *id);
 
 /**
  * Lookup a tag object from the repository,
@@ -49,12 +45,8 @@ GIT_INLINE(int) git_tag_lookup(
  * @param len the length of the short identifier
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_tag_lookup_prefix(
-	git_tag **out, git_repository *repo, const git_oid *id, size_t len)
-{
-	return git_object_lookup_prefix(
-		(git_object **)out, repo, id, len, (git_otype)GIT_OBJ_TAG);
-}
+GIT_EXTERN(int) git_tag_lookup_prefix(
+	git_tag **out, git_repository *repo, const git_oid *id, size_t len);
 
 /**
  * Close an open tag
@@ -66,12 +58,7 @@ GIT_INLINE(int) git_tag_lookup_prefix(
  *
  * @param tag the tag to close
  */
-
-GIT_INLINE(void) git_tag_free(git_tag *tag)
-{
-	git_object_free((git_object *)tag);
-}
-
+GIT_EXTERN(void) git_tag_free(git_tag *tag);
 
 /**
  * Get the id of a tag.
@@ -82,6 +69,14 @@ GIT_INLINE(void) git_tag_free(git_tag *tag)
 GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag);
 
 /**
+ * Get the repository that contains the tag.
+ *
+ * @param tag A previously loaded tag.
+ * @return Repository that contains this tag.
+ */
+GIT_EXTERN(git_repository *) git_tag_owner(const git_tag *tag);
+
+/**
  * Get the tagged object of a tag
  *
  * This method performs a repository lookup for the
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 73bfc86..6ad7220 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -29,11 +29,8 @@ GIT_BEGIN_DECL
  * @param id Identity of the tree to locate.
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_tree_lookup(
-	git_tree **out, git_repository *repo, const git_oid *id)
-{
-	return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TREE);
-}
+GIT_EXTERN(int) git_tree_lookup(
+	git_tree **out, git_repository *repo, const git_oid *id);
 
 /**
  * Lookup a tree object from the repository,
@@ -47,15 +44,11 @@ GIT_INLINE(int) git_tree_lookup(
  * @param len the length of the short identifier
  * @return 0 or an error code
  */
-GIT_INLINE(int) git_tree_lookup_prefix(
+GIT_EXTERN(int) git_tree_lookup_prefix(
 	git_tree **out,
 	git_repository *repo,
 	const git_oid *id,
-	size_t len)
-{
-	return git_object_lookup_prefix(
-		(git_object **)out, repo, id, len, GIT_OBJ_TREE);
-}
+	size_t len);
 
 /**
  * Close an open tree
@@ -67,10 +60,7 @@ GIT_INLINE(int) git_tree_lookup_prefix(
  *
  * @param tree The tree to close
  */
-GIT_INLINE(void) git_tree_free(git_tree *tree)
-{
-	git_object_free((git_object *)tree);
-}
+GIT_EXTERN(void) git_tree_free(git_tree *tree);
 
 /**
  * Get the id of a tree.
diff --git a/include/git2/types.h b/include/git2/types.h
index bc15050..aca9ed9 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -196,6 +196,26 @@ typedef struct git_push git_push;
 typedef struct git_remote_head git_remote_head;
 typedef struct git_remote_callbacks git_remote_callbacks;
 
+/**
+ * This is passed as the first argument to the callback to allow the
+ * user to see the progress.
+ */
+typedef struct git_transfer_progress {
+	unsigned int total_objects;
+	unsigned int indexed_objects;
+	unsigned int received_objects;
+	size_t received_bytes;
+} git_transfer_progress;
+
+/**
+ * Type for progress callbacks during indexing.  Return a value less than zero
+ * to cancel the transfer.
+ *
+ * @param stats Structure containing information about the state of the transfer
+ * @param payload Payload provided by caller
+ */
+typedef int (*git_transfer_progress_callback)(const git_transfer_progress *stats, void *payload);
+
 /** @} */
 GIT_END_DECL
 
diff --git a/src/attr.c b/src/attr.c
index 979fecc..6dd2c7e 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -312,7 +312,7 @@ static int load_attr_blob_from_index(
 
 	entry = git_index_get_byindex(index, pos);
 
-	if (old_oid && git_oid_cmp(old_oid, &entry->oid) == 0)
+	if (old_oid && git_oid__cmp(old_oid, &entry->oid) == 0)
 		return GIT_ENOTFOUND;
 
 	if ((error = git_blob_lookup(blob, repo, &entry->oid)) < 0)
diff --git a/src/blob.c b/src/blob.c
index c0514fc..a68c4cc 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -8,6 +8,7 @@
 #include "git2/common.h"
 #include "git2/object.h"
 #include "git2/repository.h"
+#include "git2/odb_backend.h"
 
 #include "common.h"
 #include "blob.h"
@@ -17,32 +18,34 @@
 const void *git_blob_rawcontent(const git_blob *blob)
 {
 	assert(blob);
-	return blob->odb_object->raw.data;
+	return git_odb_object_data(blob->odb_object);
 }
 
 git_off_t git_blob_rawsize(const git_blob *blob)
 {
 	assert(blob);
-	return (git_off_t)blob->odb_object->raw.len;
+	return (git_off_t)git_odb_object_size(blob->odb_object);
 }
 
 int git_blob__getbuf(git_buf *buffer, git_blob *blob)
 {
 	return git_buf_set(
-		buffer, blob->odb_object->raw.data, blob->odb_object->raw.len);
+		buffer,
+		git_odb_object_data(blob->odb_object),
+		git_odb_object_size(blob->odb_object));
 }
 
-void git_blob__free(git_blob *blob)
+void git_blob__free(void *blob)
 {
-	git_odb_object_free(blob->odb_object);
+	git_odb_object_free(((git_blob *)blob)->odb_object);
 	git__free(blob);
 }
 
-int git_blob__parse(git_blob *blob, git_odb_object *odb_obj)
+int git_blob__parse(void *blob, git_odb_object *odb_obj)
 {
 	assert(blob);
 	git_cached_obj_incref((git_cached_obj *)odb_obj);
-	blob->odb_object = odb_obj;
+	((git_blob *)blob)->odb_object = odb_obj;
 	return 0;
 }
 
@@ -314,8 +317,8 @@ int git_blob_is_binary(git_blob *blob)
 
 	assert(blob);
 
-	content.ptr = blob->odb_object->raw.data;
-	content.size = min(blob->odb_object->raw.len, 4000);
+	content.ptr = blob->odb_object->buffer;
+	content.size = min(blob->odb_object->cached.size, 4000);
 
 	return git_buf_text_is_binary(&content);
 }
diff --git a/src/blob.h b/src/blob.h
index 524734b..22e37cc 100644
--- a/src/blob.h
+++ b/src/blob.h
@@ -17,8 +17,8 @@ struct git_blob {
 	git_odb_object *odb_object;
 };
 
-void git_blob__free(git_blob *blob);
-int git_blob__parse(git_blob *blob, git_odb_object *obj);
+void git_blob__free(void *blob);
+int git_blob__parse(void *blob, git_odb_object *obj);
 int git_blob__getbuf(git_buf *buffer, git_blob *blob);
 
 #endif
diff --git a/src/branch.c b/src/branch.c
index e708879..88f0525 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -11,6 +11,7 @@
 #include "config.h"
 #include "refspec.h"
 #include "refs.h"
+#include "remote.h"
 
 #include "git2/branch.h"
 
@@ -283,12 +284,10 @@ int git_branch_upstream__name(
 		if ((error = git_remote_load(&remote, repo, remote_name)) < 0)
 			goto cleanup;
 
-		refspec = git_remote_fetchspec(remote);
-		if (refspec == NULL
-			|| refspec->src == NULL
-			|| refspec->dst == NULL) {
-				error = GIT_ENOTFOUND;
-				goto cleanup;
+		refspec = git_remote__matching_refspec(remote, merge_name);
+		if (!refspec) {
+			error = GIT_ENOTFOUND;
+			goto cleanup;
 		}
 
 		if (git_refspec_transform_r(&buf, refspec, merge_name) < 0)
@@ -333,11 +332,8 @@ static int remote_name(git_buf *buf, git_repository *repo, const char *canonical
 		if ((error = git_remote_load(&remote, repo, remote_list.strings[i])) < 0)
 			continue;
 
-		fetchspec = git_remote_fetchspec(remote);
-
-		/* Defensivly check that we have a fetchspec */
-		if (fetchspec &&
-			git_refspec_dst_matches(fetchspec, canonical_branch_name)) {
+		fetchspec = git_remote__matching_dst_refspec(remote, canonical_branch_name);
+		if (fetchspec) {
 			/* If we have not already set out yet, then set
 			 * it to the matching remote name. Otherwise
 			 * multiple remotes match this reference, and it
@@ -377,7 +373,7 @@ int git_branch_remote_name(char *buffer, size_t buffer_len, git_repository *repo
 	if (buffer)
 		git_buf_copy_cstr(buffer, buffer_len, &buf);
 
-	ret = git_buf_len(&buf) + 1;
+	ret = (int)git_buf_len(&buf) + 1;
 	git_buf_free(&buf);
 
 	return ret;
@@ -522,9 +518,9 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
 		if (git_remote_load(&remote, repo, git_buf_cstr(&value)) < 0)
 			goto on_error;
 
-		fetchspec = git_remote_fetchspec(remote);
+		fetchspec = git_remote__matching_dst_refspec(remote, git_reference_name(upstream));
 		git_buf_clear(&value);
-		if (git_refspec_transform_l(&value, fetchspec, git_reference_name(upstream)) < 0)
+		if (!fetchspec || git_refspec_transform_l(&value, fetchspec, git_reference_name(upstream)) < 0)
 			goto on_error;
 
 		git_remote_free(remote);
diff --git a/src/cache.c b/src/cache.c
index e7f3335..1360cc9 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -11,100 +11,262 @@
 #include "thread-utils.h"
 #include "util.h"
 #include "cache.h"
+#include "odb.h"
+#include "object.h"
 #include "git2/oid.h"
 
-int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_ptr)
+GIT__USE_OIDMAP
+
+bool git_cache__enabled = true;
+ssize_t git_cache__max_storage = (256 * 1024 * 1024);
+git_atomic_ssize git_cache__current_storage = {0};
+
+static size_t git_cache__max_object_size[8] = {
+	0,     /* GIT_OBJ__EXT1 */
+	4096,  /* GIT_OBJ_COMMIT */
+	4096,  /* GIT_OBJ_TREE */
+	0,     /* GIT_OBJ_BLOB */
+	4096,  /* GIT_OBJ_TAG */
+	0,     /* GIT_OBJ__EXT2 */
+	0,     /* GIT_OBJ_OFS_DELTA */
+	0      /* GIT_OBJ_REF_DELTA */
+};
+
+int git_cache_set_max_object_size(git_otype type, size_t size)
 {
-	if (size < 8)
-		size = 8;
-	size = git__size_t_powerof2(size);
+	if (type < 0 || (size_t)type >= ARRAY_SIZE(git_cache__max_object_size)) {
+		giterr_set(GITERR_INVALID, "type out of range");
+		return -1;
+	}
+
+	git_cache__max_object_size[type] = size;
+	return 0;
+}
 
-	cache->size_mask = size - 1;
-	cache->lru_count = 0;
-	cache->free_obj = free_ptr;
+void git_cache_dump_stats(git_cache *cache)
+{
+	git_cached_obj *object;
 
-	git_mutex_init(&cache->lock);
+	if (kh_size(cache->map) == 0)
+		return;
 
-	cache->nodes = git__malloc(size * sizeof(git_cached_obj *));
-	GITERR_CHECK_ALLOC(cache->nodes);
+	printf("Cache %p: %d items cached, %d bytes\n",
+		cache, kh_size(cache->map), (int)cache->used_memory);
 
-	memset(cache->nodes, 0x0, size * sizeof(git_cached_obj *));
+	kh_foreach_value(cache->map, object, {
+		char oid_str[9];
+		printf(" %s%c %s (%d)\n",
+			git_object_type2string(object->type),
+			object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ',
+			git_oid_tostr(oid_str, sizeof(oid_str), &object->oid),
+			(int)object->size
+		);
+	});
+}
+
+int git_cache_init(git_cache *cache)
+{
+	cache->used_memory = 0;
+	cache->map = git_oidmap_alloc();
+	git_mutex_init(&cache->lock);
 	return 0;
 }
 
+/* called with lock */
+static void clear_cache(git_cache *cache)
+{
+	git_cached_obj *evict = NULL;
+
+	if (kh_size(cache->map) == 0)
+		return;
+
+	kh_foreach_value(cache->map, evict, {
+		git_cached_obj_decref(evict);
+	});
+
+	kh_clear(oid, cache->map);
+	git_atomic_ssize_add(&git_cache__current_storage, -cache->used_memory);
+	cache->used_memory = 0;
+}
+
+void git_cache_clear(git_cache *cache)
+{
+	if (git_mutex_lock(&cache->lock) < 0)
+		return;
+
+	clear_cache(cache);
+
+	git_mutex_unlock(&cache->lock);
+}
+
 void git_cache_free(git_cache *cache)
 {
-	size_t i;
+	git_cache_clear(cache);
 
-	for (i = 0; i < (cache->size_mask + 1); ++i) {
-		if (cache->nodes[i] != NULL)
-			git_cached_obj_decref(cache->nodes[i], cache->free_obj);
+	git_oidmap_free(cache->map);
+	git_mutex_free(&cache->lock);
+}
+
+/* Called with lock */
+static void cache_evict_entries(git_cache *cache)
+{
+	uint32_t seed = rand();
+	size_t evict_count = 8;
+	ssize_t evicted_memory = 0;
+
+	/* do not infinite loop if there's not enough entries to evict  */
+	if (evict_count > kh_size(cache->map)) {
+		clear_cache(cache);
+		return;
 	}
 
-	git_mutex_free(&cache->lock);
-	git__free(cache->nodes);
+	while (evict_count > 0) {
+		khiter_t pos = seed++ % kh_end(cache->map);
+
+		if (kh_exist(cache->map, pos)) {
+			git_cached_obj *evict = kh_val(cache->map, pos);
+
+			evict_count--;
+			evicted_memory += evict->size;
+			git_cached_obj_decref(evict);
+
+			kh_del(oid, cache->map, pos);
+		}
+	}
+
+	cache->used_memory -= evicted_memory;
+	git_atomic_ssize_add(&git_cache__current_storage, -evicted_memory);
 }
 
-void *git_cache_get(git_cache *cache, const git_oid *oid)
+static bool cache_should_store(git_otype object_type, size_t object_size)
 {
-	uint32_t hash;
-	git_cached_obj *node = NULL, *result = NULL;
+	size_t max_size = git_cache__max_object_size[object_type];
+	return git_cache__enabled && object_size < max_size;
+}
 
-	memcpy(&hash, oid->id, sizeof(hash));
+static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
+{
+	khiter_t pos;
+	git_cached_obj *entry = NULL;
 
-	if (git_mutex_lock(&cache->lock)) {
-		giterr_set(GITERR_THREAD, "unable to lock cache mutex");
+	if (!git_cache__enabled || git_mutex_lock(&cache->lock) < 0)
 		return NULL;
-	}
 
-	{
-		node = cache->nodes[hash & cache->size_mask];
+	pos = kh_get(oid, cache->map, oid);
+	if (pos != kh_end(cache->map)) {
+		entry = kh_val(cache->map, pos);
 
-		if (node != NULL && git_oid_cmp(&node->oid, oid) == 0) {
-			git_cached_obj_incref(node);
-			result = node;
+		if (flags && entry->flags != flags) {
+			entry = NULL;
+		} else {
+			git_cached_obj_incref(entry);
 		}
 	}
+
 	git_mutex_unlock(&cache->lock);
 
-	return result;
+	return entry;
 }
 
-void *git_cache_try_store(git_cache *cache, void *_entry)
+static void *cache_store(git_cache *cache, git_cached_obj *entry)
 {
-	git_cached_obj *entry = _entry;
-	uint32_t hash;
+	khiter_t pos;
 
-	memcpy(&hash, &entry->oid, sizeof(uint32_t));
+	git_cached_obj_incref(entry);
 
-	if (git_mutex_lock(&cache->lock)) {
-		giterr_set(GITERR_THREAD, "unable to lock cache mutex");
-		return NULL;
-	}
+	if (!cache_should_store(entry->type, entry->size))
+		return entry;
 
-	{
-		git_cached_obj *node = cache->nodes[hash & cache->size_mask];
+	if (git_mutex_lock(&cache->lock) < 0)
+		return entry;
 
-		/* increase the refcount on this object, because
-		 * the cache now owns it */
-		git_cached_obj_incref(entry);
+	/* soften the load on the cache */
+	if (git_cache__current_storage.val > git_cache__max_storage)
+		cache_evict_entries(cache);
 
-		if (node == NULL) {
-			cache->nodes[hash & cache->size_mask] = entry;
-		} else if (git_oid_cmp(&node->oid, &entry->oid) == 0) {
-			git_cached_obj_decref(entry, cache->free_obj);
-			entry = node;
-		} else {
-			git_cached_obj_decref(node, cache->free_obj);
-			cache->nodes[hash & cache->size_mask] = entry;
+	pos = kh_get(oid, cache->map, &entry->oid);
+
+	/* not found */
+	if (pos == kh_end(cache->map)) {
+		int rval;
+
+		pos = kh_put(oid, cache->map, &entry->oid, &rval);
+		if (rval >= 0) {
+			kh_key(cache->map, pos) = &entry->oid;
+			kh_val(cache->map, pos) = entry;
+			git_cached_obj_incref(entry);
+			cache->used_memory += entry->size;
+			git_atomic_ssize_add(&git_cache__current_storage, (ssize_t)entry->size);
 		}
+	}
+	/* found */
+	else {
+		git_cached_obj *stored_entry = kh_val(cache->map, pos);
 
-		/* increase the refcount again, because we are
-		 * returning it to the user */
-		git_cached_obj_incref(entry);
+		if (stored_entry->flags == entry->flags) {
+			git_cached_obj_decref(entry);
+			git_cached_obj_incref(stored_entry);
+			entry = stored_entry;
+		} else if (stored_entry->flags == GIT_CACHE_STORE_RAW &&
+			entry->flags == GIT_CACHE_STORE_PARSED) {
+			git_cached_obj_decref(stored_entry);
+			git_cached_obj_incref(entry);
 
+			kh_key(cache->map, pos) = &entry->oid;
+			kh_val(cache->map, pos) = entry;
+		} else {
+			/* NO OP */
+		}
 	}
-	git_mutex_unlock(&cache->lock);
 
+	git_mutex_unlock(&cache->lock);
 	return entry;
 }
+
+void *git_cache_store_raw(git_cache *cache, git_odb_object *entry)
+{
+	entry->cached.flags = GIT_CACHE_STORE_RAW;
+	return cache_store(cache, (git_cached_obj *)entry);
+}
+
+void *git_cache_store_parsed(git_cache *cache, git_object *entry)
+{
+	entry->cached.flags = GIT_CACHE_STORE_PARSED;
+	return cache_store(cache, (git_cached_obj *)entry);
+}
+
+git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid)
+{
+	return cache_get(cache, oid, GIT_CACHE_STORE_RAW);
+}
+
+git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid)
+{
+	return cache_get(cache, oid, GIT_CACHE_STORE_PARSED);
+}
+
+void *git_cache_get_any(git_cache *cache, const git_oid *oid)
+{
+	return cache_get(cache, oid, GIT_CACHE_STORE_ANY);
+}
+
+void git_cached_obj_decref(void *_obj)
+{
+	git_cached_obj *obj = _obj;
+
+	if (git_atomic_dec(&obj->refcount) == 0) {
+		switch (obj->flags) {
+		case GIT_CACHE_STORE_RAW:
+			git_odb_object__free(_obj);
+			break;
+
+		case GIT_CACHE_STORE_PARSED:
+			git_object__free(_obj);
+			break;
+
+		default:
+			git__free(_obj);
+			break;
+		}
+	}
+}
diff --git a/src/cache.h b/src/cache.h
index 7034ec2..53fbcf4 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -12,43 +12,56 @@
 #include "git2/odb.h"
 
 #include "thread-utils.h"
+#include "oidmap.h"
 
-#define GIT_DEFAULT_CACHE_SIZE 128
-
-typedef void (*git_cached_obj_freeptr)(void *);
+enum {
+	GIT_CACHE_STORE_ANY = 0,
+	GIT_CACHE_STORE_RAW = 1,
+	GIT_CACHE_STORE_PARSED = 2
+};
 
 typedef struct {
-	git_oid oid;
+	git_oid    oid;
+	int16_t    type;  /* git_otype value */
+	uint16_t   flags; /* GIT_CACHE_STORE value */
+	size_t     size;
 	git_atomic refcount;
 } git_cached_obj;
 
 typedef struct {
-	git_cached_obj **nodes;
-	git_mutex lock;
-
-	unsigned int lru_count;
-	size_t size_mask;
-	git_cached_obj_freeptr free_obj;
+	git_oidmap *map;
+	git_mutex   lock;
+	ssize_t     used_memory;
 } git_cache;
 
-int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_ptr);
+extern bool git_cache__enabled;
+extern ssize_t git_cache__max_storage;
+extern git_atomic_ssize git_cache__current_storage;
+
+int git_cache_set_max_object_size(git_otype type, size_t size);
+
+int git_cache_init(git_cache *cache);
 void git_cache_free(git_cache *cache);
+void git_cache_clear(git_cache *cache);
 
-void *git_cache_try_store(git_cache *cache, void *entry);
-void *git_cache_get(git_cache *cache, const git_oid *oid);
+void *git_cache_store_raw(git_cache *cache, git_odb_object *entry);
+void *git_cache_store_parsed(git_cache *cache, git_object *entry);
 
-GIT_INLINE(void) git_cached_obj_incref(void *_obj)
+git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid);
+git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid);
+void *git_cache_get_any(git_cache *cache, const git_oid *oid);
+
+GIT_INLINE(size_t) git_cache_size(git_cache *cache)
 {
-	git_cached_obj *obj = _obj;
-	git_atomic_inc(&obj->refcount);
+	return (size_t)kh_size(cache->map);
 }
 
-GIT_INLINE(void) git_cached_obj_decref(void *_obj, git_cached_obj_freeptr free_obj)
+GIT_INLINE(void) git_cached_obj_incref(void *_obj)
 {
 	git_cached_obj *obj = _obj;
-
-	if (git_atomic_dec(&obj->refcount) == 0)
-		free_obj(obj);
+	git_atomic_inc(&obj->refcount);
 }
 
+void git_cached_obj_decref(void *_obj);
+
 #endif
diff --git a/src/checkout.c b/src/checkout.c
index 24fa210..21f32d8 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -16,6 +16,7 @@
 #include "git2/config.h"
 #include "git2/diff.h"
 #include "git2/submodule.h"
+#include "git2/sys/index.h"
 
 #include "refs.h"
 #include "repository.h"
@@ -119,6 +120,7 @@ static bool checkout_is_workdir_modified(
 	const git_index_entry *wditem)
 {
 	git_oid oid;
+	const git_index_entry *ie;
 
 	/* handle "modified" submodule */
 	if (wditem->mode == GIT_FILEMODE_COMMIT) {
@@ -137,7 +139,18 @@ static bool checkout_is_workdir_modified(
 		if (!sm_oid)
 			return false;
 
-		return (git_oid_cmp(&baseitem->oid, sm_oid) != 0);
+		return (git_oid__cmp(&baseitem->oid, sm_oid) != 0);
+	}
+
+	/* Look at the cache to decide if the workdir is modified.  If not,
+	 * we can simply compare the oid in the cache to the baseitem instead
+	 * of hashing the file.
+	 */
+	if ((ie = git_index_get_bypath(data->index, wditem->path, 0)) != NULL) {
+		if (wditem->mtime.seconds == ie->mtime.seconds &&
+			wditem->mtime.nanoseconds == ie->mtime.nanoseconds &&
+			wditem->file_size == ie->file_size)
+			return (git_oid__cmp(&baseitem->oid, &ie->oid) != 0);
 	}
 
 	/* depending on where base is coming from, we may or may not know
@@ -151,7 +164,7 @@ static bool checkout_is_workdir_modified(
 			wditem->file_size, &oid) < 0)
 		return false;
 
-	return (git_oid_cmp(&baseitem->oid, &oid) != 0);
+	return (git_oid__cmp(&baseitem->oid, &oid) != 0);
 }
 
 #define CHECKOUT_ACTION_IF(FLAG,YES,NO) \
@@ -454,6 +467,7 @@ static int checkout_action(
 	int cmp = -1, act;
 	int (*strcomp)(const char *, const char *) = data->diff->strcomp;
 	int (*pfxcomp)(const char *str, const char *pfx) = data->diff->pfxcomp;
+	int error;
 
 	/* move workdir iterator to follow along with deltas */
 
@@ -477,8 +491,11 @@ static int checkout_action(
 			if (cmp == 0) {
 				if (wd->mode == GIT_FILEMODE_TREE) {
 					/* case 2 - entry prefixed by workdir tree */
-					if (git_iterator_advance_into(&wd, workdir) < 0)
-						goto fail;
+					if ((error = git_iterator_advance_into(&wd, workdir)) < 0) {
+						if (error != GIT_ENOTFOUND ||
+							git_iterator_advance(&wd, workdir) < 0)
+							goto fail;
+					}
 
 					*wditem_ptr = wd;
 					continue;
@@ -698,8 +715,8 @@ static int blob_content_to_file(
 	git_vector filters = GIT_VECTOR_INIT;
 
 	/* Create a fake git_buf from the blob raw data... */
-	filtered.ptr = blob->odb_object->raw.data;
-	filtered.size = blob->odb_object->raw.len;
+	filtered.ptr  = (void *)git_blob_rawcontent(blob);
+	filtered.size = (size_t)git_blob_rawsize(blob);
 	/* ... and make sure it doesn't get unexpectedly freed */
 	dont_free_filtered = true;
 
@@ -1107,7 +1124,6 @@ static int checkout_data_init(
 	git_checkout_opts *proposed)
 {
 	int error = 0;
-	git_config *cfg;
 	git_repository *repo = git_iterator_owner(target);
 
 	memset(data, 0, sizeof(*data));
@@ -1120,9 +1136,6 @@ static int checkout_data_init(
 	if ((error = git_repository__ensure_not_bare(repo, "checkout")) < 0)
 		return error;
 
-	if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
-		return error;
-
 	data->repo = repo;
 
 	GITERR_CHECK_VERSION(
@@ -1135,7 +1148,10 @@ static int checkout_data_init(
 
 	/* refresh config and index content unless NO_REFRESH is given */
 	if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
-		if ((error = git_config_refresh(cfg)) < 0)
+		git_config *cfg;
+
+		if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
+			(error = git_config_refresh(cfg)) < 0)
 			goto cleanup;
 
 		/* if we are checking out the index, don't reload,
@@ -1172,19 +1188,13 @@ static int checkout_data_init(
 
 	data->pfx = git_pathspec_prefix(&data->opts.paths);
 
-	error = git_config_get_bool(&data->can_symlink, cfg, "core.symlinks");
-	if (error < 0) {
-		if (error != GIT_ENOTFOUND)
-			goto cleanup;
-
-		/* If "core.symlinks" is not found anywhere, default to true. */
-		data->can_symlink = true;
-		giterr_clear();
-		error = 0;
-	}
+	if ((error = git_repository__cvar(
+			 &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0)
+		goto cleanup;
 
 	if (!data->opts.baseline) {
 		data->opts_free_baseline = true;
+
 		error = checkout_lookup_head_tree(&data->opts.baseline, repo);
 
 		if (error == GIT_EORPHANEDHEAD) {
diff --git a/src/clone.c b/src/clone.c
index 0bbccd4..aeb7bbf 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -132,14 +132,14 @@ static int reference_matches_remote_head(
 			return 0;
 	}
 
-	if (git_oid_cmp(&head_info->remote_head_oid, &oid) == 0) {
+	if (git_oid__cmp(&head_info->remote_head_oid, &oid) == 0) {
 		/* Determine the local reference name from the remote tracking one */
 		if (git_refspec_transform_l(
-			&head_info->branchname, 
+			&head_info->branchname,
 			head_info->refspec,
 			reference_name) < 0)
 				return -1;
-		
+
 		if (git_buf_len(&head_info->branchname) > 0) {
 			if (git_buf_sets(
 				&head_info->branchname,
@@ -187,6 +187,7 @@ static int get_head_callback(git_remote_head *head, void *payload)
 static int update_head_to_remote(git_repository *repo, git_remote *remote)
 {
 	int retcode = -1;
+	git_refspec dummy_spec;
 	git_remote_head *remote_head;
 	struct head_info head_info;
 	git_buf remote_master_name = GIT_BUF_INIT;
@@ -211,8 +212,13 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
 	git_oid_cpy(&head_info.remote_head_oid, &remote_head->oid);
 	git_buf_init(&head_info.branchname, 16);
 	head_info.repo = repo;
-	head_info.refspec = git_remote_fetchspec(remote);
+	head_info.refspec = git_remote__matching_refspec(remote, GIT_REFS_HEADS_MASTER_FILE);
 	head_info.found = 0;
+
+	if (head_info.refspec == NULL) {
+		memset(&dummy_spec, 0, sizeof(git_refspec));
+		head_info.refspec = &dummy_spec;
+	}
 	
 	/* Determine the remote tracking reference name from the local master */
 	if (git_refspec_transform_r(
@@ -317,12 +323,14 @@ static int create_and_configure_origin(
 	    (error = git_remote_set_callbacks(origin, options->remote_callbacks)) < 0)
 		goto on_error;
 
-	if (options->fetch_spec &&
-	    (error = git_remote_set_fetchspec(origin, options->fetch_spec)) < 0)
-		goto on_error;
+	if (options->fetch_spec) {
+		git_remote_clear_refspecs(origin);
+		if ((error = git_remote_add_fetch(origin, options->fetch_spec)) < 0)
+			goto on_error;
+	}
 
 	if (options->push_spec &&
-	    (error = git_remote_set_pushspec(origin, options->push_spec)) < 0)
+	    (error = git_remote_add_push(origin, options->push_spec)) < 0)
 		goto on_error;
 
 	if (options->pushurl &&
diff --git a/src/commit.c b/src/commit.c
index c7b83ed..46c02c2 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -9,6 +9,7 @@
 #include "git2/object.h"
 #include "git2/repository.h"
 #include "git2/signature.h"
+#include "git2/sys/commit.h"
 
 #include "common.h"
 #include "odb.h"
@@ -30,8 +31,10 @@ static void clear_parents(git_commit *commit)
 	git_vector_clear(&commit->parent_ids);
 }
 
-void git_commit__free(git_commit *commit)
+void git_commit__free(void *_commit)
 {
+	git_commit *commit = _commit;
+
 	clear_parents(commit);
 	git_vector_free(&commit->parent_ids);
 
@@ -44,16 +47,16 @@ void git_commit__free(git_commit *commit)
 }
 
 int git_commit_create_v(
-		git_oid *oid,
-		git_repository *repo,
-		const char *update_ref,
-		const git_signature *author,
-		const git_signature *committer,
-		const char *message_encoding,
-		const char *message,
-		const git_tree *tree,
-		int parent_count,
-		...)
+	git_oid *oid,
+	git_repository *repo,
+	const char *update_ref,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message,
+	const git_tree *tree,
+	int parent_count,
+	...)
 {
 	va_list ap;
 	int i, res;
@@ -76,30 +79,29 @@ int git_commit_create_v(
 	return res;
 }
 
-int git_commit_create(
-		git_oid *oid,
-		git_repository *repo,
-		const char *update_ref,
-		const git_signature *author,
-		const git_signature *committer,
-		const char *message_encoding,
-		const char *message,
-		const git_tree *tree,
-		int parent_count,
-		const git_commit *parents[])
+int git_commit_create_from_oids(
+	git_oid *oid,
+	git_repository *repo,
+	const char *update_ref,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message,
+	const git_oid *tree,
+	int parent_count,
+	const git_oid *parents[])
 {
 	git_buf commit = GIT_BUF_INIT;
 	int i;
 	git_odb *odb;
 
+	assert(oid && repo && tree && parent_count >= 0);
 	assert(git_object_owner((const git_object *)tree) == repo);
 
-	git_oid__writebuf(&commit, "tree ", git_object_id((const git_object *)tree));
+	git_oid__writebuf(&commit, "tree ", tree);
 
-	for (i = 0; i < parent_count; ++i) {
-		assert(git_object_owner((const git_object *)parents[i]) == repo);
-		git_oid__writebuf(&commit, "parent ", git_object_id((const git_object *)parents[i]));
-	}
+	for (i = 0; i < parent_count; ++i)
+		git_oid__writebuf(&commit, "parent ", parents[i]);
 
 	git_signature__writebuf(&commit, "author ", author);
 	git_signature__writebuf(&commit, "committer ", committer);
@@ -131,10 +133,46 @@ on_error:
 	return -1;
 }
 
-int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len)
+int git_commit_create(
+	git_oid *oid,
+	git_repository *repo,
+	const char *update_ref,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message,
+	const git_tree *tree,
+	int parent_count,
+	const git_commit *parents[])
 {
-	const char *buffer = data;
-	const char *buffer_end = (const char *)data + len;
+	int retval, i;
+	const git_oid **parent_oids;
+
+	assert(parent_count >= 0);
+
+	parent_oids = git__malloc(parent_count * sizeof(git_oid *));
+	GITERR_CHECK_ALLOC(parent_oids);
+
+	for (i = 0; i < parent_count; ++i) {
+		assert(git_object_owner((const git_object *)parents[i]) == repo);
+		parent_oids[i] = git_object_id((const git_object *)parents[i]);
+	}
+
+	retval = git_commit_create_from_oids(
+		oid, repo, update_ref, author, committer,
+		message_encoding, message,
+		git_object_id((const git_object *)tree), parent_count, parent_oids);
+
+	git__free((void *)parent_oids);
+
+	return retval;
+}
+
+int git_commit__parse(void *_commit, git_odb_object *odb_obj)
+{
+	git_commit *commit = _commit;
+	const char *buffer = git_odb_object_data(odb_obj);
+	const char *buffer_end = buffer + git_odb_object_size(odb_obj);
 	git_oid parent_id;
 
 	if (git_vector_init(&commit->parent_ids, 4, NULL) < 0)
@@ -206,12 +244,6 @@ bad_buffer:
 	return -1;
 }
 
-int git_commit__parse(git_commit *commit, git_odb_object *obj)
-{
-	assert(commit);
-	return git_commit__parse_buffer(commit, obj->raw.data, obj->raw.len);
-}
-
 #define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
 	_rvalue git_commit_##_name(const git_commit *commit) \
 	{\
diff --git a/src/commit.h b/src/commit.h
index 1ab164c..d0981b1 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -27,8 +27,7 @@ struct git_commit {
 	char *message;
 };
 
-void git_commit__free(git_commit *c);
-int git_commit__parse(git_commit *commit, git_odb_object *obj);
+void git_commit__free(void *commit);
+int git_commit__parse(void *commit, git_odb_object *obj);
 
-int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len);
 #endif
diff --git a/src/commit_list.c b/src/commit_list.c
index 603dd75..bd5b520 100644
--- a/src/commit_list.c
+++ b/src/commit_list.c
@@ -100,12 +100,15 @@ git_commit_list_node *git_commit_list_pop(git_commit_list **stack)
 	return item;
 }
 
-static int commit_quick_parse(git_revwalk *walk, git_commit_list_node *commit, git_rawobj *raw)
+static int commit_quick_parse(
+	git_revwalk *walk,
+	git_commit_list_node *commit,
+	const uint8_t *buffer,
+	size_t buffer_len)
 {
 	const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1;
-	unsigned char *buffer = raw->data;
-	unsigned char *buffer_end = buffer + raw->len;
-	unsigned char *parents_start, *committer_start;
+	const uint8_t *buffer_end = buffer + buffer_len;
+	const uint8_t *parents_start, *committer_start;
 	int i, parents = 0;
 	int commit_time;
 
@@ -124,7 +127,7 @@ static int commit_quick_parse(git_revwalk *walk, git_commit_list_node *commit, g
 	for (i = 0; i < parents; ++i) {
 		git_oid oid;
 
-		if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) < 0)
+		if (git_oid_fromstr(&oid, (const char *)buffer + strlen("parent ")) < 0)
 			return -1;
 
 		commit->parents[i] = git_revwalk__commit_lookup(walk, &oid);
@@ -182,11 +185,14 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
 	if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
 		return error;
 
-	if (obj->raw.type != GIT_OBJ_COMMIT) {
+	if (obj->cached.type != GIT_OBJ_COMMIT) {
 		giterr_set(GITERR_INVALID, "Object is no commit object");
 		error = -1;
 	} else
-		error = commit_quick_parse(walk, commit, &obj->raw);
+		error = commit_quick_parse(
+			walk, commit,
+			(const uint8_t *)git_odb_object_data(obj),
+			git_odb_object_size(obj));
 
 	git_odb_object_free(obj);
 	return error;
diff --git a/src/config.c b/src/config.c
index 5379b0e..2e1268e 100644
--- a/src/config.c
+++ b/src/config.c
@@ -9,6 +9,7 @@
 #include "fileops.h"
 #include "config.h"
 #include "git2/config.h"
+#include "git2/sys/config.h"
 #include "vector.h"
 #include "buf_text.h"
 #include "config_file.h"
@@ -292,6 +293,9 @@ int git_config_refresh(git_config *cfg)
 		error = file->refresh(file);
 	}
 
+	if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL)
+		git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg));
+
 	return error;
 }
 
@@ -359,6 +363,7 @@ int git_config_set_bool(git_config *cfg, const char *name, int value)
 
 int git_config_set_string(git_config *cfg, const char *name, const char *value)
 {
+	int error;
 	git_config_backend *file;
 	file_internal *internal;
 
@@ -368,9 +373,20 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
 	}
 
 	internal = git_vector_get(&cfg->files, 0);
+	if (!internal) {
+		/* Should we auto-vivify .git/config? Tricky from this location */
+		giterr_set(GITERR_CONFIG, "Cannot set value when no config files exist");
+		return GIT_ENOTFOUND;
+	}
+
 	file = internal->file;
 
-	return file->set(file, name, value);
+	error = file->set(file, name, value);
+
+	if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL)
+		git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg));
+
+	return error;
 }
 
 /***********
diff --git a/src/config_cache.c b/src/config_cache.c
index 2f36df7..84de3a5 100644
--- a/src/config_cache.c
+++ b/src/config_cache.c
@@ -26,7 +26,7 @@ struct map_data {
  *	files that have the text property set. Alternatives are lf, crlf
  *	and native, which uses the platform's native line ending. The default
  *	value is native. See gitattributes(5) for more information on
- *	end-of-line conversion. 
+ *	end-of-line conversion.
  */
 static git_cvar_map _cvar_map_eol[] = {
 	{GIT_CVAR_FALSE, NULL, GIT_EOL_UNSET},
@@ -37,7 +37,7 @@ static git_cvar_map _cvar_map_eol[] = {
 
 /*
  *	core.autocrlf
- *		Setting this variable to "true" is almost the same as setting 
+ *		Setting this variable to "true" is almost the same as setting
  *	the text attribute to "auto" on all files except that text files are
  *	not guaranteed to be normalized: files that contain CRLF in the
  *	repository will not be touched. Use this setting if you want to have
@@ -51,9 +51,22 @@ static git_cvar_map _cvar_map_autocrlf[] = {
 	{GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT}
 };
 
+/*
+ * Generic map for integer values
+ */
+static git_cvar_map _cvar_map_int[] = {
+	{GIT_CVAR_INT32, NULL, 0},
+};
+
 static struct map_data _cvar_maps[] = {
 	{"core.autocrlf", _cvar_map_autocrlf, ARRAY_SIZE(_cvar_map_autocrlf), GIT_AUTO_CRLF_DEFAULT},
-	{"core.eol", _cvar_map_eol, ARRAY_SIZE(_cvar_map_eol), GIT_EOL_DEFAULT}
+	{"core.eol", _cvar_map_eol, ARRAY_SIZE(_cvar_map_eol), GIT_EOL_DEFAULT},
+	{"core.symlinks", NULL, 0, GIT_SYMLINKS_DEFAULT },
+	{"core.ignorecase", NULL, 0, GIT_IGNORECASE_DEFAULT },
+	{"core.filemode", NULL, 0, GIT_FILEMODE_DEFAULT },
+	{"core.ignorestat", NULL, 0, GIT_IGNORESTAT_DEFAULT },
+	{"core.trustctime", NULL, 0, GIT_TRUSTCTIME_DEFAULT },
+	{"core.abbrev", _cvar_map_int, 1, GIT_ABBREV_DEFAULT },
 };
 
 int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar)
@@ -69,12 +82,16 @@ int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar)
 		if (error < 0)
 			return error;
 
-		error = git_config_get_mapped(out,
-			config, data->cvar_name, data->maps, data->map_count);
+		if (data->maps)
+			error = git_config_get_mapped(
+				out, config, data->cvar_name, data->maps, data->map_count);
+		else
+			error = git_config_get_bool(out, config, data->cvar_name);
 
-		if (error == GIT_ENOTFOUND)
+		if (error == GIT_ENOTFOUND) {
+			giterr_clear();
 			*out = data->default_value;
-
+		}
 		else if (error < 0)
 			return error;
 
diff --git a/src/config_file.c b/src/config_file.c
index 8b51ab2..a9a40c3 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -12,6 +12,7 @@
 #include "buffer.h"
 #include "buf_text.h"
 #include "git2/config.h"
+#include "git2/sys/config.h"
 #include "git2/types.h"
 #include "strmap.h"
 
@@ -481,8 +482,10 @@ static int config_set_multivar(
 
 	pos = git_strmap_lookup_index(b->values, key);
 	if (!git_strmap_valid_index(b->values, pos)) {
+		/* If we don't have it, behave like a normal set */
+		result = config_set(cfg, name, value);
 		git__free(key);
-		return GIT_ENOTFOUND;
+		return result;
 	}
 
 	var = git_strmap_value_at(b->values, pos);
diff --git a/src/diff.c b/src/diff.c
index 37c89f3..a154e67 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -14,6 +14,8 @@
 
 #define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0)
 #define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0)
+#define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->opts.flags = \
+	(VAL) ? ((DIFF)->opts.flags | (FLAG)) : ((DIFF)->opts.flags & ~(VAL))
 
 static git_diff_delta *diff_delta__alloc(
 	git_diff_list *diff,
@@ -194,21 +196,21 @@ static git_diff_delta *diff_delta__last_for_item(
 	switch (delta->status) {
 	case GIT_DELTA_UNMODIFIED:
 	case GIT_DELTA_DELETED:
-		if (git_oid_cmp(&delta->old_file.oid, &item->oid) == 0)
+		if (git_oid__cmp(&delta->old_file.oid, &item->oid) == 0)
 			return delta;
 		break;
 	case GIT_DELTA_ADDED:
-		if (git_oid_cmp(&delta->new_file.oid, &item->oid) == 0)
+		if (git_oid__cmp(&delta->new_file.oid, &item->oid) == 0)
 			return delta;
 		break;
 	case GIT_DELTA_UNTRACKED:
 		if (diff->strcomp(delta->new_file.path, item->path) == 0 &&
-			git_oid_cmp(&delta->new_file.oid, &item->oid) == 0)
+			git_oid__cmp(&delta->new_file.oid, &item->oid) == 0)
 			return delta;
 		break;
 	case GIT_DELTA_MODIFIED:
-		if (git_oid_cmp(&delta->old_file.oid, &item->oid) == 0 ||
-			git_oid_cmp(&delta->new_file.oid, &item->oid) == 0)
+		if (git_oid__cmp(&delta->old_file.oid, &item->oid) == 0 ||
+			git_oid__cmp(&delta->new_file.oid, &item->oid) == 0)
 			return delta;
 		break;
 	default:
@@ -267,67 +269,157 @@ static int config_bool(git_config *cfg, const char *name, int defvalue)
 	return val;
 }
 
-static git_diff_list *git_diff_list_alloc(
-	git_repository *repo, const git_diff_options *opts)
+static int config_int(git_config *cfg, const char *name, int defvalue)
 {
-	git_config *cfg;
+	int val = defvalue;
+
+	if (git_config_get_int32(&val, cfg, name) < 0)
+		giterr_clear();
+
+	return val;
+}
+
+static const char *diff_mnemonic_prefix(
+	git_iterator_type_t type, bool left_side)
+{
+	const char *pfx = "";
+
+	switch (type) {
+	case GIT_ITERATOR_TYPE_EMPTY:   pfx = "c"; break;
+	case GIT_ITERATOR_TYPE_TREE:    pfx = "c"; break;
+	case GIT_ITERATOR_TYPE_INDEX:   pfx = "i"; break;
+	case GIT_ITERATOR_TYPE_WORKDIR: pfx = "w"; break;
+	case GIT_ITERATOR_TYPE_FS:      pfx = left_side ? "1" : "2"; break;
+	default: break;
+	}
+
+	/* note: without a deeper look at pathspecs, there is no easy way
+	 * to get the (o)bject / (w)ork tree mnemonics working...
+	 */
+
+	return pfx;
+}
+
+static git_diff_list *diff_list_alloc(
+	git_repository *repo,
+	git_iterator *old_iter,
+	git_iterator *new_iter)
+{
+	git_diff_options dflt = GIT_DIFF_OPTIONS_INIT;
 	git_diff_list *diff = git__calloc(1, sizeof(git_diff_list));
-	if (diff == NULL)
+	if (!diff)
 		return NULL;
 
+	assert(repo && old_iter && new_iter);
+
 	GIT_REFCOUNT_INC(diff);
 	diff->repo = repo;
+	diff->old_src = old_iter->type;
+	diff->new_src = new_iter->type;
+	memcpy(&diff->opts, &dflt, sizeof(diff->opts));
 
 	if (git_vector_init(&diff->deltas, 0, git_diff_delta__cmp) < 0 ||
-		git_pool_init(&diff->pool, 1, 0) < 0)
-		goto fail;
+		git_pool_init(&diff->pool, 1, 0) < 0) {
+		git_diff_list_free(diff);
+		return NULL;
+	}
+
+	/* Use case-insensitive compare if either iterator has
+	 * the ignore_case bit set */
+	if (!git_iterator_ignore_case(old_iter) &&
+		!git_iterator_ignore_case(new_iter)) {
+		diff->opts.flags &= ~GIT_DIFF_DELTAS_ARE_ICASE;
+
+		diff->strcomp    = git__strcmp;
+		diff->strncomp   = git__strncmp;
+		diff->pfxcomp    = git__prefixcmp;
+		diff->entrycomp  = git_index_entry__cmp;
+	} else {
+		diff->opts.flags |= GIT_DIFF_DELTAS_ARE_ICASE;
+
+		diff->strcomp    = git__strcasecmp;
+		diff->strncomp   = git__strncasecmp;
+		diff->pfxcomp    = git__prefixcmp_icase;
+		diff->entrycomp  = git_index_entry__cmp_icase;
+	}
+
+	return diff;
+}
+
+static int diff_list_apply_options(
+	git_diff_list *diff,
+	const git_diff_options *opts)
+{
+	git_config *cfg;
+	git_repository *repo = diff->repo;
+	git_pool *pool = &diff->pool;
+	int val;
+
+	if (opts) {
+		/* copy user options (except case sensitivity info from iterators) */
+		bool icase = DIFF_FLAG_IS_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE);
+		memcpy(&diff->opts, opts, sizeof(diff->opts));
+		DIFF_FLAG_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE, icase);
+
+		/* initialize pathspec from options */
+		if (git_pathspec_init(&diff->pathspec, &opts->pathspec, pool) < 0)
+			return -1;
+	}
+
+	/* flag INCLUDE_TYPECHANGE_TREES implies INCLUDE_TYPECHANGE */
+	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES))
+		diff->opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
 
 	/* load config values that affect diff behavior */
 	if (git_repository_config__weakptr(&cfg, repo) < 0)
-		goto fail;
-	if (config_bool(cfg, "core.symlinks", 1))
+		return -1;
+
+	if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS) && val)
 		diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_HAS_SYMLINKS;
-	if (config_bool(cfg, "core.ignorestat", 0))
+
+	if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORESTAT) && val)
 		diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_ASSUME_UNCHANGED;
-	if (config_bool(cfg, "core.filemode", 1))
+
+	if ((diff->opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 &&
+		!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE) && val)
 		diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_MODE_BITS;
-	if (config_bool(cfg, "core.trustctime", 1))
+
+	if (!git_repository__cvar(&val, repo, GIT_CVAR_TRUSTCTIME) && val)
 		diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_CTIME;
+
 	/* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */
 
-	/* TODO: there are certain config settings where even if we were
-	 * not given an options structure, we need the diff list to have one
-	 * so that we can store the altered default values.
-	 *
-	 * - diff.ignoreSubmodules
-	 * - diff.mnemonicprefix
-	 * - diff.noprefix
-	 */
+	/* If not given explicit `opts`, check `diff.xyz` configs */
+	if (!opts) {
+		diff->opts.context_lines = config_int(cfg, "diff.context", 3);
 
-	if (opts == NULL) {
-		/* Make sure we default to 3 lines */
-		diff->opts.context_lines = 3;
-		return diff;
+		if (config_bool(cfg, "diff.ignoreSubmodules", 0))
+			diff->opts.flags |= GIT_DIFF_IGNORE_SUBMODULES;
 	}
 
-	memcpy(&diff->opts, opts, sizeof(git_diff_options));
-
-	if(opts->flags & GIT_DIFF_IGNORE_FILEMODE)
-		diff->diffcaps = diff->diffcaps & ~GIT_DIFFCAPS_TRUST_MODE_BITS;
-
-	/* pathspec init will do nothing for empty pathspec */
-	if (git_pathspec_init(&diff->pathspec, &opts->pathspec, &diff->pool) < 0)
-		goto fail;
+	/* if either prefix is not set, figure out appropriate value */
+	if (!diff->opts.old_prefix || !diff->opts.new_prefix) {
+		const char *use_old = DIFF_OLD_PREFIX_DEFAULT;
+		const char *use_new = DIFF_NEW_PREFIX_DEFAULT;
 
-	/* TODO: handle config diff.mnemonicprefix, diff.noprefix */
+		if (config_bool(cfg, "diff.noprefix", 0)) {
+			use_old = use_new = "";
+		} else if (config_bool(cfg, "diff.mnemonicprefix", 0)) {
+			use_old = diff_mnemonic_prefix(diff->old_src, true);
+			use_new = diff_mnemonic_prefix(diff->new_src, false);
+		}
 
-	diff->opts.old_prefix = diff_strdup_prefix(&diff->pool,
-		opts->old_prefix ? opts->old_prefix : DIFF_OLD_PREFIX_DEFAULT);
-	diff->opts.new_prefix = diff_strdup_prefix(&diff->pool,
-		opts->new_prefix ? opts->new_prefix : DIFF_NEW_PREFIX_DEFAULT);
+		if (!diff->opts.old_prefix)
+			diff->opts.old_prefix = use_old;
+		if (!diff->opts.new_prefix)
+			diff->opts.new_prefix = use_new;
+	}
 
+	/* strdup prefix from pool so we're not dependent on external data */
+	diff->opts.old_prefix = diff_strdup_prefix(pool, diff->opts.old_prefix);
+	diff->opts.new_prefix = diff_strdup_prefix(pool, diff->opts.new_prefix);
 	if (!diff->opts.old_prefix || !diff->opts.new_prefix)
-		goto fail;
+		return -1;
 
 	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) {
 		const char *swap = diff->opts.old_prefix;
@@ -335,15 +427,7 @@ static git_diff_list *git_diff_list_alloc(
 		diff->opts.new_prefix = swap;
 	}
 
-	/* INCLUDE_TYPECHANGE_TREES implies INCLUDE_TYPECHANGE */
-	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES))
-		diff->opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
-
-	return diff;
-
-fail:
-	git_diff_list_free(diff);
-	return NULL;
+	return 0;
 }
 
 static void diff_list_free(git_diff_list *diff)
@@ -445,24 +529,30 @@ cleanup:
 	return result;
 }
 
+typedef struct {
+	git_repository *repo;
+	git_iterator *old_iter;
+	git_iterator *new_iter;
+	const git_index_entry *oitem;
+	const git_index_entry *nitem;
+	git_buf ignore_prefix;
+} diff_in_progress;
+
 #define MODE_BITS_MASK 0000777
 
 static int maybe_modified(
-	git_iterator *old_iter,
-	const git_index_entry *oitem,
-	git_iterator *new_iter,
-	const git_index_entry *nitem,
-	git_diff_list *diff)
+	git_diff_list *diff,
+	diff_in_progress *info)
 {
 	git_oid noid, *use_noid = NULL;
 	git_delta_t status = GIT_DELTA_MODIFIED;
+	const git_index_entry *oitem = info->oitem;
+	const git_index_entry *nitem = info->nitem;
 	unsigned int omode = oitem->mode;
 	unsigned int nmode = nitem->mode;
-	bool new_is_workdir = (new_iter->type == GIT_ITERATOR_TYPE_WORKDIR);
+	bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_TYPE_WORKDIR);
 	const char *matched_pathspec;
 
-	GIT_UNUSED(old_iter);
-
 	if (!git_pathspec_match_path(
 			&diff->pathspec, oitem->path,
 			DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH),
@@ -607,237 +697,311 @@ static bool entry_is_prefixed(
 			item->path[pathlen] == '/');
 }
 
-static int diff_list_init_from_iterators(
-	git_diff_list *diff,
-	git_iterator *old_iter,
-	git_iterator *new_iter)
+static int diff_scan_inside_untracked_dir(
+	git_diff_list *diff, diff_in_progress *info, git_delta_t *delta_type)
 {
-	diff->old_src = old_iter->type;
-	diff->new_src = new_iter->type;
+	int error = 0;
+	git_buf base = GIT_BUF_INIT;
+	bool is_ignored;
 
-	/* Use case-insensitive compare if either iterator has
-	 * the ignore_case bit set */
-	if (!git_iterator_ignore_case(old_iter) &&
-		!git_iterator_ignore_case(new_iter))
-	{
-		diff->opts.flags &= ~GIT_DIFF_DELTAS_ARE_ICASE;
+	*delta_type = GIT_DELTA_IGNORED;
+	git_buf_sets(&base, info->nitem->path);
 
-		diff->strcomp    = git__strcmp;
-		diff->strncomp   = git__strncmp;
-		diff->pfxcomp    = git__prefixcmp;
-		diff->entrycomp  = git_index_entry__cmp;
-	} else {
-		diff->opts.flags |= GIT_DIFF_DELTAS_ARE_ICASE;
+	/* advance into untracked directory */
+	if ((error = git_iterator_advance_into(&info->nitem, info->new_iter)) < 0) {
 
-		diff->strcomp    = git__strcasecmp;
-		diff->strncomp   = git__strncasecmp;
-		diff->pfxcomp    = git__prefixcmp_icase;
-		diff->entrycomp  = git_index_entry__cmp_icase;
+		/* skip ahead if empty */
+		if (error == GIT_ENOTFOUND) {
+			giterr_clear();
+			error = git_iterator_advance(&info->nitem, info->new_iter);
+		}
+
+		return error;
 	}
 
-	return 0;
+	/* look for actual untracked file */
+	while (!diff->pfxcomp(info->nitem->path, git_buf_cstr(&base))) {
+		is_ignored = git_iterator_current_is_ignored(info->new_iter);
+
+		/* need to recurse into non-ignored directories */
+		if (!is_ignored && S_ISDIR(info->nitem->mode)) {
+			if ((error = git_iterator_advance_into(
+					 &info->nitem, info->new_iter)) < 0)
+				break;
+			continue;
+		}
+
+		/* found a non-ignored item - treat parent dir as untracked */
+		if (!is_ignored) {
+			*delta_type = GIT_DELTA_UNTRACKED;
+			break;
+		}
+
+		if ((error = git_iterator_advance(&info->nitem, info->new_iter)) < 0)
+			break;
+	}
+
+	/* finish off scan */
+	while (!diff->pfxcomp(info->nitem->path, git_buf_cstr(&base))) {
+		if ((error = git_iterator_advance(&info->nitem, info->new_iter)) < 0)
+			break;
+	}
+
+	git_buf_free(&base);
+
+	return error;
 }
 
-int git_diff__from_iterators(
-	git_diff_list **diff_ptr,
-	git_repository *repo,
-	git_iterator *old_iter,
-	git_iterator *new_iter,
-	const git_diff_options *opts)
+static int handle_unmatched_new_item(
+	git_diff_list *diff, diff_in_progress *info)
 {
 	int error = 0;
-	const git_index_entry *oitem, *nitem;
-	git_buf ignore_prefix = GIT_BUF_INIT;
-	git_diff_list *diff = git_diff_list_alloc(repo, opts);
-
-	*diff_ptr = NULL;
+	const git_index_entry *nitem = info->nitem;
+	git_delta_t delta_type = GIT_DELTA_UNTRACKED;
+	bool contains_oitem;
 
-	if (!diff || diff_list_init_from_iterators(diff, old_iter, new_iter) < 0)
-		goto fail;
+	/* check if this is a prefix of the other side */
+	contains_oitem = entry_is_prefixed(diff, info->oitem, nitem);
 
-	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE)) {
-		if (git_iterator_set_ignore_case(old_iter, true) < 0 ||
-			git_iterator_set_ignore_case(new_iter, true) < 0)
-			goto fail;
+	/* check if this is contained in an ignored parent directory */
+	if (git_buf_len(&info->ignore_prefix)) {
+		if (diff->pfxcomp(nitem->path, git_buf_cstr(&info->ignore_prefix)) == 0)
+			delta_type = GIT_DELTA_IGNORED;
+		else
+			git_buf_clear(&info->ignore_prefix);
 	}
 
-	if (git_iterator_current(&oitem, old_iter) < 0 ||
-		git_iterator_current(&nitem, new_iter) < 0)
-		goto fail;
+	if (S_ISDIR(nitem->mode)) {
+		bool recurse_into_dir = contains_oitem;
 
-	/* run iterators building diffs */
-	while (oitem || nitem) {
-		int cmp = oitem ? (nitem ? diff->entrycomp(oitem, nitem) : -1) : 1;
+		/* if not already inside an ignored dir, check if this is ignored */
+		if (delta_type != GIT_DELTA_IGNORED &&
+			git_iterator_current_is_ignored(info->new_iter)) {
+			delta_type = GIT_DELTA_IGNORED;
+			git_buf_sets(&info->ignore_prefix, nitem->path);
+		}
 
-		/* create DELETED records for old items not matched in new */
-		if (cmp < 0) {
-			if (diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem) < 0)
-				goto fail;
+		/* check if user requests recursion into this type of dir */
+		recurse_into_dir = contains_oitem ||
+			(delta_type == GIT_DELTA_UNTRACKED &&
+			 DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) ||
+			(delta_type == GIT_DELTA_IGNORED &&
+			 DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS));
+
+		/* do not advance into directories that contain a .git file */
+		if (recurse_into_dir) {
+			git_buf *full = NULL;
+			if (git_iterator_current_workdir_path(&full, info->new_iter) < 0)
+				return -1;
+			if (full && git_path_contains_dir(full, DOT_GIT))
+				recurse_into_dir = false;
+		}
 
-			/* if we are generating TYPECHANGE records then check for that
-			 * instead of just generating a DELETE record
-			 */
-			if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) &&
-				entry_is_prefixed(diff, nitem, oitem))
-			{
-				/* this entry has become a tree! convert to TYPECHANGE */
-				git_diff_delta *last = diff_delta__last_for_item(diff, oitem);
-				if (last) {
-					last->status = GIT_DELTA_TYPECHANGE;
-					last->new_file.mode = GIT_FILEMODE_TREE;
-				}
+		/* still have to look into untracked directories to match core git -
+		 * with no untracked files, directory is treated as ignored
+		 */
+		if (!recurse_into_dir &&
+			delta_type == GIT_DELTA_UNTRACKED &&
+			DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_FAST_UNTRACKED_DIRS))
+		{
+			git_diff_delta *last;
+
+			/* attempt to insert record for this directory */
+			if ((error = diff_delta__from_one(diff, delta_type, nitem)) < 0)
+				return error;
+
+			/* if delta wasn't created (because of rules), just skip ahead */
+			last = diff_delta__last_for_item(diff, nitem);
+			if (!last)
+				return git_iterator_advance(&info->nitem, info->new_iter);
+
+			/* iterate into dir looking for an actual untracked file */
+			if (diff_scan_inside_untracked_dir(diff, info, &delta_type) < 0)
+				return -1;
 
-				/* If new_iter is a workdir iterator, then this situation
-				 * will certainly be followed by a series of untracked items.
-				 * Unless RECURSE_UNTRACKED_DIRS is set, skip over them...
-				 */
-				if (S_ISDIR(nitem->mode) &&
-					DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS))
-				{
-					if (git_iterator_advance(&nitem, new_iter) < 0)
-						goto fail;
+			/* it iteration changed delta type, the update the record */
+			if (delta_type == GIT_DELTA_IGNORED) {
+				last->status = GIT_DELTA_IGNORED;
+
+				/* remove the record if we don't want ignored records */
+				if (DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED)) {
+					git_vector_pop(&diff->deltas);
+					git__free(last);
 				}
 			}
 
-			if (git_iterator_advance(&oitem, old_iter) < 0)
-				goto fail;
+			return 0;
 		}
 
-		/* create ADDED, TRACKED, or IGNORED records for new items not
-		 * matched in old (and/or descend into directories as needed)
+		/* try to advance into directory if necessary */
+		if (recurse_into_dir) {
+			error = git_iterator_advance_into(&info->nitem, info->new_iter);
+
+			/* if real error or no error, proceed with iteration */
+			if (error != GIT_ENOTFOUND)
+				return error;
+			giterr_clear();
+
+			/* if directory is empty, can't advance into it, so either skip
+			 * it or ignore it
+			 */
+			if (contains_oitem)
+				return git_iterator_advance(&info->nitem, info->new_iter);
+			delta_type = GIT_DELTA_IGNORED;
+		}
+	}
+
+	/* In core git, the next two checks are effectively reversed --
+	 * i.e. when an file contained in an ignored directory is explicitly
+	 * ignored, it shows up as an ignored file in the diff list, even though
+	 * other untracked files in the same directory are skipped completely.
+	 *
+	 * To me, this seems odd.  If the directory is ignored and the file is
+	 * untracked, we should skip it consistently, regardless of whether it
+	 * happens to match a pattern in the ignore file.
+	 *
+	 * To match the core git behavior, reverse the following two if checks
+	 * so that individual file ignores are checked before container
+	 * directory exclusions are used to skip the file.
+	 */
+	else if (delta_type == GIT_DELTA_IGNORED &&
+		DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS))
+		/* item contained in ignored directory, so skip over it */
+		return git_iterator_advance(&info->nitem, info->new_iter);
+
+	else if (git_iterator_current_is_ignored(info->new_iter))
+		delta_type = GIT_DELTA_IGNORED;
+
+	else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR)
+		delta_type = GIT_DELTA_ADDED;
+
+	/* Actually create the record for this item if necessary */
+	if ((error = diff_delta__from_one(diff, delta_type, nitem)) < 0)
+		return error;
+
+	/* If user requested TYPECHANGE records, then check for that instead of
+	 * just generating an ADDED/UNTRACKED record
+	 */
+	if (delta_type != GIT_DELTA_IGNORED &&
+		DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) &&
+		contains_oitem)
+	{
+		/* this entry was prefixed with a tree - make TYPECHANGE */
+		git_diff_delta *last = diff_delta__last_for_item(diff, nitem);
+		if (last) {
+			last->status = GIT_DELTA_TYPECHANGE;
+			last->old_file.mode = GIT_FILEMODE_TREE;
+		}
+	}
+
+	return git_iterator_advance(&info->nitem, info->new_iter);
+}
+
+static int handle_unmatched_old_item(
+	git_diff_list *diff, diff_in_progress *info)
+{
+	int error = diff_delta__from_one(diff, GIT_DELTA_DELETED, info->oitem);
+	if (error < 0)
+		return error;
+
+	/* if we are generating TYPECHANGE records then check for that
+	 * instead of just generating a DELETE record
+	 */
+	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) &&
+		entry_is_prefixed(diff, info->nitem, info->oitem))
+	{
+		/* this entry has become a tree! convert to TYPECHANGE */
+		git_diff_delta *last = diff_delta__last_for_item(diff, info->oitem);
+		if (last) {
+			last->status = GIT_DELTA_TYPECHANGE;
+			last->new_file.mode = GIT_FILEMODE_TREE;
+		}
+
+		/* If new_iter is a workdir iterator, then this situation
+		 * will certainly be followed by a series of untracked items.
+		 * Unless RECURSE_UNTRACKED_DIRS is set, skip over them...
 		 */
-		else if (cmp > 0) {
-			git_delta_t delta_type = GIT_DELTA_UNTRACKED;
-			bool contains_oitem = entry_is_prefixed(diff, oitem, nitem);
-
-			/* check if contained in ignored parent directory */
-			if (git_buf_len(&ignore_prefix) &&
-				diff->pfxcomp(nitem->path, git_buf_cstr(&ignore_prefix)) == 0)
-				delta_type = GIT_DELTA_IGNORED;
-
-			if (S_ISDIR(nitem->mode)) {
-				/* recurse into directory only if there are tracked items in
-				 * it or if the user requested the contents of untracked
-				 * directories and it is not under an ignored directory.
-				 */
-				bool recurse_into_dir =
-					(delta_type == GIT_DELTA_UNTRACKED &&
-					 DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) ||
-					(delta_type == GIT_DELTA_IGNORED &&
-					 DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS));
-
-				/* do not advance into directories that contain a .git file */
-				if (!contains_oitem && recurse_into_dir) {
-					git_buf *full = NULL;
-					if (git_iterator_current_workdir_path(&full, new_iter) < 0)
-						goto fail;
-					if (git_path_contains_dir(full, DOT_GIT))
-						recurse_into_dir = false;
-				}
+		if (S_ISDIR(info->nitem->mode) &&
+			DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS))
+			return git_iterator_advance(&info->nitem, info->new_iter);
+	}
 
-				/* if directory is ignored, remember ignore_prefix */
-				if ((contains_oitem || recurse_into_dir) &&
-					delta_type == GIT_DELTA_UNTRACKED &&
-					git_iterator_current_is_ignored(new_iter))
-				{
-					git_buf_sets(&ignore_prefix, nitem->path);
-					delta_type = GIT_DELTA_IGNORED;
-
-					/* skip recursion if we've just learned this is ignored */
-					if (DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS))
-						recurse_into_dir = false;
-				}
+	return git_iterator_advance(&info->oitem, info->old_iter);
+}
 
-				if (contains_oitem || recurse_into_dir) {
-					/* advance into directory */
-					error = git_iterator_advance_into(&nitem, new_iter);
+static int handle_matched_item(
+	git_diff_list *diff, diff_in_progress *info)
+{
+	int error = 0;
 
-					/* if directory is empty, can't advance into it, so skip */
-					if (error == GIT_ENOTFOUND) {
-						giterr_clear();
-						error = git_iterator_advance(&nitem, new_iter);
+	if (!(error = maybe_modified(diff, info)) &&
+		!(error = git_iterator_advance(&info->oitem, info->old_iter)))
+		error = git_iterator_advance(&info->nitem, info->new_iter);
 
-						git_buf_clear(&ignore_prefix);
-					}
+	return error;
+}
 
-					if (error < 0)
-						goto fail;
-					continue;
-				}
-			}
+int git_diff__from_iterators(
+	git_diff_list **diff_ptr,
+	git_repository *repo,
+	git_iterator *old_iter,
+	git_iterator *new_iter,
+	const git_diff_options *opts)
+{
+	int error = 0;
+	diff_in_progress info;
+	git_diff_list *diff;
 
-			/* In core git, the next two "else if" clauses are effectively
-			 * reversed -- i.e. when an untracked file contained in an
-			 * ignored directory is individually ignored, it shows up as an
-			 * ignored file in the diff list, even though other untracked
-			 * files in the same directory are skipped completely.
-			 *
-			 * To me, this is odd.  If the directory is ignored and the file
-			 * is untracked, we should skip it consistently, regardless of
-			 * whether it happens to match a pattern in the ignore file.
-			 *
-			 * To match the core git behavior, just reverse the following
-			 * two "else if" cases so that individual file ignores are
-			 * checked before container directory exclusions are used to
-			 * skip the file.
-			 */
-			else if (delta_type == GIT_DELTA_IGNORED &&
-					 DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS)) {
-				if (git_iterator_advance(&nitem, new_iter) < 0)
-					goto fail;
-				continue; /* ignored parent directory, so skip completely */
-			}
+	*diff_ptr = NULL;
 
-			else if (git_iterator_current_is_ignored(new_iter))
-				delta_type = GIT_DELTA_IGNORED;
+	diff = diff_list_alloc(repo, old_iter, new_iter);
+	GITERR_CHECK_ALLOC(diff);
 
-			else if (new_iter->type != GIT_ITERATOR_TYPE_WORKDIR)
-				delta_type = GIT_DELTA_ADDED;
+	info.repo = repo;
+	info.old_iter = old_iter;
+	info.new_iter = new_iter;
+	git_buf_init(&info.ignore_prefix, 0);
 
-			if (diff_delta__from_one(diff, delta_type, nitem) < 0)
-				goto fail;
+	/* make iterators have matching icase behavior */
+	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_DELTAS_ARE_ICASE)) {
+		if (!(error = git_iterator_set_ignore_case(old_iter, true)))
+			error = git_iterator_set_ignore_case(new_iter, true);
+	}
 
-			/* if we are generating TYPECHANGE records then check for that
-			 * instead of just generating an ADDED/UNTRACKED record
-			 */
-			if (delta_type != GIT_DELTA_IGNORED &&
-				DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) &&
-				contains_oitem)
-			{
-				/* this entry was prefixed with a tree - make TYPECHANGE */
-				git_diff_delta *last = diff_delta__last_for_item(diff, nitem);
-				if (last) {
-					last->status = GIT_DELTA_TYPECHANGE;
-					last->old_file.mode = GIT_FILEMODE_TREE;
-				}
-			}
+	/* finish initialization */
+	if (!error &&
+		!(error = diff_list_apply_options(diff, opts)) &&
+		!(error = git_iterator_current(&info.oitem, old_iter)))
+		error = git_iterator_current(&info.nitem, new_iter);
 
-			if (git_iterator_advance(&nitem, new_iter) < 0)
-				goto fail;
-		}
+	/* run iterators building diffs */
+	while (!error && (info.oitem || info.nitem)) {
+		int cmp = info.oitem ?
+			(info.nitem ? diff->entrycomp(info.oitem, info.nitem) : -1) : 1;
+
+		/* create DELETED records for old items not matched in new */
+		if (cmp < 0)
+			error = handle_unmatched_old_item(diff, &info);
+
+		/* create ADDED, TRACKED, or IGNORED records for new items not
+		 * matched in old (and/or descend into directories as needed)
+		 */
+		else if (cmp > 0)
+			error = handle_unmatched_new_item(diff, &info);
 
 		/* otherwise item paths match, so create MODIFIED record
 		 * (or ADDED and DELETED pair if type changed)
 		 */
-		else {
-			assert(oitem && nitem && cmp == 0);
-
-			if (maybe_modified(old_iter, oitem, new_iter, nitem, diff) < 0 ||
-				git_iterator_advance(&oitem, old_iter) < 0 ||
-				git_iterator_advance(&nitem, new_iter) < 0)
-				goto fail;
-		}
+		else
+			error = handle_matched_item(diff, &info);
 	}
 
-	*diff_ptr = diff;
-
-fail:
-	if (!*diff_ptr) {
+	if (!error)
+		*diff_ptr = diff;
+	else
 		git_diff_list_free(diff);
-		error = -1;
-	}
 
-	git_buf_free(&ignore_prefix);
+	git_buf_free(&info.ignore_prefix);
 
 	return error;
 }
@@ -859,12 +1023,20 @@ int git_diff_tree_to_tree(
 	const git_diff_options *opts)
 {
 	int error = 0;
+	git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE;
 
 	assert(diff && repo);
 
+	/* for tree to tree diff, be case sensitive even if the index is
+	 * currently case insensitive, unless the user explicitly asked
+	 * for case insensitivity
+	 */
+	if (opts && (opts->flags & GIT_DIFF_DELTAS_ARE_ICASE) != 0)
+		iflag = GIT_ITERATOR_IGNORE_CASE;
+
 	DIFF_FROM_ITERATORS(
-		git_iterator_for_tree(&a, old_tree, 0, pfx, pfx),
-		git_iterator_for_tree(&b, new_tree, 0, pfx, pfx)
+		git_iterator_for_tree(&a, old_tree, iflag, pfx, pfx),
+		git_iterator_for_tree(&b, new_tree, iflag, pfx, pfx)
 	);
 
 	return error;
diff --git a/src/diff.h b/src/diff.h
index 8e3cbcd..48e20d1 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -74,5 +74,17 @@ extern int git_diff__from_iterators(
 	git_iterator *new_iter,
 	const git_diff_options *opts);
 
+int git_diff_find_similar__hashsig_for_file(
+	void **out, const git_diff_file *f, const char *path, void *p);
+
+int git_diff_find_similar__hashsig_for_buf(
+	void **out, const git_diff_file *f, const char *buf, size_t len, void *p);
+
+void git_diff_find_similar__hashsig_free(void *sig, void *payload);
+
+int git_diff_find_similar__calc_similarity(
+	int *score, void *siga, void *sigb, void *payload);
+
+
 #endif
 
diff --git a/src/diff_output.c b/src/diff_output.c
index 34a3e50..64ff6b5 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -101,8 +101,8 @@ static bool diff_delta_is_binary_forced(
 
 	/* make sure files are conceivably mmap-able */
 	if ((git_off_t)((size_t)delta->old_file.size) != delta->old_file.size ||
-		(git_off_t)((size_t)delta->new_file.size) != delta->new_file.size)
-	{
+		(git_off_t)((size_t)delta->new_file.size) != delta->new_file.size) {
+
 		delta->old_file.flags |= GIT_DIFF_FLAG_BINARY;
 		delta->new_file.flags |= GIT_DIFF_FLAG_BINARY;
 		delta->flags |= GIT_DIFF_FLAG_BINARY;
@@ -232,8 +232,7 @@ static int get_blob_content(
 	if (git_oid_iszero(&file->oid))
 		return 0;
 
-	if (file->mode == GIT_FILEMODE_COMMIT)
-	{
+	if (file->mode == GIT_FILEMODE_COMMIT) {
 		char oidstr[GIT_OID_HEXSZ+1];
 		git_buf content = GIT_BUF_INIT;
 
@@ -299,8 +298,8 @@ static int get_workdir_sm_content(
 	char oidstr[GIT_OID_HEXSZ+1];
 
 	if ((error = git_submodule_lookup(&sm, ctxt->repo, file->path)) < 0 ||
-		(error = git_submodule_status(&sm_status, sm)) < 0)
-	{
+		(error = git_submodule_status(&sm_status, sm)) < 0) {
+
 		/* GIT_EEXISTS means a "submodule" that has not been git added */
 		if (error == GIT_EEXISTS)
 			error = 0;
@@ -312,8 +311,8 @@ static int get_workdir_sm_content(
 		const git_oid* sm_head;
 
 		if ((sm_head = git_submodule_wd_id(sm)) != NULL ||
-			(sm_head = git_submodule_head_id(sm)) != NULL)
-		{
+			(sm_head = git_submodule_head_id(sm)) != NULL) {
+
 			git_oid_cpy(&file->oid, sm_head);
 			file->flags |= GIT_DIFF_FLAG_VALID_OID;
 		}
@@ -660,8 +659,8 @@ static int diff_patch_load(
 	 */
 	if (check_if_unmodified &&
 		delta->old_file.mode == delta->new_file.mode &&
-		!git_oid_cmp(&delta->old_file.oid, &delta->new_file.oid))
-	{
+		!git_oid__cmp(&delta->old_file.oid, &delta->new_file.oid)) {
+
 		delta->status = GIT_DELTA_UNMODIFIED;
 
 		if ((ctxt->opts->flags & GIT_DIFF_INCLUDE_UNMODIFIED) == 0)
@@ -1049,6 +1048,12 @@ char git_diff_status_char(git_delta_t status)
 	return code;
 }
 
+static int callback_error(void)
+{
+	giterr_clear();
+	return GIT_EUSER;
+}
+
 static int print_compact(
 	const git_diff_delta *delta, float progress, void *data)
 {
@@ -1083,10 +1088,7 @@ static int print_compact(
 
 	if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_FILE_HDR,
 			git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
-	{
-		giterr_clear();
-		return GIT_EUSER;
-	}
+		return callback_error();
 
 	return 0;
 }
@@ -1114,11 +1116,20 @@ int git_diff_print_compact(
 
 static int print_oid_range(diff_print_info *pi, const git_diff_delta *delta)
 {
-	char start_oid[8], end_oid[8];
+	int abbrevlen;
+	char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1];
+
+	if (git_repository__cvar(&abbrevlen, pi->diff->repo, GIT_CVAR_ABBREV) < 0)
+		return -1;
+
+	abbrevlen += 1; /* for NUL byte */
+	if (abbrevlen < 2)
+		abbrevlen = 2;
+	else if (abbrevlen > (int)sizeof(start_oid))
+		abbrevlen = (int)sizeof(start_oid);
 
-	/* TODO: Determine a good actual OID range to print */
-	git_oid_tostr(start_oid, sizeof(start_oid), &delta->old_file.oid);
-	git_oid_tostr(end_oid, sizeof(end_oid), &delta->new_file.oid);
+	git_oid_tostr(start_oid, abbrevlen, &delta->old_file.oid);
+	git_oid_tostr(end_oid, abbrevlen, &delta->new_file.oid);
 
 	/* TODO: Match git diff more closely */
 	if (delta->old_file.mode == delta->new_file.mode) {
@@ -1191,10 +1202,7 @@ static int print_patch_file(
 
 	if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_FILE_HDR,
 			git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
-	{
-		giterr_clear();
-		return GIT_EUSER;
-	}
+		return callback_error();
 
 	if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0)
 		return 0;
@@ -1208,10 +1216,7 @@ static int print_patch_file(
 
 	if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_BINARY,
 			git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
-	{
-		giterr_clear();
-		return GIT_EUSER;
-	}
+		return callback_error();
 
 	return 0;
 }
@@ -1234,10 +1239,7 @@ static int print_patch_hunk(
 
 	if (pi->print_cb(d, r, GIT_DIFF_LINE_HUNK_HDR,
 			git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
-	{
-		giterr_clear();
-		return GIT_EUSER;
-	}
+		return callback_error();
 
 	return 0;
 }
@@ -1269,10 +1271,7 @@ static int print_patch_line(
 
 	if (pi->print_cb(delta, range, line_origin,
 			git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
-	{
-		giterr_clear();
-		return GIT_EUSER;
-	}
+		return callback_error();
 
 	return 0;
 }
@@ -1379,7 +1378,7 @@ static int diff_single_apply(diff_single_data *data)
 		(has_old ? GIT_DELTA_MODIFIED : GIT_DELTA_ADDED) :
 		(has_old ? GIT_DELTA_DELETED : GIT_DELTA_UNTRACKED);
 
-	if (git_oid_cmp(&delta->new_file.oid, &delta->old_file.oid) == 0)
+	if (git_oid__cmp(&delta->new_file.oid, &delta->old_file.oid) == 0)
 		delta->status = GIT_DELTA_UNMODIFIED;
 
 	if ((error = diff_delta_is_binary_by_content(
diff --git a/src/diff_tform.c b/src/diff_tform.c
index efcb19d..201a0e8 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -170,7 +170,7 @@ int git_diff_merge(
 	return error;
 }
 
-static int find_similar__hashsig_for_file(
+int git_diff_find_similar__hashsig_for_file(
 	void **out, const git_diff_file *f, const char *path, void *p)
 {
 	git_hashsig_option_t opt = (git_hashsig_option_t)p;
@@ -187,12 +187,12 @@ static int find_similar__hashsig_for_file(
 	return error;
 }
 
-static int find_similar__hashsig_for_buf(
+int git_diff_find_similar__hashsig_for_buf(
 	void **out, const git_diff_file *f, const char *buf, size_t len, void *p)
 {
 	git_hashsig_option_t opt = (git_hashsig_option_t)p;
 	int error = 0;
-	
+
 	GIT_UNUSED(f);
 	error = git_hashsig_create((git_hashsig **)out, buf, len, opt);
 	
@@ -204,13 +204,13 @@ static int find_similar__hashsig_for_buf(
 	return error;
 }
 
-static void find_similar__hashsig_free(void *sig, void *payload)
+void git_diff_find_similar__hashsig_free(void *sig, void *payload)
 {
 	GIT_UNUSED(payload);
 	git_hashsig_free(sig);
 }
 
-static int find_similar__calc_similarity(
+int git_diff_find_similar__calc_similarity(
 	int *score, void *siga, void *sigb, void *payload)
 {
 	GIT_UNUSED(payload);
@@ -291,10 +291,10 @@ static int normalize_find_opts(
 		opts->metric = git__malloc(sizeof(git_diff_similarity_metric));
 		GITERR_CHECK_ALLOC(opts->metric);
 
-		opts->metric->file_signature = find_similar__hashsig_for_file;
-		opts->metric->buffer_signature = find_similar__hashsig_for_buf;
-		opts->metric->free_signature = find_similar__hashsig_free;
-		opts->metric->similarity = find_similar__calc_similarity;
+		opts->metric->file_signature = git_diff_find_similar__hashsig_for_file;
+		opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf;
+		opts->metric->free_signature = git_diff_find_similar__hashsig_free;
+		opts->metric->similarity = git_diff_find_similar__calc_similarity;
 
 		if (opts->flags & GIT_DIFF_FIND_IGNORE_WHITESPACE)
 			opts->metric->payload = (void *)GIT_HASHSIG_IGNORE_WHITESPACE;
@@ -429,7 +429,7 @@ static int similarity_measure(
 	if (GIT_MODE_TYPE(a_file->mode) != GIT_MODE_TYPE(b_file->mode))
 		return 0;
 
-	if (git_oid_cmp(&a_file->oid, &b_file->oid) == 0)
+	if (git_oid__cmp(&a_file->oid, &b_file->oid) == 0)
 		return 100;
 
 	/* update signature cache if needed */
diff --git a/src/fetch.c b/src/fetch.c
index b60a952..8ae34bd 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -34,7 +34,7 @@ static int filter_ref__cb(git_remote_head *head, void *payload)
 
 	if (!p->found_head && strcmp(head->name, GIT_HEAD_FILE) == 0)
 		p->found_head = 1;
-	else if (git_refspec_src_matches(p->spec, head->name))
+	else if (git_remote__matching_refspec(p->remote, head->name))
 			match = 1;
 	else if (p->remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL &&
 		 git_refspec_src_matches(p->tagspec, head->name))
@@ -68,7 +68,6 @@ static int filter_wants(git_remote *remote)
 	 * not interested in any particular branch but just the remote's
 	 * HEAD, which will be stored in FETCH_HEAD after the fetch.
 	 */
-	p.spec = git_remote_fetchspec(remote);
 	p.tagspec = &tagspec;
 	p.found_head = 0;
 	p.remote = remote;
diff --git a/src/global.c b/src/global.c
index b7fd8e2..a0571d1 100644
--- a/src/global.c
+++ b/src/global.c
@@ -135,6 +135,12 @@ int git_threads_init(void)
 
 void git_threads_shutdown(void)
 {
+	if (_tls_init) {
+		void *ptr = pthread_getspecific(_tls_key);
+		pthread_setspecific(_tls_key, NULL);
+		git__free(ptr);
+	}
+
 	pthread_key_delete(_tls_key);
 	_tls_init = 0;
 	git_mutex_free(&git__mwindow_mutex);
diff --git a/src/global.h b/src/global.h
index f0ad1df..badbc08 100644
--- a/src/global.h
+++ b/src/global.h
@@ -10,14 +10,6 @@
 #include "mwindow.h"
 #include "hash.h"
 
-#if defined(GIT_THREADS) && defined(_MSC_VER)
-# define GIT_MEMORY_BARRIER MemoryBarrier()
-#elif defined(GIT_THREADS)
-# define GIT_MEMORY_BARRIER __sync_synchronize()
-#else
-# define GIT_MEMORY_BARRIER /* noop */
-#endif
-
 typedef struct {
 	git_error *last_error;
 	git_error error_t;
diff --git a/src/ignore.c b/src/ignore.c
index 1777952..e150b95 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -15,24 +15,14 @@ static int parse_ignore_file(
 	git_attr_fnmatch *match = NULL;
 	const char *scan = NULL;
 	char *context = NULL;
-	bool ignore_case = false;
-	git_config *cfg = NULL;
-	int val;
-
-	/* Prefer to have the caller pass in a git_ignores as the parsedata object.
-	 * If they did not, then we can (much more slowly) find the value of
-	 * ignore_case by using the repository object. */
-	if (parsedata != NULL) {
-		ignore_case = ((git_ignores *)parsedata)->ignore_case;
-	} else {
-		if ((error = git_repository_config(&cfg, repo)) < 0)
-			return error;
-
-		if (git_config_get_bool(&val, cfg, "core.ignorecase") == 0)
-			ignore_case = (val != 0);
+	int ignore_case = false;
 
-		git_config_free(cfg);
-	}
+	/* Prefer to have the caller pass in a git_ignores as the parsedata
+	 * object.  If they did not, then look up the value of ignore_case */
+	if (parsedata != NULL)
+		ignore_case = ((git_ignores *)parsedata)->ignore_case;
+	else if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
+		return error;
 
 	if (ignores->key && git__suffixcmp(ignores->key, "/" GIT_IGNORE_FILE) == 0) {
 		context = ignores->key + 2;
@@ -109,8 +99,6 @@ int git_ignore__for_path(
 {
 	int error = 0;
 	const char *workdir = git_repository_workdir(repo);
-	git_config *cfg = NULL;
-	int val;
 
 	assert(ignores);
 
@@ -118,17 +106,11 @@ int git_ignore__for_path(
 	git_buf_init(&ignores->dir, 0);
 	ignores->ign_internal = NULL;
 
-	/* Set the ignore_case flag appropriately */
-	if ((error = git_repository_config(&cfg, repo)) < 0)
+	/* Read the ignore_case flag */
+	if ((error = git_repository__cvar(
+			&ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0)
 		goto cleanup;
 
-	if (git_config_get_bool(&val, cfg, "core.ignorecase") == 0)
-		ignores->ignore_case = (val != 0);
-	else
-		ignores->ignore_case = 0;
-
-	git_config_free(cfg);
-
 	if ((error = git_vector_init(&ignores->ign_path, 8, NULL)) < 0 ||
 		(error = git_vector_init(&ignores->ign_global, 2, NULL)) < 0 ||
 		(error = git_attr_cache__init(repo)) < 0)
diff --git a/src/ignore.h b/src/ignore.h
index 5af8e8e..e00e4a8 100644
--- a/src/ignore.h
+++ b/src/ignore.h
@@ -28,7 +28,7 @@ typedef struct {
 	git_attr_file *ign_internal;
 	git_vector ign_path;
 	git_vector ign_global;
-	unsigned int ignore_case:1;
+	int ignore_case;
 } git_ignores;
 
 extern int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *ign);
diff --git a/src/index.c b/src/index.c
index 6290ec4..d4aa475 100644
--- a/src/index.c
+++ b/src/index.c
@@ -19,6 +19,7 @@
 #include "git2/oid.h"
 #include "git2/blob.h"
 #include "git2/config.h"
+#include "git2/sys/index.h"
 
 #define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7)
 #define short_entry_size(len) entry_size(struct entry_short, len)
@@ -35,6 +36,7 @@ static const unsigned int INDEX_VERSION_NUMBER_EXT = 3;
 static const unsigned int INDEX_HEADER_SIG = 0x44495243;
 static const char INDEX_EXT_TREECACHE_SIG[] = {'T', 'R', 'E', 'E'};
 static const char INDEX_EXT_UNMERGED_SIG[] = {'R', 'E', 'U', 'C'};
+static const char INDEX_EXT_CONFLICT_NAME_SIG[] = {'N', 'A', 'M', 'E'};
 
 #define INDEX_OWNER(idx) ((git_repository *)(GIT_REFCOUNT_OWNER(idx)))
 
@@ -187,6 +189,51 @@ static int index_icmp(const void *a, const void *b)
 	return diff;
 }
 
+static int conflict_name_cmp(const void *a, const void *b)
+{
+	const git_index_name_entry *name_a = a;
+	const git_index_name_entry *name_b = b;
+
+	if (name_a->ancestor && !name_b->ancestor)
+		return 1;
+
+	if (!name_a->ancestor && name_b->ancestor)
+		return -1;
+
+	if (name_a->ancestor)
+		return strcmp(name_a->ancestor, name_b->ancestor);
+
+	if (!name_a->ours || !name_b->ours)
+		return 0;
+
+	return strcmp(name_a->ours, name_b->ours);
+}
+
+/**
+ * TODO: enable this when resolving case insensitive conflicts
+ */
+#if 0
+static int conflict_name_icmp(const void *a, const void *b)
+{
+	const git_index_name_entry *name_a = a;
+	const git_index_name_entry *name_b = b;
+
+	if (name_a->ancestor && !name_b->ancestor)
+		return 1;
+
+	if (!name_a->ancestor && name_b->ancestor)
+		return -1;
+
+	if (name_a->ancestor)
+		return strcasecmp(name_a->ancestor, name_b->ancestor);
+
+	if (!name_a->ours || !name_b->ours)
+		return 0;
+
+	return strcasecmp(name_a->ours, name_b->ours);
+}
+#endif
+
 static int reuc_srch(const void *key, const void *array_member)
 {
 	const git_index_reuc_entry *reuc = array_member;
@@ -278,6 +325,7 @@ int git_index_open(git_index **index_out, const char *index_path)
 	}
 
 	if (git_vector_init(&index->entries, 32, index_cmp) < 0 ||
+		git_vector_init(&index->names, 32, conflict_name_cmp) < 0 ||
 		git_vector_init(&index->reuc, 32, reuc_cmp) < 0)
 		return -1;
 
@@ -330,6 +378,8 @@ void git_index_clear(git_index *index)
 	git_vector_clear(&index->entries);
 
 	git_index_reuc_clear(index);
+
+	git_index_name_clear(index);
 	
 	git_futils_filestamp_set(&index->stamp, NULL);
 
@@ -352,19 +402,18 @@ int git_index_set_caps(git_index *index, unsigned int caps)
 	old_ignore_case = index->ignore_case;
 
 	if (caps == GIT_INDEXCAP_FROM_OWNER) {
-		git_config *cfg;
+		git_repository *repo = INDEX_OWNER(index);
 		int val;
 
-		if (INDEX_OWNER(index) == NULL ||
-			git_repository_config__weakptr(&cfg, INDEX_OWNER(index)) < 0)
-				return create_index_error(-1,
-					"Cannot get repository config to set index caps");
+		if (!repo)
+			return create_index_error(
+				-1, "Cannot access repository to set index caps");
 
-		if (git_config_get_bool(&val, cfg, "core.ignorecase") == 0)
+		if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE))
 			index->ignore_case = (val != 0);
-		if (git_config_get_bool(&val, cfg, "core.filemode") == 0)
+		if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE))
 			index->distrust_filemode = (val == 0);
-		if (git_config_get_bool(&val, cfg, "core.symlinks") == 0)
+		if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS))
 			index->no_symlinks = (val == 0);
 	}
 	else {
@@ -586,8 +635,9 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const
 
 static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
 	const char *path,
-	int ancestor_mode, git_oid *ancestor_oid,
-	int our_mode, git_oid *our_oid, int their_mode, git_oid *their_oid)
+	int ancestor_mode, const git_oid *ancestor_oid,
+	int our_mode, const git_oid *our_oid,
+	int their_mode, const git_oid *their_oid)
 {
 	git_index_reuc_entry *reuc = NULL;
 
@@ -693,7 +743,7 @@ static int index_conflict_to_reuc(git_index *index, const char *path)
 {
 	git_index_entry *conflict_entries[3];
 	int ancestor_mode, our_mode, their_mode;
-	git_oid *ancestor_oid, *our_oid, *their_oid;
+	git_oid const *ancestor_oid, *our_oid, *their_oid;
 	int ret;
 
 	if ((ret = git_index_conflict_get(&conflict_entries[0],
@@ -947,7 +997,6 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
 		return GIT_ENOTFOUND;
 
 	for (posmax = git_index_entrycount(index); pos < posmax; ++pos) {
-
 		conflict_entry = git_vector_get(&index->entries, pos);
 
 		if (index->entries_cmp_path(conflict_entry->path, path) != 0)
@@ -1043,13 +1092,82 @@ int git_index_has_conflicts(const git_index *index)
 	return 0;
 }
 
+unsigned int git_index_name_entrycount(git_index *index)
+{
+	assert(index);
+	return (unsigned int)index->names.length;
+}
+
+const git_index_name_entry *git_index_name_get_byindex(
+	git_index *index, size_t n)
+{
+	assert(index);
+	
+	git_vector_sort(&index->names);
+	return git_vector_get(&index->names, n);
+}
+
+int git_index_name_add(git_index *index,
+	const char *ancestor, const char *ours, const char *theirs)
+{
+	git_index_name_entry *conflict_name;
+
+	assert ((ancestor && ours) || (ancestor && theirs) || (ours && theirs));
+
+	conflict_name = git__calloc(1, sizeof(git_index_name_entry));
+	GITERR_CHECK_ALLOC(conflict_name);
+	
+	if (ancestor) {
+		conflict_name->ancestor = git__strdup(ancestor);
+		GITERR_CHECK_ALLOC(conflict_name->ancestor);
+	}
+
+	if (ours) {
+		conflict_name->ours = git__strdup(ours);
+		GITERR_CHECK_ALLOC(conflict_name->ours);
+	}
+
+	if (theirs) {
+		conflict_name->theirs = git__strdup(theirs);
+		GITERR_CHECK_ALLOC(conflict_name->theirs);
+	}
+	
+	return git_vector_insert(&index->names, conflict_name);
+}
+
+void git_index_name_clear(git_index *index)
+{
+	size_t i;
+	git_index_name_entry *conflict_name;
+
+	assert(index);
+	
+	git_vector_foreach(&index->names, i, conflict_name) {
+		if (conflict_name->ancestor)
+			git__free(conflict_name->ancestor);
+
+		if (conflict_name->ours)
+			git__free(conflict_name->ours);
+
+		if (conflict_name->theirs)
+			git__free(conflict_name->theirs);
+
+		git__free(conflict_name);
+	}
+	
+	git_vector_clear(&index->names);
+}
+
 unsigned int git_index_reuc_entrycount(git_index *index)
 {
 	assert(index);
 	return (unsigned int)index->reuc.length;
 }
 
-static int index_reuc_insert(git_index *index, git_index_reuc_entry *reuc, int replace)
+static int index_reuc_insert(
+	git_index *index,
+	git_index_reuc_entry *reuc,
+	int replace)
 {
 	git_index_reuc_entry **existing = NULL;
 	size_t position;
@@ -1071,9 +1189,9 @@ static int index_reuc_insert(git_index *index, git_index_reuc_entry *reuc, int r
 }
 
 int git_index_reuc_add(git_index *index, const char *path,
-	int ancestor_mode, git_oid *ancestor_oid,
-	int our_mode, git_oid *our_oid,
-	int their_mode, git_oid *their_oid)
+	int ancestor_mode, const git_oid *ancestor_oid,
+	int our_mode, const git_oid *our_oid,
+	int their_mode, const git_oid *their_oid)
 {
 	git_index_reuc_entry *reuc = NULL;
 	int error = 0;
@@ -1226,6 +1344,52 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
 	return 0;
 }
 
+
+static int read_conflict_names(git_index *index, const char *buffer, size_t size)
+{
+	size_t len;
+	
+	/* This gets called multiple times, the vector might already be initialized */
+	if (index->names._alloc_size == 0 &&
+		git_vector_init(&index->names, 16, conflict_name_cmp) < 0)
+		return -1;
+
+#define read_conflict_name(ptr) \
+	len = strlen(buffer) + 1; \
+	if (size < len) \
+		return index_error_invalid("reading conflict name entries"); \
+	\
+	if (len == 1) \
+		ptr = NULL; \
+	else { \
+		ptr = git__malloc(len); \
+		GITERR_CHECK_ALLOC(ptr); \
+		memcpy(ptr, buffer, len); \
+	} \
+	\
+	buffer += len; \
+	size -= len;
+	
+	while (size) {
+		git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry));
+		GITERR_CHECK_ALLOC(conflict_name);
+
+		read_conflict_name(conflict_name->ancestor);
+		read_conflict_name(conflict_name->ours);
+		read_conflict_name(conflict_name->theirs);
+		
+		if (git_vector_insert(&index->names, conflict_name) < 0)
+			return -1;
+	}
+
+#undef read_conflict_name
+	
+	/* entries are guaranteed to be sorted on-disk */
+	index->names.sorted = 1;
+	
+	return 0;	
+}
+
 static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffer_size)
 {
 	size_t path_length, entry_size;
@@ -1330,6 +1494,9 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
 		} else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
 			if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
 				return 0;
+		} else if (memcmp(dest.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4) == 0) {
+			if (read_conflict_names(index, buffer + 8, dest.extension_size) < 0)
+				return 0;
 		}
 		/* else, unsupported extension. We cannot parse this, but we can skip
 		 * it by returning `total_size */
@@ -1345,7 +1512,7 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
 static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
 {
 	unsigned int i;
-	struct index_header header;
+	struct index_header header = { 0 };
 	git_oid checksum_calculated, checksum_expected;
 
 #define seek_forward(_increase) { \
@@ -1412,7 +1579,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
 	/* 160-bit SHA-1 over the content of the index file before this checksum. */
 	git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer);
 
-	if (git_oid_cmp(&checksum_calculated, &checksum_expected) != 0)
+	if (git_oid__cmp(&checksum_calculated, &checksum_expected) != 0)
 		return index_error_invalid("calculated checksum does not match expected");
 
 #undef seek_forward
@@ -1543,6 +1710,61 @@ static int write_extension(git_filebuf *file, struct index_extension *header, gi
 	return error;
 }
 
+static int create_name_extension_data(git_buf *name_buf, git_index_name_entry *conflict_name)
+{
+	int error = 0;
+
+	if (conflict_name->ancestor == NULL)
+		error = git_buf_put(name_buf, "\0", 1);
+	else
+		error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1);
+	
+	if (error != 0)
+		goto on_error;
+
+	if (conflict_name->ours == NULL)
+		error = git_buf_put(name_buf, "\0", 1);
+	else
+		error = git_buf_put(name_buf, conflict_name->ours, strlen(conflict_name->ours) + 1);
+
+	if (error != 0)
+		goto on_error;
+
+	if (conflict_name->theirs == NULL)
+		error = git_buf_put(name_buf, "\0", 1);
+	else
+		error = git_buf_put(name_buf, conflict_name->theirs, strlen(conflict_name->theirs) + 1);
+
+on_error:
+	return error;
+}
+
+static int write_name_extension(git_index *index, git_filebuf *file)
+{
+	git_buf name_buf = GIT_BUF_INIT;
+	git_vector *out = &index->names;
+	git_index_name_entry *conflict_name;
+	struct index_extension extension;
+	size_t i;
+	int error = 0;
+	
+	git_vector_foreach(out, i, conflict_name) {
+		if ((error = create_name_extension_data(&name_buf, conflict_name)) < 0)
+			goto done;
+	}
+	
+	memset(&extension, 0x0, sizeof(struct index_extension));
+	memcpy(&extension.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4);
+	extension.extension_size = (uint32_t)name_buf.size;
+	
+	error = write_extension(file, &extension, &name_buf);
+	
+	git_buf_free(&name_buf);
+	
+done:
+	return error;
+}
+
 static int create_reuc_extension_data(git_buf *reuc_buf, git_index_reuc_entry *reuc)
 {
 	int i;
@@ -1613,6 +1835,10 @@ static int write_index(git_index *index, git_filebuf *file)
 
 	/* TODO: write tree cache extension */
 
+	/* write the rename conflict extension */
+	if (index->names.length > 0 && write_name_extension(index, file) < 0)
+		return -1;
+	
 	/* write the reuc extension */
 	if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0)
 		return -1;
diff --git a/src/index.h b/src/index.h
index 9498907..2ad4017 100644
--- a/src/index.h
+++ b/src/index.h
@@ -33,6 +33,7 @@ struct git_index {
 
 	git_tree_cache *tree;
 
+	git_vector names;
 	git_vector reuc;
 
 	git_vector_cmp entries_cmp_path;
diff --git a/src/indexer.c b/src/indexer.c
index 2cfbd3a..91b7ba5 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -9,7 +9,6 @@
 
 #include "git2/indexer.h"
 #include "git2/object.h"
-#include "git2/oid.h"
 
 #include "common.h"
 #include "pack.h"
@@ -17,6 +16,7 @@
 #include "posix.h"
 #include "pack.h"
 #include "filebuf.h"
+#include "oid.h"
 #include "oidmap.h"
 
 #define UINT31_MAX (0x7FFFFFFF)
@@ -60,36 +60,19 @@ const git_oid *git_indexer_stream_hash(const git_indexer_stream *idx)
 
 static int open_pack(struct git_pack_file **out, const char *filename)
 {
-	size_t namelen;
 	struct git_pack_file *pack;
-	struct stat st;
-	int fd;
 
-	namelen = strlen(filename);
-	pack = git__calloc(1, sizeof(struct git_pack_file) + namelen + 1);
-	GITERR_CHECK_ALLOC(pack);
-
-	memcpy(pack->pack_name, filename, namelen + 1);
-
-	if (p_stat(filename, &st) < 0) {
-		giterr_set(GITERR_OS, "Failed to stat packfile.");
-		goto cleanup;
-	}
+	if (git_packfile_alloc(&pack, filename) < 0)
+		return -1;
 
-	if ((fd = p_open(pack->pack_name, O_RDONLY)) < 0) {
+	if ((pack->mwf.fd = p_open(pack->pack_name, O_RDONLY)) < 0) {
 		giterr_set(GITERR_OS, "Failed to open packfile.");
-		goto cleanup;
+		git_packfile_free(pack);
+		return -1;
 	}
 
-	pack->mwf.fd = fd;
-	pack->mwf.size = (git_off_t)st.st_size;
-
 	*out = pack;
 	return 0;
-
-cleanup:
-	git__free(pack);
-	return -1;
 }
 
 static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack)
@@ -120,7 +103,7 @@ static int objects_cmp(const void *a, const void *b)
 	const struct entry *entrya = a;
 	const struct entry *entryb = b;
 
-	return git_oid_cmp(&entrya->oid, &entryb->oid);
+	return git_oid__cmp(&entrya->oid, &entryb->oid);
 }
 
 int git_indexer_stream_new(
@@ -391,7 +374,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 {
 	int error = -1;
 	struct git_pack_header hdr;
-	size_t processed; 
+	size_t processed;
 	git_mwindow_file *mwf = &idx->pack->mwf;
 
 	assert(idx && data && stats);
@@ -404,7 +387,6 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 	/* Make sure we set the new size of the pack */
 	if (idx->opened_pack) {
 		idx->pack->mwf.size += size;
-		//printf("\nadding %zu for %zu\n", size, idx->pack->mwf.size);
 	} else {
 		if (open_pack(&idx->pack, idx->pack_file.path_lock) < 0)
 			return -1;
diff --git a/src/iterator.c b/src/iterator.c
index 5b5ed95..ff08c1c 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -26,8 +26,6 @@
 	(GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_DONT_IGNORE_CASE)
 
 #define ITERATOR_BASE_INIT(P,NAME_LC,NAME_UC,REPO) do { \
-	(P) = git__calloc(1, sizeof(NAME_LC ## _iterator)); \
-	GITERR_CHECK_ALLOC(P); \
 	(P)->base.type    = GIT_ITERATOR_TYPE_ ## NAME_UC; \
 	(P)->base.cb      = &(P)->cb; \
 	ITERATOR_SET_CB(P,NAME_LC); \
@@ -148,7 +146,8 @@ int git_iterator_for_nothing(
 	const char *start,
 	const char *end)
 {
-	empty_iterator *i;
+	empty_iterator *i = git__calloc(1, sizeof(empty_iterator));
+	GITERR_CHECK_ALLOC(i);
 
 #define empty_iterator__current empty_iterator__noop
 #define empty_iterator__advance empty_iterator__noop
@@ -581,6 +580,9 @@ int git_iterator_for_tree(
 	if ((error = git_object_dup((git_object **)&tree, (git_object *)tree)) < 0)
 		return error;
 
+	ti = git__calloc(1, sizeof(tree_iterator));
+	GITERR_CHECK_ALLOC(ti);
+
 	ITERATOR_BASE_INIT(ti, tree, TREE, git_tree_owner(tree));
 
 	if ((error = iterator__update_ignore_case((git_iterator *)ti, flags)) < 0)
@@ -810,7 +812,8 @@ int git_iterator_for_index(
 	const char *start,
 	const char *end)
 {
-	index_iterator *ii;
+	index_iterator *ii = git__calloc(1, sizeof(index_iterator));
+	GITERR_CHECK_ALLOC(ii);
 
 	ITERATOR_BASE_INIT(ii, index, INDEX, git_index_owner(index));
 
@@ -833,237 +836,221 @@ int git_iterator_for_index(
 }
 
 
-#define WORKDIR_MAX_DEPTH 100
-
-typedef struct workdir_iterator_frame workdir_iterator_frame;
-struct workdir_iterator_frame {
-	workdir_iterator_frame *next;
+typedef struct fs_iterator_frame fs_iterator_frame;
+struct fs_iterator_frame {
+	fs_iterator_frame *next;
 	git_vector entries;
 	size_t index;
 };
 
-typedef struct {
+typedef struct fs_iterator fs_iterator;
+struct fs_iterator {
 	git_iterator base;
 	git_iterator_callbacks cb;
-	workdir_iterator_frame *stack;
-	git_ignores ignores;
+	fs_iterator_frame *stack;
 	git_index_entry entry;
 	git_buf path;
 	size_t root_len;
-	int is_ignored;
 	int depth;
-} workdir_iterator;
 
-GIT_INLINE(bool) path_is_dotgit(const git_path_with_stat *ps)
-{
-	if (!ps)
-		return false;
-	else {
-		const char *path = ps->path;
-		size_t len  = ps->path_len;
-
-		if (len < 4)
-			return false;
-		if (path[len - 1] == '/')
-			len--;
-		if (tolower(path[len - 1]) != 't' ||
-			tolower(path[len - 2]) != 'i' ||
-			tolower(path[len - 3]) != 'g' ||
-			tolower(path[len - 4]) != '.')
-			return false;
-		return (len == 4 || path[len - 5] == '/');
-	}
-}
+	int (*enter_dir_cb)(fs_iterator *self);
+	int (*leave_dir_cb)(fs_iterator *self);
+	int (*update_entry_cb)(fs_iterator *self);
+};
 
-static workdir_iterator_frame *workdir_iterator__alloc_frame(
-	workdir_iterator *wi)
+#define FS_MAX_DEPTH 100
+
+static fs_iterator_frame *fs_iterator__alloc_frame(fs_iterator *fi)
 {
-	workdir_iterator_frame *wf = git__calloc(1, sizeof(workdir_iterator_frame));
+	fs_iterator_frame *ff = git__calloc(1, sizeof(fs_iterator_frame));
 	git_vector_cmp entry_compare = CASESELECT(
-		iterator__ignore_case(wi),
+		iterator__ignore_case(fi),
 		git_path_with_stat_cmp_icase, git_path_with_stat_cmp);
 
-	if (wf == NULL)
-		return NULL;
-
-	if (git_vector_init(&wf->entries, 0, entry_compare) != 0) {
-		git__free(wf);
-		return NULL;
+	if (ff && git_vector_init(&ff->entries, 0, entry_compare) < 0) {
+		git__free(ff);
+		ff = NULL;
 	}
 
-	return wf;
+	return ff;
 }
 
-static void workdir_iterator__free_frame(workdir_iterator_frame *wf)
+static void fs_iterator__free_frame(fs_iterator_frame *ff)
 {
-	unsigned int i;
+	size_t i;
 	git_path_with_stat *path;
 
-	git_vector_foreach(&wf->entries, i, path)
+	git_vector_foreach(&ff->entries, i, path)
 		git__free(path);
-	git_vector_free(&wf->entries);
-	git__free(wf);
+	git_vector_free(&ff->entries);
+	git__free(ff);
+}
+
+static void fs_iterator__pop_frame(
+	fs_iterator *fi, fs_iterator_frame *ff, bool pop_last)
+{
+	if (fi && fi->stack == ff) {
+		if (!ff->next && !pop_last) {
+			memset(&fi->entry, 0, sizeof(fi->entry));
+			return;
+		}
+
+		if (fi->leave_dir_cb)
+			(void)fi->leave_dir_cb(fi);
+
+		fi->stack = ff->next;
+		fi->depth--;
+	}
+
+	fs_iterator__free_frame(ff);
 }
 
-static int workdir_iterator__update_entry(workdir_iterator *wi);
+static int fs_iterator__update_entry(fs_iterator *fi);
 
-static int workdir_iterator__entry_cmp(const void *i, const void *item)
+static int fs_iterator__entry_cmp(const void *i, const void *item)
 {
-	const workdir_iterator *wi = (const workdir_iterator *)i;
+	const fs_iterator *fi = (const fs_iterator *)i;
 	const git_path_with_stat *ps = item;
-	return wi->base.prefixcomp(wi->base.start, ps->path);
+	return fi->base.prefixcomp(fi->base.start, ps->path);
 }
 
-static void workdir_iterator__seek_frame_start(
-	workdir_iterator *wi, workdir_iterator_frame *wf)
+static void fs_iterator__seek_frame_start(
+	fs_iterator *fi, fs_iterator_frame *ff)
 {
-	if (!wf)
+	if (!ff)
 		return;
 
-	if (wi->base.start)
+	if (fi->base.start)
 		git_vector_bsearch2(
-			&wf->index, &wf->entries, workdir_iterator__entry_cmp, wi);
+			&ff->index, &ff->entries, fs_iterator__entry_cmp, fi);
 	else
-		wf->index = 0;
-
-	if (path_is_dotgit(git_vector_get(&wf->entries, wf->index)))
-		wf->index++;
+		ff->index = 0;
 }
 
-static int workdir_iterator__expand_dir(workdir_iterator *wi)
+static int fs_iterator__expand_dir(fs_iterator *fi)
 {
 	int error;
-	workdir_iterator_frame *wf;
+	fs_iterator_frame *ff;
+
+	if (fi->depth > FS_MAX_DEPTH) {
+		giterr_set(GITERR_REPOSITORY,
+			"Directory nesting is too deep (%d)", fi->depth);
+		return -1;
+	}
 
-	wf = workdir_iterator__alloc_frame(wi);
-	GITERR_CHECK_ALLOC(wf);
+	ff = fs_iterator__alloc_frame(fi);
+	GITERR_CHECK_ALLOC(ff);
 
 	error = git_path_dirload_with_stat(
-		wi->path.ptr, wi->root_len, iterator__ignore_case(wi),
-		wi->base.start, wi->base.end, &wf->entries);
+		fi->path.ptr, fi->root_len, iterator__ignore_case(fi),
+		fi->base.start, fi->base.end, &ff->entries);
 
-	if (error < 0 || wf->entries.length == 0) {
-		workdir_iterator__free_frame(wf);
+	if (error < 0 || ff->entries.length == 0) {
+		fs_iterator__free_frame(ff);
 		return GIT_ENOTFOUND;
 	}
 
-	if (++(wi->depth) > WORKDIR_MAX_DEPTH) {
-		giterr_set(GITERR_REPOSITORY,
-			"Working directory is too deep (%d)", wi->depth);
-		workdir_iterator__free_frame(wf);
-		return -1;
-	}
-
-	workdir_iterator__seek_frame_start(wi, wf);
+	fs_iterator__seek_frame_start(fi, ff);
 
-	/* only push new ignores if this is not top level directory */
-	if (wi->stack != NULL) {
-		ssize_t slash_pos = git_buf_rfind_next(&wi->path, '/');
-		(void)git_ignore__push_dir(&wi->ignores, &wi->path.ptr[slash_pos + 1]);
-	}
+	ff->next  = fi->stack;
+	fi->stack = ff;
+	fi->depth++;
 
-	wf->next  = wi->stack;
-	wi->stack = wf;
+	if (fi->enter_dir_cb && (error = fi->enter_dir_cb(fi)) < 0)
+		return error;
 
-	return workdir_iterator__update_entry(wi);
+	return fs_iterator__update_entry(fi);
 }
 
-static int workdir_iterator__current(
+static int fs_iterator__current(
 	const git_index_entry **entry, git_iterator *self)
 {
-	workdir_iterator *wi = (workdir_iterator *)self;
+	fs_iterator *fi = (fs_iterator *)self;
 	if (entry)
-		*entry = (wi->entry.path == NULL) ? NULL : &wi->entry;
+		*entry = (fi->entry.path == NULL) ? NULL : &fi->entry;
 	return 0;
 }
 
-static int workdir_iterator__at_end(git_iterator *self)
+static int fs_iterator__at_end(git_iterator *self)
 {
-	return (((workdir_iterator *)self)->entry.path == NULL);
+	return (((fs_iterator *)self)->entry.path == NULL);
 }
 
-static int workdir_iterator__advance_into(
+static int fs_iterator__advance_into(
 	const git_index_entry **entry, git_iterator *iter)
 {
 	int error = 0;
-	workdir_iterator *wi = (workdir_iterator *)iter;
+	fs_iterator *fi = (fs_iterator *)iter;
 
 	iterator__clear_entry(entry);
 
-	/* workdir iterator will allow you to explicitly advance into a
-	 * commit/submodule (as well as a tree) to avoid some cases where an
-	 * entry is mislabeled as a submodule in the working directory
+	/* Allow you to explicitly advance into a commit/submodule (as well as a
+	 * tree) to avoid cases where an entry is mislabeled as a submodule in
+	 * the working directory.  The fs iterator will never have COMMMIT
+	 * entries on it's own, but a wrapper might add them.
 	 */
-	if (wi->entry.path != NULL &&
-		(wi->entry.mode == GIT_FILEMODE_TREE ||
-		 wi->entry.mode == GIT_FILEMODE_COMMIT))
+	if (fi->entry.path != NULL &&
+		(fi->entry.mode == GIT_FILEMODE_TREE ||
+		 fi->entry.mode == GIT_FILEMODE_COMMIT))
 		/* returns GIT_ENOTFOUND if the directory is empty */
-		error = workdir_iterator__expand_dir(wi);
+		error = fs_iterator__expand_dir(fi);
 
 	if (!error && entry)
-		error = workdir_iterator__current(entry, iter);
+		error = fs_iterator__current(entry, iter);
 
 	return error;
 }
 
-static int workdir_iterator__advance(
+static int fs_iterator__advance_over(
 	const git_index_entry **entry, git_iterator *self)
 {
 	int error = 0;
-	workdir_iterator *wi = (workdir_iterator *)self;
-	workdir_iterator_frame *wf;
+	fs_iterator *fi = (fs_iterator *)self;
+	fs_iterator_frame *ff;
 	git_path_with_stat *next;
 
-	/* given include_trees & autoexpand, we might have to go into a tree */
-	if (iterator__do_autoexpand(wi) &&
-		wi->entry.path != NULL &&
-		wi->entry.mode == GIT_FILEMODE_TREE)
-	{
-		error = workdir_iterator__advance_into(entry, self);
-
-		/* continue silently past empty directories if autoexpanding */
-		if (error != GIT_ENOTFOUND)
-			return error;
-		giterr_clear();
-		error = 0;
-	}
-
 	if (entry != NULL)
 		*entry = NULL;
 
-	while (wi->entry.path != NULL) {
-		wf   = wi->stack;
-		next = git_vector_get(&wf->entries, ++wf->index);
+	while (fi->entry.path != NULL) {
+		ff   = fi->stack;
+		next = git_vector_get(&ff->entries, ++ff->index);
 
-		if (next != NULL) {
-			/* match git's behavior of ignoring anything named ".git" */
-			if (path_is_dotgit(next))
-				continue;
-			/* else found a good entry */
+		if (next != NULL)
 			break;
-		}
-
-		/* pop stack if anything is left to pop */
-		if (!wf->next) {
-			memset(&wi->entry, 0, sizeof(wi->entry));
-			return 0;
-		}
 
-		wi->stack = wf->next;
-		wi->depth--;
-		workdir_iterator__free_frame(wf);
-		git_ignore__pop_dir(&wi->ignores);
+		fs_iterator__pop_frame(fi, ff, false);
 	}
 
-	error = workdir_iterator__update_entry(wi);
+	error = fs_iterator__update_entry(fi);
 
 	if (!error && entry != NULL)
-		error = workdir_iterator__current(entry, self);
+		error = fs_iterator__current(entry, self);
 
 	return error;
 }
 
-static int workdir_iterator__seek(git_iterator *self, const char *prefix)
+static int fs_iterator__advance(
+	const git_index_entry **entry, git_iterator *self)
+{
+	fs_iterator *fi = (fs_iterator *)self;
+
+	/* given include_trees & autoexpand, we might have to go into a tree */
+	if (iterator__do_autoexpand(fi) &&
+		fi->entry.path != NULL &&
+		fi->entry.mode == GIT_FILEMODE_TREE)
+	{
+		int error = fs_iterator__advance_into(entry, self);
+		if (error != GIT_ENOTFOUND)
+			return error;
+		/* continue silently past empty directories if autoexpanding */
+		giterr_clear();
+	}
+
+	return fs_iterator__advance_over(entry, self);
+}
+
+static int fs_iterator__seek(git_iterator *self, const char *prefix)
 {
 	GIT_UNUSED(self);
 	GIT_UNUSED(prefix);
@@ -1073,107 +1060,192 @@ static int workdir_iterator__seek(git_iterator *self, const char *prefix)
 	return 0;
 }
 
-static int workdir_iterator__reset(
+static int fs_iterator__reset(
 	git_iterator *self, const char *start, const char *end)
 {
-	workdir_iterator *wi = (workdir_iterator *)self;
+	fs_iterator *fi = (fs_iterator *)self;
 
-	while (wi->stack != NULL && wi->stack->next != NULL) {
-		workdir_iterator_frame *wf = wi->stack;
-		wi->stack = wf->next;
-		workdir_iterator__free_frame(wf);
-		git_ignore__pop_dir(&wi->ignores);
-	}
-	wi->depth = 0;
+	while (fi->stack != NULL && fi->stack->next != NULL)
+		fs_iterator__pop_frame(fi, fi->stack, false);
+	fi->depth = 0;
 
 	if (iterator__reset_range(self, start, end) < 0)
 		return -1;
 
-	workdir_iterator__seek_frame_start(wi, wi->stack);
+	fs_iterator__seek_frame_start(fi, fi->stack);
 
-	return workdir_iterator__update_entry(wi);
+	return fs_iterator__update_entry(fi);
 }
 
-static void workdir_iterator__free(git_iterator *self)
+static void fs_iterator__free(git_iterator *self)
 {
-	workdir_iterator *wi = (workdir_iterator *)self;
+	fs_iterator *fi = (fs_iterator *)self;
 
-	while (wi->stack != NULL) {
-		workdir_iterator_frame *wf = wi->stack;
-		wi->stack = wf->next;
-		workdir_iterator__free_frame(wf);
-	}
+	while (fi->stack != NULL)
+		fs_iterator__pop_frame(fi, fi->stack, true);
 
-	git_ignore__free(&wi->ignores);
-	git_buf_free(&wi->path);
+	git_buf_free(&fi->path);
 }
 
-static int workdir_iterator__update_entry(workdir_iterator *wi)
+static int fs_iterator__update_entry(fs_iterator *fi)
 {
-	int error = 0;
 	git_path_with_stat *ps =
-		git_vector_get(&wi->stack->entries, wi->stack->index);
+		git_vector_get(&fi->stack->entries, fi->stack->index);
 
-	git_buf_truncate(&wi->path, wi->root_len);
-	memset(&wi->entry, 0, sizeof(wi->entry));
+	git_buf_truncate(&fi->path, fi->root_len);
+	memset(&fi->entry, 0, sizeof(fi->entry));
 
 	if (!ps)
 		return 0;
+	if (git_buf_put(&fi->path, ps->path, ps->path_len) < 0)
+		return -1;
+	if (iterator__past_end(fi, fi->path.ptr + fi->root_len))
+		return 0;
 
-	/* skip over .git entries */
-	if (path_is_dotgit(ps))
-		return workdir_iterator__advance(NULL, (git_iterator *)wi);
+	fi->entry.path = ps->path;
+	git_index_entry__init_from_stat(&fi->entry, &ps->st);
+
+	/* need different mode here to keep directories during iteration */
+	fi->entry.mode = git_futils_canonical_mode(ps->st.st_mode);
+
+	/* allow wrapper to check/update the entry (can force skip) */
+	if (fi->update_entry_cb &&
+		fi->update_entry_cb(fi) == GIT_ENOTFOUND)
+		return fs_iterator__advance_over(NULL, (git_iterator *)fi);
+
+	/* if this is a tree and trees aren't included, then skip */
+	if (fi->entry.mode == GIT_FILEMODE_TREE && !iterator__include_trees(fi))
+		return git_iterator_advance(NULL, (git_iterator *)fi);
+
+	return 0;
+}
+
+static int fs_iterator__initialize(
+	git_iterator **out, fs_iterator *fi, const char *root)
+{
+	int error;
 
-	if (git_buf_put(&wi->path, ps->path, ps->path_len) < 0)
+	if (git_buf_sets(&fi->path, root) < 0 || git_path_to_dir(&fi->path) < 0) {
+		git__free(fi);
 		return -1;
+	}
+	fi->root_len = fi->path.size;
 
-	if (iterator__past_end(wi, wi->path.ptr + wi->root_len))
-		return 0;
+	if ((error = fs_iterator__expand_dir(fi)) == GIT_ENOTFOUND) {
+		giterr_clear();
+		error = 0;
+	}
+	if (error) {
+		git_iterator_free((git_iterator *)fi);
+		fi = NULL;
+	}
 
-	wi->entry.path = ps->path;
+	*out = (git_iterator *)fi;
+	return error;
+}
 
-	wi->is_ignored = -1;
+int git_iterator_for_filesystem(
+	git_iterator **out,
+	const char *root,
+	git_iterator_flag_t flags,
+	const char *start,
+	const char *end)
+{
+	fs_iterator *fi = git__calloc(1, sizeof(fs_iterator));
+	GITERR_CHECK_ALLOC(fi);
 
-	git_index_entry__init_from_stat(&wi->entry, &ps->st);
+	ITERATOR_BASE_INIT(fi, fs, FS, NULL);
 
-	/* need different mode here to keep directories during iteration */
-	wi->entry.mode = git_futils_canonical_mode(ps->st.st_mode);
+	if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0)
+		fi->base.flags |= GIT_ITERATOR_IGNORE_CASE;
 
-	/* if this is a file type we don't handle, treat as ignored */
-	if (wi->entry.mode == 0) {
-		wi->is_ignored = 1;
-		return 0;
+	return fs_iterator__initialize(out, fi, root);
+}
+
+
+typedef struct {
+	fs_iterator fi;
+	git_ignores ignores;
+	int is_ignored;
+} workdir_iterator;
+
+GIT_INLINE(bool) workdir_path_is_dotgit(const git_buf *path)
+{
+	size_t len;
+
+	if (!path || (len = path->size) < 4)
+		return false;
+
+	if (path->ptr[len - 1] == '/')
+		len--;
+
+	if (tolower(path->ptr[len - 1]) != 't' ||
+		tolower(path->ptr[len - 2]) != 'i' ||
+		tolower(path->ptr[len - 3]) != 'g' ||
+		tolower(path->ptr[len - 4]) != '.')
+		return false;
+
+	return (len == 4 || path->ptr[len - 5] == '/');
+}
+
+static int workdir_iterator__enter_dir(fs_iterator *fi)
+{
+	/* only push new ignores if this is not top level directory */
+	if (fi->stack->next != NULL) {
+		workdir_iterator *wi = (workdir_iterator *)fi;
+		ssize_t slash_pos = git_buf_rfind_next(&fi->path, '/');
+
+		(void)git_ignore__push_dir(&wi->ignores, &fi->path.ptr[slash_pos + 1]);
 	}
 
-	/* if this isn't a tree, then we're done */
-	if (wi->entry.mode != GIT_FILEMODE_TREE)
-		return 0;
+	return 0;
+}
 
-	/* detect submodules */
-	error = git_submodule_lookup(NULL, wi->base.repo, wi->entry.path);
-	if (error == GIT_ENOTFOUND)
-		giterr_clear();
+static int workdir_iterator__leave_dir(fs_iterator *fi)
+{
+	workdir_iterator *wi = (workdir_iterator *)fi;
+	git_ignore__pop_dir(&wi->ignores);
+	return 0;
+}
 
-	if (error == GIT_EEXISTS) /* if contains .git, treat as untracked submod */
-		error = 0;
+static int workdir_iterator__update_entry(fs_iterator *fi)
+{
+	int error = 0;
+	workdir_iterator *wi = (workdir_iterator *)fi;
+
+	/* skip over .git entries */
+	if (workdir_path_is_dotgit(&fi->path))
+		return GIT_ENOTFOUND;
+
+	/* reset is_ignored since we haven't checked yet */
+	wi->is_ignored = -1;
 
-	/* if submodule, mark as GITLINK and remove trailing slash */
-	if (!error) {
-		size_t len = strlen(wi->entry.path);
-		assert(wi->entry.path[len - 1] == '/');
-		wi->entry.path[len - 1] = '\0';
-		wi->entry.mode = S_IFGITLINK;
+	/* check if apparent tree entries are actually submodules */
+	if (fi->entry.mode != GIT_FILEMODE_TREE)
 		return 0;
+
+	error = git_submodule_lookup(NULL, fi->base.repo, fi->entry.path);
+	if (error < 0)
+		giterr_clear();
+
+	/* mark submodule (or any dir with .git) as GITLINK and remove slash */
+	if (!error || error == GIT_EEXISTS) {
+		fi->entry.mode = S_IFGITLINK;
+		fi->entry.path[strlen(fi->entry.path) - 1] = '\0';
 	}
 
-	if (iterator__include_trees(wi))
-		return 0;
+	return 0;
+}
 
-	return workdir_iterator__advance(NULL, (git_iterator *)wi);
+static void workdir_iterator__free(git_iterator *self)
+{
+	workdir_iterator *wi = (workdir_iterator *)self;
+	fs_iterator__free(self);
+	git_ignore__free(&wi->ignores);
 }
 
 int git_iterator_for_workdir(
-	git_iterator **iter,
+	git_iterator **out,
 	git_repository *repo,
 	git_iterator_flag_t flags,
 	const char *start,
@@ -1182,38 +1254,28 @@ int git_iterator_for_workdir(
 	int error;
 	workdir_iterator *wi;
 
-	assert(iter && repo);
+	if (git_repository__ensure_not_bare(repo, "scan working directory") < 0)
+		return GIT_EBAREREPO;
 
-	if ((error = git_repository__ensure_not_bare(
-			 repo, "scan working directory")) < 0)
-		return error;
+	/* initialize as an fs iterator then do overrides */
+	wi = git__calloc(1, sizeof(workdir_iterator));
+	GITERR_CHECK_ALLOC(wi);
+	ITERATOR_BASE_INIT((&wi->fi), fs, FS, repo);
 
-	ITERATOR_BASE_INIT(wi, workdir, WORKDIR, repo);
-
-	if ((error = iterator__update_ignore_case((git_iterator *)wi, flags)) < 0)
-		goto fail;
+	wi->fi.base.type = GIT_ITERATOR_TYPE_WORKDIR;
+	wi->fi.cb.free = workdir_iterator__free;
+	wi->fi.enter_dir_cb = workdir_iterator__enter_dir;
+	wi->fi.leave_dir_cb = workdir_iterator__leave_dir;
+	wi->fi.update_entry_cb = workdir_iterator__update_entry;
 
-	if (git_buf_sets(&wi->path, git_repository_workdir(repo)) < 0 ||
-		git_path_to_dir(&wi->path) < 0 ||
-		git_ignore__for_path(repo, "", &wi->ignores) < 0)
+	if ((error = iterator__update_ignore_case((git_iterator *)wi, flags)) < 0 ||
+		(error = git_ignore__for_path(repo, "", &wi->ignores)) < 0)
 	{
-		git__free(wi);
-		return -1;
-	}
-	wi->root_len = wi->path.size;
-
-	if ((error = workdir_iterator__expand_dir(wi)) < 0) {
-		if (error != GIT_ENOTFOUND)
-			goto fail;
-		giterr_clear();
+		git_iterator_free((git_iterator *)wi);
+		return error;
 	}
 
-	*iter = (git_iterator *)wi;
-	return 0;
-
-fail:
-	git_iterator_free((git_iterator *)wi);
-	return error;
+	return fs_iterator__initialize(out, &wi->fi, git_repository_workdir(repo));
 }
 
 
@@ -1315,7 +1377,8 @@ bool git_iterator_current_is_ignored(git_iterator *iter)
 	if (wi->is_ignored != -1)
 		return (bool)(wi->is_ignored != 0);
 
-	if (git_ignore__lookup(&wi->ignores, wi->entry.path, &wi->is_ignored) < 0)
+	if (git_ignore__lookup(
+			&wi->ignores, wi->fi.entry.path, &wi->is_ignored) < 0)
 		wi->is_ignored = true;
 
 	return (bool)wi->is_ignored;
@@ -1340,10 +1403,10 @@ int git_iterator_current_workdir_path(git_buf **path, git_iterator *iter)
 {
 	workdir_iterator *wi = (workdir_iterator *)iter;
 
-	if (iter->type != GIT_ITERATOR_TYPE_WORKDIR || !wi->entry.path)
+	if (iter->type != GIT_ITERATOR_TYPE_WORKDIR || !wi->fi.entry.path)
 		*path = NULL;
 	else
-		*path = &wi->path;
+		*path = &wi->fi.path;
 
 	return 0;
 }
diff --git a/src/iterator.h b/src/iterator.h
index 4a4e6a9..7998f7c 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -19,6 +19,7 @@ typedef enum {
 	GIT_ITERATOR_TYPE_TREE = 1,
 	GIT_ITERATOR_TYPE_INDEX = 2,
 	GIT_ITERATOR_TYPE_WORKDIR = 3,
+	GIT_ITERATOR_TYPE_FS = 4,
 } git_iterator_type_t;
 
 typedef enum {
@@ -88,6 +89,16 @@ extern int git_iterator_for_workdir(
 	const char *start,
 	const char *end);
 
+/* for filesystem iterators, you have to explicitly pass in the ignore_case
+ * behavior that you desire
+ */
+extern int git_iterator_for_filesystem(
+	git_iterator **out,
+	const char *root,
+	git_iterator_flag_t flags,
+	const char *start,
+	const char *end);
+
 extern void git_iterator_free(git_iterator *iter);
 
 /* Return a git_index_entry structure for the current value the iterator
diff --git a/src/merge.c b/src/merge.c
index e0010d6..56290bf 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -5,15 +5,54 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+#include "posix.h"
+#include "buffer.h"
 #include "repository.h"
 #include "revwalk.h"
-#include "buffer.h"
+#include "commit_list.h"
 #include "merge.h"
+#include "path.h"
 #include "refs.h"
+#include "object.h"
+#include "iterator.h"
+#include "refs.h"
+#include "diff.h"
+#include "checkout.h"
+#include "tree.h"
+#include "merge_file.h"
+#include "blob.h"
+#include "hashsig.h"
+#include "oid.h"
+
+#include "git2/types.h"
 #include "git2/repository.h"
+#include "git2/object.h"
+#include "git2/commit.h"
 #include "git2/merge.h"
+#include "git2/refs.h"
 #include "git2/reset.h"
-#include "commit_list.h"
+#include "git2/checkout.h"
+#include "git2/signature.h"
+#include "git2/config.h"
+#include "git2/tree.h"
+#include "git2/sys/index.h"
+
+#define GIT_MERGE_INDEX_ENTRY_EXISTS(X)	((X).mode != 0)
+
+typedef enum {
+	TREE_IDX_ANCESTOR = 0,
+	TREE_IDX_OURS = 1,
+	TREE_IDX_THEIRS = 2
+} merge_tree_index_t;
+
+/* Tracks D/F conflicts */
+struct merge_diff_df_data {
+	const char *df_path;
+	const char *prev_path;
+	git_merge_diff *prev_conflict;
+};
+
 
 int git_repository_merge_cleanup(git_repository *repo)
 {
@@ -48,6 +87,8 @@ cleanup:
 	return error;
 }
 
+/* Merge base computation */
+
 int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_array[], size_t length)
 {
 	git_revwalk *walk;
@@ -177,7 +218,7 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
 		return -1;
 
 	if (git_commit_list_parse(walk, one) < 0)
-	    return -1;
+		return -1;
 
 	one->flags |= PARENT1;
 	if (git_pqueue_insert(&list, one) < 0)
@@ -294,3 +335,1296 @@ cleanup:
 
 	return error;
 }
+
+GIT_INLINE(int) index_entry_cmp(const git_index_entry *a, const git_index_entry *b)
+{
+	int value = 0;
+
+	if (a->path == NULL)
+		return (b->path == NULL) ? 0 : 1;
+
+	if ((value = a->mode - b->mode) == 0 &&
+		(value = git_oid__cmp(&a->oid, &b->oid)) == 0)
+		value = strcmp(a->path, b->path);
+
+	return value;
+}
+
+/* Conflict resolution */
+
+static int merge_conflict_resolve_trivial(
+	int *resolved,
+	git_merge_diff_list *diff_list,
+	const git_merge_diff *conflict)
+{
+	int ours_empty, theirs_empty;
+	int ours_changed, theirs_changed, ours_theirs_differ;
+	git_index_entry const *result = NULL;
+	int error = 0;
+
+	assert(resolved && diff_list && conflict);
+
+	*resolved = 0;
+
+	if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE ||
+		conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED)
+		return 0;
+	
+	if (conflict->our_status == GIT_DELTA_RENAMED ||
+		conflict->their_status == GIT_DELTA_RENAMED)
+		return 0;
+
+	ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry);
+	theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry);
+	
+	ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED);
+	theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED);
+	ours_theirs_differ = ours_changed && theirs_changed &&
+		index_entry_cmp(&conflict->our_entry, &conflict->their_entry);
+
+	/*
+	 * Note: with only one ancestor, some cases are not distinct:
+	 *
+	 * 16: ancest:anc1/anc2, head:anc1, remote:anc2 = result:no merge
+	 * 3: ancest:(empty)^, head:head, remote:(empty) = result:no merge
+	 * 2: ancest:(empty)^, head:(empty), remote:remote = result:no merge
+	 *
+	 * Note that the two cases that take D/F conflicts into account
+	 * specifically do not need to be explicitly tested, as D/F conflicts
+	 * would fail the *empty* test:
+	 *
+	 * 3ALT: ancest:(empty)+, head:head, remote:*empty* = result:head
+	 * 2ALT: ancest:(empty)+, head:*empty*, remote:remote = result:remote
+	 *
+	 * Note that many of these cases need not be explicitly tested, as
+	 * they simply degrade to "all different" cases (eg, 11):
+	 *
+	 * 4: ancest:(empty)^, head:head, remote:remote = result:no merge
+	 * 7: ancest:ancest+, head:(empty), remote:remote = result:no merge
+	 * 9: ancest:ancest+, head:head, remote:(empty) = result:no merge
+	 * 11: ancest:ancest+, head:head, remote:remote = result:no merge
+	 */
+
+	/* 5ALT: ancest:*, head:head, remote:head = result:head */
+	if (ours_changed && !ours_empty && !ours_theirs_differ)
+		result = &conflict->our_entry;
+	/* 6: ancest:ancest+, head:(empty), remote:(empty) = result:no merge */
+	else if (ours_changed && ours_empty && theirs_empty)
+		*resolved = 0;
+	/* 8: ancest:ancest^, head:(empty), remote:ancest = result:no merge */
+	else if (ours_empty && !theirs_changed)
+		*resolved = 0;
+	/* 10: ancest:ancest^, head:ancest, remote:(empty) = result:no merge */
+	else if (!ours_changed && theirs_empty)
+		*resolved = 0;
+	/* 13: ancest:ancest+, head:head, remote:ancest = result:head */
+	else if (ours_changed && !theirs_changed)
+		result = &conflict->our_entry;
+	/* 14: ancest:ancest+, head:ancest, remote:remote = result:remote */
+	else if (!ours_changed && theirs_changed)
+		result = &conflict->their_entry;
+	else
+		*resolved = 0;
+
+	if (result != NULL &&
+		GIT_MERGE_INDEX_ENTRY_EXISTS(*result) &&
+		(error = git_vector_insert(&diff_list->staged, (void *)result)) >= 0)
+		*resolved = 1;
+
+	/* Note: trivial resolution does not update the REUC. */
+	
+	return error;
+}
+
+static int merge_conflict_resolve_one_removed(
+	int *resolved,
+	git_merge_diff_list *diff_list,
+	const git_merge_diff *conflict)
+{
+	int ours_empty, theirs_empty;
+	int ours_changed, theirs_changed;
+	int error = 0;
+
+	assert(resolved && diff_list && conflict);
+
+	*resolved = 0;
+
+	if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE ||
+		conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED)
+		return 0;
+
+	ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry);
+	theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry);
+
+	ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED);
+	theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED);
+
+	/* Removed in both */
+	if (ours_changed && ours_empty && theirs_empty)
+		*resolved = 1;
+	/* Removed in ours */
+	else if (ours_empty && !theirs_changed)
+		*resolved = 1;
+	/* Removed in theirs */
+	else if (!ours_changed && theirs_empty)
+		*resolved = 1;
+
+	if (*resolved)
+		git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict);
+
+	return error;
+}
+
+
+static int merge_conflict_resolve_one_renamed(
+	int *resolved,
+	git_merge_diff_list *diff_list,
+	const git_merge_diff *conflict)
+{
+	int ours_renamed, theirs_renamed;
+	int ours_changed, theirs_changed;
+	git_index_entry *merged;
+	int error = 0;
+	
+	assert(resolved && diff_list && conflict);
+	
+	*resolved = 0;
+
+	if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ||
+		!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry))
+		return 0;
+
+	ours_renamed = (conflict->our_status == GIT_DELTA_RENAMED);
+	theirs_renamed = (conflict->their_status == GIT_DELTA_RENAMED);
+	
+	if (!ours_renamed && !theirs_renamed)
+		return 0;
+
+	/* Reject one file in a 2->1 conflict */
+	if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 ||
+		conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 ||
+		conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED)
+		return 0;
+
+	ours_changed = (git_oid__cmp(&conflict->ancestor_entry.oid, &conflict->our_entry.oid) != 0);
+	theirs_changed = (git_oid__cmp(&conflict->ancestor_entry.oid, &conflict->their_entry.oid) != 0);
+	
+	/* if both are modified (and not to a common target) require a merge */
+	if (ours_changed && theirs_changed &&
+		git_oid__cmp(&conflict->our_entry.oid, &conflict->their_entry.oid) != 0)
+		return 0;
+
+	if ((merged = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL)
+		return -1;
+	
+	if (ours_changed)
+		memcpy(merged, &conflict->our_entry, sizeof(git_index_entry));
+	else
+		memcpy(merged, &conflict->their_entry, sizeof(git_index_entry));
+
+	if (ours_renamed)
+		merged->path = conflict->our_entry.path;
+	else
+		merged->path = conflict->their_entry.path;
+	
+	*resolved = 1;
+	
+	git_vector_insert(&diff_list->staged, merged);
+	git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict);
+	
+	return error;
+}
+
+static int merge_conflict_resolve_automerge(
+	int *resolved,
+	git_merge_diff_list *diff_list,
+	const git_merge_diff *conflict,
+	unsigned int automerge_flags)
+{
+	git_merge_file_input ancestor = GIT_MERGE_FILE_INPUT_INIT,
+		ours = GIT_MERGE_FILE_INPUT_INIT,
+		theirs = GIT_MERGE_FILE_INPUT_INIT;
+	git_merge_file_result result = GIT_MERGE_FILE_RESULT_INIT;
+	git_index_entry *index_entry;
+	git_odb *odb = NULL;
+	git_oid automerge_oid;
+	int error = 0;
+	
+	assert(resolved && diff_list && conflict);
+	
+	*resolved = 0;
+	
+	if (automerge_flags == GIT_MERGE_AUTOMERGE_NONE)
+		return 0;
+
+	/* Reject D/F conflicts */
+	if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE)
+		return 0;
+
+	/* Reject link/file conflicts. */
+	if ((S_ISLNK(conflict->ancestor_entry.mode) ^ S_ISLNK(conflict->our_entry.mode)) ||
+		(S_ISLNK(conflict->ancestor_entry.mode) ^ S_ISLNK(conflict->their_entry.mode)))
+		return 0;
+
+	/* Reject name conflicts */
+	if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 ||
+		conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED)
+		return 0;
+
+	if ((conflict->our_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED &&
+		(conflict->their_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED &&
+		strcmp(conflict->ancestor_entry.path, conflict->their_entry.path) != 0)
+		return 0;
+
+	if ((error = git_repository_odb(&odb, diff_list->repo)) < 0 ||
+		(error = git_merge_file_input_from_index_entry(&ancestor, diff_list->repo, &conflict->ancestor_entry)) < 0 ||
+		(error = git_merge_file_input_from_index_entry(&ours, diff_list->repo, &conflict->our_entry)) < 0 ||
+		(error = git_merge_file_input_from_index_entry(&theirs, diff_list->repo, &conflict->their_entry)) < 0 ||
+		(error = git_merge_files(&result, &ancestor, &ours, &theirs, automerge_flags)) < 0 ||
+		!result.automergeable ||
+		(error = git_odb_write(&automerge_oid, odb, result.data, result.len, GIT_OBJ_BLOB)) < 0)
+		goto done;
+	
+	if ((index_entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL)
+	GITERR_CHECK_ALLOC(index_entry);
+
+	index_entry->path = git_pool_strdup(&diff_list->pool, result.path);
+	GITERR_CHECK_ALLOC(index_entry->path);
+
+	index_entry->file_size = result.len;
+	index_entry->mode = result.mode;
+	git_oid_cpy(&index_entry->oid, &automerge_oid);
+	
+	git_vector_insert(&diff_list->staged, index_entry);
+	git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict);
+
+	*resolved = 1;
+
+done:
+	git_merge_file_input_free(&ancestor);
+	git_merge_file_input_free(&ours);
+	git_merge_file_input_free(&theirs);
+	git_merge_file_result_free(&result);
+	git_odb_free(odb);
+	
+	return error;
+}
+
+static int merge_conflict_resolve(
+	int *out,
+	git_merge_diff_list *diff_list,
+	const git_merge_diff *conflict,
+	unsigned int automerge_flags)
+{
+	int resolved = 0;
+	int error = 0;
+	
+	*out = 0;
+	
+	if ((error = merge_conflict_resolve_trivial(&resolved, diff_list, conflict)) < 0)
+		goto done;
+
+	if (automerge_flags != GIT_MERGE_AUTOMERGE_NONE) {
+		if (!resolved && (error = merge_conflict_resolve_one_removed(&resolved, diff_list, conflict)) < 0)
+			goto done;
+		
+		if (!resolved && (error = merge_conflict_resolve_one_renamed(&resolved, diff_list, conflict)) < 0)
+			goto done;
+
+		if (!resolved && (error = merge_conflict_resolve_automerge(&resolved, diff_list, conflict, automerge_flags)) < 0)
+			goto done;
+	}
+
+	*out = resolved;
+	
+done:
+	return error;
+}
+
+/* Rename detection and coalescing */
+
+struct merge_diff_similarity {
+	unsigned char similarity;
+	size_t other_idx;
+};
+
+static int index_entry_similarity_exact(
+	git_repository *repo,
+	git_index_entry *a,
+	size_t a_idx,
+	git_index_entry *b,
+	size_t b_idx,
+	void **cache,
+	const git_merge_tree_opts *opts)
+{
+	GIT_UNUSED(repo);
+	GIT_UNUSED(a_idx);
+	GIT_UNUSED(b_idx);
+	GIT_UNUSED(cache);
+	GIT_UNUSED(opts);
+
+	if (git_oid__cmp(&a->oid, &b->oid) == 0)
+		return 100;
+	
+	return 0;
+}
+
+static int index_entry_similarity_calc(
+	void **out,
+	git_repository *repo,
+	git_index_entry *entry,
+	const git_merge_tree_opts *opts)
+{
+	git_blob *blob;
+	git_diff_file diff_file = {{{0}}};
+	git_off_t blobsize;
+	int error;
+	
+	*out = NULL;
+
+	if ((error = git_blob_lookup(&blob, repo, &entry->oid)) < 0)
+		return error;
+	
+	git_oid_cpy(&diff_file.oid, &entry->oid);
+	diff_file.path = entry->path;
+	diff_file.size = entry->file_size;
+	diff_file.mode = entry->mode;
+	diff_file.flags = 0;
+	
+	blobsize = git_blob_rawsize(blob);
+
+	/* file too big for rename processing */
+	if (!git__is_sizet(blobsize))
+		return 0;
+	
+	error = opts->metric->buffer_signature(out, &diff_file,
+		git_blob_rawcontent(blob), (size_t)blobsize,
+		opts->metric->payload);
+	
+	git_blob_free(blob);
+
+	return error;
+}
+
+static int index_entry_similarity_inexact(
+	git_repository *repo,
+	git_index_entry *a,
+	size_t a_idx,
+	git_index_entry *b,
+	size_t b_idx,
+	void **cache,
+	const git_merge_tree_opts *opts)
+{
+	int score = 0;
+	int error = 0;
+	
+	if (GIT_MODE_TYPE(a->mode) != GIT_MODE_TYPE(b->mode))
+		return 0;
+	
+	/* update signature cache if needed */
+	if (!cache[a_idx] && (error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0)
+		return error;
+	if (!cache[b_idx] && (error = index_entry_similarity_calc(&cache[b_idx], repo, b, opts)) < 0)
+		return error;
+	
+	/* some metrics may not wish to process this file (too big / too small) */
+	if (!cache[a_idx] || !cache[b_idx])
+		return 0;
+
+	/* compare signatures */
+	if (opts->metric->similarity(
+		&score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0)
+		return -1;
+	
+	/* clip score */
+	if (score < 0)
+		score = 0;
+	else if (score > 100)
+		score = 100;
+	
+	return score;
+}
+
+static int merge_diff_mark_similarity(
+	git_repository *repo,
+	git_merge_diff_list *diff_list,
+	struct merge_diff_similarity *similarity_ours,
+	struct merge_diff_similarity *similarity_theirs,
+	int (*similarity_fn)(git_repository *, git_index_entry *, size_t, git_index_entry *, size_t, void **, const git_merge_tree_opts *),
+	void **cache,
+	const git_merge_tree_opts *opts)
+{
+	size_t i, j;
+	git_merge_diff *conflict_src, *conflict_tgt;
+	int similarity;
+	
+	git_vector_foreach(&diff_list->conflicts, i, conflict_src) {
+		/* Items can be the source of a rename iff they have an item in the
+		 * ancestor slot and lack an item in the ours or theirs slot. */
+		if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry) ||
+			(GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry) &&
+			 GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)))
+			continue;
+		
+		git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) {
+			size_t our_idx = diff_list->conflicts.length + j;
+			size_t their_idx = (diff_list->conflicts.length * 2) + j;
+			
+			if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry))
+				continue;
+			
+			if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) &&
+				!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) {
+				similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->our_entry, our_idx, cache, opts);
+				
+				if (similarity == GIT_EBUFS)
+					continue;				
+				else if (similarity < 0)
+					return similarity;
+				
+				if (similarity > similarity_ours[i].similarity &&
+					similarity > similarity_ours[j].similarity) {
+					/* Clear previous best similarity */
+					if (similarity_ours[i].similarity > 0)
+						similarity_ours[similarity_ours[i].other_idx].similarity = 0;
+					
+					if (similarity_ours[j].similarity > 0)
+						similarity_ours[similarity_ours[j].other_idx].similarity = 0;
+					
+					similarity_ours[i].similarity = similarity;
+					similarity_ours[i].other_idx = j;
+					
+					similarity_ours[j].similarity = similarity;
+					similarity_ours[j].other_idx = i;
+				}
+			}
+			
+			if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) &&
+				!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) {
+				similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->their_entry, their_idx, cache, opts);
+				
+				if (similarity > similarity_theirs[i].similarity &&
+					similarity > similarity_theirs[j].similarity) {
+					/* Clear previous best similarity */
+					if (similarity_theirs[i].similarity > 0)
+						similarity_theirs[similarity_theirs[i].other_idx].similarity = 0;
+					
+					if (similarity_theirs[j].similarity > 0)
+						similarity_theirs[similarity_theirs[j].other_idx].similarity = 0;
+					
+					similarity_theirs[i].similarity = similarity;
+					similarity_theirs[i].other_idx = j;
+					
+					similarity_theirs[j].similarity = similarity;
+					similarity_theirs[j].other_idx = i;
+				}
+			}
+		}
+	}
+	
+	return 0;
+}
+
+/*
+ * Rename conflicts:
+ *
+ *      Ancestor   Ours   Theirs
+ *
+ * 0a   A          A      A        No rename
+ *  b   A          A*     A        No rename (ours was rewritten)
+ *  c   A          A      A*       No rename (theirs rewritten)
+ * 1a   A          A      B[A]     Rename or rename/edit
+ *  b   A          B[A]   A        (automergeable)
+ * 2    A          B[A]   B[A]     Both renamed (automergeable)
+ * 3a   A          B[A]            Rename/delete
+ *  b   A                 B[A]      (same)
+ * 4a   A          B[A]   B        Rename/add [B~ours B~theirs]
+ *  b   A          B      B[A]      (same)
+ * 5    A          B[A]   C[A]     Both renamed ("1 -> 2")
+ * 6    A          C[A]            Both renamed ("2 -> 1")
+ *      B                 C[B]     [C~ours C~theirs]    (automergeable)
+ */
+static void merge_diff_mark_rename_conflict(
+	git_merge_diff_list *diff_list,
+	struct merge_diff_similarity *similarity_ours,
+	bool ours_renamed,
+	size_t ours_source_idx,
+	struct merge_diff_similarity *similarity_theirs,
+	bool theirs_renamed,
+	size_t theirs_source_idx,
+	git_merge_diff *target,
+	const git_merge_tree_opts *opts)
+{
+	git_merge_diff *ours_source = NULL, *theirs_source = NULL;
+	
+	if (ours_renamed)
+		ours_source = diff_list->conflicts.contents[ours_source_idx];
+	
+	if (theirs_renamed)
+		theirs_source = diff_list->conflicts.contents[theirs_source_idx];
+	
+	/* Detect 2->1 conflicts */
+	if (ours_renamed && theirs_renamed) {
+		/* Both renamed to the same target name. */
+		if (ours_source_idx == theirs_source_idx)
+			ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED;
+		else {
+			ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1;
+			theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1;
+		}
+	} else if (ours_renamed) {
+		/* If our source was also renamed in theirs, this is a 1->2 */
+		if (similarity_theirs[ours_source_idx].similarity >= opts->rename_threshold)
+			ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2;
+		
+		else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry)) {
+			ours_source->type = GIT_MERGE_DIFF_RENAMED_ADDED;
+			target->type = GIT_MERGE_DIFF_RENAMED_ADDED;
+		}
+		
+		else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(ours_source->their_entry))
+			ours_source->type = GIT_MERGE_DIFF_RENAMED_DELETED;
+		
+		else if (ours_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED)
+			ours_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED;
+	} else if (theirs_renamed) {
+		/* If their source was also renamed in ours, this is a 1->2 */
+		if (similarity_ours[theirs_source_idx].similarity >= opts->rename_threshold)
+			theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2;
+		
+		else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry)) {
+			theirs_source->type = GIT_MERGE_DIFF_RENAMED_ADDED;
+			target->type = GIT_MERGE_DIFF_RENAMED_ADDED;
+		}
+		
+		else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(theirs_source->our_entry))
+			theirs_source->type = GIT_MERGE_DIFF_RENAMED_DELETED;
+		
+		else if (theirs_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED)
+			theirs_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED;
+	}
+}
+
+GIT_INLINE(void) merge_diff_coalesce_rename(
+	git_index_entry *source_entry,
+	git_delta_t *source_status,
+	git_index_entry *target_entry,
+	git_delta_t *target_status)
+{
+	/* Coalesce the rename target into the rename source. */
+	memcpy(source_entry, target_entry, sizeof(git_index_entry));
+	*source_status = GIT_DELTA_RENAMED;
+	
+	memset(target_entry, 0x0, sizeof(git_index_entry));
+	*target_status = GIT_DELTA_UNMODIFIED;
+}
+
+static void merge_diff_list_coalesce_renames(
+	git_merge_diff_list *diff_list,
+	struct merge_diff_similarity *similarity_ours,
+	struct merge_diff_similarity *similarity_theirs,
+	const git_merge_tree_opts *opts)
+{
+	size_t i;
+	bool ours_renamed = 0, theirs_renamed = 0;
+	size_t ours_source_idx = 0, theirs_source_idx = 0;
+	git_merge_diff *ours_source, *theirs_source, *target;
+	
+	for (i = 0; i < diff_list->conflicts.length; i++) {
+		target = diff_list->conflicts.contents[i];
+		
+		ours_renamed = 0;
+		theirs_renamed = 0;
+		
+		if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry) &&
+			similarity_ours[i].similarity >= opts->rename_threshold) {
+			ours_source_idx = similarity_ours[i].other_idx;
+			
+			ours_source = diff_list->conflicts.contents[ours_source_idx];
+			
+			merge_diff_coalesce_rename(
+				&ours_source->our_entry,
+				&ours_source->our_status,
+				&target->our_entry,
+				&target->our_status);
+			
+			similarity_ours[ours_source_idx].similarity = 0;
+			similarity_ours[i].similarity = 0;
+			
+			ours_renamed = 1;
+		}
+		
+		/* insufficient to determine direction */
+		if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry) &&
+			similarity_theirs[i].similarity >= opts->rename_threshold) {
+			theirs_source_idx = similarity_theirs[i].other_idx;
+			
+			theirs_source = diff_list->conflicts.contents[theirs_source_idx];
+			
+			merge_diff_coalesce_rename(
+				&theirs_source->their_entry,
+				&theirs_source->their_status,
+				&target->their_entry,
+				&target->their_status);
+			
+			similarity_theirs[theirs_source_idx].similarity = 0;
+			similarity_theirs[i].similarity = 0;
+			
+			theirs_renamed = 1;
+		}
+		
+		merge_diff_mark_rename_conflict(diff_list,
+			similarity_ours, ours_renamed, ours_source_idx,
+			similarity_theirs, theirs_renamed, theirs_source_idx,
+			target, opts);
+	}
+}
+
+static int merge_diff_empty(const git_vector *conflicts, size_t idx)
+{
+	git_merge_diff *conflict = conflicts->contents[idx];
+	
+	return (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) &&
+		!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) &&
+		!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry));
+}
+
+static void merge_diff_list_count_candidates(
+	git_merge_diff_list *diff_list,
+	size_t *src_count,
+	size_t *tgt_count)
+{
+	git_merge_diff *entry;
+	size_t i;
+
+	*src_count = 0;
+	*tgt_count = 0;
+	
+	git_vector_foreach(&diff_list->conflicts, i, entry) {
+		if (GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry) &&
+			(!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->our_entry) ||
+			!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->their_entry)))
+			src_count++;
+		else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry))
+			tgt_count++;
+	}
+}
+
+int git_merge_diff_list__find_renames(
+	git_repository *repo,
+	git_merge_diff_list *diff_list,
+	const git_merge_tree_opts *opts)
+{
+	struct merge_diff_similarity *similarity_ours, *similarity_theirs;
+	void **cache = NULL;
+	size_t cache_size = 0;
+	size_t src_count, tgt_count, i;
+	int error = 0;
+	
+	assert(diff_list && opts);
+	
+	if ((opts->flags & GIT_MERGE_TREE_FIND_RENAMES) == 0)
+		return 0;
+	
+	similarity_ours = git__calloc(diff_list->conflicts.length,
+		sizeof(struct merge_diff_similarity));
+	GITERR_CHECK_ALLOC(similarity_ours);
+	
+	similarity_theirs = git__calloc(diff_list->conflicts.length,
+		sizeof(struct merge_diff_similarity));
+	GITERR_CHECK_ALLOC(similarity_theirs);
+	
+	/* Calculate similarity between items that were deleted from the ancestor
+	 * and added in the other branch.
+	 */
+	if ((error = merge_diff_mark_similarity(repo, diff_list, similarity_ours,
+		similarity_theirs, index_entry_similarity_exact, NULL, opts)) < 0)
+		goto done;
+
+	if (diff_list->conflicts.length <= opts->target_limit) {
+		cache_size = diff_list->conflicts.length * 3;
+		cache = git__calloc(cache_size, sizeof(void *));
+		GITERR_CHECK_ALLOC(cache);
+
+		merge_diff_list_count_candidates(diff_list, &src_count, &tgt_count);
+		
+		if (src_count > opts->target_limit || tgt_count > opts->target_limit) {
+			/* TODO: report! */
+		} else {
+			if ((error = merge_diff_mark_similarity(
+				repo, diff_list, similarity_ours, similarity_theirs,
+				index_entry_similarity_inexact, cache, opts)) < 0)
+				goto done;
+		}
+	}
+
+	/* For entries that are appropriately similar, merge the new name's entry
+	 * into the old name.
+	 */
+	merge_diff_list_coalesce_renames(diff_list, similarity_ours, similarity_theirs, opts);
+	
+	/* And remove any entries that were merged and are now empty. */
+	git_vector_remove_matching(&diff_list->conflicts, merge_diff_empty);
+
+done:
+	if (cache != NULL) {
+		for (i = 0; i < cache_size; ++i) {
+			if (cache[i] != NULL)
+				opts->metric->free_signature(cache[i], opts->metric->payload);
+		}
+
+		git__free(cache);
+	}
+
+	git__free(similarity_ours);
+	git__free(similarity_theirs);
+
+	return error;
+}
+
+/* Directory/file conflict handling */
+
+GIT_INLINE(const char *) merge_diff_path(
+	const git_merge_diff *conflict)
+{
+	if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry))
+		return conflict->ancestor_entry.path;
+	else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry))
+		return conflict->our_entry.path;
+	else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry))
+		return conflict->their_entry.path;
+	
+	return NULL;
+}
+
+GIT_INLINE(bool) merge_diff_any_side_added_or_modified(
+	const git_merge_diff *conflict)
+{
+	if (conflict->our_status == GIT_DELTA_ADDED ||
+		conflict->our_status == GIT_DELTA_MODIFIED ||
+		conflict->their_status == GIT_DELTA_ADDED ||
+		conflict->their_status == GIT_DELTA_MODIFIED)
+		return true;
+	
+	return false;
+}
+
+GIT_INLINE(bool) path_is_prefixed(const char *parent, const char *child)
+{
+	size_t child_len = strlen(child);
+	size_t parent_len = strlen(parent);
+	
+	if (child_len < parent_len ||
+		strncmp(parent, child, parent_len) != 0)
+		return 0;
+	
+	return (child[parent_len] == '/');
+}
+
+GIT_INLINE(int) merge_diff_detect_df_conflict(
+	struct merge_diff_df_data *df_data,
+	git_merge_diff *conflict)
+{
+	const char *cur_path = merge_diff_path(conflict);
+	
+	/* Determine if this is a D/F conflict or the child of one */
+	if (df_data->df_path &&
+		path_is_prefixed(df_data->df_path, cur_path))
+		conflict->type = GIT_MERGE_DIFF_DF_CHILD;
+	else if(df_data->df_path)
+		df_data->df_path = NULL;
+	else if (df_data->prev_path &&
+		merge_diff_any_side_added_or_modified(df_data->prev_conflict) &&
+		merge_diff_any_side_added_or_modified(conflict) &&
+		path_is_prefixed(df_data->prev_path, cur_path)) {
+		conflict->type = GIT_MERGE_DIFF_DF_CHILD;
+		
+		df_data->prev_conflict->type = GIT_MERGE_DIFF_DIRECTORY_FILE;
+		df_data->df_path = df_data->prev_path;
+	}
+	
+	df_data->prev_path = cur_path;
+	df_data->prev_conflict = conflict;
+	
+	return 0;
+}
+
+/* Conflict handling */
+
+GIT_INLINE(int) merge_diff_detect_type(
+	git_merge_diff *conflict)
+{
+	if (conflict->our_status == GIT_DELTA_ADDED &&
+		conflict->their_status == GIT_DELTA_ADDED)
+		conflict->type = GIT_MERGE_DIFF_BOTH_ADDED;
+	else if (conflict->our_status == GIT_DELTA_MODIFIED &&
+			 conflict->their_status == GIT_DELTA_MODIFIED)
+		conflict->type = GIT_MERGE_DIFF_BOTH_MODIFIED;
+	else if (conflict->our_status == GIT_DELTA_DELETED &&
+			 conflict->their_status == GIT_DELTA_DELETED)
+		conflict->type = GIT_MERGE_DIFF_BOTH_DELETED;
+	else if (conflict->our_status == GIT_DELTA_MODIFIED &&
+			 conflict->their_status == GIT_DELTA_DELETED)
+		conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED;
+	else if (conflict->our_status == GIT_DELTA_DELETED &&
+			 conflict->their_status == GIT_DELTA_MODIFIED)
+		conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED;
+	else
+		conflict->type = GIT_MERGE_DIFF_NONE;
+	
+	return 0;
+}
+
+GIT_INLINE(int) index_entry_dup(
+	git_index_entry *out,
+	git_pool *pool,
+	const git_index_entry *src)
+{
+	if (src != NULL) {
+		memcpy(out, src, sizeof(git_index_entry));
+		
+		if ((out->path = git_pool_strdup(pool, src->path)) == NULL)
+			return -1;
+	}
+	
+	return 0;
+}
+
+GIT_INLINE(int) merge_delta_type_from_index_entries(
+	const git_index_entry *ancestor,
+	const git_index_entry *other)
+{
+	if (ancestor == NULL && other == NULL)
+		return GIT_DELTA_UNMODIFIED;
+	else if (ancestor == NULL && other != NULL)
+		return GIT_DELTA_ADDED;
+	else if (ancestor != NULL && other == NULL)
+		return GIT_DELTA_DELETED;
+	else if (S_ISDIR(ancestor->mode) ^ S_ISDIR(other->mode))
+		return GIT_DELTA_TYPECHANGE;
+	else if(S_ISLNK(ancestor->mode) ^ S_ISLNK(other->mode))
+		return GIT_DELTA_TYPECHANGE;
+	else if (git_oid__cmp(&ancestor->oid, &other->oid) ||
+			 ancestor->mode != other->mode)
+		return GIT_DELTA_MODIFIED;
+	
+	return GIT_DELTA_UNMODIFIED;
+}
+
+static git_merge_diff *merge_diff_from_index_entries(
+	git_merge_diff_list *diff_list,
+	const git_index_entry **entries)
+{
+	git_merge_diff *conflict;
+	git_pool *pool = &diff_list->pool;
+	
+	if ((conflict = git_pool_malloc(pool, sizeof(git_merge_diff))) == NULL)
+		return NULL;
+	
+	if (index_entry_dup(&conflict->ancestor_entry, pool, entries[TREE_IDX_ANCESTOR]) < 0 ||
+		index_entry_dup(&conflict->our_entry, pool, entries[TREE_IDX_OURS]) < 0 ||
+		index_entry_dup(&conflict->their_entry, pool, entries[TREE_IDX_THEIRS]) < 0)
+		return NULL;
+	
+	conflict->our_status = merge_delta_type_from_index_entries(
+		entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_OURS]);
+	conflict->their_status = merge_delta_type_from_index_entries(
+		entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_THEIRS]);
+	
+	return conflict;
+}
+
+/* Merge trees */
+
+static int merge_index_insert_conflict(
+	git_merge_diff_list *diff_list,
+	struct merge_diff_df_data *merge_df_data,
+	const git_index_entry *tree_items[3])
+{
+	git_merge_diff *conflict;
+	
+	if ((conflict = merge_diff_from_index_entries(diff_list, tree_items)) == NULL ||
+		merge_diff_detect_type(conflict) < 0 ||
+		merge_diff_detect_df_conflict(merge_df_data, conflict) < 0 ||
+		git_vector_insert(&diff_list->conflicts, conflict) < 0)
+		return -1;
+	
+	return 0;
+}
+
+static int merge_index_insert_unmodified(
+	git_merge_diff_list *diff_list,
+	const git_index_entry *tree_items[3])
+{
+	int error = 0;
+	git_index_entry *entry;
+	
+	entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry));
+	GITERR_CHECK_ALLOC(entry);
+	
+	if ((error = index_entry_dup(entry, &diff_list->pool, tree_items[0])) >= 0)
+		error = git_vector_insert(&diff_list->staged, entry);
+	
+	return error;
+}
+
+int git_merge_diff_list__find_differences(
+	git_merge_diff_list *diff_list,
+	const git_tree *ancestor_tree,
+	const git_tree *our_tree,
+	const git_tree *their_tree)
+{
+	git_iterator *iterators[3] = {0};
+	const git_index_entry *items[3] = {0}, *best_cur_item, *cur_items[3];
+	git_vector_cmp entry_compare = git_index_entry__cmp;
+	struct merge_diff_df_data df_data = {0};
+	int cur_item_modified;
+	size_t i, j;
+	int error = 0;
+	
+	assert(diff_list && our_tree && their_tree);
+
+	if ((error = git_iterator_for_tree(&iterators[TREE_IDX_ANCESTOR], (git_tree *)ancestor_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
+		(error = git_iterator_for_tree(&iterators[TREE_IDX_OURS], (git_tree *)our_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0 ||
+		(error = git_iterator_for_tree(&iterators[TREE_IDX_THEIRS], (git_tree *)their_tree, GIT_ITERATOR_DONT_IGNORE_CASE, NULL, NULL)) < 0)
+		goto done;
+	
+	/* Set up the iterators */
+	for (i = 0; i < 3; i++) {
+		if ((error = git_iterator_current(&items[i], iterators[i])) < 0)
+			goto done;
+	}
+	
+	while (true) {
+		for (i = 0; i < 3; i++)
+			cur_items[i] = NULL;
+
+		best_cur_item = NULL;
+		cur_item_modified = 0;
+		
+		/* Find the next path(s) to consume from each iterator */
+		for (i = 0; i < 3; i++) {
+			if (items[i] == NULL) {
+				cur_item_modified = 1;
+				continue;
+			}
+			
+			if (best_cur_item == NULL) {
+				best_cur_item = items[i];
+				cur_items[i] = items[i];
+			} else {
+				int path_diff = entry_compare(items[i], best_cur_item);
+				
+				if (path_diff < 0) {
+					/*
+					 * Found an item that sorts before our current item, make
+					 * our current item this one.
+					 */
+					for (j = 0; j < i; j++)
+						cur_items[j] = NULL;
+
+					cur_item_modified = 1;
+					best_cur_item = items[i];
+					cur_items[i] = items[i];
+				} else if (path_diff > 0) {
+					/* No entry for the current item, this is modified */
+					cur_item_modified = 1;
+				} else if (path_diff == 0) {
+					cur_items[i] = items[i];
+					
+					if (!cur_item_modified)
+						cur_item_modified = index_entry_cmp(best_cur_item, items[i]);
+				}
+			}
+		}
+		
+		if (best_cur_item == NULL)
+			break;
+		
+		if (cur_item_modified)
+			error = merge_index_insert_conflict(diff_list, &df_data, cur_items);
+		else
+			error = merge_index_insert_unmodified(diff_list, cur_items);
+		
+		/* Advance each iterator that participated */
+		for (i = 0; i < 3; i++) {
+			if (cur_items[i] != NULL &&
+				(error = git_iterator_advance(&items[i], iterators[i])) < 0)
+				goto done;
+		}
+	}
+	
+done:
+	for (i = 0; i < 3; i++)
+		git_iterator_free(iterators[i]);
+	
+	return error;
+}
+
+git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo)
+{
+	git_merge_diff_list *diff_list = git__calloc(1, sizeof(git_merge_diff_list));
+	
+	if (diff_list == NULL)
+		return NULL;
+	
+	diff_list->repo = repo;
+	
+	if (git_vector_init(&diff_list->staged, 0, NULL) < 0 ||
+		git_vector_init(&diff_list->conflicts, 0, NULL) < 0 ||
+		git_vector_init(&diff_list->resolved, 0, NULL) < 0 ||
+		git_pool_init(&diff_list->pool, 1, 0) < 0)
+		return NULL;
+	
+	return diff_list;
+}
+
+static int merge_tree_normalize_opts(
+	git_repository *repo,
+	git_merge_tree_opts *opts,
+	const git_merge_tree_opts *given)
+{
+	git_config *cfg = NULL;
+	int error = 0;
+	
+	assert(repo && opts);
+	
+	if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
+		return error;
+	
+	if (given != NULL)
+		memcpy(opts, given, sizeof(git_merge_tree_opts));
+	else {
+		git_merge_tree_opts init = GIT_MERGE_TREE_OPTS_INIT;
+		memcpy(opts, &init, sizeof(init));
+		
+		opts->flags = GIT_MERGE_TREE_FIND_RENAMES;
+		opts->rename_threshold = GIT_MERGE_TREE_RENAME_THRESHOLD;
+	}
+	
+	if (!opts->target_limit) {
+		int32_t limit = 0;
+		
+		opts->target_limit = GIT_MERGE_TREE_TARGET_LIMIT;
+		
+		if (git_config_get_int32(&limit, cfg, "merge.renameLimit") < 0) {
+			giterr_clear();
+			
+			if (git_config_get_int32(&limit, cfg, "diff.renameLimit") < 0)
+				giterr_clear();
+		}
+		
+		if (limit > 0)
+			opts->target_limit = limit;
+	}
+	
+	/* assign the internal metric with whitespace flag as payload */
+	if (!opts->metric) {
+		opts->metric = git__malloc(sizeof(git_diff_similarity_metric));
+		GITERR_CHECK_ALLOC(opts->metric);
+		
+		opts->metric->file_signature = git_diff_find_similar__hashsig_for_file;
+		opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf;
+		opts->metric->free_signature = git_diff_find_similar__hashsig_free;
+		opts->metric->similarity = git_diff_find_similar__calc_similarity;
+		
+		if (opts->flags & GIT_DIFF_FIND_IGNORE_WHITESPACE)
+			opts->metric->payload = (void *)GIT_HASHSIG_IGNORE_WHITESPACE;
+		else if (opts->flags & GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE)
+			opts->metric->payload = (void *)GIT_HASHSIG_NORMAL;
+		else
+			opts->metric->payload = (void *)GIT_HASHSIG_SMART_WHITESPACE;
+	}
+	
+	return 0;
+}
+
+
+static int merge_index_insert_reuc(
+	git_index *index,
+	size_t idx,
+	const git_index_entry *entry)
+{
+	const git_index_reuc_entry *reuc;
+	int mode[3] = { 0, 0, 0 };
+	git_oid const *oid[3] = { NULL, NULL, NULL };
+	size_t i;
+	
+	if (!GIT_MERGE_INDEX_ENTRY_EXISTS(*entry))
+		return 0;
+	
+	if ((reuc = git_index_reuc_get_bypath(index, entry->path)) != NULL) {
+		for (i = 0; i < 3; i++) {
+			mode[i] = reuc->mode[i];
+			oid[i] = &reuc->oid[i];
+		}
+	}
+	
+	mode[idx] = entry->mode;
+	oid[idx] = &entry->oid;
+	
+	return git_index_reuc_add(index, entry->path,
+		mode[0], oid[0], mode[1], oid[1], mode[2], oid[2]);
+}
+
+int index_from_diff_list(git_index **out, git_merge_diff_list *diff_list)
+{
+	git_index *index;
+	size_t i;
+	git_index_entry *entry;
+	git_merge_diff *conflict;
+	int error = 0;
+	
+	*out = NULL;
+	
+	if ((error = git_index_new(&index)) < 0)
+		return error;
+	
+	git_vector_foreach(&diff_list->staged, i, entry) {
+		if ((error = git_index_add(index, entry)) < 0)
+			goto on_error;
+	}
+	
+	git_vector_foreach(&diff_list->conflicts, i, conflict) {
+		const git_index_entry *ancestor =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ?
+			&conflict->ancestor_entry : NULL;
+		
+		const git_index_entry *ours =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ?
+			&conflict->our_entry : NULL;
+		
+		const git_index_entry *theirs =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ?
+			&conflict->their_entry : NULL;
+		
+		if ((error = git_index_conflict_add(index, ancestor, ours, theirs)) < 0)
+			goto on_error;
+	}
+	
+	/* Add each rename entry to the rename portion of the index. */
+	git_vector_foreach(&diff_list->conflicts, i, conflict) {
+		const char *ancestor_path, *our_path, *their_path;
+		
+		if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry))
+			continue;
+		
+		ancestor_path = conflict->ancestor_entry.path;
+		
+		our_path =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ?
+			conflict->our_entry.path : NULL;
+		
+		their_path =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ?
+			conflict->their_entry.path : NULL;
+		
+		if ((our_path && strcmp(ancestor_path, our_path) != 0) ||
+			(their_path && strcmp(ancestor_path, their_path) != 0)) {
+			if ((error = git_index_name_add(index, ancestor_path, our_path, their_path)) < 0)
+				goto on_error;
+		}
+	}
+	
+	/* Add each entry in the resolved conflict to the REUC independently, since
+	 * the paths may differ due to renames. */
+	git_vector_foreach(&diff_list->resolved, i, conflict) {
+		const git_index_entry *ancestor =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ?
+			&conflict->ancestor_entry : NULL;
+
+		const git_index_entry *ours =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ?
+			&conflict->our_entry : NULL;
+		
+		const git_index_entry *theirs =
+			GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ?
+			&conflict->their_entry : NULL;
+
+		if (ancestor != NULL &&
+			(error = merge_index_insert_reuc(index, TREE_IDX_ANCESTOR, ancestor)) < 0)
+			goto on_error;
+		
+		if (ours != NULL &&
+			(error = merge_index_insert_reuc(index, TREE_IDX_OURS, ours)) < 0)
+			goto on_error;
+		
+		if (theirs != NULL &&
+			(error = merge_index_insert_reuc(index, TREE_IDX_THEIRS, theirs)) < 0)
+			goto on_error;
+	}
+	
+	*out = index;
+	return 0;
+	
+on_error:
+	git_index_free(index);
+	
+	return error;
+}
+
+int git_merge_trees(
+	git_index **out,
+	git_repository *repo,
+	const git_tree *ancestor_tree,
+	const git_tree *our_tree,
+	const git_tree *their_tree,
+	const git_merge_tree_opts *given_opts)
+{
+	git_merge_diff_list *diff_list;
+	git_merge_tree_opts opts;
+	git_merge_diff *conflict;
+	git_vector changes;
+	size_t i;
+	int error = 0;
+
+	assert(out && repo && our_tree && their_tree);
+
+	*out = NULL;
+	
+	if ((error = merge_tree_normalize_opts(repo, &opts, given_opts)) < 0)
+		return error;
+
+	diff_list = git_merge_diff_list__alloc(repo);
+	GITERR_CHECK_ALLOC(diff_list);
+	
+	if ((error = git_merge_diff_list__find_differences(diff_list, ancestor_tree, our_tree, their_tree)) < 0 ||
+		(error = git_merge_diff_list__find_renames(repo, diff_list, &opts)) < 0)
+		goto done;
+	
+	memcpy(&changes, &diff_list->conflicts, sizeof(git_vector));
+	git_vector_clear(&diff_list->conflicts);
+	
+	git_vector_foreach(&changes, i, conflict) {
+		int resolved = 0;
+		
+		if ((error = merge_conflict_resolve(&resolved, diff_list, conflict, opts.automerge_flags)) < 0)
+			goto done;
+		
+		if (!resolved)
+			git_vector_insert(&diff_list->conflicts, conflict);
+	}
+	
+	if (!given_opts || !given_opts->metric)
+		git__free(opts.metric);
+	
+	error = index_from_diff_list(out, diff_list);
+
+done:
+	git_merge_diff_list__free(diff_list);
+
+	return error;
+}
+
+void git_merge_diff_list__free(git_merge_diff_list *diff_list)
+{
+	if (!diff_list)
+		return;
+	
+	git_vector_free(&diff_list->staged);
+	git_vector_free(&diff_list->conflicts);
+	git_vector_free(&diff_list->resolved);
+	git_pool_clear(&diff_list->pool);
+	git__free(diff_list);
+}
+
diff --git a/src/merge.h b/src/merge.h
index 22c6442..6307d15 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -7,16 +7,121 @@
 #ifndef INCLUDE_merge_h__
 #define INCLUDE_merge_h__
 
-#include "git2/types.h"
-#include "git2/merge.h"
-#include "commit_list.h"
 #include "vector.h"
+#include "commit_list.h"
+#include "pool.h"
+
+#include "git2/merge.h"
+#include "git2/types.h"
 
 #define GIT_MERGE_MSG_FILE		"MERGE_MSG"
 #define GIT_MERGE_MODE_FILE		"MERGE_MODE"
 
-#define MERGE_CONFIG_FILE_MODE	0666
+#define GIT_MERGE_TREE_RENAME_THRESHOLD	50
+#define GIT_MERGE_TREE_TARGET_LIMIT		1000
+
+/** Types of changes when files are merged from branch to branch. */
+typedef enum {
+	/* No conflict - a change only occurs in one branch. */
+	GIT_MERGE_DIFF_NONE = 0,
+	
+	/* Occurs when a file is modified in both branches. */
+	GIT_MERGE_DIFF_BOTH_MODIFIED = (1 << 0),
+	
+	/* Occurs when a file is added in both branches. */
+	GIT_MERGE_DIFF_BOTH_ADDED = (1 << 1),
+	
+	/* Occurs when a file is deleted in both branches. */
+	GIT_MERGE_DIFF_BOTH_DELETED = (1 << 2),
+	
+	/* Occurs when a file is modified in one branch and deleted in the other. */
+	GIT_MERGE_DIFF_MODIFIED_DELETED = (1 << 3),
+	
+	/* Occurs when a file is renamed in one branch and modified in the other. */
+	GIT_MERGE_DIFF_RENAMED_MODIFIED = (1 << 4),
+	
+	/* Occurs when a file is renamed in one branch and deleted in the other. */
+	GIT_MERGE_DIFF_RENAMED_DELETED = (1 << 5),
+	
+	/* Occurs when a file is renamed in one branch and a file with the same
+	 * name is added in the other.  Eg, A->B and new file B.  Core git calls
+	 * this a "rename/delete". */
+	GIT_MERGE_DIFF_RENAMED_ADDED = (1 << 6),
+	
+	/* Occurs when both a file is renamed to the same name in the ours and
+	 * theirs branches.  Eg, A->B and A->B in both.  Automergeable. */
+	GIT_MERGE_DIFF_BOTH_RENAMED = (1 << 7),
+	
+	/* Occurs when a file is renamed to different names in the ours and theirs
+	 * branches.  Eg, A->B and A->C. */
+	GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 = (1 << 8),
+	
+	/* Occurs when two files are renamed to the same name in the ours and
+	 * theirs branches.  Eg, A->C and B->C. */
+	GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 = (1 << 9),
+	
+	/* Occurs when an item at a path in one branch is a directory, and an
+	 * item at the same path in a different branch is a file. */
+	GIT_MERGE_DIFF_DIRECTORY_FILE = (1 << 10),
+	
+	/* The child of a folder that is in a directory/file conflict. */
+	GIT_MERGE_DIFF_DF_CHILD = (1 << 11),
+} git_merge_diff_type_t;
+
+
+typedef struct {
+    git_repository *repo;
+    git_pool pool;
+	
+    /* Vector of git_index_entry that represent the merged items that
+	 * have been staged, either because only one side changed, or because
+	 * the two changes were non-conflicting and mergeable.  These items
+	 * will be written as staged entries in the main index.
+	 */
+    git_vector staged;
+	
+    /* Vector of git_merge_diff entries that represent the conflicts that
+	 * have not been automerged.  These items will be written to high-stage
+	 * entries in the main index.
+	 */
+    git_vector conflicts;
+	
+    /* Vector of git_merge_diff that have been automerged.  These items
+	 * will be written to the REUC when the index is produced.
+	 */
+    git_vector resolved;
+} git_merge_diff_list;
+
+/**
+ * Description of changes to one file across three trees.
+ */
+typedef struct {
+    git_merge_diff_type_t type;
+	
+    git_index_entry ancestor_entry;
+	
+    git_index_entry our_entry;
+    git_delta_t our_status;
+	
+    git_index_entry their_entry;
+    git_delta_t their_status;
+} git_merge_diff;
+
+int git_merge__bases_many(
+	git_commit_list **out,
+	git_revwalk *walk,
+	git_commit_list_node *one,
+	git_vector *twos);
+
+git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo);
+
+int git_merge_diff_list__find_differences(git_merge_diff_list *merge_diff_list,
+	const git_tree *ancestor_tree,
+	const git_tree *ours_tree,
+	const git_tree *theirs_tree);
+
+int git_merge_diff_list__find_renames(git_repository *repo, git_merge_diff_list *merge_diff_list, const git_merge_tree_opts *opts);
 
-int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos);
+void git_merge_diff_list__free(git_merge_diff_list *diff_list);
 
 #endif
diff --git a/src/merge_file.c b/src/merge_file.c
new file mode 100644
index 0000000..4b3f373
--- /dev/null
+++ b/src/merge_file.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "common.h"
+#include "repository.h"
+#include "merge_file.h"
+
+#include "git2/repository.h"
+#include "git2/object.h"
+#include "git2/index.h"
+
+#include "xdiff/xdiff.h"
+
+#define GIT_MERGE_FILE_SIDE_EXISTS(X)	((X)->mode != 0)
+
+GIT_INLINE(const char *) merge_file_best_path(
+	const git_merge_file_input *ancestor,
+	const git_merge_file_input *ours,
+	const git_merge_file_input *theirs)
+{
+	if (!GIT_MERGE_FILE_SIDE_EXISTS(ancestor)) {
+		if (strcmp(ours->path, theirs->path) == 0)
+			return ours->path;
+
+		return NULL;
+	}
+	
+	if (strcmp(ancestor->path, ours->path) == 0)
+		return theirs->path;
+	else if(strcmp(ancestor->path, theirs->path) == 0)
+		return ours->path;
+	
+	return NULL;
+}
+
+GIT_INLINE(int) merge_file_best_mode(
+	const git_merge_file_input *ancestor,
+	const git_merge_file_input *ours,
+	const git_merge_file_input *theirs)
+{
+	/*
+	 * If ancestor didn't exist and either ours or theirs is executable,
+	 * assume executable.  Otherwise, if any mode changed from the ancestor,
+	 * use that one.
+	 */
+	if (GIT_MERGE_FILE_SIDE_EXISTS(ancestor)) {
+		if (ours->mode == GIT_FILEMODE_BLOB_EXECUTABLE ||
+			theirs->mode == GIT_FILEMODE_BLOB_EXECUTABLE)
+			return GIT_FILEMODE_BLOB_EXECUTABLE;
+		
+		return GIT_FILEMODE_BLOB;
+	}
+	
+	if (ancestor->mode == ours->mode)
+		return theirs->mode;
+	else if(ancestor->mode == theirs->mode)
+		return ours->mode;
+	
+	return 0;
+}
+
+int git_merge_file_input_from_index_entry(
+	git_merge_file_input *input,
+	git_repository *repo,
+	const git_index_entry *entry)
+{
+	git_odb *odb = NULL;
+	int error = 0;
+	
+	assert(input && repo && entry);
+	
+	if (entry->mode == 0)
+		return 0;
+	
+	if ((error = git_repository_odb(&odb, repo)) < 0 ||
+		(error = git_odb_read(&input->odb_object, odb, &entry->oid)) < 0)
+		goto done;
+	
+	input->mode = entry->mode;
+	input->path = git__strdup(entry->path);
+	input->mmfile.size = git_odb_object_size(input->odb_object);
+	input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object);
+	
+	if (input->label == NULL)
+		input->label = entry->path;
+	
+done:
+	git_odb_free(odb);
+	
+	return error;
+}
+
+int git_merge_file_input_from_diff_file(
+	git_merge_file_input *input,
+	git_repository *repo,
+	const git_diff_file *file)
+{
+	git_odb *odb = NULL;
+	int error = 0;
+	
+	assert(input && repo && file);
+	
+	if (file->mode == 0)
+		return 0;
+	
+	if ((error = git_repository_odb(&odb, repo)) < 0 ||
+		(error = git_odb_read(&input->odb_object, odb, &file->oid)) < 0)
+		goto done;
+	
+	input->mode = file->mode;
+	input->path = git__strdup(file->path);
+	input->mmfile.size = git_odb_object_size(input->odb_object);
+	input->mmfile.ptr = (char *)git_odb_object_data(input->odb_object);
+	
+	if (input->label == NULL)
+		input->label = file->path;
+	
+done:
+	git_odb_free(odb);
+	
+	return error;
+}
+
+int git_merge_files(
+	git_merge_file_result *out,
+	git_merge_file_input *ancestor,
+	git_merge_file_input *ours,
+	git_merge_file_input *theirs,
+	git_merge_automerge_flags flags)
+{
+	xmparam_t xmparam;
+	mmbuffer_t mmbuffer;
+	int xdl_result;
+	int error = 0;
+
+	assert(out && ancestor && ours && theirs);
+	
+	memset(out, 0x0, sizeof(git_merge_file_result));
+
+	if (!GIT_MERGE_FILE_SIDE_EXISTS(ours) || !GIT_MERGE_FILE_SIDE_EXISTS(theirs))
+		return 0;
+	
+	memset(&xmparam, 0x0, sizeof(xmparam_t));
+	xmparam.ancestor = ancestor->label;
+	xmparam.file1 = ours->label;
+	xmparam.file2 = theirs->label;
+
+	out->path = merge_file_best_path(ancestor, ours, theirs);
+	out->mode = merge_file_best_mode(ancestor, ours, theirs);
+
+	if (flags == GIT_MERGE_AUTOMERGE_FAVOR_OURS)
+		xmparam.favor = XDL_MERGE_FAVOR_OURS;
+		
+	if (flags == GIT_MERGE_AUTOMERGE_FAVOR_THEIRS)
+		xmparam.favor = XDL_MERGE_FAVOR_THEIRS;
+
+	if ((xdl_result = xdl_merge(&ancestor->mmfile, &ours->mmfile,
+		&theirs->mmfile, &xmparam, &mmbuffer)) < 0) {
+		giterr_set(GITERR_MERGE, "Failed to merge files.");
+		error = -1;
+		goto done;
+	}
+	
+	out->automergeable = (xdl_result == 0);
+	out->data = (unsigned char *)mmbuffer.ptr;
+	out->len = mmbuffer.size;
+
+done:
+	return error;
+}
+
diff --git a/src/merge_file.h b/src/merge_file.h
new file mode 100644
index 0000000..1aa3489
--- /dev/null
+++ b/src/merge_file.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_filediff_h__
+#define INCLUDE_filediff_h__
+
+#include "xdiff/xdiff.h"
+
+#include "git2/merge.h"
+
+typedef struct {
+	const char *label;
+	char *path;
+	unsigned int mode;
+	mmfile_t mmfile;
+	
+	git_odb_object *odb_object;
+} git_merge_file_input;
+
+#define GIT_MERGE_FILE_INPUT_INIT	{0}
+
+typedef struct {
+	bool automergeable;
+	
+	const char *path;
+	int mode;
+	
+	unsigned char *data;
+	size_t len;
+} git_merge_file_result;
+
+#define GIT_MERGE_FILE_RESULT_INIT	{0}
+
+int git_merge_file_input_from_index_entry(
+	git_merge_file_input *input,
+	git_repository *repo,
+	const git_index_entry *entry);
+
+int git_merge_file_input_from_diff_file(
+	git_merge_file_input *input,
+	git_repository *repo,
+	const git_diff_file *file);
+
+int git_merge_files(
+	git_merge_file_result *out,
+	git_merge_file_input *ancestor,
+	git_merge_file_input *ours,
+	git_merge_file_input *theirs,
+	git_merge_automerge_flags flags);
+
+GIT_INLINE(void) git_merge_file_input_free(git_merge_file_input *input)
+{
+	assert(input);
+	git__free(input->path);
+	git_odb_object_free(input->odb_object);
+}
+
+GIT_INLINE(void) git_merge_file_result_free(git_merge_file_result *filediff)
+{
+	if (filediff == NULL)
+		return;
+
+	/* xdiff uses malloc() not git_malloc, so we use free(), not git_free() */
+	if (filediff->data != NULL)
+		free(filediff->data);
+}
+
+#endif
diff --git a/src/mwindow.c b/src/mwindow.c
index b35503d..7e5fcdf 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -162,7 +162,7 @@ static git_mwindow *new_window(
 	git_mwindow *w;
 
 	w = git__malloc(sizeof(*w));
-	
+
 	if (w == NULL)
 		return NULL;
 
diff --git a/src/object.c b/src/object.c
index 80fe511..b87a074 100644
--- a/src/object.c
+++ b/src/object.c
@@ -18,65 +18,38 @@
 
 static const int OBJECT_BASE_SIZE = 4096;
 
-static struct {
+typedef struct {
 	const char	*str;	/* type name string */
-	int			loose; /* valid loose object type flag */
 	size_t		size;	/* size in bytes of the object structure */
-} git_objects_table[] = {
+
+	int  (*parse)(void *self, git_odb_object *obj);
+	void (*free)(void *self);
+} git_object_def;
+
+static git_object_def git_objects_table[] = {
 	/* 0 = GIT_OBJ__EXT1 */
-	{ "", 0, 0},
+	{ "", 0, NULL, NULL },
 
 	/* 1 = GIT_OBJ_COMMIT */
-	{ "commit", 1, sizeof(struct git_commit)},
+	{ "commit", sizeof(git_commit), git_commit__parse, git_commit__free },
 
 	/* 2 = GIT_OBJ_TREE */
-	{ "tree", 1, sizeof(struct git_tree) },
+	{ "tree", sizeof(git_tree), git_tree__parse, git_tree__free },
 
 	/* 3 = GIT_OBJ_BLOB */
-	{ "blob", 1, sizeof(struct git_blob) },
+	{ "blob", sizeof(git_blob), git_blob__parse, git_blob__free },
 
 	/* 4 = GIT_OBJ_TAG */
-	{ "tag", 1, sizeof(struct git_tag) },
+	{ "tag", sizeof(git_tag), git_tag__parse, git_tag__free },
 
 	/* 5 = GIT_OBJ__EXT2 */
-	{ "", 0, 0 },
-
+	{ "", 0, NULL, NULL },
 	/* 6 = GIT_OBJ_OFS_DELTA */
-	{ "OFS_DELTA", 0, 0 },
-
+	{ "OFS_DELTA", 0, NULL, NULL },
 	/* 7 = GIT_OBJ_REF_DELTA */
-	{ "REF_DELTA", 0, 0	}
+	{ "REF_DELTA", 0, NULL, NULL },
 };
 
-static int create_object(git_object **object_out, git_otype type)
-{
-	git_object *object = NULL;
-
-	assert(object_out);
-
-	*object_out = NULL;
-
-	switch (type) {
-	case GIT_OBJ_COMMIT:
-	case GIT_OBJ_TAG:
-	case GIT_OBJ_BLOB:
-	case GIT_OBJ_TREE:
-		object = git__malloc(git_object__size(type));
-		GITERR_CHECK_ALLOC(object);
-		memset(object, 0x0, git_object__size(type));
-		break;
-
-	default:
-		giterr_set(GITERR_INVALID, "The given type is invalid");
-		return -1;
-	}
-
-	object->type = type;
-
-	*object_out = object;
-	return 0;
-}
-
 int git_object__from_odb_object(
 	git_object **object_out,
 	git_repository *repo,
@@ -84,49 +57,55 @@ int git_object__from_odb_object(
 	git_otype type)
 {
 	int error;
+	size_t object_size;
+	git_object_def *def;
 	git_object *object = NULL;
 
-	if (type != GIT_OBJ_ANY && type != odb_obj->raw.type) {
-		giterr_set(GITERR_INVALID, "The requested type does not match the type in the ODB");
+	assert(object_out);
+	*object_out = NULL;
+
+	/* Validate type match */
+	if (type != GIT_OBJ_ANY && type != odb_obj->cached.type) {
+		giterr_set(GITERR_INVALID,
+			"The requested type does not match the type in the ODB");
 		return GIT_ENOTFOUND;
 	}
 
-	type = odb_obj->raw.type;
+	if ((object_size = git_object__size(odb_obj->cached.type)) == 0) {
+		giterr_set(GITERR_INVALID, "The requested type is invalid");
+		return GIT_ENOTFOUND;
+	}
 
-	if ((error = create_object(&object, type)) < 0)
-		return error;
+	/* Allocate and initialize base object */
+	object = git__calloc(1, object_size);
+	GITERR_CHECK_ALLOC(object);
 
-	/* Initialize parent object */
 	git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid);
+	object->cached.type = odb_obj->cached.type;
+	object->cached.size = odb_obj->cached.size;
 	object->repo = repo;
 
-	switch (type) {
-	case GIT_OBJ_COMMIT:
-		error = git_commit__parse((git_commit *)object, odb_obj);
-		break;
+	/* Parse raw object data */
+	def = &git_objects_table[odb_obj->cached.type];
+	assert(def->free && def->parse);
 
-	case GIT_OBJ_TREE:
-		error = git_tree__parse((git_tree *)object, odb_obj);
-		break;
-
-	case GIT_OBJ_TAG:
-		error = git_tag__parse((git_tag *)object, odb_obj);
-		break;
+	if ((error = def->parse(object, odb_obj)) < 0)
+		def->free(object);
+	else
+		*object_out = git_cache_store_parsed(&repo->objects, object);
 
-	case GIT_OBJ_BLOB:
-		error = git_blob__parse((git_blob *)object, odb_obj);
-		break;
+	return error;
+}
 
-	default:
-		break;
-	}
+void git_object__free(void *obj)
+{
+	git_otype type = ((git_object *)obj)->cached.type;
 
-	if (error < 0)
-		git_object__free(object);
+	if (type < 0 || ((size_t)type) >= ARRAY_SIZE(git_objects_table) ||
+		!git_objects_table[type].free)
+		git__free(obj);
 	else
-		*object_out = git_cache_try_store(&repo->objects, object);
-
-	return error;
+		git_objects_table[type].free(obj);
 }
 
 int git_object_lookup_prefix(
@@ -154,27 +133,38 @@ int git_object_lookup_prefix(
 		len = GIT_OID_HEXSZ;
 
 	if (len == GIT_OID_HEXSZ) {
+		git_cached_obj *cached = NULL;
+
 		/* We want to match the full id : we can first look up in the cache,
 		 * since there is no need to check for non ambiguousity
 		 */
-		object = git_cache_get(&repo->objects, id);
-		if (object != NULL) {
-			if (type != GIT_OBJ_ANY && type != object->type) {
-				git_object_free(object);
-				giterr_set(GITERR_INVALID, "The requested type does not match the type in ODB");
-				return GIT_ENOTFOUND;
+		cached = git_cache_get_any(&repo->objects, id);
+		if (cached != NULL) {
+			if (cached->flags == GIT_CACHE_STORE_PARSED) {
+				object = (git_object *)cached;
+
+				if (type != GIT_OBJ_ANY && type != object->cached.type) {
+					git_object_free(object);
+					giterr_set(GITERR_INVALID,
+						"The requested type does not match the type in ODB");
+					return GIT_ENOTFOUND;
+				}
+
+				*object_out = object;
+				return 0;
+			} else if (cached->flags == GIT_CACHE_STORE_RAW) {
+				odb_obj = (git_odb_object *)cached;
+			} else {
+				assert(!"Wrong caching type in the global object cache");
 			}
-
-			*object_out = object;
-			return 0;
+		} else {
+			/* Object was not found in the cache, let's explore the backends.
+			 * We could just use git_odb_read_unique_short_oid,
+			 * it is the same cost for packed and loose object backends,
+			 * but it may be much more costly for sqlite and hiredis.
+			 */
+			error = git_odb_read(&odb_obj, odb, id);
 		}
-
-		/* Object was not found in the cache, let's explore the backends.
-		 * We could just use git_odb_read_unique_short_oid,
-		 * it is the same cost for packed and loose object backends,
-		 * but it may be much more costly for sqlite and hiredis.
-		 */
-		error = git_odb_read(&odb_obj, odb, id);
 	} else {
 		git_oid short_oid;
 
@@ -211,41 +201,12 @@ int git_object_lookup(git_object **object_out, git_repository *repo, const git_o
 	return git_object_lookup_prefix(object_out, repo, id, GIT_OID_HEXSZ, type);
 }
 
-void git_object__free(void *_obj)
-{
-	git_object *object = (git_object *)_obj;
-
-	assert(object);
-
-	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;
-
-	case GIT_OBJ_BLOB:
-		git_blob__free((git_blob *)object);
-		break;
-
-	default:
-		git__free(object);
-		break;
-	}
-}
-
 void git_object_free(git_object *object)
 {
 	if (object == NULL)
 		return;
 
-	git_cached_obj_decref((git_cached_obj *)object, git_object__free);
+	git_cached_obj_decref(object);
 }
 
 const git_oid *git_object_id(const git_object *obj)
@@ -257,7 +218,7 @@ const git_oid *git_object_id(const git_object *obj)
 git_otype git_object_type(const git_object *obj)
 {
 	assert(obj);
-	return obj->type;
+	return obj->cached.type;
 }
 
 git_repository *git_object_owner(const git_object *obj)
@@ -293,7 +254,7 @@ int git_object_typeisloose(git_otype type)
 	if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table))
 		return 0;
 
-	return git_objects_table[type].loose;
+	return (git_objects_table[type].size > 0) ? 1 : 0;
 }
 
 size_t git_object__size(git_otype type)
diff --git a/src/object.h b/src/object.h
index c1e5059..d187c55 100644
--- a/src/object.h
+++ b/src/object.h
@@ -11,7 +11,6 @@
 struct git_object {
 	git_cached_obj cached;
 	git_repository *repo;
-	git_otype type;
 };
 
 /* fully free the object; internal method, DO NOT EXPORT */
diff --git a/src/object_api.c b/src/object_api.c
new file mode 100644
index 0000000..838bba3
--- /dev/null
+++ b/src/object_api.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#include "git2/object.h"
+
+#include "common.h"
+#include "repository.h"
+
+#include "commit.h"
+#include "tree.h"
+#include "blob.h"
+#include "tag.h"
+
+/**
+ * Blob
+ */
+int git_commit_lookup(git_commit **out, git_repository *repo, const git_oid *id)
+{
+	return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT);
+}
+
+int git_commit_lookup_prefix(git_commit **out, git_repository *repo, const git_oid *id, size_t len)
+{
+	return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT);
+}
+
+void git_commit_free(git_commit *obj)
+{
+	git_object_free((git_object *)obj);
+}
+
+const git_oid *git_commit_id(const git_commit *obj)
+{
+	return git_object_id((const git_object *)obj);
+}
+
+git_repository *git_commit_owner(const git_commit *obj)
+{
+	return git_object_owner((const git_object *)obj);
+}
+
+
+/**
+ * Tree
+ */
+int git_tree_lookup(git_tree **out, git_repository *repo, const git_oid *id)
+{
+	return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TREE);
+}
+
+int git_tree_lookup_prefix(git_tree **out, git_repository *repo, const git_oid *id, size_t len)
+{
+	return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_TREE);
+}
+
+void git_tree_free(git_tree *obj)
+{
+	git_object_free((git_object *)obj);
+}
+
+const git_oid *git_tree_id(const git_tree *obj)
+{
+	return git_object_id((const git_object *)obj);
+}
+
+git_repository *git_tree_owner(const git_tree *obj)
+{
+	return git_object_owner((const git_object *)obj);
+}
+
+
+/**
+ * Tag
+ */
+int git_tag_lookup(git_tag **out, git_repository *repo, const git_oid *id)
+{
+	return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TAG);
+}
+
+int git_tag_lookup_prefix(git_tag **out, git_repository *repo, const git_oid *id, size_t len)
+{
+	return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_TAG);
+}
+
+void git_tag_free(git_tag *obj)
+{
+	git_object_free((git_object *)obj);
+}
+
+const git_oid *git_tag_id(const git_tag *obj)
+{
+	return git_object_id((const git_object *)obj);
+}
+
+git_repository *git_tag_owner(const git_tag *obj)
+{
+	return git_object_owner((const git_object *)obj);
+}
+
+/**
+ * Blob
+ */
+int git_blob_lookup(git_blob **out, git_repository *repo, const git_oid *id)
+{
+	return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_BLOB);
+}
+
+int git_blob_lookup_prefix(git_blob **out, git_repository *repo, const git_oid *id, size_t len)
+{
+	return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_BLOB);
+}
+
+void git_blob_free(git_blob *obj)
+{
+	git_object_free((git_object *)obj);
+}
+
+const git_oid *git_blob_id(const git_blob *obj)
+{
+	return git_object_id((const git_object *)obj);
+}
+
+git_repository *git_blob_owner(const git_blob *obj)
+{
+	return git_object_owner((const git_object *)obj);
+}
diff --git a/src/odb.c b/src/odb.c
index c98df24..07e1ea6 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -8,11 +8,13 @@
 #include "common.h"
 #include <zlib.h>
 #include "git2/object.h"
+#include "git2/sys/odb_backend.h"
 #include "fileops.h"
 #include "hash.h"
 #include "odb.h"
 #include "delta-apply.h"
 #include "filter.h"
+#include "repository.h"
 
 #include "git2/odb_backend.h"
 #include "git2/oid.h"
@@ -29,10 +31,19 @@ typedef struct
 {
 	git_odb_backend *backend;
 	int priority;
-	int is_alternate;
+	bool is_alternate;
+	ino_t disk_inode;
 } backend_internal;
 
-size_t git_odb__cache_size = GIT_DEFAULT_CACHE_SIZE;
+static git_cache *odb_cache(git_odb *odb)
+{
+	if (odb->rc.owner != NULL) {
+		git_repository *owner = odb->rc.owner;
+		return &owner->objects;
+	}
+
+	return &odb->own_cache;
+}
 
 static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth);
 
@@ -54,6 +65,7 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj)
 
 	if (!git_object_typeisloose(obj->type))
 		return -1;
+
 	if (!obj->data && obj->len != 0)
 		return -1;
 
@@ -70,23 +82,24 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj)
 }
 
 
-static git_odb_object *new_odb_object(const git_oid *oid, git_rawobj *source)
+static git_odb_object *odb_object__alloc(const git_oid *oid, git_rawobj *source)
 {
-	git_odb_object *object = git__malloc(sizeof(git_odb_object));
-	memset(object, 0x0, sizeof(git_odb_object));
+	git_odb_object *object = git__calloc(1, sizeof(git_odb_object));
 
-	git_oid_cpy(&object->cached.oid, oid);
-	memcpy(&object->raw, source, sizeof(git_rawobj));
+	if (object != NULL) {
+		git_oid_cpy(&object->cached.oid, oid);
+		object->cached.type = source->type;
+		object->cached.size = source->len;
+		object->buffer      = source->data;
+	}
 
 	return object;
 }
 
-static void free_odb_object(void *o)
+void git_odb_object__free(void *object)
 {
-	git_odb_object *object = (git_odb_object *)o;
-
 	if (object != NULL) {
-		git__free(object->raw.data);
+		git__free(((git_odb_object *)object)->buffer);
 		git__free(object);
 	}
 }
@@ -98,17 +111,17 @@ const git_oid *git_odb_object_id(git_odb_object *object)
 
 const void *git_odb_object_data(git_odb_object *object)
 {
-	return object->raw.data;
+	return object->buffer;
 }
 
 size_t git_odb_object_size(git_odb_object *object)
 {
-	return object->raw.len;
+	return object->cached.size;
 }
 
 git_otype git_odb_object_type(git_odb_object *object)
 {
-	return object->raw.type;
+	return object->cached.type;
 }
 
 void git_odb_object_free(git_odb_object *object)
@@ -116,7 +129,7 @@ void git_odb_object_free(git_odb_object *object)
 	if (object == NULL)
 		return;
 
-	git_cached_obj_decref((git_cached_obj *)object, &free_odb_object);
+	git_cached_obj_decref(object);
 }
 
 int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type)
@@ -353,9 +366,8 @@ int git_odb_new(git_odb **out)
 	git_odb *db = git__calloc(1, sizeof(*db));
 	GITERR_CHECK_ALLOC(db);
 
-	if (git_cache_init(&db->cache, git_odb__cache_size, &free_odb_object) < 0 ||
-		git_vector_init(&db->backends, 4, backend_sort_cmp) < 0)
-	{
+	if (git_cache_init(&db->own_cache) < 0 ||
+		git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) {
 		git__free(db);
 		return -1;
 	}
@@ -365,7 +377,9 @@ int git_odb_new(git_odb **out)
 	return 0;
 }
 
-static int add_backend_internal(git_odb *odb, git_odb_backend *backend, int priority, int is_alternate)
+static int add_backend_internal(
+	git_odb *odb, git_odb_backend *backend,
+	int priority, bool is_alternate, ino_t disk_inode)
 {
 	backend_internal *internal;
 
@@ -382,6 +396,7 @@ static int add_backend_internal(git_odb *odb, git_odb_backend *backend, int prio
 	internal->backend = backend;
 	internal->priority = priority;
 	internal->is_alternate = is_alternate;
+	internal->disk_inode = disk_inode;
 
 	if (git_vector_insert(&odb->backends, internal) < 0) {
 		git__free(internal);
@@ -395,26 +410,74 @@ static int add_backend_internal(git_odb *odb, git_odb_backend *backend, int prio
 
 int git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority)
 {
-	return add_backend_internal(odb, backend, priority, 0);
+	return add_backend_internal(odb, backend, priority, false, 0);
 }
 
 int git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority)
 {
-	return add_backend_internal(odb, backend, priority, 1);
+	return add_backend_internal(odb, backend, priority, true, 0);
 }
 
-static int add_default_backends(git_odb *db, const char *objects_dir, int as_alternates, int alternate_depth)
+size_t git_odb_num_backends(git_odb *odb)
 {
+	assert(odb);
+	return odb->backends.length;
+}
+
+int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos)
+{
+	backend_internal *internal;
+
+	assert(odb && odb);
+	internal = git_vector_get(&odb->backends, pos);
+
+	if (internal && internal->backend) {
+		*out = internal->backend;
+		return 0;
+	}
+
+	return GIT_ENOTFOUND;
+}
+
+static int add_default_backends(
+	git_odb *db, const char *objects_dir,
+	bool as_alternates, int alternate_depth)
+{
+	size_t i;
+	struct stat st;
+	ino_t inode;
 	git_odb_backend *loose, *packed;
 
+	/* TODO: inodes are not really relevant on Win32, so we need to find
+	 * a cross-platform workaround for this */
+#ifdef GIT_WIN32
+	GIT_UNUSED(i);
+	GIT_UNUSED(st);
+
+	inode = 0;
+#else
+	if (p_stat(objects_dir, &st) < 0) {
+		giterr_set(GITERR_ODB, "Failed to load object database in '%s'", objects_dir);
+		return -1;
+	}
+
+	inode = st.st_ino;
+
+	for (i = 0; i < db->backends.length; ++i) {
+		backend_internal *backend = git_vector_get(&db->backends, i);
+		if (backend->disk_inode == inode)
+			return 0;
+	}
+#endif
+	
 	/* add the loose object backend */
 	if (git_odb_backend_loose(&loose, objects_dir, -1, 0) < 0 ||
-		add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates) < 0)
+		add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0)
 		return -1;
 
 	/* add the packed file backend */
 	if (git_odb_backend_pack(&packed, objects_dir) < 0 ||
-		add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates) < 0)
+		add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates, inode) < 0)
 		return -1;
 
 	return load_alternates(db, objects_dir, alternate_depth);
@@ -464,7 +527,7 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
 			alternate = git_buf_cstr(&alternates_path);
 		}
 
-		if ((result = add_default_backends(odb, alternate, 1, alternate_depth + 1)) < 0)
+		if ((result = add_default_backends(odb, alternate, true, alternate_depth + 1)) < 0)
 			break;
 	}
 
@@ -476,7 +539,7 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
 
 int git_odb_add_disk_alternate(git_odb *odb, const char *path)
 {
-	return add_default_backends(odb, path, 1, 0);
+	return add_default_backends(odb, path, true, 0);
 }
 
 int git_odb_open(git_odb **out, const char *objects_dir)
@@ -514,7 +577,7 @@ static void odb_free(git_odb *db)
 	}
 
 	git_vector_free(&db->backends);
-	git_cache_free(&db->cache);
+	git_cache_free(&db->own_cache);
 	git__free(db);
 }
 
@@ -535,7 +598,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
 
 	assert(db && id);
 
-	if ((object = git_cache_get(&db->cache, id)) != NULL) {
+	if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) {
 		git_odb_object_free(object);
 		return (int)true;
 	}
@@ -585,9 +648,9 @@ int git_odb__read_header_or_object(
 
 	assert(db && id && out && len_p && type_p);
 
-	if ((object = git_cache_get(&db->cache, id)) != NULL) {
-		*len_p = object->raw.len;
-		*type_p = object->raw.type;
+	if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) {
+		*len_p = object->cached.size;
+		*type_p = object->cached.type;
 		*out = object;
 		return 0;
 	}
@@ -612,8 +675,8 @@ int git_odb__read_header_or_object(
 	if ((error = git_odb_read(&object, db, id)) < 0)
 		return error; /* error already set - pass along */
 
-	*len_p = object->raw.len;
-	*type_p = object->raw.type;
+	*len_p = object->cached.size;
+	*type_p = object->cached.type;
 	*out = object;
 
 	return 0;
@@ -625,6 +688,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
 	int error;
 	bool refreshed = false;
 	git_rawobj raw;
+	git_odb_object *object;
 
 	assert(out && db && id);
 
@@ -633,7 +697,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
 		return GIT_ENOTFOUND;
 	}
 
-	*out = git_cache_get(&db->cache, id);
+	*out = git_cache_get_raw(odb_cache(db), id);
 	if (*out != NULL)
 		return 0;
 
@@ -659,7 +723,10 @@ attempt_lookup:
 	if (error && error != GIT_PASSTHROUGH)
 		return error;
 
-	*out = git_cache_try_store(&db->cache, new_odb_object(id, &raw));
+	if ((object = odb_object__alloc(id, &raw)) == NULL)
+		return -1;
+
+	*out = git_cache_store_raw(odb_cache(db), object);
 	return 0;
 }
 
@@ -672,6 +739,7 @@ int git_odb_read_prefix(
 	git_rawobj raw;
 	void *data = NULL;
 	bool found = false, refreshed = false;
+	git_odb_object *object;
 
 	assert(out && db);
 
@@ -682,7 +750,7 @@ int git_odb_read_prefix(
 		len = GIT_OID_HEXSZ;
 
 	if (len == GIT_OID_HEXSZ) {
-		*out = git_cache_get(&db->cache, short_id);
+		*out = git_cache_get_raw(odb_cache(db), short_id);
 		if (*out != NULL)
 			return 0;
 	}
@@ -704,7 +772,7 @@ attempt_lookup:
 			git__free(data);
 			data = raw.data;
 
-			if (found && git_oid_cmp(&full_oid, &found_full_oid))
+			if (found && git_oid__cmp(&full_oid, &found_full_oid))
 				return git_odb__error_ambiguous("multiple matches for prefix");
 
 			found_full_oid = full_oid;
@@ -723,7 +791,10 @@ attempt_lookup:
 	if (!found)
 		return git_odb__error_notfound("no match for prefix", short_id);
 
-	*out = git_cache_try_store(&db->cache, new_odb_object(&found_full_oid, &raw));
+	if ((object = odb_object__alloc(&found_full_oid, &raw)) == NULL)
+		return -1;
+
+	*out = git_cache_store_raw(odb_cache(db), object);
 	return 0;
 }
 
diff --git a/src/odb.h b/src/odb.h
index 7c018cc..0d9f9e2 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -29,14 +29,14 @@ typedef struct {
 /* EXPORT */
 struct git_odb_object {
 	git_cached_obj cached;
-	git_rawobj raw;
+	void *buffer;
 };
 
 /* EXPORT */
 struct git_odb {
 	git_refcount rc;
 	git_vector backends;
-	git_cache cache;
+	git_cache own_cache;
 };
 
 /*
@@ -96,4 +96,7 @@ int git_odb__read_header_or_object(
 	git_odb_object **out, size_t *len_p, git_otype *type_p,
 	git_odb *db, const git_oid *id);
 
+/* fully free the object; internal method, DO NOT EXPORT */
+void git_odb_object__free(void *object);
+
 #endif
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 68083f7..e78172c 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -8,7 +8,7 @@
 #include "common.h"
 #include <zlib.h>
 #include "git2/object.h"
-#include "git2/oid.h"
+#include "git2/sys/odb_backend.h"
 #include "fileops.h"
 #include "hash.h"
 #include "odb.h"
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 7240a4a..eec7925 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -8,7 +8,8 @@
 #include "common.h"
 #include <zlib.h>
 #include "git2/repository.h"
-#include "git2/oid.h"
+#include "git2/indexer.h"
+#include "git2/sys/odb_backend.h"
 #include "fileops.h"
 #include "hash.h"
 #include "odb.h"
@@ -206,7 +207,7 @@ static int packfile_load__cb(void *_data, git_buf *path)
 			return 0;
 	}
 
-	error = git_packfile_check(&pack, path->ptr);
+	error = git_packfile_alloc(&pack, path->ptr);
 	if (error == GIT_ENOTFOUND)
 		/* ignore missing .pack file as git does */
 		return 0;
@@ -526,80 +527,75 @@ static void pack_backend__free(git_odb_backend *_backend)
 	git__free(backend);
 }
 
-int git_odb_backend_one_pack(git_odb_backend **backend_out, const char *idx)
+static int pack_backend__alloc(struct pack_backend **out, size_t initial_size)
 {
-	struct pack_backend *backend = NULL;
-	struct git_pack_file *packfile = NULL;
+	struct pack_backend *backend = git__calloc(1, sizeof(struct pack_backend));
+	GITERR_CHECK_ALLOC(backend);
 
-	if (git_packfile_check(&packfile, idx) < 0)
+	if (git_vector_init(&backend->packs, initial_size, packfile_sort__cb) < 0) {
+		git__free(backend);
 		return -1;
+	}
 
-	backend = git__calloc(1, sizeof(struct pack_backend));
-	GITERR_CHECK_ALLOC(backend);
 	backend->parent.version = GIT_ODB_BACKEND_VERSION;
 
-	if (git_vector_init(&backend->packs, 1, NULL) < 0)
-		goto on_error;
-
-	if (git_vector_insert(&backend->packs, packfile) < 0)
-		goto on_error;
-
 	backend->parent.read = &pack_backend__read;
 	backend->parent.read_prefix = &pack_backend__read_prefix;
 	backend->parent.read_header = &pack_backend__read_header;
 	backend->parent.exists = &pack_backend__exists;
 	backend->parent.refresh = &pack_backend__refresh;
 	backend->parent.foreach = &pack_backend__foreach;
+	backend->parent.writepack = &pack_backend__writepack;
 	backend->parent.free = &pack_backend__free;
 
-	*backend_out = (git_odb_backend *)backend;
-
+	*out = backend;
 	return 0;
-
-on_error:
-	git_vector_free(&backend->packs);
-	git__free(backend);
-	git__free(packfile);
-	return -1;
 }
 
-int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
+int git_odb_backend_one_pack(git_odb_backend **backend_out, const char *idx)
 {
 	struct pack_backend *backend = NULL;
-	git_buf path = GIT_BUF_INIT;
+	struct git_pack_file *packfile = NULL;
 
-	backend = git__calloc(1, sizeof(struct pack_backend));
-	GITERR_CHECK_ALLOC(backend);
-	backend->parent.version = GIT_ODB_BACKEND_VERSION;
+	if (pack_backend__alloc(&backend, 1) < 0)
+		return -1;
 
-	if (git_vector_init(&backend->packs, 8, packfile_sort__cb) < 0 ||
-		git_buf_joinpath(&path, objects_dir, "pack") < 0)
+	if (git_packfile_alloc(&packfile, idx) < 0 ||
+		git_vector_insert(&backend->packs, packfile) < 0)
 	{
-		git__free(backend);
+		pack_backend__free((git_odb_backend *)backend);
 		return -1;
 	}
 
-	if (git_path_isdir(git_buf_cstr(&path)) == true) {
-		int error;
+	*backend_out = (git_odb_backend *)backend;
+	return 0;
+}
+
+int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
+{
+	int error = 0;
+	struct pack_backend *backend = NULL;
+	git_buf path = GIT_BUF_INIT;
+
+	if (pack_backend__alloc(&backend, 8) < 0)
+		return -1;
 
+	if (!(error = git_buf_joinpath(&path, objects_dir, "pack")) &&
+		git_path_isdir(git_buf_cstr(&path)))
+	{
 		backend->pack_folder = git_buf_detach(&path);
+
 		error = pack_backend__refresh((git_odb_backend *)backend);
-		if (error < 0)
-			return error;
 	}
 
-	backend->parent.read = &pack_backend__read;
-	backend->parent.read_prefix = &pack_backend__read_prefix;
-	backend->parent.read_header = &pack_backend__read_header;
-	backend->parent.exists = &pack_backend__exists;
-	backend->parent.refresh = &pack_backend__refresh;
-	backend->parent.foreach = &pack_backend__foreach;
-	backend->parent.writepack = &pack_backend__writepack;
-	backend->parent.free = &pack_backend__free;
+	if (error < 0) {
+		pack_backend__free((git_odb_backend *)backend);
+		backend = NULL;
+	}
 
 	*backend_out = (git_odb_backend *)backend;
 
 	git_buf_free(&path);
 
-	return 0;
+	return error;
 }
diff --git a/src/oid.c b/src/oid.c
index ab69eeb..e74640c 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -166,18 +166,26 @@ void git_oid_cpy(git_oid *out, const git_oid *src)
 	memcpy(out->id, src->id, sizeof(out->id));
 }
 
+int git_oid_cmp(const git_oid *a, const git_oid *b)
+{
+	return git_oid__cmp(a, b);
+}
+
 int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, size_t len)
 {
 	const unsigned char *a = oid_a->id;
 	const unsigned char *b = oid_b->id;
 
-	do {
+	if (len > GIT_OID_HEXSZ)
+		len = GIT_OID_HEXSZ;
+
+	while (len > 1) {
 		if (*a != *b)
 			return 1;
 		a++;
 		b++;
 		len -= 2;
-	} while (len > 1);
+	};
 
 	if (len)
 		if ((*a ^ *b) & 0xf0)
@@ -186,14 +194,31 @@ int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, size_t len)
 	return 0;
 }
 
-int git_oid_streq(const git_oid *a, const char *str)
+int git_oid_strcmp(const git_oid *oid_a, const char *str)
 {
-	git_oid id;
+	const unsigned char *a = oid_a->id;
+	unsigned char strval;
+	int hexval;
 
-	if (git_oid_fromstr(&id, str) < 0)
-		return -1;
+	for (a = oid_a->id; *str && (a - oid_a->id) < GIT_OID_RAWSZ; ++a) {
+		if ((hexval = git__fromhex(*str++)) < 0)
+			return -1;
+		strval = hexval << 4;
+		if (*str) {
+			if ((hexval = git__fromhex(*str++)) < 0)
+				return -1;
+			strval |= hexval;
+		}
+		if (*a != strval)
+			return (*a - strval);
+	}
 
-	return git_oid_cmp(a, &id) == 0 ? 0 : -1;
+	return 0;
+}
+
+int git_oid_streq(const git_oid *oid_a, const char *str)
+{
+	return git_oid_strcmp(oid_a, str) == 0 ? 0 : -1;
 }
 
 int git_oid_iszero(const git_oid *oid_a)
diff --git a/src/oid.h b/src/oid.h
new file mode 100644
index 0000000..077d0a4
--- /dev/null
+++ b/src/oid.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_oid_h__
+#define INCLUDE_oid_h__
+
+#include "git2/oid.h"
+
+/*
+ * Compare two oid structures.
+ *
+ * @param a first oid structure.
+ * @param b second oid structure.
+ * @return <0, 0, >0 if a < b, a == b, a > b.
+ */
+GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b)
+{
+	const unsigned char *sha1 = a->id;
+	const unsigned char *sha2 = b->id;
+	int i;
+
+	for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
+		if (*sha1 != *sha2)
+			return *sha1 - *sha2;
+	}
+
+	return 0;
+}
+
+#endif
diff --git a/src/oidmap.h b/src/oidmap.h
index 40274cd..a29c7cd 100644
--- a/src/oidmap.h
+++ b/src/oidmap.h
@@ -19,17 +19,15 @@
 __KHASH_TYPE(oid, const git_oid *, void *);
 typedef khash_t(oid) git_oidmap;
 
-GIT_INLINE(khint_t) hash_git_oid(const git_oid *oid)
+GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
 {
-	int i;
-	khint_t h = 0;
-	for (i = 0; i < 20; ++i)
-		h = (h << 5) - h + oid->id[i];
+	khint_t h;
+	memcpy(&h, oid, sizeof(khint_t));
 	return h;
 }
 
 #define GIT__USE_OIDMAP \
-	__KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, hash_git_oid, git_oid_equal)
+	__KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal)
 
 #define git_oidmap_alloc() kh_init(oid)
 #define git_oidmap_free(h) kh_destroy(oid,h), h = NULL
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 459201f..1329a9b 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -1284,6 +1284,21 @@ static int cb_tree_walk(const char *root, const git_tree_entry *entry, void *pay
 		git_buf_cstr(&ctx->buf));
 }
 
+int git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *oid)
+{
+	git_commit *commit;
+
+	if (git_commit_lookup(&commit, pb->repo, oid) < 0 ||
+		git_packbuilder_insert(pb, oid, NULL) < 0)
+		return -1;
+
+	if (git_packbuilder_insert_tree(pb, git_commit_tree_id(commit)) < 0)
+		return -1;
+
+	git_commit_free(commit);
+	return 0;
+}
+
 int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid)
 {
 	git_tree *tree;
diff --git a/src/pack.c b/src/pack.c
index 75ac981..417d225 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -12,8 +12,8 @@
 #include "sha1_lookup.h"
 #include "mwindow.h"
 #include "fileops.h"
+#include "oid.h"
 
-#include "git2/oid.h"
 #include <zlib.h>
 
 static int packfile_open(struct git_pack_file *p);
@@ -205,13 +205,18 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
 	if (fd < 0)
 		return fd;
 
-	if (p_fstat(fd, &st) < 0 ||
-		!S_ISREG(st.st_mode) ||
+	if (p_fstat(fd, &st) < 0) {
+		p_close(fd);
+		giterr_set(GITERR_OS, "Unable to stat pack index '%s'", path);
+		return -1;
+	}
+
+	if (!S_ISREG(st.st_mode) ||
 		!git__is_sizet(st.st_size) ||
 		(idx_size = (size_t)st.st_size) < 4 * 256 + 20 + 20)
 	{
 		p_close(fd);
-		giterr_set(GITERR_OS, "Failed to check pack index.");
+		giterr_set(GITERR_ODB, "Invalid pack index '%s'", path);
 		return -1;
 	}
 
@@ -288,32 +293,40 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
 		}
 	}
 
-	p->index_version = version;
 	p->num_objects = nr;
+	p->index_version = version;
 	return 0;
 }
 
 static int pack_index_open(struct git_pack_file *p)
 {
 	char *idx_name;
-	int error;
-	size_t name_len, offset;
+	int error = 0;
+	size_t name_len, base_len;
 
-	if (p->index_map.data)
+	if (p->index_version > -1)
 		return 0;
 
-	idx_name = git__strdup(p->pack_name);
-	GITERR_CHECK_ALLOC(idx_name);
+	name_len = strlen(p->pack_name);
+	assert(name_len > strlen(".pack")); /* checked by git_pack_file alloc */
+
+	if ((idx_name = git__malloc(name_len)) == NULL)
+		return -1;
+
+	base_len = name_len - strlen(".pack");
+	memcpy(idx_name, p->pack_name, base_len);
+	memcpy(idx_name + base_len, ".idx", sizeof(".idx"));
 
-	name_len = strlen(idx_name);
-	offset = name_len - strlen(".pack");
-	assert(offset < name_len); /* make sure no underflow */
+	if ((error = git_mutex_lock(&p->lock)) < 0)
+		return error;
 
-	strncpy(idx_name + offset, ".idx", name_len - offset);
+	if (p->index_version == -1)
+		error = pack_index_check(idx_name, p);
 
-	error = pack_index_check(idx_name, p);
 	git__free(idx_name);
 
+	git_mutex_unlock(&p->lock);
+
 	return error;
 }
 
@@ -389,12 +402,12 @@ int git_packfile_unpack_header(
 	 * the maximum deflated object size is 2^137, which is just
 	 * insane, so we know won't exceed what we have been given.
 	 */
-//	base = pack_window_open(p, w_curs, *curpos, &left);
+/*	base = pack_window_open(p, w_curs, *curpos, &left); */
 	base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left);
 	if (base == NULL)
 		return GIT_EBUFS;
 
-		ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
+	ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
 	git_mwindow_close(w_curs);
 	if (ret == GIT_EBUFS)
 		return ret;
@@ -786,23 +799,14 @@ git_off_t get_delta_base(
  *
  ***********************************************************/
 
-static struct git_pack_file *packfile_alloc(size_t extra)
-{
-	struct git_pack_file *p = git__calloc(1, sizeof(*p) + extra);
-	if (p != NULL)
-		p->mwf.fd = -1;
-	return p;
-}
-
-
 void git_packfile_free(struct git_pack_file *p)
 {
-	assert(p);
+	if (!p)
+		return;
 
 	cache_free(&p->bases);
 
 	git_mwindow_free_all(&p->mwf);
-	git_mwindow_file_deregister(&p->mwf);
 
 	if (p->mwf.fd != -1)
 		p_close(p->mwf.fd);
@@ -810,6 +814,8 @@ void git_packfile_free(struct git_pack_file *p)
 	pack_index_free(p);
 
 	git__free(p->bad_object_sha1);
+
+	git_mutex_free(&p->lock);
 	git__free(p);
 }
 
@@ -820,17 +826,22 @@ static int packfile_open(struct git_pack_file *p)
 	git_oid sha1;
 	unsigned char *idx_sha1;
 
-	assert(p->index_map.data);
-
-	if (!p->index_map.data && pack_index_open(p) < 0)
+	if (p->index_version == -1 && pack_index_open(p) < 0)
 		return git_odb__error_notfound("failed to open packfile", NULL);
 
+	/* if mwf opened by another thread, return now */
+	if (git_mutex_lock(&p->lock) < 0)
+		return packfile_error("failed to get lock for open");
+
+	if (p->mwf.fd >= 0) {
+		git_mutex_unlock(&p->lock);
+		return 0;
+	}
+
 	/* TODO: open with noatime */
 	p->mwf.fd = git_futils_open_ro(p->pack_name);
-	if (p->mwf.fd < 0) {
-		p->mwf.fd = -1;
-		return -1;
-	}
+	if (p->mwf.fd < 0)
+		goto cleanup;
 
 	if (p_fstat(p->mwf.fd, &st) < 0 ||
 		git_mwindow_file_register(&p->mwf) < 0)
@@ -871,44 +882,54 @@ static int packfile_open(struct git_pack_file *p)
 
 	idx_sha1 = ((unsigned char *)p->index_map.data) + p->index_map.len - 40;
 
-	if (git_oid_cmp(&sha1, (git_oid *)idx_sha1) == 0)
-		return 0;
+	if (git_oid__cmp(&sha1, (git_oid *)idx_sha1) != 0)
+		goto cleanup;
+
+	git_mutex_unlock(&p->lock);
+	return 0;
 
 cleanup:
 	giterr_set(GITERR_OS, "Invalid packfile '%s'", p->pack_name);
+
 	p_close(p->mwf.fd);
 	p->mwf.fd = -1;
+
+	git_mutex_unlock(&p->lock);
+
 	return -1;
 }
 
-int git_packfile_check(struct git_pack_file **pack_out, const char *path)
+int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
 {
 	struct stat st;
 	struct git_pack_file *p;
-	size_t path_len;
+	size_t path_len = path ? strlen(path) : 0;
 
 	*pack_out = NULL;
-	path_len = strlen(path);
-	p = packfile_alloc(path_len + 2);
+
+	if (path_len < strlen(".idx"))
+		return git_odb__error_notfound("invalid packfile path", NULL);
+
+	p = git__calloc(1, sizeof(*p) + path_len + 2);
 	GITERR_CHECK_ALLOC(p);
 
+	memcpy(p->pack_name, path, path_len + 1);
+
 	/*
 	 * Make sure a corresponding .pack file exists and that
 	 * the index looks sane.
 	 */
-	path_len -= strlen(".idx");
-	if (path_len < 1) {
-		git__free(p);
-		return git_odb__error_notfound("invalid packfile path", NULL);
-	}
+	if (git__suffixcmp(path, ".idx") == 0) {
+		size_t root_len = path_len - strlen(".idx");
 
-	memcpy(p->pack_name, path, path_len);
+		memcpy(p->pack_name + root_len, ".keep", sizeof(".keep"));
+		if (git_path_exists(p->pack_name) == true)
+			p->pack_keep = 1;
 
-	strcpy(p->pack_name + path_len, ".keep");
-	if (git_path_exists(p->pack_name) == true)
-		p->pack_keep = 1;
+		memcpy(p->pack_name + root_len, ".pack", sizeof(".pack"));
+		path_len = path_len - strlen(".idx") + strlen(".pack");
+	}
 
-	strcpy(p->pack_name + path_len, ".pack");
 	if (p_stat(p->pack_name, &st) < 0 || !S_ISREG(st.st_mode)) {
 		git__free(p);
 		return git_odb__error_notfound("packfile not found", NULL);
@@ -917,9 +938,13 @@ int git_packfile_check(struct git_pack_file **pack_out, const char *path)
 	/* ok, it looks sane as far as we can check without
 	 * actually mapping the pack file.
 	 */
+	p->mwf.fd = -1;
 	p->mwf.size = st.st_size;
 	p->pack_local = 1;
 	p->mtime = (git_time_t)st.st_mtime;
+	p->index_version = -1;
+
+	git_mutex_init(&p->lock);
 
 	/* see if we can parse the sha1 oid in the packfile name */
 	if (path_len < 40 ||
@@ -1034,12 +1059,11 @@ static int pack_entry_find_offset(
 
 	*offset_out = 0;
 
-	if (index == NULL) {
+	if (p->index_version == -1) {
 		int error;
 
 		if ((error = pack_index_open(p)) < 0)
 			return error;
-
 		assert(p->index_map.data);
 
 		index = p->index_map.data;
@@ -1099,6 +1123,7 @@ static int pack_entry_find_offset(
 		return git_odb__error_notfound("failed to find offset for pack entry", short_oid);
 	if (found > 1)
 		return git_odb__error_ambiguous("found multiple offsets for pack entry");
+
 	*offset_out = nth_packed_object_offset(p, pos);
 	git_oid_fromraw(found_oid, current);
 
@@ -1110,6 +1135,7 @@ static int pack_entry_find_offset(
 		printf("found lo=%d %s\n", lo, hex_sha1);
 	}
 #endif
+
 	return 0;
 }
 
@@ -1128,7 +1154,7 @@ int git_pack_entry_find(
 	if (len == GIT_OID_HEXSZ && p->num_bad_objects) {
 		unsigned i;
 		for (i = 0; i < p->num_bad_objects; i++)
-			if (git_oid_cmp(short_oid, &p->bad_object_sha1[i]) == 0)
+			if (git_oid__cmp(short_oid, &p->bad_object_sha1[i]) == 0)
 				return packfile_error("bad object found in packfile");
 	}
 
diff --git a/src/pack.h b/src/pack.h
index 8d7e33d..aeeac9c 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -79,6 +79,7 @@ typedef struct {
 struct git_pack_file {
 	git_mwindow_file mwf;
 	git_map index_map;
+	git_mutex lock; /* protect updates to mwf and index_map */
 
 	uint32_t num_objects;
 	uint32_t num_bad_objects;
@@ -142,7 +143,8 @@ git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
 		git_off_t delta_obj_offset);
 
 void git_packfile_free(struct git_pack_file *p);
-int git_packfile_check(struct git_pack_file **pack_out, const char *path);
+int git_packfile_alloc(struct git_pack_file **pack_out, const char *path);
+
 int git_pack_entry_find(
 		struct git_pack_entry *e,
 		struct git_pack_file *p,
diff --git a/src/push.c b/src/push.c
index cec4c64..9b1e78c 100644
--- a/src/push.c
+++ b/src/push.c
@@ -177,9 +177,9 @@ int git_push_add_refspec(git_push *push, const char *refspec)
 
 int git_push_update_tips(git_push *push)
 {
-	git_refspec *fetch_spec = &push->remote->fetch;
 	git_buf remote_ref_name = GIT_BUF_INIT;
 	size_t i, j;
+	git_refspec *fetch_spec;
 	push_spec *push_spec;
 	git_reference *remote_ref;
 	push_status *status;
@@ -191,7 +191,8 @@ int git_push_update_tips(git_push *push)
 			continue;
 
 		/* Find the corresponding remote ref */
-		if (!git_refspec_src_matches(fetch_spec, status->ref))
+		fetch_spec = git_remote__matching_refspec(push->remote, status->ref);
+		if (!fetch_spec)
 			continue;
 
 		if ((error = git_refspec_transform_r(&remote_ref_name, fetch_spec, status->ref)) < 0)
@@ -375,7 +376,7 @@ static int queue_differences(
 		const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j);
 		int cmp = 0;
 
-		if (!git_oid_cmp(&b_entry->oid, &d_entry->oid))
+		if (!git_oid__cmp(&b_entry->oid, &d_entry->oid))
 			goto loop;
 
 		cmp = strcmp(b_entry->filename, d_entry->filename);
diff --git a/src/refdb.c b/src/refdb.c
index d9b73c6..33a1934 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -7,15 +7,16 @@
 
 #include "common.h"
 #include "posix.h"
+
 #include "git2/object.h"
 #include "git2/refs.h"
 #include "git2/refdb.h"
+#include "git2/sys/refdb_backend.h"
+
 #include "hash.h"
 #include "refdb.h"
 #include "refs.h"
 
-#include "git2/refdb_backend.h"
-
 int git_refdb_new(git_refdb **out, git_repository *repo)
 {
 	git_refdb *db;
@@ -45,7 +46,7 @@ int git_refdb_open(git_refdb **out, git_repository *repo)
 		return -1;
 
 	/* Add the default (filesystem) backend */
-	if (git_refdb_backend_fs(&dir, repo, db) < 0) {
+	if (git_refdb_backend_fs(&dir, repo) < 0) {
 		git_refdb_free(db);
 		return -1;
 	}
@@ -57,15 +58,19 @@ int git_refdb_open(git_refdb **out, git_repository *repo)
 	return 0;
 }
 
-int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
+static void refdb_free_backend(git_refdb *db)
 {
 	if (db->backend) {
-		if(db->backend->free)
+		if (db->backend->free)
 			db->backend->free(db->backend);
 		else
 			git__free(db->backend);
 	}
+}
 
+int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
+{
+	refdb_free_backend(db);
 	db->backend = backend;
 
 	return 0;
@@ -74,23 +79,16 @@ int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
 int git_refdb_compress(git_refdb *db)
 {
 	assert(db);
-	
-	if (db->backend->compress) {
+
+	if (db->backend->compress)
 		return db->backend->compress(db->backend);
-	}
-	
+
 	return 0;
 }
 
 static void refdb_free(git_refdb *db)
 {
-	if (db->backend) {
-		if(db->backend->free)
-			db->backend->free(db->backend);
-		else
-			git__free(db->backend);
-	}
-
+	refdb_free_backend(db);
 	git__free(db);
 }
 
@@ -111,9 +109,19 @@ int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name)
 
 int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name)
 {
-	assert(db && db->backend && ref_name);
+	git_reference *ref;
+	int error;
+
+	assert(db && db->backend && out && ref_name);
 
-	return db->backend->lookup(out, db->backend, ref_name);
+	if (!(error = db->backend->lookup(&ref, db->backend, ref_name))) {
+		ref->db = db;
+		*out = ref;
+	} else {
+		*out = NULL;
+	}
+
+	return error;
 }
 
 int git_refdb_foreach(
diff --git a/src/refdb.h b/src/refdb.h
index 0969711..047113a 100644
--- a/src/refdb.h
+++ b/src/refdb.h
@@ -41,6 +41,6 @@ int git_refdb_foreach_glob(
 
 int git_refdb_write(git_refdb *refdb, const git_reference *ref);
 
-int git_refdb_delete(struct git_refdb *refdb, const git_reference *ref);
+int git_refdb_delete(git_refdb *refdb, const git_reference *ref);
 
 #endif
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index f00bd72..c0a32ba 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -11,14 +11,14 @@
 #include "fileops.h"
 #include "pack.h"
 #include "reflog.h"
-#include "config.h"
 #include "refdb.h"
 #include "refdb_fs.h"
 
 #include <git2/tag.h>
 #include <git2/object.h>
 #include <git2/refdb.h>
-#include <git2/refdb_backend.h>
+#include <git2/sys/refdb_backend.h>
+#include <git2/sys/refs.h>
 
 GIT__USE_STRMAP;
 
@@ -26,8 +26,15 @@ GIT__USE_STRMAP;
 #define MAX_NESTING_LEVEL		10
 
 enum {
-	GIT_PACKREF_HAS_PEEL = 1,
-	GIT_PACKREF_WAS_LOOSE = 2
+	PACKREF_HAS_PEEL = 1,
+	PACKREF_WAS_LOOSE = 2,
+	PACKREF_CANNOT_PEEL = 4
+};
+
+enum {
+	PEELING_NONE = 0,
+	PEELING_STANDARD,
+	PEELING_FULL
 };
 
 struct packref {
@@ -41,10 +48,10 @@ typedef struct refdb_fs_backend {
 	git_refdb_backend parent;
 
 	git_repository *repo;
-	const char *path;
-	git_refdb *refdb;
+	char *path;
 
 	git_refcache refcache;
+	int peeling_mode;
 } refdb_fs_backend;
 
 static int reference_read(
@@ -62,7 +69,7 @@ static int reference_read(
 	/* Determine the full path of the file */
 	if (git_buf_joinpath(&path, repo_path, ref_name) < 0)
 		return -1;
-	
+
 	result = git_futils_readbuffer_updated(file_content, path.ptr, mtime, NULL, updated);
 	git_buf_free(&path);
 
@@ -133,10 +140,6 @@ static int packed_parse_peel(
 	if (tag_ref == NULL)
 		goto corrupt;
 
-	/* Ensure reference is a tag */
-	if (git__prefixcmp(tag_ref->name, GIT_REFS_TAGS_DIR) != 0)
-		goto corrupt;
-
 	if (buffer + GIT_OID_HEXSZ > buffer_end)
 		goto corrupt;
 
@@ -155,6 +158,7 @@ static int packed_parse_peel(
 			goto corrupt;
 	}
 
+	tag_ref->flags |= PACKREF_HAS_PEEL;
 	*buffer_out = buffer;
 	return 0;
 
@@ -175,7 +179,7 @@ static int packed_load(refdb_fs_backend *backend)
 		ref_cache->packfile = git_strmap_alloc();
 		GITERR_CHECK_ALLOC(ref_cache->packfile);
 	}
-	
+
 	result = reference_read(&packfile, &ref_cache->packfile_time,
 		backend->path, GIT_PACKEDREFS_FILE, &updated);
 
@@ -193,7 +197,7 @@ static int packed_load(refdb_fs_backend *backend)
 
 	if (result < 0)
 		return -1;
-	
+
 	if (!updated)
 		return 0;
 
@@ -206,6 +210,30 @@ static int packed_load(refdb_fs_backend *backend)
 	buffer_start = (const char *)packfile.ptr;
 	buffer_end = (const char *)(buffer_start) + packfile.size;
 
+	backend->peeling_mode = PEELING_NONE;
+
+	if (buffer_start[0] == '#') {
+		static const char *traits_header = "# pack-refs with: "; 
+
+		if (git__prefixcmp(buffer_start, traits_header) == 0) {
+			char *traits = (char *)buffer_start + strlen(traits_header);
+			char *traits_end = strchr(traits, '\n');
+
+			if (traits_end == NULL)
+				goto parse_failed;
+
+			*traits_end = '\0';
+
+			if (strstr(traits, " fully-peeled ") != NULL) {
+				backend->peeling_mode = PEELING_FULL;
+			} else if (strstr(traits, " peeled ") != NULL) {
+				backend->peeling_mode = PEELING_STANDARD;
+			}
+
+			buffer_start = traits_end + 1;
+		}
+	}
+
 	while (buffer_start < buffer_end && buffer_start[0] == '#') {
 		buffer_start = strchr(buffer_start, '\n');
 		if (buffer_start == NULL)
@@ -224,6 +252,10 @@ static int packed_load(refdb_fs_backend *backend)
 		if (buffer_start[0] == '^') {
 			if (packed_parse_peel(ref, &buffer_start, buffer_end) < 0)
 				goto parse_failed;
+		} else if (backend->peeling_mode == PEELING_FULL ||
+                           (backend->peeling_mode == PEELING_STANDARD &&
+                            git__prefixcmp(ref->name, GIT_REFS_TAGS_DIR) == 0)) {
+			ref->flags |= PACKREF_CANNOT_PEEL;
 		}
 
 		git_strmap_insert(ref_cache->packfile, ref->name, ref, err);
@@ -241,7 +273,7 @@ parse_failed:
 	return -1;
 }
 
-static int loose_parse_oid(git_oid *oid, git_buf *file_content)
+static int loose_parse_oid(git_oid *oid, const char *filename, git_buf *file_content)
 {
 	size_t len;
 	const char *str;
@@ -263,7 +295,7 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
 		return 0;
 
 corrupted:
-	giterr_set(GITERR_REFERENCE, "Corrupted loose reference file");
+	giterr_set(GITERR_REFERENCE, "Corrupted loose reference file: %s", filename);
 	return -1;
 }
 
@@ -290,13 +322,13 @@ static int loose_lookup_to_packfile(
 	memcpy(ref->name, name, name_len);
 	ref->name[name_len] = 0;
 
-	if (loose_parse_oid(&ref->oid, &ref_file) < 0) {
+	if (loose_parse_oid(&ref->oid, name, &ref_file) < 0) {
 		git_buf_free(&ref_file);
 		git__free(ref);
 		return -1;
 	}
 
-	ref->flags = GIT_PACKREF_WAS_LOOSE;
+	ref->flags = PACKREF_WAS_LOOSE;
 
 	*ref_out = ref;
 	git_buf_free(&ref_file);
@@ -430,12 +462,12 @@ static int loose_lookup(
 			goto done;
 		}
 
-		*out = git_reference__alloc(backend->refdb, ref_name, NULL, target);
+		*out = git_reference__alloc_symbolic(ref_name, target);
 	} else {
-		if ((error = loose_parse_oid(&oid, &ref_file)) < 0)
+		if ((error = loose_parse_oid(&oid, ref_name, &ref_file)) < 0)
 			goto done;
-		
-		*out = git_reference__alloc(backend->refdb, ref_name, &oid, NULL);
+
+		*out = git_reference__alloc(ref_name, &oid, NULL);
 	}
 
 	if (*out == NULL)
@@ -456,19 +488,19 @@ static int packed_map_entry(
 
 	if (packed_load(backend) < 0)
 		return -1;
-	
+
 	/* Look up on the packfile */
 	packfile_refs = backend->refcache.packfile;
 
 	*pos = git_strmap_lookup_index(packfile_refs, ref_name);
-	
+
 	if (!git_strmap_valid_index(packfile_refs, *pos)) {
 		giterr_set(GITERR_REFERENCE, "Reference '%s' not found", ref_name);
 		return GIT_ENOTFOUND;
 	}
 
 	*entry = git_strmap_value_at(packfile_refs, *pos);
-	
+
 	return 0;
 }
 
@@ -480,13 +512,14 @@ static int packed_lookup(
 	struct packref *entry;
 	khiter_t pos;
 	int error = 0;
-	
+
 	if ((error = packed_map_entry(&entry, &pos, backend, ref_name)) < 0)
 		return error;
 
-	if ((*out = git_reference__alloc(backend->refdb, ref_name, &entry->oid, NULL)) == NULL)
+	if ((*out = git_reference__alloc(ref_name,
+		&entry->oid, &entry->peel)) == NULL)
 		return -1;
-	
+
 	return 0;
 }
 
@@ -582,7 +615,7 @@ static int refdb_fs_backend__foreach(
 	git_buf refs_path = GIT_BUF_INIT;
 	const char *ref_name;
 	void *ref = NULL;
-	
+
 	GIT_UNUSED(ref);
 
 	assert(_backend);
@@ -590,7 +623,7 @@ static int refdb_fs_backend__foreach(
 
 	if (packed_load(backend) < 0)
 		return -1;
-	
+
 	/* list all the packed references first */
 	if (list_type & GIT_REF_OID) {
 		git_strmap_foreach(backend->refcache.packfile, ref_name, ref, {
@@ -678,14 +711,7 @@ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref)
 {
 	git_object *object;
 
-	if (ref->flags & GIT_PACKREF_HAS_PEEL)
-		return 0;
-
-	/*
-	 * Only applies to tags, i.e. references
-	 * in the /refs/tags folder
-	 */
-	if (git__prefixcmp(ref->name, GIT_REFS_TAGS_DIR) != 0)
+	if (ref->flags & PACKREF_HAS_PEEL || ref->flags & PACKREF_CANNOT_PEEL)
 		return 0;
 
 	/*
@@ -706,7 +732,7 @@ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref)
 		 * Find the object pointed at by this tag
 		 */
 		git_oid_cpy(&ref->peel, git_tag_target_id(tag));
-		ref->flags |= GIT_PACKREF_HAS_PEEL;
+		ref->flags |= PACKREF_HAS_PEEL;
 
 		/*
 		 * The reference has now cached the resolved OID, and is
@@ -739,7 +765,7 @@ static int packed_write_ref(struct packref *ref, git_filebuf *file)
 	 * This obviously only applies to tags.
 	 * The required peels have already been loaded into `ref->peel_target`.
 	 */
-	if (ref->flags & GIT_PACKREF_HAS_PEEL) {
+	if (ref->flags & PACKREF_HAS_PEEL) {
 		char peel[GIT_OID_HEXSZ + 1];
 		git_oid_fmt(peel, &ref->peel);
 		peel[GIT_OID_HEXSZ] = 0;
@@ -776,7 +802,7 @@ static int packed_remove_loose(
 	for (i = 0; i < packing_list->length; ++i) {
 		struct packref *ref = git_vector_get(packing_list, i);
 
-		if ((ref->flags & GIT_PACKREF_WAS_LOOSE) == 0)
+		if ((ref->flags & PACKREF_WAS_LOOSE) == 0)
 			continue;
 
 		if (git_buf_joinpath(&full_path, backend->path, ref->name) < 0)
@@ -924,7 +950,7 @@ static int refdb_fs_backend__delete(
 	repo = backend->repo;
 
 	/* If a loose reference exists, remove it from the filesystem */
-	
+
 	if (git_buf_joinpath(&loose_path, repo->path_repository, ref->name) < 0)
 		return -1;
 
@@ -932,7 +958,7 @@ static int refdb_fs_backend__delete(
 		error = p_unlink(loose_path.ptr);
 		loose_deleted = 1;
 	}
-	
+
 	git_buf_free(&loose_path);
 
 	if (error != 0)
@@ -946,7 +972,7 @@ static int refdb_fs_backend__delete(
 
 		error = packed_write(backend);
 	}
-	
+
 	if (pack_error == GIT_ENOTFOUND)
 		error = loose_deleted ? 0 : GIT_ENOTFOUND;
 	else
@@ -993,22 +1019,65 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
 	backend = (refdb_fs_backend *)_backend;
 
 	refcache_free(&backend->refcache);
+	git__free(backend->path);
 	git__free(backend);
 }
 
+static int setup_namespace(git_buf *path, git_repository *repo)
+{
+	char *parts, *start, *end; 
+
+	/* Load the path to the repo first */
+	git_buf_puts(path, repo->path_repository);
+
+	/* if the repo is not namespaced, nothing else to do */
+	if (repo->namespace == NULL)
+		return 0;
+
+	parts = end = git__strdup(repo->namespace);
+	if (parts == NULL)
+		return -1;
+
+	/**
+	 * From `man gitnamespaces`:
+	 *  namespaces which include a / will expand to a hierarchy
+	 *  of namespaces; for example, GIT_NAMESPACE=foo/bar will store
+	 *  refs under refs/namespaces/foo/refs/namespaces/bar/
+	 */
+	while ((start = git__strsep(&end, "/")) != NULL) {
+		git_buf_printf(path, "refs/namespaces/%s/", start);
+	}
+
+	git_buf_printf(path, "refs/namespaces/%s/refs", end);
+	free(parts);
+
+	/* Make sure that the folder with the namespace exists */
+	if (git_futils_mkdir_r(git_buf_cstr(path), repo->path_repository, 0777) < 0) 
+		return -1;
+
+	/* Return the root of the namespaced path, i.e. without the trailing '/refs' */
+	git_buf_rtruncate_at_char(path, '/');
+	return 0;
+}
+
 int git_refdb_backend_fs(
 	git_refdb_backend **backend_out,
-	git_repository *repository,
-	git_refdb *refdb)
+	git_repository *repository)
 {
+	git_buf path = GIT_BUF_INIT;
 	refdb_fs_backend *backend;
 
 	backend = git__calloc(1, sizeof(refdb_fs_backend));
 	GITERR_CHECK_ALLOC(backend);
 
 	backend->repo = repository;
-	backend->path = repository->path_repository;
-	backend->refdb = refdb;
+
+	if (setup_namespace(&path, repository) < 0) {
+		git__free(backend);
+		return -1;
+	}
+
+	backend->path = git_buf_detach(&path);
 
 	backend->parent.exists = &refdb_fs_backend__exists;
 	backend->parent.lookup = &refdb_fs_backend__lookup;
diff --git a/src/refs.c b/src/refs.c
index b1f6796..b85a2e8 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -19,7 +19,7 @@
 #include <git2/branch.h>
 #include <git2/refs.h>
 #include <git2/refdb.h>
-#include <git2/refdb_backend.h>
+#include <git2/sys/refs.h>
 
 GIT__USE_STRMAP;
 
@@ -31,37 +31,58 @@ enum {
 	GIT_PACKREF_WAS_LOOSE = 2
 };
 
+static git_reference *alloc_ref(const char *name)
+{
+	git_reference *ref;
+	size_t namelen = strlen(name);
+
+	if ((ref = git__calloc(1, sizeof(git_reference) + namelen + 1)) == NULL)
+		return NULL;
+
+	memcpy(ref->name, name, namelen + 1);
+
+	return ref;
+}
+
+git_reference *git_reference__alloc_symbolic(
+	const char *name, const char *target)
+{
+	git_reference *ref;
+
+	assert(name && target);
+
+	ref = alloc_ref(name);
+	if (!ref)
+		return NULL;
+
+	ref->type = GIT_REF_SYMBOLIC;
+
+	if ((ref->target.symbolic = git__strdup(target)) == NULL) {
+		git__free(ref);
+		return NULL;
+	}
+
+	return ref;
+}
 
 git_reference *git_reference__alloc(
-	git_refdb *refdb,
 	const char *name,
 	const git_oid *oid,
-	const char *symbolic)
+	const git_oid *peel)
 {
 	git_reference *ref;
-	size_t namelen;
-
-	assert(refdb && name && ((oid && !symbolic) || (!oid && symbolic)));
 
-	namelen = strlen(name);
+	assert(name && oid);
 
-	if ((ref = git__calloc(1, sizeof(git_reference) + namelen + 1)) == NULL)
+	ref = alloc_ref(name);
+	if (!ref)
 		return NULL;
 
-	if (oid) {
-		ref->type = GIT_REF_OID;
-		git_oid_cpy(&ref->target.oid, oid);
-	} else {
-		ref->type = GIT_REF_SYMBOLIC;
+	ref->type = GIT_REF_OID;
+	git_oid_cpy(&ref->target.oid, oid);
 
-		if ((ref->target.symbolic = git__strdup(symbolic)) == NULL) {
-			git__free(ref);
-			return NULL;
-		}
-	}
-
-	ref->db = refdb;
-	memcpy(ref->name, name, namelen + 1);
+	if (peel != NULL)
+		git_oid_cpy(&ref->peel, peel);
 
 	return ref;
 }
@@ -71,13 +92,8 @@ void git_reference_free(git_reference *reference)
 	if (reference == NULL)
 		return;
 
-	if (reference->type == GIT_REF_SYMBOLIC) {
+	if (reference->type == GIT_REF_SYMBOLIC)
 		git__free(reference->target.symbolic);
-		reference->target.symbolic = NULL;
-	}
-
-	reference->db = NULL;
-	reference->type = GIT_REF_INVALID;
 
 	git__free(reference);
 }
@@ -238,10 +254,10 @@ int git_reference_lookup_resolved(
 		max_nesting = MAX_NESTING_LEVEL;
 	else if (max_nesting < 0)
 		max_nesting = DEFAULT_NESTING_LEVEL;
-	
+
 	strncpy(scan_name, name, GIT_REFNAME_MAX);
 	scan_type = GIT_REF_SYMBOLIC;
-	
+
 	if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
 		return -1;
 
@@ -259,7 +275,7 @@ int git_reference_lookup_resolved(
 
 		if ((error = git_refdb_lookup(&ref, refdb, scan_name)) < 0)
 			return error;
-		
+
 		scan_type = ref->type;
 	}
 
@@ -305,6 +321,16 @@ const git_oid *git_reference_target(const git_reference *ref)
 	return &ref->target.oid;
 }
 
+const git_oid *git_reference_target_peel(const git_reference *ref)
+{
+	assert(ref);
+
+	if (ref->type != GIT_REF_OID || git_oid_iszero(&ref->peel))
+		return NULL;
+
+	return &ref->peel;
+}
+
 const char *git_reference_symbolic_target(const git_reference *ref)
 {
 	assert(ref);
@@ -327,7 +353,7 @@ static int reference__create(
 	git_refdb *refdb;
 	git_reference *ref = NULL;
 	int error = 0;
-	
+
 	if (ref_out)
 		*ref_out = NULL;
 
@@ -335,15 +361,22 @@ static int reference__create(
 		(error = reference_can_write(repo, normalized, NULL, force)) < 0 ||
 		(error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
 		return error;
-	
-	if ((ref = git_reference__alloc(refdb, name, oid, symbolic)) == NULL)
-		return -1;
+
+	if (oid != NULL) {
+		assert(symbolic == NULL);
+		ref = git_reference__alloc(name, oid, NULL);
+	} else {
+		ref = git_reference__alloc_symbolic(name, symbolic);
+	}
+
+	GITERR_CHECK_ALLOC(ref);
+	ref->db = refdb;
 
 	if ((error = git_refdb_write(refdb, ref)) < 0) {
 		git_reference_free(ref);
 		return error;
 	}
-	
+
 	if (ref_out == NULL)
 		git_reference_free(ref);
 	else
@@ -363,17 +396,17 @@ int git_reference_create(
 	int error = 0;
 
 	assert(repo && name && oid);
-	
+
 	/* Sanity check the reference being created - target must exist. */
 	if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
 		return error;
-	
+
 	if (!git_odb_exists(odb, oid)) {
 		giterr_set(GITERR_REFERENCE,
 			"Target OID for the reference doesn't exist on the repository");
 		return -1;
 	}
-	
+
 	return reference__create(ref_out, repo, name, oid, NULL, force);
 }
 
@@ -388,7 +421,7 @@ int git_reference_symbolic_create(
 	int error = 0;
 
 	assert(repo && name && target);
-	
+
 	if ((error = git_reference__normalize_name_lax(
 		normalized, sizeof(normalized), target)) < 0)
 		return error;
@@ -402,7 +435,7 @@ int git_reference_set_target(
 	const git_oid *id)
 {
 	assert(out && ref && id);
-	
+
 	if (ref->type != GIT_REF_OID) {
 		giterr_set(GITERR_REFERENCE, "Cannot set OID on symbolic reference");
 		return -1;
@@ -417,13 +450,13 @@ int git_reference_symbolic_set_target(
 	const char *target)
 {
 	assert(out && ref && target);
-	
+
 	if (ref->type != GIT_REF_SYMBOLIC) {
 		giterr_set(GITERR_REFERENCE,
 			"Cannot set symbolic target on a direct reference");
 		return -1;
 	}
-	
+
 	return git_reference_symbolic_create(out, ref->db->repo, ref->name, target, 1);
 }
 
@@ -437,17 +470,16 @@ int git_reference_rename(
 	char normalized[GIT_REFNAME_MAX];
 	bool should_head_be_updated = false;
 	git_reference *result = NULL;
-	git_oid *oid;
-	const char *symbolic;
 	int error = 0;
 	int reference_has_log;
-	
+
 	*out = NULL;
 
 	normalization_flags = ref->type == GIT_REF_SYMBOLIC ?
 		GIT_REF_FORMAT_ALLOW_ONELEVEL : GIT_REF_FORMAT_NORMAL;
 
-	if ((error = git_reference_normalize_name(normalized, sizeof(normalized), new_name, normalization_flags)) < 0 ||
+	if ((error = git_reference_normalize_name(
+			normalized, sizeof(normalized), new_name, normalization_flags)) < 0 ||
 		(error = reference_can_write(ref->db->repo, normalized, ref->name, force)) < 0)
 		return error;
 
@@ -455,16 +487,18 @@ int git_reference_rename(
 	 * Create the new reference.
 	 */
 	if (ref->type == GIT_REF_OID) {
-		oid = &ref->target.oid;
-		symbolic = NULL;
+		result = git_reference__alloc(new_name, &ref->target.oid, &ref->peel);
+	} else if (ref->type == GIT_REF_SYMBOLIC) {
+		result = git_reference__alloc_symbolic(new_name, ref->target.symbolic);
 	} else {
-		oid = NULL;
-		symbolic = ref->target.symbolic;
+		assert(0);
 	}
-	
-	if ((result = git_reference__alloc(ref->db, new_name, oid, symbolic)) == NULL)
+
+	if (result == NULL)
 		return -1;
 
+	result->db = ref->db;
+
 	/* Check if we have to update HEAD. */
 	if ((error = git_branch_is_head(ref)) < 0)
 		goto on_error;
@@ -474,11 +508,11 @@ int git_reference_rename(
 	/* Now delete the old ref and save the new one. */
 	if ((error = git_refdb_delete(ref->db, ref)) < 0)
 		goto on_error;
-	
+
 	/* Save the new reference. */
 	if ((error = git_refdb_write(ref->db, result)) < 0)
 		goto rollback;
-	
+
 	/* Update HEAD it was poiting to the reference being renamed. */
 	if (should_head_be_updated && (error = git_repository_set_head(ref->db->repo, new_name)) < 0) {
 		giterr_set(GITERR_REFERENCE, "Failed to update HEAD after renaming reference");
@@ -509,11 +543,17 @@ on_error:
 
 int git_reference_resolve(git_reference **ref_out, const git_reference *ref)
 {
-	if (ref->type == GIT_REF_OID)
+	switch (git_reference_type(ref)) {
+	case GIT_REF_OID:
 		return git_reference_lookup(ref_out, ref->db->repo, ref->name);
-	else
-		return git_reference_lookup_resolved(ref_out, ref->db->repo,
-			ref->target.symbolic, -1);
+
+	case GIT_REF_SYMBOLIC:
+		return git_reference_lookup_resolved(ref_out, ref->db->repo, ref->target.symbolic, -1);
+
+	default:
+		giterr_set(GITERR_REFERENCE, "Invalid reference");
+		return -1;
+	}
 }
 
 int git_reference_foreach(
@@ -712,6 +752,7 @@ int git_reference__normalize_name(
 		goto cleanup;
 
 	if ((segments_count == 1 ) &&
+	    !(flags & GIT_REF_FORMAT_REFSPEC_SHORTHAND) &&
 		!(is_all_caps_and_underscore(name, (size_t)segment_len) ||
 			((flags & GIT_REF_FORMAT_REFSPEC_PATTERN) && !strcmp("*", name))))
 			goto cleanup;
@@ -778,16 +819,20 @@ int git_reference__normalize_name_lax(
 
 int git_reference_cmp(git_reference *ref1, git_reference *ref2)
 {
+	git_ref_t type1, type2;
 	assert(ref1 && ref2);
 
+	type1 = git_reference_type(ref1);
+	type2 = git_reference_type(ref2);
+
 	/* let's put symbolic refs before OIDs */
-	if (ref1->type != ref2->type)
-		return (ref1->type == GIT_REF_SYMBOLIC) ? -1 : 1;
+	if (type1 != type2)
+		return (type1 == GIT_REF_SYMBOLIC) ? -1 : 1;
 
-	if (ref1->type == GIT_REF_SYMBOLIC)
+	if (type1 == GIT_REF_SYMBOLIC)
 		return strcmp(ref1->target.symbolic, ref2->target.symbolic);
 
-	return git_oid_cmp(&ref1->target.oid, &ref2->target.oid);
+	return git_oid__cmp(&ref1->target.oid, &ref2->target.oid);
 }
 
 static int reference__update_terminal(
@@ -801,7 +846,7 @@ static int reference__update_terminal(
 
 	if (nesting > MAX_NESTING_LEVEL)
 		return GIT_ENOTFOUND;
-	
+
 	error = git_reference_lookup(&ref, repo, ref_name);
 
 	/* If we haven't found the reference at all, create a new reference. */
@@ -809,10 +854,10 @@ static int reference__update_terminal(
 		giterr_clear();
 		return git_reference_create(NULL, repo, ref_name, oid, 0);
 	}
-	
+
 	if (error < 0)
 		return error;
-	
+
 	/* If the ref is a symbolic reference, follow its target. */
 	if (git_reference_type(ref) == GIT_REF_SYMBOLIC) {
 		error = reference__update_terminal(repo, git_reference_symbolic_target(ref), oid,
@@ -822,7 +867,7 @@ static int reference__update_terminal(
 		git_reference_free(ref);
 		error = git_reference_create(NULL, repo, ref_name, oid, 1);
 	}
-	
+
 	return error;
 }
 
@@ -905,15 +950,6 @@ static int peel_error(int error, git_reference *ref, const char* msg)
 	return error;
 }
 
-static int reference_target(git_object **object, git_reference *ref)
-{
-	const git_oid *oid;
-
-	oid = git_reference_target(ref);
-
-	return git_object_lookup(object, git_reference_owner(ref), oid, GIT_OBJ_ANY);
-}
-
 int git_reference_peel(
 		git_object **peeled,
 		git_reference *ref,
@@ -925,10 +961,22 @@ int git_reference_peel(
 
 	assert(ref);
 
-	if ((error = git_reference_resolve(&resolved, ref)) < 0)
-		return peel_error(error, ref, "Cannot resolve reference");
+	if (ref->type == GIT_REF_OID) {
+		resolved = ref;
+	} else {
+		if ((error = git_reference_resolve(&resolved, ref)) < 0)
+			return peel_error(error, ref, "Cannot resolve reference");
+	}
+
+	if (!git_oid_iszero(&resolved->peel)) {
+		error = git_object_lookup(&target,
+			git_reference_owner(ref), &resolved->peel, GIT_OBJ_ANY);
+	} else {
+		error = git_object_lookup(&target,
+			git_reference_owner(ref), &resolved->target.oid, GIT_OBJ_ANY);
+	}
 
-	if ((error = reference_target(&target, resolved)) < 0) {
+	if (error < 0) {
 		peel_error(error, ref, "Cannot retrieve reference target");
 		goto cleanup;
 	}
@@ -940,7 +988,10 @@ int git_reference_peel(
 
 cleanup:
 	git_object_free(target);
-	git_reference_free(resolved);
+
+	if (resolved != ref)
+		git_reference_free(resolved);
+
 	return error;
 }
 
diff --git a/src/refs.h b/src/refs.h
index 7d63c3f..f487ee3 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -13,6 +13,7 @@
 #include "git2/refdb.h"
 #include "strmap.h"
 #include "buffer.h"
+#include "oid.h"
 
 #define GIT_REFS_DIR "refs/"
 #define GIT_REFS_HEADS_DIR GIT_REFS_DIR "heads/"
@@ -25,7 +26,7 @@
 
 #define GIT_SYMREF "ref: "
 #define GIT_PACKEDREFS_FILE "packed-refs"
-#define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled "
+#define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled fully-peeled "
 #define GIT_PACKEDREFS_FILE_MODE 0666
 
 #define GIT_HEAD_FILE "HEAD"
@@ -49,14 +50,14 @@
 
 struct git_reference {
 	git_refdb *db;
-
 	git_ref_t type;
 
 	union {
 		git_oid oid;
 		char *symbolic;
 	} target;
-	
+
+	git_oid peel;
 	char name[0];
 };
 
diff --git a/src/refspec.c b/src/refspec.c
index a51b0cf..a907df8 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -25,6 +25,7 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
 	assert(refspec && input);
 
 	memset(refspec, 0x0, sizeof(git_refspec));
+	refspec->push = !is_fetch;
 
 	lhs = input;
 	if (*lhs == '+') {
@@ -59,7 +60,7 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
 
 	refspec->pattern = is_glob;
 	refspec->src = git__strndup(lhs, llen);
-	flags = GIT_REF_FORMAT_ALLOW_ONELEVEL
+	flags = GIT_REF_FORMAT_ALLOW_ONELEVEL | GIT_REF_FORMAT_REFSPEC_SHORTHAND
 		| (is_glob ? GIT_REF_FORMAT_REFSPEC_PATTERN : 0);
 
 	if (is_fetch) {
@@ -119,6 +120,9 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
 		}
 	}
 
+	refspec->string = git__strdup(input);
+	GITERR_CHECK_ALLOC(refspec->string);
+
 	return 0;
 
  invalid:
@@ -132,6 +136,7 @@ void git_refspec__free(git_refspec *refspec)
 
 	git__free(refspec->src);
 	git__free(refspec->dst);
+	git__free(refspec->string);
 }
 
 const char *git_refspec_src(const git_refspec *refspec)
@@ -144,6 +149,11 @@ const char *git_refspec_dst(const git_refspec *refspec)
 	return refspec == NULL ? NULL : refspec->dst;
 }
 
+const char *git_refspec_string(const git_refspec *refspec)
+{
+	return refspec == NULL ? NULL : refspec->string;
+}
+
 int git_refspec_force(const git_refspec *refspec)
 {
 	assert(refspec);
@@ -264,3 +274,10 @@ int git_refspec_is_wildcard(const git_refspec *spec)
 
 	return (spec->src[strlen(spec->src) - 1] == '*');
 }
+
+git_direction git_refspec_direction(const git_refspec *spec)
+{
+	assert(spec);
+
+	return spec->push;
+}
diff --git a/src/refspec.h b/src/refspec.h
index a7a4dd8..44d484c 100644
--- a/src/refspec.h
+++ b/src/refspec.h
@@ -11,11 +11,13 @@
 #include "buffer.h"
 
 struct git_refspec {
-	struct git_refspec *next;
+	char *string;
 	char *src;
 	char *dst;
 	unsigned int force :1,
+		push : 1,
 		pattern :1,
+		dwim :1,
 		matching :1;
 };
 
diff --git a/src/remote.c b/src/remote.c
index 5685383..6eaaf8b 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -8,6 +8,7 @@
 #include "git2/config.h"
 #include "git2/types.h"
 #include "git2/oid.h"
+#include "git2/net.h"
 
 #include "config.h"
 #include "repository.h"
@@ -19,15 +20,26 @@
 
 #include <regex.h>
 
-static int parse_remote_refspec(git_config *cfg, git_refspec *refspec, const char *var, bool is_fetch)
+static int add_refspec(git_remote *remote, const char *string, bool is_fetch)
 {
-	int error;
-	const char *val;
+	git_refspec *spec;
 
-	if ((error = git_config_get_string(&val, cfg, var)) < 0)
-		return error;
+	spec = git__calloc(1, sizeof(git_refspec));
+	GITERR_CHECK_ALLOC(spec);
+
+	if (git_refspec__parse(spec, string, is_fetch) < 0) {
+		git__free(spec);
+		return -1;
+	}
 
-	return git_refspec__parse(refspec, val, is_fetch);
+	spec->push = !is_fetch;
+	if (git_vector_insert(&remote->refspecs, spec) < 0) {
+		git_refspec__free(spec);
+		git__free(spec);
+		return -1;
+	}
+
+	return 0;
 }
 
 static int download_tags_value(git_remote *remote, git_config *cfg)
@@ -99,7 +111,7 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
 	}
 
 	if (fetch != NULL) {
-		if (git_refspec__parse(&remote->fetch, fetch, true) < 0)
+		if (add_refspec(remote, fetch, true) < 0)
 			goto on_error;
 	}
 
@@ -186,6 +198,18 @@ int git_remote_create_inmemory(git_remote **out, git_repository *repo, const cha
 	return 0;
 }
 
+struct refspec_cb_data {
+	git_remote *remote;
+	int fetch;
+};
+
+static int refspec_cb(const git_config_entry *entry, void *payload)
+{
+	const struct refspec_cb_data *data = (struct refspec_cb_data *)payload;
+
+	return add_refspec(data->remote, entry->value, data->fetch);
+}
+
 int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 {
 	git_remote *remote;
@@ -193,6 +217,8 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 	const char *val;
 	int error = 0;
 	git_config *config;
+	struct refspec_cb_data data;
+
 
 	assert(out && repo && name);
 
@@ -211,7 +237,8 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 	remote->name = git__strdup(name);
 	GITERR_CHECK_ALLOC(remote->name);
 
-	if (git_vector_init(&remote->refs, 32, NULL) < 0) {
+	if ((git_vector_init(&remote->refs, 32, NULL) < 0) ||
+	    (git_vector_init(&remote->refspecs, 2, NULL))) {
 		error = -1;
 		goto cleanup;
 	}
@@ -262,7 +289,9 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 		goto cleanup;
 	}
 
-	error = parse_remote_refspec(config, &remote->fetch, git_buf_cstr(&buf), true);
+	data.remote = remote;
+	data.fetch = true;
+	error = git_config_get_multivar(config, git_buf_cstr(&buf), NULL, refspec_cb, &data);
 	if (error == GIT_ENOTFOUND)
 		error = 0;
 
@@ -277,7 +306,8 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 		goto cleanup;
 	}
 
-	error = parse_remote_refspec(config, &remote->push, git_buf_cstr(&buf), false);
+	data.fetch = false;
+	error = git_config_get_multivar(config, git_buf_cstr(&buf), NULL, refspec_cb, &data);
 	if (error == GIT_ENOTFOUND)
 		error = 0;
 
@@ -300,36 +330,44 @@ cleanup:
 	return error;
 }
 
-static int update_config_refspec(
-	git_config *config,
-	const char *remote_name,
-	const git_refspec *refspec,
-	int git_direction)
+static int update_config_refspec(const git_remote *remote, git_config *config, int direction)
 {
-	git_buf name = GIT_BUF_INIT, value = GIT_BUF_INIT;
+	git_buf name = GIT_BUF_INIT;
+	int push;
+	const char *dir;
+	size_t i;
 	int error = -1;
 
-	if (refspec->src == NULL || refspec->dst == NULL)
-		return 0;
+	push = direction == GIT_DIRECTION_PUSH;
+	dir = push ? "push" : "fetch";
 
-	if (git_buf_printf(
-		&name,
-		"remote.%s.%s",
-		remote_name,
-		git_direction == GIT_DIRECTION_FETCH ? "fetch" : "push") < 0)
-			goto cleanup;
+	if (git_buf_printf(&name, "remote.%s.%s", remote->name, dir) < 0)
+		return -1;
 
-	if (git_refspec__serialize(&value, refspec) < 0)
-		goto cleanup;
+	/* Clear out the existing config */
+	do {
+		error = git_config_delete_entry(config, git_buf_cstr(&name));
+	} while (!error);
 
-	error = git_config_set_string(
-		config,
-		git_buf_cstr(&name),
-		git_buf_cstr(&value));
+	if (error != GIT_ENOTFOUND)
+		return error;
+
+	for (i = 0; i < remote->refspecs.length; i++) {
+		git_refspec *spec = git_vector_get(&remote->refspecs, i);
+
+		if (spec->push != push)
+			continue;
+
+		if ((error = git_config_set_multivar(config, git_buf_cstr(&name), "", spec->string)) < 0) {
+			goto cleanup;
+		}
+	}
+
+	giterr_clear();
+	error = 0;
 
 cleanup:
 	git_buf_free(&name);
-	git_buf_free(&value);
 
 	return error;
 }
@@ -383,19 +421,11 @@ int git_remote_save(const git_remote *remote)
 		}
 	}
 
-	if (update_config_refspec(
-		config,
-		remote->name,
-		&remote->fetch,
-		GIT_DIRECTION_FETCH) < 0)
-			goto on_error;
+	if (update_config_refspec(remote, config, GIT_DIRECTION_FETCH) < 0)
+		goto on_error;
 
-	if (update_config_refspec(
-		config,
-		remote->name,
-		&remote->push,
-		GIT_DIRECTION_PUSH) < 0)
-			goto on_error;
+	if (update_config_refspec(remote, config, GIT_DIRECTION_PUSH) < 0)
+		goto on_error;
 
 	/*
 	 * What action to take depends on the old and new values. This
@@ -482,49 +512,6 @@ int git_remote_set_pushurl(git_remote *remote, const char* url)
 	return 0;
 }
 
-int git_remote_set_fetchspec(git_remote *remote, const char *spec)
-{
-	git_refspec refspec;
-
-	assert(remote && spec);
-
-	if (git_refspec__parse(&refspec, spec, true) < 0)
-		return -1;
-
-	git_refspec__free(&remote->fetch);
-	memcpy(&remote->fetch, &refspec, sizeof(git_refspec));
-
-	return 0;
-}
-
-const git_refspec *git_remote_fetchspec(const git_remote *remote)
-{
-	assert(remote);
-	return &remote->fetch;
-}
-
-int git_remote_set_pushspec(git_remote *remote, const char *spec)
-{
-	git_refspec refspec;
-
-	assert(remote && spec);
-
-	if (git_refspec__parse(&refspec, spec, false) < 0)
-		return -1;
-
-	git_refspec__free(&remote->push);
-	remote->push.src = refspec.src;
-	remote->push.dst = refspec.dst;
-
-	return 0;
-}
-
-const git_refspec *git_remote_pushspec(const git_remote *remote)
-{
-	assert(remote);
-	return &remote->push;
-}
-
 const char* git_remote__urlfordirection(git_remote *remote, int direction)
 {
 	assert(remote);
@@ -646,28 +633,105 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
 	return 0;
 }
 
+static int store_refs(git_remote_head *head, void *payload)
+{
+	git_vector *refs = (git_vector *)payload;
+
+	return git_vector_insert(refs, head);
+}
+
+static int dwim_refspecs(git_vector *refspecs, git_vector *refs)
+{
+	git_buf buf = GIT_BUF_INIT;
+	git_refspec *spec;
+	size_t i, j, pos;
+	git_remote_head key;
+
+	const char* formatters[] = {
+		GIT_REFS_DIR "%s",
+		GIT_REFS_TAGS_DIR "%s",
+		GIT_REFS_HEADS_DIR "%s",
+		NULL
+	};
+
+	git_vector_foreach(refspecs, i, spec) {
+		if (spec->dwim)
+			continue;
+
+		/* shorthand on the lhs */
+		if (git__prefixcmp(spec->src, GIT_REFS_DIR)) {
+			for (j = 0; formatters[j]; j++) {
+				git_buf_clear(&buf);
+				if (git_buf_printf(&buf, formatters[j], spec->src) < 0)
+					return -1;
+
+				key.name = (char *) git_buf_cstr(&buf);
+				if (!git_vector_search(&pos, refs, &key)) {
+					/* we found something to match the shorthand, set src to that */
+					git__free(spec->src);
+					spec->src = git_buf_detach(&buf);
+				}
+			}
+		}
+
+		if (spec->dst && git__prefixcmp(spec->dst, GIT_REFS_DIR)) {
+			/* if it starts with "remotes" then we just prepend "refs/" */
+			if (!git__prefixcmp(spec->dst, "remotes/")) {
+				git_buf_puts(&buf, GIT_REFS_DIR);
+			} else {
+				git_buf_puts(&buf, GIT_REFS_HEADS_DIR);
+			}
+
+			if (git_buf_puts(&buf, spec->dst) < 0)
+				return -1;
+
+			git__free(spec->dst);
+			spec->dst = git_buf_detach(&buf);
+		}
+
+		spec->dwim = 1;
+	}
+
+	git_buf_free(&buf);
+	return 0;
+}
+
+static int remote_head_cmp(const void *_a, const void *_b)
+{
+	const git_remote_head *a = (git_remote_head *) _a;
+	const git_remote_head *b = (git_remote_head *) _b;
+
+	return git__strcmp_cb(a->name, b->name);
+}
+
 int git_remote_download(
 		git_remote *remote,
 		git_transfer_progress_callback progress_cb,
 		void *progress_payload)
 {
 	int error;
+	git_vector refs;
 
 	assert(remote);
 
+	if (git_vector_init(&refs, 16, remote_head_cmp) < 0)
+		return -1;
+
+	if (git_remote_ls(remote, store_refs, &refs) < 0) {
+		return -1;
+	}
+
+	error = dwim_refspecs(&remote->refspecs, &refs);
+	git_vector_free(&refs);
+	if (error < 0)
+		return -1;
+
 	if ((error = git_fetch_negotiate(remote)) < 0)
 		return error;
 
 	return git_fetch_download_pack(remote, progress_cb, progress_payload);
 }
 
-static int update_tips_callback(git_remote_head *head, void *payload)
-{
-	git_vector *refs = (git_vector *)payload;
-
-	return git_vector_insert(refs, head);
-}
-
 static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *update_heads, const char *fetchspec_src)
 {
 	unsigned int i;
@@ -687,21 +751,21 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
 	return 0;
 }
 
-static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_vector *update_heads, git_reference *ref)
+static int remote_head_for_ref(git_remote_head **out, git_refspec *spec, git_vector *update_heads, git_reference *ref)
 {
 	git_reference *resolved_ref = NULL;
 	git_reference *tracking_ref = NULL;
 	git_buf remote_name = GIT_BUF_INIT;
 	int error = 0;
 
-	assert(out && remote && ref);
+	assert(out && spec && ref);
 
 	*out = NULL;
 
 	if ((error = git_reference_resolve(&resolved_ref, ref)) < 0 ||
 		(!git_reference_is_branch(resolved_ref)) ||
 		(error = git_branch_upstream(&tracking_ref, resolved_ref)) < 0 ||
-		(error = git_refspec_transform_l(&remote_name, &remote->fetch, git_reference_name(tracking_ref))) < 0) {
+		(error = git_refspec_transform_l(&remote_name, spec, git_reference_name(tracking_ref))) < 0) {
 		/* Not an error if HEAD is orphaned or no tracking branch */
 		if (error == GIT_ENOTFOUND)
 			error = 0;
@@ -718,9 +782,8 @@ cleanup:
 	return error;
 }
 
-static int git_remote_write_fetchhead(git_remote *remote, git_vector *update_heads)
+static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git_vector *update_heads)
 {
-	struct git_refspec *spec;
 	git_reference *head_ref = NULL;
 	git_fetchhead_ref *fetchhead_ref;
 	git_remote_head *remote_ref, *merge_remote_ref;
@@ -735,8 +798,6 @@ static int git_remote_write_fetchhead(git_remote *remote, git_vector *update_hea
 	if (update_heads->length == 0)
 		return 0;
 
-	spec = &remote->fetch;
-
 	if (git_vector_init(&fetchhead_refs, update_heads->length, git_fetchhead_ref_cmp) < 0)
 		return -1;
 
@@ -746,7 +807,7 @@ static int git_remote_write_fetchhead(git_remote *remote, git_vector *update_hea
 	/* Determine what to merge: if refspec was a wildcard, just use HEAD */
 	if (git_refspec_is_wildcard(spec)) {
 		if ((error = git_reference_lookup(&head_ref, remote->repo, GIT_HEAD_FILE)) < 0 ||
-			(error = remote_head_for_ref(&merge_remote_ref, remote, update_heads, head_ref)) < 0)
+			(error = remote_head_for_ref(&merge_remote_ref, spec, update_heads, head_ref)) < 0)
 				goto cleanup;
 	} else {
 		/* If we're fetching a single refspec, that's the only thing that should be in FETCH_HEAD. */
@@ -786,7 +847,7 @@ cleanup:
 	return error;
 }
 
-int git_remote_update_tips(git_remote *remote)
+static int update_tips_for_spec(git_remote *remote, git_refspec *spec, git_vector *refs)
 {
 	int error = 0, autotag;
 	unsigned int i = 0;
@@ -795,14 +856,11 @@ int git_remote_update_tips(git_remote *remote)
 	git_odb *odb;
 	git_remote_head *head;
 	git_reference *ref;
-	struct git_refspec *spec;
 	git_refspec tagspec;
-	git_vector refs, update_heads;
+	git_vector update_heads;
 
 	assert(remote);
 
-	spec = &remote->fetch;
-	
 	if (git_repository_odb__weakptr(&odb, remote->repo) < 0)
 		return -1;
 
@@ -810,16 +868,12 @@ int git_remote_update_tips(git_remote *remote)
 		return -1;
 
 	/* Make a copy of the transport's refs */
-	if (git_vector_init(&refs, 16, NULL) < 0 ||
-		git_vector_init(&update_heads, 16, NULL) < 0)
+	if (git_vector_init(&update_heads, 16, NULL) < 0)
 		return -1;
 
-	if (git_remote_ls(remote, update_tips_callback, &refs) < 0)
-		goto on_error;
-
 	/* Let's go find HEAD, if it exists. Check only the first ref in the vector. */
-	if (refs.length > 0) {
-		head = (git_remote_head *)refs.contents[0];
+	if (refs->length > 0) {
+		head = git_vector_get(refs, 0);
 
 		if (!strcmp(head->name, GIT_HEAD_FILE))	{
 			if (git_reference_create(&ref, remote->repo, GIT_FETCH_HEAD_FILE, &head->oid, 1) < 0)
@@ -830,15 +884,15 @@ int git_remote_update_tips(git_remote *remote)
 		}
 	}
 
-	for (; i < refs.length; ++i) {
-		head = (git_remote_head *)refs.contents[i];
+	for (; i < refs->length; ++i) {
+		head = git_vector_get(refs, i);
 		autotag = 0;
 
 		/* Ignore malformed ref names (which also saves us from tag^{} */
 		if (!git_reference_is_valid_name(head->name))
 			continue;
 
-		if (git_refspec_src_matches(spec, head->name)) {
+		if (git_refspec_src_matches(spec, head->name) && spec->dst) {
 			if (git_refspec_transform_r(&refname, spec, head->name) < 0)
 				goto on_error;
 		} else if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
@@ -869,7 +923,7 @@ int git_remote_update_tips(git_remote *remote)
 		if (error == GIT_ENOTFOUND)
 			memset(&old, 0, GIT_OID_RAWSZ);
 
-		if (!git_oid_cmp(&old, &head->oid))
+		if (!git_oid__cmp(&old, &head->oid))
 			continue;
 
 		/* In autotag mode, don't overwrite any locally-existing tags */
@@ -886,17 +940,15 @@ int git_remote_update_tips(git_remote *remote)
 	}
 
 	if (git_remote_update_fetchhead(remote) &&
-		(error = git_remote_write_fetchhead(remote, &update_heads)) < 0)
+	    (error = git_remote_write_fetchhead(remote, spec, &update_heads)) < 0)
 		goto on_error;
 
-	git_vector_free(&refs);
 	git_vector_free(&update_heads);
 	git_refspec__free(&tagspec);
 	git_buf_free(&refname);
 	return 0;
 
 on_error:
-	git_vector_free(&refs);
 	git_vector_free(&update_heads);
 	git_refspec__free(&tagspec);
 	git_buf_free(&refname);
@@ -904,6 +956,34 @@ on_error:
 
 }
 
+int git_remote_update_tips(git_remote *remote)
+{
+	git_refspec *spec;
+	git_vector refs;
+	size_t i;
+
+	if (git_vector_init(&refs, 16, NULL) < 0)
+		return -1;
+
+	if (git_remote_ls(remote, store_refs, &refs) < 0)
+		goto on_error;
+
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		if (spec->push)
+			continue;
+
+		if (update_tips_for_spec(remote, spec, &refs) < 0)
+			goto on_error;
+	}
+
+	git_vector_free(&refs);
+	return 0;
+
+on_error:
+	git_vector_free(&refs);
+	return -1;
+}
+
 int git_remote_connected(git_remote *remote)
 {
 	assert(remote);
@@ -933,6 +1013,9 @@ void git_remote_disconnect(git_remote *remote)
 
 void git_remote_free(git_remote *remote)
 {
+	git_refspec *spec;
+	size_t i;
+
 	if (remote == NULL)
 		return;
 
@@ -945,8 +1028,12 @@ void git_remote_free(git_remote *remote)
 
 	git_vector_free(&remote->refs);
 
-	git_refspec__free(&remote->fetch);
-	git_refspec__free(&remote->push);
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		git_refspec__free(spec);
+		git__free(spec);
+	}
+	git_vector_free(&remote->refspecs);
+
 	git__free(remote->url);
 	git__free(remote->pushurl);
 	git__free(remote->name);
@@ -1237,58 +1324,58 @@ static int rename_fetch_refspecs(
 	void *payload)
 {
 	git_config *config;
-	const git_refspec *fetch_refspec;
-	git_buf dst_prefix = GIT_BUF_INIT, serialized = GIT_BUF_INIT;
-	const char* pos;
+	git_buf base = GIT_BUF_INIT, var = GIT_BUF_INIT, val = GIT_BUF_INIT;
+	const git_refspec *spec;
+	size_t i;
 	int error = -1;
 
-	fetch_refspec = git_remote_fetchspec(remote);
-
-	/* Is there a refspec to deal with? */
-	if (fetch_refspec->src == NULL &&
-		fetch_refspec->dst == NULL)
-		return 0;
-
-	if (git_refspec__serialize(&serialized, fetch_refspec) < 0)
+	if (git_buf_printf(&base, "+refs/heads/*:refs/remotes/%s/*", remote->name) < 0)
 		goto cleanup;
 
-	/* Is it an in-memory remote? */
-	if (!remote->name) {
-		error = (callback(git_buf_cstr(&serialized), payload) < 0) ? GIT_EUSER : 0;
-		goto cleanup;
-	}
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		if (spec->push)
+			continue;
 
-	if (git_buf_printf(&dst_prefix, ":refs/remotes/%s/", remote->name) < 0)
-		goto cleanup;
+		/* Every refspec is a problem refspec for an in-memory remote */
+		if (!remote->name) {
+			if (callback(spec->string, payload) < 0) {
+				error = GIT_EUSER;
+				goto cleanup;
+			}
 
-	pos = strstr(git_buf_cstr(&serialized), git_buf_cstr(&dst_prefix));
+			continue;
+		}
 
-	/* Does the dst part of the refspec follow the extected standard format? */
-	if (!pos) {
-		error = (callback(git_buf_cstr(&serialized), payload) < 0) ? GIT_EUSER : 0;
-		goto cleanup;
-	}
+		/* Does the dst part of the refspec follow the extected standard format? */
+		if (strcmp(git_buf_cstr(&base), spec->string)) {
+			if (callback(spec->string, payload) < 0) {
+				error = GIT_EUSER;
+				goto cleanup;
+			}
 
-	if (git_buf_splice(
-		&serialized,
-		pos - git_buf_cstr(&serialized) + strlen(":refs/remotes/"),
-		strlen(remote->name), new_name,
-		strlen(new_name)) < 0)
+			continue;
+		}
+
+		/* If we do want to move it to the new section */
+		if (git_buf_printf(&val, "+refs/heads/*:refs/remotes/%s/*", new_name) < 0)
 			goto cleanup;
 
-	git_refspec__free(&remote->fetch);
+		if (git_buf_printf(&var, "remote.%s.fetch", new_name) < 0)
+			goto cleanup;
 
-	if (git_refspec__parse(&remote->fetch, git_buf_cstr(&serialized), true) < 0)
-		goto cleanup;
+		if (git_repository_config__weakptr(&config, remote->repo) < 0)
+			goto cleanup;
 
-	if (git_repository_config__weakptr(&config, remote->repo) < 0)
-		goto cleanup;
+		if (git_config_set_string(config, git_buf_cstr(&var), git_buf_cstr(&val)) < 0)
+			goto cleanup;
+	}
 
-	error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIRECTION_FETCH);
+	error = 0;
 
 cleanup:
-	git_buf_free(&serialized);
-	git_buf_free(&dst_prefix);
+	git_buf_free(&base);
+	git_buf_free(&var);
+	git_buf_free(&val);
 	return error;
 }
 
@@ -1389,3 +1476,128 @@ int git_remote_is_valid_name(
 	giterr_clear();
 	return error == 0;
 }
+
+git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname)
+{
+	git_refspec *spec;
+	size_t i;
+
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		if (spec->push)
+			continue;
+
+		if (git_refspec_src_matches(spec, refname))
+			return spec;
+	}
+
+	return NULL;
+}
+
+git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname)
+{
+	git_refspec *spec;
+	size_t i;
+
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		if (spec->push)
+			continue;
+
+		if (git_refspec_dst_matches(spec, refname))
+			return spec;
+	}
+
+	return NULL;
+}
+
+void git_remote_clear_refspecs(git_remote *remote)
+{
+	git_refspec *spec;
+	size_t i;
+
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		git_refspec__free(spec);
+		git__free(spec);
+	}
+	git_vector_clear(&remote->refspecs);
+}
+
+int git_remote_add_fetch(git_remote *remote, const char *refspec)
+{
+	return add_refspec(remote, refspec, true);
+}
+
+int git_remote_add_push(git_remote *remote, const char *refspec)
+{
+	return add_refspec(remote, refspec, false);
+}
+
+static int copy_refspecs(git_strarray *array, git_remote *remote, int push)
+{
+	size_t i;
+	git_vector refspecs;
+	git_refspec *spec;
+	char *dup;
+
+	if (git_vector_init(&refspecs, remote->refspecs.length, NULL) < 0)
+		return -1;
+
+	git_vector_foreach(&remote->refspecs, i, spec) {
+		if (spec->push != push)
+			continue;
+
+		if ((dup = git__strdup(spec->string)) == NULL)
+			goto on_error;
+
+		if (git_vector_insert(&refspecs, dup) < 0) {
+			git__free(dup);
+			goto on_error;
+		}
+	}
+
+	array->strings = (char **)refspecs.contents;
+	array->count = refspecs.length;
+
+	return 0;
+
+on_error:
+	git_vector_foreach(&refspecs, i, dup)
+		git__free(dup);
+	git_vector_free(&refspecs);
+
+	return -1;
+}
+
+int git_remote_get_fetch_refspecs(git_strarray *array, git_remote *remote)
+{
+	return copy_refspecs(array, remote, false);
+}
+
+int git_remote_get_push_refspecs(git_strarray *array, git_remote *remote)
+{
+	return copy_refspecs(array, remote, true);
+}
+
+size_t git_remote_refspec_count(git_remote *remote)
+{
+	return remote->refspecs.length;
+}
+
+const git_refspec *git_remote_get_refspec(git_remote *remote, size_t n)
+{
+	return git_vector_get(&remote->refspecs, n);
+}
+
+int git_remote_remove_refspec(git_remote *remote, size_t n)
+{
+	git_refspec *spec;
+
+	assert(remote);
+
+	spec = git_vector_get(&remote->refspecs, n);
+	if (spec) {
+		git_refspec__free(spec);
+		git__free(spec);
+	}
+
+	return git_vector_remove(&remote->refspecs, n);
+}
diff --git a/src/remote.h b/src/remote.h
index 4c1a18a..c9c26b7 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -20,8 +20,7 @@ struct git_remote {
 	char *url;
 	char *pushurl;
 	git_vector refs;
-	struct git_refspec fetch;
-	struct git_refspec push;
+	git_vector refspecs;
 	git_cred_acquire_cb cred_acquire_cb;
 	void *cred_acquire_payload;
 	git_transport *transport;
@@ -37,4 +36,7 @@ struct git_remote {
 const char* git_remote__urlfordirection(struct git_remote *remote, int direction);
 int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url);
 
+git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname);
+git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname);
+
 #endif
diff --git a/src/repository.c b/src/repository.c
index 0ad7449..e6eaf75 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -9,6 +9,7 @@
 
 #include "git2/object.h"
 #include "git2/refdb.h"
+#include "git2/sys/repository.h"
 
 #include "common.h"
 #include "repository.h"
@@ -31,42 +32,71 @@
 
 #define GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
 
-static void drop_odb(git_repository *repo)
+static void set_odb(git_repository *repo, git_odb *odb)
 {
-	if (repo->_odb != NULL) {
-		GIT_REFCOUNT_OWN(repo->_odb, NULL);
-		git_odb_free(repo->_odb);
-		repo->_odb = NULL;
+	if (odb) {
+		GIT_REFCOUNT_OWN(odb, repo);
+		GIT_REFCOUNT_INC(odb);
+	}
+
+	if ((odb = git__swap(repo->_odb, odb)) != NULL) {
+		GIT_REFCOUNT_OWN(odb, NULL);
+		git_odb_free(odb);
 	}
 }
 
-static void drop_refdb(git_repository *repo)
+static void set_refdb(git_repository *repo, git_refdb *refdb)
 {
-	if (repo->_refdb != NULL) {
-		GIT_REFCOUNT_OWN(repo->_refdb, NULL);
-		git_refdb_free(repo->_refdb);
-		repo->_refdb = NULL;
+	if (refdb) {
+		GIT_REFCOUNT_OWN(refdb, repo);
+		GIT_REFCOUNT_INC(refdb);
+	}
+
+	if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) {
+		GIT_REFCOUNT_OWN(refdb, NULL);
+		git_refdb_free(refdb);
 	}
 }
 
-static void drop_config(git_repository *repo)
+static void set_config(git_repository *repo, git_config *config)
 {
-	if (repo->_config != NULL) {
-		GIT_REFCOUNT_OWN(repo->_config, NULL);
-		git_config_free(repo->_config);
-		repo->_config = NULL;
+	if (config) {
+		GIT_REFCOUNT_OWN(config, repo);
+		GIT_REFCOUNT_INC(config);
+	}
+
+	if ((config = git__swap(repo->_config, config)) != NULL) {
+		GIT_REFCOUNT_OWN(config, NULL);
+		git_config_free(config);
 	}
 
 	git_repository__cvar_cache_clear(repo);
 }
 
-static void drop_index(git_repository *repo)
+static void set_index(git_repository *repo, git_index *index)
 {
-	if (repo->_index != NULL) {
-		GIT_REFCOUNT_OWN(repo->_index, NULL);
-		git_index_free(repo->_index);
-		repo->_index = NULL;
+	if (index) {
+		GIT_REFCOUNT_OWN(index, repo);
+		GIT_REFCOUNT_INC(index);
 	}
+
+	if ((index = git__swap(repo->_index, index)) != NULL) {
+		GIT_REFCOUNT_OWN(index, NULL);
+		git_index_free(index);
+	}
+}
+
+void git_repository__cleanup(git_repository *repo)
+{
+	assert(repo);
+
+	git_cache_clear(&repo->objects);
+	git_attr_cache_flush(repo);
+
+	set_config(repo, NULL);
+	set_index(repo, NULL);
+	set_odb(repo, NULL);
+	set_refdb(repo, NULL);
 }
 
 void git_repository_free(git_repository *repo)
@@ -74,17 +104,14 @@ void git_repository_free(git_repository *repo)
 	if (repo == NULL)
 		return;
 
+	git_repository__cleanup(repo);
+
 	git_cache_free(&repo->objects);
-	git_attr_cache_flush(repo);
 	git_submodule_config_free(repo);
 
 	git__free(repo->path_repository);
 	git__free(repo->workdir);
-
-	drop_config(repo);
-	drop_index(repo);
-	drop_odb(repo);
-	drop_refdb(repo);
+	git__free(repo->namespace);
 
 	git__free(repo);
 }
@@ -118,7 +145,7 @@ static git_repository *repository_alloc(void)
 
 	memset(repo, 0x0, sizeof(git_repository));
 
-	if (git_cache_init(&repo->objects, GIT_DEFAULT_CACHE_SIZE, &git_object__free) < 0) {
+	if (git_cache_init(&repo->objects) < 0) {
 		git__free(repo);
 		return NULL;
 	}
@@ -129,6 +156,12 @@ static git_repository *repository_alloc(void)
 	return repo;
 }
 
+int git_repository_new(git_repository **out)
+{
+	*out = repository_alloc();
+	return 0;
+}
+
 static int load_config_data(git_repository *repo)
 {
 	int is_bare;
@@ -368,6 +401,37 @@ static int find_repo(
 	return error;
 }
 
+int git_repository_open_bare(
+	git_repository **repo_ptr,
+	const char *bare_path)
+{
+	int error;
+	git_buf path = GIT_BUF_INIT;
+	git_repository *repo = NULL;
+
+	if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0)
+		return error;
+
+	if (!valid_repository_path(&path)) {
+		git_buf_free(&path);
+		giterr_set(GITERR_REPOSITORY, "Path is not a repository: %s", bare_path);
+		return GIT_ENOTFOUND;
+	}
+
+	repo = repository_alloc();
+	GITERR_CHECK_ALLOC(repo);
+
+	repo->path_repository = git_buf_detach(&path);
+	GITERR_CHECK_ALLOC(repo->path_repository);
+
+	/* of course we're bare! */
+	repo->is_bare = 1;
+	repo->workdir = NULL;
+
+	*repo_ptr = repo;
+	return 0;
+}
+
 int git_repository_open_ext(
 	git_repository **repo_ptr,
 	const char *start_path,
@@ -511,39 +575,47 @@ on_error:
 	return error;
 }
 
-int git_repository_config__weakptr(git_config **out, git_repository *repo)
+static const char *path_unless_empty(git_buf *buf)
 {
-	if (repo->_config == NULL) {
-		git_buf global_buf = GIT_BUF_INIT, xdg_buf = GIT_BUF_INIT, system_buf = GIT_BUF_INIT;
-		int res;
-
-		const char *global_config_path = NULL;
-		const char *xdg_config_path = NULL;
-		const char *system_config_path = NULL;
-
-		if (git_config_find_global_r(&global_buf) == 0)
-			global_config_path = global_buf.ptr;
+	return git_buf_len(buf) > 0 ? git_buf_cstr(buf) : NULL;
+}
 
-		if (git_config_find_xdg_r(&xdg_buf) == 0)
-			xdg_config_path = xdg_buf.ptr;
+int git_repository_config__weakptr(git_config **out, git_repository *repo)
+{
+	int error = 0;
 
-		if (git_config_find_system_r(&system_buf) == 0)
-			system_config_path = system_buf.ptr;
+	if (repo->_config == NULL) {
+		git_buf global_buf = GIT_BUF_INIT;
+		git_buf xdg_buf = GIT_BUF_INIT;
+		git_buf system_buf = GIT_BUF_INIT;
+		git_config *config;
 
-		res = load_config(&repo->_config, repo, global_config_path, xdg_config_path, system_config_path);
+		git_config_find_global_r(&global_buf);
+		git_config_find_xdg_r(&xdg_buf);
+		git_config_find_system_r(&system_buf);
+
+		error = load_config(
+			&config, repo,
+			path_unless_empty(&global_buf),
+			path_unless_empty(&xdg_buf),
+			path_unless_empty(&system_buf));
+		if (!error) {
+			GIT_REFCOUNT_OWN(config, repo);
+
+			config = git__compare_and_swap(&repo->_config, NULL, config);
+			if (config != NULL) {
+				GIT_REFCOUNT_OWN(config, NULL);
+				git_config_free(config);
+			}
+		}
 
 		git_buf_free(&global_buf);
 		git_buf_free(&xdg_buf);
 		git_buf_free(&system_buf);
-
-		if (res < 0)
-			return -1;
-
-		GIT_REFCOUNT_OWN(repo->_config, repo);
 	}
 
 	*out = repo->_config;
-	return 0;
+	return error;
 }
 
 int git_repository_config(git_config **out, git_repository *repo)
@@ -558,36 +630,37 @@ int git_repository_config(git_config **out, git_repository *repo)
 void git_repository_set_config(git_repository *repo, git_config *config)
 {
 	assert(repo && config);
-
-	drop_config(repo);
-
-	repo->_config = config;
-	GIT_REFCOUNT_OWN(repo->_config, repo);
-	GIT_REFCOUNT_INC(repo->_config);
+	set_config(repo, config);
 }
 
 int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
 {
+	int error = 0;
+
 	assert(repo && out);
 
 	if (repo->_odb == NULL) {
 		git_buf odb_path = GIT_BUF_INIT;
-		int res;
+		git_odb *odb;
 
-		if (git_buf_joinpath(&odb_path, repo->path_repository, GIT_OBJECTS_DIR) < 0)
-			return -1;
+		git_buf_joinpath(&odb_path, repo->path_repository, GIT_OBJECTS_DIR);
 
-		res = git_odb_open(&repo->_odb, odb_path.ptr);
-		git_buf_free(&odb_path); /* done with path */
+		error = git_odb_open(&odb, odb_path.ptr);
+		if (!error) {
+			GIT_REFCOUNT_OWN(odb, repo);
 
-		if (res < 0)
-			return -1;
+			odb = git__compare_and_swap(&repo->_odb, NULL, odb);
+			if (odb != NULL) {
+				GIT_REFCOUNT_OWN(odb, NULL);
+				git_odb_free(odb);
+			}
+		}
 
-		GIT_REFCOUNT_OWN(repo->_odb, repo);
+		git_buf_free(&odb_path);
 	}
 
 	*out = repo->_odb;
-	return 0;
+	return error;
 }
 
 int git_repository_odb(git_odb **out, git_repository *repo)
@@ -602,31 +675,32 @@ int git_repository_odb(git_odb **out, git_repository *repo)
 void git_repository_set_odb(git_repository *repo, git_odb *odb)
 {
 	assert(repo && odb);
-
-	drop_odb(repo);
-
-	repo->_odb = odb;
-	GIT_REFCOUNT_OWN(repo->_odb, repo);
-	GIT_REFCOUNT_INC(odb);
+	set_odb(repo, odb);
 }
 
 int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
 {
+	int error = 0;
+
 	assert(out && repo);
 
 	if (repo->_refdb == NULL) {
-		int res;
-
-		res = git_refdb_open(&repo->_refdb, repo);
+		git_refdb *refdb;
 
-		if (res < 0)
-			return -1;
+		error = git_refdb_open(&refdb, repo);
+		if (!error) {
+			GIT_REFCOUNT_OWN(refdb, repo);
 
-		GIT_REFCOUNT_OWN(repo->_refdb, repo);
+			refdb = git__compare_and_swap(&repo->_refdb, NULL, refdb);
+			if (refdb != NULL) {
+				GIT_REFCOUNT_OWN(refdb, NULL);
+				git_refdb_free(refdb);
+			}
+		}
 	}
 
 	*out = repo->_refdb;
-	return 0;
+	return error;
 }
 
 int git_repository_refdb(git_refdb **out, git_repository *repo)
@@ -640,40 +714,40 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
 
 void git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
 {
-	assert (repo && refdb);
-
-	drop_refdb(repo);
-
-	repo->_refdb = refdb;
-	GIT_REFCOUNT_OWN(repo->_refdb, repo);
-	GIT_REFCOUNT_INC(refdb);
+	assert(repo && refdb);
+	set_refdb(repo, refdb);
 }
 
 int git_repository_index__weakptr(git_index **out, git_repository *repo)
 {
+	int error = 0;
+
 	assert(out && repo);
 
 	if (repo->_index == NULL) {
-		int res;
 		git_buf index_path = GIT_BUF_INIT;
+		git_index *index;
 
-		if (git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE) < 0)
-			return -1;
+		git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE);
 
-		res = git_index_open(&repo->_index, index_path.ptr);
-		git_buf_free(&index_path); /* done with path */
+		error = git_index_open(&index, index_path.ptr);
+		if (!error) {
+			GIT_REFCOUNT_OWN(index, repo);
 
-		if (res < 0)
-			return -1;
+			index = git__compare_and_swap(&repo->_index, NULL, index);
+			if (index != NULL) {
+				GIT_REFCOUNT_OWN(index, NULL);
+				git_index_free(index);
+			}
 
-		GIT_REFCOUNT_OWN(repo->_index, repo);
+			error = git_index_set_caps(repo->_index, GIT_INDEXCAP_FROM_OWNER);
+		}
 
-		if (git_index_set_caps(repo->_index, GIT_INDEXCAP_FROM_OWNER) < 0)
-			return -1;
+		git_buf_free(&index_path);
 	}
 
 	*out = repo->_index;
-	return 0;
+	return error;
 }
 
 int git_repository_index(git_index **out, git_repository *repo)
@@ -688,12 +762,24 @@ int git_repository_index(git_index **out, git_repository *repo)
 void git_repository_set_index(git_repository *repo, git_index *index)
 {
 	assert(repo && index);
+	set_index(repo, index);
+}
 
-	drop_index(repo);
+int git_repository_set_namespace(git_repository *repo, const char *namespace)
+{
+	git__free(repo->namespace);
 
-	repo->_index = index;
-	GIT_REFCOUNT_OWN(repo->_index, repo);
-	GIT_REFCOUNT_INC(index);
+	if (namespace == NULL) {
+		repo->namespace = NULL;
+		return 0;
+	}
+
+	return (repo->namespace = git__strdup(namespace)) ? 0 : -1;
+}
+
+const char *git_repository_get_namespace(git_repository *repo)
+{
+	return repo->namespace;
 }
 
 static int check_repositoryformatversion(git_config *config)
@@ -1383,14 +1469,13 @@ static int at_least_one_cb(const char *refname, void *payload)
 
 static int repo_contains_no_reference(git_repository *repo)
 {
-	int error;
-	
-	error = git_reference_foreach(repo, GIT_REF_LISTALL, at_least_one_cb, NULL);
+	int error = git_reference_foreach(repo, GIT_REF_LISTALL, at_least_one_cb, NULL);
 
 	if (error == GIT_EUSER)
 		return 0;
-
-	return error == 0 ? 1 : error;
+	if (!error)
+		return 1;
+	return error;
 }
 
 int git_repository_is_empty(git_repository *repo)
diff --git a/src/repository.h b/src/repository.h
index cc2f8c2..bd5f63d 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -12,6 +12,7 @@
 #include "git2/odb.h"
 #include "git2/repository.h"
 #include "git2/object.h"
+#include "git2/config.h"
 
 #include "index.h"
 #include "cache.h"
@@ -31,7 +32,13 @@
 /** Cvar cache identifiers */
 typedef enum {
 	GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */
-	GIT_CVAR_EOL, /* core.eol */
+	GIT_CVAR_EOL,           /* core.eol */
+	GIT_CVAR_SYMLINKS,      /* core.symlinks */
+	GIT_CVAR_IGNORECASE,    /* core.ignorecase */
+	GIT_CVAR_FILEMODE,      /* core.filemode */
+	GIT_CVAR_IGNORESTAT,    /* core.ignorestat */
+	GIT_CVAR_TRUSTCTIME,    /* core.trustctime */
+	GIT_CVAR_ABBREV,        /* core.abbrev */
 	GIT_CVAR_CACHE_MAX
 } git_cvar_cached;
 
@@ -67,7 +74,21 @@ typedef enum {
 #else
 	GIT_EOL_NATIVE = GIT_EOL_LF,
 #endif
-	GIT_EOL_DEFAULT = GIT_EOL_NATIVE
+	GIT_EOL_DEFAULT = GIT_EOL_NATIVE,
+
+	/* core.symlinks: bool */
+	GIT_SYMLINKS_DEFAULT = GIT_CVAR_TRUE,
+	/* core.ignorecase */
+	GIT_IGNORECASE_DEFAULT = GIT_CVAR_FALSE,
+	/* core.filemode */
+	GIT_FILEMODE_DEFAULT = GIT_CVAR_TRUE,
+	/* core.ignorestat */
+	GIT_IGNORESTAT_DEFAULT = GIT_CVAR_FALSE,
+	/* core.trustctime */
+	GIT_TRUSTCTIME_DEFAULT = GIT_CVAR_TRUE,
+	/* core.abbrev */
+	GIT_ABBREV_DEFAULT = 7,
+
 } git_cvar_value;
 
 /* internal repository init flags */
@@ -90,6 +111,7 @@ struct git_repository {
 
 	char *path_repository;
 	char *workdir;
+	char *namespace;
 
 	unsigned is_bare:1;
 	unsigned int lru_counter;
diff --git a/src/revparse.c b/src/revparse.c
index 74635ed..8a22a04 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -16,7 +16,7 @@
 
 static int disambiguate_refname(git_reference **out, git_repository *repo, const char *refname)
 {
-	int error, i;
+	int error = 0, i;
 	bool fallbackmode = true;
 	git_reference *ref;
 	git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
diff --git a/src/signature.c b/src/signature.c
index 164e8eb..649dbcd 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -69,7 +69,7 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
 	if (p->name == NULL || p->email == NULL ||
 		p->name[0] == '\0' || p->email[0] == '\0') {
 		git_signature_free(p);
-		return -1;
+		return signature_error("Empty name or email");
 	}
 		
 	p->when.time = time;
diff --git a/src/submodule.c b/src/submodule.c
index 2fdaf2f..0a22e3b 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -7,6 +7,7 @@
 
 #include "common.h"
 #include "git2/config.h"
+#include "git2/sys/config.h"
 #include "git2/types.h"
 #include "git2/repository.h"
 #include "git2/index.h"
diff --git a/src/tag.c b/src/tag.c
index 735ba7e..a4f2e25 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -13,20 +13,17 @@
 #include "git2/object.h"
 #include "git2/repository.h"
 #include "git2/signature.h"
+#include "git2/odb_backend.h"
 
-void git_tag__free(git_tag *tag)
+void git_tag__free(void *_tag)
 {
+	git_tag *tag = _tag;
 	git_signature_free(tag->tagger);
 	git__free(tag->message);
 	git__free(tag->tag_name);
 	git__free(tag);
 }
 
-const git_oid *git_tag_id(const git_tag *c)
-{
-	return git_object_id((const git_object *)c);
-}
-
 int git_tag_target(git_object **target, const git_tag *t)
 {
 	assert(t);
@@ -68,7 +65,7 @@ static int tag_error(const char *str)
 	return -1;
 }
 
-int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
+static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end)
 {
 	static const char *tag_types[] = {
 		NULL, "commit\n", "tree\n", "blob\n", "tag\n"
@@ -78,8 +75,6 @@ int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
 	size_t text_len;
 	char *search;
 
-	const char *buffer_end = buffer + length;
-
 	if (git_oid__parse(&tag->target, &buffer, buffer_end, "object ") < 0)
 		return tag_error("Object field invalid");
 
@@ -156,6 +151,15 @@ int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
 	return 0;
 }
 
+int git_tag__parse(void *_tag, git_odb_object *odb_obj)
+{
+	git_tag *tag = _tag;
+	const char *buffer = git_odb_object_data(odb_obj);
+	const char *buffer_end = buffer + git_odb_object_size(odb_obj);
+
+	return tag_parse(tag, buffer, buffer_end);
+}
+
 static int retrieve_tag_reference(
 	git_reference **tag_reference_out,
 	git_buf *ref_name_out,
@@ -276,23 +280,23 @@ cleanup:
 }
 
 int git_tag_create(
-		git_oid *oid,
-		git_repository *repo,
-		const char *tag_name,
-		const git_object *target,
-		const git_signature *tagger,
-		const char *message,
-		int allow_ref_overwrite)
+	git_oid *oid,
+	git_repository *repo,
+	const char *tag_name,
+	const git_object *target,
+	const git_signature *tagger,
+	const char *message,
+	int allow_ref_overwrite)
 {
 	return git_tag_create__internal(oid, repo, tag_name, target, tagger, message, allow_ref_overwrite, 1);
 }
 
 int git_tag_create_lightweight(
-		git_oid *oid,
-		git_repository *repo,
-		const char *tag_name,
-		const git_object *target,
-		int allow_ref_overwrite)
+	git_oid *oid,
+	git_repository *repo,
+	const char *tag_name,
+	const git_object *target,
+	int allow_ref_overwrite)
 {
 	return git_tag_create__internal(oid, repo, tag_name, target, NULL, NULL, allow_ref_overwrite, 0);
 }
@@ -316,14 +320,14 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
 		return -1;
 
 	/* validate the buffer */
-	if (git_tag__parse_buffer(&tag, buffer, strlen(buffer)) < 0)
+	if (tag_parse(&tag, buffer, buffer + strlen(buffer)) < 0)
 		return -1;
 
 	/* validate the target */
 	if (git_odb_read(&target_obj, odb, &tag.target) < 0)
 		goto on_error;
 
-	if (tag.type != target_obj->raw.type) {
+	if (tag.type != target_obj->cached.type) {
 		giterr_set(GITERR_TAG, "The type for the given target is invalid");
 		goto on_error;
 	}
@@ -389,14 +393,8 @@ int git_tag_delete(git_repository *repo, const char *tag_name)
 
 	if ((error = git_reference_delete(tag_ref)) == 0)
 		git_reference_free(tag_ref);
-	
-	return error;
-}
 
-int git_tag__parse(git_tag *tag, git_odb_object *obj)
-{
-	assert(tag);
-	return git_tag__parse_buffer(tag, obj->raw.data, obj->raw.len);
+	return error;
 }
 
 typedef struct {
diff --git a/src/tag.h b/src/tag.h
index c8e421e..d0cd393 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -22,8 +22,7 @@ struct git_tag {
 	char *message;
 };
 
-void git_tag__free(git_tag *tag);
-int git_tag__parse(git_tag *tag, git_odb_object *obj);
-int git_tag__parse_buffer(git_tag *tag, const char *data, size_t len);
+void git_tag__free(void *tag);
+int git_tag__parse(void *tag, git_odb_object *obj);
 
 #endif
diff --git a/src/thread-utils.h b/src/thread-utils.h
index 2ca290a..49b5f3b 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -18,6 +18,28 @@ typedef struct {
 #endif
 } git_atomic;
 
+#ifdef GIT_ARCH_64
+
+typedef struct {
+#if defined(GIT_WIN32)
+	__int64 val;
+#else
+	int64_t val;
+#endif
+} git_atomic64;
+
+typedef git_atomic64 git_atomic_ssize;
+
+#define git_atomic_ssize_add git_atomic64_add
+
+#else
+
+typedef git_atomic git_atomic_ssize;
+
+#define git_atomic_ssize_add git_atomic_add
+
+#endif
+
 GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
 {
 	a->val = val;
@@ -57,6 +79,17 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
 #endif
 }
 
+GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
+{
+#if defined(GIT_WIN32)
+	return InterlockedExchangeAdd(&a->val, addend);
+#elif defined(__GNUC__)
+	return __sync_add_and_fetch(&a->val, addend);
+#else
+#	error "Unsupported architecture for atomic operations"
+#endif
+}
+
 GIT_INLINE(int) git_atomic_dec(git_atomic *a)
 {
 #if defined(GIT_WIN32)
@@ -68,6 +101,35 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
 #endif
 }
 
+GIT_INLINE(void *) git___compare_and_swap(
+	volatile void **ptr, void *oldval, void *newval)
+{
+	volatile void *foundval;
+#if defined(GIT_WIN32)
+	foundval = InterlockedCompareExchangePointer(ptr, newval, oldval);
+#elif defined(__GNUC__)
+	foundval = __sync_val_compare_and_swap(ptr, oldval, newval);
+#else
+#	error "Unsupported architecture for atomic operations"
+#endif
+	return (foundval == oldval) ? oldval : newval;
+}
+
+#ifdef GIT_ARCH_64
+
+GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
+{
+#if defined(GIT_WIN32)
+	return InterlockedExchangeAdd64(&a->val, addend);
+#elif defined(__GNUC__)
+	return __sync_add_and_fetch(&a->val, addend);
+#else
+#	error "Unsupported architecture for atomic operations"
+#endif
+}
+
+#endif
+
 #else
 
 #define git_thread unsigned int
@@ -96,13 +158,55 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
 	return ++a->val;
 }
 
+GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
+{
+	a->val += addend;
+	return a->val;
+}
+
 GIT_INLINE(int) git_atomic_dec(git_atomic *a)
 {
 	return --a->val;
 }
 
+GIT_INLINE(void *) git___compare_and_swap(
+	volatile void **ptr, void *oldval, void *newval)
+{
+	if (*ptr == oldval)
+		*ptr = newval;
+	else
+		oldval = newval;
+	return oldval;
+}
+
+#ifdef GIT_ARCH_64
+
+GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
+{
+	a->val += addend;
+	return a->val;
+}
+
+#endif
+
 #endif
 
+/* Atomically replace oldval with newval
+ * @return oldval if it was replaced or newval if it was not
+ */
+#define git__compare_and_swap(P,O,N) \
+	git___compare_and_swap((volatile void **)P, O, N)
+
+#define git__swap(ptr, val) git__compare_and_swap(&ptr, ptr, val)
+
 extern int git_online_cpus(void);
 
+#if defined(GIT_THREADS) && defined(GIT_WIN32)
+# define GIT_MEMORY_BARRIER MemoryBarrier()
+#elif defined(GIT_THREADS)
+# define GIT_MEMORY_BARRIER __sync_synchronize()
+#else
+# define GIT_MEMORY_BARRIER /* noop */
+#endif
+
 #endif /* INCLUDE_thread_utils_h__ */
diff --git a/src/transports/local.c b/src/transports/local.c
index 8af970e..8b4d50c 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -282,7 +282,7 @@ static int local_push_copy_object(
 		odb_obj_size) < 0 ||
 		odb_stream->finalize_write(&remote_odb_obj_oid, odb_stream) < 0) {
 		error = -1;
-	} else if (git_oid_cmp(&obj->id, &remote_odb_obj_oid) != 0) {
+	} else if (git_oid__cmp(&obj->id, &remote_odb_obj_oid) != 0) {
 		giterr_set(GITERR_ODB, "Error when writing object to remote odb "
 			"during local push operation. Remote odb object oid does not "
 			"match local oid.");
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 8acedeb..a5ad1e4 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -5,6 +5,7 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 #include "git2.h"
+#include "git2/odb_backend.h"
 
 #include "smart.h"
 #include "refs.h"
@@ -806,13 +807,13 @@ int git_smart__push(git_transport *transport, git_push *push)
 	transport_smart *t = (transport_smart *)transport;
 	git_smart_subtransport_stream *s;
 	git_buf pktline = GIT_BUF_INIT;
-	int error = -1;
+	int error = -1, need_pack = 0;
+	push_spec *spec;
+	unsigned int i;
 
 #ifdef PUSH_DEBUG
 {
 	git_remote_head *head;
-	push_spec *spec;
-	unsigned int i;
 	char hex[41]; hex[40] = '\0';
 
 	git_vector_foreach(&push->remote->refs, i, head) {
@@ -830,10 +831,23 @@ int git_smart__push(git_transport *transport, git_push *push)
 }
 #endif
 
+	/*
+	 * Figure out if we need to send a packfile; which is in all
+	 * cases except when we only send delete commands
+	 */
+	git_vector_foreach(&push->specs, i, spec) {
+		if (spec->lref) {
+			need_pack = 1;
+			break;
+		}
+	}
+
 	if (git_smart__get_push_stream(t, &s) < 0 ||
 		gen_pktline(&pktline, push) < 0 ||
-		s->write(s, git_buf_cstr(&pktline), git_buf_len(&pktline)) < 0 ||
-		git_packbuilder_foreach(push->pb, &stream_thunk, s) < 0)
+		s->write(s, git_buf_cstr(&pktline), git_buf_len(&pktline)) < 0)
+		goto on_error;
+
+	if (need_pack && git_packbuilder_foreach(push->pb, &stream_thunk, s) < 0)
 		goto on_error;
 
 	/* If we sent nothing or the server doesn't support report-status, then
diff --git a/src/tree.c b/src/tree.c
index 17b3c37..79cbcff 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -219,8 +219,9 @@ git_tree_entry *git_tree_entry_dup(const git_tree_entry *entry)
 	return copy;
 }
 
-void git_tree__free(git_tree *tree)
+void git_tree__free(void *_tree)
 {
+	git_tree *tree = _tree;
 	size_t i;
 	git_tree_entry *e;
 
@@ -231,16 +232,6 @@ void git_tree__free(git_tree *tree)
 	git__free(tree);
 }
 
-const git_oid *git_tree_id(const git_tree *t)
-{
-	return git_object_id((const git_object *)t);
-}
-
-git_repository *git_tree_owner(const git_tree *t)
-{
-	return git_object_owner((const git_object *)t);
-}
-
 git_filemode_t git_tree_entry_filemode(const git_tree_entry *entry)
 {
 	return (git_filemode_t)entry->attr;
@@ -371,8 +362,12 @@ static int tree_error(const char *str, const char *path)
 	return -1;
 }
 
-static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buffer_end)
+int git_tree__parse(void *_tree, git_odb_object *odb_obj)
 {
+	git_tree *tree = _tree;
+	const char *buffer = git_odb_object_data(odb_obj);
+	const char *buffer_end = buffer + git_odb_object_size(odb_obj);
+
 	if (git_vector_init(&tree->entries, DEFAULT_TREE_SIZE, entry_sort_cmp) < 0)
 		return -1;
 
@@ -416,12 +411,6 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
 	return 0;
 }
 
-int git_tree__parse(git_tree *tree, git_odb_object *obj)
-{
-	assert(tree);
-	return tree_parse_buffer(tree, (char *)obj->raw.data, (char *)obj->raw.data + obj->raw.len);
-}
-
 static size_t find_next_dir(const char *dirname, git_index *index, size_t start)
 {
 	size_t dirlen, i, entries = git_index_entrycount(index);
@@ -525,7 +514,6 @@ static int write_tree(
 			/* Write out the subtree */
 			written = write_tree(&sub_oid, repo, index, subdir, i);
 			if (written < 0) {
-				tree_error("Failed to write subtree", subdir);
 				git__free(subdir);
 				goto on_error;
 			} else {
diff --git a/src/tree.h b/src/tree.h
index b77bfd9..7cb2dd3 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -37,8 +37,8 @@ GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
 
 extern int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2);
 
-void git_tree__free(git_tree *tree);
-int git_tree__parse(git_tree *tree, git_odb_object *obj);
+void git_tree__free(void *tree);
+int git_tree__parse(void *tree, git_odb_object *obj);
 
 /**
  * Lookup the first position in the tree with a given prefix.
diff --git a/src/unix/posix.h b/src/unix/posix.h
index f4886c5..9c9f837 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -21,6 +21,8 @@
 /* The OpenBSD realpath function behaves differently */
 #if !defined(__OpenBSD__)
 # define p_realpath(p, po) realpath(p, po)
+#else
+char *p_realpath(const char *, char *);
 #endif
 
 #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
diff --git a/src/util.c b/src/util.c
index 8e83d29..8c8bc1a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -11,6 +11,7 @@
 #include <ctype.h>
 #include "posix.h"
 #include "fileops.h"
+#include "cache.h"
 
 #ifdef _MSC_VER
 # include <Shlwapi.h>
@@ -38,7 +39,6 @@ int git_libgit2_capabilities()
 /* Declarations for tuneable settings */
 extern size_t git_mwindow__window_size;
 extern size_t git_mwindow__mapped_limit;
-extern size_t git_odb__cache_size;
 
 static int config_level_to_futils_dir(int config_level)
 {
@@ -94,12 +94,25 @@ int git_libgit2_opts(int key, ...)
 			error = git_futils_dirs_set(error, va_arg(ap, const char *));
 		break;
 
-	case GIT_OPT_GET_ODB_CACHE_SIZE:
-		*(va_arg(ap, size_t *)) = git_odb__cache_size;
+	case GIT_OPT_SET_CACHE_OBJECT_LIMIT:
+		{
+			git_otype type = (git_otype)va_arg(ap, int);
+			size_t size = va_arg(ap, size_t);
+			error = git_cache_set_max_object_size(type, size);
+			break;
+		}
+
+	case GIT_OPT_SET_CACHE_MAX_SIZE:
+		git_cache__max_storage = va_arg(ap, ssize_t);
+		break;
+
+	case GIT_OPT_ENABLE_CACHING:
+		git_cache__enabled = (va_arg(ap, int) != 0);
 		break;
 
-	case GIT_OPT_SET_ODB_CACHE_SIZE:
-		git_odb__cache_size = va_arg(ap, size_t);
+	case GIT_OPT_GET_CACHED_MEMORY:
+		*(va_arg(ap, ssize_t *)) = git_cache__current_storage.val;
+		*(va_arg(ap, ssize_t *)) = git_cache__max_storage;
 		break;
 	}
 
diff --git a/src/util.h b/src/util.h
index c0f2719..687afe0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_util_h__
 #define INCLUDE_util_h__
 
+#include "common.h"
+
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 #define bitsizeof(x) (CHAR_BIT * sizeof(x))
 #define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
@@ -186,20 +188,20 @@ extern int git__strncmp(const char *a, const char *b, size_t sz);
 extern int git__strncasecmp(const char *a, const char *b, size_t sz);
 
 typedef struct {
-	short refcount;
+	git_atomic refcount;
 	void *owner;
 } git_refcount;
 
 typedef void (*git_refcount_freeptr)(void *r);
 
 #define GIT_REFCOUNT_INC(r) { \
-	((git_refcount *)(r))->refcount++; \
+	git_atomic_inc(&((git_refcount *)(r))->refcount);	\
 }
 
 #define GIT_REFCOUNT_DEC(_r, do_free) { \
 	git_refcount *r = (git_refcount *)(_r); \
-	r->refcount--; \
-	if (r->refcount <= 0 && r->owner == NULL) { do_free(_r); } \
+	int val = git_atomic_dec(&r->refcount); \
+	if (val <= 0 && r->owner == NULL) { do_free(_r); } \
 }
 
 #define GIT_REFCOUNT_OWN(r, o) { \
@@ -304,7 +306,7 @@ int git__date_parse(git_time_t *out, const char *date);
 
 /*
  * Unescapes a string in-place.
- * 
+ *
  * Edge cases behavior:
  * - "jackie\" -> "jacky\"
  * - "chan\\" -> "chan\"
diff --git a/src/vector.c b/src/vector.c
index f4a818e..5ba2fab 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -277,15 +277,13 @@ void git_vector_swap(git_vector *a, git_vector *b)
 
 int git_vector_resize_to(git_vector *v, size_t new_length)
 {
-	if (new_length <= v->length)
-		return 0;
-
 	if (new_length > v->_alloc_size &&
 		resize_vector(v, new_length) < 0)
 		return -1;
 
-	memset(&v->contents[v->length], 0,
-		sizeof(void *) * (new_length - v->length));
+	if (new_length > v->length)
+		memset(&v->contents[v->length], 0,
+			sizeof(void *) * (new_length - v->length));
 
 	v->length = new_length;
 
diff --git a/src/win32/pthread.c b/src/win32/pthread.c
index 105f4b8..232709e 100644
--- a/src/win32/pthread.c
+++ b/src/win32/pthread.c
@@ -14,22 +14,28 @@ int pthread_create(
 	void *GIT_RESTRICT arg)
 {
 	GIT_UNUSED(attr);
-	*thread = (pthread_t) CreateThread(
+	*thread = CreateThread(
 		NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, arg, 0, NULL);
 	return *thread ? 0 : -1;
 }
 
 int pthread_join(pthread_t thread, void **value_ptr)
 {
-	int ret;
-	ret = WaitForSingleObject(thread, INFINITE);
-	if (ret && value_ptr)
-		GetExitCodeThread(thread, (void*) value_ptr);
-	return -(!!ret);
+	DWORD ret = WaitForSingleObject(thread, INFINITE);
+
+	if (ret == WAIT_OBJECT_0) {
+		if (value_ptr != NULL)
+			GetExitCodeThread(thread, (void *)value_ptr);
+		CloseHandle(thread);
+		return 0;
+	}
+
+	return -1;
 }
 
-int pthread_mutex_init(pthread_mutex_t *GIT_RESTRICT mutex,
-						const pthread_mutexattr_t *GIT_RESTRICT mutexattr)
+int pthread_mutex_init(
+	pthread_mutex_t *GIT_RESTRICT mutex,
+	const pthread_mutexattr_t *GIT_RESTRICT mutexattr)
 {
 	GIT_UNUSED(mutexattr);
 	InitializeCriticalSection(mutex);
diff --git a/src/win32/pthread.h b/src/win32/pthread.h
index a219a01..8277ecf 100644
--- a/src/win32/pthread.h
+++ b/src/win32/pthread.h
@@ -25,13 +25,16 @@ typedef HANDLE pthread_cond_t;
 
 #define PTHREAD_MUTEX_INITIALIZER {(void*)-1};
 
-int pthread_create(pthread_t *GIT_RESTRICT,
-					const pthread_attr_t *GIT_RESTRICT,
-					void *(*start_routine)(void*), void *__restrict);
+int pthread_create(
+	pthread_t *GIT_RESTRICT,
+	const pthread_attr_t *GIT_RESTRICT,
+	void *(*start_routine)(void*),
+	void *__restrict);
 
 int pthread_join(pthread_t, void **);
 
-int pthread_mutex_init(pthread_mutex_t *GIT_RESTRICT, const pthread_mutexattr_t *GIT_RESTRICT);
+int pthread_mutex_init(
+	pthread_mutex_t *GIT_RESTRICT, const pthread_mutexattr_t *GIT_RESTRICT);
 int pthread_mutex_destroy(pthread_mutex_t *);
 int pthread_mutex_lock(pthread_mutex_t *);
 int pthread_mutex_unlock(pthread_mutex_t *);
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c
index 0748b22..eb129f3 100644
--- a/tests-clar/checkout/tree.c
+++ b/tests-clar/checkout/tree.c
@@ -501,3 +501,28 @@ void test_checkout_tree__issue_1397(void)
 
 	git_object_free(tree);
 }
+
+void test_checkout_tree__can_write_to_empty_dirs(void)
+{
+	git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
+	git_oid oid;
+	git_object *obj = NULL;
+
+	assert_on_branch(g_repo, "master");
+
+	cl_git_pass(p_mkdir("testrepo/a", 0777));
+
+	/* do first checkout with FORCE because we don't know if testrepo
+	 * base data is clean for a checkout or not
+	 */
+	opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
+	cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/dir"));
+	cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+
+	cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
+
+	cl_assert(git_path_isfile("testrepo/a/b.txt"));
+
+	git_object_free(obj);
+}
diff --git a/tests-clar/checkout/typechange.c b/tests-clar/checkout/typechange.c
index b92cc23..6cf99ac 100644
--- a/tests-clar/checkout/typechange.c
+++ b/tests-clar/checkout/typechange.c
@@ -187,7 +187,7 @@ static void force_create_file(const char *file)
 		GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_REMOVE_BLOCKERS);
 	cl_assert(!error || error == GIT_ENOTFOUND);
 	cl_git_pass(git_futils_mkpath2file(file, 0777));
-	cl_git_rewritefile(file, "yowza!");
+	cl_git_rewritefile(file, "yowza!!");
 }
 
 void test_checkout_typechange__checkout_with_conflicts(void)
diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index c4b4822..545fe3a 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -2,6 +2,7 @@
 
 #include "git2/clone.h"
 #include "repository.h"
+#include "remote.h"
 
 #define LIVE_REPO_URL "git://github.com/libgit2/TestGitRepository"
 
@@ -148,7 +149,7 @@ void test_clone_nonetwork__custom_fetch_spec(void)
 	cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
 
 	cl_git_pass(git_remote_load(&g_remote, g_repo, "origin"));
-	actual_fs = git_remote_fetchspec(g_remote);
+	actual_fs = git_remote_get_refspec(g_remote, 0);
 	cl_assert_equal_s("refs/heads/master", git_refspec_src(actual_fs));
 	cl_assert_equal_s("refs/heads/foo", git_refspec_dst(actual_fs));
 
@@ -164,7 +165,7 @@ void test_clone_nonetwork__custom_push_spec(void)
 	cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
 
 	cl_git_pass(git_remote_load(&g_remote, g_repo, "origin"));
-	actual_fs = git_remote_pushspec(g_remote);
+	actual_fs = git_remote_get_refspec(g_remote, git_remote_refspec_count(g_remote) - 1);
 	cl_assert_equal_s("refs/heads/master", git_refspec_src(actual_fs));
 	cl_assert_equal_s("refs/heads/foo", git_refspec_dst(actual_fs));
 }
diff --git a/tests-clar/commit/parse.c b/tests-clar/commit/parse.c
index b99d279..8de4401 100644
--- a/tests-clar/commit/parse.c
+++ b/tests-clar/commit/parse.c
@@ -264,37 +264,40 @@ gpgsig -----BEGIN PGP SIGNATURE-----\n\
 a simple commit which works\n",
 };
 
-void test_commit_parse__entire_commit(void)
+static int parse_commit(git_commit **out, const char *buffer)
 {
-	const int broken_commit_count = sizeof(failing_commit_cases) / sizeof(*failing_commit_cases);
-	const int working_commit_count = sizeof(passing_commit_cases) / sizeof(*passing_commit_cases);
-	int i;
+	git_commit *commit;
+	git_odb_object fake_odb_object;
+	int error;
 
-	for (i = 0; i < broken_commit_count; ++i) {
-		git_commit *commit;
-		commit = (git_commit*)git__malloc(sizeof(git_commit));
-		memset(commit, 0x0, sizeof(git_commit));
-		commit->object.repo = g_repo;
+	commit = (git_commit*)git__malloc(sizeof(git_commit));
+	memset(commit, 0x0, sizeof(git_commit));
+	commit->object.repo = g_repo;
 
-		cl_git_fail(git_commit__parse_buffer(
-			commit, failing_commit_cases[i], strlen(failing_commit_cases[i]))
-		);
+	memset(&fake_odb_object, 0x0, sizeof(git_odb_object));
+	fake_odb_object.buffer = (char *)buffer;
+	fake_odb_object.cached.size = strlen(fake_odb_object.buffer);
 
-		git_commit__free(commit);
-	}
+	error = git_commit__parse(commit, &fake_odb_object);
 
-	for (i = 0; i < working_commit_count; ++i) {
-		git_commit *commit;
+	*out = commit;
+	return error;
+}
+
+void test_commit_parse__entire_commit(void)
+{
+	const int failing_commit_count = ARRAY_SIZE(failing_commit_cases);
+	const int passing_commit_count = ARRAY_SIZE(passing_commit_cases);
+	int i;
+	git_commit *commit;
 
-		commit = (git_commit*)git__malloc(sizeof(git_commit));
-		memset(commit, 0x0, sizeof(git_commit));
-		commit->object.repo = g_repo;
+	for (i = 0; i < failing_commit_count; ++i) {
+		cl_git_fail(parse_commit(&commit, failing_commit_cases[i]));
+		git_commit__free(commit);
+	}
 
-		cl_git_pass(git_commit__parse_buffer(
-                     commit,
-                     passing_commit_cases[i],
-                     strlen(passing_commit_cases[i]))
-         );
+	for (i = 0; i < passing_commit_count; ++i) {
+		cl_git_pass(parse_commit(&commit, passing_commit_cases[i]));
 
 		if (!i)
 			cl_assert_equal_s("", git_commit_message(commit));
@@ -387,9 +390,7 @@ This commit has a few LF at the start of the commit message";
 	memset(commit, 0x0, sizeof(git_commit));
 	commit->object.repo = g_repo;
 
-	cl_git_pass(git_commit__parse_buffer(commit, buffer, strlen(buffer)));
-
+	cl_git_pass(parse_commit(&commit, buffer));
 	cl_assert_equal_s(message, git_commit_message(commit));
-
 	git_commit__free(commit);
 }
diff --git a/tests-clar/config/backend.c b/tests-clar/config/backend.c
index 28502a8..3fd6eb1 100644
--- a/tests-clar/config/backend.c
+++ b/tests-clar/config/backend.c
@@ -1,4 +1,5 @@
 #include "clar_libgit2.h"
+#include "git2/sys/config.h"
 
 void test_config_backend__checks_version(void)
 {
diff --git a/tests-clar/config/multivar.c b/tests-clar/config/multivar.c
index 26537e2..0bda6bc 100644
--- a/tests-clar/config/multivar.c
+++ b/tests-clar/config/multivar.c
@@ -97,6 +97,22 @@ void test_config_multivar__add(void)
 	git_config_free(cfg);
 }
 
+void test_config_multivar__add_new(void)
+{
+	const char *var = "a.brand.new";
+	git_config *cfg;
+	int n;
+
+	cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
+
+	cl_git_pass(git_config_set_multivar(cfg, var, "", "variable"));
+	n = 0;
+	cl_git_pass(git_config_get_multivar(cfg, var, NULL, cb, &n));
+	cl_assert(n == 1);
+
+	git_config_free(cfg);
+}
+
 void test_config_multivar__replace(void)
 {
 	git_config *cfg;
diff --git a/tests-clar/core/oid.c b/tests-clar/core/oid.c
index 08791cc..7ee6fb6 100644
--- a/tests-clar/core/oid.c
+++ b/tests-clar/core/oid.c
@@ -16,15 +16,55 @@ void test_core_oid__initialize(void)
 
 void test_core_oid__streq(void)
 {
-	cl_assert(git_oid_streq(&id, str_oid) == 0);
-	cl_assert(git_oid_streq(&id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef") == -1);
+	cl_assert_equal_i(0, git_oid_streq(&id, str_oid));
+	cl_assert_equal_i(-1, git_oid_streq(&id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
 
-	cl_assert(git_oid_streq(&id, "deadbeef") == -1);
-	cl_assert(git_oid_streq(&id, "I'm not an oid.... :)") == -1);
-	
-	cl_assert(git_oid_streq(&idp, "ae90f12eea699729ed0000000000000000000000") == 0);
-	cl_assert(git_oid_streq(&idp, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef") == -1);
+	cl_assert_equal_i(-1, git_oid_streq(&id, "deadbeef"));
+	cl_assert_equal_i(-1, git_oid_streq(&id, "I'm not an oid.... :)"));
 
-	cl_assert(git_oid_streq(&idp, "deadbeef") == -1);
-	cl_assert(git_oid_streq(&idp, "I'm not an oid.... :)") == -1);
+	cl_assert_equal_i(0, git_oid_streq(&idp, "ae90f12eea699729ed0000000000000000000000"));
+	cl_assert_equal_i(0, git_oid_streq(&idp, "ae90f12eea699729ed"));
+	cl_assert_equal_i(-1, git_oid_streq(&idp, "ae90f12eea699729ed1"));
+	cl_assert_equal_i(-1, git_oid_streq(&idp, "ae90f12eea699729ec"));
+	cl_assert_equal_i(-1, git_oid_streq(&idp, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
+
+	cl_assert_equal_i(-1, git_oid_streq(&idp, "deadbeef"));
+	cl_assert_equal_i(-1, git_oid_streq(&idp, "I'm not an oid.... :)"));
+}
+
+void test_core_oid__strcmp(void)
+{
+	cl_assert_equal_i(0, git_oid_strcmp(&id, str_oid));
+	cl_assert(git_oid_strcmp(&id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef") < 0);
+
+	cl_assert(git_oid_strcmp(&id, "deadbeef") < 0);
+	cl_assert_equal_i(-1, git_oid_strcmp(&id, "I'm not an oid.... :)"));
+
+	cl_assert_equal_i(0, git_oid_strcmp(&idp, "ae90f12eea699729ed0000000000000000000000"));
+	cl_assert_equal_i(0, git_oid_strcmp(&idp, "ae90f12eea699729ed"));
+	cl_assert(git_oid_strcmp(&idp, "ae90f12eea699729ed1") < 0);
+	cl_assert(git_oid_strcmp(&idp, "ae90f12eea699729ec") > 0);
+	cl_assert(git_oid_strcmp(&idp, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef") < 0);
+
+	cl_assert(git_oid_strcmp(&idp, "deadbeef") < 0);
+	cl_assert_equal_i(-1, git_oid_strcmp(&idp, "I'm not an oid.... :)"));
+}
+
+void test_core_oid__ncmp(void)
+{
+	cl_assert(!git_oid_ncmp(&id, &idp, 0));
+	cl_assert(!git_oid_ncmp(&id, &idp, 1));
+	cl_assert(!git_oid_ncmp(&id, &idp, 2));
+	cl_assert(!git_oid_ncmp(&id, &idp, 17));
+	cl_assert(!git_oid_ncmp(&id, &idp, 18));
+	cl_assert(git_oid_ncmp(&id, &idp, 19));
+	cl_assert(git_oid_ncmp(&id, &idp, 40));
+	cl_assert(git_oid_ncmp(&id, &idp, 41));
+	cl_assert(git_oid_ncmp(&id, &idp, 42));
+
+	cl_assert(!git_oid_ncmp(&id, &id, 0));
+	cl_assert(!git_oid_ncmp(&id, &id, 1));
+	cl_assert(!git_oid_ncmp(&id, &id, 39));
+	cl_assert(!git_oid_ncmp(&id, &id, 40));
+	cl_assert(!git_oid_ncmp(&id, &id, 41));
 }
diff --git a/tests-clar/core/oidmap.c b/tests-clar/core/oidmap.c
new file mode 100644
index 0000000..ec4b5e7
--- /dev/null
+++ b/tests-clar/core/oidmap.c
@@ -0,0 +1,110 @@
+#include "clar_libgit2.h"
+#include "oidmap.h"
+
+GIT__USE_OIDMAP;
+
+typedef struct {
+	git_oid oid;
+	size_t extra;
+} oidmap_item;
+
+#define NITEMS 0x0fff
+
+void test_core_oidmap__basic(void)
+{
+	git_oidmap *map;
+	oidmap_item items[NITEMS];
+	uint32_t i, j;
+
+	for (i = 0; i < NITEMS; ++i) {
+		items[i].extra = i;
+		for (j = 0; j < GIT_OID_RAWSZ / 4; ++j) {
+			items[i].oid.id[j * 4    ] = (unsigned char)i;
+			items[i].oid.id[j * 4 + 1] = (unsigned char)(i >> 8);
+			items[i].oid.id[j * 4 + 2] = (unsigned char)(i >> 16);
+			items[i].oid.id[j * 4 + 3] = (unsigned char)(i >> 24);
+		}
+	}
+
+	map = git_oidmap_alloc();
+	cl_assert(map != NULL);
+
+	for (i = 0; i < NITEMS; ++i) {
+		khiter_t pos;
+		int ret;
+
+		pos = kh_get(oid, map, &items[i].oid);
+		cl_assert(pos == kh_end(map));
+
+		pos = kh_put(oid, map, &items[i].oid, &ret);
+		cl_assert(ret != 0);
+
+		kh_val(map, pos) = &items[i];
+	}
+
+
+	for (i = 0; i < NITEMS; ++i) {
+		khiter_t pos;
+
+		pos = kh_get(oid, map, &items[i].oid);
+		cl_assert(pos != kh_end(map));
+
+		cl_assert_equal_p(kh_val(map, pos), &items[i]);
+	}
+
+	git_oidmap_free(map);
+}
+
+void test_core_oidmap__hash_collision(void)
+{
+	git_oidmap *map;
+	oidmap_item items[NITEMS];
+	uint32_t i, j;
+
+	for (i = 0; i < NITEMS; ++i) {
+		uint32_t segment = i / 8;
+		int modi = i - (segment * 8);
+
+		items[i].extra = i;
+
+		for (j = 0; j < GIT_OID_RAWSZ / 4; ++j) {
+			items[i].oid.id[j * 4    ] = (unsigned char)modi;
+			items[i].oid.id[j * 4 + 1] = (unsigned char)(modi >> 8);
+			items[i].oid.id[j * 4 + 2] = (unsigned char)(modi >> 16);
+			items[i].oid.id[j * 4 + 3] = (unsigned char)(modi >> 24);
+		}
+
+		items[i].oid.id[ 8] = (unsigned char)i;
+		items[i].oid.id[ 9] = (unsigned char)(i >> 8);
+		items[i].oid.id[10] = (unsigned char)(i >> 16);
+		items[i].oid.id[11] = (unsigned char)(i >> 24);
+	}
+
+	map = git_oidmap_alloc();
+	cl_assert(map != NULL);
+
+	for (i = 0; i < NITEMS; ++i) {
+		khiter_t pos;
+		int ret;
+
+		pos = kh_get(oid, map, &items[i].oid);
+		cl_assert(pos == kh_end(map));
+
+		pos = kh_put(oid, map, &items[i].oid, &ret);
+		cl_assert(ret != 0);
+
+		kh_val(map, pos) = &items[i];
+	}
+
+
+	for (i = 0; i < NITEMS; ++i) {
+		khiter_t pos;
+
+		pos = kh_get(oid, map, &items[i].oid);
+		cl_assert(pos != kh_end(map));
+
+		cl_assert_equal_p(kh_val(map, pos), &items[i]);
+	}
+
+	git_oidmap_free(map);
+}
diff --git a/tests-clar/core/opts.c b/tests-clar/core/opts.c
index 907339d..3173c64 100644
--- a/tests-clar/core/opts.c
+++ b/tests-clar/core/opts.c
@@ -16,15 +16,4 @@ void test_core_opts__readwrite(void)
 	git_libgit2_opts(GIT_OPT_GET_MWINDOW_SIZE, &new_val);
 
 	cl_assert(new_val == old_val);
-
-	git_libgit2_opts(GIT_OPT_GET_ODB_CACHE_SIZE, &old_val);
-
-	cl_assert(old_val == GIT_DEFAULT_CACHE_SIZE);
-
-	git_libgit2_opts(GIT_OPT_SET_ODB_CACHE_SIZE, (size_t)GIT_DEFAULT_CACHE_SIZE*2);
-	git_libgit2_opts(GIT_OPT_GET_ODB_CACHE_SIZE, &new_val);
-
-	cl_assert(new_val == (GIT_DEFAULT_CACHE_SIZE*2));
-
-	git_libgit2_opts(GIT_OPT_GET_ODB_CACHE_SIZE, &old_val);
 }
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 19c005e..e7f97c0 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -28,7 +28,15 @@ int diff_file_cb(
 {
 	diff_expects *e = payload;
 
-	GIT_UNUSED(progress);
+	if (e->debug)
+		fprintf(stderr, "%c %s (%.3f)\n",
+			git_diff_status_char(delta->status),
+			delta->old_file.path, progress);
+
+	if (e->names)
+		cl_assert_equal_s(e->names[e->files], delta->old_file.path);
+	if (e->statuses)
+		cl_assert_equal_i(e->statuses[e->files], (int)delta->status);
 
 	e->files++;
 
diff --git a/tests-clar/diff/diff_helpers.h b/tests-clar/diff/diff_helpers.h
index 674fd8e..b39a69d 100644
--- a/tests-clar/diff/diff_helpers.h
+++ b/tests-clar/diff/diff_helpers.h
@@ -18,6 +18,13 @@ typedef struct {
 	int line_ctxt;
 	int line_adds;
 	int line_dels;
+
+	/* optional arrays of expected specific values */
+	const char **names;
+	int *statuses;
+
+	int debug;
+
 } diff_expects;
 
 typedef struct {
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index 4d17da4..40b191d 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -1,4 +1,6 @@
 #include "clar_libgit2.h"
+#include "git2/sys/repository.h"
+
 #include "diff_helpers.h"
 #include "repository.h"
 #include "buf_text.h"
@@ -133,6 +135,84 @@ void test_diff_patch__to_string(void)
 	git_tree_free(one);
 }
 
+void test_diff_patch__config_options(void)
+{
+	const char *one_sha = "26a125e"; /* current HEAD */
+	git_tree *one;
+	git_config *cfg;
+	git_diff_list *diff;
+	git_diff_patch *patch;
+	char *text;
+	git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+	char *onefile = "staged_changes_modified_file";
+	const char *expected1 = "diff --git c/staged_changes_modified_file i/staged_changes_modified_file\nindex 70bd944..906ee77 100644\n--- c/staged_changes_modified_file\n+++ i/staged_changes_modified_file\n@@ -1 +1,2 @@\n staged_changes_modified_file\n+staged_changes_modified_file\n";
+	const char *expected2 = "diff --git i/staged_changes_modified_file w/staged_changes_modified_file\nindex 906ee77..011c344 100644\n--- i/staged_changes_modified_file\n+++ w/staged_changes_modified_file\n@@ -1,2 +1,3 @@\n staged_changes_modified_file\n staged_changes_modified_file\n+staged_changes_modified_file\n";
+	const char *expected3 = "diff --git staged_changes_modified_file staged_changes_modified_file\nindex 906ee77..011c344 100644\n--- staged_changes_modified_file\n+++ staged_changes_modified_file\n@@ -1,2 +1,3 @@\n staged_changes_modified_file\n staged_changes_modified_file\n+staged_changes_modified_file\n";
+	const char *expected4 = "diff --git staged_changes_modified_file staged_changes_modified_file\nindex 70bd9443ada0..906ee7711f4f 100644\n--- staged_changes_modified_file\n+++ staged_changes_modified_file\n@@ -1 +1,2 @@\n staged_changes_modified_file\n+staged_changes_modified_file\n";
+
+	g_repo = cl_git_sandbox_init("status");
+	cl_git_pass(git_repository_config(&cfg, g_repo));
+	one = resolve_commit_oid_to_tree(g_repo, one_sha);
+	opts.pathspec.count = 1;
+	opts.pathspec.strings = &onefile;
+
+
+	cl_git_pass(git_config_set_string(cfg, "diff.mnemonicprefix", "true"));
+
+	cl_git_pass(git_diff_tree_to_index(&diff, g_repo, one, NULL, &opts));
+
+	cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+	cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+	cl_git_pass(git_diff_patch_to_str(&text, patch));
+	cl_assert_equal_s(expected1, text);
+
+	git__free(text);
+	git_diff_patch_free(patch);
+	git_diff_list_free(diff);
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+	cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+	cl_git_pass(git_diff_patch_to_str(&text, patch));
+	cl_assert_equal_s(expected2, text);
+
+	git__free(text);
+	git_diff_patch_free(patch);
+	git_diff_list_free(diff);
+
+
+	cl_git_pass(git_config_set_string(cfg, "diff.noprefix", "true"));
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+	cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+	cl_git_pass(git_diff_patch_to_str(&text, patch));
+	cl_assert_equal_s(expected3, text);
+
+	git__free(text);
+	git_diff_patch_free(patch);
+	git_diff_list_free(diff);
+
+
+	cl_git_pass(git_config_set_int32(cfg, "core.abbrev", 12));
+
+	cl_git_pass(git_diff_tree_to_index(&diff, g_repo, one, NULL, &opts));
+
+	cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+	cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+	cl_git_pass(git_diff_patch_to_str(&text, patch));
+	cl_assert_equal_s(expected4, text);
+
+	git__free(text);
+	git_diff_patch_free(patch);
+	git_diff_list_free(diff);
+
+	git_tree_free(one);
+	git_config_free(cfg);
+}
+
 void test_diff_patch__hunks_have_correct_line_numbers(void)
 {
 	git_config *cfg;
diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c
index 850feef..f05c786 100644
--- a/tests-clar/diff/tree.c
+++ b/tests-clar/diff/tree.c
@@ -454,3 +454,77 @@ void test_diff_tree__issue_1397(void)
 	cl_assert_equal_i(0, expect.file_status[GIT_DELTA_ADDED]);
 	cl_assert_equal_i(0, expect.file_status[GIT_DELTA_TYPECHANGE]);
 }
+
+static void set_config_int(git_repository *repo, const char *name, int value)
+{
+	git_config *cfg;
+
+	cl_git_pass(git_repository_config(&cfg, repo));
+	cl_git_pass(git_config_set_int32(cfg, name, value));
+	git_config_free(cfg);
+}
+
+void test_diff_tree__diff_configs(void)
+{
+	const char *a_commit = "d70d245e";
+	const char *b_commit = "7a9e0b02";
+
+	g_repo = cl_git_sandbox_init("diff");
+
+	cl_assert((a = resolve_commit_oid_to_tree(g_repo, a_commit)) != NULL);
+	cl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL);
+
+	cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
+
+	cl_git_pass(git_diff_foreach(
+		diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+
+	cl_assert_equal_i(2, expect.files);
+	cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(6, expect.hunks);
+	cl_assert_equal_i(55, expect.lines);
+	cl_assert_equal_i(33, expect.line_ctxt);
+	cl_assert_equal_i(7, expect.line_adds);
+	cl_assert_equal_i(15, expect.line_dels);
+
+	git_diff_list_free(diff);
+	diff = NULL;
+
+	set_config_int(g_repo, "diff.context", 1);
+
+	memset(&expect, 0, sizeof(expect));
+
+	cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
+
+	cl_git_pass(git_diff_foreach(
+		diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+
+	cl_assert_equal_i(2, expect.files);
+	cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(7, expect.hunks);
+	cl_assert_equal_i(34, expect.lines);
+	cl_assert_equal_i(12, expect.line_ctxt);
+	cl_assert_equal_i(7, expect.line_adds);
+	cl_assert_equal_i(15, expect.line_dels);
+
+	git_diff_list_free(diff);
+	diff = NULL;
+
+	set_config_int(g_repo, "diff.context", 0);
+	set_config_int(g_repo, "diff.noprefix", 1);
+
+	memset(&expect, 0, sizeof(expect));
+
+	cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));
+
+	cl_git_pass(git_diff_foreach(
+		diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &expect));
+
+	cl_assert_equal_i(2, expect.files);
+	cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(7, expect.hunks);
+	cl_assert_equal_i(22, expect.lines);
+	cl_assert_equal_i(0, expect.line_ctxt);
+	cl_assert_equal_i(7, expect.line_adds);
+	cl_assert_equal_i(15, expect.line_dels);
+}
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c
index 9d92d8d..94fd716 100644
--- a/tests-clar/diff/workdir.c
+++ b/tests-clar/diff/workdir.c
@@ -908,7 +908,6 @@ void test_diff_workdir__can_diff_empty_file(void)
 	/* baseline - make sure there are no outstanding diffs */
 
 	cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, tree, &opts));
-	git_tree_free(tree);
 	cl_assert_equal_i(2, (int)git_diff_num_deltas(diff));
 	git_diff_list_free(diff);
 
@@ -935,6 +934,8 @@ void test_diff_workdir__can_diff_empty_file(void)
 	cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 1));
 	git_diff_patch_free(patch);
 	git_diff_list_free(diff);
+
+	git_tree_free(tree);
 }
 
 void test_diff_workdir__to_index_issue_1397(void)
@@ -1032,3 +1033,190 @@ void test_diff_workdir__to_tree_issue_1397(void)
 	git_diff_list_free(diff);
 	git_tree_free(a);
 }
+
+void test_diff_workdir__untracked_directory_scenarios(void)
+{
+	git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+	git_diff_list *diff = NULL;
+	diff_expects exp;
+	char *pathspec = NULL;
+	static const char *files0[] = {
+		"subdir/deleted_file",
+		"subdir/modified_file",
+		"subdir/new_file",
+		NULL
+	};
+	static const char *files1[] = {
+		"subdir/deleted_file",
+		"subdir/directory/",
+		"subdir/modified_file",
+		"subdir/new_file",
+		NULL
+	};
+	static const char *files2[] = {
+		"subdir/deleted_file",
+		"subdir/directory/more/notignored",
+		"subdir/modified_file",
+		"subdir/new_file",
+		NULL
+	};
+
+	g_repo = cl_git_sandbox_init("status");
+	cl_git_mkfile("status/.gitignore", "ignored\n");
+
+	opts.context_lines = 3;
+	opts.interhunk_lines = 1;
+	opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
+	opts.pathspec.strings = &pathspec;
+	opts.pathspec.count   = 1;
+	pathspec = "subdir";
+
+	/* baseline for "subdir" pathspec */
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files0;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(3, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+
+	/* empty directory */
+
+	cl_git_pass(p_mkdir("status/subdir/directory", 0777));
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files1;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(4, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+
+	/* directory with only ignored files */
+
+	cl_git_pass(p_mkdir("status/subdir/directory/deeper", 0777));
+	cl_git_mkfile("status/subdir/directory/deeper/ignored", "ignore me\n");
+
+	cl_git_pass(p_mkdir("status/subdir/directory/another", 0777));
+	cl_git_mkfile("status/subdir/directory/another/ignored", "ignore me\n");
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files1;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(4, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+
+	/* directory with ignored directory (contents irrelevant) */
+
+	cl_git_pass(p_mkdir("status/subdir/directory/more", 0777));
+	cl_git_pass(p_mkdir("status/subdir/directory/more/ignored", 0777));
+	cl_git_mkfile("status/subdir/directory/more/ignored/notignored",
+		"inside ignored dir\n");
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files1;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(4, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+
+	/* quick version avoids directory scan */
+
+	opts.flags = opts.flags | GIT_DIFF_FAST_UNTRACKED_DIRS;
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files1;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(4, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(2, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+
+	/* directory with nested non-ignored content */
+
+	opts.flags = opts.flags & ~GIT_DIFF_FAST_UNTRACKED_DIRS;
+
+	cl_git_mkfile("status/subdir/directory/more/notignored",
+		"not ignored deep under untracked\n");
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files1;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(4, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(2, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+
+	/* use RECURSE_UNTRACKED_DIRS to get actual untracked files (no ignores) */
+
+	opts.flags = opts.flags & ~GIT_DIFF_INCLUDE_IGNORED;
+	opts.flags = opts.flags | GIT_DIFF_RECURSE_UNTRACKED_DIRS;
+
+	memset(&exp, 0, sizeof(exp));
+	exp.names = files2;
+
+	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+	cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
+
+	cl_assert_equal_i(4, exp.files);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+	cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
+	cl_assert_equal_i(2, exp.file_status[GIT_DELTA_UNTRACKED]);
+
+	git_diff_list_free(diff);
+}
diff --git a/tests-clar/index/names.c b/tests-clar/index/names.c
new file mode 100644
index 0000000..6861553
--- /dev/null
+++ b/tests-clar/index/names.c
@@ -0,0 +1,84 @@
+#include "clar_libgit2.h"
+#include "index.h"
+#include "git2/sys/index.h"
+#include "git2/repository.h"
+#include "../reset/reset_helpers.h"
+
+static git_repository *repo;
+static git_index *repo_index;
+
+#define TEST_REPO_PATH "mergedrepo"
+#define TEST_INDEX_PATH TEST_REPO_PATH "/.git/index"
+
+// Fixture setup and teardown
+void test_index_names__initialize(void)
+{
+	repo = cl_git_sandbox_init("mergedrepo");
+	git_repository_index(&repo_index, repo);
+}
+
+void test_index_names__cleanup(void)
+{
+	git_index_free(repo_index);
+	repo_index = NULL;
+	
+	cl_git_sandbox_cleanup();
+}
+
+void test_index_names__add(void)
+{
+	const git_index_name_entry *conflict_name;
+
+	cl_git_pass(git_index_name_add(repo_index, "ancestor", "ours", "theirs"));
+	cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL));
+	cl_git_pass(git_index_name_add(repo_index, "ancestor3", NULL, "theirs3"));
+	
+	cl_assert(git_index_name_entrycount(repo_index) == 3);
+	
+	conflict_name = git_index_name_get_byindex(repo_index, 0);
+	cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0);
+	cl_assert(strcmp(conflict_name->ours, "ours") == 0);
+	cl_assert(strcmp(conflict_name->theirs, "theirs") == 0);
+	
+	conflict_name = git_index_name_get_byindex(repo_index, 1);
+	cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0);
+	cl_assert(strcmp(conflict_name->ours, "ours2") == 0);
+	cl_assert(conflict_name->theirs == NULL);
+
+	conflict_name = git_index_name_get_byindex(repo_index, 2);
+	cl_assert(strcmp(conflict_name->ancestor, "ancestor3") == 0);
+	cl_assert(conflict_name->ours == NULL);
+	cl_assert(strcmp(conflict_name->theirs, "theirs3") == 0);
+}
+
+void test_index_names__roundtrip(void)
+{
+	const git_index_name_entry *conflict_name;
+	
+	cl_git_pass(git_index_name_add(repo_index, "ancestor", "ours", "theirs"));
+	cl_git_pass(git_index_name_add(repo_index, "ancestor2", "ours2", NULL));
+	cl_git_pass(git_index_name_add(repo_index, "ancestor3", NULL, "theirs3"));
+	
+	cl_git_pass(git_index_write(repo_index));
+	git_index_clear(repo_index);
+	cl_assert(git_index_name_entrycount(repo_index) == 0);
+	
+	cl_git_pass(git_index_read(repo_index));
+	cl_assert(git_index_name_entrycount(repo_index) == 3);
+	
+	conflict_name = git_index_name_get_byindex(repo_index, 0);
+	cl_assert(strcmp(conflict_name->ancestor, "ancestor") == 0);
+	cl_assert(strcmp(conflict_name->ours, "ours") == 0);
+	cl_assert(strcmp(conflict_name->theirs, "theirs") == 0);
+	
+	conflict_name = git_index_name_get_byindex(repo_index, 1);
+	cl_assert(strcmp(conflict_name->ancestor, "ancestor2") == 0);
+	cl_assert(strcmp(conflict_name->ours, "ours2") == 0);
+	cl_assert(conflict_name->theirs == NULL);
+	
+	conflict_name = git_index_name_get_byindex(repo_index, 2);
+	cl_assert(strcmp(conflict_name->ancestor, "ancestor3") == 0);
+	cl_assert(conflict_name->ours == NULL);
+	cl_assert(strcmp(conflict_name->theirs, "theirs3") == 0);
+	
+}
diff --git a/tests-clar/index/reuc.c b/tests-clar/index/reuc.c
index 4d5955a..0e38a92 100644
--- a/tests-clar/index/reuc.c
+++ b/tests-clar/index/reuc.c
@@ -1,5 +1,6 @@
 #include "clar_libgit2.h"
 #include "index.h"
+#include "git2/sys/index.h"
 #include "git2/repository.h"
 #include "../reset/reset_helpers.h"
 
diff --git a/tests-clar/merge/merge_helpers.c b/tests-clar/merge/merge_helpers.c
new file mode 100644
index 0000000..71bb967
--- /dev/null
+++ b/tests-clar/merge/merge_helpers.c
@@ -0,0 +1,310 @@
+#include "clar_libgit2.h"
+#include "buffer.h"
+#include "refs.h"
+#include "tree.h"
+#include "merge_helpers.h"
+#include "merge.h"
+#include "git2/merge.h"
+#include "git2/sys/index.h"
+
+int merge_trees_from_branches(
+	git_index **index, git_repository *repo,
+	const char *ours_name, const char *theirs_name,
+	git_merge_tree_opts *opts)
+{
+	git_commit *our_commit, *their_commit, *ancestor_commit = NULL;
+	git_tree *our_tree, *their_tree, *ancestor_tree = NULL;
+	git_oid our_oid, their_oid, ancestor_oid;
+	git_buf branch_buf = GIT_BUF_INIT;
+	int error;
+
+	git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
+	cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
+	cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
+
+	git_buf_clear(&branch_buf);
+	git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
+	cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
+	cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
+
+	error = git_merge_base(&ancestor_oid, repo, git_commit_id(our_commit), git_commit_id(their_commit));
+
+	if (error != GIT_ENOTFOUND) {
+		cl_git_pass(error);
+
+		cl_git_pass(git_commit_lookup(&ancestor_commit, repo, &ancestor_oid));
+		cl_git_pass(git_commit_tree(&ancestor_tree, ancestor_commit));
+	}
+
+	cl_git_pass(git_commit_tree(&our_tree, our_commit));
+	cl_git_pass(git_commit_tree(&their_tree, their_commit));
+
+	cl_git_pass(git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, opts));
+
+	git_buf_free(&branch_buf);
+	git_tree_free(our_tree);
+	git_tree_free(their_tree);
+	git_tree_free(ancestor_tree);
+	git_commit_free(our_commit);
+	git_commit_free(their_commit);
+	git_commit_free(ancestor_commit);
+
+	return 0;
+}
+
+void merge__dump_index_entries(git_vector *index_entries)
+{
+	size_t i;
+	const git_index_entry *index_entry;
+	
+	printf ("\nINDEX [%d]:\n", (int)index_entries->length);
+	for (i = 0; i < index_entries->length; i++) {
+		index_entry = index_entries->contents[i];
+		
+		printf("%o ", index_entry->mode);
+		printf("%s ", git_oid_allocfmt(&index_entry->oid));
+		printf("%d ", git_index_entry_stage(index_entry));
+		printf("%s ", index_entry->path);
+		printf("\n");
+	}
+	printf("\n");
+}
+
+void merge__dump_names(git_index *index)
+{
+	size_t i;
+	const git_index_name_entry *conflict_name;
+
+	for (i = 0; i < git_index_name_entrycount(index); i++) {
+		conflict_name = git_index_name_get_byindex(index, i);
+		
+		printf("%s %s %s\n", conflict_name->ancestor, conflict_name->ours, conflict_name->theirs);
+	}
+	printf("\n");
+}
+
+void merge__dump_reuc(git_index *index)
+{
+	size_t i;
+	const git_index_reuc_entry *reuc;
+
+	printf ("\nREUC:\n");
+	for (i = 0; i < git_index_reuc_entrycount(index); i++) {
+		reuc = git_index_reuc_get_byindex(index, i);
+		
+		printf("%s ", reuc->path);
+		printf("%o ", reuc->mode[0]);
+		printf("%s\n", git_oid_allocfmt(&reuc->oid[0]));
+		printf("          %o ", reuc->mode[1]);
+		printf("          %s\n", git_oid_allocfmt(&reuc->oid[1]));
+		printf("          %o ", reuc->mode[2]);
+		printf("          %s ", git_oid_allocfmt(&reuc->oid[2]));
+		printf("\n");
+	}
+	printf("\n");
+}
+
+static int index_entry_eq_merge_index_entry(const struct merge_index_entry *expected, const git_index_entry *actual)
+{
+	git_oid expected_oid;
+	bool test_oid;
+
+	if (strlen(expected->oid_str) != 0) {
+		cl_git_pass(git_oid_fromstr(&expected_oid, expected->oid_str));
+		test_oid = 1;
+	} else
+		test_oid = 0;
+	
+	if (actual->mode != expected->mode ||
+		(test_oid && git_oid_cmp(&actual->oid, &expected_oid) != 0) ||
+		git_index_entry_stage(actual) != expected->stage)
+		return 0;
+	
+	if (actual->mode == 0 && (actual->path != NULL || strlen(expected->path) > 0))
+		return 0;
+
+	if (actual->mode != 0 && (strcmp(actual->path, expected->path) != 0))
+		return 0;
+	
+	return 1;
+}
+
+static int name_entry_eq(const char *expected, const char *actual)
+{
+	if (strlen(expected) == 0)
+		return (actual == NULL) ? 1 : 0;
+	
+	return (strcmp(expected, actual) == 0) ? 1 : 0;
+}
+
+static int name_entry_eq_merge_name_entry(const struct merge_name_entry *expected, const git_index_name_entry *actual)
+{
+	if (name_entry_eq(expected->ancestor_path, actual->ancestor) == 0 ||
+		name_entry_eq(expected->our_path, actual->ours) == 0 ||
+		name_entry_eq(expected->their_path, actual->theirs) == 0)
+		return 0;
+
+	return 1;
+}
+
+static int index_conflict_data_eq_merge_diff(const struct merge_index_conflict_data *expected, git_merge_diff *actual)
+{
+	if (!index_entry_eq_merge_index_entry(&expected->ancestor.entry, &actual->ancestor_entry) ||
+		!index_entry_eq_merge_index_entry(&expected->ours.entry, &actual->our_entry) ||
+		!index_entry_eq_merge_index_entry(&expected->theirs.entry, &actual->their_entry))
+		return 0;
+	
+	if (expected->ours.status != actual->our_status ||
+		expected->theirs.status != actual->their_status)
+		return 0;
+    
+	return 1;
+}
+
+int merge_test_merge_conflicts(git_vector *conflicts, const struct merge_index_conflict_data expected[], size_t expected_len)
+{
+	git_merge_diff *actual;
+	size_t i;
+	
+	if (conflicts->length != expected_len)
+		return 0;
+
+	for (i = 0; i < expected_len; i++) {
+		actual = conflicts->contents[i];
+		
+		if (!index_conflict_data_eq_merge_diff(&expected[i], actual))
+			return 0;
+	}
+
+    return 1;
+}
+
+int merge_test_index(git_index *index, const struct merge_index_entry expected[], size_t expected_len)
+{
+    size_t i;
+    const git_index_entry *index_entry;
+	
+	/*
+	dump_index_entries(&index->entries);
+	*/
+
+    if (git_index_entrycount(index) != expected_len)
+        return 0;
+    
+    for (i = 0; i < expected_len; i++) {
+        if ((index_entry = git_index_get_byindex(index, i)) == NULL)
+            return 0;
+		
+		if (!index_entry_eq_merge_index_entry(&expected[i], index_entry))
+			return 0;
+    }
+    
+    return 1;
+}
+
+int merge_test_names(git_index *index, const struct merge_name_entry expected[], size_t expected_len)
+{
+	size_t i;
+	const git_index_name_entry *name_entry;
+	
+	/*
+	dump_names(index);
+	*/
+
+	if (git_index_name_entrycount(index) != expected_len)
+		return 0;
+
+	for (i = 0; i < expected_len; i++) {
+		if ((name_entry = git_index_name_get_byindex(index, i)) == NULL)
+			return 0;
+
+		if (! name_entry_eq_merge_name_entry(&expected[i], name_entry))
+			return 0;
+	}
+	
+	return 1;
+}
+
+int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], size_t expected_len)
+{
+    size_t i;
+	const git_index_reuc_entry *reuc_entry;
+    git_oid expected_oid;
+	
+	/*
+	dump_reuc(index);
+	*/
+	
+    if (git_index_reuc_entrycount(index) != expected_len)
+        return 0;
+    
+    for (i = 0; i < expected_len; i++) {
+        if ((reuc_entry = git_index_reuc_get_byindex(index, i)) == NULL)
+            return 0;
+
+		if (strcmp(reuc_entry->path, expected[i].path) != 0 ||
+			reuc_entry->mode[0] != expected[i].ancestor_mode ||
+			reuc_entry->mode[1] != expected[i].our_mode ||
+			reuc_entry->mode[2] != expected[i].their_mode)
+			return 0;
+
+		if (expected[i].ancestor_mode > 0) {
+			cl_git_pass(git_oid_fromstr(&expected_oid, expected[i].ancestor_oid_str));
+
+			if (git_oid_cmp(&reuc_entry->oid[0], &expected_oid) != 0)
+				return 0;
+		}
+
+		if (expected[i].our_mode > 0) {
+			cl_git_pass(git_oid_fromstr(&expected_oid, expected[i].our_oid_str));
+
+			if (git_oid_cmp(&reuc_entry->oid[1], &expected_oid) != 0)
+				return 0;
+		}
+
+		if (expected[i].their_mode > 0) {
+			cl_git_pass(git_oid_fromstr(&expected_oid, expected[i].their_oid_str));
+
+			if (git_oid_cmp(&reuc_entry->oid[2], &expected_oid) != 0)
+				return 0;
+		}
+    }
+    
+    return 1;
+}
+
+int dircount(void *payload, git_buf *pathbuf)
+{
+	int *entries = payload;
+	size_t len = git_buf_len(pathbuf);
+	
+	if (len < 5 || strcmp(pathbuf->ptr + (git_buf_len(pathbuf) - 5), "/.git") != 0)
+		(*entries)++;
+	
+	return 0;
+}
+
+int merge_test_workdir(git_repository *repo, const struct merge_index_entry expected[], size_t expected_len)
+{
+	size_t actual_len = 0, i;
+	git_oid actual_oid, expected_oid;
+	git_buf wd = GIT_BUF_INIT;
+	
+	git_buf_puts(&wd, repo->workdir);	
+	git_path_direach(&wd, dircount, &actual_len);
+	
+	if (actual_len != expected_len)
+		return 0;
+		
+	for (i = 0; i < expected_len; i++) {
+		git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path);
+		git_oid_fromstr(&expected_oid, expected[i].oid_str);
+		
+		if (git_oid_cmp(&actual_oid, &expected_oid) != 0)
+			return 0;
+	}
+	
+	git_buf_free(&wd);
+	
+	return 1;
+}
diff --git a/tests-clar/merge/merge_helpers.h b/tests-clar/merge/merge_helpers.h
new file mode 100644
index 0000000..cb718e0
--- /dev/null
+++ b/tests-clar/merge/merge_helpers.h
@@ -0,0 +1,59 @@
+#ifndef INCLUDE_cl_merge_helpers_h__
+#define INCLUDE_cl_merge_helpers_h__
+
+#include "merge.h"
+#include "git2/merge.h"
+
+struct merge_index_entry {
+	uint16_t mode;
+	char oid_str[41];
+	int stage;
+	char path[128];
+};
+
+struct merge_name_entry {
+	char ancestor_path[128];
+	char our_path[128];
+	char their_path[128];
+};
+
+struct merge_index_with_status {
+	struct merge_index_entry entry;
+	unsigned int status;
+};
+
+struct merge_reuc_entry {
+	char path[128];
+	unsigned int ancestor_mode;
+	unsigned int our_mode;
+	unsigned int their_mode;
+	char ancestor_oid_str[41];
+	char our_oid_str[41];
+	char their_oid_str[41];
+};
+
+struct merge_index_conflict_data {
+	struct merge_index_with_status ancestor;
+	struct merge_index_with_status ours;
+	struct merge_index_with_status theirs;
+	git_merge_diff_type_t change_type;
+};
+
+int merge_trees_from_branches(
+	git_index **index, git_repository *repo,
+	const char *ours_name, const char *theirs_name,
+	git_merge_tree_opts *opts);
+
+int merge_test_diff_list(git_merge_diff_list *diff_list, const struct merge_index_entry expected[], size_t expected_len);
+
+int merge_test_merge_conflicts(git_vector *conflicts, const struct merge_index_conflict_data expected[], size_t expected_len);
+
+int merge_test_index(git_index *index, const struct merge_index_entry expected[], size_t expected_len);
+
+int merge_test_names(git_index *index, const struct merge_name_entry expected[], size_t expected_len);
+
+int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], size_t expected_len);
+
+int merge_test_workdir(git_repository *repo, const struct merge_index_entry expected[], size_t expected_len);
+
+#endif
diff --git a/tests-clar/merge/setup.c b/tests-clar/merge/setup.c
deleted file mode 100644
index 946c67e..0000000
--- a/tests-clar/merge/setup.c
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "clar_libgit2.h"
-#include "git2/repository.h"
-#include "git2/merge.h"
-#include "merge.h"
-#include "refs.h"
-#include "fileops.h"
-
-static git_repository *repo;
-static git_index *repo_index;
-
-#define TEST_REPO_PATH "testrepo"
-#define TEST_INDEX_PATH TEST_REPO_PATH "/.git/index"
-
-#define ORIG_HEAD                   "bd593285fc7fe4ca18ccdbabf027f5d689101452"
-
-#define THEIRS_SIMPLE_BRANCH        "branch"
-#define THEIRS_SIMPLE_OID           "7cb63eed597130ba4abb87b3e544b85021905520"
-
-#define OCTO1_BRANCH                "octo1"
-#define OCTO1_OID                   "16f825815cfd20a07a75c71554e82d8eede0b061"
-
-#define OCTO2_BRANCH                "octo2"
-#define OCTO2_OID                   "158dc7bedb202f5b26502bf3574faa7f4238d56c"
-
-#define OCTO3_BRANCH                "octo3"
-#define OCTO3_OID                   "50ce7d7d01217679e26c55939eef119e0c93e272"
-
-#define OCTO4_BRANCH                "octo4"
-#define OCTO4_OID                   "54269b3f6ec3d7d4ede24dd350dd5d605495c3ae"
-
-#define OCTO5_BRANCH                "octo5"
-#define OCTO5_OID                   "e4f618a2c3ed0669308735727df5ebf2447f022f"
-
-// Fixture setup and teardown
-void test_merge_setup__initialize(void)
-{
-	repo = cl_git_sandbox_init(TEST_REPO_PATH);
-    git_repository_index(&repo_index, repo);
-}
-
-void test_merge_setup__cleanup(void)
-{
-    git_index_free(repo_index);
-	cl_git_sandbox_cleanup();
-}
-
-static void write_file_contents(const char *filename, const char *output)
-{
-	git_buf file_path_buf = GIT_BUF_INIT;
-
-    git_buf_printf(&file_path_buf, "%s/%s", git_repository_path(repo), filename);
-	cl_git_rewritefile(file_path_buf.ptr, output);
-
-	git_buf_free(&file_path_buf);
-}
-
-struct merge_head_cb_data {
-	const char **oid_str;
-	unsigned int len;
-
-	unsigned int i;
-};
-
-static int merge_head_foreach_cb(const git_oid *oid, void *payload)
-{
-	git_oid expected_oid;
-	struct merge_head_cb_data *cb_data = payload;
-
-	git_oid_fromstr(&expected_oid, cb_data->oid_str[cb_data->i]);
-	cl_assert(git_oid_cmp(&expected_oid, oid) == 0);
-	cb_data->i++;
-	return 0;
-}
-
-void test_merge_setup__head_notfound(void)
-{
-	int error;
-
-	cl_git_fail((error = git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, NULL)));
-	cl_assert(error == GIT_ENOTFOUND);
-}
-
-void test_merge_setup__head_invalid_oid(void)
-{
-	int error;
-
-	write_file_contents(GIT_MERGE_HEAD_FILE, "invalid-oid\n");
-
-	cl_git_fail((error = git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, NULL)));
-	cl_assert(error == -1);
-}
-
-void test_merge_setup__head_foreach_nonewline(void)
-{
-	int error;
-
-	write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID);
-
-	cl_git_fail((error = git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, NULL)));
-	cl_assert(error == -1);
-}
-
-void test_merge_setup__head_foreach_one(void)
-{
-	const char *expected = THEIRS_SIMPLE_OID;
-
-	struct merge_head_cb_data cb_data = { &expected, 1 };
-
-	write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID "\n");
-
-	cl_git_pass(git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, &cb_data));
-
-	cl_assert(cb_data.i == cb_data.len);
-}
-
-void test_merge_setup__head_foreach_octopus(void)
-{
-	const char *expected[] = { THEIRS_SIMPLE_OID,
-		OCTO1_OID, OCTO2_OID, OCTO3_OID, OCTO4_OID, OCTO5_OID };
-
-	struct merge_head_cb_data cb_data = { expected, 6 };
-
-	write_file_contents(GIT_MERGE_HEAD_FILE,
-		THEIRS_SIMPLE_OID "\n"
-		OCTO1_OID "\n"
-		OCTO2_OID "\n"
-		OCTO3_OID "\n"
-		OCTO4_OID "\n"
-		OCTO5_OID "\n");
-
-	cl_git_pass(git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, &cb_data));
-
-	cl_assert(cb_data.i == cb_data.len);
-}
diff --git a/tests-clar/merge/trees/automerge.c b/tests-clar/merge/trees/automerge.c
new file mode 100644
index 0000000..7592a92
--- /dev/null
+++ b/tests-clar/merge/trees/automerge.c
@@ -0,0 +1,217 @@
+#include "clar_libgit2.h"
+#include "git2/repository.h"
+#include "git2/merge.h"
+#include "buffer.h"
+#include "merge.h"
+#include "../merge_helpers.h"
+#include "fileops.h"
+
+static git_repository *repo;
+
+#define TEST_REPO_PATH "merge-resolve"
+#define TEST_INDEX_PATH TEST_REPO_PATH "/.git/index"
+
+#define THEIRS_AUTOMERGE_BRANCH        "branch"
+
+#define THEIRS_UNRELATED_BRANCH		"unrelated"
+#define THEIRS_UNRELATED_OID		"55b4e4687e7a0d9ca367016ed930f385d4022e6f"
+#define THEIRS_UNRELATED_PARENT		"d6cf6c7741b3316826af1314042550c97ded1d50"
+
+#define OURS_DIRECTORY_FILE			"df_side1"
+#define THEIRS_DIRECTORY_FILE		"df_side2"
+
+/* Non-conflicting files, index entries are common to every merge operation */
+#define ADDED_IN_MASTER_INDEX_ENTRY	\
+	{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0,  "added-in-master.txt" }
+#define AUTOMERGEABLE_INDEX_ENTRY \
+	{ 0100644, "f2e1550a0c9e53d5811175864a29536642ae3821", 0,  "automergeable.txt" }
+#define CHANGED_IN_BRANCH_INDEX_ENTRY \
+	{ 0100644, "4eb04c9e79e88f6640d01ff5b25ca2a60764f216", 0,  "changed-in-branch.txt" }
+#define CHANGED_IN_MASTER_INDEX_ENTRY \
+	{ 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0,  "changed-in-master.txt" }
+#define UNCHANGED_INDEX_ENTRY \
+	{ 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0,  "unchanged.txt" }
+
+/* Expected REUC entries */
+#define AUTOMERGEABLE_REUC_ENTRY \
+	{ "automergeable.txt", 0100644, 0100644, 0100644, \
+	  "6212c31dab5e482247d7977e4f0dd3601decf13b", \
+	  "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", \
+	  "058541fc37114bfc1dddf6bd6bffc7fae5c2e6fe" }
+#define CONFLICTING_REUC_ENTRY \
+	{ "conflicting.txt", 0100644, 0100644, 0100644, \
+	  "d427e0b2e138501a3d15cc376077a3631e15bd46", \
+	  "4e886e602529caa9ab11d71f86634bd1b6e0de10", \
+	  "2bd0a343aeef7a2cf0d158478966a6e587ff3863" }
+#define REMOVED_IN_BRANCH_REUC_ENTRY \
+	{ "removed-in-branch.txt", 0100644, 0100644, 0, \
+	  "dfe3f22baa1f6fce5447901c3086bae368de6bdd", \
+	  "dfe3f22baa1f6fce5447901c3086bae368de6bdd", \
+	  "" }
+#define REMOVED_IN_MASTER_REUC_ENTRY \
+	{ "removed-in-master.txt", 0100644, 0, 0100644, \
+	  "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", \
+	  "", \
+	  "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5" }
+
+#define AUTOMERGEABLE_MERGED_FILE \
+	"this file is changed in master\n" \
+	"this file is automergeable\n" \
+	"this file is automergeable\n" \
+	"this file is automergeable\n" \
+	"this file is automergeable\n" \
+	"this file is automergeable\n" \
+	"this file is automergeable\n" \
+	"this file is automergeable\n" \
+	"this file is changed in branch\n"
+
+#define AUTOMERGEABLE_MERGED_FILE_CRLF \
+	"this file is changed in master\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is automergeable\r\n" \
+	"this file is changed in branch\r\n"
+
+// Fixture setup and teardown
+void test_merge_trees_automerge__initialize(void)
+{
+	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+}
+
+void test_merge_trees_automerge__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+void test_merge_trees_automerge__automerge(void)
+{
+	git_index *index;
+	const git_index_entry *entry;
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+	git_blob *blob;
+    
+	struct merge_index_entry merge_index_entries[] = {
+		ADDED_IN_MASTER_INDEX_ENTRY,
+		AUTOMERGEABLE_INDEX_ENTRY,
+		CHANGED_IN_BRANCH_INDEX_ENTRY,
+		CHANGED_IN_MASTER_INDEX_ENTRY,
+
+		{ 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 1, "conflicting.txt" },
+		{ 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 2, "conflicting.txt" },
+		{ 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 3, "conflicting.txt" },
+
+		UNCHANGED_INDEX_ENTRY,
+    };
+
+	struct merge_reuc_entry merge_reuc_entries[] = {
+		AUTOMERGEABLE_REUC_ENTRY,
+		REMOVED_IN_BRANCH_REUC_ENTRY,
+		REMOVED_IN_MASTER_REUC_ENTRY
+	};
+
+	cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts));
+
+	cl_assert(merge_test_index(index, merge_index_entries, 8));
+	cl_assert(merge_test_reuc(index, merge_reuc_entries, 3));
+
+	cl_assert((entry = git_index_get_bypath(index, "automergeable.txt", 0)) != NULL);
+	cl_assert(entry->file_size == strlen(AUTOMERGEABLE_MERGED_FILE));
+	
+	cl_git_pass(git_object_lookup((git_object **)&blob, repo, &entry->oid, GIT_OBJ_BLOB));
+	cl_assert(memcmp(git_blob_rawcontent(blob), AUTOMERGEABLE_MERGED_FILE, entry->file_size) == 0);
+    
+	git_index_free(index);
+	git_blob_free(blob);
+}
+
+void test_merge_trees_automerge__favor_ours(void)
+{
+	git_index *index;
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+	
+	struct merge_index_entry merge_index_entries[] = {
+		ADDED_IN_MASTER_INDEX_ENTRY,
+		AUTOMERGEABLE_INDEX_ENTRY,
+		CHANGED_IN_BRANCH_INDEX_ENTRY,
+		CHANGED_IN_MASTER_INDEX_ENTRY,
+		{ 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 0, "conflicting.txt" },
+		UNCHANGED_INDEX_ENTRY,
+	};
+
+	struct merge_reuc_entry merge_reuc_entries[] = {
+		AUTOMERGEABLE_REUC_ENTRY,
+		CONFLICTING_REUC_ENTRY,
+		REMOVED_IN_BRANCH_REUC_ENTRY,
+		REMOVED_IN_MASTER_REUC_ENTRY,
+	};
+	
+	opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_OURS;
+    
+	cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts));
+
+	cl_assert(merge_test_index(index, merge_index_entries, 6));
+	cl_assert(merge_test_reuc(index, merge_reuc_entries, 4));
+
+	git_index_free(index);
+}
+
+void test_merge_trees_automerge__favor_theirs(void)
+{
+	git_index *index;
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+	
+	struct merge_index_entry merge_index_entries[] = {
+		ADDED_IN_MASTER_INDEX_ENTRY,
+		AUTOMERGEABLE_INDEX_ENTRY,
+		CHANGED_IN_BRANCH_INDEX_ENTRY,
+		CHANGED_IN_MASTER_INDEX_ENTRY,
+		{ 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 0, "conflicting.txt" },
+		UNCHANGED_INDEX_ENTRY,
+	};
+
+	struct merge_reuc_entry merge_reuc_entries[] = {
+		AUTOMERGEABLE_REUC_ENTRY,
+		CONFLICTING_REUC_ENTRY,
+		REMOVED_IN_BRANCH_REUC_ENTRY,
+		REMOVED_IN_MASTER_REUC_ENTRY,
+	};
+
+	opts.automerge_flags = GIT_MERGE_AUTOMERGE_FAVOR_THEIRS;
+    
+	cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_AUTOMERGE_BRANCH, &opts));
+
+	cl_assert(merge_test_index(index, merge_index_entries, 6));
+	cl_assert(merge_test_reuc(index, merge_reuc_entries, 4));
+    
+	git_index_free(index);
+}
+
+void test_merge_trees_automerge__unrelated(void)
+{
+	git_index *index;
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+    
+	struct merge_index_entry merge_index_entries[] = {
+		{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" },
+		{ 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 2, "automergeable.txt" },
+		{ 0100644, "d07ec190c306ec690bac349e87d01c4358e49bb2", 3, "automergeable.txt" },
+		{ 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-branch.txt" },
+		{ 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0, "changed-in-master.txt" },
+		{ 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 2, "conflicting.txt" },
+		{ 0100644, "4b253da36a0ae8bfce63aeabd8c5b58429925594", 3, "conflicting.txt" },
+		{ 0100644, "ef58fdd8086c243bdc81f99e379acacfd21d32d6", 0, "new-in-unrelated1.txt" },
+		{ 0100644, "948ba6e701c1edab0c2d394fb7c5538334129793", 0, "new-in-unrelated2.txt" },
+		{ 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" },
+		{ 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "unchanged.txt" },
+	};
+    
+	cl_git_pass(merge_trees_from_branches(&index, repo, "master", THEIRS_UNRELATED_BRANCH, &opts));
+	
+	cl_assert(merge_test_index(index, merge_index_entries, 11));
+	
+	git_index_free(index);
+}
diff --git a/tests-clar/merge/trees/modeconflict.c b/tests-clar/merge/trees/modeconflict.c
new file mode 100644
index 0000000..0661ce5
--- /dev/null
+++ b/tests-clar/merge/trees/modeconflict.c
@@ -0,0 +1,59 @@
+#include "clar_libgit2.h"
+#include "git2/repository.h"
+#include "git2/merge.h"
+#include "buffer.h"
+#include "merge.h"
+#include "../merge_helpers.h"
+#include "fileops.h"
+
+static git_repository *repo;
+
+#define TEST_REPO_PATH "merge-resolve"
+
+#define DF_SIDE1_BRANCH		"df_side1"
+#define DF_SIDE2_BRANCH		"df_side2"
+
+// Fixture setup and teardown
+void test_merge_trees_modeconflict__initialize(void)
+{
+	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+}
+
+void test_merge_trees_modeconflict__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+void test_merge_trees_modeconflict__df_conflict(void)
+{
+	git_index *index;
+	
+	struct merge_index_entry merge_index_entries[] = {
+		{ 0100644, "49130a28ef567af9a6a6104c38773fedfa5f9742", 2, "dir-10" },
+		{ 0100644, "6c06dcd163587c2cc18be44857e0b71116382aeb", 3, "dir-10" },
+		{ 0100644, "43aafd43bea779ec74317dc361f45ae3f532a505", 0, "dir-6" },
+		{ 0100644, "a031a28ae70e33a641ce4b8a8f6317f1ab79dee4", 3, "dir-7" },
+		{ 0100644, "5012fd565b1393bdfda1805d4ec38ce6619e1fd1", 1, "dir-7/file.txt" },
+		{ 0100644, "a5563304ddf6caba25cb50323a2ea6f7dbfcadca", 2, "dir-7/file.txt" },
+		{ 0100644, "e9ad6ec3e38364a3d07feda7c4197d4d845c53b5", 0, "dir-8" },
+		{ 0100644, "3ef4d30382ca33fdeba9fda895a99e0891ba37aa", 2, "dir-9" },
+		{ 0100644, "fc4c636d6515e9e261f9260dbcf3cc6eca97ea08", 1, "dir-9/file.txt" },
+		{ 0100644, "76ab0e2868197ec158ddd6c78d8a0d2fd73d38f9", 3, "dir-9/file.txt" },
+		{ 0100644, "5c2411f8075f48a6b2fdb85ebc0d371747c4df15", 0, "file-1/new" },
+		{ 0100644, "a39a620dae5bc8b4e771cd4d251b7d080401a21e", 1, "file-2" },
+		{ 0100644, "d963979c237d08b6ba39062ee7bf64c7d34a27f8", 2, "file-2" },
+		{ 0100644, "5c341ead2ba6f2af98ce5ec3fe84f6b6d2899c0d", 0, "file-2/new" },
+		{ 0100644, "9efe7723802d4305142eee177e018fee1572c4f4", 0, "file-3/new" },
+		{ 0100644, "bacac9b3493509aa15e1730e1545fc0919d1dae0", 1, "file-4" },
+		{ 0100644, "7663fce0130db092936b137cabd693ec234eb060", 3, "file-4" },
+		{ 0100644, "e49f917b448d1340b31d76e54ba388268fd4c922", 0, "file-4/new" },
+		{ 0100644, "cab2cf23998b40f1af2d9d9a756dc9e285a8df4b", 2, "file-5/new" },
+		{ 0100644, "f5504f36e6f4eb797a56fc5bac6c6c7f32969bf2", 3, "file-5/new" },
+    };
+
+	cl_git_pass(merge_trees_from_branches(&index, repo, DF_SIDE1_BRANCH, DF_SIDE2_BRANCH, NULL));
+
+	cl_assert(merge_test_index(index, merge_index_entries, 20));
+
+	git_index_free(index);
+}
diff --git a/tests-clar/merge/trees/renames.c b/tests-clar/merge/trees/renames.c
new file mode 100644
index 0000000..dc0564b
--- /dev/null
+++ b/tests-clar/merge/trees/renames.c
@@ -0,0 +1,253 @@
+#include "clar_libgit2.h"
+#include "git2/repository.h"
+#include "git2/merge.h"
+#include "buffer.h"
+#include "merge.h"
+#include "../merge_helpers.h"
+#include "fileops.h"
+
+static git_repository *repo;
+
+#define TEST_REPO_PATH "merge-resolve"
+
+#define BRANCH_RENAME_OURS					"rename_conflict_ours"
+#define BRANCH_RENAME_THEIRS				"rename_conflict_theirs"
+
+// Fixture setup and teardown
+void test_merge_trees_renames__initialize(void)
+{
+	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+}
+
+void test_merge_trees_renames__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+void test_merge_trees_renames__index(void)
+{
+	git_index *index;
+	git_merge_tree_opts *opts = NULL;
+
+	struct merge_index_entry merge_index_entries[] = {
+		{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
+		{ 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-duplicated-in-ours.txt" },
+		{ 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 1, "0b-rewritten-in-ours.txt" },
+		{ 0100644, "e376fbdd06ebf021c92724da9f26f44212734e3e", 2, "0b-rewritten-in-ours.txt" },
+		{ 0100644, "b2d399ae15224e1d58066e3c8df70ce37de7a656", 3, "0b-rewritten-in-ours.txt" },
+		{ 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 0, "0c-duplicated-in-theirs.txt" },
+		{ 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 1, "0c-rewritten-in-theirs.txt" },
+		{ 0100644, "efc9121fdedaf08ba180b53ebfbcf71bd488ed09", 2, "0c-rewritten-in-theirs.txt" },
+		{ 0100644, "712ebba6669ea847d9829e4f1059d6c830c8b531", 3, "0c-rewritten-in-theirs.txt" },
+		{ 0100644, "0d872f8e871a30208305978ecbf9e66d864f1638", 0, "1a-newname-in-ours-edited-in-theirs.txt" },
+		{ 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-newname-in-ours.txt" },
+		{ 0100644, "ed9523e62e453e50dd9be1606af19399b96e397a", 0, "1b-newname-in-theirs-edited-in-ours.txt" },
+		{ 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-newname-in-theirs.txt" },
+		{ 0100644, "178940b450f238a56c0d75b7955cb57b38191982", 0, "2-newname-in-both.txt" },
+		{ 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 2, "3a-newname-in-ours-deleted-in-theirs.txt" },
+		{ 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 1, "3a-renamed-in-ours-deleted-in-theirs.txt" },
+		{ 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 3, "3b-newname-in-theirs-deleted-in-ours.txt" },
+		{ 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 1, "3b-renamed-in-theirs-deleted-in-ours.txt" },
+		{ 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 2, "4a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "8b5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a", 3, "4a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 1, "4a-renamed-in-ours-added-in-theirs.txt" },
+		{ 0100644, "de872ee3618b894992e9d1e18ba2ebe256a112f9", 2, "4b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "98d52d07c0b0bbf2b46548f6aa521295c2cb55db", 3, "4b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "98d52d07c0b0bbf2b46548f6aa521295c2cb55db", 1, "4b-renamed-in-theirs-added-in-ours.txt" },
+		{ 0100644, "d3719a5ae8e4d92276b5313ce976f6ee5af2b436", 2, "5a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "98ba4205fcf31f5dd93c916d35fe3f3b3d0e6714", 3, "5a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "d3719a5ae8e4d92276b5313ce976f6ee5af2b436", 1, "5a-renamed-in-ours-added-in-theirs.txt" },
+		{ 0100644, "d3719a5ae8e4d92276b5313ce976f6ee5af2b436", 3, "5a-renamed-in-ours-added-in-theirs.txt" },
+		{ 0100644, "385c8a0f26ddf79e9041e15e17dc352ed2c4cced", 2, "5b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "63247125386de9ec90a27ad36169307bf8a11a38", 3, "5b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "63247125386de9ec90a27ad36169307bf8a11a38", 1, "5b-renamed-in-theirs-added-in-ours.txt" },
+		{ 0100644, "63247125386de9ec90a27ad36169307bf8a11a38", 2, "5b-renamed-in-theirs-added-in-ours.txt" },
+		{ 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 2, "6-both-renamed-1-to-2-ours.txt" },
+		{ 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 3, "6-both-renamed-1-to-2-theirs.txt" },
+		{ 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 1, "6-both-renamed-1-to-2.txt" },
+		{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 1, "7-both-renamed-side-1.txt" },
+		{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 3, "7-both-renamed-side-1.txt" },
+		{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 1, "7-both-renamed-side-2.txt" },
+		{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 2, "7-both-renamed-side-2.txt" },
+		{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" },
+		{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
+	};
+	
+	struct merge_name_entry merge_name_entries[] = {
+		{
+			"3a-renamed-in-ours-deleted-in-theirs.txt",
+			"3a-newname-in-ours-deleted-in-theirs.txt",
+			""
+		},
+		
+		{
+			"3b-renamed-in-theirs-deleted-in-ours.txt",
+			"",
+			"3b-newname-in-theirs-deleted-in-ours.txt",
+		},
+
+		{
+			"4a-renamed-in-ours-added-in-theirs.txt",
+			"4a-newname-in-ours-added-in-theirs.txt",
+			"",
+		},
+
+		{
+			"4b-renamed-in-theirs-added-in-ours.txt",
+			"",
+			"4b-newname-in-theirs-added-in-ours.txt",
+		},
+		
+		{
+			"5a-renamed-in-ours-added-in-theirs.txt",
+			"5a-newname-in-ours-added-in-theirs.txt",
+			"5a-renamed-in-ours-added-in-theirs.txt",
+		},
+
+		{
+			"5b-renamed-in-theirs-added-in-ours.txt",
+			"5b-renamed-in-theirs-added-in-ours.txt",
+			"5b-newname-in-theirs-added-in-ours.txt",
+		},
+
+		{
+			"6-both-renamed-1-to-2.txt",
+			"6-both-renamed-1-to-2-ours.txt",
+			"6-both-renamed-1-to-2-theirs.txt",
+		},
+		
+		{
+			"7-both-renamed-side-1.txt",
+			"7-both-renamed.txt",
+			"7-both-renamed-side-1.txt",
+		},
+		
+		{
+			"7-both-renamed-side-2.txt",
+			"7-both-renamed-side-2.txt",
+			"7-both-renamed.txt",
+		},
+	};
+
+	struct merge_reuc_entry merge_reuc_entries[] = {
+		{ "1a-newname-in-ours-edited-in-theirs.txt",
+			0, 0100644, 0,
+			"",
+			"c3d02eeef75183df7584d8d13ac03053910c1301",
+			"" },
+
+		{ "1a-newname-in-ours.txt",
+			0, 0100644, 0,
+			"",
+			"d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb",
+			"" },
+
+		{ "1a-renamed-in-ours-edited-in-theirs.txt",
+			0100644, 0, 0100644,
+			"c3d02eeef75183df7584d8d13ac03053910c1301",
+			"",
+			"0d872f8e871a30208305978ecbf9e66d864f1638" },
+
+		{ "1a-renamed-in-ours.txt",
+			0100644, 0, 0100644,
+			"d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb",
+			"",
+			"d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb" },
+
+		{ "1b-newname-in-theirs-edited-in-ours.txt",
+			0, 0, 0100644,
+			"",
+			"",
+			"241a1005cd9b980732741b74385b891142bcba28" },
+		
+		{ "1b-newname-in-theirs.txt",
+			0, 0, 0100644,
+			"",
+			"",
+			"2b5f1f181ee3b58ea751f5dd5d8f9b445520a136" },
+
+		{ "1b-renamed-in-theirs-edited-in-ours.txt",
+			0100644, 0100644, 0,
+			"241a1005cd9b980732741b74385b891142bcba28",
+			"ed9523e62e453e50dd9be1606af19399b96e397a",
+			"" },
+
+		{ "1b-renamed-in-theirs.txt",
+			0100644, 0100644, 0,
+			"2b5f1f181ee3b58ea751f5dd5d8f9b445520a136",
+			"2b5f1f181ee3b58ea751f5dd5d8f9b445520a136",
+			"" },
+
+		{ "2-newname-in-both.txt",
+			0, 0100644, 0100644,
+			"",
+			"178940b450f238a56c0d75b7955cb57b38191982",
+			"178940b450f238a56c0d75b7955cb57b38191982" },
+
+		{ "2-renamed-in-both.txt",
+			0100644, 0, 0,
+			"178940b450f238a56c0d75b7955cb57b38191982",
+			"",
+			"" },
+	};
+
+	cl_git_pass(merge_trees_from_branches(&index, repo,
+		BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
+		opts));
+	
+	cl_assert(merge_test_index(index, merge_index_entries, 41));
+	cl_assert(merge_test_names(index, merge_name_entries, 9));
+	cl_assert(merge_test_reuc(index, merge_reuc_entries, 10));
+	
+	git_index_free(index);
+}
+
+void test_merge_trees_renames__no_rename_index(void)
+{
+	git_index *index;
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+	
+	struct merge_index_entry merge_index_entries[] = {
+		{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
+		{ 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-duplicated-in-ours.txt" },
+		{ 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 1, "0b-rewritten-in-ours.txt" },
+		{ 0100644, "e376fbdd06ebf021c92724da9f26f44212734e3e", 2, "0b-rewritten-in-ours.txt" },
+		{ 0100644, "b2d399ae15224e1d58066e3c8df70ce37de7a656", 3, "0b-rewritten-in-ours.txt" },
+		{ 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 0, "0c-duplicated-in-theirs.txt" },
+		{ 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 1, "0c-rewritten-in-theirs.txt" },
+		{ 0100644, "efc9121fdedaf08ba180b53ebfbcf71bd488ed09", 2, "0c-rewritten-in-theirs.txt" },
+		{ 0100644, "712ebba6669ea847d9829e4f1059d6c830c8b531", 3, "0c-rewritten-in-theirs.txt" },
+		{ 0100644, "c3d02eeef75183df7584d8d13ac03053910c1301", 0, "1a-newname-in-ours-edited-in-theirs.txt" },
+		{ 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-newname-in-ours.txt" },
+		{ 0100644, "c3d02eeef75183df7584d8d13ac03053910c1301", 1, "1a-renamed-in-ours-edited-in-theirs.txt" },
+		{ 0100644, "0d872f8e871a30208305978ecbf9e66d864f1638", 3, "1a-renamed-in-ours-edited-in-theirs.txt" },
+		{ 0100644, "241a1005cd9b980732741b74385b891142bcba28", 0, "1b-newname-in-theirs-edited-in-ours.txt" },
+		{ 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-newname-in-theirs.txt" },
+		{ 0100644, "241a1005cd9b980732741b74385b891142bcba28", 1, "1b-renamed-in-theirs-edited-in-ours.txt" },
+		{ 0100644, "ed9523e62e453e50dd9be1606af19399b96e397a", 2, "1b-renamed-in-theirs-edited-in-ours.txt" },
+		{ 0100644, "178940b450f238a56c0d75b7955cb57b38191982", 0, "2-newname-in-both.txt" },
+		{ 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 0, "3a-newname-in-ours-deleted-in-theirs.txt" },
+		{ 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 0, "3b-newname-in-theirs-deleted-in-ours.txt" },
+		{ 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 2, "4a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "8b5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a", 3, "4a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "de872ee3618b894992e9d1e18ba2ebe256a112f9", 2, "4b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "98d52d07c0b0bbf2b46548f6aa521295c2cb55db", 3, "4b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "d3719a5ae8e4d92276b5313ce976f6ee5af2b436", 2, "5a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "98ba4205fcf31f5dd93c916d35fe3f3b3d0e6714", 3, "5a-newname-in-ours-added-in-theirs.txt" },
+		{ 0100644, "385c8a0f26ddf79e9041e15e17dc352ed2c4cced", 2, "5b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "63247125386de9ec90a27ad36169307bf8a11a38", 3, "5b-newname-in-theirs-added-in-ours.txt" },
+		{ 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "6-both-renamed-1-to-2-ours.txt" },
+		{ 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "6-both-renamed-1-to-2-theirs.txt" },
+		{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 2, "7-both-renamed.txt" },
+		{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 3, "7-both-renamed.txt" },
+	};
+	
+	cl_git_pass(merge_trees_from_branches(&index, repo,
+		BRANCH_RENAME_OURS, BRANCH_RENAME_THEIRS,
+		&opts));
+	
+	cl_assert(merge_test_index(index, merge_index_entries, 32));
+	
+	git_index_free(index);
+}
+
diff --git a/tests-clar/merge/trees/treediff.c b/tests-clar/merge/trees/treediff.c
new file mode 100644
index 0000000..06ea94e
--- /dev/null
+++ b/tests-clar/merge/trees/treediff.c
@@ -0,0 +1,543 @@
+#include "clar_libgit2.h"
+#include "git2/tree.h"
+#include "merge.h"
+#include "../merge_helpers.h"
+#include "diff.h"
+#include "hashsig.h"
+
+static git_repository *repo;
+
+#define TEST_REPO_PATH "merge-resolve"
+
+#define TREE_OID_ANCESTOR		"0d52e3a556e189ba0948ae56780918011c1b167d"
+#define TREE_OID_MASTER			"1f81433e3161efbf250576c58fede7f6b836f3d3"
+#define TREE_OID_BRANCH			"eea9286df54245fea72c5b557291470eb825f38f"
+#define TREE_OID_RENAMES1		"f5f9dd5886a6ee20272be0aafc790cba43b31931"
+#define TREE_OID_RENAMES2		"5fbfbdc04b4eca46f54f4853a3c5a1dce28f5165"
+
+#define TREE_OID_DF_ANCESTOR	"b8a3a806d3950e8c0a03a34f234a92eff0e2c68d"
+#define TREE_OID_DF_SIDE1		"ee1d6f164893c1866a323f072eeed36b855656be"
+#define TREE_OID_DF_SIDE2		"6178885b38fe96e825ac0f492c0a941f288b37f6"
+
+#define TREE_OID_RENAME_CONFLICT_ANCESTOR	"476dbb3e207313d1d8aaa120c6ad204bf1295e53"
+#define TREE_OID_RENAME_CONFLICT_OURS		"c4efe31e9decccc8b2b4d3df9aac2cdfe2995618"
+#define TREE_OID_RENAME_CONFLICT_THEIRS		"9e7f4359c469f309b6057febf4c6e80742cbed5b"
+
+void test_merge_trees_treediff__initialize(void)
+{
+	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+}
+
+void test_merge_trees_treediff__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+static void test_find_differences(
+    const char *ancestor_oidstr,
+    const char *ours_oidstr,
+    const char *theirs_oidstr,
+    struct merge_index_conflict_data *treediff_conflict_data,
+    size_t treediff_conflict_data_len)
+{
+    git_merge_diff_list *merge_diff_list = git_merge_diff_list__alloc(repo);
+    git_oid ancestor_oid, ours_oid, theirs_oid;
+    git_tree *ancestor_tree, *ours_tree, *theirs_tree;
+
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+	opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
+	opts.target_limit = 1000;
+	opts.rename_threshold = 50;
+
+	opts.metric = git__malloc(sizeof(git_diff_similarity_metric));
+	cl_assert(opts.metric != NULL);
+
+	opts.metric->file_signature = git_diff_find_similar__hashsig_for_file;
+	opts.metric->buffer_signature = git_diff_find_similar__hashsig_for_buf;
+	opts.metric->free_signature = git_diff_find_similar__hashsig_free;
+	opts.metric->similarity = git_diff_find_similar__calc_similarity;
+	opts.metric->payload = (void *)GIT_HASHSIG_SMART_WHITESPACE;
+
+    cl_git_pass(git_oid_fromstr(&ancestor_oid, ancestor_oidstr));
+    cl_git_pass(git_oid_fromstr(&ours_oid, ours_oidstr));
+    cl_git_pass(git_oid_fromstr(&theirs_oid, theirs_oidstr));
+    
+    cl_git_pass(git_tree_lookup(&ancestor_tree, repo, &ancestor_oid));
+    cl_git_pass(git_tree_lookup(&ours_tree, repo, &ours_oid));
+    cl_git_pass(git_tree_lookup(&theirs_tree, repo, &theirs_oid));
+    
+	cl_git_pass(git_merge_diff_list__find_differences(merge_diff_list, ancestor_tree, ours_tree, theirs_tree));
+	cl_git_pass(git_merge_diff_list__find_renames(repo, merge_diff_list, &opts));
+
+	/*
+	dump_merge_index(merge_index);
+	 */
+	
+    cl_assert(treediff_conflict_data_len == merge_diff_list->conflicts.length);
+
+	cl_assert(merge_test_merge_conflicts(&merge_diff_list->conflicts, treediff_conflict_data, treediff_conflict_data_len));
+
+    git_tree_free(ancestor_tree);
+    git_tree_free(ours_tree);
+    git_tree_free(theirs_tree);
+    
+	git_merge_diff_list__free(merge_diff_list);
+	
+	git__free(opts.metric);
+}
+
+void test_merge_trees_treediff__simple(void)
+{
+    struct merge_index_conflict_data treediff_conflict_data[] = {
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE
+		},
+
+        {
+			{ { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "058541fc37114bfc1dddf6bd6bffc7fae5c2e6fe", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_BOTH_MODIFIED
+		},
+		
+		{
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-branch.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-branch.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "4eb04c9e79e88f6640d01ff5b25ca2a60764f216", 0, "changed-in-branch.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_NONE
+		},
+		
+		{
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0, "changed-in-master.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE
+        },
+		
+		{
+			{ { 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 0, "conflicting.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 0, "conflicting.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "2bd0a343aeef7a2cf0d158478966a6e587ff3863", 0, "conflicting.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_BOTH_MODIFIED
+        },
+		
+		{
+			{ { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_NONE
+        },
+		
+		{
+			{ { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE
+		},
+    };
+    
+    test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_BRANCH, treediff_conflict_data, 7);
+}
+
+void test_merge_trees_treediff__df_conflicts(void)
+{
+    struct merge_index_conflict_data treediff_conflict_data[] = {
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "49130a28ef567af9a6a6104c38773fedfa5f9742", 0, "dir-10" }, GIT_DELTA_ADDED },
+			{ { 0100644, "6c06dcd163587c2cc18be44857e0b71116382aeb", 0, "dir-10" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_BOTH_ADDED,
+		},
+
+		{
+			{ { 0100644, "242591eb280ee9eeb2ce63524b9a8b9bc4cb515d", 0, "dir-10/file.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_BOTH_DELETED,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "43aafd43bea779ec74317dc361f45ae3f532a505", 0, "dir-6" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "cf8c5cc8a85a1ff5a4ba51e0bc7cf5665669924d", 0, "dir-6/file.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "cf8c5cc8a85a1ff5a4ba51e0bc7cf5665669924d", 0, "dir-6/file.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_NONE,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "a031a28ae70e33a641ce4b8a8f6317f1ab79dee4", 0, "dir-7" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_DIRECTORY_FILE,
+		},
+
+		{
+			{ { 0100644, "5012fd565b1393bdfda1805d4ec38ce6619e1fd1", 0, "dir-7/file.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "a5563304ddf6caba25cb50323a2ea6f7dbfcadca", 0, "dir-7/file.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_DF_CHILD,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "e9ad6ec3e38364a3d07feda7c4197d4d845c53b5", 0, "dir-8" }, GIT_DELTA_ADDED },
+			{ {0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "f20c9063fa0bda9a397c96947a7b687305c49753", 0, "dir-8/file.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "f20c9063fa0bda9a397c96947a7b687305c49753", 0, "dir-8/file.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "3ef4d30382ca33fdeba9fda895a99e0891ba37aa", 0, "dir-9" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_DIRECTORY_FILE,
+		},
+
+		{
+			{ { 0100644, "fc4c636d6515e9e261f9260dbcf3cc6eca97ea08", 0, "dir-9/file.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "76ab0e2868197ec158ddd6c78d8a0d2fd73d38f9", 0, "dir-9/file.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_DF_CHILD,
+		},
+
+		{
+			{ { 0100644, "1e4ff029aee68d0d69ef9eb6efa6cbf1ec732f99", 0, "file-1" },  GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "1e4ff029aee68d0d69ef9eb6efa6cbf1ec732f99", 0, "file-1" },  GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "5c2411f8075f48a6b2fdb85ebc0d371747c4df15", 0, "file-1/new" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "a39a620dae5bc8b4e771cd4d251b7d080401a21e", 0, "file-2" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "d963979c237d08b6ba39062ee7bf64c7d34a27f8", 0, "file-2" }, GIT_DELTA_MODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_DIRECTORY_FILE,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "5c341ead2ba6f2af98ce5ec3fe84f6b6d2899c0d", 0, "file-2/new" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_DF_CHILD,
+		},
+
+		{
+			{ { 0100644, "032ebc5ab85d9553bb187d3cd40875ff23a63ed0", 0, "file-3" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "032ebc5ab85d9553bb187d3cd40875ff23a63ed0", 0, "file-3" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "9efe7723802d4305142eee177e018fee1572c4f4", 0, "file-3/new" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "bacac9b3493509aa15e1730e1545fc0919d1dae0", 0, "file-4" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "7663fce0130db092936b137cabd693ec234eb060", 0, "file-4" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_DIRECTORY_FILE,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "e49f917b448d1340b31d76e54ba388268fd4c922", 0, "file-4/new" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_DF_CHILD,
+		},
+
+		{
+			{ { 0100644, "ac4045f965119e6998f4340ed0f411decfb3ec05", 0, "file-5" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_BOTH_DELETED,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "cab2cf23998b40f1af2d9d9a756dc9e285a8df4b", 0, "file-5/new" }, GIT_DELTA_ADDED },
+			{ { 0100644, "f5504f36e6f4eb797a56fc5bac6c6c7f32969bf2", 0, "file-5/new" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_BOTH_ADDED,
+		},
+	};
+	
+	test_find_differences(TREE_OID_DF_ANCESTOR, TREE_OID_DF_SIDE1, TREE_OID_DF_SIDE2, treediff_conflict_data, 20);
+}
+
+void test_merge_trees_treediff__strict_renames(void)
+{
+	struct merge_index_conflict_data treediff_conflict_data[] = {
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+        
+		{
+			{ { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0, "changed-in-master.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 0, "conflicting.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 0, "conflicting.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 0, "conflicting.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "removed-in-branch.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "dfe3f22baa1f6fce5447901c3086bae368de6bdd", 0, "renamed-in-branch.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644,  "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "renamed.txt" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "unchanged.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "unchanged.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "c8f06f2e3bb2964174677e91f0abead0e43c9e5d", 0, "copied.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_NONE,
+		},
+    };
+    
+    test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_RENAMES1, treediff_conflict_data, 8);
+}
+
+void test_merge_trees_treediff__rename_conflicts(void)
+{
+	struct merge_index_conflict_data treediff_conflict_data[] = {
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-duplicated-in-ours.txt" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "f0ce2b8e4986084d9b308fb72709e414c23eb5e6", 0, "0b-rewritten-in-ours.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "e376fbdd06ebf021c92724da9f26f44212734e3e", 0, "0b-rewritten-in-ours.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "b2d399ae15224e1d58066e3c8df70ce37de7a656", 0, "0b-rewritten-in-ours.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_BOTH_MODIFIED,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 0, "0c-duplicated-in-theirs.txt" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_NONE,
+		},
+		
+		{
+			{ { 0100644, "2f56120107d680129a5d9791b521cb1e73a2ed31", 0, "0c-rewritten-in-theirs.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "efc9121fdedaf08ba180b53ebfbcf71bd488ed09", 0, "0c-rewritten-in-theirs.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "712ebba6669ea847d9829e4f1059d6c830c8b531", 0, "0c-rewritten-in-theirs.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_BOTH_MODIFIED,
+		},
+
+		{
+			{ { 0100644, "c3d02eeef75183df7584d8d13ac03053910c1301", 0, "1a-renamed-in-ours-edited-in-theirs.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "c3d02eeef75183df7584d8d13ac03053910c1301", 0, "1a-newname-in-ours-edited-in-theirs.txt" }, GIT_DELTA_RENAMED },
+			{ { 0100644, "0d872f8e871a30208305978ecbf9e66d864f1638", 0, "1a-renamed-in-ours-edited-in-theirs.txt" }, GIT_DELTA_MODIFIED },
+			GIT_MERGE_DIFF_RENAMED_MODIFIED,
+		},
+		
+		{
+			{ { 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-renamed-in-ours.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-newname-in-ours.txt" }, GIT_DELTA_RENAMED },
+			{ { 0100644, "d0d4594e16f2e19107e3fa7ea63e7aaaff305ffb", 0, "1a-renamed-in-ours.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+		
+		{
+			{ { 0100644, "241a1005cd9b980732741b74385b891142bcba28", 0, "1b-renamed-in-theirs-edited-in-ours.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "ed9523e62e453e50dd9be1606af19399b96e397a", 0, "1b-renamed-in-theirs-edited-in-ours.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "241a1005cd9b980732741b74385b891142bcba28", 0, "1b-newname-in-theirs-edited-in-ours.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_RENAMED_MODIFIED,
+		},
+		
+		{
+			{ { 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-renamed-in-theirs.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-renamed-in-theirs.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "2b5f1f181ee3b58ea751f5dd5d8f9b445520a136", 0, "1b-newname-in-theirs.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "178940b450f238a56c0d75b7955cb57b38191982", 0, "2-renamed-in-both.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "178940b450f238a56c0d75b7955cb57b38191982", 0, "2-newname-in-both.txt" }, GIT_DELTA_RENAMED },
+			{ { 0100644, "178940b450f238a56c0d75b7955cb57b38191982", 0, "2-newname-in-both.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_BOTH_RENAMED,
+		},
+		
+		{
+			{ { 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 0, "3a-renamed-in-ours-deleted-in-theirs.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "18cb316b1cefa0f8a6946f0e201a8e1a6f845ab9", 0, "3a-newname-in-ours-deleted-in-theirs.txt" }, GIT_DELTA_RENAMED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_RENAMED_DELETED,
+		},
+		
+		{
+			{ { 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 0, "3b-renamed-in-theirs-deleted-in-ours.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "36219b49367146cb2e6a1555b5a9ebd4d0328495", 0, "3b-newname-in-theirs-deleted-in-ours.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_RENAMED_DELETED,
+		},
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "8b5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a", 0, "4a-newname-in-ours-added-in-theirs.txt" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_RENAMED_ADDED,
+		},		
+		
+		{
+			{ { 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 0, "4a-renamed-in-ours-added-in-theirs.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "227792b52aaa0b238bea00ec7e509b02623f168c", 0, "4a-newname-in-ours-added-in-theirs.txt" }, GIT_DELTA_RENAMED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			GIT_MERGE_DIFF_RENAMED_ADDED,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "de872ee3618b894992e9d1e18ba2ebe256a112f9", 0, "4b-newname-in-theirs-added-in-ours.txt" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_RENAMED_ADDED,
+		},
+
+		{
+			{ { 0100644, "98d52d07c0b0bbf2b46548f6aa521295c2cb55db", 0, "4b-renamed-in-theirs-added-in-ours.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "98d52d07c0b0bbf2b46548f6aa521295c2cb55db", 0, "4b-newname-in-theirs-added-in-ours.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_RENAMED_ADDED,
+		},
+		
+		{
+			{ { 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "5-both-renamed-1-to-2.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "5-both-renamed-1-to-2-ours.txt" }, GIT_DELTA_RENAMED },
+			{ { 0100644, "d8fa77b6833082c1ea36b7828a582d4c43882450", 0, "5-both-renamed-1-to-2-theirs.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2,
+		},
+		
+		{
+			{ { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "6-both-renamed-side-1.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "6-both-renamed.txt" }, GIT_DELTA_RENAMED },
+			{ { 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "6-both-renamed-side-1.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1,
+		},
+		
+		{
+			{ { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "6-both-renamed-side-2.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "6-both-renamed-side-2.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "6-both-renamed.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1,
+		},
+    };
+    
+    test_find_differences(TREE_OID_RENAME_CONFLICT_ANCESTOR,
+		TREE_OID_RENAME_CONFLICT_OURS, TREE_OID_RENAME_CONFLICT_THEIRS, treediff_conflict_data, 18);
+}
+
+void test_merge_trees_treediff__best_renames(void)
+{
+	struct merge_index_conflict_data treediff_conflict_data[] = {
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" }, GIT_DELTA_ADDED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+        },
+
+		{
+			{ { 0100644, "6212c31dab5e482247d7977e4f0dd3601decf13b", 0, "automergeable.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf", 0, "automergeable.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "45299c1ca5e07bba1fd90843056fb559f96b1f5a", 0, "renamed-90.txt" }, GIT_DELTA_RENAMED },
+			GIT_MERGE_DIFF_RENAMED_MODIFIED,
+        },
+		
+		{
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "11deab00b2d3a6f5a3073988ac050c2d7b6655e2", 0, "changed-in-master.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "ab6c44a2e84492ad4b41bb6bac87353e9d02ac8b", 0, "changed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+        },
+
+		{
+			{ { 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 0, "conflicting.txt" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "4e886e602529caa9ab11d71f86634bd1b6e0de10", 0, "conflicting.txt" }, GIT_DELTA_MODIFIED },
+			{ { 0100644, "d427e0b2e138501a3d15cc376077a3631e15bd46", 0, "conflicting.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" },GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_DELETED },
+			{ { 0100644, "5c3b68a71fc4fa5d362fd3875e53137c6a5ab7a5", 0, "removed-in-master.txt" }, GIT_DELTA_UNMODIFIED },
+			GIT_MERGE_DIFF_MODIFIED_DELETED,
+        },
+		
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "5843febcb23480df0b5edb22a21c59c772bb8e29", 0, "renamed-50.txt" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_NONE,
+		},
+
+		{
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0, "", 0, "" }, GIT_DELTA_UNMODIFIED },
+			{ { 0100644, "a77a56a49f8f3ae242e02717f18ebbc60c5cc543", 0, "renamed-75.txt" }, GIT_DELTA_ADDED },
+			GIT_MERGE_DIFF_NONE,
+		},
+    };
+    
+    test_find_differences(TREE_OID_ANCESTOR, TREE_OID_MASTER, TREE_OID_RENAMES2, treediff_conflict_data, 7);
+}
diff --git a/tests-clar/merge/trees/trivial.c b/tests-clar/merge/trees/trivial.c
new file mode 100644
index 0000000..7d8d2cb
--- /dev/null
+++ b/tests-clar/merge/trees/trivial.c
@@ -0,0 +1,397 @@
+#include "clar_libgit2.h"
+#include "git2/repository.h"
+#include "git2/merge.h"
+#include "merge.h"
+#include "../merge_helpers.h"
+#include "refs.h"
+#include "fileops.h"
+#include "git2/sys/index.h"
+
+static git_repository *repo;
+
+#define TEST_REPO_PATH "merge-resolve"
+#define TEST_INDEX_PATH TEST_REPO_PATH "/.git/index"
+
+
+// Fixture setup and teardown
+void test_merge_trees_trivial__initialize(void)
+{
+	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+}
+
+void test_merge_trees_trivial__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+
+static int merge_trivial(git_index **index, const char *ours, const char *theirs, bool automerge)
+{
+	git_commit *our_commit, *their_commit, *ancestor_commit;
+	git_tree *our_tree, *their_tree, *ancestor_tree;
+	git_oid our_oid, their_oid, ancestor_oid;
+	git_buf branch_buf = GIT_BUF_INIT;
+	git_merge_tree_opts opts = GIT_MERGE_TREE_OPTS_INIT;
+
+	opts.automerge_flags |= automerge ? 0 : GIT_MERGE_AUTOMERGE_NONE;
+	
+	git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours);
+	cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
+	cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
+
+	git_buf_clear(&branch_buf);
+	git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
+	cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
+	cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
+
+	cl_git_pass(git_merge_base(&ancestor_oid, repo, git_commit_id(our_commit), git_commit_id(their_commit)));
+	cl_git_pass(git_commit_lookup(&ancestor_commit, repo, &ancestor_oid));
+	
+	cl_git_pass(git_commit_tree(&ancestor_tree, ancestor_commit));
+	cl_git_pass(git_commit_tree(&our_tree, our_commit));
+	cl_git_pass(git_commit_tree(&their_tree, their_commit));
+
+	cl_git_pass(git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, &opts));
+
+	git_buf_free(&branch_buf);
+	git_tree_free(our_tree);
+	git_tree_free(their_tree);
+	git_tree_free(ancestor_tree);
+	git_commit_free(our_commit);
+	git_commit_free(their_commit);
+	git_commit_free(ancestor_commit);
+
+	return 0;
+}
+
+static int merge_trivial_conflict_entrycount(git_index *index)
+{
+	const git_index_entry *entry;
+	size_t count = 0;
+	size_t i;
+
+	for (i = 0; i < git_index_entrycount(index); i++) {
+		cl_assert(entry = git_index_get_byindex(index, i));
+
+		if (git_index_entry_stage(entry) > 0)
+			count++;
+	}
+
+	return count;
+}
+
+/* 2ALT: ancest:(empty)+, head:*empty*, remote:remote = result:remote */
+void test_merge_trees_trivial__2alt(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-2alt", "trivial-2alt-branch", 0));
+
+	cl_assert(entry = git_index_get_bypath(result, "new-in-branch.txt", 0));
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+
+	git_index_free(result);
+}
+
+/* 3ALT: ancest:(empty)+, head:head, remote:*empty* = result:head */
+void test_merge_trees_trivial__3alt(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-3alt", "trivial-3alt-branch", 0));
+
+	cl_assert(entry = git_index_get_bypath(result, "new-in-3alt.txt", 0));
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 4: ancest:(empty)^, head:head, remote:remote = result:no merge */
+void test_merge_trees_trivial__4(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-4", "trivial-4-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "new-and-different.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "new-and-different.txt", 2));
+	cl_assert(entry = git_index_get_bypath(result, "new-and-different.txt", 3));
+	
+	git_index_free(result);
+}
+
+/* 5ALT: ancest:*, head:head, remote:head = result:head */
+void test_merge_trees_trivial__5alt_1(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-5alt-1", "trivial-5alt-1-branch", 0));
+
+	cl_assert(entry = git_index_get_bypath(result, "new-and-same.txt", 0));
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 5ALT: ancest:*, head:head, remote:head = result:head */
+void test_merge_trees_trivial__5alt_2(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-5alt-2", "trivial-5alt-2-branch", 0));
+
+	cl_assert(entry = git_index_get_bypath(result, "modified-to-same.txt", 0));
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 6: ancest:ancest+, head:(empty), remote:(empty) = result:no merge */
+void test_merge_trees_trivial__6(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-6", "trivial-6-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-both.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 1);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-both.txt", 1));
+	
+	git_index_free(result);
+}
+
+/* 6: ancest:ancest+, head:(empty), remote:(empty) = result:no merge */
+void test_merge_trees_trivial__6_automerge(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+	const git_index_reuc_entry *reuc;
+
+	cl_git_pass(merge_trivial(&result, "trivial-6", "trivial-6-branch", 1));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-both.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 1);
+	cl_assert(reuc = git_index_reuc_get_bypath(result, "removed-in-both.txt"));
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 8: ancest:ancest^, head:(empty), remote:ancest = result:no merge */
+void test_merge_trees_trivial__8(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-8", "trivial-8-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-8.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-8.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-8.txt", 3));
+	
+	git_index_free(result);
+}
+
+/* 8: ancest:ancest^, head:(empty), remote:ancest = result:no merge */
+void test_merge_trees_trivial__8_automerge(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+	const git_index_reuc_entry *reuc;
+
+	cl_git_pass(merge_trivial(&result, "trivial-8", "trivial-8-branch", 1));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-8.txt", 0)) == NULL);
+
+	cl_assert(git_index_reuc_entrycount(result) == 1);
+	cl_assert(reuc = git_index_reuc_get_bypath(result, "removed-in-8.txt"));
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 7: ancest:ancest+, head:(empty), remote:remote = result:no merge */
+void test_merge_trees_trivial__7(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-7", "trivial-7-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-7.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3));
+	
+	git_index_free(result);
+}
+
+/* 7: ancest:ancest+, head:(empty), remote:remote = result:no merge */
+void test_merge_trees_trivial__7_automerge(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-7", "trivial-7-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-7.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-7.txt", 3));
+	
+	git_index_free(result);
+}
+
+/* 10: ancest:ancest^, head:ancest, remote:(empty) = result:no merge */
+void test_merge_trees_trivial__10(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-10", "trivial-10-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 2));
+	
+	git_index_free(result);
+}
+
+/* 10: ancest:ancest^, head:ancest, remote:(empty) = result:no merge */
+void test_merge_trees_trivial__10_automerge(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+	const git_index_reuc_entry *reuc;
+
+	cl_git_pass(merge_trivial(&result, "trivial-10", "trivial-10-branch", 1));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-10-branch.txt", 0)) == NULL);
+
+	cl_assert(git_index_reuc_entrycount(result) == 1);
+	cl_assert(reuc = git_index_reuc_get_bypath(result, "removed-in-10-branch.txt"));
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 9: ancest:ancest+, head:head, remote:(empty) = result:no merge */
+void test_merge_trees_trivial__9(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-9", "trivial-9-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2));
+	
+	git_index_free(result);
+}
+
+/* 9: ancest:ancest+, head:head, remote:(empty) = result:no merge */
+void test_merge_trees_trivial__9_automerge(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-9", "trivial-9-branch", 1));
+
+	cl_assert((entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 2);
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "removed-in-9-branch.txt", 2));
+	
+	git_index_free(result);
+}
+
+/* 13: ancest:ancest+, head:head, remote:ancest = result:head */
+void test_merge_trees_trivial__13(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+	git_oid expected_oid;
+
+	cl_git_pass(merge_trivial(&result, "trivial-13", "trivial-13-branch", 0));
+
+	cl_assert(entry = git_index_get_bypath(result, "modified-in-13.txt", 0));
+	cl_git_pass(git_oid_fromstr(&expected_oid, "1cff9ec6a47a537380dedfdd17c9e76d74259a2b"));
+	cl_assert(git_oid_cmp(&entry->oid, &expected_oid) == 0);
+
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 14: ancest:ancest+, head:ancest, remote:remote = result:remote */
+void test_merge_trees_trivial__14(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+	git_oid expected_oid;
+
+	cl_git_pass(merge_trivial(&result, "trivial-14", "trivial-14-branch", 0));
+
+	cl_assert(entry = git_index_get_bypath(result, "modified-in-14-branch.txt", 0));
+	cl_git_pass(git_oid_fromstr(&expected_oid, "26153a3ff3649b6c2bb652d3f06878c6e0a172f9"));
+	cl_assert(git_oid_cmp(&entry->oid, &expected_oid) == 0);
+
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+	cl_assert(merge_trivial_conflict_entrycount(result) == 0);
+	
+	git_index_free(result);
+}
+
+/* 11: ancest:ancest+, head:head, remote:remote = result:no merge */
+void test_merge_trees_trivial__11(void)
+{
+	git_index *result;
+	const git_index_entry *entry;
+
+	cl_git_pass(merge_trivial(&result, "trivial-11", "trivial-11-branch", 0));
+
+	cl_assert((entry = git_index_get_bypath(result, "modified-in-both.txt", 0)) == NULL);
+	cl_assert(git_index_reuc_entrycount(result) == 0);
+
+	cl_assert(merge_trivial_conflict_entrycount(result) == 3);
+	cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 1));
+	cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 2));
+	cl_assert(entry = git_index_get_bypath(result, "modified-in-both.txt", 3));
+	
+	git_index_free(result);
+}
diff --git a/tests-clar/merge/workdir/setup.c b/tests-clar/merge/workdir/setup.c
new file mode 100644
index 0000000..6ae9dbb
--- /dev/null
+++ b/tests-clar/merge/workdir/setup.c
@@ -0,0 +1,140 @@
+#include "clar_libgit2.h"
+#include "git2/repository.h"
+#include "git2/merge.h"
+#include "merge.h"
+#include "refs.h"
+#include "fileops.h"
+
+static git_repository *repo;
+static git_index *repo_index;
+
+#define TEST_REPO_PATH "testrepo"
+#define TEST_INDEX_PATH TEST_REPO_PATH "/.git/index"
+
+#define ORIG_HEAD                   "bd593285fc7fe4ca18ccdbabf027f5d689101452"
+
+#define THEIRS_SIMPLE_BRANCH        "branch"
+#define THEIRS_SIMPLE_OID           "7cb63eed597130ba4abb87b3e544b85021905520"
+
+#define OCTO1_BRANCH                "octo1"
+#define OCTO1_OID                   "16f825815cfd20a07a75c71554e82d8eede0b061"
+
+#define OCTO2_BRANCH                "octo2"
+#define OCTO2_OID                   "158dc7bedb202f5b26502bf3574faa7f4238d56c"
+
+#define OCTO3_BRANCH                "octo3"
+#define OCTO3_OID                   "50ce7d7d01217679e26c55939eef119e0c93e272"
+
+#define OCTO4_BRANCH                "octo4"
+#define OCTO4_OID                   "54269b3f6ec3d7d4ede24dd350dd5d605495c3ae"
+
+#define OCTO5_BRANCH                "octo5"
+#define OCTO5_OID                   "e4f618a2c3ed0669308735727df5ebf2447f022f"
+
+// Fixture setup and teardown
+void test_merge_workdir_setup__initialize(void)
+{
+	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+	git_repository_index(&repo_index, repo);
+}
+
+void test_merge_workdir_setup__cleanup(void)
+{
+	git_index_free(repo_index);
+	cl_git_sandbox_cleanup();
+}
+
+static void write_file_contents(const char *filename, const char *output)
+{
+	git_buf file_path_buf = GIT_BUF_INIT;
+
+	git_buf_printf(&file_path_buf, "%s/%s", git_repository_path(repo),
+		filename);
+	cl_git_rewritefile(file_path_buf.ptr, output);
+
+	git_buf_free(&file_path_buf);
+}
+
+struct merge_head_cb_data {
+	const char **oid_str;
+	unsigned int len;
+
+	unsigned int i;
+};
+
+static int merge_head_foreach_cb(const git_oid *oid, void *payload)
+{
+	git_oid expected_oid;
+	struct merge_head_cb_data *cb_data = payload;
+
+	git_oid_fromstr(&expected_oid, cb_data->oid_str[cb_data->i]);
+	cl_assert(git_oid_cmp(&expected_oid, oid) == 0);
+	cb_data->i++;
+	return 0;
+}
+
+void test_merge_workdir_setup__head_notfound(void)
+{
+	int error;
+
+	cl_git_fail((error = git_repository_mergehead_foreach(repo,
+		merge_head_foreach_cb, NULL)));
+	cl_assert(error == GIT_ENOTFOUND);
+}
+
+void test_merge_workdir_setup__head_invalid_oid(void)
+{
+	int error;
+
+	write_file_contents(GIT_MERGE_HEAD_FILE, "invalid-oid\n");
+
+	cl_git_fail((error = git_repository_mergehead_foreach(repo,
+		merge_head_foreach_cb, NULL)));
+	cl_assert(error == -1);
+}
+
+void test_merge_workdir_setup__head_foreach_nonewline(void)
+{
+	int error;
+
+	write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID);
+
+	cl_git_fail((error = git_repository_mergehead_foreach(repo,
+		merge_head_foreach_cb, NULL)));
+	cl_assert(error == -1);
+}
+
+void test_merge_workdir_setup__head_foreach_one(void)
+{
+	const char *expected = THEIRS_SIMPLE_OID;
+
+	struct merge_head_cb_data cb_data = { &expected, 1 };
+
+	write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID "\n");
+
+	cl_git_pass(git_repository_mergehead_foreach(repo,
+		merge_head_foreach_cb, &cb_data));
+
+	cl_assert(cb_data.i == cb_data.len);
+}
+
+void test_merge_workdir_setup__head_foreach_octopus(void)
+{
+	const char *expected[] = { THEIRS_SIMPLE_OID,
+		OCTO1_OID, OCTO2_OID, OCTO3_OID, OCTO4_OID, OCTO5_OID };
+
+	struct merge_head_cb_data cb_data = { expected, 6 };
+
+	write_file_contents(GIT_MERGE_HEAD_FILE,
+		THEIRS_SIMPLE_OID "\n"
+		OCTO1_OID "\n"
+		OCTO2_OID "\n"
+		OCTO3_OID "\n"
+		OCTO4_OID "\n"
+		OCTO5_OID "\n");
+
+	cl_git_pass(git_repository_mergehead_foreach(repo,
+		merge_head_foreach_cb, &cb_data));
+
+	cl_assert(cb_data.i == cb_data.len);
+}
diff --git a/tests-clar/network/refspecs.c b/tests-clar/network/refspecs.c
index b3d80fb..676a1fa 100644
--- a/tests-clar/network/refspecs.c
+++ b/tests-clar/network/refspecs.c
@@ -81,4 +81,7 @@ void test_network_refspecs__parsing(void)
 
 	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
 	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
+
+	assert_refspec(GIT_DIRECTION_FETCH, "master", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "master", true);
 }
diff --git a/tests-clar/network/remote/local.c b/tests-clar/network/remote/local.c
index 7e847e6..74ef63d 100644
--- a/tests-clar/network/remote/local.c
+++ b/tests-clar/network/remote/local.c
@@ -100,3 +100,44 @@ void test_network_remote_local__nested_tags_are_completely_peeled(void)
 
 	cl_git_pass(git_remote_ls(remote, &ensure_peeled__cb, NULL));
 }
+
+void test_network_remote_local__shorthand_fetch_refspec0(void)
+{
+	const char *refspec = "master:remotes/sloppy/master";
+	const char *refspec2 = "master:boh/sloppy/master";
+
+	git_reference *ref;
+
+	connect_to_local_repository(cl_fixture("testrepo.git"));
+	cl_git_pass(git_remote_add_fetch(remote, refspec));
+	cl_git_pass(git_remote_add_fetch(remote, refspec2));
+
+	cl_git_pass(git_remote_download(remote, NULL, NULL));
+	cl_git_pass(git_remote_update_tips(remote));
+
+	cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
+	git_reference_free(ref);
+
+	cl_git_pass(git_reference_lookup(&ref, repo, "refs/heads/boh/sloppy/master"));
+	git_reference_free(ref);
+}
+
+void test_network_remote_local__shorthand_fetch_refspec1(void)
+{
+	const char *refspec = "master";
+	const char *refspec2 = "hard_tag";
+
+	git_reference *ref;
+
+	connect_to_local_repository(cl_fixture("testrepo.git"));
+	git_remote_clear_refspecs(remote);
+	cl_git_pass(git_remote_add_fetch(remote, refspec));
+	cl_git_pass(git_remote_add_fetch(remote, refspec2));
+
+	cl_git_pass(git_remote_download(remote, NULL, NULL));
+	cl_git_pass(git_remote_update_tips(remote));
+
+	cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master"));
+
+	cl_git_fail(git_reference_lookup(&ref, repo, "refs/tags/hard_tag"));
+}
diff --git a/tests-clar/network/remote/remotes.c b/tests-clar/network/remote/remotes.c
index a5ff741..4c24db8 100644
--- a/tests-clar/network/remote/remotes.c
+++ b/tests-clar/network/remote/remotes.c
@@ -13,7 +13,7 @@ void test_network_remote_remotes__initialize(void)
 
 	cl_git_pass(git_remote_load(&_remote, _repo, "test"));
 
-	_refspec = git_remote_fetchspec(_remote);
+	_refspec = git_remote_get_refspec(_remote, 0);
 	cl_assert(_refspec != NULL);
 }
 
@@ -109,31 +109,57 @@ void test_network_remote_remotes__refspec_parsing(void)
 	cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/test/*");
 }
 
-void test_network_remote_remotes__set_fetchspec(void)
+void test_network_remote_remotes__add_fetchspec(void)
 {
-	cl_git_pass(git_remote_set_fetchspec(_remote, "refs/*:refs/*"));
-	_refspec = git_remote_fetchspec(_remote);
+	size_t size;
+
+	size = git_remote_refspec_count(_remote);
+
+	cl_git_pass(git_remote_add_fetch(_remote, "refs/*:refs/*"));
+
+	size++;
+	cl_assert_equal_i(size, git_remote_refspec_count(_remote));
+
+	_refspec = git_remote_get_refspec(_remote, size - 1);
 	cl_assert_equal_s(git_refspec_src(_refspec), "refs/*");
 	cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*");
+	cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*");
+	cl_assert_equal_i(_refspec->push, false);
 }
 
-void test_network_remote_remotes__set_pushspec(void)
+void test_network_remote_remotes__add_pushspec(void)
 {
-	cl_git_pass(git_remote_set_pushspec(_remote, "refs/*:refs/*"));
-	_refspec = git_remote_pushspec(_remote);
+	size_t size;
+
+	size = git_remote_refspec_count(_remote);
+
+	cl_git_pass(git_remote_add_push(_remote, "refs/*:refs/*"));
+	size++;
+	cl_assert_equal_i(size, git_remote_refspec_count(_remote));
+
+	_refspec = git_remote_get_refspec(_remote, size - 1);
 	cl_assert_equal_s(git_refspec_src(_refspec), "refs/*");
 	cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*");
+	cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*");
+
+	cl_assert_equal_i(_refspec->push, true);
 }
 
 void test_network_remote_remotes__save(void)
 {
+	git_strarray array;
+	const char *fetch_refspec = "refs/heads/*:refs/remotes/upstream/*";
+	const char *push_refspec = "refs/heads/*:refs/heads/*";
+
 	git_remote_free(_remote);
 	_remote = NULL;
 
 	/* Set up the remote and save it to config */
 	cl_git_pass(git_remote_create(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2"));
-	cl_git_pass(git_remote_set_fetchspec(_remote, "refs/heads/*:refs/remotes/upstream/*"));
-	cl_git_pass(git_remote_set_pushspec(_remote, "refs/heads/*:refs/heads/*"));
+	git_remote_clear_refspecs(_remote);
+
+	cl_git_pass(git_remote_add_fetch(_remote, fetch_refspec));
+	cl_git_pass(git_remote_add_push(_remote, push_refspec));
 	cl_git_pass(git_remote_set_pushurl(_remote, "git://github.com/libgit2/libgit2_push"));
 	cl_git_pass(git_remote_save(_remote));
 	git_remote_free(_remote);
@@ -142,19 +168,17 @@ void test_network_remote_remotes__save(void)
 	/* Load it from config and make sure everything matches */
 	cl_git_pass(git_remote_load(&_remote, _repo, "upstream"));
 
-	_refspec = git_remote_fetchspec(_remote);
-	cl_assert(_refspec != NULL);
-	cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*");
-	cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/upstream/*");
-	cl_assert_equal_i(0, git_refspec_force(_refspec));
-
-	_refspec = git_remote_pushspec(_remote);
-	cl_assert(_refspec != NULL);
-	cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*");
-	cl_assert_equal_s(git_refspec_dst(_refspec), "refs/heads/*");
+	cl_git_pass(git_remote_get_fetch_refspecs(&array, _remote));
+	cl_assert_equal_i(1, array.count);
+	cl_assert_equal_s(fetch_refspec, array.strings[0]);
+	git_strarray_free(&array);
 
+	cl_git_pass(git_remote_get_push_refspecs(&array, _remote));
+	cl_assert_equal_i(1, array.count);
+	cl_assert_equal_s(push_refspec, array.strings[0]);
 	cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
 	cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/libgit2_push");
+	git_strarray_free(&array);
 
 	/* remove the pushurl again and see if we can save that too */
 	cl_git_pass(git_remote_set_pushurl(_remote, NULL));
@@ -265,7 +289,7 @@ void test_network_remote_remotes__add(void)
 	_remote = NULL;
 
 	cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
-	_refspec = git_remote_fetchspec(_remote);
+	_refspec = git_vector_get(&_remote->refspecs, 0);
 	cl_assert_equal_s("refs/heads/*", git_refspec_src(_refspec));
 	cl_assert(git_refspec_force(_refspec) == 1);
 	cl_assert_equal_s("refs/remotes/addtest/*", git_refspec_dst(_refspec));
@@ -386,3 +410,43 @@ void test_network_remote_remotes__cannot_create_a_remote_which_name_is_invalid(v
 	assert_cannot_create_remote(".lock", GIT_EINVALIDSPEC);
 	assert_cannot_create_remote("a.lock", GIT_EINVALIDSPEC);
 }
+
+static const char *fetch_refspecs[] = {
+	"+refs/heads/*:refs/remotes/origin/*",
+	"refs/tags/*:refs/tags/*",
+	"+refs/pull/*:refs/pull/*",
+};
+
+static const char *push_refspecs[] = {
+	"refs/heads/*:refs/heads/*",
+	"refs/tags/*:refs/tags/*",
+	"refs/notes/*:refs/notes/*",
+};
+
+void test_network_remote_remotes__query_refspecs(void)
+{
+	git_remote *remote;
+	git_strarray array;
+	int i;
+
+	cl_git_pass(git_remote_create_inmemory(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
+
+	for (i = 0; i < 3; i++) {
+		cl_git_pass(git_remote_add_fetch(remote, fetch_refspecs[i]));
+		cl_git_pass(git_remote_add_push(remote, push_refspecs[i]));
+	}
+
+	cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
+	for (i = 0; i < 3; i++) {
+		cl_assert_equal_s(fetch_refspecs[i], array.strings[i]);
+	}
+	git_strarray_free(&array);
+
+	cl_git_pass(git_remote_get_push_refspecs(&array, remote));
+	for (i = 0; i < 3; i++) {
+		cl_assert_equal_s(push_refspecs[i], array.strings[i]);
+	}
+	git_strarray_free(&array);
+
+	git_remote_free(remote);
+}
diff --git a/tests-clar/object/cache.c b/tests-clar/object/cache.c
new file mode 100644
index 0000000..e06760e
--- /dev/null
+++ b/tests-clar/object/cache.c
@@ -0,0 +1,287 @@
+#include "clar_libgit2.h"
+#include "repository.h"
+
+static git_repository *g_repo;
+
+void test_object_cache__initialize(void)
+{
+	g_repo = NULL;
+}
+
+void test_object_cache__cleanup(void)
+{
+	git_repository_free(g_repo);
+	g_repo = NULL;
+
+	git_libgit2_opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, (int)GIT_OBJ_BLOB, (size_t)0);
+}
+
+static struct {
+	git_otype type;
+	const char *sha;
+} g_data[] = {
+	/* HEAD */
+	{ GIT_OBJ_BLOB, "a8233120f6ad708f843d861ce2b7228ec4e3dec6" }, /* README */
+	{ GIT_OBJ_BLOB, "3697d64be941a53d4ae8f6a271e4e3fa56b022cc" }, /* branch_file.txt */
+	{ GIT_OBJ_BLOB, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd" }, /* new.txt */
+
+	/* refs/heads/subtrees */
+	{ GIT_OBJ_BLOB, "1385f264afb75a56a5bec74243be9b367ba4ca08" }, /* README */
+	{ GIT_OBJ_TREE, "f1425cef211cc08caa31e7b545ffb232acb098c3" }, /* ab */
+	{ GIT_OBJ_BLOB, "d6c93164c249c8000205dd4ec5cbca1b516d487f" }, /* ab/4.txt */
+	{ GIT_OBJ_TREE, "9a03079b8a8ee85a0bee58bf9be3da8b62414ed4" }, /* ab/c */
+	{ GIT_OBJ_BLOB, "270b8ea76056d5cad83af921837702d3e3c2924d" }, /* ab/c/3.txt */
+	{ GIT_OBJ_TREE, "b6361fc6a97178d8fc8639fdeed71c775ab52593" }, /* ab/de */
+	{ GIT_OBJ_BLOB, "e7b4ad382349ff96dd8199000580b9b1e2042eb0" }, /* ab/de/2.txt */
+	{ GIT_OBJ_TREE, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54" }, /* ab/de/fgh */
+	{ GIT_OBJ_BLOB, "1f67fc4386b2d171e0d21be1c447e12660561f9b" }, /* ab/de/fgh/1.txt */
+	{ GIT_OBJ_BLOB, "45b983be36b73c0788dc9cbcb76cbb80fc7bb057" }, /* branch_file.txt */
+	{ GIT_OBJ_BLOB, "fa49b077972391ad58037050f2a75f74e3671e92" }, /* new.txt */
+
+	/* refs/heads/chomped */
+	{ GIT_OBJ_BLOB, "0266163a49e280c4f5ed1e08facd36a2bd716bcf" }, /* readme.txt */
+
+	{ 0, NULL },
+	{ 0, NULL }
+};
+
+void test_object_cache__cache_everything(void)
+{
+	int i, start;
+	git_oid oid;
+	git_odb_object *odb_obj;
+	git_object *obj;
+	git_odb *odb;
+
+	git_libgit2_opts(
+		GIT_OPT_SET_CACHE_OBJECT_LIMIT, (int)GIT_OBJ_BLOB, (size_t)32767);
+
+	cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+	cl_git_pass(git_repository_odb(&odb, g_repo));
+
+	start = (int)git_cache_size(&g_repo->objects);
+
+	for (i = 0; g_data[i].sha != NULL; ++i) {
+		int count = (int)git_cache_size(&g_repo->objects);
+
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+
+		/* alternate between loading raw and parsed objects */
+		if ((i & 1) == 0) {
+			cl_git_pass(git_odb_read(&odb_obj, odb, &oid));
+			cl_assert(g_data[i].type == git_odb_object_type(odb_obj));
+			git_odb_object_free(odb_obj);
+		} else {
+			cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+			cl_assert(g_data[i].type == git_object_type(obj));
+			git_object_free(obj);
+		}
+
+		cl_assert_equal_i(count + 1, (int)git_cache_size(&g_repo->objects));
+	}
+
+	cl_assert_equal_i(i, git_cache_size(&g_repo->objects) - start);
+
+	git_odb_free(odb);
+
+	for (i = 0; g_data[i].sha != NULL; ++i) {
+		int count = (int)git_cache_size(&g_repo->objects);
+
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+		cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+		cl_assert(g_data[i].type == git_object_type(obj));
+		git_object_free(obj);
+
+		cl_assert_equal_i(count, (int)git_cache_size(&g_repo->objects));
+	}
+}
+
+void test_object_cache__cache_no_blobs(void)
+{
+	int i, start, nonblobs = 0;
+	git_oid oid;
+	git_odb_object *odb_obj;
+	git_object *obj;
+	git_odb *odb;
+
+	git_libgit2_opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, (int)GIT_OBJ_BLOB, (size_t)0);
+
+	cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+	cl_git_pass(git_repository_odb(&odb, g_repo));
+
+	start = (int)git_cache_size(&g_repo->objects);
+
+	for (i = 0; g_data[i].sha != NULL; ++i) {
+		int count = (int)git_cache_size(&g_repo->objects);
+
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+
+		/* alternate between loading raw and parsed objects */
+		if ((i & 1) == 0) {
+			cl_git_pass(git_odb_read(&odb_obj, odb, &oid));
+			cl_assert(g_data[i].type == git_odb_object_type(odb_obj));
+			git_odb_object_free(odb_obj);
+		} else {
+			cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+			cl_assert(g_data[i].type == git_object_type(obj));
+			git_object_free(obj);
+		}
+
+		if (g_data[i].type == GIT_OBJ_BLOB)
+			cl_assert_equal_i(count, (int)git_cache_size(&g_repo->objects));
+		else {
+			cl_assert_equal_i(count + 1, (int)git_cache_size(&g_repo->objects));
+			nonblobs++;
+		}
+	}
+
+	cl_assert_equal_i(nonblobs, git_cache_size(&g_repo->objects) - start);
+
+	git_odb_free(odb);
+}
+
+static void *cache_parsed(void *arg)
+{
+	int i;
+	git_oid oid;
+	git_object *obj;
+
+	for (i = ((int *)arg)[1]; g_data[i].sha != NULL; i += 2) {
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+		cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+		cl_assert(g_data[i].type == git_object_type(obj));
+		git_object_free(obj);
+	}
+
+	for (i = 0; i < ((int *)arg)[1]; i += 2) {
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+		cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+		cl_assert(g_data[i].type == git_object_type(obj));
+		git_object_free(obj);
+	}
+
+	return arg;
+}
+
+static void *cache_raw(void *arg)
+{
+	int i;
+	git_oid oid;
+	git_odb *odb;
+	git_odb_object *odb_obj;
+
+	cl_git_pass(git_repository_odb(&odb, g_repo));
+
+	for (i = ((int *)arg)[1]; g_data[i].sha != NULL; i += 2) {
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+		cl_git_pass(git_odb_read(&odb_obj, odb, &oid));
+		cl_assert(g_data[i].type == git_odb_object_type(odb_obj));
+		git_odb_object_free(odb_obj);
+	}
+
+	for (i = 0; i < ((int *)arg)[1]; i += 2) {
+		cl_git_pass(git_oid_fromstr(&oid, g_data[i].sha));
+		cl_git_pass(git_odb_read(&odb_obj, odb, &oid));
+		cl_assert(g_data[i].type == git_odb_object_type(odb_obj));
+		git_odb_object_free(odb_obj);
+	}
+
+	git_odb_free(odb);
+
+	return arg;
+}
+
+#define REPEAT 20
+#define THREADCOUNT 50
+
+void test_object_cache__threadmania(void)
+{
+	int try, th, max_i;
+	void *data;
+	void *(*fn)(void *);
+
+#ifdef GIT_THREADS
+	git_thread t[THREADCOUNT];
+#endif
+
+	for (max_i = 0; g_data[max_i].sha != NULL; ++max_i)
+		/* count up */;
+
+	for (try = 0; try < REPEAT; ++try) {
+
+		cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+
+		for (th = 0; th < THREADCOUNT; ++th) {
+			data = git__malloc(2 * sizeof(int));
+
+			((int *)data)[0] = th;
+			((int *)data)[1] = th % max_i;
+
+			fn = (th & 1) ? cache_parsed : cache_raw;
+
+#ifdef GIT_THREADS
+			cl_git_pass(git_thread_create(&t[th], NULL, fn, data));
+#else
+			cl_assert(fn(data) == data);
+			git__free(data);
+#endif
+		}
+
+#ifdef GIT_THREADS
+		for (th = 0; th < THREADCOUNT; ++th) {
+			cl_git_pass(git_thread_join(t[th], &data));
+			cl_assert_equal_i(th, ((int *)data)[0]);
+			git__free(data);
+		}
+#endif
+
+		git_repository_free(g_repo);
+		g_repo = NULL;
+	}
+}
+
+static void *cache_quick(void *arg)
+{
+	git_oid oid;
+	git_object *obj;
+
+	cl_git_pass(git_oid_fromstr(&oid, g_data[4].sha));
+	cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
+	cl_assert(g_data[4].type == git_object_type(obj));
+	git_object_free(obj);
+
+	return arg;
+}
+
+void test_object_cache__fast_thread_rush(void)
+{
+	int try, th, data[THREADCOUNT*2];
+#ifdef GIT_THREADS
+	git_thread t[THREADCOUNT*2];
+#endif
+
+	for (try = 0; try < REPEAT; ++try) {
+		cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+
+		for (th = 0; th < THREADCOUNT*2; ++th) {
+			data[th] = th;
+#ifdef GIT_THREADS
+			cl_git_pass(
+				git_thread_create(&t[th], NULL, cache_quick, &data[th]));
+#else
+			cl_assert(cache_quick(&data[th]) == &data[th]);
+#endif
+		}
+
+#ifdef GIT_THREADS
+		for (th = 0; th < THREADCOUNT*2; ++th) {
+			void *rval;
+			cl_git_pass(git_thread_join(t[th], &rval));
+			cl_assert_equal_i(th, *((int *)rval));
+		}
+#endif
+
+		git_repository_free(g_repo);
+		g_repo = NULL;
+	}
+}
diff --git a/tests-clar/object/raw/write.c b/tests-clar/object/raw/write.c
index 1b28d0d..9709c03 100644
--- a/tests-clar/object/raw/write.c
+++ b/tests-clar/object/raw/write.c
@@ -1,5 +1,6 @@
-
 #include "clar_libgit2.h"
+#include "git2/odb_backend.h"
+
 #include "fileops.h"
 #include "odb.h"
 
@@ -62,6 +63,7 @@ void test_body(object_data *d, git_rawobj *o)
    git_odb *db;
    git_oid id1, id2;
    git_odb_object *obj;
+   git_rawobj tmp;
 
    make_odb_dir();
    cl_git_pass(git_odb_open(&db, odb_dir));
@@ -72,7 +74,12 @@ void test_body(object_data *d, git_rawobj *o)
    check_object_files(d);
 
    cl_git_pass(git_odb_read(&obj, db, &id1));
-   cmp_objects(&obj->raw, o);
+
+   tmp.data = obj->buffer;
+   tmp.len = obj->cached.size;
+   tmp.type = obj->cached.type;
+
+   cmp_objects(&tmp, o);
 
    git_odb_object_free(obj);
    git_odb_free(db);
diff --git a/tests-clar/odb/loose.c b/tests-clar/odb/loose.c
index f95dc28..9539bb2 100644
--- a/tests-clar/odb/loose.c
+++ b/tests-clar/odb/loose.c
@@ -30,6 +30,7 @@ static void test_read_object(object_data *data)
     git_oid id;
     git_odb_object *obj;
 	git_odb *odb;
+	git_rawobj tmp;
 
     write_object_files(data);
 
@@ -37,7 +38,11 @@ static void test_read_object(object_data *data)
     cl_git_pass(git_oid_fromstr(&id, data->id));
     cl_git_pass(git_odb_read(&obj, odb, &id));
 
-    cmp_objects((git_rawobj *)&obj->raw, data);
+	tmp.data = obj->buffer;
+	tmp.len = obj->cached.size;
+	tmp.type = obj->cached.type;
+
+    cmp_objects(&tmp, data);
 
     git_odb_object_free(obj);
 	git_odb_free(odb);
diff --git a/tests-clar/odb/packed.c b/tests-clar/odb/packed.c
index 90e9f3a..b4f549b 100644
--- a/tests-clar/odb/packed.c
+++ b/tests-clar/odb/packed.c
@@ -46,8 +46,8 @@ void test_odb_packed__read_header_0(void)
 		cl_git_pass(git_odb_read(&obj, _odb, &id));
 		cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
 
-		cl_assert(obj->raw.len == len);
-		cl_assert(obj->raw.type == type);
+		cl_assert(obj->cached.size == len);
+		cl_assert(obj->cached.type == type);
 
 		git_odb_object_free(obj);
 	}
@@ -70,8 +70,8 @@ void test_odb_packed__read_header_1(void)
 		cl_git_pass(git_odb_read(&obj, _odb, &id));
 		cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
 
-		cl_assert(obj->raw.len == len);
-		cl_assert(obj->raw.type == type);
+		cl_assert(obj->cached.size == len);
+		cl_assert(obj->cached.type == type);
 
 		git_odb_object_free(obj);
 	}
diff --git a/tests-clar/odb/packed_one.c b/tests-clar/odb/packed_one.c
index e9d246c..0c6ed38 100644
--- a/tests-clar/odb/packed_one.c
+++ b/tests-clar/odb/packed_one.c
@@ -1,5 +1,6 @@
 #include "clar_libgit2.h"
-#include "odb.h"
+#include "git2/odb_backend.h"
+
 #include "pack_data_one.h"
 #include "pack.h"
 
@@ -51,8 +52,8 @@ void test_odb_packed_one__read_header_0(void)
 		cl_git_pass(git_odb_read(&obj, _odb, &id));
 		cl_git_pass(git_odb_read_header(&len, &type, _odb, &id));
 
-		cl_assert(obj->raw.len == len);
-		cl_assert(obj->raw.type == type);
+		cl_assert(obj->cached.size == len);
+		cl_assert(obj->cached.type == type);
 
 		git_odb_object_free(obj);
 	}
diff --git a/tests-clar/odb/sorting.c b/tests-clar/odb/sorting.c
index b4f9e44..147a160 100644
--- a/tests-clar/odb/sorting.c
+++ b/tests-clar/odb/sorting.c
@@ -1,13 +1,12 @@
 #include "clar_libgit2.h"
-#include "git2/odb_backend.h"
-#include "odb.h"
+#include "git2/sys/odb_backend.h"
 
 typedef struct {
 	git_odb_backend base;
-	int position;
+	size_t position;
 } fake_backend;
 
-static git_odb_backend *new_backend(int position)
+static git_odb_backend *new_backend(size_t position)
 {
 	fake_backend *b;
 
@@ -22,14 +21,13 @@ static git_odb_backend *new_backend(int position)
 
 static void check_backend_sorting(git_odb *odb)
 {
-	unsigned int i;
-
-	for (i = 0; i < odb->backends.length; ++i) {
-		fake_backend *internal =
-			*((fake_backend **)git_vector_get(&odb->backends, i));
+	size_t i, max_i = git_odb_num_backends(odb);
+	fake_backend *internal;
 
+	for (i = 0; i < max_i; ++i) {
+		cl_git_pass(git_odb_get_backend((git_odb_backend **)&internal, odb, i));
 		cl_assert(internal != NULL);
-		cl_assert(internal->position == (int)i);
+		cl_assert_equal_sz(i, internal->position);
 	}
 }
 
diff --git a/tests-clar/online/fetchhead.c b/tests-clar/online/fetchhead.c
index a8a5bb9..e14ae09 100644
--- a/tests-clar/online/fetchhead.c
+++ b/tests-clar/online/fetchhead.c
@@ -42,8 +42,10 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
 	cl_git_pass(git_remote_load(&remote, g_repo, "origin"));
 	git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_AUTO);
 
-	if(fetchspec != NULL)
-		git_remote_set_fetchspec(remote, fetchspec);
+	if(fetchspec != NULL) {
+		git_remote_clear_refspecs(remote);
+		git_remote_add_fetch(remote, fetchspec);
+	}
 
 	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(remote, NULL, NULL));
diff --git a/tests-clar/online/push.c b/tests-clar/online/push.c
index 907d6d2..5dc7974 100644
--- a/tests-clar/online/push.c
+++ b/tests-clar/online/push.c
@@ -160,7 +160,7 @@ static int tracking_branch_list_cb(const char *branch_name, git_branch_t branch_
  */
 static void verify_tracking_branches(git_remote *remote, expected_ref expected_refs[], size_t expected_refs_len)
 {
-	git_refspec *fetch_spec = &remote->fetch;
+	git_refspec *fetch_spec;
 	size_t i, j;
 	git_buf msg = GIT_BUF_INIT;
 	git_buf ref_name = GIT_BUF_INIT;
@@ -179,7 +179,8 @@ static void verify_tracking_branches(git_remote *remote, expected_ref expected_r
 		/* Convert remote reference name into tracking branch name.
 		 * If the spec is not under refs/heads/, then skip.
 		 */
-		if (!git_refspec_src_matches(fetch_spec, expected_refs[i].name))
+		fetch_spec = git_remote__matching_refspec(remote, expected_refs[i].name);
+		if (!fetch_spec)
 			continue;
 
 		cl_git_pass(git_refspec_transform_r(&ref_name, fetch_spec, expected_refs[i].name));
diff --git a/tests-clar/refdb/inmemory.c b/tests-clar/refdb/inmemory.c
index 6f56519..243b5bb 100644
--- a/tests-clar/refdb/inmemory.c
+++ b/tests-clar/refdb/inmemory.c
@@ -1,13 +1,15 @@
 #include "clar_libgit2.h"
-#include "refdb.h"
-#include "repository.h"
+
+#include "buffer.h"
+#include "posix.h"
+#include "path.h"
+#include "refs.h"
+
 #include "testdb.h"
 
 #define TEST_REPO_PATH "testrepo"
 
 static git_repository *repo;
-static git_refdb *refdb;
-static git_refdb_backend *refdb_backend;
 
 int unlink_ref(void *payload, git_buf *file)
 {
@@ -27,7 +29,7 @@ int ref_file_foreach(git_repository *repo, int (* cb)(void *payload, git_buf *fi
 	const char *repo_path;
 	git_buf repo_refs_dir = GIT_BUF_INIT;
 	int error = 0;
-	
+
 	repo_path = git_repository_path(repo);
 
 	git_buf_joinpath(&repo_refs_dir, repo_path, "HEAD");
@@ -39,7 +41,7 @@ int ref_file_foreach(git_repository *repo, int (* cb)(void *payload, git_buf *fi
 	git_buf_joinpath(&repo_refs_dir, git_buf_cstr(&repo_refs_dir), "heads");
 	if (git_path_direach(&repo_refs_dir, cb, NULL) != 0)
 		return -1;
-	
+
 	git_buf_joinpath(&repo_refs_dir, repo_path, "packed-refs");
 	if (git_path_exists(git_buf_cstr(&repo_refs_dir)) &&
 		cb(NULL, &repo_refs_dir) < 0)
@@ -53,17 +55,19 @@ int ref_file_foreach(git_repository *repo, int (* cb)(void *payload, git_buf *fi
 void test_refdb_inmemory__initialize(void)
 {
 	git_buf repo_refs_dir = GIT_BUF_INIT;
+	git_refdb *refdb;
+	git_refdb_backend *refdb_backend;
 
 	repo = cl_git_sandbox_init(TEST_REPO_PATH);
 
 	cl_git_pass(git_repository_refdb(&refdb, repo));
 	cl_git_pass(refdb_backend_test(&refdb_backend, repo));
 	cl_git_pass(git_refdb_set_backend(refdb, refdb_backend));
-	
-	
+
 	ref_file_foreach(repo, unlink_ref);
 
 	git_buf_free(&repo_refs_dir);
+	git_refdb_free(refdb);
 }
 
 void test_refdb_inmemory__cleanup(void)
@@ -75,10 +79,10 @@ void test_refdb_inmemory__doesnt_write_ref_file(void)
 {
 	git_reference *ref;
 	git_oid oid;
-	
+
 	cl_git_pass(git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd"));
 	cl_git_pass(git_reference_create(&ref, repo, GIT_REFS_HEADS_DIR "test1", &oid, 0));
-	
+
 	ref_file_foreach(repo, empty);
 
 	git_reference_free(ref);
@@ -88,10 +92,10 @@ void test_refdb_inmemory__read(void)
 {
 	git_reference *write1, *write2, *write3, *read1, *read2, *read3;
 	git_oid oid1, oid2, oid3;
-	
+
 	cl_git_pass(git_oid_fromstr(&oid1, "c47800c7266a2be04c571c04d5a6614691ea99bd"));
 	cl_git_pass(git_reference_create(&write1, repo, GIT_REFS_HEADS_DIR "test1", &oid1, 0));
-	
+
 	cl_git_pass(git_oid_fromstr(&oid2, "e90810b8df3e80c413d903f631643c716887138d"));
 	cl_git_pass(git_reference_create(&write2, repo, GIT_REFS_HEADS_DIR "test2", &oid2, 0));
 
@@ -135,10 +139,10 @@ int foreach_test(const char *ref_name, void *payload)
 	else if (*i == 2)
 		cl_git_pass(git_oid_fromstr(&expected, "763d71aadf09a7951596c9746c024e7eece7c7af"));
 
-	cl_assert(git_oid_cmp(&expected, &ref->target.oid) == 0);
+	cl_assert(git_oid_cmp(&expected, git_reference_target(ref)) == 0);
 
 	++(*i);
-	
+
 	git_reference_free(ref);
 
 	return 0;
@@ -149,19 +153,19 @@ void test_refdb_inmemory__foreach(void)
 	git_reference *write1, *write2, *write3;
 	git_oid oid1, oid2, oid3;
 	size_t i = 0;
-	
+
 	cl_git_pass(git_oid_fromstr(&oid1, "c47800c7266a2be04c571c04d5a6614691ea99bd"));
 	cl_git_pass(git_reference_create(&write1, repo, GIT_REFS_HEADS_DIR "test1", &oid1, 0));
-	
+
 	cl_git_pass(git_oid_fromstr(&oid2, "e90810b8df3e80c413d903f631643c716887138d"));
 	cl_git_pass(git_reference_create(&write2, repo, GIT_REFS_HEADS_DIR "test2", &oid2, 0));
-	
+
 	cl_git_pass(git_oid_fromstr(&oid3, "763d71aadf09a7951596c9746c024e7eece7c7af"));
 	cl_git_pass(git_reference_create(&write3, repo, GIT_REFS_HEADS_DIR "test3", &oid3, 0));
-	
+
 	cl_git_pass(git_reference_foreach(repo, GIT_REF_LISTALL, foreach_test, &i));
-	cl_assert_equal_i(i, 3);
-	
+	cl_assert_equal_i(3, (int)i);
+
 	git_reference_free(write1);
 	git_reference_free(write2);
 	git_reference_free(write3);
@@ -174,14 +178,14 @@ int delete_test(const char *ref_name, void *payload)
 	size_t *i = payload;
 
 	cl_git_pass(git_reference_lookup(&ref, repo, ref_name));
-	
-	cl_git_pass(git_oid_fromstr(&expected, "e90810b8df3e80c413d903f631643c716887138d"));	
-	cl_assert(git_oid_cmp(&expected, &ref->target.oid) == 0);
-	
+
+	cl_git_pass(git_oid_fromstr(&expected, "e90810b8df3e80c413d903f631643c716887138d"));
+	cl_assert(git_oid_cmp(&expected, git_reference_target(ref)) == 0);
+
 	++(*i);
-	
+
 	git_reference_free(ref);
-	
+
 	return 0;
 }
 
@@ -190,24 +194,24 @@ void test_refdb_inmemory__delete(void)
 	git_reference *write1, *write2, *write3;
 	git_oid oid1, oid2, oid3;
 	size_t i = 0;
-	
+
 	cl_git_pass(git_oid_fromstr(&oid1, "c47800c7266a2be04c571c04d5a6614691ea99bd"));
 	cl_git_pass(git_reference_create(&write1, repo, GIT_REFS_HEADS_DIR "test1", &oid1, 0));
-	
+
 	cl_git_pass(git_oid_fromstr(&oid2, "e90810b8df3e80c413d903f631643c716887138d"));
 	cl_git_pass(git_reference_create(&write2, repo, GIT_REFS_HEADS_DIR "test2", &oid2, 0));
-	
+
 	cl_git_pass(git_oid_fromstr(&oid3, "763d71aadf09a7951596c9746c024e7eece7c7af"));
 	cl_git_pass(git_reference_create(&write3, repo, GIT_REFS_HEADS_DIR "test3", &oid3, 0));
-	
+
 	git_reference_delete(write1);
 	git_reference_free(write1);
-	
+
 	git_reference_delete(write3);
 	git_reference_free(write3);
-	
+
 	cl_git_pass(git_reference_foreach(repo, GIT_REF_LISTALL, delete_test, &i));
-	cl_assert_equal_i(i, 1);
+	cl_assert_equal_i(1, (int)i);
 
 	git_reference_free(write2);
 }
diff --git a/tests-clar/refdb/testdb.c b/tests-clar/refdb/testdb.c
index a8e7ba5..627254e 100644
--- a/tests-clar/refdb/testdb.c
+++ b/tests-clar/refdb/testdb.c
@@ -1,23 +1,18 @@
-#include "common.h"
 #include "vector.h"
 #include "util.h"
-#include <git2/refdb.h>
-#include <git2/refdb_backend.h>
-#include <git2/errors.h>
-#include <git2/repository.h>
+#include "testdb.h"
 
 typedef struct refdb_test_backend {
 	git_refdb_backend parent;
-	
+
 	git_repository *repo;
-	git_refdb *refdb;
 	git_vector refs;
 } refdb_test_backend;
 
 typedef struct refdb_test_entry {
 	char *name;
 	git_ref_t type;
-	
+
 	union {
 		git_oid oid;
 		char *symbolic;
@@ -38,19 +33,19 @@ static int refdb_test_backend__exists(
 	refdb_test_backend *backend;
 	refdb_test_entry *entry;
 	size_t i;
-	
+
 	assert(_backend);
 	backend = (refdb_test_backend *)_backend;
-	
+
 	*exists = 0;
-	
+
 	git_vector_foreach(&backend->refs, i, entry) {
 		if (strcmp(entry->name, ref_name) == 0) {
 			*exists = 1;
 			break;
 		}
 	}
-	
+
 	return 0;
 }
 
@@ -60,18 +55,18 @@ static int refdb_test_backend__write(
 {
 	refdb_test_backend *backend;
 	refdb_test_entry *entry;
-	
+
 	assert(_backend);
 	backend = (refdb_test_backend *)_backend;
 
 	entry = git__calloc(1, sizeof(refdb_test_entry));
 	GITERR_CHECK_ALLOC(entry);
-	
+
 	entry->name = git__strdup(git_reference_name(ref));
 	GITERR_CHECK_ALLOC(entry->name);
-	
+
 	entry->type = git_reference_type(ref);
-	
+
 	if (entry->type == GIT_REF_OID)
 		git_oid_cpy(&entry->target.oid, git_reference_target(ref));
 	else {
@@ -80,7 +75,7 @@ static int refdb_test_backend__write(
 	}
 
 	git_vector_insert(&backend->refs, entry);
-	
+
 	return 0;
 }
 
@@ -95,17 +90,21 @@ static int refdb_test_backend__lookup(
 
 	assert(_backend);
 	backend = (refdb_test_backend *)_backend;
-	
+
 	git_vector_foreach(&backend->refs, i, entry) {
 		if (strcmp(entry->name, ref_name) == 0) {
-			const git_oid *oid =
-				entry->type == GIT_REF_OID ? &entry->target.oid : NULL;
-			const char *symbolic =
-				entry->type == GIT_REF_SYMBOLIC ? entry->target.symbolic : NULL;
-			
-			if ((*out = git_reference__alloc(backend->refdb, ref_name, oid, symbolic)) == NULL)
+
+			if (entry->type == GIT_REF_OID) {
+				*out = git_reference__alloc(ref_name,
+					&entry->target.oid, NULL);
+			} else if (entry->type == GIT_REF_SYMBOLIC) {
+				*out = git_reference__alloc_symbolic(ref_name,
+					entry->target.symbolic);
+			}
+
+			if (*out == NULL)
 				return -1;
-			
+
 			return 0;
 		}
 	}
@@ -122,21 +121,21 @@ static int refdb_test_backend__foreach(
 	refdb_test_backend *backend;
 	refdb_test_entry *entry;
 	size_t i;
-	
+
 	assert(_backend);
 	backend = (refdb_test_backend *)_backend;
 
 	git_vector_foreach(&backend->refs, i, entry) {
 		if (entry->type == GIT_REF_OID && (list_flags & GIT_REF_OID) == 0)
 			continue;
-		
+
 		if (entry->type == GIT_REF_SYMBOLIC && (list_flags & GIT_REF_SYMBOLIC) == 0)
 			continue;
-		
+
 		if (callback(entry->name, payload) != 0)
 			return GIT_EUSER;
 	}
-	
+
 	return 0;
 }
 
@@ -144,7 +143,7 @@ static void refdb_test_entry_free(refdb_test_entry *entry)
 {
 	if (entry->type == GIT_REF_SYMBOLIC)
 		git__free(entry->target.symbolic);
-	
+
 	git__free(entry->name);
 	git__free(entry);
 }
@@ -175,14 +174,14 @@ static void refdb_test_backend__free(git_refdb_backend *_backend)
 	refdb_test_backend *backend;
 	refdb_test_entry *entry;
 	size_t i;
-	
+
 	assert(_backend);
 	backend = (refdb_test_backend *)_backend;
 
 	git_vector_foreach(&backend->refs, i, entry)
 		refdb_test_entry_free(entry);
 
-	git_vector_free(&backend->refs);	
+	git_vector_free(&backend->refs);
 	git__free(backend);
 }
 
@@ -191,19 +190,13 @@ int refdb_backend_test(
 	git_repository *repo)
 {
 	refdb_test_backend *backend;
-	git_refdb *refdb;
-	int error = 0;
-
-	if ((error = git_repository_refdb(&refdb, repo)) < 0)
-		return error;
 
 	backend = git__calloc(1, sizeof(refdb_test_backend));
 	GITERR_CHECK_ALLOC(backend);
-	
+
 	git_vector_init(&backend->refs, 0, ref_name_cmp);
 
 	backend->repo = repo;
-	backend->refdb = refdb;
 
 	backend->parent.exists = &refdb_test_backend__exists;
 	backend->parent.lookup = &refdb_test_backend__lookup;
diff --git a/tests-clar/refdb/testdb.h b/tests-clar/refdb/testdb.h
index e38abd9..a0d1bbc 100644
--- a/tests-clar/refdb/testdb.h
+++ b/tests-clar/refdb/testdb.h
@@ -1,3 +1,9 @@
+#include <git2/errors.h>
+#include <git2/repository.h>
+#include <git2/refdb.h>
+#include <git2/sys/refs.h>
+#include <git2/sys/refdb_backend.h>
+
 int refdb_backend_test(
 	git_refdb_backend **backend_out,
 	git_repository *repo);
diff --git a/tests-clar/refs/branches/remote.c b/tests-clar/refs/branches/remote.c
index 2beef37..6043828 100644
--- a/tests-clar/refs/branches/remote.c
+++ b/tests-clar/refs/branches/remote.c
@@ -69,7 +69,8 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void)
 	cl_git_pass(git_remote_create(&remote, g_repo, "addtest", "http://github.com/libgit2/libgit2"));
 
 	/* Update the remote fetch spec */
-	cl_git_pass(git_remote_set_fetchspec(remote, "refs/heads/*:refs/remotes/test/*"));
+	git_remote_clear_refspecs(remote);
+	cl_git_pass(git_remote_add_fetch(remote, "refs/heads/*:refs/remotes/test/*"));
 	cl_git_pass(git_remote_save(remote));
 
 	git_remote_free(remote);
diff --git a/tests-clar/refs/delete.c b/tests-clar/refs/delete.c
index ac517d8..053f412 100644
--- a/tests-clar/refs/delete.c
+++ b/tests-clar/refs/delete.c
@@ -88,4 +88,5 @@ void test_refs_delete__packed_only(void)
 	/* This should pass */
 	cl_git_pass(git_reference_delete(ref));
 	git_reference_free(ref);
+	git_refdb_free(refdb);
 }
diff --git a/tests-clar/refs/pack.c b/tests-clar/refs/pack.c
index 973abae..412c4c5 100644
--- a/tests-clar/refs/pack.c
+++ b/tests-clar/refs/pack.c
@@ -25,6 +25,7 @@ static void packall(void)
 
 	cl_git_pass(git_repository_refdb(&refdb, g_repo));
 	cl_git_pass(git_refdb_compress(refdb));
+	git_refdb_free(refdb);
 }
 
 void test_refs_pack__empty(void)
diff --git a/tests-clar/refs/peel.c b/tests-clar/refs/peel.c
index 34bd02c..f2fb6e2 100644
--- a/tests-clar/refs/peel.c
+++ b/tests-clar/refs/peel.c
@@ -1,19 +1,24 @@
 #include "clar_libgit2.h"
 
 static git_repository *g_repo;
+static git_repository *g_peel_repo;
 
 void test_refs_peel__initialize(void)
 {
 	cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
+	cl_git_pass(git_repository_open(&g_peel_repo, cl_fixture("peeled.git")));
 }
 
 void test_refs_peel__cleanup(void)
 {
 	git_repository_free(g_repo);
 	g_repo = NULL;
+	git_repository_free(g_peel_repo);
+	g_peel_repo = NULL;
 }
 
-static void assert_peel(
+static void assert_peel_generic(
+	git_repository *repo,
 	const char *ref_name,
 	git_otype requested_type,
 	const char* expected_sha,
@@ -23,7 +28,7 @@ static void assert_peel(
 	git_reference *ref;
 	git_object *peeled;
 
-	cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
+	cl_git_pass(git_reference_lookup(&ref, repo, ref_name));
 	
 	cl_git_pass(git_reference_peel(&peeled, ref, requested_type));
 
@@ -36,6 +41,16 @@ static void assert_peel(
 	git_reference_free(ref);
 }
 
+static void assert_peel(
+	const char *ref_name,
+	git_otype requested_type,
+	const char* expected_sha,
+	git_otype expected_type)
+{
+	assert_peel_generic(g_repo, ref_name, requested_type,
+			    expected_sha, expected_type);
+}
+
 static void assert_peel_error(int error, const char *ref_name, git_otype requested_type)
 {
 	git_reference *ref;
@@ -90,3 +105,15 @@ void test_refs_peel__can_peel_into_any_non_tag_object(void)
 	assert_peel("refs/tags/test", GIT_OBJ_ANY,
 		"e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
 }
+
+void test_refs_peel__can_peel_fully_peeled_packed_refs(void)
+{
+	assert_peel_generic(g_peel_repo,
+			    "refs/tags/tag-inside-tags", GIT_OBJ_ANY,
+			    "0df1a5865c8abfc09f1f2182e6a31be550e99f07",
+			    GIT_OBJ_COMMIT);
+	assert_peel_generic(g_peel_repo,
+			    "refs/foo/tag-outside-tags", GIT_OBJ_ANY,
+			    "0df1a5865c8abfc09f1f2182e6a31be550e99f07",
+			    GIT_OBJ_COMMIT);
+}
diff --git a/tests-clar/refs/rename.c b/tests-clar/refs/rename.c
index e39abeb..5ab84c4 100644
--- a/tests-clar/refs/rename.c
+++ b/tests-clar/refs/rename.c
@@ -284,6 +284,7 @@ void test_refs_rename__overwrite(void)
 	git_reference_free(ref_one);
 	git_reference_free(ref_one_new);
 	git_reference_free(ref_two);
+	git_refdb_free(refdb);
 }
 
 
diff --git a/tests-clar/repo/getters.c b/tests-clar/repo/getters.c
index b372f5b..b8ede12 100644
--- a/tests-clar/repo/getters.c
+++ b/tests-clar/repo/getters.c
@@ -31,10 +31,10 @@ void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
 	cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
 
 	cl_git_pass(git_repository_odb(&odb, repo));
-	cl_assert(((git_refcount *)odb)->refcount == 2);
+	cl_assert(((git_refcount *)odb)->refcount.val == 2);
 
 	git_repository_free(repo);
-	cl_assert(((git_refcount *)odb)->refcount == 1);
+	cl_assert(((git_refcount *)odb)->refcount.val == 1);
 
 	git_odb_free(odb);
 }
diff --git a/tests-clar/repo/iterator.c b/tests-clar/repo/iterator.c
index 00c46d6..ab46073 100644
--- a/tests-clar/repo/iterator.c
+++ b/tests-clar/repo/iterator.c
@@ -422,7 +422,7 @@ static void build_test_tree(
 	git_treebuilder *builder;
 	const char *scan = fmt, *next;
 	char type, delimiter;
-	git_filemode_t mode;
+	git_filemode_t mode = GIT_FILEMODE_BLOB;
 	git_buf name = GIT_BUF_INIT;
 	va_list arglist;
 
@@ -755,47 +755,52 @@ void test_repo_iterator__workdir_icase(void)
 	git_iterator_free(i);
 }
 
-void test_repo_iterator__workdir_depth(void)
+static void build_workdir_tree(const char *root, int dirs, int subs)
 {
 	int i, j;
-	git_iterator *iter;
-	char buf[64];
-
-	g_repo = cl_git_sandbox_init("icase");
-
-	for (i = 0; i < 10; ++i) {
-		p_snprintf(buf, sizeof(buf), "icase/dir%02d", i);
-		cl_git_pass(git_futils_mkdir(buf, NULL, 0775, GIT_MKDIR_PATH));
+	char buf[64], sub[64];
 
+	for (i = 0; i < dirs; ++i) {
 		if (i % 2 == 0) {
-			p_snprintf(buf, sizeof(buf), "icase/dir%02d/file", i);
+			p_snprintf(buf, sizeof(buf), "%s/dir%02d", root, i);
+			cl_git_pass(git_futils_mkdir(buf, NULL, 0775, GIT_MKDIR_PATH));
+
+			p_snprintf(buf, sizeof(buf), "%s/dir%02d/file", root, i);
 			cl_git_mkfile(buf, buf);
+			buf[strlen(buf) - 5] = '\0';
+		} else {
+			p_snprintf(buf, sizeof(buf), "%s/DIR%02d", root, i);
+			cl_git_pass(git_futils_mkdir(buf, NULL, 0775, GIT_MKDIR_PATH));
 		}
 
-		for (j = 0; j < 10; ++j) {
-			p_snprintf(buf, sizeof(buf), "icase/dir%02d/sub%02d", i, j);
-			cl_git_pass(git_futils_mkdir(buf, NULL, 0775, GIT_MKDIR_PATH));
+		for (j = 0; j < subs; ++j) {
+			switch (j % 4) {
+			case 0: p_snprintf(sub, sizeof(sub), "%s/sub%02d", buf, j); break;
+			case 1: p_snprintf(sub, sizeof(sub), "%s/sUB%02d", buf, j); break;
+			case 2: p_snprintf(sub, sizeof(sub), "%s/Sub%02d", buf, j); break;
+			case 3: p_snprintf(sub, sizeof(sub), "%s/SUB%02d", buf, j); break;
+			}
+			cl_git_pass(git_futils_mkdir(sub, NULL, 0775, GIT_MKDIR_PATH));
 
 			if (j % 2 == 0) {
-				p_snprintf(
-					buf, sizeof(buf), "icase/dir%02d/sub%02d/file", i, j);
-				cl_git_mkfile(buf, buf);
+				size_t sublen = strlen(sub);
+				memcpy(&sub[sublen], "/file", sizeof("/file"));
+				cl_git_mkfile(sub, sub);
+				sub[sublen] = '\0';
 			}
 		}
 	}
+}
 
-	for (i = 1; i < 3; ++i) {
-		for (j = 0; j < 50; ++j) {
-			p_snprintf(buf, sizeof(buf), "icase/dir%02d/sub01/moar%02d", i, j);
-			cl_git_pass(git_futils_mkdir(buf, NULL, 0775, GIT_MKDIR_PATH));
+void test_repo_iterator__workdir_depth(void)
+{
+	git_iterator *iter;
 
-			if (j % 2 == 0) {
-				p_snprintf(buf, sizeof(buf),
-					"icase/dir%02d/sub01/moar%02d/file", i, j);
-				cl_git_mkfile(buf, buf);
-			}
-		}
-	}
+	g_repo = cl_git_sandbox_init("icase");
+
+	build_workdir_tree("icase", 10, 10);
+	build_workdir_tree("icase/DIR01/sUB01", 50, 0);
+	build_workdir_tree("icase/dir02/sUB01", 50, 0);
 
 	/* auto expand with no tree entries */
 	cl_git_pass(git_iterator_for_workdir(&iter, g_repo, 0, NULL, NULL));
@@ -808,3 +813,114 @@ void test_repo_iterator__workdir_depth(void)
 	expect_iterator_items(iter, 337, NULL, 337, NULL);
 	git_iterator_free(iter);
 }
+
+void test_repo_iterator__fs(void)
+{
+	git_iterator *i;
+	static const char *expect_base[] = {
+		"DIR01/Sub02/file",
+		"DIR01/sub00/file",
+		"current_file",
+		"dir00/Sub02/file",
+		"dir00/file",
+		"dir00/sub00/file",
+		"modified_file",
+		"new_file",
+		NULL,
+	};
+	static const char *expect_trees[] = {
+		"DIR01/",
+		"DIR01/SUB03/",
+		"DIR01/Sub02/",
+		"DIR01/Sub02/file",
+		"DIR01/sUB01/",
+		"DIR01/sub00/",
+		"DIR01/sub00/file",
+		"current_file",
+		"dir00/",
+		"dir00/SUB03/",
+		"dir00/Sub02/",
+		"dir00/Sub02/file",
+		"dir00/file",
+		"dir00/sUB01/",
+		"dir00/sub00/",
+		"dir00/sub00/file",
+		"modified_file",
+		"new_file",
+		NULL,
+	};
+	static const char *expect_noauto[] = {
+		"DIR01/",
+		"current_file",
+		"dir00/",
+		"modified_file",
+		"new_file",
+		NULL,
+	};
+
+	g_repo = cl_git_sandbox_init("status");
+
+	build_workdir_tree("status/subdir", 2, 4);
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "status/subdir", 0, NULL, NULL));
+	expect_iterator_items(i, 8, expect_base, 8, expect_base);
+	git_iterator_free(i);
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "status/subdir", GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+	expect_iterator_items(i, 18, expect_trees, 18, expect_trees);
+	git_iterator_free(i);
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "status/subdir", GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+	expect_iterator_items(i, 5, expect_noauto, 18, expect_trees);
+	git_iterator_free(i);
+
+	git__tsort((void **)expect_base, 8, (git__tsort_cmp)git__strcasecmp);
+	git__tsort((void **)expect_trees, 18, (git__tsort_cmp)git__strcasecmp);
+	git__tsort((void **)expect_noauto, 5, (git__tsort_cmp)git__strcasecmp);
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "status/subdir", GIT_ITERATOR_IGNORE_CASE, NULL, NULL));
+	expect_iterator_items(i, 8, expect_base, 8, expect_base);
+	git_iterator_free(i);
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "status/subdir", GIT_ITERATOR_IGNORE_CASE |
+		GIT_ITERATOR_INCLUDE_TREES, NULL, NULL));
+	expect_iterator_items(i, 18, expect_trees, 18, expect_trees);
+	git_iterator_free(i);
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "status/subdir", GIT_ITERATOR_IGNORE_CASE |
+		GIT_ITERATOR_DONT_AUTOEXPAND, NULL, NULL));
+	expect_iterator_items(i, 5, expect_noauto, 18, expect_trees);
+	git_iterator_free(i);
+}
+
+void test_repo_iterator__fs2(void)
+{
+	git_iterator *i;
+	static const char *expect_base[] = {
+		"heads/br2",
+		"heads/dir",
+		"heads/master",
+		"heads/packed-test",
+		"heads/subtrees",
+		"heads/test",
+		"tags/e90810b",
+		"tags/foo/bar",
+		"tags/foo/foo/bar",
+		"tags/point_to_blob",
+		"tags/test",
+		NULL,
+	};
+
+	g_repo = cl_git_sandbox_init("testrepo");
+
+	cl_git_pass(git_iterator_for_filesystem(
+		&i, "testrepo/.git/refs", 0, NULL, NULL));
+	expect_iterator_items(i, 11, expect_base, 11, expect_base);
+	git_iterator_free(i);
+}
diff --git a/tests-clar/repo/open.c b/tests-clar/repo/open.c
index 7f93ae9..6b52537 100644
--- a/tests-clar/repo/open.c
+++ b/tests-clar/repo/open.c
@@ -280,3 +280,38 @@ void test_repo_open__opening_a_non_existing_repository_returns_ENOTFOUND(void)
 	git_repository *repo;
 	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_open(&repo, "i-do-not/exist"));
 }
+
+void test_repo_open__no_config(void)
+{
+	git_buf path = GIT_BUF_INIT;
+	git_repository *repo;
+	git_config *config;
+
+	cl_fixture_sandbox("empty_standard_repo");
+	cl_git_pass(cl_rename("empty_standard_repo/.gitted", "empty_standard_repo/.git"));
+
+	/* remove local config */
+	cl_git_pass(git_futils_rmdir_r(
+		"empty_standard_repo/.git/config", NULL, GIT_RMDIR_REMOVE_FILES));
+
+	/* isolate from system level configs */
+	cl_must_pass(p_mkdir("alternate", 0777));
+	cl_git_pass(git_path_prettify(&path, "alternate", NULL));
+	cl_git_pass(git_libgit2_opts(
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
+	cl_git_pass(git_libgit2_opts(
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
+	cl_git_pass(git_libgit2_opts(
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
+
+	git_buf_free(&path);
+
+	cl_git_pass(git_repository_open(&repo, "empty_standard_repo"));
+	cl_git_pass(git_repository_config(&config, repo));
+
+	cl_git_fail(git_config_set_string(config, "test.set", "42"));
+
+	git_config_free(config);
+	git_repository_free(repo);
+	cl_fixture_cleanup("empty_standard_repo");
+}
diff --git a/tests-clar/repo/setters.c b/tests-clar/repo/setters.c
index 7e482de..f34f1e4 100644
--- a/tests-clar/repo/setters.c
+++ b/tests-clar/repo/setters.c
@@ -1,4 +1,6 @@
 #include "clar_libgit2.h"
+#include "git2/sys/repository.h"
+
 #include "buffer.h"
 #include "posix.h"
 #include "util.h"
@@ -67,13 +69,13 @@ void test_repo_setters__setting_a_new_index_on_a_repo_which_has_already_loaded_o
 	git_index *new_index;
 
 	cl_git_pass(git_index_open(&new_index, "./my-index"));
-	cl_assert(((git_refcount *)new_index)->refcount == 1);
+	cl_assert(((git_refcount *)new_index)->refcount.val == 1);
 
 	git_repository_set_index(repo, new_index);
-	cl_assert(((git_refcount *)new_index)->refcount == 2);
+	cl_assert(((git_refcount *)new_index)->refcount.val == 2);
 
 	git_repository_free(repo);
-	cl_assert(((git_refcount *)new_index)->refcount == 1);
+	cl_assert(((git_refcount *)new_index)->refcount.val == 1);
 
 	git_index_free(new_index);
 
@@ -88,13 +90,13 @@ void test_repo_setters__setting_a_new_odb_on_a_repo_which_already_loaded_one_pro
 	git_odb *new_odb;
 
 	cl_git_pass(git_odb_open(&new_odb, "./testrepo.git/objects"));
-	cl_assert(((git_refcount *)new_odb)->refcount == 1);
+	cl_assert(((git_refcount *)new_odb)->refcount.val == 1);
 
 	git_repository_set_odb(repo, new_odb);
-	cl_assert(((git_refcount *)new_odb)->refcount == 2);
+	cl_assert(((git_refcount *)new_odb)->refcount.val == 2);
 
 	git_repository_free(repo);
-	cl_assert(((git_refcount *)new_odb)->refcount == 1);
+	cl_assert(((git_refcount *)new_odb)->refcount.val == 1);
 
 	git_odb_free(new_odb);
 
diff --git a/tests-clar/resources/merge-resolve/.gitted/COMMIT_EDITMSG b/tests-clar/resources/merge-resolve/.gitted/COMMIT_EDITMSG
new file mode 100644
index 0000000..245b18a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/COMMIT_EDITMSG
@@ -0,0 +1 @@
+rename conflict theirs
diff --git a/tests-clar/resources/merge-resolve/.gitted/HEAD b/tests-clar/resources/merge-resolve/.gitted/HEAD
new file mode 100644
index 0000000..cb089cd
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests-clar/resources/merge-resolve/.gitted/ORIG_HEAD b/tests-clar/resources/merge-resolve/.gitted/ORIG_HEAD
new file mode 100644
index 0000000..4092d42
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/ORIG_HEAD
@@ -0,0 +1 @@
+2392a2dacc9efb562b8635d6579fb458751c7c5b
diff --git a/tests-clar/resources/merge-resolve/.gitted/config b/tests-clar/resources/merge-resolve/.gitted/config
new file mode 100644
index 0000000..af10792
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/config
@@ -0,0 +1,6 @@
+[core]
+	repositoryformatversion = 0
+	filemode = true
+	bare = false
+	logallrefupdates = true
+	ignorecase = true
diff --git a/tests-clar/resources/merge-resolve/.gitted/description b/tests-clar/resources/merge-resolve/.gitted/description
new file mode 100644
index 0000000..498b267
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/description
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.
diff --git a/tests-clar/resources/merge-resolve/.gitted/index b/tests-clar/resources/merge-resolve/.gitted/index
new file mode 100644
index 0000000..230eba9
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/index differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/HEAD b/tests-clar/resources/merge-resolve/.gitted/logs/HEAD
new file mode 100644
index 0000000..96cdb33
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/HEAD
@@ -0,0 +1,236 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351563869 -0500	commit (initial): initial
+c607fc30883e335def28cd686b51f6cfa02b06ec c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351563886 -0500	checkout: moving from master to branch
+c607fc30883e335def28cd686b51f6cfa02b06ec 7cb63eed597130ba4abb87b3e544b85021905520 Edward Thomson <ethomson@edwardthomson.com> 1351563965 -0500	commit: branch
+7cb63eed597130ba4abb87b3e544b85021905520 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351563968 -0500	checkout: moving from branch to master
+c607fc30883e335def28cd686b51f6cfa02b06ec 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351564033 -0500	commit: master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351605785 -0500	checkout: moving from master to ff_branch
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 33d500f588fbbe65901d82b4e6b008e549064be0 Edward Thomson <ethomson@edwardthomson.com> 1351605830 -0500	commit: fastforward
+33d500f588fbbe65901d82b4e6b008e549064be0 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351605889 -0500	checkout: moving from ff_branch to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874933 -0500	checkout: moving from master to octo1
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 16f825815cfd20a07a75c71554e82d8eede0b061 Edward Thomson <ethomson@edwardthomson.com> 1351874954 -0500	commit: octo1
+16f825815cfd20a07a75c71554e82d8eede0b061 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874957 -0500	checkout: moving from octo1 to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874960 -0500	checkout: moving from master to octo2
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 158dc7bedb202f5b26502bf3574faa7f4238d56c Edward Thomson <ethomson@edwardthomson.com> 1351874974 -0500	commit: octo2
+158dc7bedb202f5b26502bf3574faa7f4238d56c 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874976 -0500	checkout: moving from octo2 to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874980 -0500	checkout: moving from master to octo3
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 50ce7d7d01217679e26c55939eef119e0c93e272 Edward Thomson <ethomson@edwardthomson.com> 1351874998 -0500	commit: octo3
+50ce7d7d01217679e26c55939eef119e0c93e272 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875006 -0500	checkout: moving from octo3 to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875010 -0500	checkout: moving from master to octo4
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae Edward Thomson <ethomson@edwardthomson.com> 1351875023 -0500	commit: octo4
+54269b3f6ec3d7d4ede24dd350dd5d605495c3ae 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875031 -0500	checkout: moving from octo4 to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875031 -0500	checkout: moving from master to octo5
+977c696519c5a3004c5f1d15d60c89dbeb8f235f e4f618a2c3ed0669308735727df5ebf2447f022f Edward Thomson <ethomson@edwardthomson.com> 1351875041 -0500	commit: octo5
+e4f618a2c3ed0669308735727df5ebf2447f022f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875046 -0500	checkout: moving from octo5 to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875046 -0500	checkout: moving from master to octo6
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 4ca408a8c88655f7586a1b580be6fad138121e98 Edward Thomson <ethomson@edwardthomson.com> 1351875057 -0500	commit: octo5
+4ca408a8c88655f7586a1b580be6fad138121e98 b6f610aef53bd343e6c96227de874c66f00ee8e8 Edward Thomson <ethomson@edwardthomson.com> 1351875065 -0500	commit (amend): octo6
+b6f610aef53bd343e6c96227de874c66f00ee8e8 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875071 -0500	checkout: moving from octo6 to master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 4e0d9401aee78eb345a8685a859d37c8c3c0bbed Edward Thomson <ethomson@edwardthomson.com> 1351875091 -0500	merge octo1 octo2 octo3 octo4: Merge made by the 'octopus' strategy.
+4e0d9401aee78eb345a8685a859d37c8c3c0bbed 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae Edward Thomson <ethomson@edwardthomson.com> 1351875108 -0500	reset: moving to 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae
+54269b3f6ec3d7d4ede24dd350dd5d605495c3ae 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875584 -0500	reset: moving to 977c696519c5a3004c5f1d15d60c89dbeb8f235f
+bd593285fc7fe4ca18ccdbabf027f5d689101452 33d500f588fbbe65901d82b4e6b008e549064be0 Edward Thomson <ethomson@edwardthomson.com> 1351990193 -0500	checkout: moving from master to ff_branch
+33d500f588fbbe65901d82b4e6b008e549064be0 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351990202 -0500	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1351990205 -0500	merge master: Fast-forward
+bd593285fc7fe4ca18ccdbabf027f5d689101452 fd89f8cffb663ac89095a0f9764902e93ceaca6a Edward Thomson <ethomson@edwardthomson.com> 1351990229 -0500	commit: fastforward
+fd89f8cffb663ac89095a0f9764902e93ceaca6a bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1351990233 -0500	checkout: moving from ff_branch to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352091703 -0600	checkout: moving from master to trivial-2alt
+c607fc30883e335def28cd686b51f6cfa02b06ec c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352092411 -0600	checkout: moving from trivial-2alt to trivial-2alt-branch
+c607fc30883e335def28cd686b51f6cfa02b06ec c9174cef549ec94ecbc43ef03cdc775b4950becb Edward Thomson <ethomson@edwardthomson.com> 1352092434 -0600	commit: 2alt-branch
+c9174cef549ec94ecbc43ef03cdc775b4950becb c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352092440 -0600	checkout: moving from trivial-2alt-branch to trivial-2alt
+c607fc30883e335def28cd686b51f6cfa02b06ec 566ab53c220a2eafc1212af1a024513230280ab9 Edward Thomson <ethomson@edwardthomson.com> 1352092452 -0600	commit: 2alt
+bd593285fc7fe4ca18ccdbabf027f5d689101452 566ab53c220a2eafc1212af1a024513230280ab9 Edward Thomson <ethomson@edwardthomson.com> 1352094476 -0600	checkout: moving from master to trivial-3alt
+566ab53c220a2eafc1212af1a024513230280ab9 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094547 -0600	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 5459c89aa0026d543ce8343bd89871bce543f9c2 Edward Thomson <ethomson@edwardthomson.com> 1352094580 -0600	commit: 3alt
+5459c89aa0026d543ce8343bd89871bce543f9c2 4c9fac0707f8d4195037ae5a681aa48626491541 Edward Thomson <ethomson@edwardthomson.com> 1352094610 -0600	commit: 3alt-branch
+4c9fac0707f8d4195037ae5a681aa48626491541 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352094620 -0600	checkout: moving from trivial-3alt to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 566ab53c220a2eafc1212af1a024513230280ab9 Edward Thomson <ethomson@edwardthomson.com> 1352094752 -0600	checkout: moving from master to trivial-4
+566ab53c220a2eafc1212af1a024513230280ab9 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094764 -0600	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec cc3e3009134cb88014129fc8858d1101359e5e2f Edward Thomson <ethomson@edwardthomson.com> 1352094815 -0600	commit: trivial-4
+cc3e3009134cb88014129fc8858d1101359e5e2f c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094843 -0600	checkout: moving from trivial-4 to trivial-4-branch
+c607fc30883e335def28cd686b51f6cfa02b06ec 183310e30fb1499af8c619108ffea4d300b5e778 Edward Thomson <ethomson@edwardthomson.com> 1352094856 -0600	commit: trivial-4-branch
+183310e30fb1499af8c619108ffea4d300b5e778 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352094860 -0600	checkout: moving from trivial-4-branch to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 cc3e3009134cb88014129fc8858d1101359e5e2f Edward Thomson <ethomson@edwardthomson.com> 1352096588 -0600	checkout: moving from master to trivial-4
+cc3e3009134cb88014129fc8858d1101359e5e2f c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096612 -0600	checkout: moving from trivial-4 to trivial-5alt-1
+c607fc30883e335def28cd686b51f6cfa02b06ec 4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 Edward Thomson <ethomson@edwardthomson.com> 1352096643 -0600	commit: 5alt-1
+4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096661 -0600	checkout: moving from trivial-5alt-1 to trivial-5alt-1-branch
+c607fc30883e335def28cd686b51f6cfa02b06ec 4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 Edward Thomson <ethomson@edwardthomson.com> 1352096671 -0600	checkout: moving from trivial-5alt-1-branch to trivial-5alt-1
+4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096678 -0600	checkout: moving from trivial-5alt-1 to trivial-5alt-1-branch
+c607fc30883e335def28cd686b51f6cfa02b06ec 478172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2 Edward Thomson <ethomson@edwardthomson.com> 1352096689 -0600	commit: 5alt-1-branch
+478172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2 4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 Edward Thomson <ethomson@edwardthomson.com> 1352096701 -0600	checkout: moving from trivial-5alt-1-branch to trivial-5alt-1
+4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096715 -0600	checkout: moving from trivial-5alt-1 to trivial-5alt-2
+c607fc30883e335def28cd686b51f6cfa02b06ec ebc09d0137cfb0c26697aed0109fb943ad906f3f Edward Thomson <ethomson@edwardthomson.com> 1352096764 -0600	commit: existing file
+ebc09d0137cfb0c26697aed0109fb943ad906f3f 3b47b031b3e55ae11e14a05260b1c3ffd6838d55 Edward Thomson <ethomson@edwardthomson.com> 1352096815 -0600	commit: 5alt-2
+3b47b031b3e55ae11e14a05260b1c3ffd6838d55 ebc09d0137cfb0c26697aed0109fb943ad906f3f Edward Thomson <ethomson@edwardthomson.com> 1352096840 -0600	checkout: moving from trivial-5alt-2 to trivial-5alt-2-branch
+ebc09d0137cfb0c26697aed0109fb943ad906f3f f48097eb340dc5a7cae55aabcf1faf4548aa821f Edward Thomson <ethomson@edwardthomson.com> 1352096855 -0600	commit: 5alt-2-branch
+f48097eb340dc5a7cae55aabcf1faf4548aa821f bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352096858 -0600	checkout: moving from trivial-5alt-2-branch to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352097377 -0600	checkout: moving from master to trivial-6
+c607fc30883e335def28cd686b51f6cfa02b06ec f7c332bd4d4d4b777366cae4d24d1687477576bf Edward Thomson <ethomson@edwardthomson.com> 1352097389 -0600	commit: 6
+f7c332bd4d4d4b777366cae4d24d1687477576bf 99b4f7e4f24470fa06b980bc21f1095c2a9425c0 Edward Thomson <ethomson@edwardthomson.com> 1352097404 -0600	commit: trivial-6
+99b4f7e4f24470fa06b980bc21f1095c2a9425c0 f7c332bd4d4d4b777366cae4d24d1687477576bf Edward Thomson <ethomson@edwardthomson.com> 1352097420 -0600	checkout: moving from trivial-6 to trivial-6-branch
+f7c332bd4d4d4b777366cae4d24d1687477576bf a43150a738849c59376cf30bb2a68348a83c8f48 Edward Thomson <ethomson@edwardthomson.com> 1352097431 -0600	commit: 6-branch
+a43150a738849c59376cf30bb2a68348a83c8f48 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352097442 -0600	checkout: moving from trivial-6-branch to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 99b4f7e4f24470fa06b980bc21f1095c2a9425c0 Edward Thomson <ethomson@edwardthomson.com> 1352098040 -0600	checkout: moving from master to trivial-6
+99b4f7e4f24470fa06b980bc21f1095c2a9425c0 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352098057 -0600	checkout: moving from trivial-6 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 cc3e3009134cb88014129fc8858d1101359e5e2f Edward Thomson <ethomson@edwardthomson.com> 1352098792 -0600	checkout: moving from master to trivial-4
+cc3e3009134cb88014129fc8858d1101359e5e2f c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352098818 -0600	checkout: moving from trivial-4 to trivial-8
+c607fc30883e335def28cd686b51f6cfa02b06ec 75a811bf6bc57694adb3fe604786f3a4efd1cd1b Edward Thomson <ethomson@edwardthomson.com> 1352098884 -0600	commit: trivial-8
+75a811bf6bc57694adb3fe604786f3a4efd1cd1b 75a811bf6bc57694adb3fe604786f3a4efd1cd1b Edward Thomson <ethomson@edwardthomson.com> 1352098947 -0600	checkout: moving from trivial-8 to trivial-8-branch
+75a811bf6bc57694adb3fe604786f3a4efd1cd1b 52d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9 Edward Thomson <ethomson@edwardthomson.com> 1352098979 -0600	commit: trivial-8-branch
+52d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9 75a811bf6bc57694adb3fe604786f3a4efd1cd1b Edward Thomson <ethomson@edwardthomson.com> 1352098982 -0600	checkout: moving from trivial-8-branch to trivial-8
+75a811bf6bc57694adb3fe604786f3a4efd1cd1b 3575826c96a975031d2c14368529cc5c4353a8fd Edward Thomson <ethomson@edwardthomson.com> 1352099000 -0600	commit: trivial-8
+3575826c96a975031d2c14368529cc5c4353a8fd bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352099008 -0600	checkout: moving from trivial-8 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352099776 -0600	checkout: moving from master to trivial-7
+c607fc30883e335def28cd686b51f6cfa02b06ec 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099790 -0600	commit: trivial-7
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099799 -0600	checkout: moving from trivial-7 to trivial-7-branch
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 73cbfdc4fe843169e5b2af8dcad03cbf3acf306c Edward Thomson <ethomson@edwardthomson.com> 1352099812 -0600	commit: trivial-7-branch
+73cbfdc4fe843169e5b2af8dcad03cbf3acf306c 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099815 -0600	checkout: moving from trivial-7-branch to trivial-7
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 73cbfdc4fe843169e5b2af8dcad03cbf3acf306c Edward Thomson <ethomson@edwardthomson.com> 1352099838 -0600	checkout: moving from trivial-7 to trivial-7-branch
+73cbfdc4fe843169e5b2af8dcad03cbf3acf306c 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099874 -0600	reset: moving to 092ce8682d7f3a2a3a769a6daca58950168ba5c4
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 009b9cab6fdac02915a88ecd078b7a792ed802d8 Edward Thomson <ethomson@edwardthomson.com> 1352099921 -0600	commit: removed in 7
+009b9cab6fdac02915a88ecd078b7a792ed802d8 5195a1b480f66691b667f10a9e41e70115a78351 Edward Thomson <ethomson@edwardthomson.com> 1352099927 -0600	commit (amend): trivial-7-branch
+5195a1b480f66691b667f10a9e41e70115a78351 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099937 -0600	checkout: moving from trivial-7-branch to trivial-7
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 d874671ef5b20184836cb983bb273e5280384d0b Edward Thomson <ethomson@edwardthomson.com> 1352099947 -0600	commit: trivial-7
+d874671ef5b20184836cb983bb273e5280384d0b bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352099949 -0600	checkout: moving from trivial-7 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100174 -0600	checkout: moving from master to trivial-10
+c607fc30883e335def28cd686b51f6cfa02b06ec 53825f41ac8d640612f9423a2f03a69f3d96809a Edward Thomson <ethomson@edwardthomson.com> 1352100193 -0600	commit: trivial-10
+53825f41ac8d640612f9423a2f03a69f3d96809a 53825f41ac8d640612f9423a2f03a69f3d96809a Edward Thomson <ethomson@edwardthomson.com> 1352100200 -0600	checkout: moving from trivial-10 to trivial-10-branch
+53825f41ac8d640612f9423a2f03a69f3d96809a 11f4f3c08b737f5fd896cbefa1425ee63b21b2fa Edward Thomson <ethomson@edwardthomson.com> 1352100211 -0600	commit: trivial-10-branch
+11f4f3c08b737f5fd896cbefa1425ee63b21b2fa 53825f41ac8d640612f9423a2f03a69f3d96809a Edward Thomson <ethomson@edwardthomson.com> 1352100214 -0600	checkout: moving from trivial-10-branch to trivial-10
+53825f41ac8d640612f9423a2f03a69f3d96809a 0ec5f433959cd46177f745903353efb5be08d151 Edward Thomson <ethomson@edwardthomson.com> 1352100223 -0600	commit: trivial-10
+0ec5f433959cd46177f745903353efb5be08d151 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352100225 -0600	checkout: moving from trivial-10 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100270 -0600	checkout: moving from master to trivial-9
+c607fc30883e335def28cd686b51f6cfa02b06ec f0053b8060bb3f0be5cbcc3147a07ece26bf097e Edward Thomson <ethomson@edwardthomson.com> 1352100304 -0600	commit: trivial-9
+f0053b8060bb3f0be5cbcc3147a07ece26bf097e f0053b8060bb3f0be5cbcc3147a07ece26bf097e Edward Thomson <ethomson@edwardthomson.com> 1352100310 -0600	checkout: moving from trivial-9 to trivial-9-branch
+f0053b8060bb3f0be5cbcc3147a07ece26bf097e 13d1be4ea52a6ced1d7a1d832f0ee3c399348e5e Edward Thomson <ethomson@edwardthomson.com> 1352100317 -0600	commit: trivial-9-branch
+13d1be4ea52a6ced1d7a1d832f0ee3c399348e5e f0053b8060bb3f0be5cbcc3147a07ece26bf097e Edward Thomson <ethomson@edwardthomson.com> 1352100319 -0600	checkout: moving from trivial-9-branch to trivial-9
+f0053b8060bb3f0be5cbcc3147a07ece26bf097e c35dee9bcc0e989f3b0c40f68372a9a51b6c4e6a Edward Thomson <ethomson@edwardthomson.com> 1352100333 -0600	commit: trivial-9
+c35dee9bcc0e989f3b0c40f68372a9a51b6c4e6a bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352100335 -0600	checkout: moving from trivial-9 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100576 -0600	checkout: moving from master to trivial-13
+c607fc30883e335def28cd686b51f6cfa02b06ec 8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa Edward Thomson <ethomson@edwardthomson.com> 1352100589 -0600	commit: trivial-13
+8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa 8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa Edward Thomson <ethomson@edwardthomson.com> 1352100604 -0600	checkout: moving from trivial-13 to trivial-13-branch
+8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa 05f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c Edward Thomson <ethomson@edwardthomson.com> 1352100610 -0600	commit: trivial-13-branch
+05f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c 8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa Edward Thomson <ethomson@edwardthomson.com> 1352100612 -0600	checkout: moving from trivial-13-branch to trivial-13
+8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa a3fabece9eb8748da810e1e08266fef9b7136ad4 Edward Thomson <ethomson@edwardthomson.com> 1352100625 -0600	commit: trivial-13
+a3fabece9eb8748da810e1e08266fef9b7136ad4 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352100627 -0600	checkout: moving from trivial-13 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100936 -0600	checkout: moving from master to trivial-11
+c607fc30883e335def28cd686b51f6cfa02b06ec 35632e43612c06a3ea924bfbacd48333da874c29 Edward Thomson <ethomson@edwardthomson.com> 1352100958 -0600	commit: trivial-11
+35632e43612c06a3ea924bfbacd48333da874c29 35632e43612c06a3ea924bfbacd48333da874c29 Edward Thomson <ethomson@edwardthomson.com> 1352100964 -0600	checkout: moving from trivial-11 to trivial-11-branch
+35632e43612c06a3ea924bfbacd48333da874c29 6718a45909532d1fcf5600d0877f7fe7e78f0b86 Edward Thomson <ethomson@edwardthomson.com> 1352100978 -0600	commit: trivial-11-branch
+6718a45909532d1fcf5600d0877f7fe7e78f0b86 35632e43612c06a3ea924bfbacd48333da874c29 Edward Thomson <ethomson@edwardthomson.com> 1352100981 -0600	checkout: moving from trivial-11-branch to trivial-11
+35632e43612c06a3ea924bfbacd48333da874c29 3168dca1a561889b045a6441909f4c56145e666d Edward Thomson <ethomson@edwardthomson.com> 1352100992 -0600	commit: trivial-11
+3168dca1a561889b045a6441909f4c56145e666d bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352100996 -0600	checkout: moving from trivial-11 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352101098 -0600	checkout: moving from master to trivial-14
+c607fc30883e335def28cd686b51f6cfa02b06ec 596803b523203a4851c824c07366906f8353f4ad Edward Thomson <ethomson@edwardthomson.com> 1352101113 -0600	commit: trivial-14
+596803b523203a4851c824c07366906f8353f4ad 596803b523203a4851c824c07366906f8353f4ad Edward Thomson <ethomson@edwardthomson.com> 1352101117 -0600	checkout: moving from trivial-14 to trivial-14-branch
+596803b523203a4851c824c07366906f8353f4ad 8187117062b750eed4f93fd7e899f17b52ce554d Edward Thomson <ethomson@edwardthomson.com> 1352101132 -0600	commit: trivial-14-branch
+8187117062b750eed4f93fd7e899f17b52ce554d 596803b523203a4851c824c07366906f8353f4ad Edward Thomson <ethomson@edwardthomson.com> 1352101135 -0600	checkout: moving from trivial-14-branch to trivial-14
+596803b523203a4851c824c07366906f8353f4ad 7e2d058d5fedf8329db44db4fac610d6b1a89159 Edward Thomson <ethomson@edwardthomson.com> 1352101141 -0600	commit: trivial-14
+7e2d058d5fedf8329db44db4fac610d6b1a89159 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1352101145 -0600	checkout: moving from trivial-14 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1353177749 -0600	checkout: moving from master to renames1
+c607fc30883e335def28cd686b51f6cfa02b06ec 412b32fb66137366147f1801ecc962452757d48a Edward Thomson <ethomson@edwardthomson.com> 1353177886 -0600	commit: renames
+412b32fb66137366147f1801ecc962452757d48a bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1353794607 -0600	checkout: moving from renames1 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1353794647 -0600	checkout: moving from master to renames2
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1353794677 -0600	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec ab40af3cb8a3ed2e2843e96d9aa7871336b94573 Edward Thomson <ethomson@edwardthomson.com> 1353794852 -0600	commit: renames2
+ab40af3cb8a3ed2e2843e96d9aa7871336b94573 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1353794883 -0600	checkout: moving from renames2 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1354574697 -0600	checkout: moving from master to df_side1
+bd593285fc7fe4ca18ccdbabf027f5d689101452 d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1354574962 -0600	commit: df_ancestor
+d4207f77243500bec335ab477f9227fcdb1e271a c94b27e41064c521120627e07e2035cca1d24ffa Edward Thomson <ethomson@edwardthomson.com> 1354575027 -0600	commit: df_side1
+c94b27e41064c521120627e07e2035cca1d24ffa d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1354575070 -0600	checkout: moving from df_side1 to df_side2
+d4207f77243500bec335ab477f9227fcdb1e271a f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 Edward Thomson <ethomson@edwardthomson.com> 1354575206 -0600	commit: df_side2
+f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1354575381 -0600	checkout: moving from df_side2 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c94b27e41064c521120627e07e2035cca1d24ffa Edward Thomson <ethomson@edwardthomson.com> 1355017614 -0600	checkout: moving from master to df_side1
+c94b27e41064c521120627e07e2035cca1d24ffa a90bc3fb6f15181972a2959a921429efbd81a473 Edward Thomson <ethomson@edwardthomson.com> 1355017650 -0600	commit: df_added
+a90bc3fb6f15181972a2959a921429efbd81a473 c94b27e41064c521120627e07e2035cca1d24ffa Edward Thomson <ethomson@edwardthomson.com> 1355017673 -0600	checkout: moving from df_side1 to c94b27e
+c94b27e41064c521120627e07e2035cca1d24ffa d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355017673 -0600	rebase -i (squash): updating HEAD
+d4207f77243500bec335ab477f9227fcdb1e271a 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355017673 -0600	rebase -i (squash): df_side1
+005b6fcc8fec71d2550bef8462d169b3c26aa14b 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355017676 -0600	rebase -i (finish): returning to refs/heads/df_side1
+005b6fcc8fec71d2550bef8462d169b3c26aa14b f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 Edward Thomson <ethomson@edwardthomson.com> 1355017715 -0600	reset: moving to df_side2
+f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 8c749d9968d4b10dcfb06c9f97d0e5d92d337071 Edward Thomson <ethomson@edwardthomson.com> 1355017744 -0600	commit: df_added
+8c749d9968d4b10dcfb06c9f97d0e5d92d337071 f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 Edward Thomson <ethomson@edwardthomson.com> 1355017754 -0600	checkout: moving from df_side1 to f8958bd
+f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355017754 -0600	rebase -i (squash): updating HEAD
+d4207f77243500bec335ab477f9227fcdb1e271a 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355017754 -0600	rebase -i (squash): df_side2
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355017756 -0600	rebase -i (finish): returning to refs/heads/df_side1
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355017793 -0600	reset: moving to 005b6fcc8fec71d2550bef8462d169b3c26aa14b
+005b6fcc8fec71d2550bef8462d169b3c26aa14b 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355017826 -0600	reset: moving to 0204a84
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1355017847 -0600	checkout: moving from df_side1 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355168677 -0600	checkout: moving from master to df_side1
+005b6fcc8fec71d2550bef8462d169b3c26aa14b 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355168829 -0600	checkout: moving from df_side1 to df_side1
+005b6fcc8fec71d2550bef8462d169b3c26aa14b 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355168838 -0600	checkout: moving from df_side1 to df_side1
+005b6fcc8fec71d2550bef8462d169b3c26aa14b e8107f24196736b870a318a0e28f048e29f6feff Edward Thomson <ethomson@edwardthomson.com> 1355169065 -0600	commit: df_side1
+e8107f24196736b870a318a0e28f048e29f6feff 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355169081 -0600	checkout: moving from df_side1 to 005b6fc
+005b6fcc8fec71d2550bef8462d169b3c26aa14b d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355169081 -0600	rebase -i (squash): updating HEAD
+d4207f77243500bec335ab477f9227fcdb1e271a 80a8fbb3abb1ba423d554e9630b8fc2e5698f86b Edward Thomson <ethomson@edwardthomson.com> 1355169081 -0600	rebase -i (squash): df_side1
+80a8fbb3abb1ba423d554e9630b8fc2e5698f86b 80a8fbb3abb1ba423d554e9630b8fc2e5698f86b Edward Thomson <ethomson@edwardthomson.com> 1355169084 -0600	rebase -i (finish): returning to refs/heads/df_side1
+80a8fbb3abb1ba423d554e9630b8fc2e5698f86b 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355169141 -0600	checkout: moving from df_side1 to df_side2
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 944f5dd1a867cab4c2bbcb896493435cae1dcc1a Edward Thomson <ethomson@edwardthomson.com> 1355169174 -0600	commit: both
+944f5dd1a867cab4c2bbcb896493435cae1dcc1a 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355169182 -0600	checkout: moving from df_side2 to 0204a84
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355169182 -0600	rebase -i (squash): updating HEAD
+d4207f77243500bec335ab477f9227fcdb1e271a 57079a46233ae2b6df62e9ade71c4948512abefb Edward Thomson <ethomson@edwardthomson.com> 1355169182 -0600	rebase -i (squash): df_side2
+57079a46233ae2b6df62e9ade71c4948512abefb 57079a46233ae2b6df62e9ade71c4948512abefb Edward Thomson <ethomson@edwardthomson.com> 1355169185 -0600	rebase -i (finish): returning to refs/heads/df_side2
+57079a46233ae2b6df62e9ade71c4948512abefb 80a8fbb3abb1ba423d554e9630b8fc2e5698f86b Edward Thomson <ethomson@edwardthomson.com> 1355169241 -0600	checkout: moving from df_side2 to df_side1
+80a8fbb3abb1ba423d554e9630b8fc2e5698f86b e65a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812 Edward Thomson <ethomson@edwardthomson.com> 1355169419 -0600	commit: side1
+e65a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812 80a8fbb3abb1ba423d554e9630b8fc2e5698f86b Edward Thomson <ethomson@edwardthomson.com> 1355169431 -0600	checkout: moving from df_side1 to 80a8fbb
+80a8fbb3abb1ba423d554e9630b8fc2e5698f86b d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355169431 -0600	rebase -i (squash): updating HEAD
+d4207f77243500bec335ab477f9227fcdb1e271a 5dc1018e90b19654bee986b7a0c268804d39659d Edward Thomson <ethomson@edwardthomson.com> 1355169431 -0600	rebase -i (squash): df_side1
+5dc1018e90b19654bee986b7a0c268804d39659d 5dc1018e90b19654bee986b7a0c268804d39659d Edward Thomson <ethomson@edwardthomson.com> 1355169435 -0600	rebase -i (finish): returning to refs/heads/df_side1
+5dc1018e90b19654bee986b7a0c268804d39659d 57079a46233ae2b6df62e9ade71c4948512abefb Edward Thomson <ethomson@edwardthomson.com> 1355169439 -0600	checkout: moving from df_side1 to df_side2
+57079a46233ae2b6df62e9ade71c4948512abefb 58e853f66699fd02629fd50bde08082bc005933a Edward Thomson <ethomson@edwardthomson.com> 1355169460 -0600	commit: side2
+58e853f66699fd02629fd50bde08082bc005933a 57079a46233ae2b6df62e9ade71c4948512abefb Edward Thomson <ethomson@edwardthomson.com> 1355169469 -0600	checkout: moving from df_side2 to 57079a4
+57079a46233ae2b6df62e9ade71c4948512abefb d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355169469 -0600	rebase -i (squash): updating HEAD
+d4207f77243500bec335ab477f9227fcdb1e271a fada9356aa3f74622327a3038ae9c6f92e1c5c1d Edward Thomson <ethomson@edwardthomson.com> 1355169469 -0600	rebase -i (squash): df_side2
+fada9356aa3f74622327a3038ae9c6f92e1c5c1d fada9356aa3f74622327a3038ae9c6f92e1c5c1d Edward Thomson <ethomson@edwardthomson.com> 1355169471 -0600	rebase -i (finish): returning to refs/heads/df_side2
+fada9356aa3f74622327a3038ae9c6f92e1c5c1d 5dc1018e90b19654bee986b7a0c268804d39659d Edward Thomson <ethomson@edwardthomson.com> 1355169494 -0600	checkout: moving from df_side2 to df_side1
+5dc1018e90b19654bee986b7a0c268804d39659d d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355169663 -0600	checkout: moving from df_side1 to d4207f77243500bec335ab477f9227fcdb1e271a
+d4207f77243500bec335ab477f9227fcdb1e271a 849619b03ae540acee4d1edec96b86993da6b497 Edward Thomson <ethomson@edwardthomson.com> 1355169683 -0600	commit: both_dirs
+849619b03ae540acee4d1edec96b86993da6b497 d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1355169691 -0600	checkout: moving from 849619b03ae540acee4d1edec96b86993da6b497 to d4207f7
+d4207f77243500bec335ab477f9227fcdb1e271a bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1355169691 -0600	rebase -i (squash): updating HEAD
+bd593285fc7fe4ca18ccdbabf027f5d689101452 a765fb87eb2f7a1920b73b2d5a057f8f8476a42b Edward Thomson <ethomson@edwardthomson.com> 1355169691 -0600	rebase -i (squash): df_ancestor
+a765fb87eb2f7a1920b73b2d5a057f8f8476a42b 5dc1018e90b19654bee986b7a0c268804d39659d Edward Thomson <ethomson@edwardthomson.com> 1355169706 -0600	checkout: moving from a765fb87eb2f7a1920b73b2d5a057f8f8476a42b to df_side1
+5dc1018e90b19654bee986b7a0c268804d39659d a765fb87eb2f7a1920b73b2d5a057f8f8476a42b Edward Thomson <ethomson@edwardthomson.com> 1355169715 -0600	checkout: moving from df_side1 to a765fb87eb2f7a1920b73b2d5a057f8f8476a42b^0
+a765fb87eb2f7a1920b73b2d5a057f8f8476a42b bc744705e1d8a019993cf88f62bc4020f1b80919 Edward Thomson <ethomson@edwardthomson.com> 1355169801 -0600	commit: df_side1
+bc744705e1d8a019993cf88f62bc4020f1b80919 bc744705e1d8a019993cf88f62bc4020f1b80919 Edward Thomson <ethomson@edwardthomson.com> 1355169822 -0600	checkout: moving from bc744705e1d8a019993cf88f62bc4020f1b80919 to df_side1
+bc744705e1d8a019993cf88f62bc4020f1b80919 fada9356aa3f74622327a3038ae9c6f92e1c5c1d Edward Thomson <ethomson@edwardthomson.com> 1355169826 -0600	checkout: moving from df_side1 to df_side2
+fada9356aa3f74622327a3038ae9c6f92e1c5c1d a765fb87eb2f7a1920b73b2d5a057f8f8476a42b Edward Thomson <ethomson@edwardthomson.com> 1355169866 -0600	checkout: moving from df_side2 to a765fb87eb2f7a1920b73b2d5a057f8f8476a42b^0
+a765fb87eb2f7a1920b73b2d5a057f8f8476a42b 95646149ab6b6ba6edc83cff678582538b457b2b Edward Thomson <ethomson@edwardthomson.com> 1355169897 -0600	rebase: df_side2
+95646149ab6b6ba6edc83cff678582538b457b2b 95646149ab6b6ba6edc83cff678582538b457b2b Edward Thomson <ethomson@edwardthomson.com> 1355169897 -0600	rebase finished: returning to refs/heads/df_side2
+95646149ab6b6ba6edc83cff678582538b457b2b bc744705e1d8a019993cf88f62bc4020f1b80919 Edward Thomson <ethomson@edwardthomson.com> 1355169949 -0600	checkout: moving from df_side2 to df_side1
+bc744705e1d8a019993cf88f62bc4020f1b80919 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1355170046 -0600	checkout: moving from df_side1 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1355181639 -0600	checkout: moving from master to df_ancestor
+bd593285fc7fe4ca18ccdbabf027f5d689101452 2da538570bc1e5b2c3e855bf702f35248ad0735f Edward Thomson <ethomson@edwardthomson.com> 1355181673 -0600	commit: df_ancestor
+2da538570bc1e5b2c3e855bf702f35248ad0735f a7dbfcbfc1a60709cb80b5ca24539008456531d0 Edward Thomson <ethomson@edwardthomson.com> 1355181715 -0600	commit: df_side1
+a7dbfcbfc1a60709cb80b5ca24539008456531d0 a7dbfcbfc1a60709cb80b5ca24539008456531d0 Edward Thomson <ethomson@edwardthomson.com> 1355181743 -0600	checkout: moving from df_ancestor to df_ancestor
+a7dbfcbfc1a60709cb80b5ca24539008456531d0 9a301fbe6fada7dcb74fcd7c20269b5c743459a7 Edward Thomson <ethomson@edwardthomson.com> 1355181775 -0600	commit: df_side2
+9a301fbe6fada7dcb74fcd7c20269b5c743459a7 a7dbfcbfc1a60709cb80b5ca24539008456531d0 Edward Thomson <ethomson@edwardthomson.com> 1355181793 -0600	checkout: moving from df_ancestor to df_side1
+a7dbfcbfc1a60709cb80b5ca24539008456531d0 9a301fbe6fada7dcb74fcd7c20269b5c743459a7 Edward Thomson <ethomson@edwardthomson.com> 1355181797 -0600	checkout: moving from df_side1 to df_side2
+9a301fbe6fada7dcb74fcd7c20269b5c743459a7 9a301fbe6fada7dcb74fcd7c20269b5c743459a7 Edward Thomson <ethomson@edwardthomson.com> 1355182062 -0600	checkout: moving from df_side2 to df_ancestor
+9a301fbe6fada7dcb74fcd7c20269b5c743459a7 2da538570bc1e5b2c3e855bf702f35248ad0735f Edward Thomson <ethomson@edwardthomson.com> 1355182067 -0600	reset: moving to 2da538570bc1e5b2c3e855bf702f35248ad0735f
+2da538570bc1e5b2c3e855bf702f35248ad0735f 2da538570bc1e5b2c3e855bf702f35248ad0735f Edward Thomson <ethomson@edwardthomson.com> 1355182087 -0600	checkout: moving from df_ancestor to df_side2
+2da538570bc1e5b2c3e855bf702f35248ad0735f fc90237dc4891fa6c69827fc465632225e391618 Edward Thomson <ethomson@edwardthomson.com> 1355182104 -0600	commit: df_side2
+fc90237dc4891fa6c69827fc465632225e391618 a7dbfcbfc1a60709cb80b5ca24539008456531d0 Edward Thomson <ethomson@edwardthomson.com> 1355182111 -0600	checkout: moving from df_side2 to df_side1
+a7dbfcbfc1a60709cb80b5ca24539008456531d0 fc90237dc4891fa6c69827fc465632225e391618 Edward Thomson <ethomson@edwardthomson.com> 1355182115 -0600	checkout: moving from df_side1 to df_side2
+fc90237dc4891fa6c69827fc465632225e391618 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1355182122 -0600	checkout: moving from df_side2 to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 d6cf6c7741b3316826af1314042550c97ded1d50 Edward Thomson <ethomson@edwardthomson.com> 1358997543 -0600	checkout: moving from master to unrelated
+d6cf6c7741b3316826af1314042550c97ded1d50 55b4e4687e7a0d9ca367016ed930f385d4022e6f Edward Thomson <ethomson@edwardthomson.com> 1358997664 -0600	commit: conflicting changes
+55b4e4687e7a0d9ca367016ed930f385d4022e6f bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1358997675 -0600	checkout: moving from unrelated to master
+bd593285fc7fe4ca18ccdbabf027f5d689101452 88e185910a15cd13bdf44854ad037f4842b03b29 Edward Thomson <ethomson@microsoft.com> 1365714471 -0500	checkout: moving from master to rename_conflict_ours
+88e185910a15cd13bdf44854ad037f4842b03b29 bef6e37b3ee632ba74159168836f382fed21d77d Edward Thomson <ethomson@microsoft.com> 1365714516 -0500	checkout: moving from rename_conflict_ours to bef6e37b3ee632ba74159168836f382fed21d77d
+bef6e37b3ee632ba74159168836f382fed21d77d 01f149e1b8f84bd8896aaff6d6b22af88459ded0 Edward Thomson <ethomson@microsoft.com> 1365714831 -0500	commit: rename ancestor
+0000000000000000000000000000000000000000 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365714958 -0500	commit (initial): rename conflict ancestor
+2392a2dacc9efb562b8635d6579fb458751c7c5b 88e185910a15cd13bdf44854ad037f4842b03b29 Edward Thomson <ethomson@microsoft.com> 1365714980 -0500	checkout: moving from rename_conflict_ancestor to rename_conflict_ours
+88e185910a15cd13bdf44854ad037f4842b03b29 7c2c5228c9e90170d4a35e6558e47163daf092e5 Edward Thomson <ethomson@microsoft.com> 1365715250 -0500	commit: rename conflict ours
+7c2c5228c9e90170d4a35e6558e47163daf092e5 2f4024ce528d36d8670c289cce5a7963e625bb0c Edward Thomson <ethomson@microsoft.com> 1365715274 -0500	checkout: moving from rename_conflict_ours to rename_conflict_theirs
+2f4024ce528d36d8670c289cce5a7963e625bb0c 56a638b76b75e068590ac999c2f8621e7f3e264c Edward Thomson <ethomson@microsoft.com> 1365715362 -0500	commit: rename conflict theirs
+56a638b76b75e068590ac999c2f8621e7f3e264c 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715368 -0500	checkout: moving from rename_conflict_theirs to rename_conflict_ancestor
+2392a2dacc9efb562b8635d6579fb458751c7c5b 56a638b76b75e068590ac999c2f8621e7f3e264c Edward Thomson <ethomson@microsoft.com> 1365715371 -0500	checkout: moving from rename_conflict_ancestor to rename_conflict_theirs
+56a638b76b75e068590ac999c2f8621e7f3e264c 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715404 -0500	checkout: moving from rename_conflict_theirs to rename_conflict_ancestor
+2392a2dacc9efb562b8635d6579fb458751c7c5b 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715438 -0500	checkout: moving from rename_conflict_ancestor to rename_conflict_ours
+2392a2dacc9efb562b8635d6579fb458751c7c5b 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715480 -0500	checkout: moving from rename_conflict_ours to rename_conflict_ancestor
+2392a2dacc9efb562b8635d6579fb458751c7c5b 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715486 -0500	checkout: moving from rename_conflict_ancestor to rename_conflict_ours
+2392a2dacc9efb562b8635d6579fb458751c7c5b f3293571dcd708b6a3faf03818cd2844d000e198 Edward Thomson <ethomson@microsoft.com> 1365715538 -0500	commit: rename conflict ours
+f3293571dcd708b6a3faf03818cd2844d000e198 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715546 -0500	checkout: moving from rename_conflict_ours to rename_conflict_ancestor
+2392a2dacc9efb562b8635d6579fb458751c7c5b 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715550 -0500	checkout: moving from rename_conflict_ancestor to rename_conflict_thiers
+2392a2dacc9efb562b8635d6579fb458751c7c5b 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715554 -0500	checkout: moving from rename_conflict_thiers to rename_conflict_ancestor
+2392a2dacc9efb562b8635d6579fb458751c7c5b 2392a2dacc9efb562b8635d6579fb458751c7c5b Edward Thomson <ethomson@microsoft.com> 1365715557 -0500	checkout: moving from rename_conflict_ancestor to rename_conflict_theirs
+2392a2dacc9efb562b8635d6579fb458751c7c5b a802e06f1782a9645b9851bc7202cee74a8a4972 Edward Thomson <ethomson@microsoft.com> 1365715572 -0500	commit: rename conflict theirs
+a802e06f1782a9645b9851bc7202cee74a8a4972 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@microsoft.com> 1365715620 -0500	checkout: moving from rename_conflict_theirs to master
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/branch
new file mode 100644
index 0000000..8b0acb7
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351563886 -0500	branch: Created from HEAD
+c607fc30883e335def28cd686b51f6cfa02b06ec 7cb63eed597130ba4abb87b3e544b85021905520 Edward Thomson <ethomson@edwardthomson.com> 1351563965 -0500	commit: branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_ancestor b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_ancestor
new file mode 100644
index 0000000..df7695a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_ancestor
@@ -0,0 +1,5 @@
+0000000000000000000000000000000000000000 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1355181639 -0600	branch: Created from HEAD
+bd593285fc7fe4ca18ccdbabf027f5d689101452 2da538570bc1e5b2c3e855bf702f35248ad0735f Edward Thomson <ethomson@edwardthomson.com> 1355181673 -0600	commit: df_ancestor
+2da538570bc1e5b2c3e855bf702f35248ad0735f a7dbfcbfc1a60709cb80b5ca24539008456531d0 Edward Thomson <ethomson@edwardthomson.com> 1355181715 -0600	commit: df_side1
+a7dbfcbfc1a60709cb80b5ca24539008456531d0 9a301fbe6fada7dcb74fcd7c20269b5c743459a7 Edward Thomson <ethomson@edwardthomson.com> 1355181775 -0600	commit: df_side2
+9a301fbe6fada7dcb74fcd7c20269b5c743459a7 2da538570bc1e5b2c3e855bf702f35248ad0735f Edward Thomson <ethomson@edwardthomson.com> 1355182067 -0600	reset: moving to 2da538570bc1e5b2c3e855bf702f35248ad0735f
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_side1 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_side1
new file mode 100644
index 0000000..a504ad6
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_side1
@@ -0,0 +1,14 @@
+0000000000000000000000000000000000000000 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1354574697 -0600	branch: Created from HEAD
+bd593285fc7fe4ca18ccdbabf027f5d689101452 d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1354574962 -0600	commit: df_ancestor
+d4207f77243500bec335ab477f9227fcdb1e271a c94b27e41064c521120627e07e2035cca1d24ffa Edward Thomson <ethomson@edwardthomson.com> 1354575027 -0600	commit: df_side1
+c94b27e41064c521120627e07e2035cca1d24ffa a90bc3fb6f15181972a2959a921429efbd81a473 Edward Thomson <ethomson@edwardthomson.com> 1355017650 -0600	commit: df_added
+a90bc3fb6f15181972a2959a921429efbd81a473 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355017676 -0600	rebase -i (finish): refs/heads/df_side1 onto c94b27e
+005b6fcc8fec71d2550bef8462d169b3c26aa14b f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 Edward Thomson <ethomson@edwardthomson.com> 1355017715 -0600	reset: moving to df_side2
+f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 8c749d9968d4b10dcfb06c9f97d0e5d92d337071 Edward Thomson <ethomson@edwardthomson.com> 1355017744 -0600	commit: df_added
+8c749d9968d4b10dcfb06c9f97d0e5d92d337071 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355017756 -0600	rebase -i (finish): refs/heads/df_side1 onto f8958bd
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 005b6fcc8fec71d2550bef8462d169b3c26aa14b Edward Thomson <ethomson@edwardthomson.com> 1355017793 -0600	reset: moving to 005b6fcc8fec71d2550bef8462d169b3c26aa14b
+005b6fcc8fec71d2550bef8462d169b3c26aa14b 0204a84f822acbf6386b36d33f1f6bc68bbbf858 Edward Thomson <ethomson@edwardthomson.com> 1355017826 -0600	reset: moving to 0204a84
+005b6fcc8fec71d2550bef8462d169b3c26aa14b e8107f24196736b870a318a0e28f048e29f6feff Edward Thomson <ethomson@edwardthomson.com> 1355169065 -0600	commit: df_side1
+e8107f24196736b870a318a0e28f048e29f6feff 80a8fbb3abb1ba423d554e9630b8fc2e5698f86b Edward Thomson <ethomson@edwardthomson.com> 1355169084 -0600	rebase -i (finish): refs/heads/df_side1 onto 005b6fc
+80a8fbb3abb1ba423d554e9630b8fc2e5698f86b e65a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812 Edward Thomson <ethomson@edwardthomson.com> 1355169419 -0600	commit: side1
+e65a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812 5dc1018e90b19654bee986b7a0c268804d39659d Edward Thomson <ethomson@edwardthomson.com> 1355169435 -0600	rebase -i (finish): refs/heads/df_side1 onto 80a8fbb
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_side2 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_side2
new file mode 100644
index 0000000..27d833e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/df_side2
@@ -0,0 +1,9 @@
+0000000000000000000000000000000000000000 d4207f77243500bec335ab477f9227fcdb1e271a Edward Thomson <ethomson@edwardthomson.com> 1354575051 -0600	branch: Created from d4207f77243500bec335ab477f9227fcdb1e271a
+d4207f77243500bec335ab477f9227fcdb1e271a f8958bdf4d365a84a9a178b1f5f35ff1dacbd884 Edward Thomson <ethomson@edwardthomson.com> 1354575206 -0600	commit: df_side2
+0204a84f822acbf6386b36d33f1f6bc68bbbf858 944f5dd1a867cab4c2bbcb896493435cae1dcc1a Edward Thomson <ethomson@edwardthomson.com> 1355169174 -0600	commit: both
+944f5dd1a867cab4c2bbcb896493435cae1dcc1a 57079a46233ae2b6df62e9ade71c4948512abefb Edward Thomson <ethomson@edwardthomson.com> 1355169185 -0600	rebase -i (finish): refs/heads/df_side2 onto 0204a84
+57079a46233ae2b6df62e9ade71c4948512abefb 58e853f66699fd02629fd50bde08082bc005933a Edward Thomson <ethomson@edwardthomson.com> 1355169460 -0600	commit: side2
+58e853f66699fd02629fd50bde08082bc005933a fada9356aa3f74622327a3038ae9c6f92e1c5c1d Edward Thomson <ethomson@edwardthomson.com> 1355169471 -0600	rebase -i (finish): refs/heads/df_side2 onto 57079a4
+fada9356aa3f74622327a3038ae9c6f92e1c5c1d 95646149ab6b6ba6edc83cff678582538b457b2b Edward Thomson <ethomson@edwardthomson.com> 1355169897 -0600	rebase finished: refs/heads/df_side2 onto a765fb87eb2f7a1920b73b2d5a057f8f8476a42b
+0000000000000000000000000000000000000000 2da538570bc1e5b2c3e855bf702f35248ad0735f Edward Thomson <ethomson@edwardthomson.com> 1355182087 -0600	branch: Created from HEAD
+2da538570bc1e5b2c3e855bf702f35248ad0735f fc90237dc4891fa6c69827fc465632225e391618 Edward Thomson <ethomson@edwardthomson.com> 1355182104 -0600	commit: df_side2
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/ff_branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/ff_branch
new file mode 100644
index 0000000..c470617
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/ff_branch
@@ -0,0 +1,5 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351605785 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 33d500f588fbbe65901d82b4e6b008e549064be0 Edward Thomson <ethomson@edwardthomson.com> 1351605830 -0500	commit: fastforward
+33d500f588fbbe65901d82b4e6b008e549064be0 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351990202 -0500	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1351990205 -0500	merge master: Fast-forward
+bd593285fc7fe4ca18ccdbabf027f5d689101452 fd89f8cffb663ac89095a0f9764902e93ceaca6a Edward Thomson <ethomson@edwardthomson.com> 1351990229 -0500	commit: fastforward
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/master b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/master
new file mode 100644
index 0000000..6047599
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/master
@@ -0,0 +1,5 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1351563869 -0500	commit (initial): initial
+c607fc30883e335def28cd686b51f6cfa02b06ec 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351564033 -0500	commit: master
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 4e0d9401aee78eb345a8685a859d37c8c3c0bbed Edward Thomson <ethomson@edwardthomson.com> 1351875091 -0500	merge octo1 octo2 octo3 octo4: Merge made by the 'octopus' strategy.
+4e0d9401aee78eb345a8685a859d37c8c3c0bbed 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae Edward Thomson <ethomson@edwardthomson.com> 1351875108 -0500	reset: moving to 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae
+54269b3f6ec3d7d4ede24dd350dd5d605495c3ae 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875584 -0500	reset: moving to 977c696519c5a3004c5f1d15d60c89dbeb8f235f
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo1 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo1
new file mode 100644
index 0000000..0b6c921
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo1
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874933 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 16f825815cfd20a07a75c71554e82d8eede0b061 Edward Thomson <ethomson@edwardthomson.com> 1351874954 -0500	commit: octo1
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo2 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo2
new file mode 100644
index 0000000..5392a4f
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo2
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874960 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 158dc7bedb202f5b26502bf3574faa7f4238d56c Edward Thomson <ethomson@edwardthomson.com> 1351874974 -0500	commit: octo2
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo3 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo3
new file mode 100644
index 0000000..7db5617
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo3
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351874980 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 50ce7d7d01217679e26c55939eef119e0c93e272 Edward Thomson <ethomson@edwardthomson.com> 1351874998 -0500	commit: octo3
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo4 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo4
new file mode 100644
index 0000000..b0f9e42
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo4
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875010 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae Edward Thomson <ethomson@edwardthomson.com> 1351875023 -0500	commit: octo4
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo5 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo5
new file mode 100644
index 0000000..614563e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo5
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875031 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f e4f618a2c3ed0669308735727df5ebf2447f022f Edward Thomson <ethomson@edwardthomson.com> 1351875041 -0500	commit: octo5
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo6 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo6
new file mode 100644
index 0000000..4c812ea
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/octo6
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 977c696519c5a3004c5f1d15d60c89dbeb8f235f Edward Thomson <ethomson@edwardthomson.com> 1351875046 -0500	branch: Created from HEAD
+977c696519c5a3004c5f1d15d60c89dbeb8f235f 4ca408a8c88655f7586a1b580be6fad138121e98 Edward Thomson <ethomson@edwardthomson.com> 1351875057 -0500	commit: octo5
+4ca408a8c88655f7586a1b580be6fad138121e98 b6f610aef53bd343e6c96227de874c66f00ee8e8 Edward Thomson <ethomson@edwardthomson.com> 1351875065 -0500	commit (amend): octo6
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/renames1 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/renames1
new file mode 100644
index 0000000..58a7e05
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/renames1
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1353177745 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 412b32fb66137366147f1801ecc962452757d48a Edward Thomson <ethomson@edwardthomson.com> 1353177886 -0600	commit: renames
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/renames2 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/renames2
new file mode 100644
index 0000000..5645ece
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/renames2
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 bd593285fc7fe4ca18ccdbabf027f5d689101452 Edward Thomson <ethomson@edwardthomson.com> 1353794647 -0600	branch: Created from HEAD
+bd593285fc7fe4ca18ccdbabf027f5d689101452 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1353794677 -0600	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec ab40af3cb8a3ed2e2843e96d9aa7871336b94573 Edward Thomson <ethomson@edwardthomson.com> 1353794852 -0600	commit: renames2
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-10 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-10
new file mode 100644
index 0000000..b6bd247
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-10
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100171 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 53825f41ac8d640612f9423a2f03a69f3d96809a Edward Thomson <ethomson@edwardthomson.com> 1352100193 -0600	commit: trivial-10
+53825f41ac8d640612f9423a2f03a69f3d96809a 0ec5f433959cd46177f745903353efb5be08d151 Edward Thomson <ethomson@edwardthomson.com> 1352100223 -0600	commit: trivial-10
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-10-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-10-branch
new file mode 100644
index 0000000..14ce9e5
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-10-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 53825f41ac8d640612f9423a2f03a69f3d96809a Edward Thomson <ethomson@edwardthomson.com> 1352100200 -0600	branch: Created from HEAD
+53825f41ac8d640612f9423a2f03a69f3d96809a 11f4f3c08b737f5fd896cbefa1425ee63b21b2fa Edward Thomson <ethomson@edwardthomson.com> 1352100211 -0600	commit: trivial-10-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-11 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-11
new file mode 100644
index 0000000..3e6b774
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-11
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100930 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 35632e43612c06a3ea924bfbacd48333da874c29 Edward Thomson <ethomson@edwardthomson.com> 1352100958 -0600	commit: trivial-11
+35632e43612c06a3ea924bfbacd48333da874c29 3168dca1a561889b045a6441909f4c56145e666d Edward Thomson <ethomson@edwardthomson.com> 1352100992 -0600	commit: trivial-11
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-11-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-11-branch
new file mode 100644
index 0000000..30d5ec7
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-11-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 35632e43612c06a3ea924bfbacd48333da874c29 Edward Thomson <ethomson@edwardthomson.com> 1352100964 -0600	branch: Created from HEAD
+35632e43612c06a3ea924bfbacd48333da874c29 6718a45909532d1fcf5600d0877f7fe7e78f0b86 Edward Thomson <ethomson@edwardthomson.com> 1352100978 -0600	commit: trivial-11-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-13 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-13
new file mode 100644
index 0000000..3a7302d
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-13
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100559 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa Edward Thomson <ethomson@edwardthomson.com> 1352100589 -0600	commit: trivial-13
+8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa a3fabece9eb8748da810e1e08266fef9b7136ad4 Edward Thomson <ethomson@edwardthomson.com> 1352100625 -0600	commit: trivial-13
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-13-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-13-branch
new file mode 100644
index 0000000..bb26042
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-13-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa Edward Thomson <ethomson@edwardthomson.com> 1352100604 -0600	branch: Created from HEAD
+8f4433f8593ddd65b7dd43dd4564d841f4d9c8aa 05f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c Edward Thomson <ethomson@edwardthomson.com> 1352100610 -0600	commit: trivial-13-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-14 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-14
new file mode 100644
index 0000000..4b70d28
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-14
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352101083 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 596803b523203a4851c824c07366906f8353f4ad Edward Thomson <ethomson@edwardthomson.com> 1352101113 -0600	commit: trivial-14
+596803b523203a4851c824c07366906f8353f4ad 7e2d058d5fedf8329db44db4fac610d6b1a89159 Edward Thomson <ethomson@edwardthomson.com> 1352101141 -0600	commit: trivial-14
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-14-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-14-branch
new file mode 100644
index 0000000..8e491ca
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-14-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 596803b523203a4851c824c07366906f8353f4ad Edward Thomson <ethomson@edwardthomson.com> 1352101117 -0600	branch: Created from HEAD
+596803b523203a4851c824c07366906f8353f4ad 8187117062b750eed4f93fd7e899f17b52ce554d Edward Thomson <ethomson@edwardthomson.com> 1352101132 -0600	commit: trivial-14-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-2alt b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-2alt
new file mode 100644
index 0000000..a2a28d4
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-2alt
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352091695 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 566ab53c220a2eafc1212af1a024513230280ab9 Edward Thomson <ethomson@edwardthomson.com> 1352092452 -0600	commit: 2alt
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-2alt-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-2alt-branch
new file mode 100644
index 0000000..a0a48ae
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-2alt-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352092411 -0600	branch: Created from HEAD
+c607fc30883e335def28cd686b51f6cfa02b06ec c9174cef549ec94ecbc43ef03cdc775b4950becb Edward Thomson <ethomson@edwardthomson.com> 1352092434 -0600	commit: 2alt-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-3alt b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-3alt
new file mode 100644
index 0000000..4374d38
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-3alt
@@ -0,0 +1,3 @@
+566ab53c220a2eafc1212af1a024513230280ab9 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094547 -0600	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 5459c89aa0026d543ce8343bd89871bce543f9c2 Edward Thomson <ethomson@edwardthomson.com> 1352094580 -0600	commit: 3alt
+5459c89aa0026d543ce8343bd89871bce543f9c2 4c9fac0707f8d4195037ae5a681aa48626491541 Edward Thomson <ethomson@edwardthomson.com> 1352094610 -0600	commit: 3alt-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-3alt-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-3alt-branch
new file mode 100644
index 0000000..7a2e6f8
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-3alt-branch
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094594 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-4 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-4
new file mode 100644
index 0000000..3ee6d25
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-4
@@ -0,0 +1,2 @@
+566ab53c220a2eafc1212af1a024513230280ab9 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094764 -0600	reset: moving to c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec cc3e3009134cb88014129fc8858d1101359e5e2f Edward Thomson <ethomson@edwardthomson.com> 1352094815 -0600	commit: trivial-4
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-4-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-4-branch
new file mode 100644
index 0000000..51f8a92
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-4-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352094830 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 183310e30fb1499af8c619108ffea4d300b5e778 Edward Thomson <ethomson@edwardthomson.com> 1352094856 -0600	commit: trivial-4-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-1 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-1
new file mode 100644
index 0000000..1449702
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-1
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096606 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 4fe93c0ec83eb6305cbace3dace88ecee1b63cb6 Edward Thomson <ethomson@edwardthomson.com> 1352096643 -0600	commit: 5alt-1
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-1-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-1-branch
new file mode 100644
index 0000000..4cff835
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-1-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096657 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 478172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2 Edward Thomson <ethomson@edwardthomson.com> 1352096689 -0600	commit: 5alt-1-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-2 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-2
new file mode 100644
index 0000000..3ca077b
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-2
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352096711 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec ebc09d0137cfb0c26697aed0109fb943ad906f3f Edward Thomson <ethomson@edwardthomson.com> 1352096764 -0600	commit: existing file
+ebc09d0137cfb0c26697aed0109fb943ad906f3f 3b47b031b3e55ae11e14a05260b1c3ffd6838d55 Edward Thomson <ethomson@edwardthomson.com> 1352096815 -0600	commit: 5alt-2
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-2-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-2-branch
new file mode 100644
index 0000000..e7bb901
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-5alt-2-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 ebc09d0137cfb0c26697aed0109fb943ad906f3f Edward Thomson <ethomson@edwardthomson.com> 1352096833 -0600	branch: Created from ebc09d0
+ebc09d0137cfb0c26697aed0109fb943ad906f3f f48097eb340dc5a7cae55aabcf1faf4548aa821f Edward Thomson <ethomson@edwardthomson.com> 1352096855 -0600	commit: 5alt-2-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-6 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-6
new file mode 100644
index 0000000..7c717a2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-6
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352097371 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec f7c332bd4d4d4b777366cae4d24d1687477576bf Edward Thomson <ethomson@edwardthomson.com> 1352097389 -0600	commit: 6
+f7c332bd4d4d4b777366cae4d24d1687477576bf 99b4f7e4f24470fa06b980bc21f1095c2a9425c0 Edward Thomson <ethomson@edwardthomson.com> 1352097404 -0600	commit: trivial-6
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-6-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-6-branch
new file mode 100644
index 0000000..715f3ae
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-6-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 f7c332bd4d4d4b777366cae4d24d1687477576bf Edward Thomson <ethomson@edwardthomson.com> 1352097414 -0600	branch: Created from f7c332bd4d4d4b777366cae4d24d1687477576bf
+f7c332bd4d4d4b777366cae4d24d1687477576bf a43150a738849c59376cf30bb2a68348a83c8f48 Edward Thomson <ethomson@edwardthomson.com> 1352097431 -0600	commit: 6-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-7 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-7
new file mode 100644
index 0000000..a014f17
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-7
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352099765 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099790 -0600	commit: trivial-7
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 d874671ef5b20184836cb983bb273e5280384d0b Edward Thomson <ethomson@edwardthomson.com> 1352099947 -0600	commit: trivial-7
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-7-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-7-branch
new file mode 100644
index 0000000..22331d7
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-7-branch
@@ -0,0 +1,5 @@
+0000000000000000000000000000000000000000 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099799 -0600	branch: Created from HEAD
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 73cbfdc4fe843169e5b2af8dcad03cbf3acf306c Edward Thomson <ethomson@edwardthomson.com> 1352099812 -0600	commit: trivial-7-branch
+73cbfdc4fe843169e5b2af8dcad03cbf3acf306c 092ce8682d7f3a2a3a769a6daca58950168ba5c4 Edward Thomson <ethomson@edwardthomson.com> 1352099874 -0600	reset: moving to 092ce8682d7f3a2a3a769a6daca58950168ba5c4
+092ce8682d7f3a2a3a769a6daca58950168ba5c4 009b9cab6fdac02915a88ecd078b7a792ed802d8 Edward Thomson <ethomson@edwardthomson.com> 1352099921 -0600	commit: removed in 7
+009b9cab6fdac02915a88ecd078b7a792ed802d8 5195a1b480f66691b667f10a9e41e70115a78351 Edward Thomson <ethomson@edwardthomson.com> 1352099927 -0600	commit (amend): trivial-7-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-8 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-8
new file mode 100644
index 0000000..7670c35
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-8
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352098816 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec 75a811bf6bc57694adb3fe604786f3a4efd1cd1b Edward Thomson <ethomson@edwardthomson.com> 1352098884 -0600	commit: trivial-8
+75a811bf6bc57694adb3fe604786f3a4efd1cd1b 3575826c96a975031d2c14368529cc5c4353a8fd Edward Thomson <ethomson@edwardthomson.com> 1352099000 -0600	commit: trivial-8
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-8-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-8-branch
new file mode 100644
index 0000000..c4d68ed
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-8-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 75a811bf6bc57694adb3fe604786f3a4efd1cd1b Edward Thomson <ethomson@edwardthomson.com> 1352098947 -0600	branch: Created from HEAD
+75a811bf6bc57694adb3fe604786f3a4efd1cd1b 52d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9 Edward Thomson <ethomson@edwardthomson.com> 1352098979 -0600	commit: trivial-8-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-9 b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-9
new file mode 100644
index 0000000..09a343b
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-9
@@ -0,0 +1,3 @@
+0000000000000000000000000000000000000000 c607fc30883e335def28cd686b51f6cfa02b06ec Edward Thomson <ethomson@edwardthomson.com> 1352100268 -0600	branch: Created from c607fc30883e335def28cd686b51f6cfa02b06ec
+c607fc30883e335def28cd686b51f6cfa02b06ec f0053b8060bb3f0be5cbcc3147a07ece26bf097e Edward Thomson <ethomson@edwardthomson.com> 1352100304 -0600	commit: trivial-9
+f0053b8060bb3f0be5cbcc3147a07ece26bf097e c35dee9bcc0e989f3b0c40f68372a9a51b6c4e6a Edward Thomson <ethomson@edwardthomson.com> 1352100333 -0600	commit: trivial-9
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-9-branch b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-9-branch
new file mode 100644
index 0000000..1b126fb
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/trivial-9-branch
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 f0053b8060bb3f0be5cbcc3147a07ece26bf097e Edward Thomson <ethomson@edwardthomson.com> 1352100310 -0600	branch: Created from HEAD
+f0053b8060bb3f0be5cbcc3147a07ece26bf097e 13d1be4ea52a6ced1d7a1d832f0ee3c399348e5e Edward Thomson <ethomson@edwardthomson.com> 1352100317 -0600	commit: trivial-9-branch
diff --git a/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/unrelated b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/unrelated
new file mode 100644
index 0000000..a83ffc2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/logs/refs/heads/unrelated
@@ -0,0 +1 @@
+d6cf6c7741b3316826af1314042550c97ded1d50 55b4e4687e7a0d9ca367016ed930f385d4022e6f Edward Thomson <ethomson@edwardthomson.com> 1358997664 -0600	commit: conflicting changes
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/00/5b6fcc8fec71d2550bef8462d169b3c26aa14b b/tests-clar/resources/merge-resolve/.gitted/objects/00/5b6fcc8fec71d2550bef8462d169b3c26aa14b
new file mode 100644
index 0000000..82a8da5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/00/5b6fcc8fec71d2550bef8462d169b3c26aa14b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/00/9b9cab6fdac02915a88ecd078b7a792ed802d8 b/tests-clar/resources/merge-resolve/.gitted/objects/00/9b9cab6fdac02915a88ecd078b7a792ed802d8
new file mode 100644
index 0000000..f663a3c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/00/9b9cab6fdac02915a88ecd078b7a792ed802d8 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/00/c7d33f1ffa79d19c2272b370fcaeaadba49c08 b/tests-clar/resources/merge-resolve/.gitted/objects/00/c7d33f1ffa79d19c2272b370fcaeaadba49c08
new file mode 100644
index 0000000..72698dc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/00/c7d33f1ffa79d19c2272b370fcaeaadba49c08 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/01/f149e1b8f84bd8896aaff6d6b22af88459ded0 b/tests-clar/resources/merge-resolve/.gitted/objects/01/f149e1b8f84bd8896aaff6d6b22af88459ded0
new file mode 100644
index 0000000..aa6336d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/01/f149e1b8f84bd8896aaff6d6b22af88459ded0 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/02/04a84f822acbf6386b36d33f1f6bc68bbbf858 b/tests-clar/resources/merge-resolve/.gitted/objects/02/04a84f822acbf6386b36d33f1f6bc68bbbf858
new file mode 100644
index 0000000..2f0a0e1
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/02/04a84f822acbf6386b36d33f1f6bc68bbbf858 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/02/251f990ca8e92e7ae61d3426163fa821c64001 b/tests-clar/resources/merge-resolve/.gitted/objects/02/251f990ca8e92e7ae61d3426163fa821c64001
new file mode 100644
index 0000000..d623117
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/02/251f990ca8e92e7ae61d3426163fa821c64001 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/03/21415405cb906c46869919af56d51dbbe5e85c b/tests-clar/resources/merge-resolve/.gitted/objects/03/21415405cb906c46869919af56d51dbbe5e85c
new file mode 100644
index 0000000..277bdcf
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/03/21415405cb906c46869919af56d51dbbe5e85c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/03/2ebc5ab85d9553bb187d3cd40875ff23a63ed0 b/tests-clar/resources/merge-resolve/.gitted/objects/03/2ebc5ab85d9553bb187d3cd40875ff23a63ed0
new file mode 100644
index 0000000..e5404d8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/03/2ebc5ab85d9553bb187d3cd40875ff23a63ed0 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/03/b87706555accbf874ccd410dbda01e8e70a67f b/tests-clar/resources/merge-resolve/.gitted/objects/03/b87706555accbf874ccd410dbda01e8e70a67f
new file mode 100644
index 0000000..0befcd7
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/03/b87706555accbf874ccd410dbda01e8e70a67f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/03/dad1005e5d06d418f50b12e0bcd48ff2306a03 b/tests-clar/resources/merge-resolve/.gitted/objects/03/dad1005e5d06d418f50b12e0bcd48ff2306a03
new file mode 100644
index 0000000..04011a2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/03/dad1005e5d06d418f50b12e0bcd48ff2306a03 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/05/1ffd7901a442faf56b226161649074f15c7c47 b/tests-clar/resources/merge-resolve/.gitted/objects/05/1ffd7901a442faf56b226161649074f15c7c47
new file mode 100644
index 0000000..65fa689
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/05/1ffd7901a442faf56b226161649074f15c7c47
@@ -0,0 +1 @@
+x+)JMU06·`040031QH,-ÉÏM-JOMLÊIÕ+©(aH:,»:ÎCÉýúô:ÞË	²o>ZC'g$楧¦èfæé&%æ%g€5¬ÎqYôÂeÒZoÇÝÙkÚMíæ2­éÆÔ›X\’ZDPC~^ZNfrIf^:Xéõ›ZHÙŠž1O(_œ,'º×
jvn~JfZ&Ä5†&ȚؽùÁ„	+gÆz¬Ÿ¥•4íú3Ž^¨¦¢ÔÜü2ÜüI{•|þ¹÷	2m»gÜ˾‹©É1ÖËåüŠ5Ó¿Ü,\“µ})TC)0XÀ¡vÿ‰ùzÖ›¦9–¤×Mü°úÕ…'6óbó#—
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/05/8541fc37114bfc1dddf6bd6bffc7fae5c2e6fe b/tests-clar/resources/merge-resolve/.gitted/objects/05/8541fc37114bfc1dddf6bd6bffc7fae5c2e6fe
new file mode 100644
index 0000000..d79dc30
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/05/8541fc37114bfc1dddf6bd6bffc7fae5c2e6fe differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/05/f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c b/tests-clar/resources/merge-resolve/.gitted/objects/05/f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c
new file mode 100644
index 0000000..7b4b152
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/05/f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/07/a759da919f737221791d542f176ab49c88837f b/tests-clar/resources/merge-resolve/.gitted/objects/07/a759da919f737221791d542f176ab49c88837f
new file mode 100644
index 0000000..a34b6c2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/07/a759da919f737221791d542f176ab49c88837f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/07/c514b04698e068892b31c8d352b85813b99c6e b/tests-clar/resources/merge-resolve/.gitted/objects/07/c514b04698e068892b31c8d352b85813b99c6e
new file mode 100644
index 0000000..23ab921
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/07/c514b04698e068892b31c8d352b85813b99c6e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/09/055301463b7f2f8ee5d368f8ed5c0a40ad8515 b/tests-clar/resources/merge-resolve/.gitted/objects/09/055301463b7f2f8ee5d368f8ed5c0a40ad8515
new file mode 100644
index 0000000..bf5b0fc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/09/055301463b7f2f8ee5d368f8ed5c0a40ad8515 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/09/17bb159596aea4d295f4857da77e8f96b3c7dc b/tests-clar/resources/merge-resolve/.gitted/objects/09/17bb159596aea4d295f4857da77e8f96b3c7dc
new file mode 100644
index 0000000..9fb640d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/09/17bb159596aea4d295f4857da77e8f96b3c7dc differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/09/2ce8682d7f3a2a3a769a6daca58950168ba5c4 b/tests-clar/resources/merge-resolve/.gitted/objects/09/2ce8682d7f3a2a3a769a6daca58950168ba5c4
new file mode 100644
index 0000000..b709cf4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/09/2ce8682d7f3a2a3a769a6daca58950168ba5c4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/09/3bebf072dd4bbba88833667d6ffe454df199e1 b/tests-clar/resources/merge-resolve/.gitted/objects/09/3bebf072dd4bbba88833667d6ffe454df199e1
new file mode 100644
index 0000000..ae13207
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/09/3bebf072dd4bbba88833667d6ffe454df199e1 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/09/768bed22680cdb0859683fa9677ccc8d5a25c1 b/tests-clar/resources/merge-resolve/.gitted/objects/09/768bed22680cdb0859683fa9677ccc8d5a25c1
new file mode 100644
index 0000000..5f4b4da
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/09/768bed22680cdb0859683fa9677ccc8d5a25c1 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/0a/75d9aac1dc84fb5aa51f7325c0ab53242ddef7 b/tests-clar/resources/merge-resolve/.gitted/objects/0a/75d9aac1dc84fb5aa51f7325c0ab53242ddef7
new file mode 100644
index 0000000..d537734
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/0a/75d9aac1dc84fb5aa51f7325c0ab53242ddef7 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/0c/fd6c54ef6532d862408f562309dc9c74a401e8 b/tests-clar/resources/merge-resolve/.gitted/objects/0c/fd6c54ef6532d862408f562309dc9c74a401e8
new file mode 100644
index 0000000..40f628f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/0c/fd6c54ef6532d862408f562309dc9c74a401e8 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/0d/52e3a556e189ba0948ae56780918011c1b167d b/tests-clar/resources/merge-resolve/.gitted/objects/0d/52e3a556e189ba0948ae56780918011c1b167d
new file mode 100644
index 0000000..4b633e5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/0d/52e3a556e189ba0948ae56780918011c1b167d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/0d/872f8e871a30208305978ecbf9e66d864f1638 b/tests-clar/resources/merge-resolve/.gitted/objects/0d/872f8e871a30208305978ecbf9e66d864f1638
new file mode 100644
index 0000000..4cbc18e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/0d/872f8e871a30208305978ecbf9e66d864f1638 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/0e/c5f433959cd46177f745903353efb5be08d151 b/tests-clar/resources/merge-resolve/.gitted/objects/0e/c5f433959cd46177f745903353efb5be08d151
new file mode 100644
index 0000000..1bee56c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/0e/c5f433959cd46177f745903353efb5be08d151 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/11/deab00b2d3a6f5a3073988ac050c2d7b6655e2 b/tests-clar/resources/merge-resolve/.gitted/objects/11/deab00b2d3a6f5a3073988ac050c2d7b6655e2
new file mode 100644
index 0000000..857b236
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/11/deab00b2d3a6f5a3073988ac050c2d7b6655e2 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/11/f4f3c08b737f5fd896cbefa1425ee63b21b2fa b/tests-clar/resources/merge-resolve/.gitted/objects/11/f4f3c08b737f5fd896cbefa1425ee63b21b2fa
new file mode 100644
index 0000000..6555194
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/11/f4f3c08b737f5fd896cbefa1425ee63b21b2fa
@@ -0,0 +1 @@
+x¥ŽQ Dýæ\ fw)cüñ^`Û´‰-Q¯/oàßÌ›Ìdb^×¥j²´«EDC²$†­u‚>Œ¡÷,Ö
z@Œ8¢’ºq‘­jk<Ù©GŽ>¹Òz2Lva2)¸VeÅ:ç¢ÏéÅ%éËœ×{ÞôAý¨“|ƒŸÛǼ5K@ˆº mg«ü9£jYž_;„n,¼ÅY½y²P”
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/13/d1be4ea52a6ced1d7a1d832f0ee3c399348e5e b/tests-clar/resources/merge-resolve/.gitted/objects/13/d1be4ea52a6ced1d7a1d832f0ee3c399348e5e
new file mode 100644
index 0000000..4e4e175
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/13/d1be4ea52a6ced1d7a1d832f0ee3c399348e5e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/14/39088f509b79b1535b64193137d3ce4b240734 b/tests-clar/resources/merge-resolve/.gitted/objects/14/39088f509b79b1535b64193137d3ce4b240734
new file mode 100644
index 0000000..51ddf6d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/14/39088f509b79b1535b64193137d3ce4b240734 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/15/8dc7bedb202f5b26502bf3574faa7f4238d56c b/tests-clar/resources/merge-resolve/.gitted/objects/15/8dc7bedb202f5b26502bf3574faa7f4238d56c
new file mode 100644
index 0000000..064423d
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/15/8dc7bedb202f5b26502bf3574faa7f4238d56c
@@ -0,0 +1,2 @@
+x¥ŽK!D]sŠ¾€¦ùCbŒoà i2.b¼¾£ñîªÞK*E½µÛep73UƒÓ¾*NYYôI²Ô”)–j¼ŠL:8§<‹{¼NˆÞ“‹ÎÊH6iDC¶Ê"mqH!–Ì9T¥mé9—>àR^i¸.½=ú
+GÞè'ù+~í@½@j+ƒ7ÑØ£EÝÎNþsFtš]‰7bN)
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/16/f825815cfd20a07a75c71554e82d8eede0b061 b/tests-clar/resources/merge-resolve/.gitted/objects/16/f825815cfd20a07a75c71554e82d8eede0b061
new file mode 100644
index 0000000..82d6525
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/16/f825815cfd20a07a75c71554e82d8eede0b061
@@ -0,0 +1 @@
+x¥ŽK!D]sŠ¾€†šObŒoà Œƒ¯ïh¼»ª÷’Jqoí6A¹›£°JÙ€ˆ¬“T1h¢3§£·Î'LÕ ó.‰{eœc,a`ŠZJÃT1#e+Ù‡œJòUiª">çÒ\ò+Ž×¥·G_áX6úIçò¿vàÞN€šÐ;ÈÀ^’”b£ÛÙYþœgGñ—MMµ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/17/8940b450f238a56c0d75b7955cb57b38191982 b/tests-clar/resources/merge-resolve/.gitted/objects/17/8940b450f238a56c0d75b7955cb57b38191982
new file mode 100644
index 0000000..94e571e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/17/8940b450f238a56c0d75b7955cb57b38191982 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/18/3310e30fb1499af8c619108ffea4d300b5e778 b/tests-clar/resources/merge-resolve/.gitted/objects/18/3310e30fb1499af8c619108ffea4d300b5e778
new file mode 100644
index 0000000..1c4010d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/18/3310e30fb1499af8c619108ffea4d300b5e778 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/18/cb316b1cefa0f8a6946f0e201a8e1a6f845ab9 b/tests-clar/resources/merge-resolve/.gitted/objects/18/cb316b1cefa0f8a6946f0e201a8e1a6f845ab9
new file mode 100644
index 0000000..30f3110
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/18/cb316b1cefa0f8a6946f0e201a8e1a6f845ab9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/19/b7ac485269b672a101060894de3ba9c2a24dd1 b/tests-clar/resources/merge-resolve/.gitted/objects/19/b7ac485269b672a101060894de3ba9c2a24dd1
new file mode 100644
index 0000000..e34ccb8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/19/b7ac485269b672a101060894de3ba9c2a24dd1 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/1c/ff9ec6a47a537380dedfdd17c9e76d74259a2b b/tests-clar/resources/merge-resolve/.gitted/objects/1c/ff9ec6a47a537380dedfdd17c9e76d74259a2b
new file mode 100644
index 0000000..30802bc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/1c/ff9ec6a47a537380dedfdd17c9e76d74259a2b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/1e/4ff029aee68d0d69ef9eb6efa6cbf1ec732f99 b/tests-clar/resources/merge-resolve/.gitted/objects/1e/4ff029aee68d0d69ef9eb6efa6cbf1ec732f99
new file mode 100644
index 0000000..5183b83
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/1e/4ff029aee68d0d69ef9eb6efa6cbf1ec732f99 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/1f/81433e3161efbf250576c58fede7f6b836f3d3 b/tests-clar/resources/merge-resolve/.gitted/objects/1f/81433e3161efbf250576c58fede7f6b836f3d3
new file mode 100644
index 0000000..9708556
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/1f/81433e3161efbf250576c58fede7f6b836f3d3 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/20/91d94c8bd3eb0835dc5220de5e8bb310fa1513 b/tests-clar/resources/merge-resolve/.gitted/objects/20/91d94c8bd3eb0835dc5220de5e8bb310fa1513
new file mode 100644
index 0000000..a843890
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/20/91d94c8bd3eb0835dc5220de5e8bb310fa1513 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/21/671e290278286fb2ce4c63d01699b67adce331 b/tests-clar/resources/merge-resolve/.gitted/objects/21/671e290278286fb2ce4c63d01699b67adce331
new file mode 100644
index 0000000..b656d00
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/21/671e290278286fb2ce4c63d01699b67adce331 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/22/7792b52aaa0b238bea00ec7e509b02623f168c b/tests-clar/resources/merge-resolve/.gitted/objects/22/7792b52aaa0b238bea00ec7e509b02623f168c
new file mode 100644
index 0000000..3bb19bb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/22/7792b52aaa0b238bea00ec7e509b02623f168c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/23/3c0919c998ed110a4b6ff36f353aec8b713487 b/tests-clar/resources/merge-resolve/.gitted/objects/23/3c0919c998ed110a4b6ff36f353aec8b713487
new file mode 100644
index 0000000..d0c8c9e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/23/3c0919c998ed110a4b6ff36f353aec8b713487 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/23/92a2dacc9efb562b8635d6579fb458751c7c5b b/tests-clar/resources/merge-resolve/.gitted/objects/23/92a2dacc9efb562b8635d6579fb458751c7c5b
new file mode 100644
index 0000000..86127a3
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/23/92a2dacc9efb562b8635d6579fb458751c7c5b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/24/1a1005cd9b980732741b74385b891142bcba28 b/tests-clar/resources/merge-resolve/.gitted/objects/24/1a1005cd9b980732741b74385b891142bcba28
new file mode 100644
index 0000000..9b65f66
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/24/1a1005cd9b980732741b74385b891142bcba28 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/24/2591eb280ee9eeb2ce63524b9a8b9bc4cb515d b/tests-clar/resources/merge-resolve/.gitted/objects/24/2591eb280ee9eeb2ce63524b9a8b9bc4cb515d
new file mode 100644
index 0000000..74a0137
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/24/2591eb280ee9eeb2ce63524b9a8b9bc4cb515d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/24/90b9f1a079420870027deefb49f51d6656cf74 b/tests-clar/resources/merge-resolve/.gitted/objects/24/90b9f1a079420870027deefb49f51d6656cf74
new file mode 100644
index 0000000..60497ca
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/24/90b9f1a079420870027deefb49f51d6656cf74 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/25/9d08ca43af9200e9ea9a098e44a5a350ebd9b3 b/tests-clar/resources/merge-resolve/.gitted/objects/25/9d08ca43af9200e9ea9a098e44a5a350ebd9b3
new file mode 100644
index 0000000..2bae669
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/25/9d08ca43af9200e9ea9a098e44a5a350ebd9b3 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/25/c40b7660c08c8fb581f770312f41b9b03119d1 b/tests-clar/resources/merge-resolve/.gitted/objects/25/c40b7660c08c8fb581f770312f41b9b03119d1
new file mode 100644
index 0000000..1852147
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/25/c40b7660c08c8fb581f770312f41b9b03119d1 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/26/153a3ff3649b6c2bb652d3f06878c6e0a172f9 b/tests-clar/resources/merge-resolve/.gitted/objects/26/153a3ff3649b6c2bb652d3f06878c6e0a172f9
new file mode 100644
index 0000000..4fcaa07
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/26/153a3ff3649b6c2bb652d3f06878c6e0a172f9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/27/133da702ba3c60af2a01e96c2555ff4045d692 b/tests-clar/resources/merge-resolve/.gitted/objects/27/133da702ba3c60af2a01e96c2555ff4045d692
new file mode 100644
index 0000000..08e61f8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/27/133da702ba3c60af2a01e96c2555ff4045d692 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2b/0de5dc27505dcdd83a75c8bf1fcd9462cd7add b/tests-clar/resources/merge-resolve/.gitted/objects/2b/0de5dc27505dcdd83a75c8bf1fcd9462cd7add
new file mode 100644
index 0000000..a95f926
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/2b/0de5dc27505dcdd83a75c8bf1fcd9462cd7add differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2b/5f1f181ee3b58ea751f5dd5d8f9b445520a136 b/tests-clar/resources/merge-resolve/.gitted/objects/2b/5f1f181ee3b58ea751f5dd5d8f9b445520a136
new file mode 100644
index 0000000..d24231e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/2b/5f1f181ee3b58ea751f5dd5d8f9b445520a136 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2b/d0a343aeef7a2cf0d158478966a6e587ff3863 b/tests-clar/resources/merge-resolve/.gitted/objects/2b/d0a343aeef7a2cf0d158478966a6e587ff3863
new file mode 100644
index 0000000..d10ca63
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/2b/d0a343aeef7a2cf0d158478966a6e587ff3863 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2d/a538570bc1e5b2c3e855bf702f35248ad0735f b/tests-clar/resources/merge-resolve/.gitted/objects/2d/a538570bc1e5b2c3e855bf702f35248ad0735f
new file mode 100644
index 0000000..83253f8
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/2d/a538570bc1e5b2c3e855bf702f35248ad0735f
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç¹€ÒùN"n¼{ét:Œ‹L$ñúŽâ
ÜU½EQ«õ>¤¶~7:³L
ðÙD[´±5—¬É‡,Øy2e®ÐTت@”¦z*.û(ë´Àç˜[——üžåunum‹<òF?éÌ_ñkjõ$•qNå'#÷àÄF·³ƒÿœ¹Üp!^Gëâ
9+Q.
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2f/2e37b7ebbae467978610896ca3aafcdad2ee67 b/tests-clar/resources/merge-resolve/.gitted/objects/2f/2e37b7ebbae467978610896ca3aafcdad2ee67
new file mode 100644
index 0000000..7adffb1
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/2f/2e37b7ebbae467978610896ca3aafcdad2ee67 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2f/4024ce528d36d8670c289cce5a7963e625bb0c b/tests-clar/resources/merge-resolve/.gitted/objects/2f/4024ce528d36d8670c289cce5a7963e625bb0c
new file mode 100644
index 0000000..0100fd7
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/2f/4024ce528d36d8670c289cce5a7963e625bb0c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2f/56120107d680129a5d9791b521cb1e73a2ed31 b/tests-clar/resources/merge-resolve/.gitted/objects/2f/56120107d680129a5d9791b521cb1e73a2ed31
new file mode 100644
index 0000000..1f5f597
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/2f/56120107d680129a5d9791b521cb1e73a2ed31
@@ -0,0 +1,3 @@
+xí[
+Â@EýžUdR臸žy¤öBÌ”LJ·oÔnBð/pî#Ü"½Ðí>_|Å Ât@„
+“ñapg%hò•aãJYÁÕ®Aâ8Õ©í› fçà²ûN©ì¦¯4À;œ”h[º%cÍO¦ÆÎÕÑuJÑ÷çWÖyÎ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/2f/598248eeccfc27e5ca44d9d96383f6dfea7b16 b/tests-clar/resources/merge-resolve/.gitted/objects/2f/598248eeccfc27e5ca44d9d96383f6dfea7b16
new file mode 100644
index 0000000..1d9f226
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/2f/598248eeccfc27e5ca44d9d96383f6dfea7b16
@@ -0,0 +1 @@
+x+)JMU067c040031QH,-ÉÏM-JOMLÊIÕ+©(aH:,»:ÎCÉýúô:ÞË	²o>ZC'g$楧¦èfæé&%æ%g€5¬ÎqYôÂeÒZoÇÝÙkÚMíæ2­éÆÔ›X\’ZDPC~^ZNfrIf^:Xéõ›ZHÙŠž1O(_œ,'º×
jvQjn~Ä1–ÈÎÑ×3ßþzדôém9‹Wý¹ué]:¦$÷ßüI{•|þ¹÷	2m»gÜ˾‹©Éý1ÖËåüŠ5Ó¿Ü,\“µ})TC)0PÀavý‰ùzÖ›¦9–¤×Mü°úÕ…'6óbˆ—¢
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/31/68dca1a561889b045a6441909f4c56145e666d b/tests-clar/resources/merge-resolve/.gitted/objects/31/68dca1a561889b045a6441909f4c56145e666d
new file mode 100644
index 0000000..2de1c5a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/31/68dca1a561889b045a6441909f4c56145e666d
@@ -0,0 +1,2 @@
+x¥ŽQ
+Â0DýÎ)rJ²›MñÇxM²¥ÛHŒz}«xÿfÞƒaRY–¹ip´kUD$Ï1f¢Q2qê-Ó=Y£ëÁ3R7®²6äÄ¡·Œgàâ9e7 bæ¡w	‚âG›JÕçüâšõe*˽¬ú ý¤“|ůíSYŽÚ"5&Ðñƨng›ü9£ZŸ3_;kÕ¬dO¼
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/31/d5472536041a83d986829240bbbdc897c6f8a6 b/tests-clar/resources/merge-resolve/.gitted/objects/31/d5472536041a83d986829240bbbdc897c6f8a6
new file mode 100644
index 0000000..5ec5acb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/31/d5472536041a83d986829240bbbdc897c6f8a6 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/32/21dd512b7e2dc4b5bd03046df6c81b2ab2070b b/tests-clar/resources/merge-resolve/.gitted/objects/32/21dd512b7e2dc4b5bd03046df6c81b2ab2070b
new file mode 100644
index 0000000..d36138d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/32/21dd512b7e2dc4b5bd03046df6c81b2ab2070b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/33/46d64325b39e5323733492cd55f808994a2475 b/tests-clar/resources/merge-resolve/.gitted/objects/33/46d64325b39e5323733492cd55f808994a2475
new file mode 100644
index 0000000..11546ce
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/33/46d64325b39e5323733492cd55f808994a2475 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/33/d500f588fbbe65901d82b4e6b008e549064be0 b/tests-clar/resources/merge-resolve/.gitted/objects/33/d500f588fbbe65901d82b4e6b008e549064be0
new file mode 100644
index 0000000..061a031
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/33/d500f588fbbe65901d82b4e6b008e549064be0
@@ -0,0 +1,2 @@
+x¥ŽA E]s
+. hbŒoত.ZÅx}[ã
Üýÿ~òó¤Îó£këü¡·œµCAŒž<:km`d”„Ì‘d,!:𦳤žÜòÒõ‚øÁ“„œP1ÉPò qHcc±HEñ«Oµé[zsKú>Õy­‹>çî隿ï¤ÎmŒŠú 6ºÉöüç*¼öRÛn¢>úåOÇ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/34/bfafff88eaf118402b44e6f3e2dbbf1a582b05 b/tests-clar/resources/merge-resolve/.gitted/objects/34/bfafff88eaf118402b44e6f3e2dbbf1a582b05
new file mode 100644
index 0000000..c653cec
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/34/bfafff88eaf118402b44e6f3e2dbbf1a582b05
@@ -0,0 +1 @@
+x•ŽKj1D½Ö)ú	úµ>`Œ7¾A. µ$<`MŒ¯orlŠ¢ ¸÷m‚¶þ4G­›·&údVdƒ[j2ÖµËJÉâ›C«ÑŠgu_GuÒ%ÅÚ2:ƒ3XúزÅàQ‘'Ì"½æÜÊ;?wîïp®kým×¾ÑàƒÛü&îPf!¢	ð%QJ±Ö%:ëûCˆeœzâ½=6šÀ¯qˆ;iOè
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/35/0c6eb3010efc403a6bed682332635314e9ed58 b/tests-clar/resources/merge-resolve/.gitted/objects/35/0c6eb3010efc403a6bed682332635314e9ed58
new file mode 100644
index 0000000..2eee602
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/35/0c6eb3010efc403a6bed682332635314e9ed58 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/35/411bfb77cd2cc431f3a03a2b4976ed94b5d241 b/tests-clar/resources/merge-resolve/.gitted/objects/35/411bfb77cd2cc431f3a03a2b4976ed94b5d241
new file mode 100644
index 0000000..ea024cc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/35/411bfb77cd2cc431f3a03a2b4976ed94b5d241 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/35/4704d3613ad4228e4786fc76656b11e98236c4 b/tests-clar/resources/merge-resolve/.gitted/objects/35/4704d3613ad4228e4786fc76656b11e98236c4
new file mode 100644
index 0000000..1dd13c4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/35/4704d3613ad4228e4786fc76656b11e98236c4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/35/632e43612c06a3ea924bfbacd48333da874c29 b/tests-clar/resources/merge-resolve/.gitted/objects/35/632e43612c06a3ea924bfbacd48333da874c29
new file mode 100644
index 0000000..be7684f
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/35/632e43612c06a3ea924bfbacd48333da874c29
@@ -0,0 +1 @@
+x¥NË
!õLÓÀšd–MŒñb60ÀÝă¨í‹Æ¼½^,ëº40;·iUFf+)›³ˆ1vòBÁ939fG–(ôDIݸʵA$s´è½k]’l|Lä{IgŠ™Ñ$‰Šm.NéÅ5Áy.ë½\a/]ý £|ÛƲ@[g4âä<Hˆª«ýl“?gT«ËsáË µzCøP˜
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/35/75826c96a975031d2c14368529cc5c4353a8fd b/tests-clar/resources/merge-resolve/.gitted/objects/35/75826c96a975031d2c14368529cc5c4353a8fd
new file mode 100644
index 0000000..24e33bc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/35/75826c96a975031d2c14368529cc5c4353a8fd differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/36/219b49367146cb2e6a1555b5a9ebd4d0328495 b/tests-clar/resources/merge-resolve/.gitted/objects/36/219b49367146cb2e6a1555b5a9ebd4d0328495
new file mode 100644
index 0000000..7f80443
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/36/219b49367146cb2e6a1555b5a9ebd4d0328495 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/36/4bbe4ce80c7bd31e6307dce77d46e3e1759fb3 b/tests-clar/resources/merge-resolve/.gitted/objects/36/4bbe4ce80c7bd31e6307dce77d46e3e1759fb3
new file mode 100644
index 0000000..90fd965
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/36/4bbe4ce80c7bd31e6307dce77d46e3e1759fb3 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/37/48859b001c6e627e712a07951aee40afd19b41 b/tests-clar/resources/merge-resolve/.gitted/objects/37/48859b001c6e627e712a07951aee40afd19b41
new file mode 100644
index 0000000..6a0c389
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/37/48859b001c6e627e712a07951aee40afd19b41 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/38/5c8a0f26ddf79e9041e15e17dc352ed2c4cced b/tests-clar/resources/merge-resolve/.gitted/objects/38/5c8a0f26ddf79e9041e15e17dc352ed2c4cced
new file mode 100644
index 0000000..e95ff3a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/38/5c8a0f26ddf79e9041e15e17dc352ed2c4cced
@@ -0,0 +1,2 @@
+x-MK
+1uS¼YÍRÄ…ñ™6C±…6Ò뛪ð¼okn÷ÇåYt àEpª	iÅDûØCd§Éœ³dLõB+8ø%¨q‚±ƒkµÿú+Þe™Þ6¢ï‡©fHüBü·¯1J©ÕÓ4ùFà1l
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/3b/47b031b3e55ae11e14a05260b1c3ffd6838d55 b/tests-clar/resources/merge-resolve/.gitted/objects/3b/47b031b3e55ae11e14a05260b1c3ffd6838d55
new file mode 100644
index 0000000..8208646
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/3b/47b031b3e55ae11e14a05260b1c3ffd6838d55 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/3b/bf0bf59b20df5d5fc58b9fc1dc07be637c301f b/tests-clar/resources/merge-resolve/.gitted/objects/3b/bf0bf59b20df5d5fc58b9fc1dc07be637c301f
new file mode 100644
index 0000000..723a9ae
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/3b/bf0bf59b20df5d5fc58b9fc1dc07be637c301f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/3e/f4d30382ca33fdeba9fda895a99e0891ba37aa b/tests-clar/resources/merge-resolve/.gitted/objects/3e/f4d30382ca33fdeba9fda895a99e0891ba37aa
new file mode 100644
index 0000000..49ee152
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/3e/f4d30382ca33fdeba9fda895a99e0891ba37aa differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/3e/f9bfe82f9635518ae89152322f3b46fd4ba25b b/tests-clar/resources/merge-resolve/.gitted/objects/3e/f9bfe82f9635518ae89152322f3b46fd4ba25b
new file mode 100644
index 0000000..3b5998c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/3e/f9bfe82f9635518ae89152322f3b46fd4ba25b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/40/2784a46a4a3982294231594cbeb431f506d22c b/tests-clar/resources/merge-resolve/.gitted/objects/40/2784a46a4a3982294231594cbeb431f506d22c
new file mode 100644
index 0000000..a17e05d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/40/2784a46a4a3982294231594cbeb431f506d22c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/41/2b32fb66137366147f1801ecc962452757d48a b/tests-clar/resources/merge-resolve/.gitted/objects/41/2b32fb66137366147f1801ecc962452757d48a
new file mode 100644
index 0000000..b183dd7
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/41/2b32fb66137366147f1801ecc962452757d48a
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç¹€ÒIO>"n¼èt:Œ‹™‰x}£xwU¯ xÜj½um'»ë«ˆ.®Ì9»=y6Ø$@T8ÌÀ‰&Lhf4êA«Ü»f¡0BŒ(ˆ.K±‘³>9S<›À+zö¥­ú’_´f}]ZÝÚ]eÐO:Ëwøµ·zÒš†‹ÞƒPƒÙ.Þ¨aNU6õÎOÖ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/43/aafd43bea779ec74317dc361f45ae3f532a505 b/tests-clar/resources/merge-resolve/.gitted/objects/43/aafd43bea779ec74317dc361f45ae3f532a505
new file mode 100644
index 0000000..ac86823
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/43/aafd43bea779ec74317dc361f45ae3f532a505 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/43/c338656342227a3a3cd3aa85cbf784061f5425 b/tests-clar/resources/merge-resolve/.gitted/objects/43/c338656342227a3a3cd3aa85cbf784061f5425
new file mode 100644
index 0000000..d977311
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/43/c338656342227a3a3cd3aa85cbf784061f5425 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/45/299c1ca5e07bba1fd90843056fb559f96b1f5a b/tests-clar/resources/merge-resolve/.gitted/objects/45/299c1ca5e07bba1fd90843056fb559f96b1f5a
new file mode 100644
index 0000000..2093b44
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/45/299c1ca5e07bba1fd90843056fb559f96b1f5a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/46/6daf8552b891e5c22bc58c9d7fc1a2eb8f0289 b/tests-clar/resources/merge-resolve/.gitted/objects/46/6daf8552b891e5c22bc58c9d7fc1a2eb8f0289
new file mode 100644
index 0000000..c39b53a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/46/6daf8552b891e5c22bc58c9d7fc1a2eb8f0289 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/47/6dbb3e207313d1d8aaa120c6ad204bf1295e53 b/tests-clar/resources/merge-resolve/.gitted/objects/47/6dbb3e207313d1d8aaa120c6ad204bf1295e53
new file mode 100644
index 0000000..3e5f66e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/47/6dbb3e207313d1d8aaa120c6ad204bf1295e53 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/47/8172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2 b/tests-clar/resources/merge-resolve/.gitted/objects/47/8172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2
new file mode 100644
index 0000000..d9e250e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/47/8172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/49/130a28ef567af9a6a6104c38773fedfa5f9742 b/tests-clar/resources/merge-resolve/.gitted/objects/49/130a28ef567af9a6a6104c38773fedfa5f9742
new file mode 100644
index 0000000..e2c49f5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/49/130a28ef567af9a6a6104c38773fedfa5f9742 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/49/9df817155e4bdd3c6ee192a72c52f481818230 b/tests-clar/resources/merge-resolve/.gitted/objects/49/9df817155e4bdd3c6ee192a72c52f481818230
new file mode 100644
index 0000000..9c7e471
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/49/9df817155e4bdd3c6ee192a72c52f481818230 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4a/9550ebcc97ce22b22f45af7b829bb030d003f5 b/tests-clar/resources/merge-resolve/.gitted/objects/4a/9550ebcc97ce22b22f45af7b829bb030d003f5
new file mode 100644
index 0000000..6ec674a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4a/9550ebcc97ce22b22f45af7b829bb030d003f5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4b/253da36a0ae8bfce63aeabd8c5b58429925594 b/tests-clar/resources/merge-resolve/.gitted/objects/4b/253da36a0ae8bfce63aeabd8c5b58429925594
new file mode 100644
index 0000000..1a40727
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/4b/253da36a0ae8bfce63aeabd8c5b58429925594
@@ -0,0 +1,2 @@
+x
ÅA
+€0@ÏûŠ¾AðAILm l¡¦ÿ×¹ŒæÔvGxÑ#ÿ6Ù3¬‚tWBØ6—§”ßÐ%´h”
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464 b/tests-clar/resources/merge-resolve/.gitted/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464
new file mode 100644
index 0000000..328c850
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4b/48deed3a433909bfd6b6ab3d4b91348b6af464 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/tests-clar/resources/merge-resolve/.gitted/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
new file mode 100644
index 0000000..adf6411
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4c/9fac0707f8d4195037ae5a681aa48626491541 b/tests-clar/resources/merge-resolve/.gitted/objects/4c/9fac0707f8d4195037ae5a681aa48626491541
new file mode 100644
index 0000000..6b8c85e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4c/9fac0707f8d4195037ae5a681aa48626491541 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4c/a408a8c88655f7586a1b580be6fad138121e98 b/tests-clar/resources/merge-resolve/.gitted/objects/4c/a408a8c88655f7586a1b580be6fad138121e98
new file mode 100644
index 0000000..15cb7f2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4c/a408a8c88655f7586a1b580be6fad138121e98 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4e/0d9401aee78eb345a8685a859d37c8c3c0bbed b/tests-clar/resources/merge-resolve/.gitted/objects/4e/0d9401aee78eb345a8685a859d37c8c3c0bbed
new file mode 100644
index 0000000..57f7eb6
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4e/0d9401aee78eb345a8685a859d37c8c3c0bbed differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4e/886e602529caa9ab11d71f86634bd1b6e0de10 b/tests-clar/resources/merge-resolve/.gitted/objects/4e/886e602529caa9ab11d71f86634bd1b6e0de10
new file mode 100644
index 0000000..53168a0
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4e/886e602529caa9ab11d71f86634bd1b6e0de10 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4e/b04c9e79e88f6640d01ff5b25ca2a60764f216 b/tests-clar/resources/merge-resolve/.gitted/objects/4e/b04c9e79e88f6640d01ff5b25ca2a60764f216
new file mode 100644
index 0000000..f4ec0ef
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4e/b04c9e79e88f6640d01ff5b25ca2a60764f216 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/4f/e93c0ec83eb6305cbace3dace88ecee1b63cb6 b/tests-clar/resources/merge-resolve/.gitted/objects/4f/e93c0ec83eb6305cbace3dace88ecee1b63cb6
new file mode 100644
index 0000000..67dc684
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/4f/e93c0ec83eb6305cbace3dace88ecee1b63cb6 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/50/12fd565b1393bdfda1805d4ec38ce6619e1fd1 b/tests-clar/resources/merge-resolve/.gitted/objects/50/12fd565b1393bdfda1805d4ec38ce6619e1fd1
new file mode 100644
index 0000000..d629a23
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/50/12fd565b1393bdfda1805d4ec38ce6619e1fd1 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/50/4f75ac95a71ef98051817618576a68505b92f9 b/tests-clar/resources/merge-resolve/.gitted/objects/50/4f75ac95a71ef98051817618576a68505b92f9
new file mode 100644
index 0000000..1b24c72
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/50/4f75ac95a71ef98051817618576a68505b92f9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/50/84fc2a88b6bdba8db93bd3953a8f4fdb470238 b/tests-clar/resources/merge-resolve/.gitted/objects/50/84fc2a88b6bdba8db93bd3953a8f4fdb470238
new file mode 100644
index 0000000..84c9987
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/50/84fc2a88b6bdba8db93bd3953a8f4fdb470238 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/50/ce7d7d01217679e26c55939eef119e0c93e272 b/tests-clar/resources/merge-resolve/.gitted/objects/50/ce7d7d01217679e26c55939eef119e0c93e272
new file mode 100644
index 0000000..e2f9f67
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/50/ce7d7d01217679e26c55939eef119e0c93e272 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/51/95a1b480f66691b667f10a9e41e70115a78351 b/tests-clar/resources/merge-resolve/.gitted/objects/51/95a1b480f66691b667f10a9e41e70115a78351
new file mode 100644
index 0000000..088ee54
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/51/95a1b480f66691b667f10a9e41e70115a78351 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/52/d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9 b/tests-clar/resources/merge-resolve/.gitted/objects/52/d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9
new file mode 100644
index 0000000..6522209
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/52/d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9
@@ -0,0 +1,3 @@
+x¥Ž]
+Â0„}Î)rÊnóÓD|ñ^`“ÝЂm$F½¾U¼o3ßä²,sÓ½Ã]«"#€ÇàÙbÈ"ö1±
9÷<Q7ª²6=8
+ˆ1û˜ÜàGKMv>²’cTôhS©úÌ/ª¬/SYîeÕÙè'ä+~mŸÊrÔh\c‡QwàÔF·³MþœQ­ÎÏ™®]èb¥5Mê
¨ÚRŸ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/53/825f41ac8d640612f9423a2f03a69f3d96809a b/tests-clar/resources/merge-resolve/.gitted/objects/53/825f41ac8d640612f9423a2f03a69f3d96809a
new file mode 100644
index 0000000..08cb0b6
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/53/825f41ac8d640612f9423a2f03a69f3d96809a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/54/269b3f6ec3d7d4ede24dd350dd5d605495c3ae b/tests-clar/resources/merge-resolve/.gitted/objects/54/269b3f6ec3d7d4ede24dd350dd5d605495c3ae
new file mode 100644
index 0000000..4a24153
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/54/269b3f6ec3d7d4ede24dd350dd5d605495c3ae
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç¹€ÒI¦ó7ÞÀLºÓŒ‹L$F¼¾£xwUïAQÔj½
m'Ø^Šv9dÁ”-° £Æœ„„\¼äÀˆºÏ½¬C§È'&Î`"ÃÙÅĹä(Ö¡¨ù9–Öõ…_sg}]Z}´UËF?é\¾â×ÔêI‡&ëô@mt;;ÊŸ3ªÑh“z“ÎNÀ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/54/59c89aa0026d543ce8343bd89871bce543f9c2 b/tests-clar/resources/merge-resolve/.gitted/objects/54/59c89aa0026d543ce8343bd89871bce543f9c2
new file mode 100644
index 0000000..178b833
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/54/59c89aa0026d543ce8343bd89871bce543f9c2
@@ -0,0 +1,3 @@
+x¥ŽÑ
!Dý¦
+Ð,,,ãØÀ,9OblßÓØ3ï%“ÉmY.C[L›ÑEtd–`\
%aBH%TƒvB G%QphÐqªêÎ]nCg‚P3BŒ(ˆ¾Hµ1Š4yS)W;IVüsëúT^Ü‹>Ïmy´›ÞËJ?é(_ñk»Ü–ƒ6è-$ç#è-€ZézvÈŸ3
+ù:ÔNqMB
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/54/7607c690372fe81fab8e3bb44c530e129118fd b/tests-clar/resources/merge-resolve/.gitted/objects/54/7607c690372fe81fab8e3bb44c530e129118fd
new file mode 100644
index 0000000..dccd220
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/54/7607c690372fe81fab8e3bb44c530e129118fd differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/55/b4e4687e7a0d9ca367016ed930f385d4022e6f b/tests-clar/resources/merge-resolve/.gitted/objects/55/b4e4687e7a0d9ca367016ed930f385d4022e6f
new file mode 100644
index 0000000..fb157a2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/55/b4e4687e7a0d9ca367016ed930f385d4022e6f
@@ -0,0 +1 @@
+x¥ŽQjÃ0DûíSìZv¥ÕJ‚ú“ä²´Š
µ•\¿Né
ú7ó“û¶­Œã·±«‚Ôd-{á¹LìXçÀÖ'ÅŒ
ÊçéžvmŠä*Ù{¦ÙZ’`$U²ÄÈÆ9ÌÑ-TNé{,}‡Ky¦½ÀuéÛ£78éA_éS‡¿ö‘ûv².ÄèEÞQ§ƒg‡þSsxZýZóXÛ
ò’ÚMÓNRi
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/56/6ab53c220a2eafc1212af1a024513230280ab9 b/tests-clar/resources/merge-resolve/.gitted/objects/56/6ab53c220a2eafc1212af1a024513230280ab9
new file mode 100644
index 0000000..a8855ae
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/56/6ab53c220a2eafc1212af1a024513230280ab9
@@ -0,0 +1,3 @@
+x¥ŽÑ
!Dý¦
+Ð,˱‰1þØ
,°äLDblßÓØ3ï%“I­ÖËÐhÃft
Ù¡XvŽÄøÂäYÍ‚ñ`L2ÑМջ܆NsI¼·b­ËRЧLž¢3…RaÀ$Iñs,­ëS~qÏú¼´úh7½—•~ÒQ¾â×v©Õƒ6Ö!œê-€ZézvÈŸ3
+ù:Ô9âM&
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/56/a638b76b75e068590ac999c2f8621e7f3e264c b/tests-clar/resources/merge-resolve/.gitted/objects/56/a638b76b75e068590ac999c2f8621e7f3e264c
new file mode 100644
index 0000000..36289bf
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/56/a638b76b75e068590ac999c2f8621e7f3e264c
@@ -0,0 +1 @@
+x¥ŽAj!E³öu	vuW©B6sƒ¹€–%ÝÛÁ6äúqÎÝçÁ<iµpo£«BNŒ¼D'LâJfç	­„”¸ lŽ<Æ4“yÆ®ç<–Íâ&JèóÊÙ³³‚>È$Ñ^•‘R²bâÏØ[‡{þ=Ãcoõj'|褯õUéíje¼K«Ÿ°¬Ln¡•n–¬5“ÎСÿP˜Y«‚´³|2`ìzôËü—zQ{
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/57/079a46233ae2b6df62e9ade71c4948512abefb b/tests-clar/resources/merge-resolve/.gitted/objects/57/079a46233ae2b6df62e9ade71c4948512abefb
new file mode 100644
index 0000000..c7eabc4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/57/079a46233ae2b6df62e9ade71c4948512abefb differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/58/43febcb23480df0b5edb22a21c59c772bb8e29 b/tests-clar/resources/merge-resolve/.gitted/objects/58/43febcb23480df0b5edb22a21c59c772bb8e29
new file mode 100644
index 0000000..f6b2a2b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/58/43febcb23480df0b5edb22a21c59c772bb8e29 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/58/e853f66699fd02629fd50bde08082bc005933a b/tests-clar/resources/merge-resolve/.gitted/objects/58/e853f66699fd02629fd50bde08082bc005933a
new file mode 100644
index 0000000..cf6db63
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/58/e853f66699fd02629fd50bde08082bc005933a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/59/6803b523203a4851c824c07366906f8353f4ad b/tests-clar/resources/merge-resolve/.gitted/objects/59/6803b523203a4851c824c07366906f8353f4ad
new file mode 100644
index 0000000..cbc8cbe
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/59/6803b523203a4851c824c07366906f8353f4ad differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5c/2411f8075f48a6b2fdb85ebc0d371747c4df15 b/tests-clar/resources/merge-resolve/.gitted/objects/5c/2411f8075f48a6b2fdb85ebc0d371747c4df15
new file mode 100644
index 0000000..7b41413
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5c/2411f8075f48a6b2fdb85ebc0d371747c4df15 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5c/341ead2ba6f2af98ce5ec3fe84f6b6d2899c0d b/tests-clar/resources/merge-resolve/.gitted/objects/5c/341ead2ba6f2af98ce5ec3fe84f6b6d2899c0d
new file mode 100644
index 0000000..63c86bd
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5c/341ead2ba6f2af98ce5ec3fe84f6b6d2899c0d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5c/3b68a71fc4fa5d362fd3875e53137c6a5ab7a5 b/tests-clar/resources/merge-resolve/.gitted/objects/5c/3b68a71fc4fa5d362fd3875e53137c6a5ab7a5
new file mode 100644
index 0000000..5410014
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5c/3b68a71fc4fa5d362fd3875e53137c6a5ab7a5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5d/c1018e90b19654bee986b7a0c268804d39659d b/tests-clar/resources/merge-resolve/.gitted/objects/5d/c1018e90b19654bee986b7a0c268804d39659d
new file mode 100644
index 0000000..7500b99
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5d/c1018e90b19654bee986b7a0c268804d39659d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5d/dd0fe66f990dc0e5cf9fec6d9b465240e9537f b/tests-clar/resources/merge-resolve/.gitted/objects/5d/dd0fe66f990dc0e5cf9fec6d9b465240e9537f
new file mode 100644
index 0000000..9d8691e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5d/dd0fe66f990dc0e5cf9fec6d9b465240e9537f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5e/b7bb6a146eb3c7fd3990b240a2308eceb1cf8d b/tests-clar/resources/merge-resolve/.gitted/objects/5e/b7bb6a146eb3c7fd3990b240a2308eceb1cf8d
new file mode 100644
index 0000000..aca2666
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5e/b7bb6a146eb3c7fd3990b240a2308eceb1cf8d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/5f/bfbdc04b4eca46f54f4853a3c5a1dce28f5165 b/tests-clar/resources/merge-resolve/.gitted/objects/5f/bfbdc04b4eca46f54f4853a3c5a1dce28f5165
new file mode 100644
index 0000000..aec3867
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/5f/bfbdc04b4eca46f54f4853a3c5a1dce28f5165 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/60/91fc2c036a382a69489e3f518ee5aae9a4e567 b/tests-clar/resources/merge-resolve/.gitted/objects/60/91fc2c036a382a69489e3f518ee5aae9a4e567
new file mode 100644
index 0000000..fa63afb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/60/91fc2c036a382a69489e3f518ee5aae9a4e567 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/61/340eeed7340fa6a8792def9a5938bb5d4434bb b/tests-clar/resources/merge-resolve/.gitted/objects/61/340eeed7340fa6a8792def9a5938bb5d4434bb
new file mode 100644
index 0000000..e830caf
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/61/340eeed7340fa6a8792def9a5938bb5d4434bb differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/61/78885b38fe96e825ac0f492c0a941f288b37f6 b/tests-clar/resources/merge-resolve/.gitted/objects/61/78885b38fe96e825ac0f492c0a941f288b37f6
new file mode 100644
index 0000000..bedc5f2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/61/78885b38fe96e825ac0f492c0a941f288b37f6 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/62/12c31dab5e482247d7977e4f0dd3601decf13b b/tests-clar/resources/merge-resolve/.gitted/objects/62/12c31dab5e482247d7977e4f0dd3601decf13b
new file mode 100644
index 0000000..b6f0607
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/62/12c31dab5e482247d7977e4f0dd3601decf13b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/62/269111c3b02a9355badcb9da8678b1bf41787b b/tests-clar/resources/merge-resolve/.gitted/objects/62/269111c3b02a9355badcb9da8678b1bf41787b
new file mode 100644
index 0000000..0edf659
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/62/269111c3b02a9355badcb9da8678b1bf41787b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/62/c4f6533c9a3894191fdcb96a3be935ade63f1a b/tests-clar/resources/merge-resolve/.gitted/objects/62/c4f6533c9a3894191fdcb96a3be935ade63f1a
new file mode 100644
index 0000000..c0f822d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/62/c4f6533c9a3894191fdcb96a3be935ade63f1a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/63/247125386de9ec90a27ad36169307bf8a11a38 b/tests-clar/resources/merge-resolve/.gitted/objects/63/247125386de9ec90a27ad36169307bf8a11a38
new file mode 100644
index 0000000..bc2d738
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/63/247125386de9ec90a27ad36169307bf8a11a38
@@ -0,0 +1 @@
+xÝ;1D©}Šé¶A‹Vâô\ÀÙ8¬¥àHIVp|²?‰‚ÐLãyO“ÃuN7C]Í¥ƒËlãt¦:iAÐ(xiŒp‚,ÆOñÄæ¡;•æo†7 …UYZB‡½ß÷ý]ÆdUmÔyk©ô[…½Úc©ñþÍ¥)©ñ!êX{¢¿Zó±ö
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/67/18a45909532d1fcf5600d0877f7fe7e78f0b86 b/tests-clar/resources/merge-resolve/.gitted/objects/67/18a45909532d1fcf5600d0877f7fe7e78f0b86
new file mode 100644
index 0000000..ffda698
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/67/18a45909532d1fcf5600d0877f7fe7e78f0b86
@@ -0,0 +1 @@
+x¥ŽÑM1DùNi`‘ǹDBè~è€ǧ]‰Ý ƒöYð7óž4íû¾M8<ÌaæF䬵@Ò˜r*‹Ü85ÆV«±eV÷.Î鉋”0($!“b½UÑ35É—¨¡8¹ÏµÿÒ¾d4ÿºöý£þÉNú“®ö+þÚ£öýÙ#q@€rÉ~àNzžöÏ7Çö¹ÉÛ‚¸Ô!‡®î÷uQu
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/68/c6c84b091926c7d90aa6a79b2bc3bb6adccd8e b/tests-clar/resources/merge-resolve/.gitted/objects/68/c6c84b091926c7d90aa6a79b2bc3bb6adccd8e
new file mode 100644
index 0000000..1e4b075
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/68/c6c84b091926c7d90aa6a79b2bc3bb6adccd8e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/69/f570c57b24ea7c086e94c5e574964798321435 b/tests-clar/resources/merge-resolve/.gitted/objects/69/f570c57b24ea7c086e94c5e574964798321435
new file mode 100644
index 0000000..6975f0b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/69/f570c57b24ea7c086e94c5e574964798321435 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/6a/e1a3967031a42cf955d9d5c2395211ac82f6cf b/tests-clar/resources/merge-resolve/.gitted/objects/6a/e1a3967031a42cf955d9d5c2395211ac82f6cf
new file mode 100644
index 0000000..3b5713c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/6a/e1a3967031a42cf955d9d5c2395211ac82f6cf differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/6b/7e37be8ce0b897093f2878a9dcd8f396beda2c b/tests-clar/resources/merge-resolve/.gitted/objects/6b/7e37be8ce0b897093f2878a9dcd8f396beda2c
new file mode 100644
index 0000000..c393186
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/6b/7e37be8ce0b897093f2878a9dcd8f396beda2c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/6c/06dcd163587c2cc18be44857e0b71116382aeb b/tests-clar/resources/merge-resolve/.gitted/objects/6c/06dcd163587c2cc18be44857e0b71116382aeb
new file mode 100644
index 0000000..2f54be8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/6c/06dcd163587c2cc18be44857e0b71116382aeb differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/6f/32739c3724d1d5f855299309f388606f407468 b/tests-clar/resources/merge-resolve/.gitted/objects/6f/32739c3724d1d5f855299309f388606f407468
new file mode 100644
index 0000000..6741aa4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/6f/32739c3724d1d5f855299309f388606f407468 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/6f/a33014764bf1120a454eb8437ae098238e409b b/tests-clar/resources/merge-resolve/.gitted/objects/6f/a33014764bf1120a454eb8437ae098238e409b
new file mode 100644
index 0000000..973a4f6
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/6f/a33014764bf1120a454eb8437ae098238e409b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/6f/be9fb85c86d7d1435f728da418bdff52c640a9 b/tests-clar/resources/merge-resolve/.gitted/objects/6f/be9fb85c86d7d1435f728da418bdff52c640a9
new file mode 100644
index 0000000..a2c8d93
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/6f/be9fb85c86d7d1435f728da418bdff52c640a9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/71/17467b18605a660ebe5586df69e2311ed5609f b/tests-clar/resources/merge-resolve/.gitted/objects/71/17467b18605a660ebe5586df69e2311ed5609f
new file mode 100644
index 0000000..02e1831
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/71/17467b18605a660ebe5586df69e2311ed5609f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/71/2ebba6669ea847d9829e4f1059d6c830c8b531 b/tests-clar/resources/merge-resolve/.gitted/objects/71/2ebba6669ea847d9829e4f1059d6c830c8b531
new file mode 100644
index 0000000..dd7d58f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/71/2ebba6669ea847d9829e4f1059d6c830c8b531 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/71/add2d7b93d55bf3600f8a1582beceebbd050c8 b/tests-clar/resources/merge-resolve/.gitted/objects/71/add2d7b93d55bf3600f8a1582beceebbd050c8
new file mode 100644
index 0000000..221afa3
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/71/add2d7b93d55bf3600f8a1582beceebbd050c8 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/74/df13f0793afdaa972150bba976f7de8284914e b/tests-clar/resources/merge-resolve/.gitted/objects/74/df13f0793afdaa972150bba976f7de8284914e
new file mode 100644
index 0000000..cb50e67
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/74/df13f0793afdaa972150bba976f7de8284914e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/75/a811bf6bc57694adb3fe604786f3a4efd1cd1b b/tests-clar/resources/merge-resolve/.gitted/objects/75/a811bf6bc57694adb3fe604786f3a4efd1cd1b
new file mode 100644
index 0000000..477fd87
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/75/a811bf6bc57694adb3fe604786f3a4efd1cd1b
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç¹ÀHçk"n¼Hº;Ì€3‘õúŽâ
ÜU½EQç©këý¦7
Ž€ !²7Xdc2±ÇR¬ƒ˜À©[j²tMv… :q.°‹Äc¦D*	l†(¤Ò£µé3¿Rc}ë|¯‹>ÈJ?é$_ñk[ªóQ,ìÑë"€Zéz¶ËŸ3ª·é9¥ë€ê
LŽOÊ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/76/63fce0130db092936b137cabd693ec234eb060 b/tests-clar/resources/merge-resolve/.gitted/objects/76/63fce0130db092936b137cabd693ec234eb060
new file mode 100644
index 0000000..f578a4a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/76/63fce0130db092936b137cabd693ec234eb060 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/76/ab0e2868197ec158ddd6c78d8a0d2fd73d38f9 b/tests-clar/resources/merge-resolve/.gitted/objects/76/ab0e2868197ec158ddd6c78d8a0d2fd73d38f9
new file mode 100644
index 0000000..4d41ad8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/76/ab0e2868197ec158ddd6c78d8a0d2fd73d38f9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/7a/a3edf2bcfee22398e6b55295aa56366b7aaf76 b/tests-clar/resources/merge-resolve/.gitted/objects/7a/a3edf2bcfee22398e6b55295aa56366b7aaf76
new file mode 100644
index 0000000..09f1e4d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/7a/a3edf2bcfee22398e6b55295aa56366b7aaf76 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/7c/2c5228c9e90170d4a35e6558e47163daf092e5 b/tests-clar/resources/merge-resolve/.gitted/objects/7c/2c5228c9e90170d4a35e6558e47163daf092e5
new file mode 100644
index 0000000..52fde92
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/7c/2c5228c9e90170d4a35e6558e47163daf092e5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/7c/b63eed597130ba4abb87b3e544b85021905520 b/tests-clar/resources/merge-resolve/.gitted/objects/7c/b63eed597130ba4abb87b3e544b85021905520
new file mode 100644
index 0000000..769f29c
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/7c/b63eed597130ba4abb87b3e544b85021905520
@@ -0,0 +1,3 @@
+x¥ŽK
+1D]ç¹€Òùt'"n¼H:ÆÅL$F¼¾£xwUïAQÜ–å6´õf7ºˆI“T*zë±J
+–1#;@r´X]¬êžº¬C3A¨ì F'Îa‘j#Š”ÑTâšÀf a•žcn]_Ê+õ¢¯s[mÕGÙè'å+~íÀm9iãÐ ¹‰PïÔF·³CþœQ¹§•gõe"NÕ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/7e/2d058d5fedf8329db44db4fac610d6b1a89159 b/tests-clar/resources/merge-resolve/.gitted/objects/7e/2d058d5fedf8329db44db4fac610d6b1a89159
new file mode 100644
index 0000000..d12d7b4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/7e/2d058d5fedf8329db44db4fac610d6b1a89159 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/7f/7a2da58126226986d71c6ddfab4afba693280d b/tests-clar/resources/merge-resolve/.gitted/objects/7f/7a2da58126226986d71c6ddfab4afba693280d
new file mode 100644
index 0000000..2f833c2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/7f/7a2da58126226986d71c6ddfab4afba693280d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/80/a8fbb3abb1ba423d554e9630b8fc2e5698f86b b/tests-clar/resources/merge-resolve/.gitted/objects/80/a8fbb3abb1ba423d554e9630b8fc2e5698f86b
new file mode 100644
index 0000000..3daf6c3
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/80/a8fbb3abb1ba423d554e9630b8fc2e5698f86b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/81/87117062b750eed4f93fd7e899f17b52ce554d b/tests-clar/resources/merge-resolve/.gitted/objects/81/87117062b750eed4f93fd7e899f17b52ce554d
new file mode 100644
index 0000000..19cac9f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/81/87117062b750eed4f93fd7e899f17b52ce554d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/83/07d93a155903a5c49576583f0ce1f6ff897c0e b/tests-clar/resources/merge-resolve/.gitted/objects/83/07d93a155903a5c49576583f0ce1f6ff897c0e
new file mode 100644
index 0000000..5a96a4e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/83/07d93a155903a5c49576583f0ce1f6ff897c0e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/83/824a8c6658768e2013905219cc8c64cc3d9a2e b/tests-clar/resources/merge-resolve/.gitted/objects/83/824a8c6658768e2013905219cc8c64cc3d9a2e
new file mode 100644
index 0000000..066190f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/83/824a8c6658768e2013905219cc8c64cc3d9a2e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/84/9619b03ae540acee4d1edec96b86993da6b497 b/tests-clar/resources/merge-resolve/.gitted/objects/84/9619b03ae540acee4d1edec96b86993da6b497
new file mode 100644
index 0000000..67271ac
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/84/9619b03ae540acee4d1edec96b86993da6b497
@@ -0,0 +1,3 @@
+x¥ŽK
+1D]ç¹€Òùv7ÞÀ½t’3‹L$ñúŽâ
ÜU½E¥Vë<¤¶v7:³"xç¥K@›R¶
+rÌŠ#Ç"Ôy2[
Xµ5 r2ÆQ´ˆå¨5–”£bŠ=ÇÔº¼æõ,oS«k[ä‰7úIþŠ_;¤VÏRç”?ú`ä<€ØèvvðŸ3"¶1ÝóÜWñEÇP
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/84/de84f8f3a6d63e636ee9ad81f4b80512fa9bbe b/tests-clar/resources/merge-resolve/.gitted/objects/84/de84f8f3a6d63e636ee9ad81f4b80512fa9bbe
new file mode 100644
index 0000000..32f1461
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/84/de84f8f3a6d63e636ee9ad81f4b80512fa9bbe differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/86/088dae8bade454995b21a1c88107b0e1accdab b/tests-clar/resources/merge-resolve/.gitted/objects/86/088dae8bade454995b21a1c88107b0e1accdab
new file mode 100644
index 0000000..623a747
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/86/088dae8bade454995b21a1c88107b0e1accdab differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/87/b4926260d77a3b851e71ecce06839bd650b231 b/tests-clar/resources/merge-resolve/.gitted/objects/87/b4926260d77a3b851e71ecce06839bd650b231
new file mode 100644
index 0000000..91944ff
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/87/b4926260d77a3b851e71ecce06839bd650b231 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/88/e185910a15cd13bdf44854ad037f4842b03b29 b/tests-clar/resources/merge-resolve/.gitted/objects/88/e185910a15cd13bdf44854ad037f4842b03b29
new file mode 100644
index 0000000..ae1c5e2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/88/e185910a15cd13bdf44854ad037f4842b03b29 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/8a/ad9d0ea334951da47b621a475b39cc6ed759bf b/tests-clar/resources/merge-resolve/.gitted/objects/8a/ad9d0ea334951da47b621a475b39cc6ed759bf
new file mode 100644
index 0000000..5e2c943
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/8a/ad9d0ea334951da47b621a475b39cc6ed759bf differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/8a/ae714f7d939309d7f132b30646d96743134a9f b/tests-clar/resources/merge-resolve/.gitted/objects/8a/ae714f7d939309d7f132b30646d96743134a9f
new file mode 100644
index 0000000..34ff560
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/8a/ae714f7d939309d7f132b30646d96743134a9f
@@ -0,0 +1 @@
+x+)JMU06³`040031QH,-ÉÏM-JOMLÊIÕ+©(aH:,»:ÎCÉýúô:ÞË	²o>ZC'g$楧¦èfæé&%æ%g€5¬ÎqYôÂeÒZoÇÝÙkÚMíæ2­éÆÔ›X\’ZDPC~^ZNfrIf^:Xéõ›ZHÙŠž1O(_œ,'º×
jv^j9È!Ɖ9%`¥<sBÞ§ÝHrèSæ¼3§d	ã¨Ò¢ÔÜü2wßüI{•|þ¹÷	2m»gÜ˾‹©ÉÝ1ÖËåüŠ5Ó¿Ü,\“µ})TC)00ÀavʉùzÖ›¦9–¤×Mü°úÕ…'6óbÊå’G
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/8b/095d8fd01594f4d14454d073e3ac57b9ce485f b/tests-clar/resources/merge-resolve/.gitted/objects/8b/095d8fd01594f4d14454d073e3ac57b9ce485f
new file mode 100644
index 0000000..4ec0138
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/8b/095d8fd01594f4d14454d073e3ac57b9ce485f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/8b/5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a b/tests-clar/resources/merge-resolve/.gitted/objects/8b/5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a
new file mode 100644
index 0000000..f4249c2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/8b/5b53cb2aa9ceb1139f5312fcfa3cc3c5a47c9a
@@ -0,0 +1 @@
+xí±	À0S{Š"2ŽŒd,0²‘^?&S¤HóÕÝŸ[Ï8ï눪E›`Ñ„ËrƒZŠ*êdŒ¥­ÆrlŒ,©±ÙcbF/ ·“¶÷'¿ûågв
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/8c/749d9968d4b10dcfb06c9f97d0e5d92d337071 b/tests-clar/resources/merge-resolve/.gitted/objects/8c/749d9968d4b10dcfb06c9f97d0e5d92d337071
new file mode 100644
index 0000000..e42393c
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/8c/749d9968d4b10dcfb06c9f97d0e5d92d337071
@@ -0,0 +1,2 @@
+x¥ŽAB!C]s
+. a€ùcÜx÷f`†|_b¼¾h¼»ö5mšëº^»¶ÞmzÑÙL“`ð”}$26#"8°ÅÆ`s.`Ԛܺ.!bH\<»	i´"Á,K¦œ8¯èÙ—Úô‰_ÔXŸ—º>êMïeÐ:Ê7ø¹]®ëAƒC40ÏÞë­™ŒQƒŽ³]þœQ\.Ä,¬ÞVO 
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/8f/4433f8593ddd65b7dd43dd4564d841f4d9c8aa b/tests-clar/resources/merge-resolve/.gitted/objects/8f/4433f8593ddd65b7dd43dd4564d841f4d9c8aa
new file mode 100644
index 0000000..d2de777
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/8f/4433f8593ddd65b7dd43dd4564d841f4d9c8aa differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/90/a336c7dacbe295159413559b0043b8bdc60d57 b/tests-clar/resources/merge-resolve/.gitted/objects/90/a336c7dacbe295159413559b0043b8bdc60d57
new file mode 100644
index 0000000..35453eb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/90/a336c7dacbe295159413559b0043b8bdc60d57 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/91/2b2d7819cf9c1029e414883857ed61d597a1a5 b/tests-clar/resources/merge-resolve/.gitted/objects/91/2b2d7819cf9c1029e414883857ed61d597a1a5
new file mode 100644
index 0000000..d5df393
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/91/2b2d7819cf9c1029e414883857ed61d597a1a5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/91/8bb3e09090a9995d48af9a2a6296d7e6088d1c b/tests-clar/resources/merge-resolve/.gitted/objects/91/8bb3e09090a9995d48af9a2a6296d7e6088d1c
new file mode 100644
index 0000000..c214ab2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/91/8bb3e09090a9995d48af9a2a6296d7e6088d1c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/92/7d4943cdbdc9a667db8e62cfd0a41870235c51 b/tests-clar/resources/merge-resolve/.gitted/objects/92/7d4943cdbdc9a667db8e62cfd0a41870235c51
new file mode 100644
index 0000000..b6b92c8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/92/7d4943cdbdc9a667db8e62cfd0a41870235c51 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/93/77fccdb210540b8c0520cc6e80eb632c20bd25 b/tests-clar/resources/merge-resolve/.gitted/objects/93/77fccdb210540b8c0520cc6e80eb632c20bd25
new file mode 100644
index 0000000..4b2d93b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/93/77fccdb210540b8c0520cc6e80eb632c20bd25 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/94/4f5dd1a867cab4c2bbcb896493435cae1dcc1a b/tests-clar/resources/merge-resolve/.gitted/objects/94/4f5dd1a867cab4c2bbcb896493435cae1dcc1a
new file mode 100644
index 0000000..1430938
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/94/4f5dd1a867cab4c2bbcb896493435cae1dcc1a
@@ -0,0 +1,2 @@
+x¥ŽK!D]s
+. zšÄ7ÞÀÐ|2.b¼¾h¼»ªWÉKÅVëmH0~7zÎÒ"¦PÈ9`ò:»ÀÑQôi)QÈLEyq=oC*P6-"4„l0StAŽHÌ<u$Âs¬­ËKz…žäumõÑ6yÌ“~Ò9‡_;ÄVORç4z½X¹W¨”˜tžùOà6Vññ4NF
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/94/8ba6e701c1edab0c2d394fb7c5538334129793 b/tests-clar/resources/merge-resolve/.gitted/objects/94/8ba6e701c1edab0c2d394fb7c5538334129793
new file mode 100644
index 0000000..b3e3ef9
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/94/8ba6e701c1edab0c2d394fb7c5538334129793 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/95/646149ab6b6ba6edc83cff678582538b457b2b b/tests-clar/resources/merge-resolve/.gitted/objects/95/646149ab6b6ba6edc83cff678582538b457b2b
new file mode 100644
index 0000000..de9ba28
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/95/646149ab6b6ba6edc83cff678582538b457b2b
@@ -0,0 +1,3 @@
+x•ŽMÂ …]s
+. ™ÃObŒoàÞeH»h1ãõEÓ¸{?y_ÞX–enR}h•Y*	üHFS
+€S ž!$À1…¨Å“*¯M’³˜£wUv4ôIt:ª„è²ÏÞ8KFEA¯6•*oéM5ÉûT–­¬òÌ=ýª+ÿŠÝƲ\ä Ñ CVÁˆžö³ÿÆà`ƒnLj”ÛœX‰iO\
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/95/9de65e568274120fdf9e3af9f77b1550122149 b/tests-clar/resources/merge-resolve/.gitted/objects/95/9de65e568274120fdf9e3af9f77b1550122149
new file mode 100644
index 0000000..e998de8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/95/9de65e568274120fdf9e3af9f77b1550122149 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/96/8ca794a4597f7f6abbb2b8d940b4078a0f3fd4 b/tests-clar/resources/merge-resolve/.gitted/objects/96/8ca794a4597f7f6abbb2b8d940b4078a0f3fd4
new file mode 100644
index 0000000..359e43a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/96/8ca794a4597f7f6abbb2b8d940b4078a0f3fd4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/97/7c696519c5a3004c5f1d15d60c89dbeb8f235f b/tests-clar/resources/merge-resolve/.gitted/objects/97/7c696519c5a3004c5f1d15d60c89dbeb8f235f
new file mode 100644
index 0000000..e561b47
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/97/7c696519c5a3004c5f1d15d60c89dbeb8f235f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/98/ba4205fcf31f5dd93c916d35fe3f3b3d0e6714 b/tests-clar/resources/merge-resolve/.gitted/objects/98/ba4205fcf31f5dd93c916d35fe3f3b3d0e6714
new file mode 100644
index 0000000..6f5e979
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/98/ba4205fcf31f5dd93c916d35fe3f3b3d0e6714
@@ -0,0 +1 @@
+x-ŒÁ
Ã0ûÖ ÐþºG% È…­"ë×Mú!@yÉjÂýñ¼½Šv¬j‚¢:ïAÜÁ‹ÂAÇèM~dú¹­ãÐ{.3Ñ);ÔlÂç]vi›ú6Á„D%þ«¯¦9fú|.z
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/98/d52d07c0b0bbf2b46548f6aa521295c2cb55db b/tests-clar/resources/merge-resolve/.gitted/objects/98/d52d07c0b0bbf2b46548f6aa521295c2cb55db
new file mode 100644
index 0000000..c8d636e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/98/d52d07c0b0bbf2b46548f6aa521295c2cb55db
@@ -0,0 +1,3 @@
+xíA
+€0=÷y„}NË®taÝJ[ï
+ú/^r“’´$ŒÓ<ô,
‡¨"1*[\™ †žYjÑ‹(;Ôóm£9ƒoNŒxcëz"1ï(»7„áy÷Û—.øõ®þ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/99/b4f7e4f24470fa06b980bc21f1095c2a9425c0 b/tests-clar/resources/merge-resolve/.gitted/objects/99/b4f7e4f24470fa06b980bc21f1095c2a9425c0
new file mode 100644
index 0000000..01ad66e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/99/b4f7e4f24470fa06b980bc21f1095c2a9425c0 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/9a/301fbe6fada7dcb74fcd7c20269b5c743459a7 b/tests-clar/resources/merge-resolve/.gitted/objects/9a/301fbe6fada7dcb74fcd7c20269b5c743459a7
new file mode 100644
index 0000000..f413cc5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/9a/301fbe6fada7dcb74fcd7c20269b5c743459a7 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/9a/f731fa116d1eb9a6c0109562472cfee6f5a979 b/tests-clar/resources/merge-resolve/.gitted/objects/9a/f731fa116d1eb9a6c0109562472cfee6f5a979
new file mode 100644
index 0000000..53233c4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/9a/f731fa116d1eb9a6c0109562472cfee6f5a979 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/9c/0b6c34ef379a42d858f03fef38630f476b9102 b/tests-clar/resources/merge-resolve/.gitted/objects/9c/0b6c34ef379a42d858f03fef38630f476b9102
new file mode 100644
index 0000000..e6f8500
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/9c/0b6c34ef379a42d858f03fef38630f476b9102 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/9e/7f4359c469f309b6057febf4c6e80742cbed5b b/tests-clar/resources/merge-resolve/.gitted/objects/9e/7f4359c469f309b6057febf4c6e80742cbed5b
new file mode 100644
index 0000000..72b7c49
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/9e/7f4359c469f309b6057febf4c6e80742cbed5b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/9e/fe7723802d4305142eee177e018fee1572c4f4 b/tests-clar/resources/merge-resolve/.gitted/objects/9e/fe7723802d4305142eee177e018fee1572c4f4
new file mode 100644
index 0000000..c63fc2c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/9e/fe7723802d4305142eee177e018fee1572c4f4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/9f/74397a3397b3585faf09e9926b110d7f654254 b/tests-clar/resources/merge-resolve/.gitted/objects/9f/74397a3397b3585faf09e9926b110d7f654254
new file mode 100644
index 0000000..e7ec397
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/9f/74397a3397b3585faf09e9926b110d7f654254 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a0/31a28ae70e33a641ce4b8a8f6317f1ab79dee4 b/tests-clar/resources/merge-resolve/.gitted/objects/a0/31a28ae70e33a641ce4b8a8f6317f1ab79dee4
new file mode 100644
index 0000000..a6c05d1
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a0/31a28ae70e33a641ce4b8a8f6317f1ab79dee4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a3/9a620dae5bc8b4e771cd4d251b7d080401a21e b/tests-clar/resources/merge-resolve/.gitted/objects/a3/9a620dae5bc8b4e771cd4d251b7d080401a21e
new file mode 100644
index 0000000..4d22586
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a3/9a620dae5bc8b4e771cd4d251b7d080401a21e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a3/fabece9eb8748da810e1e08266fef9b7136ad4 b/tests-clar/resources/merge-resolve/.gitted/objects/a3/fabece9eb8748da810e1e08266fef9b7136ad4
new file mode 100644
index 0000000..24d7dbc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a3/fabece9eb8748da810e1e08266fef9b7136ad4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a4/1b1bb6d0be3c22fb654234c33b428e15c8cc27 b/tests-clar/resources/merge-resolve/.gitted/objects/a4/1b1bb6d0be3c22fb654234c33b428e15c8cc27
new file mode 100644
index 0000000..60789ee
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a4/1b1bb6d0be3c22fb654234c33b428e15c8cc27 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a4/3150a738849c59376cf30bb2a68348a83c8f48 b/tests-clar/resources/merge-resolve/.gitted/objects/a4/3150a738849c59376cf30bb2a68348a83c8f48
new file mode 100644
index 0000000..06ae09e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a4/3150a738849c59376cf30bb2a68348a83c8f48 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a5/563304ddf6caba25cb50323a2ea6f7dbfcadca b/tests-clar/resources/merge-resolve/.gitted/objects/a5/563304ddf6caba25cb50323a2ea6f7dbfcadca
new file mode 100644
index 0000000..a831878
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a5/563304ddf6caba25cb50323a2ea6f7dbfcadca differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a7/08b253bd507417ec42d1467a7fd2d7519c4956 b/tests-clar/resources/merge-resolve/.gitted/objects/a7/08b253bd507417ec42d1467a7fd2d7519c4956
new file mode 100644
index 0000000..bae752a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a7/08b253bd507417ec42d1467a7fd2d7519c4956 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a7/65fb87eb2f7a1920b73b2d5a057f8f8476a42b b/tests-clar/resources/merge-resolve/.gitted/objects/a7/65fb87eb2f7a1920b73b2d5a057f8f8476a42b
new file mode 100644
index 0000000..30abd8b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a7/65fb87eb2f7a1920b73b2d5a057f8f8476a42b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a7/7a56a49f8f3ae242e02717f18ebbc60c5cc543 b/tests-clar/resources/merge-resolve/.gitted/objects/a7/7a56a49f8f3ae242e02717f18ebbc60c5cc543
new file mode 100644
index 0000000..76dd5f9
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a7/7a56a49f8f3ae242e02717f18ebbc60c5cc543 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a7/dbfcbfc1a60709cb80b5ca24539008456531d0 b/tests-clar/resources/merge-resolve/.gitted/objects/a7/dbfcbfc1a60709cb80b5ca24539008456531d0
new file mode 100644
index 0000000..67126c9
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/a7/dbfcbfc1a60709cb80b5ca24539008456531d0
@@ -0,0 +1 @@
+x¥NË
!õL4 a˜ÀÄ/vàÝð²{`1,ÆöEcÞÞ?/ÖR–.õ„»Þ˜%3$“ÁL15fe53'4Á2ÅÃ7^G1yBGV…LAGä	Ù*‘ôä|R)ÿìsmòš^¾%y›kÙê*O<Ôºð×ø±C¬å,‰À’{e”Cg;ÿ9#R¾oKboœ³NÀ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a8/02e06f1782a9645b9851bc7202cee74a8a4972 b/tests-clar/resources/merge-resolve/.gitted/objects/a8/02e06f1782a9645b9851bc7202cee74a8a4972
new file mode 100644
index 0000000..d39034b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/a8/02e06f1782a9645b9851bc7202cee74a8a4972 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a8/87dd39ad3edd610fc9083dcb61e40ab50673d1 b/tests-clar/resources/merge-resolve/.gitted/objects/a8/87dd39ad3edd610fc9083dcb61e40ab50673d1
new file mode 100644
index 0000000..968c42a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/a8/87dd39ad3edd610fc9083dcb61e40ab50673d1
@@ -0,0 +1 @@
+x+)JMU067a040031QH,-ÉÏM-JOMLÊIÕ+©(aH:,»:ÎCÉýúô:ÞË	²o>ZC'g$楧¦èfæé&%æ%g€5¬ÎqYôÂeÒZoÇÝÙkÚMíæ2­éÆÔ›X\’ZDPC~^ZNfrIf^:Xéõ›ZHÙŠž1O(_œ,'º×
jv^j¹nb^ŠnJfZZjQj^	XÃû#3ƒ|>²^Uó:þ'äAÝÔ2¿†R¨†¢ÔÜü2×ßüI{•|þ¹÷	2m»gÜ˾‹©Éõ1ÖËåüŠ5Ó¿Ü,\“µ})TC)0HÀ!vʉùzÖ›¦9–¤×Mü°úÕ…'6óbG–x
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/a9/0bc3fb6f15181972a2959a921429efbd81a473 b/tests-clar/resources/merge-resolve/.gitted/objects/a9/0bc3fb6f15181972a2959a921429efbd81a473
new file mode 100644
index 0000000..91113ee
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/a9/0bc3fb6f15181972a2959a921429efbd81a473
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç}¥;ÿ7ÞÀ½dÒ=Œ‹‰¯ooà®^UQT®¥\;hk6½‰@¦™Â‰gŒ	§5r’èƒÑ“–Œ]uOMnòdgÄz›&ÒècÆ圈õ¨'•ž}­
NüJá¼Öò¨7ØËp?ê(ßàG»\ËÈ8‡¼CØ¢GTÃg»ü9£x¹$faõxN"
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ab/40af3cb8a3ed2e2843e96d9aa7871336b94573 b/tests-clar/resources/merge-resolve/.gitted/objects/ab/40af3cb8a3ed2e2843e96d9aa7871336b94573
new file mode 100644
index 0000000..7da1da6
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ab/40af3cb8a3ed2e2843e96d9aa7871336b94573 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ab/6c44a2e84492ad4b41bb6bac87353e9d02ac8b b/tests-clar/resources/merge-resolve/.gitted/objects/ab/6c44a2e84492ad4b41bb6bac87353e9d02ac8b
new file mode 100644
index 0000000..d840c1a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ab/6c44a2e84492ad4b41bb6bac87353e9d02ac8b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ab/929391ac42572f92110f3deeb4f0844a951e22 b/tests-clar/resources/merge-resolve/.gitted/objects/ab/929391ac42572f92110f3deeb4f0844a951e22
new file mode 100644
index 0000000..8840d00
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ab/929391ac42572f92110f3deeb4f0844a951e22 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ac/4045f965119e6998f4340ed0f411decfb3ec05 b/tests-clar/resources/merge-resolve/.gitted/objects/ac/4045f965119e6998f4340ed0f411decfb3ec05
new file mode 100644
index 0000000..4c32d63
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ac/4045f965119e6998f4340ed0f411decfb3ec05 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ad/a14492498136771f69dd451866cabcb0e9ef9a b/tests-clar/resources/merge-resolve/.gitted/objects/ad/a14492498136771f69dd451866cabcb0e9ef9a
new file mode 100644
index 0000000..71023de
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ad/a14492498136771f69dd451866cabcb0e9ef9a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ad/a55a45d14527dc3dfc714ea1c65d2e1e6fbe87 b/tests-clar/resources/merge-resolve/.gitted/objects/ad/a55a45d14527dc3dfc714ea1c65d2e1e6fbe87
new file mode 100644
index 0000000..3091b8f
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/ad/a55a45d14527dc3dfc714ea1c65d2e1e6fbe87
@@ -0,0 +1 @@
+x+)JMU067d040031QH,-ÉÏM-JOMLÊIÕ+©(aH:,»:ÎCÉýúô:ÞË	²o>ZC'g$楧¦èfæé&%æ%g€5¬ÎqYôÂeÒZoÇÝÙkÚMíæ2­éÆÔ›X\’ZDPC~^ZNfrIf^:Xéõ›ZHÙŠž1O(_œ,'º×
jvn~JfZ&Ä5†Æ`ÕÆnלU7ÏV.6™t6ôÇL/•R¨ê¢ÔÜü2§ßüI{•|þ¹÷	2m»gÜ˾‹©Éé1ÖËåüŠ5Ó¿Ü,\“µ})TC)0<ÀÁvʉùzÖ›¦9–¤×Mü°úÕ…'6ób±N’*
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/b2/d399ae15224e1d58066e3c8df70ce37de7a656 b/tests-clar/resources/merge-resolve/.gitted/objects/b2/d399ae15224e1d58066e3c8df70ce37de7a656
new file mode 100644
index 0000000..20fa838
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/b2/d399ae15224e1d58066e3c8df70ce37de7a656
@@ -0,0 +1,2 @@
+xíQA1ôÌ+x€ÙÄ‹‰Ï¡-kI*5”f¿/»zõîÁ	af˜!¤Ö^/·“W¸Jcܤ5LŒÆ›‰;+ŠBŸ6ÎHZP|`îóh>\(óÙ$“sà´î•íX·@š¢75€}57¹K
+¯µ+=;g—®@нÒ!¬4Úè!Œ,\$\ \Âb/±ÉHsø©#þa¾¼÷QÄß
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/b4/2712cfe99a1a500b2a51fe984e0b8a7702ba11 b/tests-clar/resources/merge-resolve/.gitted/objects/b4/2712cfe99a1a500b2a51fe984e0b8a7702ba11
new file mode 100644
index 0000000..2820b46
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/b4/2712cfe99a1a500b2a51fe984e0b8a7702ba11
@@ -0,0 +1,5 @@
+xíA
+À {öû†Bé{M1 	¨¥ß¯>£PØËË–‹3ŽýÜFÖŽ7Á¥E02
<Z
+XÐĨJ
+ÃAˆ^«Ú
+ündim=p#‹Yz¿÷“?¼\»š
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/b6/9fe837e4cecfd4c9a40cdca7c138468687df07 b/tests-clar/resources/merge-resolve/.gitted/objects/b6/9fe837e4cecfd4c9a40cdca7c138468687df07
new file mode 100644
index 0000000..6dbcb05
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/b6/9fe837e4cecfd4c9a40cdca7c138468687df07
@@ -0,0 +1,2 @@
+xí’A
+1E»Î)þf7í}ÌŒ!‚QHzýZºí\|üOùU½âµ?Ñe!‹pJk<ÙM”oQ-¤ËQéÑàáI>†Ûý¶‹XŽ0üš¹Ì’ê,)ë$;:¯‚­Ü·îþÍÆ(óä:
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/b6/f610aef53bd343e6c96227de874c66f00ee8e8 b/tests-clar/resources/merge-resolve/.gitted/objects/b6/f610aef53bd343e6c96227de874c66f00ee8e8
new file mode 100644
index 0000000..fb102f1
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/b6/f610aef53bd343e6c96227de874c66f00ee8e8 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/b7/a2576f9fc20024ac9ef17cb134acbd1ac73127 b/tests-clar/resources/merge-resolve/.gitted/objects/b7/a2576f9fc20024ac9ef17cb134acbd1ac73127
new file mode 100644
index 0000000..22f2d13
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/b7/a2576f9fc20024ac9ef17cb134acbd1ac73127 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/b8/a3a806d3950e8c0a03a34f234a92eff0e2c68d b/tests-clar/resources/merge-resolve/.gitted/objects/b8/a3a806d3950e8c0a03a34f234a92eff0e2c68d
new file mode 100644
index 0000000..24f0299
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/b8/a3a806d3950e8c0a03a34f234a92eff0e2c68d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ba/cac9b3493509aa15e1730e1545fc0919d1dae0 b/tests-clar/resources/merge-resolve/.gitted/objects/ba/cac9b3493509aa15e1730e1545fc0919d1dae0
new file mode 100644
index 0000000..f35586f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ba/cac9b3493509aa15e1730e1545fc0919d1dae0 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/bc/744705e1d8a019993cf88f62bc4020f1b80919 b/tests-clar/resources/merge-resolve/.gitted/objects/bc/744705e1d8a019993cf88f62bc4020f1b80919
new file mode 100644
index 0000000..0d4bdb3
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/bc/744705e1d8a019993cf88f62bc4020f1b80919
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç}%ÿˆ¸ñî%t˜YÄH&âõâ
ÜU½¢ŠJ­Öu€Ôj7:P(Ú#¥”¬ÌF§Ì„Ä£1”°Ù+kÙ#vºˆÎš‚ÞÊ⢒£S8«‘W|ñÚÙ¨%²øKëpɯØ3\—V·v‡#MúQgú?wH­ž@(c„
žØsË9›tžôçË嶭™{ŸkOó
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/bc/95c75d59386147d1e79a87c33068d8dbfd71f2 b/tests-clar/resources/merge-resolve/.gitted/objects/bc/95c75d59386147d1e79a87c33068d8dbfd71f2
new file mode 100644
index 0000000..436d5a0
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/bc/95c75d59386147d1e79a87c33068d8dbfd71f2 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/bd/593285fc7fe4ca18ccdbabf027f5d689101452 b/tests-clar/resources/merge-resolve/.gitted/objects/bd/593285fc7fe4ca18ccdbabf027f5d689101452
new file mode 100644
index 0000000..75ab1f0
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/bd/593285fc7fe4ca18ccdbabf027f5d689101452 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/bd/867fbae2faa80b920b002b80b1c91bcade7784 b/tests-clar/resources/merge-resolve/.gitted/objects/bd/867fbae2faa80b920b002b80b1c91bcade7784
new file mode 100644
index 0000000..0f74219
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/bd/867fbae2faa80b920b002b80b1c91bcade7784 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/bd/9cb4cd0a770cb9adcb5fce212142ef40ea1c35 b/tests-clar/resources/merge-resolve/.gitted/objects/bd/9cb4cd0a770cb9adcb5fce212142ef40ea1c35
new file mode 100644
index 0000000..2aafdc6
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/bd/9cb4cd0a770cb9adcb5fce212142ef40ea1c35 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/be/f6e37b3ee632ba74159168836f382fed21d77d b/tests-clar/resources/merge-resolve/.gitted/objects/be/f6e37b3ee632ba74159168836f382fed21d77d
new file mode 100644
index 0000000..6c24315
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/be/f6e37b3ee632ba74159168836f382fed21d77d
@@ -0,0 +1,2 @@
+x¥K
+1D]ç}¥»3?AÄ7p?ô$=Œ`Ò‰x}GñîªÞƒª`)Ý+0Ñ®Uhú.N“WÆÞ“!ÆÐIdl¦™øØjë<ëb®ñ%%Âm±´Z†“nô“.ú¿v–Î@¾Cdjy€=ˆn£ÛyÕ?g\Ñ,IÇ`y~ÜC%]«÷½¿H&
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c0/6a9be584ac49aa02c5551312d9e2982c91df10 b/tests-clar/resources/merge-resolve/.gitted/objects/c0/6a9be584ac49aa02c5551312d9e2982c91df10
new file mode 100644
index 0000000..963ef23
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c0/6a9be584ac49aa02c5551312d9e2982c91df10 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c1/b17981db0840109a820dae8674ee29684134ff b/tests-clar/resources/merge-resolve/.gitted/objects/c1/b17981db0840109a820dae8674ee29684134ff
new file mode 100644
index 0000000..fdcf28c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c1/b17981db0840109a820dae8674ee29684134ff differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c1/b6a51bbb87c2f82b161412c3d20b59fc69b090 b/tests-clar/resources/merge-resolve/.gitted/objects/c1/b6a51bbb87c2f82b161412c3d20b59fc69b090
new file mode 100644
index 0000000..3b369f8
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c1/b6a51bbb87c2f82b161412c3d20b59fc69b090 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c3/5dee9bcc0e989f3b0c40f68372a9a51b6c4e6a b/tests-clar/resources/merge-resolve/.gitted/objects/c3/5dee9bcc0e989f3b0c40f68372a9a51b6c4e6a
new file mode 100644
index 0000000..d22b3b2
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c3/5dee9bcc0e989f3b0c40f68372a9a51b6c4e6a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c3/d02eeef75183df7584d8d13ac03053910c1301 b/tests-clar/resources/merge-resolve/.gitted/objects/c3/d02eeef75183df7584d8d13ac03053910c1301
new file mode 100644
index 0000000..2294f01
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c3/d02eeef75183df7584d8d13ac03053910c1301 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c4/efe31e9decccc8b2b4d3df9aac2cdfe2995618 b/tests-clar/resources/merge-resolve/.gitted/objects/c4/efe31e9decccc8b2b4d3df9aac2cdfe2995618
new file mode 100644
index 0000000..c7572d5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c4/efe31e9decccc8b2b4d3df9aac2cdfe2995618 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c5/0d0f1cb60b8b0fe1615ad20ace557e9d68d7bd b/tests-clar/resources/merge-resolve/.gitted/objects/c5/0d0f1cb60b8b0fe1615ad20ace557e9d68d7bd
new file mode 100644
index 0000000..a1d5321
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/c5/0d0f1cb60b8b0fe1615ad20ace557e9d68d7bd
@@ -0,0 +1 @@
+x¥ŽKj1D³Ö)t˜–4ê–À˜l|ï>-f ‚¯9äÞU½‚â¥Vë6¤¶ô1:³Ì¸èè‰ !ÆüÀå>Z.¼P…0“x„Îû‘²¡h˜ÑèhQÖ+tÎ`1NÎZe¢,ÂÏX[—×ü=ËÛÚêÑvyæI_é‹ÿ†ÿvJ­^¤2 í$?ÁˆI§ìà7oÄ4•ï©íå{Kã>VÞú!~|”U=
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c5/bbe550b9f09444bdddd3ecf3d97c0b42aa786c b/tests-clar/resources/merge-resolve/.gitted/objects/c5/bbe550b9f09444bdddd3ecf3d97c0b42aa786c
new file mode 100644
index 0000000..2f2ada7
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c5/bbe550b9f09444bdddd3ecf3d97c0b42aa786c differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c6/07fc30883e335def28cd686b51f6cfa02b06ec b/tests-clar/resources/merge-resolve/.gitted/objects/c6/07fc30883e335def28cd686b51f6cfa02b06ec
new file mode 100644
index 0000000..475b87e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/c6/07fc30883e335def28cd686b51f6cfa02b06ec
@@ -0,0 +1,2 @@
+x¥Q
+1Dýî)r%±›n"þx/m[°[¨¯ooàßÌ{0k)¹…i×›*`â£ZavJ>,‚aò¢ìf<EZÈÍÉȳ¯µÁ5½¤%¸­µ<ê'ô“.ú¿vˆµœ,;ë]€=2¢tœwýsÆä-÷,wóÊ8@°
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c6/92ecf62007c0ac9fb26e2aa884de2933de15ed b/tests-clar/resources/merge-resolve/.gitted/objects/c6/92ecf62007c0ac9fb26e2aa884de2933de15ed
new file mode 100644
index 0000000..ae430bd
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c6/92ecf62007c0ac9fb26e2aa884de2933de15ed differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c8/f06f2e3bb2964174677e91f0abead0e43c9e5d b/tests-clar/resources/merge-resolve/.gitted/objects/c8/f06f2e3bb2964174677e91f0abead0e43c9e5d
new file mode 100644
index 0000000..5dae4c3
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c8/f06f2e3bb2964174677e91f0abead0e43c9e5d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c9/174cef549ec94ecbc43ef03cdc775b4950becb b/tests-clar/resources/merge-resolve/.gitted/objects/c9/174cef549ec94ecbc43ef03cdc775b4950becb
new file mode 100644
index 0000000..da8dba2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/c9/174cef549ec94ecbc43ef03cdc775b4950becb
@@ -0,0 +1,2 @@
+x¥ŽQ
+Â0DýÎ)rÊf“nSñÇxífCÛHŒx}«xÿfÞÀc¤,˵Y´kUÕbïò8‚pÔu`%—|@rä3GtBÀ™;W]›‚!‹‡½zß'Í%Q¤iÓdœ€T?Û\ª=§×d/sYeµÝè'ô;üÚ^Êr´Î÷#l`6ºmú§Æ ßZ7U^e6oVòO´
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/c9/4b27e41064c521120627e07e2035cca1d24ffa b/tests-clar/resources/merge-resolve/.gitted/objects/c9/4b27e41064c521120627e07e2035cca1d24ffa
new file mode 100644
index 0000000..fd1ec9f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/c9/4b27e41064c521120627e07e2035cca1d24ffa differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ca/b2cf23998b40f1af2d9d9a756dc9e285a8df4b b/tests-clar/resources/merge-resolve/.gitted/objects/ca/b2cf23998b40f1af2d9d9a756dc9e285a8df4b
new file mode 100644
index 0000000..32ba2aa
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ca/b2cf23998b40f1af2d9d9a756dc9e285a8df4b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/cb/491780d82e46dc88a065b965ab307a038f2bc2 b/tests-clar/resources/merge-resolve/.gitted/objects/cb/491780d82e46dc88a065b965ab307a038f2bc2
new file mode 100644
index 0000000..cf9cd7d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/cb/491780d82e46dc88a065b965ab307a038f2bc2 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/cb/6693a788715b82440a54e0eacd19ba9f6ec559 b/tests-clar/resources/merge-resolve/.gitted/objects/cb/6693a788715b82440a54e0eacd19ba9f6ec559
new file mode 100644
index 0000000..e11181a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/cb/6693a788715b82440a54e0eacd19ba9f6ec559 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/cc/3e3009134cb88014129fc8858d1101359e5e2f b/tests-clar/resources/merge-resolve/.gitted/objects/cc/3e3009134cb88014129fc8858d1101359e5e2f
new file mode 100644
index 0000000..9a0cb7a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/cc/3e3009134cb88014129fc8858d1101359e5e2f
@@ -0,0 +1,2 @@
+x¥Ž]
+Â0„}Î)ö•Íß&_¼H“
-ØFbÔë[Åø6ó}0LªË2wPÆìzc†’­Ë*“sXbö‚
Rt”®#Gë$‰[l¼vH„®$ÞkÖÚf.ʧLžF+¥QHœD|ô©68çWl.S]îu…oô“Nü¿¶Ou9‚ÔVa0^ZÅF·³ÿœ½ÍÏ9^#Þ
ØOd
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ce/8860d49e3bea6fd745874a01b7c3e46da8cbc3 b/tests-clar/resources/merge-resolve/.gitted/objects/ce/8860d49e3bea6fd745874a01b7c3e46da8cbc3
new file mode 100644
index 0000000..860f995
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ce/8860d49e3bea6fd745874a01b7c3e46da8cbc3 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ce/e656c392ad0557b3aae0fb411475c206e2926f b/tests-clar/resources/merge-resolve/.gitted/objects/ce/e656c392ad0557b3aae0fb411475c206e2926f
new file mode 100644
index 0000000..ff0624c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ce/e656c392ad0557b3aae0fb411475c206e2926f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/cf/8c5cc8a85a1ff5a4ba51e0bc7cf5665669924d b/tests-clar/resources/merge-resolve/.gitted/objects/cf/8c5cc8a85a1ff5a4ba51e0bc7cf5665669924d
new file mode 100644
index 0000000..36b0289
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/cf/8c5cc8a85a1ff5a4ba51e0bc7cf5665669924d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d0/7ec190c306ec690bac349e87d01c4358e49bb2 b/tests-clar/resources/merge-resolve/.gitted/objects/d0/7ec190c306ec690bac349e87d01c4358e49bb2
new file mode 100644
index 0000000..d52a56f
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/d0/7ec190c306ec690bac349e87d01c4358e49bb2
@@ -0,0 +1,2 @@
+xÕ±
€0©™Â3¤ažObˆ%Ç‘S°=HTŒ@u:]uYG¦´¥%šLÚE™–;¸’uÌ`_?gŒÎ~0²òßÒ”.
+׋Pëû£ÓœñxvXië
Ó­f!
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d0/d4594e16f2e19107e3fa7ea63e7aaaff305ffb b/tests-clar/resources/merge-resolve/.gitted/objects/d0/d4594e16f2e19107e3fa7ea63e7aaaff305ffb
new file mode 100644
index 0000000..5f7e286
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d0/d4594e16f2e19107e3fa7ea63e7aaaff305ffb differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d2/f8637f2eab2507a1e13cbc9df4729ec386627e b/tests-clar/resources/merge-resolve/.gitted/objects/d2/f8637f2eab2507a1e13cbc9df4729ec386627e
new file mode 100644
index 0000000..558a851
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d2/f8637f2eab2507a1e13cbc9df4729ec386627e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d3/719a5ae8e4d92276b5313ce976f6ee5af2b436 b/tests-clar/resources/merge-resolve/.gitted/objects/d3/719a5ae8e4d92276b5313ce976f6ee5af2b436
new file mode 100644
index 0000000..930bf5a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/d3/719a5ae8e4d92276b5313ce976f6ee5af2b436
@@ -0,0 +1,2 @@
+x=1Â0E™}Š¿uAH…بÄ
z‡¸ÔRHPÔŸ´T–¿÷ìBrh/ç]?ªaÐ ˜48¡,‘_â¡MúdköÄуTPF!«÷›TïZµQ?
+RÖ§F«Në™ÕÊÒ_J͆ÃÔØh’ª{Ÿßò(kÒËLKV1p–+Q‹êÑÕÝÑ®A×
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d3/7aa3bbfe1c0c49b909781251b956dbabe85f96 b/tests-clar/resources/merge-resolve/.gitted/objects/d3/7aa3bbfe1c0c49b909781251b956dbabe85f96
new file mode 100644
index 0000000..5902e0f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d3/7aa3bbfe1c0c49b909781251b956dbabe85f96 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d3/7ad72a2052685fc6201c2af90103ad42d2079b b/tests-clar/resources/merge-resolve/.gitted/objects/d3/7ad72a2052685fc6201c2af90103ad42d2079b
new file mode 100644
index 0000000..b2f39bf
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d3/7ad72a2052685fc6201c2af90103ad42d2079b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d4/207f77243500bec335ab477f9227fcdb1e271a b/tests-clar/resources/merge-resolve/.gitted/objects/d4/207f77243500bec335ab477f9227fcdb1e271a
new file mode 100644
index 0000000..862e4e5
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/d4/207f77243500bec335ab477f9227fcdb1e271a
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç¹€’O'™7ÞÀ½t:ÝŒ‹™H&âõŸ«zŠ¢:Ï÷®Ä]oÌZÀBñBXlô(ƒƒ“昭+d<"«6^ºÎ%ŒÞ
A(	¡ˆJÆ,Æ%	%£5‚SøìSmúR^ØŠ¾Nu^뢼ÑO:óWüÚê|ÒÖ	ÆèôÞDcÔF·³ÿœQEn¸¯½6õÔ#Qç
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d4/27e0b2e138501a3d15cc376077a3631e15bd46 b/tests-clar/resources/merge-resolve/.gitted/objects/d4/27e0b2e138501a3d15cc376077a3631e15bd46
new file mode 100644
index 0000000..0b3611a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d4/27e0b2e138501a3d15cc376077a3631e15bd46 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d5/093787ef302b941b6aab081b99fb4880038bd8 b/tests-clar/resources/merge-resolve/.gitted/objects/d5/093787ef302b941b6aab081b99fb4880038bd8
new file mode 100644
index 0000000..7d73449
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d5/093787ef302b941b6aab081b99fb4880038bd8 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d5/a61b0b4992a4f0caa887fa08b52431e727bb6f b/tests-clar/resources/merge-resolve/.gitted/objects/d5/a61b0b4992a4f0caa887fa08b52431e727bb6f
new file mode 100644
index 0000000..a7921de
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d5/a61b0b4992a4f0caa887fa08b52431e727bb6f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d5/b6fc965c926a1bfc9ee456042b94088b5c5d21 b/tests-clar/resources/merge-resolve/.gitted/objects/d5/b6fc965c926a1bfc9ee456042b94088b5c5d21
new file mode 100644
index 0000000..924bdbb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d5/b6fc965c926a1bfc9ee456042b94088b5c5d21 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d5/ec1152fe25e9fec00189eb00b3db71db24c218 b/tests-clar/resources/merge-resolve/.gitted/objects/d5/ec1152fe25e9fec00189eb00b3db71db24c218
new file mode 100644
index 0000000..0d2534b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d5/ec1152fe25e9fec00189eb00b3db71db24c218 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d6/42b9770c66bba94a08df09b5efb095001f76d7 b/tests-clar/resources/merge-resolve/.gitted/objects/d6/42b9770c66bba94a08df09b5efb095001f76d7
new file mode 100644
index 0000000..1671f9f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d6/42b9770c66bba94a08df09b5efb095001f76d7 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d6/462fa3f5292857db599c54aea2bf91616230c5 b/tests-clar/resources/merge-resolve/.gitted/objects/d6/462fa3f5292857db599c54aea2bf91616230c5
new file mode 100644
index 0000000..baae3f0
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d6/462fa3f5292857db599c54aea2bf91616230c5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d6/cf6c7741b3316826af1314042550c97ded1d50 b/tests-clar/resources/merge-resolve/.gitted/objects/d6/cf6c7741b3316826af1314042550c97ded1d50
new file mode 100644
index 0000000..8f9ae1f
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/d6/cf6c7741b3316826af1314042550c97ded1d50
@@ -0,0 +1,2 @@
+x¥Q
+1Dýî)r%µ¦i@Äoàj›e»…ÚÅë[Åø7ó̤Zʽƒ¿éMSLB‘­Nl°ìm öÑBºÉ~×>×—üŠ-Ãu®åY8ê ŸtÖ¯øµ]ªåÖQaǶèÍ ã¼ëŸ3f]š>b×lÞ(„A]
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d8/74671ef5b20184836cb983bb273e5280384d0b b/tests-clar/resources/merge-resolve/.gitted/objects/d8/74671ef5b20184836cb983bb273e5280384d0b
new file mode 100644
index 0000000..1d80378
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d8/74671ef5b20184836cb983bb273e5280384d0b differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d8/fa77b6833082c1ea36b7828a582d4c43882450 b/tests-clar/resources/merge-resolve/.gitted/objects/d8/fa77b6833082c1ea36b7828a582d4c43882450
new file mode 100644
index 0000000..9881453
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/d8/fa77b6833082c1ea36b7828a582d4c43882450
@@ -0,0 +1 @@
+xíÐ1€ DQkN1¥–&6‡•%l²BkŒ·naa1Åk¦ø¤…°íëdI¢(ãU£rö'7‰‘»LŸ’AÅ,±+Wmð9ŒI'UŸÄ͹ÿñ£_ÛÜ°N
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/d9/63979c237d08b6ba39062ee7bf64c7d34a27f8 b/tests-clar/resources/merge-resolve/.gitted/objects/d9/63979c237d08b6ba39062ee7bf64c7d34a27f8
new file mode 100644
index 0000000..5fa1040
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/d9/63979c237d08b6ba39062ee7bf64c7d34a27f8 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/da/178208145ef585a1bd5ca5f4c9785d738df2cf b/tests-clar/resources/merge-resolve/.gitted/objects/da/178208145ef585a1bd5ca5f4c9785d738df2cf
new file mode 100644
index 0000000..6292118
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/da/178208145ef585a1bd5ca5f4c9785d738df2cf differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/db/6261a7c65c7fd678520c9bb6f2c47582ab9ed5 b/tests-clar/resources/merge-resolve/.gitted/objects/db/6261a7c65c7fd678520c9bb6f2c47582ab9ed5
new file mode 100644
index 0000000..b82e7fc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/db/6261a7c65c7fd678520c9bb6f2c47582ab9ed5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/dd/9a570c3400e6e07bc4d7651d6e20b08926b3d9 b/tests-clar/resources/merge-resolve/.gitted/objects/dd/9a570c3400e6e07bc4d7651d6e20b08926b3d9
new file mode 100644
index 0000000..8fd60cb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/dd/9a570c3400e6e07bc4d7651d6e20b08926b3d9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/de/872ee3618b894992e9d1e18ba2ebe256a112f9 b/tests-clar/resources/merge-resolve/.gitted/objects/de/872ee3618b894992e9d1e18ba2ebe256a112f9
new file mode 100644
index 0000000..04dda4a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/de/872ee3618b894992e9d1e18ba2ebe256a112f9
@@ -0,0 +1 @@
+xí±
À S3Å‚…ŒlK–A†ˆõƒ²BÚ4W®¸b­ Ÿù˜—T5Á¢:§8ÔS»c€œ±ÔÔ»P`KäI¥Ë†O3Z½•”þàç‡&ØÝ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/df/e3f22baa1f6fce5447901c3086bae368de6bdd b/tests-clar/resources/merge-resolve/.gitted/objects/df/e3f22baa1f6fce5447901c3086bae368de6bdd
new file mode 100644
index 0000000..e135694
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/df/e3f22baa1f6fce5447901c3086bae368de6bdd differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e0/67f9361140f19391472df8a82d6610813c73b7 b/tests-clar/resources/merge-resolve/.gitted/objects/e0/67f9361140f19391472df8a82d6610813c73b7
new file mode 100644
index 0000000..955431d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e0/67f9361140f19391472df8a82d6610813c73b7 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e1/129b3cfb5898e0fbd606e0cb80b2755e50d161 b/tests-clar/resources/merge-resolve/.gitted/objects/e1/129b3cfb5898e0fbd606e0cb80b2755e50d161
new file mode 100644
index 0000000..751f1dd
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e1/129b3cfb5898e0fbd606e0cb80b2755e50d161 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e1/7ace1492648c9dc5701bad5c47af9d1b60c4e9 b/tests-clar/resources/merge-resolve/.gitted/objects/e1/7ace1492648c9dc5701bad5c47af9d1b60c4e9
new file mode 100644
index 0000000..4a812e5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e1/7ace1492648c9dc5701bad5c47af9d1b60c4e9 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e2/c6abbd55fed5ac71a5f2751e29b4a34726a595 b/tests-clar/resources/merge-resolve/.gitted/objects/e2/c6abbd55fed5ac71a5f2751e29b4a34726a595
new file mode 100644
index 0000000..7b84ce9
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/e2/c6abbd55fed5ac71a5f2751e29b4a34726a595
@@ -0,0 +1 @@
+x+)JMU067f040031QH,-ÉÏM-JOMLÊIÕ+©(aH:,»:ÎCÉýúô:ÞË	²o>ZC'g$楧¦èfæé&%æ%g€5¬ÎqYôÂeÒZoÇÝÙkÚMíæ2­éÆÔ›X\’ZDPC~^ZNfrIf^:Xéõ›ZHÙŠž1O(_œ,'º×
jvn~JfZ&Ô5ù%·˜º³\N´º¢ÔçÞö§,5[ðe“Ù¨ú¢ÔÜü2ÇßüI{•|þ¹÷	2m»gÜ˾‹©Éñ1ÖËåüŠ5Ó¿Ü,\“µ})TC)0DÀvú‰ùzÖ›¦9–¤×Mü°úÕ…'6ób‹”
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e3/1e7ad3ed298f24e383c4950f4671993ec078e4 b/tests-clar/resources/merge-resolve/.gitted/objects/e3/1e7ad3ed298f24e383c4950f4671993ec078e4
new file mode 100644
index 0000000..a28ded3
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e3/1e7ad3ed298f24e383c4950f4671993ec078e4 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e3/76fbdd06ebf021c92724da9f26f44212734e3e b/tests-clar/resources/merge-resolve/.gitted/objects/e3/76fbdd06ebf021c92724da9f26f44212734e3e
new file mode 100644
index 0000000..8da2341
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/e3/76fbdd06ebf021c92724da9f26f44212734e3e
@@ -0,0 +1,3 @@
+xíAÂ@E]s
+`ö@ÌuHš)M=¾Scô®Üþü’zÂé:¢ÊŠ³(ãN+6Þ›D°¡Feð­­˜Y®g$+GˆÞä&F
+Ÿ½ì‹p‡þâG—4”mQÉ\±á85Æ#FìCð¥ï~QEóÀÄÀÚR—š½u)£;cáàâ6ü­öë'ÍjÄÇ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e4/9f917b448d1340b31d76e54ba388268fd4c922 b/tests-clar/resources/merge-resolve/.gitted/objects/e4/9f917b448d1340b31d76e54ba388268fd4c922
new file mode 100644
index 0000000..870c3e7
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e4/9f917b448d1340b31d76e54ba388268fd4c922 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e4/f618a2c3ed0669308735727df5ebf2447f022f b/tests-clar/resources/merge-resolve/.gitted/objects/e4/f618a2c3ed0669308735727df5ebf2447f022f
new file mode 100644
index 0000000..c7e1ee9
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/e4/f618a2c3ed0669308735727df5ebf2447f022f
@@ -0,0 +1,2 @@
+x¥ŽK!D]s
+. išObŒoà i2.b¼¾h¼»ª÷’JQ«õ6äb`7:³DN.%•±œ4¹’u¦‹ÏÄIQñYÜcçmÈàÙ`Q¨aQYa¶@>äÄÉ—Ecñ9ÖÖå%¿bÏòº¶úh›<ò¤Ÿtæ¯øµµz’J£òÁ(¹“γƒÿœFCñ_‹NŒ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e6/5a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812 b/tests-clar/resources/merge-resolve/.gitted/objects/e6/5a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812
new file mode 100644
index 0000000..72f1cbc
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e6/5a9bb2af9f4c2d1c375dd0f8f8a46cf9c68812 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e8/107f24196736b870a318a0e28f048e29f6feff b/tests-clar/resources/merge-resolve/.gitted/objects/e8/107f24196736b870a318a0e28f048e29f6feff
new file mode 100644
index 0000000..ffcf843
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/e8/107f24196736b870a318a0e28f048e29f6feff
@@ -0,0 +1,3 @@
+x¥ŽK!D]s
+. i~=LbŒoàÞ@ÓdfãõEã
ÜU½—TŠj)k—Úš]oÌÒ¯mð„èü„ž5(3ƒÓj&Ô™4Íâß»póp™iRI;‘³·¨“Â9Ò‚²Q„g_j“—ô
+-ÉëRËVïòȃ~Ò™¿â×TËI*ãÜtr g;ÿ9#R¾mkb%ÞrLNÁ
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e9/2cdb7017dc6c5aed25cb4202c5b0104b872246 b/tests-clar/resources/merge-resolve/.gitted/objects/e9/2cdb7017dc6c5aed25cb4202c5b0104b872246
new file mode 100644
index 0000000..cb1260e
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e9/2cdb7017dc6c5aed25cb4202c5b0104b872246 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e9/ad6ec3e38364a3d07feda7c4197d4d845c53b5 b/tests-clar/resources/merge-resolve/.gitted/objects/e9/ad6ec3e38364a3d07feda7c4197d4d845c53b5
new file mode 100644
index 0000000..da4a5ed
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e9/ad6ec3e38364a3d07feda7c4197d4d845c53b5 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/e9/f48beccc62d535739bfbdebe0a55ed716d8366 b/tests-clar/resources/merge-resolve/.gitted/objects/e9/f48beccc62d535739bfbdebe0a55ed716d8366
new file mode 100644
index 0000000..23c59e4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/e9/f48beccc62d535739bfbdebe0a55ed716d8366 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/eb/c09d0137cfb0c26697aed0109fb943ad906f3f b/tests-clar/resources/merge-resolve/.gitted/objects/eb/c09d0137cfb0c26697aed0109fb943ad906f3f
new file mode 100644
index 0000000..83b489d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/eb/c09d0137cfb0c26697aed0109fb943ad906f3f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ec/67e5a86adff465359f1c8f995e12dbdfa08d8a b/tests-clar/resources/merge-resolve/.gitted/objects/ec/67e5a86adff465359f1c8f995e12dbdfa08d8a
new file mode 100644
index 0000000..8490346
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ec/67e5a86adff465359f1c8f995e12dbdfa08d8a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ed/9523e62e453e50dd9be1606af19399b96e397a b/tests-clar/resources/merge-resolve/.gitted/objects/ed/9523e62e453e50dd9be1606af19399b96e397a
new file mode 100644
index 0000000..7853e23
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ed/9523e62e453e50dd9be1606af19399b96e397a differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ee/1d6f164893c1866a323f072eeed36b855656be b/tests-clar/resources/merge-resolve/.gitted/objects/ee/1d6f164893c1866a323f072eeed36b855656be
new file mode 100644
index 0000000..87d8080
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ee/1d6f164893c1866a323f072eeed36b855656be differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ee/3fa1b8c00aff7fe02065fdb50864bb0d932ccf b/tests-clar/resources/merge-resolve/.gitted/objects/ee/3fa1b8c00aff7fe02065fdb50864bb0d932ccf
new file mode 100644
index 0000000..974b72d
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ee/3fa1b8c00aff7fe02065fdb50864bb0d932ccf differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ee/a9286df54245fea72c5b557291470eb825f38f b/tests-clar/resources/merge-resolve/.gitted/objects/ee/a9286df54245fea72c5b557291470eb825f38f
new file mode 100644
index 0000000..ead0b2c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ee/a9286df54245fea72c5b557291470eb825f38f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ef/58fdd8086c243bdc81f99e379acacfd21d32d6 b/tests-clar/resources/merge-resolve/.gitted/objects/ef/58fdd8086c243bdc81f99e379acacfd21d32d6
new file mode 100644
index 0000000..55f79e0
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/ef/58fdd8086c243bdc81f99e379acacfd21d32d6
@@ -0,0 +1,2 @@
+x
ÉÁ	À0Оâï:JŠB¢ÝŸæôOV
+Þñ´yáó5éê†5jã†q!’4÷Î{¡³:ýp;¼
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ef/c499524cf105d5264ac7fc54e07e95764e8075 b/tests-clar/resources/merge-resolve/.gitted/objects/ef/c499524cf105d5264ac7fc54e07e95764e8075
new file mode 100644
index 0000000..bc9350b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ef/c499524cf105d5264ac7fc54e07e95764e8075 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ef/c9121fdedaf08ba180b53ebfbcf71bd488ed09 b/tests-clar/resources/merge-resolve/.gitted/objects/ef/c9121fdedaf08ba180b53ebfbcf71bd488ed09
new file mode 100644
index 0000000..5f9cd30
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ef/c9121fdedaf08ba180b53ebfbcf71bd488ed09 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f0/053b8060bb3f0be5cbcc3147a07ece26bf097e b/tests-clar/resources/merge-resolve/.gitted/objects/f0/053b8060bb3f0be5cbcc3147a07ece26bf097e
new file mode 100644
index 0000000..c63d37f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f0/053b8060bb3f0be5cbcc3147a07ece26bf097e differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f0/ce2b8e4986084d9b308fb72709e414c23eb5e6 b/tests-clar/resources/merge-resolve/.gitted/objects/f0/ce2b8e4986084d9b308fb72709e414c23eb5e6
new file mode 100644
index 0000000..e78c19f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f0/ce2b8e4986084d9b308fb72709e414c23eb5e6 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f2/0c9063fa0bda9a397c96947a7b687305c49753 b/tests-clar/resources/merge-resolve/.gitted/objects/f2/0c9063fa0bda9a397c96947a7b687305c49753
new file mode 100644
index 0000000..34d9aed
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f2/0c9063fa0bda9a397c96947a7b687305c49753 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f2/9e7fb590551095230c6149cbe72f2e9104a796 b/tests-clar/resources/merge-resolve/.gitted/objects/f2/9e7fb590551095230c6149cbe72f2e9104a796
new file mode 100644
index 0000000..663f6ae
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f2/9e7fb590551095230c6149cbe72f2e9104a796 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f3/293571dcd708b6a3faf03818cd2844d000e198 b/tests-clar/resources/merge-resolve/.gitted/objects/f3/293571dcd708b6a3faf03818cd2844d000e198
new file mode 100644
index 0000000..f748743
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/f3/293571dcd708b6a3faf03818cd2844d000e198
@@ -0,0 +1 @@
+x¥ŽKjÄ0³Ö)údµZ!›¹Á\@nIعƒ,3×Ͳ{¼¢XZÛë?F/\Eã12zcó’©"#êX1§]µÚ[Ô_êå˜GŒ&™œ˜c©+9³‡”ùXWKÁÓžiUé›t¸çgê›´Sø*“¾×OÛ¹Ë)u|²´oXp*"pÓ¤µšt†Žò…šÅ©`9êïÎäê§zÅKO\
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f3/f1164b68b57b1995b658a828320e6df3081fae b/tests-clar/resources/merge-resolve/.gitted/objects/f3/f1164b68b57b1995b658a828320e6df3081fae
new file mode 100644
index 0000000..5f0b4e4
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f3/f1164b68b57b1995b658a828320e6df3081fae differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f4/15caf3fcad16304cb424b67f0ee6b12dc03aae b/tests-clar/resources/merge-resolve/.gitted/objects/f4/15caf3fcad16304cb424b67f0ee6b12dc03aae
new file mode 100644
index 0000000..21ce1a0
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f4/15caf3fcad16304cb424b67f0ee6b12dc03aae differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f4/8097eb340dc5a7cae55aabcf1faf4548aa821f b/tests-clar/resources/merge-resolve/.gitted/objects/f4/8097eb340dc5a7cae55aabcf1faf4548aa821f
new file mode 100644
index 0000000..5a4a9a5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f4/8097eb340dc5a7cae55aabcf1faf4548aa821f differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f5/504f36e6f4eb797a56fc5bac6c6c7f32969bf2 b/tests-clar/resources/merge-resolve/.gitted/objects/f5/504f36e6f4eb797a56fc5bac6c6c7f32969bf2
new file mode 100644
index 0000000..2aa0c3b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f5/504f36e6f4eb797a56fc5bac6c6c7f32969bf2 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f5/b50c85a87cac64d7eb3254cdd1aec9564c0293 b/tests-clar/resources/merge-resolve/.gitted/objects/f5/b50c85a87cac64d7eb3254cdd1aec9564c0293
new file mode 100644
index 0000000..c1885cb
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f5/b50c85a87cac64d7eb3254cdd1aec9564c0293 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f5/f9dd5886a6ee20272be0aafc790cba43b31931 b/tests-clar/resources/merge-resolve/.gitted/objects/f5/f9dd5886a6ee20272be0aafc790cba43b31931
new file mode 100644
index 0000000..17ad506
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f5/f9dd5886a6ee20272be0aafc790cba43b31931 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f6/be049e284c0f9dcbbc745543885be3502ea521 b/tests-clar/resources/merge-resolve/.gitted/objects/f6/be049e284c0f9dcbbc745543885be3502ea521
new file mode 100644
index 0000000..12d3c25
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f6/be049e284c0f9dcbbc745543885be3502ea521 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f7/c332bd4d4d4b777366cae4d24d1687477576bf b/tests-clar/resources/merge-resolve/.gitted/objects/f7/c332bd4d4d4b777366cae4d24d1687477576bf
new file mode 100644
index 0000000..b36bcea
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/f7/c332bd4d4d4b777366cae4d24d1687477576bf differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/f8/958bdf4d365a84a9a178b1f5f35ff1dacbd884 b/tests-clar/resources/merge-resolve/.gitted/objects/f8/958bdf4d365a84a9a178b1f5f35ff1dacbd884
new file mode 100644
index 0000000..5dbbef2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/f8/958bdf4d365a84a9a178b1f5f35ff1dacbd884
@@ -0,0 +1,2 @@
+x¥ŽK
+1D]ç}¥ÓI¦qã
ÜK>f1’‰x}£xwU¯àQ±–²v kv½‰@`OŽ§<çHˆd}œ%kŽA›‘CÒ>²ÑÄêá›Ü;$KÈ™ybhŒóÁ2癈sLA±öÊ?ûR\ÒË·×¥–­Þá(ƒ~ÒY¾Ã¯b-'ÐÆYÇŽp‚=NˆjÐq¶ËŸ•òm[“zí O+
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fa/c03f2c5139618d87d53614c153823bf1f31396 b/tests-clar/resources/merge-resolve/.gitted/objects/fa/c03f2c5139618d87d53614c153823bf1f31396
new file mode 100644
index 0000000..30e07e5
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fa/c03f2c5139618d87d53614c153823bf1f31396 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fa/da9356aa3f74622327a3038ae9c6f92e1c5c1d b/tests-clar/resources/merge-resolve/.gitted/objects/fa/da9356aa3f74622327a3038ae9c6f92e1c5c1d
new file mode 100644
index 0000000..16ce49a
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fa/da9356aa3f74622327a3038ae9c6f92e1c5c1d differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fb/738a106cfd097a4acb96ce132ecb1ad6c46b03 b/tests-clar/resources/merge-resolve/.gitted/objects/fb/738a106cfd097a4acb96ce132ecb1ad6c46b03
new file mode 100644
index 0000000..4f1e726
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fb/738a106cfd097a4acb96ce132ecb1ad6c46b03 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fc/4c636d6515e9e261f9260dbcf3cc6eca97ea08 b/tests-clar/resources/merge-resolve/.gitted/objects/fc/4c636d6515e9e261f9260dbcf3cc6eca97ea08
new file mode 100644
index 0000000..be8a810
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fc/4c636d6515e9e261f9260dbcf3cc6eca97ea08 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fc/7d7b805f7a9428574f4f802b2e34cd20ab9d99 b/tests-clar/resources/merge-resolve/.gitted/objects/fc/7d7b805f7a9428574f4f802b2e34cd20ab9d99
new file mode 100644
index 0000000..20493e6
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fc/7d7b805f7a9428574f4f802b2e34cd20ab9d99 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fc/90237dc4891fa6c69827fc465632225e391618 b/tests-clar/resources/merge-resolve/.gitted/objects/fc/90237dc4891fa6c69827fc465632225e391618
new file mode 100644
index 0000000..961814b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fc/90237dc4891fa6c69827fc465632225e391618 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fd/57d2d6770fad8e9959124793a17f441b571e66 b/tests-clar/resources/merge-resolve/.gitted/objects/fd/57d2d6770fad8e9959124793a17f441b571e66
new file mode 100644
index 0000000..21e6b2c
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fd/57d2d6770fad8e9959124793a17f441b571e66 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fd/89f8cffb663ac89095a0f9764902e93ceaca6a b/tests-clar/resources/merge-resolve/.gitted/objects/fd/89f8cffb663ac89095a0f9764902e93ceaca6a
new file mode 100644
index 0000000..2f9d83b
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/objects/fd/89f8cffb663ac89095a0f9764902e93ceaca6a
@@ -0,0 +1,2 @@
+x¥ŽK!D]s
+. ¡{` cÜx/À§É¸`0ÆëËoà®êURy±–òèõ|èY`ÀdPÌA!±íÜäŒå4C2d=x#ž¾ñÚe`Bgr´™uôàbLÁ‡¬Ðf“fG @þÕ—Úä-½}Kò¾Ô²ÕUžyÐ=]ù;üÚ)Ör‘0 Rˆ$Ê(%²ÿ¼Ùo=׶›ˆ‡OPw
\ No newline at end of file
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/fe/5407fc50a53aecb41d1a6e9ea7b612e581af87 b/tests-clar/resources/merge-resolve/.gitted/objects/fe/5407fc50a53aecb41d1a6e9ea7b612e581af87
new file mode 100644
index 0000000..4ce7d22
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/fe/5407fc50a53aecb41d1a6e9ea7b612e581af87 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ff/49d07869831ad761bbdaea026086f8789bcb00 b/tests-clar/resources/merge-resolve/.gitted/objects/ff/49d07869831ad761bbdaea026086f8789bcb00
new file mode 100644
index 0000000..eada39b
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ff/49d07869831ad761bbdaea026086f8789bcb00 differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/objects/ff/b312248d607284c290023f9502eea010d34efd b/tests-clar/resources/merge-resolve/.gitted/objects/ff/b312248d607284c290023f9502eea010d34efd
new file mode 100644
index 0000000..7e46c4f
Binary files /dev/null and b/tests-clar/resources/merge-resolve/.gitted/objects/ff/b312248d607284c290023f9502eea010d34efd differ
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/branch
new file mode 100644
index 0000000..03f79a3
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/branch
@@ -0,0 +1 @@
+7cb63eed597130ba4abb87b3e544b85021905520
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_ancestor b/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_ancestor
new file mode 100644
index 0000000..4bc37ac
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_ancestor
@@ -0,0 +1 @@
+2da538570bc1e5b2c3e855bf702f35248ad0735f
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_side1 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_side1
new file mode 100644
index 0000000..ca6dd67
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_side1
@@ -0,0 +1 @@
+a7dbfcbfc1a60709cb80b5ca24539008456531d0
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_side2 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_side2
new file mode 100644
index 0000000..b8160f8
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/df_side2
@@ -0,0 +1 @@
+fc90237dc4891fa6c69827fc465632225e391618
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/ff_branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/ff_branch
new file mode 100644
index 0000000..e9e9051
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/ff_branch
@@ -0,0 +1 @@
+fd89f8cffb663ac89095a0f9764902e93ceaca6a
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/master b/tests-clar/resources/merge-resolve/.gitted/refs/heads/master
new file mode 100644
index 0000000..8a329ae
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/master
@@ -0,0 +1 @@
+bd593285fc7fe4ca18ccdbabf027f5d689101452
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo1 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo1
new file mode 100644
index 0000000..4d2c669
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo1
@@ -0,0 +1 @@
+16f825815cfd20a07a75c71554e82d8eede0b061
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo2 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo2
new file mode 100644
index 0000000..f503977
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo2
@@ -0,0 +1 @@
+158dc7bedb202f5b26502bf3574faa7f4238d56c
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo3 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo3
new file mode 100644
index 0000000..b92994f
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo3
@@ -0,0 +1 @@
+50ce7d7d01217679e26c55939eef119e0c93e272
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo4 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo4
new file mode 100644
index 0000000..f33d57c
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo4
@@ -0,0 +1 @@
+54269b3f6ec3d7d4ede24dd350dd5d605495c3ae
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo5 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo5
new file mode 100644
index 0000000..e9f9433
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo5
@@ -0,0 +1 @@
+e4f618a2c3ed0669308735727df5ebf2447f022f
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo6 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo6
new file mode 100644
index 0000000..4c5a98a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/octo6
@@ -0,0 +1 @@
+b6f610aef53bd343e6c96227de874c66f00ee8e8
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_ancestor b/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_ancestor
new file mode 100644
index 0000000..4092d42
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_ancestor
@@ -0,0 +1 @@
+2392a2dacc9efb562b8635d6579fb458751c7c5b
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_ours b/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_ours
new file mode 100644
index 0000000..a1c50dc
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_ours
@@ -0,0 +1 @@
+34bfafff88eaf118402b44e6f3e2dbbf1a582b05
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_theirs b/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_theirs
new file mode 100644
index 0000000..1309893
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/rename_conflict_theirs
@@ -0,0 +1 @@
+a802e06f1782a9645b9851bc7202cee74a8a4972
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/renames1 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/renames1
new file mode 100644
index 0000000..3d24810
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/renames1
@@ -0,0 +1 @@
+412b32fb66137366147f1801ecc962452757d48a
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/renames2 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/renames2
new file mode 100644
index 0000000..d226215
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/renames2
@@ -0,0 +1 @@
+ab40af3cb8a3ed2e2843e96d9aa7871336b94573
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-10 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-10
new file mode 100644
index 0000000..5b378cd
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-10
@@ -0,0 +1 @@
+0ec5f433959cd46177f745903353efb5be08d151
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-10-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-10-branch
new file mode 100644
index 0000000..b3db6c8
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-10-branch
@@ -0,0 +1 @@
+11f4f3c08b737f5fd896cbefa1425ee63b21b2fa
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-11 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-11
new file mode 100644
index 0000000..154de9a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-11
@@ -0,0 +1 @@
+3168dca1a561889b045a6441909f4c56145e666d
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-11-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-11-branch
new file mode 100644
index 0000000..2e41180
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-11-branch
@@ -0,0 +1 @@
+6718a45909532d1fcf5600d0877f7fe7e78f0b86
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-13 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-13
new file mode 100644
index 0000000..297573a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-13
@@ -0,0 +1 @@
+a3fabece9eb8748da810e1e08266fef9b7136ad4
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-13-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-13-branch
new file mode 100644
index 0000000..22e429a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-13-branch
@@ -0,0 +1 @@
+05f3c1a2a56ca95c3d2ef28dc9ddf32b5cd6c91c
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-14 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-14
new file mode 100644
index 0000000..8905185
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-14
@@ -0,0 +1 @@
+7e2d058d5fedf8329db44db4fac610d6b1a89159
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-14-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-14-branch
new file mode 100644
index 0000000..0158f95
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-14-branch
@@ -0,0 +1 @@
+8187117062b750eed4f93fd7e899f17b52ce554d
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-2alt b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-2alt
new file mode 100644
index 0000000..4740741
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-2alt
@@ -0,0 +1 @@
+566ab53c220a2eafc1212af1a024513230280ab9
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-2alt-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-2alt-branch
new file mode 100644
index 0000000..2f5f1a4
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-2alt-branch
@@ -0,0 +1 @@
+c9174cef549ec94ecbc43ef03cdc775b4950becb
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-3alt b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-3alt
new file mode 100644
index 0000000..18e50ae
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-3alt
@@ -0,0 +1 @@
+4c9fac0707f8d4195037ae5a681aa48626491541
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-3alt-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-3alt-branch
new file mode 100644
index 0000000..7bc1a8d
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-3alt-branch
@@ -0,0 +1 @@
+c607fc30883e335def28cd686b51f6cfa02b06ec
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-4 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-4
new file mode 100644
index 0000000..f49bbf9
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-4
@@ -0,0 +1 @@
+cc3e3009134cb88014129fc8858d1101359e5e2f
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-4-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-4-branch
new file mode 100644
index 0000000..bff519e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-4-branch
@@ -0,0 +1 @@
+183310e30fb1499af8c619108ffea4d300b5e778
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-1 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-1
new file mode 100644
index 0000000..963a7b3
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-1
@@ -0,0 +1 @@
+4fe93c0ec83eb6305cbace3dace88ecee1b63cb6
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-1-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-1-branch
new file mode 100644
index 0000000..4a22138
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-1-branch
@@ -0,0 +1 @@
+478172cb2f5ff9b514bc9d04d3bd5ef5840cb3b2
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-2 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-2
new file mode 100644
index 0000000..aa4ada1
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-2
@@ -0,0 +1 @@
+3b47b031b3e55ae11e14a05260b1c3ffd6838d55
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-2-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-2-branch
new file mode 100644
index 0000000..5553cdb
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-5alt-2-branch
@@ -0,0 +1 @@
+f48097eb340dc5a7cae55aabcf1faf4548aa821f
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-6 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-6
new file mode 100644
index 0000000..fb685bb
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-6
@@ -0,0 +1 @@
+99b4f7e4f24470fa06b980bc21f1095c2a9425c0
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-6-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-6-branch
new file mode 100644
index 0000000..efc4c55
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-6-branch
@@ -0,0 +1 @@
+a43150a738849c59376cf30bb2a68348a83c8f48
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-7 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-7
new file mode 100644
index 0000000..9c94243
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-7
@@ -0,0 +1 @@
+d874671ef5b20184836cb983bb273e5280384d0b
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-7-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-7-branch
new file mode 100644
index 0000000..1762bb5
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-7-branch
@@ -0,0 +1 @@
+5195a1b480f66691b667f10a9e41e70115a78351
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-8 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-8
new file mode 100644
index 0000000..837c491
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-8
@@ -0,0 +1 @@
+3575826c96a975031d2c14368529cc5c4353a8fd
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-8-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-8-branch
new file mode 100644
index 0000000..874230e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-8-branch
@@ -0,0 +1 @@
+52d8bc572af2b6d4ee0d5e62ed5d1fbad92210a9
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-9 b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-9
new file mode 100644
index 0000000..b968a3e
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-9
@@ -0,0 +1 @@
+c35dee9bcc0e989f3b0c40f68372a9a51b6c4e6a
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-9-branch b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-9-branch
new file mode 100644
index 0000000..7f3097b
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/trivial-9-branch
@@ -0,0 +1 @@
+13d1be4ea52a6ced1d7a1d832f0ee3c399348e5e
diff --git a/tests-clar/resources/merge-resolve/.gitted/refs/heads/unrelated b/tests-clar/resources/merge-resolve/.gitted/refs/heads/unrelated
new file mode 100644
index 0000000..bb877be
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/.gitted/refs/heads/unrelated
@@ -0,0 +1 @@
+55b4e4687e7a0d9ca367016ed930f385d4022e6f
diff --git a/tests-clar/resources/merge-resolve/added-in-master.txt b/tests-clar/resources/merge-resolve/added-in-master.txt
new file mode 100644
index 0000000..233c091
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/added-in-master.txt
@@ -0,0 +1 @@
+this file is added in master
diff --git a/tests-clar/resources/merge-resolve/automergeable.txt b/tests-clar/resources/merge-resolve/automergeable.txt
new file mode 100644
index 0000000..ee3fa1b
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/automergeable.txt
@@ -0,0 +1,9 @@
+this file is changed in master
+this file is automergeable
+this file is automergeable
+this file is automergeable
+this file is automergeable
+this file is automergeable
+this file is automergeable
+this file is automergeable
+this file is automergeable
diff --git a/tests-clar/resources/merge-resolve/changed-in-branch.txt b/tests-clar/resources/merge-resolve/changed-in-branch.txt
new file mode 100644
index 0000000..ab6c44a
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/changed-in-branch.txt
@@ -0,0 +1 @@
+initial revision
diff --git a/tests-clar/resources/merge-resolve/changed-in-master.txt b/tests-clar/resources/merge-resolve/changed-in-master.txt
new file mode 100644
index 0000000..11deab0
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/changed-in-master.txt
@@ -0,0 +1 @@
+changed in master
diff --git a/tests-clar/resources/merge-resolve/conflicting.txt b/tests-clar/resources/merge-resolve/conflicting.txt
new file mode 100644
index 0000000..4e886e6
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/conflicting.txt
@@ -0,0 +1 @@
+this file is changed in master and branch
diff --git a/tests-clar/resources/merge-resolve/removed-in-branch.txt b/tests-clar/resources/merge-resolve/removed-in-branch.txt
new file mode 100644
index 0000000..dfe3f22
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/removed-in-branch.txt
@@ -0,0 +1 @@
+this is removed in branch
diff --git a/tests-clar/resources/merge-resolve/unchanged.txt b/tests-clar/resources/merge-resolve/unchanged.txt
new file mode 100644
index 0000000..c8f06f2
--- /dev/null
+++ b/tests-clar/resources/merge-resolve/unchanged.txt
@@ -0,0 +1 @@
+this file is unchanged in both
diff --git a/tests-clar/resources/peeled.git/HEAD b/tests-clar/resources/peeled.git/HEAD
new file mode 100644
index 0000000..cb089cd
--- /dev/null
+++ b/tests-clar/resources/peeled.git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests-clar/resources/peeled.git/config b/tests-clar/resources/peeled.git/config
new file mode 100644
index 0000000..8830052
--- /dev/null
+++ b/tests-clar/resources/peeled.git/config
@@ -0,0 +1,8 @@
+[core]
+	repositoryformatversion = 0
+	filemode = true
+	bare = true
+[remote "origin"]
+	url = /home/peff/compile/libgit2/tests-clar/resources/peeled
+	fetch = +refs/*:refs/*
+	mirror = true
diff --git a/tests-clar/resources/peeled.git/objects/info/packs b/tests-clar/resources/peeled.git/objects/info/packs
new file mode 100644
index 0000000..0d88b32
--- /dev/null
+++ b/tests-clar/resources/peeled.git/objects/info/packs
@@ -0,0 +1,2 @@
+P pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.pack
+
diff --git a/tests-clar/resources/peeled.git/objects/pack/pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.idx b/tests-clar/resources/peeled.git/objects/pack/pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.idx
new file mode 100644
index 0000000..9b79e9b
Binary files /dev/null and b/tests-clar/resources/peeled.git/objects/pack/pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.idx differ
diff --git a/tests-clar/resources/peeled.git/objects/pack/pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.pack b/tests-clar/resources/peeled.git/objects/pack/pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.pack
new file mode 100644
index 0000000..2459ca2
Binary files /dev/null and b/tests-clar/resources/peeled.git/objects/pack/pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.pack differ
diff --git a/tests-clar/resources/peeled.git/packed-refs b/tests-clar/resources/peeled.git/packed-refs
new file mode 100644
index 0000000..ad053d5
--- /dev/null
+++ b/tests-clar/resources/peeled.git/packed-refs
@@ -0,0 +1,6 @@
+# pack-refs with: peeled fully-peeled 
+c2596aa0151888587ec5c0187f261e63412d9e11 refs/foo/tag-outside-tags
+^0df1a5865c8abfc09f1f2182e6a31be550e99f07
+0df1a5865c8abfc09f1f2182e6a31be550e99f07 refs/heads/master
+c2596aa0151888587ec5c0187f261e63412d9e11 refs/tags/tag-inside-tags
+^0df1a5865c8abfc09f1f2182e6a31be550e99f07
diff --git a/tests-clar/resources/peeled.git/refs/heads/master b/tests-clar/resources/peeled.git/refs/heads/master
new file mode 100644
index 0000000..76c15e2
--- /dev/null
+++ b/tests-clar/resources/peeled.git/refs/heads/master
@@ -0,0 +1 @@
+0df1a5865c8abfc09f1f2182e6a31be550e99f07
diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c
index 12f9226..60b3c72 100644
--- a/tests-clar/stash/drop.c
+++ b/tests-clar/stash/drop.c
@@ -146,6 +146,8 @@ void retrieve_top_stash_id(git_oid *out)
 	cl_git_pass(git_reference_name_to_id(out, repo, GIT_REFS_STASH_FILE));
 
 	cl_assert_equal_i(true, git_oid_cmp(out, git_object_id(top_stash)) == 0);
+
+	git_object_free(top_stash);
 }
 
 void test_stash_drop__dropping_the_top_stash_updates_the_stash_reference(void)
@@ -165,4 +167,6 @@ void test_stash_drop__dropping_the_top_stash_updates_the_stash_reference(void)
 	retrieve_top_stash_id(&oid);
 
 	cl_git_pass(git_oid_cmp(&oid, git_object_id(next_top_stash)));
+
+	git_object_free(next_top_stash);
 }
diff --git a/tests-clar/status/status_helpers.c b/tests-clar/status/status_helpers.c
index 24546d4..f073c24 100644
--- a/tests-clar/status/status_helpers.c
+++ b/tests-clar/status/status_helpers.c
@@ -40,7 +40,8 @@ int cb_status__single(const char *p, unsigned int s, void *payload)
 {
 	status_entry_single *data = (status_entry_single *)payload;
 
-	GIT_UNUSED(p);
+	if (data->debug)
+		fprintf(stderr, "%02d: %s (%04x)\n", data->count, p, s);
 
 	data->count++;
 	data->status = s;
diff --git a/tests-clar/status/status_helpers.h b/tests-clar/status/status_helpers.h
index 1aa0263..ae1469e 100644
--- a/tests-clar/status/status_helpers.h
+++ b/tests-clar/status/status_helpers.h
@@ -24,6 +24,7 @@ extern int cb_status__count(const char *p, unsigned int s, void *payload);
 typedef struct {
 	int count;
 	unsigned int status;
+	bool debug;
 } status_entry_single;
 
 /* cb_status__single takes payload of "status_entry_single *" */
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index a9b8a12..0138b17 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -258,9 +258,8 @@ void test_status_worktree__ignores(void)
 
 static int cb_status__check_592(const char *p, unsigned int s, void *payload)
 {
-	GIT_UNUSED(payload);
-
-	if (s != GIT_STATUS_WT_DELETED || (payload != NULL && strcmp(p, (const char *)payload) != 0))
+	if (s != GIT_STATUS_WT_DELETED ||
+		(payload != NULL && strcmp(p, (const char *)payload) != 0))
 		return -1;
 
 	return 0;
diff --git a/tests-clar/status/worktree_init.c b/tests-clar/status/worktree_init.c
index b67107a..296c27c 100644
--- a/tests-clar/status/worktree_init.c
+++ b/tests-clar/status/worktree_init.c
@@ -1,4 +1,6 @@
 #include "clar_libgit2.h"
+#include "git2/sys/repository.h"
+
 #include "fileops.h"
 #include "ignore.h"
 #include "status_helpers.h"
@@ -321,10 +323,10 @@ void test_status_worktree_init__new_staged_file_must_handle_crlf(void)
 	cl_set_cleanup(&cleanup_new_repo, "getting_started");
 	cl_git_pass(git_repository_init(&repo, "getting_started", 0));
 
-	// Ensure that repo has core.autocrlf=true
+	/* Ensure that repo has core.autocrlf=true */
 	cl_repo_set_bool(repo, "core.autocrlf", true);
 
-	cl_git_mkfile("getting_started/testfile.txt", "content\r\n");	// Content with CRLF
+	cl_git_mkfile("getting_started/testfile.txt", "content\r\n");	/* Content with CRLF */
 
 	cl_git_pass(git_repository_index(&index, repo));
 	cl_git_pass(git_index_add_bypath(index, "testfile.txt"));
diff --git a/tests-clar/submodule/status.c b/tests-clar/submodule/status.c
index 282e827..fca84af 100644
--- a/tests-clar/submodule/status.c
+++ b/tests-clar/submodule/status.c
@@ -383,3 +383,30 @@ void test_submodule_status__iterator(void)
 
 	cl_git_pass(git_status_foreach_ext(g_repo, &opts, confirm_submodule_status, &exp));
 }
+
+void test_submodule_status__untracked_dirs_containing_ignored_files(void)
+{
+	git_buf path = GIT_BUF_INIT;
+	unsigned int status, expected;
+	git_submodule *sm;
+
+	cl_git_pass(git_buf_joinpath(&path, git_repository_path(g_repo), "modules/sm_unchanged/info/exclude"));
+	cl_git_append2file(git_buf_cstr(&path), "\n*.ignored\n");
+
+	cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged/directory"));
+	cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0));
+	cl_git_pass(git_buf_joinpath(&path, git_buf_cstr(&path), "i_am.ignored"));
+	cl_git_mkfile(git_buf_cstr(&path), "ignored this file, please\n");
+
+	cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
+	cl_git_pass(git_submodule_status(&status, sm));
+
+	cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
+
+	expected = GIT_SUBMODULE_STATUS_IN_HEAD |
+		GIT_SUBMODULE_STATUS_IN_INDEX |
+		GIT_SUBMODULE_STATUS_IN_CONFIG |
+		GIT_SUBMODULE_STATUS_IN_WD;
+
+	cl_assert(status == expected);
+}