Commit b07db1eb7696c1ef71f122c2103780c7bb55ed47

Edward Thomson 2014-10-26T20:18:04

Merge pull request #2482 from libgit2/ed/rebase Rebase (merge)

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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e076dd5..93b189c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -90,3 +90,17 @@ v0.21 + 1
 
 * Introduce git_merge_bases_many() to expose all merge bases between
   multiple commits.
+
+* git_merge_head is now git_annotated_commit, to better reflect its usage
+  for multiple functions (including rebase)
+
+* Introduce rebase functionality (using the merge algorithm only).
+  Introduce git_rebase_init() to begin a new rebase session,
+  git_rebase_open() to open an in-progress rebase session,
+  git_rebase_commit() to commit the current rebase operation,
+  git_rebase_next() to apply the next rebase operation,
+  git_rebase_abort() to abort an in-progress rebase and git_rebase_finish()
+  to complete a rebase operation.
+
+* Introduce git_note_author() and git_note_committer() to get the author
+  and committer information on a git_note, respectively.
diff --git a/include/git2.h b/include/git2.h
index baa7fca..41adbba 100644
--- a/include/git2.h
+++ b/include/git2.h
@@ -8,6 +8,7 @@
 #ifndef INCLUDE_git_git_h__
 #define INCLUDE_git_git_h__
 
+#include "git2/annotated_commit.h"
 #include "git2/attr.h"
 #include "git2/blob.h"
 #include "git2/blame.h"
@@ -39,6 +40,7 @@
 #include "git2/patch.h"
 #include "git2/pathspec.h"
 #include "git2/push.h"
+#include "git2/rebase.h"
 #include "git2/refdb.h"
 #include "git2/reflog.h"
 #include "git2/refs.h"
diff --git a/include/git2/annotated_commit.h b/include/git2/annotated_commit.h
new file mode 100644
index 0000000..87e3398
--- /dev/null
+++ b/include/git2/annotated_commit.h
@@ -0,0 +1,99 @@
+/*
+ * 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_annotated_commit_h__
+#define INCLUDE_git_annotated_commit_h__
+
+#include "common.h"
+#include "repository.h"
+#include "types.h"
+
+/**
+ * @file git2/annotated_commit.h
+ * @brief Git annotated commit routines
+ * @defgroup git_annotated_commit Git annotated commit routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Creates a `git_annotated_commit` from the given reference.
+ * The resulting git_annotated_commit must be freed with
+ * `git_annotated_commit_free`.
+ *
+ * @param out pointer to store the git_annotated_commit result in
+ * @param repo repository that contains the given reference
+ * @param ref reference to use to lookup the git_annotated_commit
+ * @return 0 on success or error code
+ */
+GIT_EXTERN(int) git_annotated_commit_from_ref(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const git_reference *ref);
+
+/**
+ * Creates a `git_annotated_commit` from the given fetch head data.
+ * The resulting git_annotated_commit must be freed with
+ * `git_annotated_commit_free`.
+ *
+ * @param out pointer to store the git_annotated_commit result in
+ * @param repo repository that contains the given commit
+ * @param branch_name name of the (remote) branch
+ * @param remote_url url of the remote
+ * @param oid the commit object id of the remote branch
+ * @return 0 on success or error code
+ */
+GIT_EXTERN(int) git_annotated_commit_from_fetchhead(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const char *branch_name,
+	const char *remote_url,
+	const git_oid *id);
+
+/**
+ * Creates a `git_annotated_commit` from the given commit id.
+ * The resulting git_annotated_commit must be freed with
+ * `git_annotated_commit_free`.
+ *
+ * An annotated commit contains information about how it was
+ * looked up, which may be useful for functions like merge or
+ * rebase to provide context to the operation.  For example,
+ * conflict files will include the name of the source or target
+ * branches being merged.  It is therefore preferable to use the
+ * most specific function (eg `git_annotated_commit_from_ref`)
+ * instead of this one when that data is known.
+ *
+ * @param out pointer to store the git_annotated_commit result in
+ * @param repo repository that contains the given commit
+ * @param id the commit object id to lookup
+ * @return 0 on success or error code
+ */
+GIT_EXTERN(int) git_annotated_commit_lookup(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const git_oid *id);
+
+/**
+ * Gets the commit ID that the given `git_annotated_commit` refers to.
+ *
+ * @param head the given annotated commit
+ * @return commit id
+ */
+GIT_EXTERN(const git_oid *) git_annotated_commit_id(
+	const git_annotated_commit *commit);
+
+/**
+ * Frees a `git_annotated_commit`.
+ *
+ * @param annotated_commit annotated commit to free
+ */
+GIT_EXTERN(void) git_annotated_commit_free(
+	git_annotated_commit *commit);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 1e3ed3a..b33118e 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -43,6 +43,7 @@ typedef enum {
 	GIT_EMODIFIED       = -15,	/**< Reference value does not match expected */
 	GIT_EAUTH           = -16,      /**< Authentication error */
 	GIT_ECERTIFICATE    = -17,      /**< Server certificate is invalid */
+	GIT_EAPPLIED        = -18,	/**< Patch/merge has already been applied */
 
 	GIT_PASSTHROUGH     = -30,	/**< Internal only */
 	GIT_ITEROVER        = -31,	/**< Signals end of iteration with iterator */
@@ -90,6 +91,7 @@ typedef enum {
 	GITERR_CALLBACK,
 	GITERR_CHERRYPICK,
 	GITERR_DESCRIBE,
+	GITERR_REBASE,
 } git_error_t;
 
 /**
diff --git a/include/git2/merge.h b/include/git2/merge.h
index ed1b9a3..9082fd6 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -13,6 +13,7 @@
 #include "oidarray.h"
 #include "checkout.h"
 #include "index.h"
+#include "annotated_commit.h"
 
 /**
  * @file git2/merge.h
@@ -303,7 +304,7 @@ GIT_EXTERN(int) git_merge_analysis(
 	git_merge_analysis_t *analysis_out,
 	git_merge_preference_t *preference_out,
 	git_repository *repo,
-	const git_merge_head **their_heads,
+	const git_annotated_commit **their_heads,
 	size_t their_heads_len);
 
 /**
@@ -382,69 +383,6 @@ GIT_EXTERN(int) git_merge_base_octopus(
 	const git_oid input_array[]);
 
 /**
- * Creates a `git_merge_head` from the given reference.  The resulting
- * git_merge_head must be freed with `git_merge_head_free`.
- *
- * @param out pointer to store the git_merge_head result in
- * @param repo repository that contains the given reference
- * @param ref reference to use as a merge input
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_head_from_ref(
-	git_merge_head **out,
-	git_repository *repo,
-	const git_reference *ref);
-
-/**
- * Creates a `git_merge_head` from the given fetch head data.  The resulting
- * git_merge_head must be freed with `git_merge_head_free`.
- *
- * @param out pointer to store the git_merge_head result in
- * @param repo repository that contains the given commit
- * @param branch_name name of the (remote) branch
- * @param remote_url url of the remote
- * @param oid the commit object id to use as a merge input
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_head_from_fetchhead(
-	git_merge_head **out,
-	git_repository *repo,
-	const char *branch_name,
-	const char *remote_url,
-	const git_oid *oid);
-
-/**
- * Creates a `git_merge_head` from the given commit id.  The resulting
- * git_merge_head must be freed with `git_merge_head_free`.
- *
- * @param out pointer to store the git_merge_head result in
- * @param repo repository that contains the given commit
- * @param id the commit object id to use as a merge input
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_head_from_id(
-	git_merge_head **out,
-	git_repository *repo,
-	const git_oid *id);
-
-/**
- * Gets the commit ID that the given `git_merge_head` refers to.
- *
- * @param head the given merge head
- * @return commit id
- */
-GIT_EXTERN(const git_oid *) git_merge_head_id(
-	const git_merge_head *head);
-
-/**
- * Frees a `git_merge_head`.
- *
- * @param head merge head to free
- */
-GIT_EXTERN(void) git_merge_head_free(
-	git_merge_head *head);
-
-/**
  * Merge two files as they exist in the in-memory data structures, using
  * the given common ancestor as the baseline, producing a
  * `git_merge_file_result` that reflects the merge result.  The
@@ -557,7 +495,7 @@ GIT_EXTERN(int) git_merge_commits(
  */
 GIT_EXTERN(int) git_merge(
 	git_repository *repo,
-	const git_merge_head **their_heads,
+	const git_annotated_commit **their_heads,
 	size_t their_heads_len,
 	const git_merge_options *merge_opts,
 	const git_checkout_options *checkout_opts);
diff --git a/include/git2/notes.h b/include/git2/notes.h
index 98eb2ae..1a7794a 100644
--- a/include/git2/notes.h
+++ b/include/git2/notes.h
@@ -97,6 +97,23 @@ GIT_EXTERN(int) git_note_read(
 	const git_oid *oid);
 
 /**
+ * Get the note author
+ *
+ * @param note the note
+ * @return the author
+ */
+GIT_EXTERN(const git_signature *) git_note_author(const git_note *note);
+
+/**
+ * Get the note committer
+ *
+ * @param note the note
+ * @return the committer
+ */
+GIT_EXTERN(const git_signature *) git_note_committer(const git_note *note);
+
+
+/**
  * Get the note message
  *
  * @param note the note
diff --git a/include/git2/rebase.h b/include/git2/rebase.h
new file mode 100644
index 0000000..095975e
--- /dev/null
+++ b/include/git2/rebase.h
@@ -0,0 +1,261 @@
+/*
+ * 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_rebase_h__
+#define INCLUDE_git_rebase_h__
+
+#include "common.h"
+#include "types.h"
+#include "oid.h"
+#include "annotated_commit.h"
+
+/**
+ * @file git2/rebase.h
+ * @brief Git rebase routines
+ * @defgroup git_rebase Git merge routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+typedef struct {
+	unsigned int version;
+
+	/**
+	 * Provide a quiet rebase experience; unused by libgit2 but provided for
+	 * interoperability with other clients.
+	 */
+	int quiet;
+
+	/**
+	 * Canonical name of the notes reference used to rewrite notes for
+	 * rebased commits when finishing the rebase; if NULL, the contents of
+	 * the coniguration option `notes.rewriteRef` is examined, unless the
+	 * configuration option `notes.rewrite.rebase` is set to false.  If
+	 * `notes.rewriteRef` is NULL, notes will not be rewritten.
+	 */
+	const char *rewrite_notes_ref;
+} git_rebase_options;
+
+/** Type of rebase operation in-progress after calling `git_rebase_next`. */
+typedef enum {
+	/**
+	 * The given commit is to be cherry-picked.  The client should commit
+	 * the changes and continue if there are no conflicts.
+	 */
+	GIT_REBASE_OPERATION_PICK = 0,
+
+	/**
+	 * The given commit is to be cherry-picked, but the client should prompt
+	 * the user to provide an updated commit message.
+	 */
+	GIT_REBASE_OPERATION_REWORD,
+
+	/**
+	 * The given commit is to be cherry-picked, but the client should stop
+	 * to allow the user to edit the changes before committing them.
+	 */
+	GIT_REBASE_OPERATION_EDIT,
+
+	/**
+	 * The given commit is to be squashed into the previous commit.  The
+	 * commit message will be merged with the previous message.
+	 */
+	GIT_REBASE_OPERATION_SQUASH,
+
+	/**
+	 * The given commit is to be squashed into the previous commit.  The
+	 * commit message from this commit will be discarded.
+	 */
+	GIT_REBASE_OPERATION_FIXUP,
+
+	/**
+	 * No commit will be cherry-picked.  The client should run the given
+	 * command and (if successful) continue.
+	 */
+	GIT_REBASE_OPERATION_EXEC,
+} git_rebase_operation_t;
+
+#define GIT_REBASE_OPTIONS_VERSION 1
+#define GIT_REBASE_OPTIONS_INIT {GIT_REBASE_OPTIONS_VERSION}
+
+typedef struct {
+	/** The type of rebase operation. */
+	git_rebase_operation_t type;
+
+	/**
+	 * The commit ID being cherry-picked.  This will be populated for
+	 * all operations except those of type `GIT_REBASE_OPERATION_EXEC`.
+	 */
+	const git_oid id;
+
+	/**
+	 * The executable the user has requested be run.  This will only
+	 * be populated for operations of type `GIT_REBASE_OPERATION_EXEC`.
+	 */
+	const char *exec;
+} git_rebase_operation;
+
+/**
+ * Initializes a `git_rebase_options` with default values. Equivalent to
+ * creating an instance with GIT_REBASE_OPTIONS_INIT.
+ *
+ * @param opts the `git_rebase_options` instance to initialize.
+ * @param version the version of the struct; you should pass
+ *        `GIT_REBASE_OPTIONS_VERSION` here.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_rebase_init_options(
+	git_rebase_options *opts,
+	unsigned int version);
+
+/**
+ * Initializes a rebase operation to rebase the changes in `branch`
+ * relative to `upstream` onto another branch.  To begin the rebase
+ * process, call `git_rebase_next`.  When you have finished with this
+ * object, call `git_rebase_free`.
+ *
+ * @param out Pointer to store the rebase object
+ * @param repo The repository to perform the rebase
+ * @param branch The terminal commit to rebase
+ * @param upstream The commit to begin rebasing from, or NULL to rebase all
+ *                 reachable commits
+ * @param onto The branch to rebase onto, or NULL to rebase onto the given
+ *             upstream
+ * @param signature The signature of the rebaser (optional)
+ * @param opts Options to specify how rebase is performed
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_rebase_init(
+	git_rebase **out,
+	git_repository *repo,
+	const git_annotated_commit *branch,
+	const git_annotated_commit *upstream,
+	const git_annotated_commit *onto,
+	const git_signature *signature,
+	const git_rebase_options *opts);
+
+/**
+ * Opens an existing rebase that was previously started by either an
+ * invocation of `git_rebase_init` or by another client.
+ *
+ * @param out Pointer to store the rebase object
+ * @param reop The repository that has a rebase in-progress
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_rebase_open(git_rebase **out, git_repository *repo);
+
+/**
+ * Gets the count of rebase operations that are to be applied.
+ *
+ * @param rebase The in-progress rebase
+ * @return The number of rebase operations in total
+ */
+GIT_EXTERN(size_t) git_rebase_operation_entrycount(git_rebase *rebase);
+
+/**
+ * Gets the index of the rebase operation that is currently being applied.
+ *
+ * @param rebase The in-progress rebase
+ * @return The index of the rebase operation currently being applied.
+ */
+GIT_EXTERN(size_t) git_rebase_operation_current(git_rebase *rebase);
+
+/**
+ * Gets the rebase operation specified by the given index.
+ *
+ * @param rebase The in-progress rebase
+ * @param idx The index of the rebase operation to retrieve
+ * @return The rebase operation or NULL if `idx` was out of bounds
+ */
+GIT_EXTERN(git_rebase_operation *) git_rebase_operation_byindex(
+	git_rebase *rebase,
+	size_t idx);
+
+/**
+ * Performs the next rebase operation and returns the information about it.
+ * If the operation is one that applies a patch (which is any operation except
+ * GIT_REBASE_OPERATION_EXEC) then the patch will be applied and the index and
+ * working directory will be updated with the changes.  If there are conflicts,
+ * you will need to address those before committing the changes.
+ *
+ * @param out Pointer to store the rebase operation that is to be performed next
+ * @param repo The rebase in progress
+ * @param checkout_opts Options to specify how the patch should be checked out
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_rebase_next(
+	git_rebase_operation **operation,
+	git_rebase *rebase,
+	git_checkout_options *checkout_opts);
+
+/**
+ * Commits the current patch.  You must have resolved any conflicts that
+ * were introduced during the patch application from the `git_rebase_next`
+ * invocation.
+ *
+ * @param id Pointer in which to store the OID of the newly created commit
+ * @param repo The rebase that is in-progress
+ * @param author The author of the updated commit, or NULL to keep the
+ *        author from the original commit
+ * @param committer The committer of the rebase
+ * @param message_encoding The encoding for the message in the commit,
+ *        represented with a standard encoding name.  If message is NULL,
+ *        this should also be NULL, and the encoding from the original
+ *        commit will be maintained.  If message is specified, this may be
+ *        NULL to indicate that "UTF-8" is to be used.
+ * @param message The message for this commit, or NULL to use the message
+ *        from the original commit.
+ * @return Zero on success, GIT_EUNMERGED if there are unmerged changes in
+ *        the index, GIT_EAPPLIED if the current commit has already
+ *        been applied to the upstream and there is nothing to commit,
+ *        -1 on failure.
+ */
+GIT_EXTERN(int) git_rebase_commit(
+	git_oid *id,
+	git_rebase *rebase,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message);
+
+/**
+ * Aborts a rebase that is currently in progress, resetting the repository
+ * and working directory to their state before rebase began.
+ *
+ * @param rebase The rebase that is in-progress
+ * @param signature The identity that is aborting the rebase
+ * @return Zero on success; GIT_ENOTFOUND if a rebase is not in progress,
+ *         -1 on other errors.
+ */
+GIT_EXTERN(int) git_rebase_abort(
+	git_rebase *rebase,
+	const git_signature *signature);
+
+/**
+ * Finishes a rebase that is currently in progress once all patches have
+ * been applied.
+ *
+ * @param rebase The rebase that is in-progress
+ * @param signature The identity that is finishing the rebase (optional)
+ * @param opts Options to specify how rebase is finished
+ * @param Zero on success; -1 on error
+ */
+GIT_EXTERN(int) git_rebase_finish(
+	git_rebase *rebase,
+	const git_signature *signature,
+	const git_rebase_options *opts);
+
+/**
+ * Frees the `git_rebase` object.
+ *
+ * @param rebase The rebase object
+ */
+GIT_EXTERN(void) git_rebase_free(git_rebase *rebase);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/reset.h b/include/git2/reset.h
index 5f2ba57..53f3e89 100644
--- a/include/git2/reset.h
+++ b/include/git2/reset.h
@@ -70,7 +70,7 @@ GIT_EXTERN(int) git_reset(
 	git_object *target,
 	git_reset_t reset_type,
 	git_checkout_options *checkout_opts,
-	git_signature *signature,
+	const git_signature *signature,
 	const char *log_message);
 
 /**
diff --git a/include/git2/types.h b/include/git2/types.h
index 1693397..aa7a56f 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -174,8 +174,8 @@ typedef struct git_reference_iterator  git_reference_iterator;
 /** Transactional interface to references */
 typedef struct git_transaction git_transaction;
 
-/** Merge heads, the input to merge */
-typedef struct git_merge_head git_merge_head;
+/** Annotated commits, the input to merge and rebase. */
+typedef struct git_annotated_commit git_annotated_commit;
 
 /** Merge result */
 typedef struct git_merge_result git_merge_result;
@@ -183,6 +183,8 @@ typedef struct git_merge_result git_merge_result;
 /** Representation of a status collection */
 typedef struct git_status_list git_status_list;
 
+/** Representation of a rebase */
+typedef struct git_rebase git_rebase;
 
 /** Basic type of any Git reference. */
 typedef enum {
diff --git a/src/annotated_commit.c b/src/annotated_commit.c
new file mode 100644
index 0000000..0a91780
--- /dev/null
+++ b/src/annotated_commit.c
@@ -0,0 +1,121 @@
+/*
+ * 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 "annotated_commit.h"
+
+#include "git2/commit.h"
+#include "git2/refs.h"
+#include "git2/repository.h"
+#include "git2/annotated_commit.h"
+
+static int annotated_commit_init(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const git_oid *id,
+	const char *ref_name,
+	const char *remote_url)
+{
+	git_annotated_commit *annotated_commit;
+	int error = 0;
+
+	assert(out && id);
+
+	*out = NULL;
+
+	annotated_commit = git__calloc(1, sizeof(git_annotated_commit));
+	GITERR_CHECK_ALLOC(annotated_commit);
+
+	if (ref_name) {
+		annotated_commit->ref_name = git__strdup(ref_name);
+		GITERR_CHECK_ALLOC(annotated_commit->ref_name);
+	}
+
+	if (remote_url) {
+		annotated_commit->remote_url = git__strdup(remote_url);
+		GITERR_CHECK_ALLOC(annotated_commit->remote_url);
+	}
+
+	git_oid_fmt(annotated_commit->id_str, id);
+	annotated_commit->id_str[GIT_OID_HEXSZ] = '\0';
+
+	if ((error = git_commit_lookup(&annotated_commit->commit, repo, id)) < 0) {
+		git_annotated_commit_free(annotated_commit);
+		return error;
+	}
+
+	*out = annotated_commit;
+	return error;
+}
+
+int git_annotated_commit_from_ref(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const git_reference *ref)
+{
+	git_reference *resolved;
+	int error = 0;
+
+	assert(out && repo && ref);
+
+	*out = NULL;
+
+	if ((error = git_reference_resolve(&resolved, ref)) < 0)
+		return error;
+	
+	error = annotated_commit_init(out, repo, git_reference_target(resolved),
+		git_reference_name(ref), NULL);
+
+	git_reference_free(resolved);
+	return error;
+}
+
+int git_annotated_commit_lookup(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const git_oid *id)
+{
+	assert(out && repo && id);
+
+	return annotated_commit_init(out, repo, id, NULL, NULL);
+}
+
+int git_annotated_commit_from_fetchhead(
+	git_annotated_commit **out,
+	git_repository *repo,
+	const char *branch_name,
+	const char *remote_url,
+	const git_oid *id)
+{
+	assert(repo && id && branch_name && remote_url);
+
+	return annotated_commit_init(out, repo, id, branch_name, remote_url);
+}
+
+const git_oid *git_annotated_commit_id(
+	const git_annotated_commit *annotated_commit)
+{
+	assert(annotated_commit);
+	return git_commit_id(annotated_commit->commit);
+}
+
+void git_annotated_commit_free(git_annotated_commit *annotated_commit)
+{
+	if (annotated_commit == NULL)
+		return;
+
+	if (annotated_commit->commit != NULL)
+		git_commit_free(annotated_commit->commit);
+
+	if (annotated_commit->ref_name != NULL)
+		git__free(annotated_commit->ref_name);
+
+	if (annotated_commit->remote_url != NULL)
+		git__free(annotated_commit->remote_url);
+
+	git__free(annotated_commit);
+}
diff --git a/src/annotated_commit.h b/src/annotated_commit.h
new file mode 100644
index 0000000..e873184
--- /dev/null
+++ b/src/annotated_commit.h
@@ -0,0 +1,22 @@
+/*
+ * 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_annotated_commit_h__
+#define INCLUDE_annotated_commit_h__
+
+#include "git2/oid.h"
+
+/** Internal structure for merge inputs */
+struct git_annotated_commit {
+	git_commit *commit;
+
+	char *ref_name;
+	char *remote_url;
+
+	char id_str[GIT_OID_HEXSZ+1];
+};
+
+#endif
diff --git a/src/commit.c b/src/commit.c
index 227d5c4..78c4b9d 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -16,6 +16,7 @@
 #include "commit.h"
 #include "signature.h"
 #include "message.h"
+#include "refs.h"
 
 void git_commit__free(void *_commit)
 {
@@ -34,35 +35,6 @@ void git_commit__free(void *_commit)
 	git__free(commit);
 }
 
-static int update_ref_for_commit(git_repository *repo, git_reference *ref, const char *update_ref, const git_oid *id, const git_signature *committer)
-{
-	git_reference *ref2 = NULL;
-	int error;
-	git_commit *c;
-	const char *shortmsg;
-	git_buf reflog_msg = GIT_BUF_INIT;
-
-	if ((error = git_commit_lookup(&c, repo, id)) < 0) {
-		return error;
-	}
-
-	shortmsg = git_commit_summary(c);
-	git_buf_printf(&reflog_msg, "commit%s: %s",
-		       git_commit_parentcount(c) == 0 ? " (initial)" : "",
-		       shortmsg);
-	git_commit_free(c);
-
-	if (ref) {
-		error = git_reference_set_target(&ref2, ref, id, committer, git_buf_cstr(&reflog_msg));
-		git_reference_free(ref2);
-	} else {
-		error = git_reference__update_terminal(repo, update_ref, id, committer, git_buf_cstr(&reflog_msg));
-	}
-
-	git_buf_free(&reflog_msg);
-	return error;
-}
-
 int git_commit_create_from_callback(
 	git_oid *id,
 	git_repository *repo,
@@ -131,7 +103,8 @@ int git_commit_create_from_callback(
 	git_buf_free(&commit);
 
 	if (update_ref != NULL) {
-		error = update_ref_for_commit(repo, ref, update_ref, id, committer);
+		error = git_reference__update_for_commit(
+			repo, ref, update_ref, id, committer, "commit");
 		git_reference_free(ref);
 		return error;
 	}
@@ -321,7 +294,8 @@ int git_commit_amend(
 		&tree_id, commit_parent_for_amend, (void *)commit_to_amend);
 
 	if (!error && update_ref) {
-		error = update_ref_for_commit(repo, ref, NULL, id, committer);
+		error = git_reference__update_for_commit(
+			repo, ref, NULL, id, committer, "commit");
 		git_reference_free(ref);
 	}
 
diff --git a/src/merge.c b/src/merge.c
index 8252f67..1c55e79 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -27,6 +27,7 @@
 #include "filebuf.h"
 #include "config.h"
 #include "oidarray.h"
+#include "annotated_commit.h"
 
 #include "git2/types.h"
 #include "git2/repository.h"
@@ -40,6 +41,7 @@
 #include "git2/config.h"
 #include "git2/tree.h"
 #include "git2/oidarray.h"
+#include "git2/annotated_commit.h"
 #include "git2/sys/index.h"
 #include "git2/sys/hashsig.h"
 
@@ -1835,32 +1837,9 @@ done:
 
 /* Merge setup / cleanup */
 
-static int write_orig_head(
-	git_repository *repo,
-	const git_merge_head *our_head)
-{
-	git_filebuf file = GIT_FILEBUF_INIT;
-	git_buf file_path = GIT_BUF_INIT;
-	int error = 0;
-
-	assert(repo && our_head);
-
-	if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 &&
-		(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 &&
-		(error = git_filebuf_printf(&file, "%s\n", our_head->oid_str)) == 0)
-		error = git_filebuf_commit(&file);
-
-	if (error < 0)
-		git_filebuf_cleanup(&file);
-
-	git_buf_free(&file_path);
-
-	return error;
-}
-
 static int write_merge_head(
 	git_repository *repo,
-	const git_merge_head *heads[],
+	const git_annotated_commit *heads[],
 	size_t heads_len)
 {
 	git_filebuf file = GIT_FILEBUF_INIT;
@@ -1875,7 +1854,7 @@ static int write_merge_head(
 		goto cleanup;
 
 	for (i = 0; i < heads_len; i++) {
-		if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->oid_str)) < 0)
+		if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->id_str)) < 0)
 			goto cleanup;
 	}
 
@@ -1917,7 +1896,7 @@ cleanup:
 }
 
 struct merge_msg_entry {
-	const git_merge_head *merge_head;
+	const git_annotated_commit *merge_head;
 	bool written;
 };
 
@@ -2105,7 +2084,7 @@ static int merge_msg_write_remotes(
 
 static int write_merge_msg(
 	git_repository *repo,
-	const git_merge_head *heads[],
+	const git_annotated_commit *heads[],
 	size_t heads_len)
 {
 	git_filebuf file = GIT_FILEBUF_INIT;
@@ -2151,7 +2130,7 @@ static int write_merge_msg(
 
 		if ((error = git_filebuf_printf(&file,
 			"%scommit '%s'", (i > 0) ? "; " : "",
-			entries[i].merge_head->oid_str)) < 0)
+			entries[i].merge_head->id_str)) < 0)
 			goto cleanup;
 
 		entries[i].written = 1;
@@ -2199,7 +2178,7 @@ static int write_merge_msg(
 			continue;
 
 		if ((error = git_filebuf_printf(&file, "; commit '%s'",
-			entries[i].merge_head->oid_str)) < 0)
+			entries[i].merge_head->id_str)) < 0)
 			goto cleanup;
 	}
 
@@ -2221,15 +2200,15 @@ cleanup:
 
 int git_merge__setup(
 	git_repository *repo,
-	const git_merge_head *our_head,
-	const git_merge_head *heads[],
+	const git_annotated_commit *our_head,
+	const git_annotated_commit *heads[],
 	size_t heads_len)
 {
 	int error = 0;
 
 	assert (repo && our_head && heads);
 
-	if ((error = write_orig_head(repo, our_head)) == 0 &&
+	if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 &&
 		(error = write_merge_head(repo, heads, heads_len)) == 0 &&
 		(error = write_merge_mode(repo)) == 0) {
 		error = write_merge_msg(repo, heads, heads_len);
@@ -2241,10 +2220,10 @@ int git_merge__setup(
 /* Merge branches */
 
 static int merge_ancestor_head(
-	git_merge_head **ancestor_head,
+	git_annotated_commit **ancestor_head,
 	git_repository *repo,
-	const git_merge_head *our_head,
-	const git_merge_head **their_heads,
+	const git_annotated_commit *our_head,
+	const git_annotated_commit **their_heads,
 	size_t their_heads_len)
 {
 	git_oid *oids, ancestor_oid;
@@ -2259,12 +2238,12 @@ static int merge_ancestor_head(
 	git_oid_cpy(&oids[0], git_commit_id(our_head->commit));
 
 	for (i = 0; i < their_heads_len; i++)
-		git_oid_cpy(&oids[i + 1], &their_heads[i]->oid);
+		git_oid_cpy(&oids[i + 1], git_annotated_commit_id(their_heads[i]));
 
 	if ((error = git_merge_base_many(&ancestor_oid, repo, their_heads_len + 1, oids)) < 0)
 		goto on_error;
 
-	error = git_merge_head_from_id(ancestor_head, repo, &ancestor_oid);
+	error = git_annotated_commit_lookup(ancestor_head, repo, &ancestor_oid);
 
 on_error:
 	git__free(oids);
@@ -2288,10 +2267,10 @@ static int merge_normalize_checkout_opts(
 	git_repository *repo,
 	git_checkout_options *checkout_opts,
 	const git_checkout_options *given_checkout_opts,
-	const git_merge_head *ancestor_head,
-	const git_merge_head *our_head,
+	const git_annotated_commit *ancestor_head,
+	const git_annotated_commit *our_head,
 	size_t their_heads_len,
-	const git_merge_head **their_heads)
+	const git_annotated_commit **their_heads)
 {
 	int error = 0;
 
@@ -2325,7 +2304,7 @@ static int merge_normalize_checkout_opts(
 		if (their_heads_len == 1 && their_heads[0]->ref_name)
 			checkout_opts->their_label = merge_their_label(their_heads[0]->ref_name);
 		else if (their_heads_len == 1)
-			checkout_opts->their_label = their_heads[0]->oid_str;
+			checkout_opts->their_label = their_heads[0]->id_str;
 		else
 			checkout_opts->their_label = "theirs";
 	}
@@ -2539,13 +2518,13 @@ static int merge_state_cleanup(git_repository *repo)
 }
 
 static int merge_heads(
-	git_merge_head **ancestor_head_out,
-	git_merge_head **our_head_out,
+	git_annotated_commit **ancestor_head_out,
+	git_annotated_commit **our_head_out,
 	git_repository *repo,
-	const git_merge_head **their_heads,
+	const git_annotated_commit **their_heads,
 	size_t their_heads_len)
 {
-	git_merge_head *ancestor_head = NULL, *our_head = NULL;
+	git_annotated_commit *ancestor_head = NULL, *our_head = NULL;
 	git_reference *our_ref = NULL;
 	int error = 0;
 
@@ -2556,7 +2535,7 @@ static int merge_heads(
 		goto done;
 
 	if ((error = git_reference_lookup(&our_ref, repo, GIT_HEAD_FILE)) < 0 ||
-		(error = git_merge_head_from_ref(&our_head, repo, our_ref)) < 0)
+		(error = git_annotated_commit_from_ref(&our_head, repo, our_ref)) < 0)
 		goto done;
 
 	if ((error = merge_ancestor_head(&ancestor_head, repo, our_head, their_heads, their_heads_len)) < 0) {
@@ -2572,8 +2551,8 @@ static int merge_heads(
 
 done:
 	if (error < 0) {
-		git_merge_head_free(ancestor_head);
-		git_merge_head_free(our_head);
+		git_annotated_commit_free(ancestor_head);
+		git_annotated_commit_free(our_head);
 	}
 
 	git_reference_free(our_ref);
@@ -2618,10 +2597,10 @@ int git_merge_analysis(
 	git_merge_analysis_t *analysis_out,
 	git_merge_preference_t *preference_out,
 	git_repository *repo,
-	const git_merge_head **their_heads,
+	const git_annotated_commit **their_heads,
 	size_t their_heads_len)
 {
-	git_merge_head *ancestor_head = NULL, *our_head = NULL;
+	git_annotated_commit *ancestor_head = NULL, *our_head = NULL;
 	int error = 0;
 
 	assert(analysis_out && preference_out && repo && their_heads);
@@ -2646,11 +2625,13 @@ int git_merge_analysis(
 		goto done;
 
 	/* We're up-to-date if we're trying to merge our own common ancestor. */
-	if (ancestor_head && git_oid_equal(&ancestor_head->oid, &their_heads[0]->oid))
+	if (ancestor_head && git_oid_equal(
+		git_annotated_commit_id(ancestor_head), git_annotated_commit_id(their_heads[0])))
 		*analysis_out |= GIT_MERGE_ANALYSIS_UP_TO_DATE;
 
 	/* We're fastforwardable if we're our own common ancestor. */
-	else if (ancestor_head && git_oid_equal(&ancestor_head->oid, &our_head->oid))
+	else if (ancestor_head && git_oid_equal(
+		git_annotated_commit_id(ancestor_head), git_annotated_commit_id(our_head)))
 		*analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL;
 
 	/* Otherwise, just a normal merge is possible. */
@@ -2658,21 +2639,21 @@ int git_merge_analysis(
 		*analysis_out |= GIT_MERGE_ANALYSIS_NORMAL;
 
 done:
-	git_merge_head_free(ancestor_head);
-	git_merge_head_free(our_head);
+	git_annotated_commit_free(ancestor_head);
+	git_annotated_commit_free(our_head);
 	return error;
 }
 
 int git_merge(
 	git_repository *repo,
-	const git_merge_head **their_heads,
+	const git_annotated_commit **their_heads,
 	size_t their_heads_len,
 	const git_merge_options *merge_opts,
 	const git_checkout_options *given_checkout_opts)
 {
 	git_reference *our_ref = NULL;
 	git_checkout_options checkout_opts;
-	git_merge_head *ancestor_head = NULL, *our_head = NULL;
+	git_annotated_commit *ancestor_head = NULL, *our_head = NULL;
 	git_tree *ancestor_tree = NULL, *our_tree = NULL, **their_trees = NULL;
 	git_index *index_new = NULL;
 	size_t i;
@@ -2735,126 +2716,14 @@ done:
 
 	git__free(their_trees);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(ancestor_head);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(ancestor_head);
 
 	git_reference_free(our_ref);
 
 	return error;
 }
 
-/* Merge heads are the input to merge */
-
-static int merge_head_init(
-	git_merge_head **out,
-	git_repository *repo,
-	const char *ref_name,
-	const char *remote_url,
-	const git_oid *oid)
-{
-	git_merge_head *head;
-	int error = 0;
-
-	assert(out && oid);
-
-	*out = NULL;
-
-	head = git__calloc(1, sizeof(git_merge_head));
-	GITERR_CHECK_ALLOC(head);
-
-	if (ref_name) {
-		head->ref_name = git__strdup(ref_name);
-		GITERR_CHECK_ALLOC(head->ref_name);
-	}
-
-	if (remote_url) {
-		head->remote_url = git__strdup(remote_url);
-		GITERR_CHECK_ALLOC(head->remote_url);
-	}
-
-	git_oid_cpy(&head->oid, oid);
-
-	git_oid_fmt(head->oid_str, oid);
-	head->oid_str[GIT_OID_HEXSZ] = '\0';
-
-	if ((error = git_commit_lookup(&head->commit, repo, &head->oid)) < 0) {
-		git_merge_head_free(head);
-		return error;
-	}
-
-	*out = head;
-	return error;
-}
-
-int git_merge_head_from_ref(
-	git_merge_head **out,
-	git_repository *repo,
-	const git_reference *ref)
-{
-	git_reference *resolved;
-	int error = 0;
-
-	assert(out && repo && ref);
-
-	*out = NULL;
-
-	if ((error = git_reference_resolve(&resolved, ref)) < 0)
-		return error;
-	
-	error = merge_head_init(out, repo, git_reference_name(ref), NULL,
-		git_reference_target(resolved));
-
-	git_reference_free(resolved);
-	return error;
-}
-
-int git_merge_head_from_id(
-	git_merge_head **out,
-	git_repository *repo,
-	const git_oid *oid)
-{
-	assert(out && repo && oid);
-
-	return merge_head_init(out, repo, NULL, NULL, oid);
-}
-
-int git_merge_head_from_fetchhead(
-	git_merge_head **out,
-	git_repository *repo,
-	const char *branch_name,
-	const char *remote_url,
-	const git_oid *oid)
-{
-	assert(repo && branch_name && remote_url && oid);
-
-	return merge_head_init(out, repo, branch_name, remote_url, oid);
-}
-
-const git_oid *git_merge_head_id(
-	const git_merge_head *head)
-{
-	assert(head);
-
-	return &head->oid;
-}
-
-void git_merge_head_free(git_merge_head *head)
-{
-	if (head == NULL)
-		return;
-
-	if (head->commit != NULL)
-		git_object_free((git_object *)head->commit);
-
-	if (head->ref_name != NULL)
-		git__free(head->ref_name);
-
-	if (head->remote_url != NULL)
-		git__free(head->remote_url);
-
-	git__free(head);
-}
-
 int git_merge_init_options(git_merge_options *opts, unsigned int version)
 {
 	GIT_INIT_STRUCTURE_FROM_TEMPLATE(
diff --git a/src/merge.h b/src/merge.h
index cc17389..2684c15 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -110,16 +110,6 @@ typedef struct {
 	int binary:1;
 } git_merge_diff;
 
-/** Internal structure for merge inputs */
-struct git_merge_head {
-	char *ref_name;
-	char *remote_url;
-
-	git_oid oid;
-	char oid_str[GIT_OID_HEXSZ+1];
-	git_commit *commit;
-};
-
 int git_merge__bases_many(
 	git_commit_list **out,
 	git_revwalk *walk,
@@ -145,8 +135,8 @@ void git_merge_diff_list__free(git_merge_diff_list *diff_list);
 
 int git_merge__setup(
 	git_repository *repo,
-	const git_merge_head *our_head,
-	const git_merge_head *heads[],
+	const git_annotated_commit *our_head,
+	const git_annotated_commit *heads[],
 	size_t heads_len);
 
 int git_merge__check_result(git_repository *repo, git_index *index_new);
diff --git a/src/notes.c b/src/notes.c
index ffe5d34..046a916 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -306,7 +306,11 @@ cleanup:
 	return error;
 }
 
-static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
+static int note_new(
+	git_note **out,
+	git_oid *note_oid,
+	git_commit *commit,
+	git_blob *blob)
 {
 	git_note *note = NULL;
 
@@ -314,6 +318,11 @@ static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
 	GITERR_CHECK_ALLOC(note);
 
 	git_oid_cpy(&note->id, note_oid);
+
+	if (git_signature_dup(&note->author, git_commit_author(commit)) < 0 ||
+		git_signature_dup(&note->committer, git_commit_committer(commit)) < 0)
+		return -1;
+
 	note->message = git__strdup((char *)git_blob_rawcontent(blob));
 	GITERR_CHECK_ALLOC(note->message);
 
@@ -323,7 +332,11 @@ static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
 }
 
 static int note_lookup(
-	git_note **out, git_repository *repo, git_tree *tree, const char *target)
+	git_note **out,
+	git_repository *repo,
+	git_commit *commit,
+	git_tree *tree,
+	const char *target)
 {
 	int error, fanout = 0;
 	git_oid oid;
@@ -340,7 +353,7 @@ static int note_lookup(
 	if ((error = git_blob_lookup(&blob, repo, &oid)) < 0)
 		goto cleanup;
 
-	if ((error = note_new(&note, &oid, blob)) < 0)
+	if ((error = note_new(&note, &oid, commit, blob)) < 0)
 		goto cleanup;
 
 	*out = note;
@@ -432,7 +445,7 @@ int git_note_read(git_note **out, git_repository *repo,
 
 	if (!(error = retrieve_note_tree_and_commit(
 			&tree, &commit, repo, &notes_ref)))
-		error = note_lookup(out, repo, tree, target);
+		error = note_lookup(out, repo, commit, tree, target);
 
 	git__free(target);
 	git_tree_free(tree);
@@ -502,6 +515,18 @@ int git_note_default_ref(const char **out, git_repository *repo)
 	return note_get_default_ref(out, repo);
 }
 
+const git_signature *git_note_committer(const git_note *note)
+{
+	assert(note);
+	return note->committer;
+}
+
+const git_signature *git_note_author(const git_note *note)
+{
+	assert(note);
+	return note->author;
+}
+
 const char * git_note_message(const git_note *note)
 {
 	assert(note);
@@ -519,6 +544,8 @@ void git_note_free(git_note *note)
 	if (note == NULL)
 		return;
 
+	git_signature_free(note->committer);
+	git_signature_free(note->author);
 	git__free(note->message);
 	git__free(note);
 }
diff --git a/src/notes.h b/src/notes.h
index e9cfa00..cfc0ca2 100644
--- a/src/notes.h
+++ b/src/notes.h
@@ -23,6 +23,9 @@
 struct git_note {
 	git_oid id;
 
+	git_signature *author;
+	git_signature *committer;
+
 	char *message;
 };
 
diff --git a/src/rebase.c b/src/rebase.c
new file mode 100644
index 0000000..6453ecc
--- /dev/null
+++ b/src/rebase.c
@@ -0,0 +1,1125 @@
+/*
+ * 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 "buffer.h"
+#include "repository.h"
+#include "posix.h"
+#include "filebuf.h"
+#include "merge.h"
+#include "array.h"
+#include "config.h"
+#include "annotated_commit.h"
+
+#include <git2/types.h>
+#include <git2/annotated_commit.h>
+#include <git2/rebase.h>
+#include <git2/commit.h>
+#include <git2/reset.h>
+#include <git2/revwalk.h>
+#include <git2/notes.h>
+
+#define REBASE_APPLY_DIR    "rebase-apply"
+#define REBASE_MERGE_DIR    "rebase-merge"
+
+#define HEAD_NAME_FILE      "head-name"
+#define ORIG_HEAD_FILE      "orig-head"
+#define HEAD_FILE           "head"
+#define ONTO_FILE           "onto"
+#define ONTO_NAME_FILE      "onto_name"
+#define QUIET_FILE          "quiet"
+
+#define MSGNUM_FILE         "msgnum"
+#define END_FILE            "end"
+#define CMT_FILE_FMT        "cmt.%" PRIuZ
+#define CURRENT_FILE        "current"
+#define REWRITTEN_FILE      "rewritten"
+
+#define ORIG_DETACHED_HEAD  "detached HEAD"
+
+#define NOTES_DEFAULT_REF   NULL
+
+#define REBASE_DIR_MODE     0777
+#define REBASE_FILE_MODE    0666
+
+typedef enum {
+	GIT_REBASE_TYPE_NONE = 0,
+	GIT_REBASE_TYPE_APPLY = 1,
+	GIT_REBASE_TYPE_MERGE = 2,
+	GIT_REBASE_TYPE_INTERACTIVE = 3,
+} git_rebase_type_t;
+
+struct git_rebase {
+	git_repository *repo;
+
+	git_rebase_type_t type;
+	char *state_path;
+
+	int head_detached : 1,
+		quiet : 1,
+		started : 1;
+
+	char *orig_head_name;
+	git_oid orig_head_id;
+
+	git_oid onto_id;
+	char *onto_name;
+
+	git_array_t(git_rebase_operation) operations;
+	size_t current;
+};
+
+#define GIT_REBASE_STATE_INIT {0}
+
+static int rebase_state_type(
+	git_rebase_type_t *type_out,
+	char **path_out,
+	git_repository *repo)
+{
+	git_buf path = GIT_BUF_INIT;
+	git_rebase_type_t type = GIT_REBASE_TYPE_NONE;
+
+	if (git_buf_joinpath(&path, repo->path_repository, REBASE_APPLY_DIR) < 0)
+		return -1;
+
+	if (git_path_isdir(git_buf_cstr(&path))) {
+		type = GIT_REBASE_TYPE_APPLY;
+		goto done;
+	}
+
+	git_buf_clear(&path);
+	if (git_buf_joinpath(&path, repo->path_repository, REBASE_MERGE_DIR) < 0)
+		return -1;
+
+	if (git_path_isdir(git_buf_cstr(&path))) {
+		type = GIT_REBASE_TYPE_MERGE;
+		goto done;
+	}
+
+done:
+	*type_out = type;
+
+	if (type != GIT_REBASE_TYPE_NONE && path_out)
+		*path_out = git_buf_detach(&path);
+
+	git_buf_free(&path);
+
+	return 0;
+}
+
+GIT_INLINE(int) rebase_readfile(
+	git_buf *out,
+	git_buf *state_path,
+	const char *filename)
+{
+	size_t state_path_len = state_path->size;
+	int error;
+
+	git_buf_clear(out);
+
+	if ((error = git_buf_joinpath(state_path, state_path->ptr, filename)) < 0 ||
+		(error = git_futils_readbuffer(out, state_path->ptr)) < 0)
+		goto done;
+
+	git_buf_rtrim(out);
+
+done:
+	git_buf_truncate(state_path, state_path_len);
+	return error;
+}
+
+GIT_INLINE(int) rebase_readint(
+	size_t *out, git_buf *asc_out, git_buf *state_path, const char *filename)
+{
+	int32_t num;
+	const char *eol;
+	int error = 0;
+
+	if ((error = rebase_readfile(asc_out, state_path, filename)) < 0)
+		return error;
+
+	if (git__strtol32(&num, asc_out->ptr, &eol, 10) < 0 || num < 0 || *eol) {
+		giterr_set(GITERR_REBASE, "The file '%s' contains an invalid numeric value", filename);
+		return -1;
+	}
+
+	*out = (size_t) num;
+
+	return 0;
+}
+
+GIT_INLINE(int) rebase_readoid(
+	git_oid *out, git_buf *str_out, git_buf *state_path, const char *filename)
+{
+	int error;
+
+	if ((error = rebase_readfile(str_out, state_path, filename)) < 0)
+		return error;
+
+	if (str_out->size != GIT_OID_HEXSZ || git_oid_fromstr(out, str_out->ptr) < 0) {
+		giterr_set(GITERR_REBASE, "The file '%s' contains an invalid object ID", filename);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int rebase_open_merge(git_rebase *rebase)
+{
+	git_buf state_path = GIT_BUF_INIT, buf = GIT_BUF_INIT, cmt = GIT_BUF_INIT;
+	git_oid current_id = {{0}};
+	git_rebase_operation *operation;
+	size_t i, msgnum = 0, end;
+	int error;
+
+	if ((error = git_buf_puts(&state_path, rebase->state_path)) < 0)
+		goto done;
+
+	/* Read 'msgnum' if it exists (otherwise, let msgnum = 0) */
+	if ((error = rebase_readint(&msgnum, &buf, &state_path, MSGNUM_FILE)) < 0 &&
+		error != GIT_ENOTFOUND)
+		goto done;
+
+	if (msgnum) {
+		rebase->started = 1;
+		rebase->current = msgnum - 1;
+	}
+
+	/* Read 'end' */
+	if ((error = rebase_readint(&end, &buf, &state_path, END_FILE)) < 0)
+		goto done;
+
+	/* Read 'current' if it exists */
+	if ((error = rebase_readoid(&current_id, &buf, &state_path, CURRENT_FILE)) < 0 &&
+		error != GIT_ENOTFOUND)
+		goto done;
+
+	/* Read cmt.* */
+	git_array_init_to_size(rebase->operations, end);
+	GITERR_CHECK_ARRAY(rebase->operations);
+
+	for (i = 0; i < end; i++) {
+		operation = git_array_alloc(rebase->operations);
+		GITERR_CHECK_ALLOC(operation);
+
+		git_buf_clear(&cmt);
+
+		if ((error = git_buf_printf(&cmt, "cmt.%" PRIuZ, (i+1))) < 0 ||
+			(error = rebase_readoid((git_oid *)&operation->id, &buf, &state_path, cmt.ptr)) < 0)
+			goto done;
+	}
+
+	/* Read 'onto_name' */
+	if ((error = rebase_readfile(&buf, &state_path, ONTO_NAME_FILE)) < 0)
+		goto done;
+
+	rebase->onto_name = git_buf_detach(&buf);
+
+done:
+	git_buf_free(&cmt);
+	git_buf_free(&state_path);
+	git_buf_free(&buf);
+
+	return error;
+}
+
+int git_rebase_open(git_rebase **out, git_repository *repo)
+{
+	git_rebase *rebase;
+	git_buf path = GIT_BUF_INIT, orig_head_name = GIT_BUF_INIT,
+		orig_head_id = GIT_BUF_INIT, onto_id = GIT_BUF_INIT;
+	int state_path_len, error;
+
+	assert(repo);
+
+	rebase = git__calloc(1, sizeof(git_rebase));
+	GITERR_CHECK_ALLOC(rebase);
+
+	rebase->repo = repo;
+
+	if ((error = rebase_state_type(&rebase->type, &rebase->state_path, repo)) < 0)
+		goto done;
+
+	if (rebase->type == GIT_REBASE_TYPE_NONE) {
+		giterr_set(GITERR_REBASE, "There is no rebase in progress");
+		return GIT_ENOTFOUND;
+	}
+
+	if ((error = git_buf_puts(&path, rebase->state_path)) < 0)
+		goto done;
+
+	state_path_len = git_buf_len(&path);
+
+	if ((error = git_buf_joinpath(&path, path.ptr, HEAD_NAME_FILE)) < 0 ||
+		(error = git_futils_readbuffer(&orig_head_name, path.ptr)) < 0)
+		goto done;
+
+	git_buf_rtrim(&orig_head_name);
+
+	if (strcmp(ORIG_DETACHED_HEAD, orig_head_name.ptr) == 0)
+		rebase->head_detached = 1;
+
+	git_buf_truncate(&path, state_path_len);
+
+	if ((error = git_buf_joinpath(&path, path.ptr, ORIG_HEAD_FILE)) < 0)
+		goto done;
+
+	if (!git_path_isfile(path.ptr)) {
+		/* Previous versions of git.git used 'head' here; support that. */
+		git_buf_truncate(&path, state_path_len);
+
+		if ((error = git_buf_joinpath(&path, path.ptr, HEAD_FILE)) < 0)
+			goto done;
+	}
+
+	if ((error = git_futils_readbuffer(&orig_head_id, path.ptr)) < 0)
+		goto done;
+
+	git_buf_rtrim(&orig_head_id);
+
+	if ((error = git_oid_fromstr(&rebase->orig_head_id, orig_head_id.ptr)) < 0)
+		goto done;
+
+	git_buf_truncate(&path, state_path_len);
+
+	if ((error = git_buf_joinpath(&path, path.ptr, ONTO_FILE)) < 0 ||
+		(error = git_futils_readbuffer(&onto_id, path.ptr)) < 0)
+		goto done;
+
+	git_buf_rtrim(&onto_id);
+
+	if ((error = git_oid_fromstr(&rebase->onto_id, onto_id.ptr)) < 0)
+		goto done;
+
+	if (!rebase->head_detached)
+		rebase->orig_head_name = git_buf_detach(&orig_head_name);
+
+	switch (rebase->type) {
+	case GIT_REBASE_TYPE_INTERACTIVE:
+		giterr_set(GITERR_REBASE, "Interactive rebase is not supported");
+		error = -1;
+		break;
+	case GIT_REBASE_TYPE_MERGE:
+		error = rebase_open_merge(rebase);
+		break;
+	case GIT_REBASE_TYPE_APPLY:
+		giterr_set(GITERR_REBASE, "Patch application rebase is not supported");
+		error = -1;
+		break;
+	default:
+		abort();
+	}
+
+done:
+	if (error == 0)
+		*out = rebase;
+	else
+		git_rebase_free(rebase);
+
+	git_buf_free(&path);
+	git_buf_free(&orig_head_name);
+	git_buf_free(&orig_head_id);
+	git_buf_free(&onto_id);
+	return error;
+}
+
+static int rebase_cleanup(git_rebase *rebase)
+{
+	return git_path_isdir(rebase->state_path) ?
+		git_futils_rmdir_r(rebase->state_path, NULL, GIT_RMDIR_REMOVE_FILES) :
+		0;
+}
+
+static int rebase_setupfile(git_rebase *rebase, const char *filename, int flags, const char *fmt, ...)
+{
+	git_buf path = GIT_BUF_INIT,
+		contents = GIT_BUF_INIT;
+	va_list ap;
+	int error;
+
+	va_start(ap, fmt);
+	git_buf_vprintf(&contents, fmt, ap);
+	va_end(ap);
+
+	if ((error = git_buf_joinpath(&path, rebase->state_path, filename)) == 0)
+		error = git_futils_writebuffer(&contents, path.ptr, flags, REBASE_FILE_MODE);
+
+	git_buf_free(&path);
+	git_buf_free(&contents);
+
+	return error;
+}
+
+static const char *rebase_onto_name(const git_annotated_commit *onto)
+{
+	if (onto->ref_name && git__strncmp(onto->ref_name, "refs/heads/", 11) == 0)
+		return onto->ref_name + 11;
+	else if (onto->ref_name)
+		return onto->ref_name;
+	else
+		return onto->id_str;
+}
+
+static int rebase_setupfiles_merge(git_rebase *rebase)
+{
+	git_buf commit_filename = GIT_BUF_INIT;
+	char id_str[GIT_OID_HEXSZ];
+	git_rebase_operation *operation;
+	size_t i;
+	int error = 0;
+
+	if ((error = rebase_setupfile(rebase, END_FILE, -1, "%d\n", git_array_size(rebase->operations))) < 0 ||
+		(error = rebase_setupfile(rebase, ONTO_NAME_FILE, -1, "%s\n", rebase->onto_name)) < 0)
+		goto done;
+
+	for (i = 0; i < git_array_size(rebase->operations); i++) {
+		operation = git_array_get(rebase->operations, i);
+
+		git_buf_clear(&commit_filename);
+		git_buf_printf(&commit_filename, CMT_FILE_FMT, i+1);
+
+		git_oid_fmt(id_str, &operation->id);
+
+		if ((error = rebase_setupfile(rebase, commit_filename.ptr, -1,
+				"%.*s\n", GIT_OID_HEXSZ, id_str)) < 0)
+			goto done;
+	}
+
+done:
+	git_buf_free(&commit_filename);
+	return error;
+}
+
+static int rebase_setupfiles(git_rebase *rebase)
+{
+	char onto[GIT_OID_HEXSZ], orig_head[GIT_OID_HEXSZ];
+
+	git_oid_fmt(onto, &rebase->onto_id);
+	git_oid_fmt(orig_head, &rebase->orig_head_id);
+
+	if (p_mkdir(rebase->state_path, REBASE_DIR_MODE) < 0) {
+		giterr_set(GITERR_OS, "Failed to create rebase directory '%s'", rebase->state_path);
+		return -1;
+	}
+
+	if (git_repository__set_orig_head(rebase->repo, &rebase->orig_head_id) < 0 ||
+		rebase_setupfile(rebase, HEAD_NAME_FILE, -1, "%s\n", rebase->orig_head_name) < 0 ||
+		rebase_setupfile(rebase, ONTO_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, onto) < 0 ||
+		rebase_setupfile(rebase, ORIG_HEAD_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, orig_head) < 0 ||
+		rebase_setupfile(rebase, QUIET_FILE, -1, rebase->quiet ? "t\n" : "\n") < 0)
+		return -1;
+
+	return rebase_setupfiles_merge(rebase);
+}
+
+int git_rebase_init_options(git_rebase_options *opts, unsigned int version)
+{
+	GIT_INIT_STRUCTURE_FROM_TEMPLATE(
+		opts, version, git_rebase_options, GIT_REBASE_OPTIONS_INIT);
+	return 0;
+}
+
+static int rebase_normalize_opts(
+	git_repository *repo,
+	git_rebase_options *opts,
+	const git_rebase_options *given_opts)
+{
+	git_rebase_options default_opts = GIT_REBASE_OPTIONS_INIT;
+	git_config *config;
+
+	if (given_opts)
+		memcpy(opts, given_opts, sizeof(git_rebase_options));
+	else
+		memcpy(opts, &default_opts, sizeof(git_rebase_options));
+
+	if (git_repository_config(&config, repo) < 0)
+		return -1;
+
+	if (given_opts && given_opts->rewrite_notes_ref) {
+		opts->rewrite_notes_ref = git__strdup(given_opts->rewrite_notes_ref);
+		GITERR_CHECK_ALLOC(opts->rewrite_notes_ref);
+	} else if (git_config__get_bool_force(config, "notes.rewrite.rebase", 1)) {
+		const char *rewrite_ref = git_config__get_string_force(
+			config, "notes.rewriteref", NOTES_DEFAULT_REF);
+
+		if (rewrite_ref) {
+			opts->rewrite_notes_ref = git__strdup(rewrite_ref);
+			GITERR_CHECK_ALLOC(opts->rewrite_notes_ref);
+		}
+	}
+
+	git_config_free(config);
+
+	return 0;
+}
+
+static void rebase_opts_free(git_rebase_options *opts)
+{
+	if (!opts)
+		return;
+
+	git__free((char *)opts->rewrite_notes_ref);
+}
+
+static int rebase_ensure_not_in_progress(git_repository *repo)
+{
+	int error;
+	git_rebase_type_t type;
+
+	if ((error = rebase_state_type(&type, NULL, repo)) < 0)
+		return error;
+
+	if (type != GIT_REBASE_TYPE_NONE) {
+		giterr_set(GITERR_REBASE, "There is an existing rebase in progress");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int rebase_ensure_not_dirty(git_repository *repo)
+{
+	git_tree *head = NULL;
+	git_index *index = NULL;
+	git_diff *diff = NULL;
+	int error;
+
+	if ((error = git_repository_head_tree(&head, repo)) < 0 ||
+		(error = git_repository_index(&index, repo)) < 0 ||
+		(error = git_diff_tree_to_index(&diff, repo, head, index, NULL)) < 0)
+		goto done;
+
+	if (git_diff_num_deltas(diff) > 0) {
+		giterr_set(GITERR_REBASE, "Uncommitted changes exist in index");
+		error = -1;
+		goto done;
+	}
+
+	git_diff_free(diff);
+	diff = NULL;
+
+	if ((error = git_diff_index_to_workdir(&diff, repo, index, NULL)) < 0)
+		goto done;
+
+	if (git_diff_num_deltas(diff) > 0) {
+		giterr_set(GITERR_REBASE, "Unstaged changes exist in workdir");
+		error = -1;
+	}
+
+done:
+	git_diff_free(diff);
+	git_index_free(index);
+	git_tree_free(head);
+
+	return error;
+}
+
+static int rebase_init_operations(
+	git_rebase *rebase,
+	git_repository *repo,
+	const git_annotated_commit *branch,
+	const git_annotated_commit *upstream,
+	const git_annotated_commit *onto)
+{
+	git_revwalk *revwalk = NULL;
+	git_commit *commit;
+	git_oid id;
+	bool merge;
+	git_rebase_operation *operation;
+	int error;
+
+	if (!upstream)
+		upstream = onto;
+
+	if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 ||
+		(error = git_revwalk_push(revwalk, git_annotated_commit_id(branch))) < 0 ||
+		(error = git_revwalk_hide(revwalk, git_annotated_commit_id(upstream))) < 0)
+		goto done;
+
+	git_revwalk_sorting(revwalk, GIT_SORT_REVERSE | GIT_SORT_TIME);
+
+	while ((error = git_revwalk_next(&id, revwalk)) == 0) {
+		if ((error = git_commit_lookup(&commit, repo, &id)) < 0)
+			goto done;
+
+		merge = (git_commit_parentcount(commit) > 1);
+		git_commit_free(commit);
+
+		if (merge)
+			continue;
+
+		operation = git_array_alloc(rebase->operations);
+		operation->type = GIT_REBASE_OPERATION_PICK;
+		git_oid_cpy((git_oid *)&operation->id, &id);
+	}
+
+	error = 0;
+
+done:
+	git_revwalk_free(revwalk);
+	return error;
+}
+
+static int rebase_init_merge(
+	git_rebase *rebase,
+	git_repository *repo,
+	const git_annotated_commit *branch,
+	const git_annotated_commit *upstream,
+	const git_annotated_commit *onto)
+{
+	if (rebase_init_operations(rebase, repo, branch, upstream, onto) < 0)
+		return -1;
+
+	rebase->onto_name = git__strdup(rebase_onto_name(onto));
+	GITERR_CHECK_ALLOC(rebase->onto_name);
+
+	return 0;
+}
+
+static int rebase_init(
+	git_rebase *rebase,
+	git_repository *repo,
+	const git_annotated_commit *branch,
+	const git_annotated_commit *upstream,
+	const git_annotated_commit *onto,
+	const git_rebase_options *opts)
+{
+	git_buf state_path = GIT_BUF_INIT;
+	int error;
+
+	git_buf_joinpath(&state_path, repo->path_repository, REBASE_MERGE_DIR);
+
+	rebase->repo = repo;
+	rebase->type = GIT_REBASE_TYPE_MERGE;
+	rebase->state_path = git_buf_detach(&state_path);
+	rebase->orig_head_name = git__strdup(branch->ref_name ? branch->ref_name : ORIG_DETACHED_HEAD);
+	rebase->quiet = opts->quiet;
+
+	git_oid_cpy(&rebase->orig_head_id, git_annotated_commit_id(branch));
+	git_oid_cpy(&rebase->onto_id, git_annotated_commit_id(onto));
+
+	if (!rebase->orig_head_name || !rebase->state_path)
+		return -1;
+
+	error = rebase_init_merge(rebase, repo, branch, upstream, onto);
+
+	git_buf_free(&state_path);
+
+	return error;
+}
+
+int git_rebase_init(
+	git_rebase **out,
+	git_repository *repo,
+	const git_annotated_commit *branch,
+	const git_annotated_commit *upstream,
+	const git_annotated_commit *onto,
+	const git_signature *signature,
+	const git_rebase_options *given_opts)
+{
+	git_rebase *rebase = NULL;
+	git_rebase_options opts;
+	git_reference *head_ref = NULL;
+	git_buf reflog = GIT_BUF_INIT;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	int error;
+
+	assert(repo && branch && (upstream || onto));
+
+	*out = NULL;
+
+	GITERR_CHECK_VERSION(given_opts, GIT_MERGE_OPTIONS_VERSION, "git_merge_options");
+
+	if (!onto)
+		onto = upstream;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
+	if ((error = rebase_normalize_opts(repo, &opts, given_opts)) < 0 ||
+		(error = git_repository__ensure_not_bare(repo, "rebase")) < 0 ||
+		(error = rebase_ensure_not_in_progress(repo)) < 0 ||
+		(error = rebase_ensure_not_dirty(repo)) < 0)
+		return error;
+
+	rebase = git__calloc(1, sizeof(git_rebase));
+	GITERR_CHECK_ALLOC(rebase);
+
+	if ((error = rebase_init(rebase, repo, branch, upstream, onto, &opts)) < 0 ||
+		(error = rebase_setupfiles(rebase)) < 0 ||
+		(error = git_buf_printf(&reflog,
+			"rebase: checkout %s", rebase_onto_name(onto))) < 0 ||
+		(error = git_reference_create(&head_ref, repo, GIT_HEAD_FILE,
+			git_annotated_commit_id(onto), 1, signature, reflog.ptr)) < 0 ||
+		(error = git_checkout_head(repo, &checkout_opts)) < 0)
+		goto done;
+
+	*out = rebase;
+
+done:
+	if (error < 0) {
+		rebase_cleanup(rebase);
+		git_rebase_free(rebase);
+	}
+
+	git_reference_free(head_ref);
+	git_buf_free(&reflog);
+	rebase_opts_free(&opts);
+
+	return error;
+}
+
+static void normalize_checkout_opts(
+	git_rebase *rebase,
+	git_commit *current_commit,
+	git_checkout_options *checkout_opts,
+	const git_checkout_options *given_checkout_opts)
+{
+	if (given_checkout_opts != NULL)
+		memcpy(checkout_opts, given_checkout_opts, sizeof(git_checkout_options));
+	else {
+		git_checkout_options default_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+		default_checkout_opts.checkout_strategy =  GIT_CHECKOUT_SAFE;
+
+		memcpy(checkout_opts, &default_checkout_opts, sizeof(git_checkout_options));
+	}
+
+	if (!checkout_opts->ancestor_label)
+		checkout_opts->ancestor_label = "ancestor";
+
+	if (rebase->type == GIT_REBASE_TYPE_MERGE) {
+		if (!checkout_opts->our_label)
+			checkout_opts->our_label = rebase->onto_name;
+
+		if (!checkout_opts->their_label)
+			checkout_opts->their_label = git_commit_summary(current_commit);
+	} else {
+		abort();
+	}
+}
+
+GIT_INLINE(int) rebase_movenext(git_rebase *rebase)
+{
+	size_t next = rebase->started ? rebase->current + 1 : 0;
+
+	if (next == git_array_size(rebase->operations))
+		return GIT_ITEROVER;
+
+	rebase->started = 1;
+	rebase->current = next;
+
+	return 0;
+}
+
+static int rebase_next_merge(
+	git_rebase_operation **out,
+	git_rebase *rebase,
+	git_checkout_options *given_checkout_opts)
+{
+	git_buf path = GIT_BUF_INIT;
+	git_checkout_options checkout_opts = {0};
+	git_commit *current_commit = NULL, *parent_commit = NULL;
+	git_tree *current_tree = NULL, *head_tree = NULL, *parent_tree = NULL;
+	git_index *index = NULL;
+	git_rebase_operation *operation;
+	char current_idstr[GIT_OID_HEXSZ];
+	unsigned int parent_count;
+	int error;
+
+	*out = NULL;
+
+	if ((error = rebase_movenext(rebase)) < 0)
+		goto done;
+
+	operation = git_array_get(rebase->operations, rebase->current);
+
+	if ((error = git_commit_lookup(&current_commit, rebase->repo, &operation->id)) < 0 ||
+		(error = git_commit_tree(&current_tree, current_commit)) < 0 ||
+		(error = git_repository_head_tree(&head_tree, rebase->repo)) < 0)
+		goto done;
+
+	if ((parent_count = git_commit_parentcount(current_commit)) > 1) {
+		giterr_set(GITERR_REBASE, "Cannot rebase a merge commit");
+		error = -1;
+		goto done;
+	} else if (parent_count) {
+		if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 ||
+			(error = git_commit_tree(&parent_tree, parent_commit)) < 0)
+			goto done;
+	}
+
+	git_oid_fmt(current_idstr, &operation->id);
+
+	if ((error = rebase_setupfile(rebase, MSGNUM_FILE, -1, "%d\n", rebase->current+1)) < 0 ||
+		(error = rebase_setupfile(rebase, CURRENT_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, current_idstr)) < 0)
+		goto done;
+
+	normalize_checkout_opts(rebase, current_commit, &checkout_opts, given_checkout_opts);
+
+	if ((error = git_merge_trees(&index, rebase->repo, parent_tree, head_tree, current_tree, NULL)) < 0 ||
+		(error = git_merge__check_result(rebase->repo, index)) < 0 ||
+		(error = git_checkout_index(rebase->repo, index, &checkout_opts)) < 0)
+		goto done;
+
+	*out = operation;
+
+done:
+	git_index_free(index);
+	git_tree_free(current_tree);
+	git_tree_free(head_tree);
+	git_tree_free(parent_tree);
+	git_commit_free(parent_commit);
+	git_commit_free(current_commit);
+	git_buf_free(&path);
+
+	return error;
+}
+
+int git_rebase_next(
+	git_rebase_operation **out,
+	git_rebase *rebase,
+	git_checkout_options *checkout_opts)
+{
+	int error;
+
+	assert(out && rebase);
+
+	switch (rebase->type) {
+	case GIT_REBASE_TYPE_MERGE:
+		error = rebase_next_merge(out, rebase, checkout_opts);
+		break;
+	default:
+		abort();
+	}
+
+	return error;
+}
+
+static int rebase_commit_merge(
+	git_oid *commit_id,
+	git_rebase *rebase,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message)
+{
+	git_index *index = NULL;
+	git_reference *head = NULL;
+	git_commit *current_commit = NULL, *head_commit = NULL, *commit = NULL;
+	git_rebase_operation *operation;
+	git_tree *head_tree = NULL, *tree = NULL;
+	git_diff *diff = NULL;
+	git_oid tree_id;
+	git_buf reflog_msg = GIT_BUF_INIT;
+	char old_idstr[GIT_OID_HEXSZ], new_idstr[GIT_OID_HEXSZ];
+	int error;
+
+	operation = git_array_get(rebase->operations, rebase->current);
+	assert(operation);
+
+	if ((error = git_repository_index(&index, rebase->repo)) < 0)
+		goto done;
+
+	if (git_index_has_conflicts(index)) {
+		giterr_set(GITERR_REBASE, "Conflicts have not been resolved");
+		error = GIT_EMERGECONFLICT;
+		goto done;
+	}
+
+	if ((error = git_commit_lookup(&current_commit, rebase->repo, &operation->id)) < 0 ||
+		(error = git_repository_head(&head, rebase->repo)) < 0 ||
+		(error = git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT)) < 0 ||
+		(error = git_commit_tree(&head_tree, head_commit)) < 0 ||
+		(error = git_diff_tree_to_index(&diff, rebase->repo, head_tree, index, NULL)) < 0)
+		goto done;
+
+	if (git_diff_num_deltas(diff) == 0) {
+		giterr_set(GITERR_REBASE, "This patch has already been applied");
+		error = GIT_EAPPLIED;
+		goto done;
+	}
+
+	if ((error = git_index_write_tree(&tree_id, index)) < 0 ||
+		(error = git_tree_lookup(&tree, rebase->repo, &tree_id)) < 0)
+		goto done;
+
+	if (!author)
+		author = git_commit_author(current_commit);
+
+	if (!message) {
+		message_encoding = git_commit_message_encoding(current_commit);
+		message = git_commit_message(current_commit);
+	}
+
+	if ((error = git_commit_create(commit_id, rebase->repo, NULL, author,
+			committer, message_encoding, message, tree, 1,
+			(const git_commit **)&head_commit)) < 0 ||
+		(error = git_commit_lookup(&commit, rebase->repo, commit_id)) < 0 ||
+		(error = git_reference__update_for_commit(
+			rebase->repo, NULL, "HEAD", commit_id, committer, "rebase")) < 0)
+		goto done;
+
+	git_oid_fmt(old_idstr, git_commit_id(current_commit));
+	git_oid_fmt(new_idstr, commit_id);
+
+	error = rebase_setupfile(rebase, REWRITTEN_FILE, O_CREAT|O_WRONLY|O_APPEND,
+		"%.*s %.*s\n", GIT_OID_HEXSZ, old_idstr, GIT_OID_HEXSZ, new_idstr);
+
+done:
+	git_buf_free(&reflog_msg);
+	git_commit_free(commit);
+	git_diff_free(diff);
+	git_tree_free(tree);
+	git_tree_free(head_tree);
+	git_commit_free(head_commit);
+	git_commit_free(current_commit);
+	git_reference_free(head);
+	git_index_free(index);
+
+	return error;
+}
+
+int git_rebase_commit(
+	git_oid *id,
+	git_rebase *rebase,
+	const git_signature *author,
+	const git_signature *committer,
+	const char *message_encoding,
+	const char *message)
+{
+	int error;
+
+	assert(rebase && committer);
+
+	switch (rebase->type) {
+	case GIT_REBASE_TYPE_MERGE:
+		error = rebase_commit_merge(
+			id, rebase, author, committer, message_encoding, message);
+		break;
+	default:
+		abort();
+	}
+
+	return error;
+}
+
+int git_rebase_abort(git_rebase *rebase, const git_signature *signature)
+{
+	git_reference *orig_head_ref = NULL;
+	git_commit *orig_head_commit = NULL;
+	int error;
+
+	assert(rebase && signature);
+
+	error = rebase->head_detached ?
+		git_reference_create(&orig_head_ref, rebase->repo, GIT_HEAD_FILE,
+			 &rebase->orig_head_id, 1, signature, "rebase: aborting") :
+		git_reference_symbolic_create(
+			&orig_head_ref, rebase->repo, GIT_HEAD_FILE, rebase->orig_head_name, 1,
+			signature, "rebase: aborting");
+
+	if (error < 0)
+		goto done;
+
+	if ((error = git_commit_lookup(
+			&orig_head_commit, rebase->repo, &rebase->orig_head_id)) < 0 ||
+		(error = git_reset(rebase->repo, (git_object *)orig_head_commit,
+			GIT_RESET_HARD, NULL, signature, NULL)) < 0)
+		goto done;
+
+	error = rebase_cleanup(rebase);
+
+done:
+	git_commit_free(orig_head_commit);
+	git_reference_free(orig_head_ref);
+
+	return error;
+}
+
+static int rebase_copy_note(
+	git_rebase *rebase,
+	git_oid *from,
+	git_oid *to,
+	const git_signature *committer,
+	const git_rebase_options *opts)
+{
+	git_note *note = NULL;
+	git_oid note_id;
+	git_signature *who = NULL;
+	int error;
+
+	if ((error = git_note_read(&note, rebase->repo, opts->rewrite_notes_ref, from)) < 0) {
+		if (error == GIT_ENOTFOUND) {
+			giterr_clear();
+			error = 0;
+		}
+
+		goto done;
+	}
+
+	if (!committer) {
+		if((error = git_signature_default(&who, rebase->repo)) < 0) {
+			if (error != GIT_ENOTFOUND ||
+				(error = git_signature_now(&who, "unknown", "unknown")) < 0)
+				goto done;
+
+			giterr_clear();
+		}
+
+		committer = who;
+	}
+
+	error = git_note_create(&note_id, rebase->repo, git_note_author(note),
+		committer, opts->rewrite_notes_ref, to, git_note_message(note), 0);
+
+done:
+	git_note_free(note);
+	git_signature_free(who);
+
+	return error;
+}
+
+static int rebase_copy_notes(
+	git_rebase *rebase,
+	const git_signature *committer,
+	const git_rebase_options *opts)
+{
+	git_buf path = GIT_BUF_INIT, rewritten = GIT_BUF_INIT;
+	char *pair_list, *fromstr, *tostr, *end;
+	git_oid from, to;
+	unsigned int linenum = 1;
+	int error = 0;
+
+	if (!opts->rewrite_notes_ref)
+		goto done;
+
+	if ((error = git_buf_joinpath(&path, rebase->state_path, REWRITTEN_FILE)) < 0 ||
+		(error = git_futils_readbuffer(&rewritten, path.ptr)) < 0)
+		goto done;
+
+	pair_list = rewritten.ptr;
+
+	while (*pair_list) {
+		fromstr = pair_list;
+
+		if ((end = strchr(fromstr, '\n')) == NULL)
+			goto on_error;
+
+		pair_list = end+1;
+		*end = '\0';
+
+		if ((end = strchr(fromstr, ' ')) == NULL)
+			goto on_error;
+
+		tostr = end+1;
+		*end = '\0';
+
+		if (strlen(fromstr) != GIT_OID_HEXSZ ||
+			strlen(tostr) != GIT_OID_HEXSZ ||
+			git_oid_fromstr(&from, fromstr) < 0 ||
+			git_oid_fromstr(&to, tostr) < 0)
+			goto on_error;
+
+		if ((error = rebase_copy_note(rebase, &from, &to, committer, opts)) < 0)
+			goto done;
+
+		linenum++;
+	}
+
+	goto done;
+
+on_error:
+	giterr_set(GITERR_REBASE, "Invalid rewritten file at line %d", linenum);
+	error = -1;
+
+done:
+	git_buf_free(&rewritten);
+	git_buf_free(&path);
+
+	return error;
+}
+
+int git_rebase_finish(
+	git_rebase *rebase,
+	const git_signature *signature,
+	const git_rebase_options *given_opts)
+{
+	git_rebase_options opts;
+	git_reference *terminal_ref = NULL, *branch_ref = NULL, *head_ref = NULL;
+	git_commit *terminal_commit = NULL;
+	git_buf branch_msg = GIT_BUF_INIT, head_msg = GIT_BUF_INIT;
+	char onto[GIT_OID_HEXSZ];
+	int error;
+
+	assert(rebase);
+
+	if ((error = rebase_normalize_opts(rebase->repo, &opts, given_opts)) < 0)
+		goto done;
+
+	git_oid_fmt(onto, &rebase->onto_id);
+
+	if ((error = git_buf_printf(&branch_msg, "rebase finished: %s onto %.*s",
+			rebase->orig_head_name, GIT_OID_HEXSZ, onto)) < 0 ||
+		(error = git_buf_printf(&head_msg, "rebase finished: returning to %s",
+			rebase->orig_head_name)) < 0 ||
+		(error = git_repository_head(&terminal_ref, rebase->repo)) < 0 ||
+		(error = git_reference_peel((git_object **)&terminal_commit,
+			terminal_ref, GIT_OBJ_COMMIT)) < 0 ||
+		(error = git_reference_create_matching(&branch_ref,
+			rebase->repo, rebase->orig_head_name, git_commit_id(terminal_commit), 1,
+			&rebase->orig_head_id, signature, branch_msg.ptr)) < 0 ||
+		(error = git_reference_symbolic_create(&head_ref,
+			rebase->repo, GIT_HEAD_FILE, rebase->orig_head_name, 1,
+			signature, head_msg.ptr)) < 0 ||
+		(error = rebase_copy_notes(rebase, signature, &opts)) < 0)
+		goto done;
+
+	error = rebase_cleanup(rebase);
+
+done:
+	git_buf_free(&head_msg);
+	git_buf_free(&branch_msg);
+	git_commit_free(terminal_commit);
+	git_reference_free(head_ref);
+	git_reference_free(branch_ref);
+	git_reference_free(terminal_ref);
+	rebase_opts_free(&opts);
+
+	return error;
+}
+
+size_t git_rebase_operation_entrycount(git_rebase *rebase)
+{
+	assert(rebase);
+
+	return git_array_size(rebase->operations);
+}
+
+size_t git_rebase_operation_current(git_rebase *rebase)
+{
+	assert(rebase);
+
+	return rebase->current;
+}
+
+git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx)
+{
+	assert(rebase);
+
+	return git_array_get(rebase->operations, idx);
+}
+
+void git_rebase_free(git_rebase *rebase)
+{
+	if (rebase == NULL)
+		return;
+
+	git__free(rebase->onto_name);
+	git__free(rebase->orig_head_name);
+	git__free(rebase->state_path);
+	git_array_clear(rebase->operations);
+	git__free(rebase);
+}
diff --git a/src/refs.c b/src/refs.c
index 08e407e..43c7333 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -22,6 +22,7 @@
 #include <git2/refdb.h>
 #include <git2/sys/refs.h>
 #include <git2/signature.h>
+#include <git2/commit.h>
 
 GIT__USE_STRMAP;
 
@@ -1090,6 +1091,40 @@ int git_reference__update_terminal(
 	return reference__update_terminal(repo, ref_name, oid, 0, signature, log_message);
 }
 
+int git_reference__update_for_commit(
+	git_repository *repo,
+	git_reference *ref,
+	const char *ref_name,
+	const git_oid *id,
+	const git_signature *committer,
+	const char *operation)
+{
+	git_reference *ref_new = NULL;
+	git_commit *commit = NULL;
+	git_buf reflog_msg = GIT_BUF_INIT;
+	int error;
+
+	if ((error = git_commit_lookup(&commit, repo, id)) < 0 ||
+		(error = git_buf_printf(&reflog_msg, "%s%s: %s",
+			operation ? operation : "commit",
+			git_commit_parentcount(commit) == 0 ? " (initial)" : "",
+			git_commit_summary(commit))) < 0)
+		goto done;
+
+	if (ref)
+		error = git_reference_set_target(
+			&ref_new, ref, id, committer, git_buf_cstr(&reflog_msg));
+	else
+		error = git_reference__update_terminal(
+			repo, ref_name, id, committer, git_buf_cstr(&reflog_msg));
+
+done:
+	git_reference_free(ref_new);
+	git_buf_free(&reflog_msg);
+	git_commit_free(commit);
+	return error;
+}
+
 int git_reference_has_log(git_repository *repo, const char *refname)
 {
 	int error;
diff --git a/src/refs.h b/src/refs.h
index c6ec429..5f48efc 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -100,4 +100,13 @@ int git_reference_lookup_resolved(
 
 int git_reference__log_signature(git_signature **out, git_repository *repo);
 
+/** Update a reference after a commit. */
+int git_reference__update_for_commit(
+	git_repository *repo,
+	git_reference *ref,
+	const char *ref_name,
+	const git_oid *id,
+	const git_signature *committer,
+	const char *operation);
+
 #endif
diff --git a/src/repository.c b/src/repository.c
index f032c89..2bab529 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1728,6 +1728,28 @@ cleanup:
 	return error;
 }
 
+int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head)
+{
+	git_filebuf file = GIT_FILEBUF_INIT;
+	git_buf file_path = GIT_BUF_INIT;
+	char orig_head_str[GIT_OID_HEXSZ];
+	int error = 0;
+
+	git_oid_fmt(orig_head_str, orig_head);
+
+	if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 &&
+		(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 &&
+		(error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0)
+		error = git_filebuf_commit(&file);
+
+	if (error < 0)
+		git_filebuf_cleanup(&file);
+
+	git_buf_free(&file_path);
+
+	return error;
+}
+
 int git_repository_message(git_buf *out, git_repository *repo)
 {
 	git_buf path = GIT_BUF_INIT;
diff --git a/src/repository.h b/src/repository.h
index aba16a0..45b95a0 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -170,6 +170,8 @@ GIT_INLINE(int) git_repository__ensure_not_bare(
 	return GIT_EBAREREPO;
 }
 
+int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head);
+
 int git_repository__cleanup_files(git_repository *repo, const char *files[], size_t files_len);
 
 #endif
diff --git a/src/reset.c b/src/reset.c
index d063abe..dc3aa4a 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -101,7 +101,7 @@ int git_reset(
 	git_object *target,
 	git_reset_t reset_type,
 	git_checkout_options *checkout_opts,
-	git_signature *signature,
+	const git_signature *signature,
 	const char *log_message)
 {
 	git_object *commit = NULL;
diff --git a/src/signature.c b/src/signature.c
index 514b153..818cd30 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -270,3 +270,14 @@ void git_signature__writebuf(git_buf *buf, const char *header, const git_signatu
 			(unsigned)sig->when.time, sign, hours, mins);
 }
 
+bool git_signature__equal(const git_signature *one, const git_signature *two)
+{
+	assert(one && two);
+
+	return
+		git__strcmp(one->name, two->name) == 0 &&
+		git__strcmp(one->email, two->email) == 0 &&
+		one->when.time == two->when.time &&
+		one->when.offset == two->when.offset;
+}
+
diff --git a/src/signature.h b/src/signature.h
index eb71db7..75265df 100644
--- a/src/signature.h
+++ b/src/signature.h
@@ -14,6 +14,7 @@
 
 int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender);
 void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig);
+bool git_signature__equal(const git_signature *one, const git_signature *two);
 
 int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool);
 
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index e3e7039..9a6ead9 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -6,6 +6,7 @@
 #include "merge.h"
 #include "git2/merge.h"
 #include "git2/sys/index.h"
+#include "git2/annotated_commit.h"
 
 int merge_trees_from_branches(
 	git_index **index, git_repository *repo,
@@ -84,7 +85,7 @@ int merge_branches(git_repository *repo,
 	git_merge_options *merge_opts, git_checkout_options *checkout_opts)
 {
 	git_reference *head_ref, *theirs_ref;
-	git_merge_head *theirs_head;
+	git_annotated_commit *theirs_head;
 	git_checkout_options head_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 
 	head_checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
@@ -93,13 +94,13 @@ int merge_branches(git_repository *repo,
 	cl_git_pass(git_checkout_head(repo, &head_checkout_opts));
 
 	cl_git_pass(git_reference_lookup(&theirs_ref, repo, theirs_branch));
-	cl_git_pass(git_merge_head_from_ref(&theirs_head, repo, theirs_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&theirs_head, repo, theirs_ref));
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)&theirs_head, 1, merge_opts, checkout_opts));
 
 	git_reference_free(head_ref);
 	git_reference_free(theirs_ref);
-	git_merge_head_free(theirs_head);
+	git_annotated_commit_free(theirs_head);
 
 	return 0;
 }
diff --git a/tests/merge/workdir/analysis.c b/tests/merge/workdir/analysis.c
index 85918ab..351cfbd 100644
--- a/tests/merge/workdir/analysis.c
+++ b/tests/merge/workdir/analysis.c
@@ -1,6 +1,7 @@
 #include "clar_libgit2.h"
 #include "git2/repository.h"
 #include "git2/merge.h"
+#include "git2/annotated_commit.h"
 #include "git2/sys/index.h"
 #include "merge.h"
 #include "../merge_helpers.h"
@@ -43,17 +44,17 @@ static void analysis_from_branch(
 {
 	git_buf refname = GIT_BUF_INIT;
 	git_reference *their_ref;
-	git_merge_head *their_head;
+	git_annotated_commit *their_head;
 
 	git_buf_printf(&refname, "%s%s", GIT_REFS_HEADS_DIR, branchname);
 
 	cl_git_pass(git_reference_lookup(&their_ref, repo, git_buf_cstr(&refname)));
-	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
 
-	cl_git_pass(git_merge_analysis(merge_analysis, merge_pref, repo, (const git_merge_head **)&their_head, 1));
+	cl_git_pass(git_merge_analysis(merge_analysis, merge_pref, repo, (const git_annotated_commit **)&their_head, 1));
 
 	git_buf_free(&refname);
-	git_merge_head_free(their_head);
+	git_annotated_commit_free(their_head);
 	git_reference_free(their_ref);
 }
 
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c
index 0549b06..4b68b21 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/merge/workdir/dirty.c
@@ -89,18 +89,18 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
 static int merge_branch(void)
 {
 	git_oid their_oids[1];
-	git_merge_head *their_heads[1];
+	git_annotated_commit *their_head;
 	git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
 	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 	int error;
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], MERGE_BRANCH_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
+	cl_git_pass(git_annotated_commit_lookup(&their_head, repo, &their_oids[0]));
 
 	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
-	error = git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
+	error = git_merge(repo, (const git_annotated_commit **)&their_head, 1, &merge_opts, &checkout_opts);
 
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(their_head);
 
 	return error;
 }
diff --git a/tests/merge/workdir/setup.c b/tests/merge/workdir/setup.c
index a0028ec..099bc12 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/merge/workdir/setup.c
@@ -76,15 +76,15 @@ void test_merge_workdir_setup__one_branch(void)
 {
 	git_oid our_oid;
 	git_reference *octo1_ref;
-	git_merge_head *our_head, *their_heads[1];
+	git_annotated_commit *our_head, *their_heads[1];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -93,8 +93,8 @@ void test_merge_workdir_setup__one_branch(void)
 
 	git_reference_free(octo1_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 /* git merge --no-ff 16f825815cfd20a07a75c71554e82d8eede0b061 */
@@ -102,23 +102,23 @@ void test_merge_workdir_setup__one_oid(void)
 {
 	git_oid our_oid;
 	git_oid octo1_oid;
-	git_merge_head *our_head, *their_heads[1];
+	git_annotated_commit *our_head, *their_heads[1];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'\n"));
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 /* git merge octo1 octo2 */
@@ -127,18 +127,18 @@ void test_merge_workdir_setup__two_branches(void)
 	git_oid our_oid;
 	git_reference *octo1_ref;
 	git_reference *octo2_ref;
-	git_merge_head *our_head, *their_heads[2];
+	git_annotated_commit *our_head, *their_heads[2];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -148,9 +148,9 @@ void test_merge_workdir_setup__two_branches(void)
 	git_reference_free(octo1_ref);
 	git_reference_free(octo2_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
 }
 
 /* git merge octo1 octo2 octo3 */
@@ -160,21 +160,21 @@ void test_merge_workdir_setup__three_branches(void)
 	git_reference *octo1_ref;
 	git_reference *octo2_ref;
 	git_reference *octo3_ref;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 	
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
 	cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -185,10 +185,10 @@ void test_merge_workdir_setup__three_branches(void)
 	git_reference_free(octo2_ref);
 	git_reference_free(octo3_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 /* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 158dc7bedb202f5b26502bf3574faa7f4238d56c 50ce7d7d01217679e26c55939eef119e0c93e272 */
@@ -198,31 +198,31 @@ void test_merge_workdir_setup__three_oids(void)
 	git_oid octo1_oid;
 	git_oid octo2_oid;
 	git_oid octo3_oid;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
 	
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo2_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo3_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; commit '" OCTO2_OID "'; commit '" OCTO3_OID "'\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 /* git merge octo1 158dc7bedb202f5b26502bf3574faa7f4238d56c */
@@ -231,18 +231,18 @@ void test_merge_workdir_setup__branches_and_oids_1(void)
 	git_oid our_oid;
 	git_reference *octo1_ref;
 	git_oid octo2_oid;
-	git_merge_head *our_head, *their_heads[2];
+	git_annotated_commit *our_head, *their_heads[2];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo2_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -251,9 +251,9 @@ void test_merge_workdir_setup__branches_and_oids_1(void)
 	
 	git_reference_free(octo1_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
 }
 
 /* git merge octo1 158dc7bedb202f5b26502bf3574faa7f4238d56c octo3 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae */
@@ -264,24 +264,24 @@ void test_merge_workdir_setup__branches_and_oids_2(void)
 	git_oid octo2_oid;
 	git_reference *octo3_ref;
 	git_oid octo4_oid;
-	git_merge_head *our_head, *their_heads[4];
+	git_annotated_commit *our_head, *their_heads[4];
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 	
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo2_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
 
 	cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
 	
 	cl_git_pass(git_oid_fromstr(&octo4_oid, OCTO4_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[3], repo, &octo4_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[3], repo, &octo4_oid));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -291,11 +291,11 @@ void test_merge_workdir_setup__branches_and_oids_2(void)
 	git_reference_free(octo1_ref);
 	git_reference_free(octo3_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
-	git_merge_head_free(their_heads[3]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
+	git_annotated_commit_free(their_heads[3]);
 }
 
 /* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 octo2 50ce7d7d01217679e26c55939eef119e0c93e272 octo4 */
@@ -306,24 +306,24 @@ void test_merge_workdir_setup__branches_and_oids_3(void)
 	git_reference *octo2_ref;
 	git_oid octo3_oid;
 	git_reference *octo4_ref;
-	git_merge_head *our_head, *their_heads[4];
+	git_annotated_commit *our_head, *their_heads[4];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
 
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
 	cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo3_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[3], repo, octo4_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -333,11 +333,11 @@ void test_merge_workdir_setup__branches_and_oids_3(void)
 	git_reference_free(octo2_ref);
 	git_reference_free(octo4_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
-	git_merge_head_free(their_heads[3]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
+	git_annotated_commit_free(their_heads[3]);
 }
 
 /* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 octo2 50ce7d7d01217679e26c55939eef119e0c93e272 octo4 octo5 */
@@ -349,27 +349,27 @@ void test_merge_workdir_setup__branches_and_oids_4(void)
 	git_oid octo3_oid;
 	git_reference *octo4_ref;
 	git_reference *octo5_ref;
-	git_merge_head *our_head, *their_heads[5];
+	git_annotated_commit *our_head, *their_heads[5];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 	
 	cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo3_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[3], repo, octo4_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
 
 	cl_git_pass(git_reference_lookup(&octo5_ref, repo, GIT_REFS_HEADS_DIR OCTO5_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[4], repo, octo5_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[4], repo, octo5_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 5));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 5));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n" OCTO5_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -380,12 +380,12 @@ void test_merge_workdir_setup__branches_and_oids_4(void)
 	git_reference_free(octo4_ref);
 	git_reference_free(octo5_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
-	git_merge_head_free(their_heads[3]);
-	git_merge_head_free(their_heads[4]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
+	git_annotated_commit_free(their_heads[3]);
+	git_annotated_commit_free(their_heads[4]);
 }
 
 /* git merge octo1 octo1 octo1 */
@@ -395,21 +395,21 @@ void test_merge_workdir_setup__three_same_branches(void)
 	git_reference *octo1_1_ref;
 	git_reference *octo1_2_ref;
 	git_reference *octo1_3_ref;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_1_ref));
 	
 	cl_git_pass(git_reference_lookup(&octo1_2_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo1_2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo1_2_ref));
 	
 	cl_git_pass(git_reference_lookup(&octo1_3_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo1_3_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo1_3_ref));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO1_OID "\n" OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -420,10 +420,10 @@ void test_merge_workdir_setup__three_same_branches(void)
 	git_reference_free(octo1_2_ref);
 	git_reference_free(octo1_3_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 /* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 16f825815cfd20a07a75c71554e82d8eede0b061 16f825815cfd20a07a75c71554e82d8eede0b061 */
@@ -433,31 +433,31 @@ void test_merge_workdir_setup__three_same_oids(void)
 	git_oid octo1_1_oid;
 	git_oid octo1_2_oid;
 	git_oid octo1_3_oid;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_oid_fromstr(&octo1_1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_1_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_1_oid));
 	
 	cl_git_pass(git_oid_fromstr(&octo1_2_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo1_2_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo1_2_oid));
 	
 	cl_git_pass(git_oid_fromstr(&octo1_3_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo1_3_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo1_3_oid));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO1_OID "\n" OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; commit '" OCTO1_OID "'; commit '" OCTO1_OID "'\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 static int create_remote_tracking_branch(const char *branch_name, const char *oid_str)
@@ -508,17 +508,17 @@ void test_merge_workdir_setup__remote_tracking_one_branch(void)
 {
 	git_oid our_oid;
 	git_reference *octo1_ref;
-	git_merge_head *our_head, *their_heads[1];
+	git_annotated_commit *our_head, *their_heads[1];
 
 	cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -527,8 +527,8 @@ void test_merge_workdir_setup__remote_tracking_one_branch(void)
 
 	git_reference_free(octo1_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 /* git merge refs/remotes/origin/octo1 refs/remotes/origin/octo2 */
@@ -537,21 +537,21 @@ void test_merge_workdir_setup__remote_tracking_two_branches(void)
 	git_oid our_oid;
 	git_reference *octo1_ref;
 	git_reference *octo2_ref;
-	git_merge_head *our_head, *their_heads[2];
+	git_annotated_commit *our_head, *their_heads[2];
 
 	cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
 	cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -561,9 +561,9 @@ void test_merge_workdir_setup__remote_tracking_two_branches(void)
 	git_reference_free(octo1_ref);
 	git_reference_free(octo2_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
 }
 
 /* git merge refs/remotes/origin/octo1 refs/remotes/origin/octo2 refs/remotes/origin/octo3 */
@@ -573,25 +573,25 @@ void test_merge_workdir_setup__remote_tracking_three_branches(void)
 	git_reference *octo1_ref;
 	git_reference *octo2_ref;
 	git_reference *octo3_ref;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 
 	cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
 	cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
 	cl_git_pass(create_remote_tracking_branch(OCTO3_BRANCH, OCTO3_OID));
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 	
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
 	cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO3_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -602,10 +602,10 @@ void test_merge_workdir_setup__remote_tracking_three_branches(void)
 	git_reference_free(octo2_ref);
 	git_reference_free(octo3_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 /* git merge octo1 refs/remotes/origin/octo2 */
@@ -614,20 +614,20 @@ void test_merge_workdir_setup__normal_branch_and_remote_tracking_branch(void)
 	git_oid our_oid;
 	git_reference *octo1_ref;
 	git_reference *octo2_ref;
-	git_merge_head *our_head, *their_heads[2];
+	git_annotated_commit *our_head, *their_heads[2];
 
 	cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -637,9 +637,9 @@ void test_merge_workdir_setup__normal_branch_and_remote_tracking_branch(void)
 	git_reference_free(octo1_ref);
 	git_reference_free(octo2_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
 }
 
 /* git merge refs/remotes/origin/octo1 octo2 */
@@ -648,20 +648,20 @@ void test_merge_workdir_setup__remote_tracking_branch_and_normal_branch(void)
 	git_oid our_oid;
 	git_reference *octo1_ref;
 	git_reference *octo2_ref;
-	git_merge_head *our_head, *their_heads[2];
+	git_annotated_commit *our_head, *their_heads[2];
 
 	cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -671,9 +671,9 @@ void test_merge_workdir_setup__remote_tracking_branch_and_normal_branch(void)
 	git_reference_free(octo1_ref);
 	git_reference_free(octo2_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
 }
 
 /* git merge octo1 refs/remotes/origin/octo2 octo3 refs/remotes/origin/octo4 */
@@ -684,27 +684,27 @@ void test_merge_workdir_setup__two_remote_tracking_branch_and_two_normal_branche
 	git_reference *octo2_ref;
 	git_reference *octo3_ref;
 	git_reference *octo4_ref;
-	git_merge_head *our_head, *their_heads[4];
+	git_annotated_commit *our_head, *their_heads[4];
 
 	cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
 	cl_git_pass(create_remote_tracking_branch(OCTO4_BRANCH, OCTO4_OID));
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 	
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
 
 	cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
 
 	cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO4_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[3], repo, octo4_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -716,11 +716,11 @@ void test_merge_workdir_setup__two_remote_tracking_branch_and_two_normal_branche
 	git_reference_free(octo3_ref);
 	git_reference_free(octo4_ref);
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
-	git_merge_head_free(their_heads[3]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
+	git_annotated_commit_free(their_heads[3]);
 }
 
 /* git pull origin branch octo1 */
@@ -728,23 +728,23 @@ void test_merge_workdir_setup__pull_one(void)
 {
 	git_oid our_oid;
 	git_oid octo1_1_oid;
-	git_merge_head *our_head, *their_heads[1];
+	git_annotated_commit *our_head, *their_heads[1];
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_1_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_1_oid));
 	
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
 	
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch 'octo1' of http://remote.url/repo.git\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 /* git pull origin octo1 octo2 */
@@ -753,27 +753,27 @@ void test_merge_workdir_setup__pull_two(void)
 	git_oid our_oid;
 	git_oid octo1_oid;
 	git_oid octo2_oid;
-	git_merge_head *our_head, *their_heads[2];
+	git_annotated_commit *our_head, *their_heads[2];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO2_BRANCH "' of http://remote.url/repo.git\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
 }
 
 /* git pull origin octo1 octo2 octo3 */
@@ -783,31 +783,31 @@ void test_merge_workdir_setup__pull_three(void)
 	git_oid octo1_oid;
 	git_oid octo2_oid;
 	git_oid octo3_oid;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.url/repo.git", &octo3_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.url/repo.git", &octo3_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "', '" OCTO2_BRANCH "' and '" OCTO3_BRANCH "' of http://remote.url/repo.git\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 void test_merge_workdir_setup__three_remotes(void)
@@ -816,31 +816,31 @@ void test_merge_workdir_setup__three_remotes(void)
 	git_oid octo1_oid;
 	git_oid octo2_oid;
 	git_oid octo3_oid;
-	git_merge_head *our_head, *their_heads[3];
+	git_annotated_commit *our_head, *their_heads[3];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.third/repo.git", &octo3_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.third/repo.git", &octo3_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO1_BRANCH "' of http://remote.first/repo.git, branch '" OCTO2_BRANCH "' of http://remote.second/repo.git, branch '" OCTO3_BRANCH "' of http://remote.third/repo.git\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
 }
 
 void test_merge_workdir_setup__two_remotes(void)
@@ -850,35 +850,35 @@ void test_merge_workdir_setup__two_remotes(void)
 	git_oid octo2_oid;
 	git_oid octo3_oid;
 	git_oid octo4_oid;
-	git_merge_head *our_head, *their_heads[4];
+	git_annotated_commit *our_head, *their_heads[4];
 	
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.first/repo.git", &octo3_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.first/repo.git", &octo3_oid));
 
 	cl_git_pass(git_oid_fromstr(&octo4_oid, OCTO4_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&their_heads[3], repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH, "http://remote.second/repo.git", &octo4_oid));
+	cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[3], repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH, "http://remote.second/repo.git", &octo4_oid));
 
-	cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
+	cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
 	cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
 	cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO3_BRANCH "' of http://remote.first/repo.git, branches '" OCTO2_BRANCH "' and '" OCTO4_BRANCH "' of http://remote.second/repo.git\n"));
 	
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
-	git_merge_head_free(their_heads[1]);
-	git_merge_head_free(their_heads[2]);
-	git_merge_head_free(their_heads[3]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[1]);
+	git_annotated_commit_free(their_heads[2]);
+	git_annotated_commit_free(their_heads[3]);
 }
 
 void test_merge_workdir_setup__id_from_head(void)
@@ -886,39 +886,39 @@ void test_merge_workdir_setup__id_from_head(void)
 	git_oid expected_id;
 	const git_oid *id;
 	git_reference *ref;
-	git_merge_head *heads[3];
+	git_annotated_commit *heads[3];
 
 	cl_git_pass(git_oid_fromstr(&expected_id, OCTO1_OID));
-	cl_git_pass(git_merge_head_from_fetchhead(&heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &expected_id));
-	id = git_merge_head_id(heads[0]);
+	cl_git_pass(git_annotated_commit_from_fetchhead(&heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &expected_id));
+	id = git_annotated_commit_id(heads[0]);
 	cl_assert_equal_i(1, git_oid_equal(id, &expected_id));
 
-	cl_git_pass(git_merge_head_from_id(&heads[1], repo, &expected_id));
-	id = git_merge_head_id(heads[1]);
+	cl_git_pass(git_annotated_commit_lookup(&heads[1], repo, &expected_id));
+	id = git_annotated_commit_id(heads[1]);
 	cl_assert_equal_i(1, git_oid_equal(id, &expected_id));
 
 	cl_git_pass(git_reference_lookup(&ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&heads[2], repo, ref));
-	id = git_merge_head_id(heads[2]);
+	cl_git_pass(git_annotated_commit_from_ref(&heads[2], repo, ref));
+	id = git_annotated_commit_id(heads[2]);
 	cl_assert_equal_i(1, git_oid_equal(id, &expected_id));
 
 	git_reference_free(ref);
-	git_merge_head_free(heads[0]);
-	git_merge_head_free(heads[1]);
-	git_merge_head_free(heads[2]);
+	git_annotated_commit_free(heads[0]);
+	git_annotated_commit_free(heads[1]);
+	git_annotated_commit_free(heads[2]);
 }
 
-struct merge_head_cb_data {
+struct annotated_commit_cb_data {
 	const char **oid_str;
 	unsigned int len;
 
 	unsigned int i;
 };
 
-static int merge_head_foreach_cb(const git_oid *oid, void *payload)
+static int annotated_commit_foreach_cb(const git_oid *oid, void *payload)
 {
 	git_oid expected_oid;
-	struct merge_head_cb_data *cb_data = payload;
+	struct annotated_commit_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);
@@ -931,7 +931,7 @@ void test_merge_workdir_setup__head_notfound(void)
 	int error;
 
 	cl_git_fail((error = git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, NULL)));
+		annotated_commit_foreach_cb, NULL)));
 	cl_assert(error == GIT_ENOTFOUND);
 }
 
@@ -942,7 +942,7 @@ void test_merge_workdir_setup__head_invalid_oid(void)
 	write_file_contents(GIT_MERGE_HEAD_FILE, "invalid-oid\n");
 
 	cl_git_fail((error = git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, NULL)));
+		annotated_commit_foreach_cb, NULL)));
 	cl_assert(error == -1);
 }
 
@@ -953,7 +953,7 @@ void test_merge_workdir_setup__head_foreach_nonewline(void)
 	write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID);
 
 	cl_git_fail((error = git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, NULL)));
+		annotated_commit_foreach_cb, NULL)));
 	cl_assert(error == -1);
 }
 
@@ -961,12 +961,12 @@ void test_merge_workdir_setup__head_foreach_one(void)
 {
 	const char *expected = THEIRS_SIMPLE_OID;
 
-	struct merge_head_cb_data cb_data = { &expected, 1 };
+	struct annotated_commit_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));
+		annotated_commit_foreach_cb, &cb_data));
 
 	cl_assert(cb_data.i == cb_data.len);
 }
@@ -976,7 +976,7 @@ 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 };
+	struct annotated_commit_cb_data cb_data = { expected, 6 };
 
 	write_file_contents(GIT_MERGE_HEAD_FILE,
 		THEIRS_SIMPLE_OID "\n"
@@ -987,7 +987,7 @@ void test_merge_workdir_setup__head_foreach_octopus(void)
 		OCTO5_OID "\n");
 
 	cl_git_pass(git_repository_mergehead_foreach(repo,
-		merge_head_foreach_cb, &cb_data));
+		annotated_commit_foreach_cb, &cb_data));
 
 	cl_assert(cb_data.i == cb_data.len);
 }
@@ -996,16 +996,16 @@ void test_merge_workdir_setup__retained_after_success(void)
 {
 	git_oid our_oid;
 	git_reference *octo1_ref;
-	git_merge_head *our_head, *their_heads[1];
+	git_annotated_commit *our_head, *their_heads[1];
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
 
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
 
 	cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
 	cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -1014,27 +1014,27 @@ void test_merge_workdir_setup__retained_after_success(void)
 
 	git_reference_free(octo1_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 void test_merge_workdir_setup__removed_after_failure(void)
 {
 	git_oid our_oid;
 	git_reference *octo1_ref;
-	git_merge_head *our_head, *their_heads[1];
+	git_annotated_commit *our_head, *their_heads[1];
 
 	cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
-	cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
+	cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
 
 	cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
 
 	cl_git_rewritefile("merge-resolve/new-in-octo1.txt",
 		"Conflicting file!\n\nMerge will fail!\n");
 
 	cl_git_fail(git_merge(
-		repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
+		repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
 
 	cl_assert(!git_path_exists("merge-resolve/" GIT_MERGE_HEAD_FILE));
 	cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE));
@@ -1043,6 +1043,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
 
 	git_reference_free(octo1_ref);
 
-	git_merge_head_free(our_head);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(our_head);
+	git_annotated_commit_free(their_heads[0]);
 }
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index fcd84dc..df531f4 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -95,20 +95,20 @@ void test_merge_workdir_simple__cleanup(void)
 static void merge_simple_branch(int merge_file_favor, int addl_checkout_strategy)
 {
 	git_oid their_oids[1];
-	git_merge_head *their_heads[1];
+	git_annotated_commit *their_heads[1];
 	git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
 	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_SIMPLE_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
 
 	merge_opts.file_favor = merge_file_favor;
 	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS |
 		addl_checkout_strategy;
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, &checkout_opts));
 
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 static void set_core_autocrlf_to(git_repository *repo, bool value)
@@ -486,7 +486,7 @@ void test_merge_workdir_simple__directory_file(void)
 {
 	git_reference *head;
 	git_oid their_oids[1], head_commit_id;
-	git_merge_head *their_heads[1];
+	git_annotated_commit *their_heads[1];
 	git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
 	git_commit *head_commit;
 
@@ -519,22 +519,22 @@ void test_merge_workdir_simple__directory_file(void)
 	cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD, NULL, NULL, NULL));
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_DIRECTORY_FILE));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
 
 	merge_opts.file_favor = 0;
-	cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 20));
 
 	git_reference_free(head);
 	git_commit_free(head_commit);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 void test_merge_workdir_simple__unrelated(void)
 {
 	git_oid their_oids[1];
-	git_merge_head *their_heads[1];
+	git_annotated_commit *their_heads[1];
 	git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -550,20 +550,20 @@ void test_merge_workdir_simple__unrelated(void)
 	};
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_PARENT));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
 
 	merge_opts.file_favor = 0;
-	cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 9));
 
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 void test_merge_workdir_simple__unrelated_with_conflicts(void)
 {
 	git_oid their_oids[1];
-	git_merge_head *their_heads[1];
+	git_annotated_commit *their_heads[1];
 	git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -581,21 +581,21 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
 	};
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_OID));
-	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
+	cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
 
 	merge_opts.file_favor = 0;
-	cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 11));
 
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[0]);
 }
 
 void test_merge_workdir_simple__binary(void)
 {
 	git_oid our_oid, their_oid, our_file_oid;
 	git_commit *our_commit;
-	git_merge_head *their_head;
+	git_annotated_commit *their_head;
 	const git_index_entry *binary_entry;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -610,9 +610,9 @@ void test_merge_workdir_simple__binary(void)
 	cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
 	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL, NULL));
 
-	cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
+	cl_git_pass(git_annotated_commit_lookup(&their_head, repo, &their_oid));
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_head, 1, NULL, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 3));
 
@@ -622,6 +622,6 @@ void test_merge_workdir_simple__binary(void)
 	cl_git_pass(git_oid_fromstr(&our_file_oid, "23ed141a6ae1e798b2f721afedbe947c119111ba"));
 	cl_assert(git_oid_cmp(&binary_entry->id, &our_file_oid) == 0);
 
-	git_merge_head_free(their_head);
+	git_annotated_commit_free(their_head);
 	git_commit_free(our_commit);
 }
diff --git a/tests/merge/workdir/submodules.c b/tests/merge/workdir/submodules.c
index eec9f14..31ded46 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/merge/workdir/submodules.c
@@ -30,7 +30,7 @@ void test_merge_workdir_submodules__automerge(void)
 {
 	git_reference *our_ref, *their_ref;
 	git_commit *our_commit;
-	git_merge_head *their_head;
+	git_annotated_commit *their_head;
 	git_index *index;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -47,15 +47,15 @@ void test_merge_workdir_submodules__automerge(void)
 	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL, NULL));
 
 	cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_head, 1, NULL, NULL));
 
 	cl_git_pass(git_repository_index(&index, repo));
 	cl_assert(merge_test_index(index, merge_index_entries, 6));
 
 	git_index_free(index);
-	git_merge_head_free(their_head);
+	git_annotated_commit_free(their_head);
 	git_commit_free(our_commit);
 	git_reference_free(their_ref);
 	git_reference_free(our_ref);
@@ -65,7 +65,7 @@ void test_merge_workdir_submodules__take_changed(void)
 {
 	git_reference *our_ref, *their_ref;
 	git_commit *our_commit;
-	git_merge_head *their_head;
+	git_annotated_commit *their_head;
 	git_index *index;
 
 	struct merge_index_entry merge_index_entries[] = {
@@ -80,15 +80,15 @@ void test_merge_workdir_submodules__take_changed(void)
 	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL, NULL));
 
 	cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
-	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_head, 1, NULL, NULL));
 
 	cl_git_pass(git_repository_index(&index, repo));
 	cl_assert(merge_test_index(index, merge_index_entries, 4));
 
 	git_index_free(index);
-	git_merge_head_free(their_head);
+	git_annotated_commit_free(their_head);
 	git_commit_free(our_commit);
 	git_reference_free(their_ref);
 	git_reference_free(our_ref);
diff --git a/tests/merge/workdir/trivial.c b/tests/merge/workdir/trivial.c
index cc82d99..fa261c3 100644
--- a/tests/merge/workdir/trivial.c
+++ b/tests/merge/workdir/trivial.c
@@ -33,7 +33,7 @@ static int merge_trivial(const char *ours, const char *theirs)
 	git_buf branch_buf = GIT_BUF_INIT;
 	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
 	git_reference *our_ref, *their_ref;
-	git_merge_head *their_heads[1];
+	git_annotated_commit *their_heads[1];
 
 	checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
 
@@ -45,14 +45,14 @@ static int merge_trivial(const char *ours, const char *theirs)
 	git_buf_clear(&branch_buf);
 	git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
 	cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr));
-	cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, their_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, their_ref));
 
-	cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
+	cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, NULL, NULL));
 
 	git_buf_free(&branch_buf);
 	git_reference_free(our_ref);
 	git_reference_free(their_ref);
-	git_merge_head_free(their_heads[0]);
+	git_annotated_commit_free(their_heads[0]);
 
 	return 0;
 }
diff --git a/tests/rebase/abort.c b/tests/rebase/abort.c
new file mode 100644
index 0000000..7132643
--- /dev/null
+++ b/tests/rebase/abort.c
@@ -0,0 +1,158 @@
+#include "clar_libgit2.h"
+#include "git2/rebase.h"
+#include "merge.h"
+#include "posix.h"
+#include "annotated_commit.h"
+
+#include <fcntl.h>
+
+static git_repository *repo;
+
+// Fixture setup and teardown
+void test_rebase_abort__initialize(void)
+{
+	repo = cl_git_sandbox_init("rebase");
+}
+
+void test_rebase_abort__cleanup(void)
+{
+	cl_git_sandbox_cleanup();
+}
+
+static void test_abort(git_annotated_commit *branch, git_annotated_commit *onto)
+{
+	git_rebase *rebase;
+	git_reference *head_ref, *branch_ref = NULL;
+	git_signature *signature;
+	git_status_list *statuslist;
+	git_reflog *reflog;
+	const git_reflog_entry *reflog_entry;
+
+	cl_git_pass(git_rebase_open(&rebase, repo));
+	cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
+	cl_git_pass(git_rebase_abort(rebase, signature));
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	/* Make sure the refs are updated appropriately */
+	cl_git_pass(git_reference_lookup(&head_ref, repo, "HEAD"));
+
+	if (branch->ref_name == NULL)
+		cl_assert_equal_oid(git_annotated_commit_id(branch), git_reference_target(head_ref));
+	else {
+		cl_assert_equal_s("refs/heads/beef", git_reference_symbolic_target(head_ref));
+		cl_git_pass(git_reference_lookup(&branch_ref, repo, git_reference_symbolic_target(head_ref)));
+		cl_assert_equal_oid(git_annotated_commit_id(branch), git_reference_target(branch_ref));
+	}
+
+	git_status_list_new(&statuslist, repo, NULL);
+	cl_assert_equal_i(0, git_status_list_entrycount(statuslist));
+	git_status_list_free(statuslist);
+
+	/* Make sure the reflogs are updated appropriately */
+	cl_git_pass(git_reflog_read(&reflog, repo, "HEAD"));
+
+	cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
+	cl_assert_equal_oid(git_annotated_commit_id(onto), git_reflog_entry_id_old(reflog_entry));
+	cl_assert_equal_oid(git_annotated_commit_id(branch), git_reflog_entry_id_new(reflog_entry));
+	cl_assert_equal_s("rebase: aborting", git_reflog_entry_message(reflog_entry));
+
+	git_reflog_free(reflog);
+	git_reference_free(head_ref);
+	git_reference_free(branch_ref);
+	git_signature_free(signature);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_abort__merge(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *onto_ref;
+	git_signature *signature;
+	git_annotated_commit *branch_head, *onto_head;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
+
+	cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, signature, NULL));
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	test_abort(branch_head, onto_head);
+
+	git_signature_free(signature);
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(onto_head);
+
+	git_reference_free(branch_ref);
+	git_reference_free(onto_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_abort__detached_head(void)
+{
+	git_rebase *rebase;
+	git_oid branch_id;
+	git_reference *onto_ref;
+	git_signature *signature;
+	git_annotated_commit *branch_head, *onto_head;
+
+	git_oid_fromstr(&branch_id, "b146bd7608eac53d9bf9e1a6963543588b555c64");
+	cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_lookup(&branch_head, repo, &branch_id));
+	cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
+
+	cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, signature, NULL));
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	test_abort(branch_head, onto_head);
+
+	git_signature_free(signature);
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(onto_head);
+
+	git_reference_free(onto_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_abort__old_style_head_file(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *onto_ref;
+	git_signature *signature;
+	git_annotated_commit *branch_head, *onto_head;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
+
+	cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, signature, NULL));
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	p_rename("rebase-merge/.git/rebase-merge/orig-head",
+		"rebase-merge/.git/rebase-merge/head");
+
+	test_abort(branch_head, onto_head);
+
+	git_signature_free(signature);
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(onto_head);
+
+	git_reference_free(branch_ref);
+	git_reference_free(onto_ref);
+	git_rebase_free(rebase);
+}
diff --git a/tests/rebase/iterator.c b/tests/rebase/iterator.c
new file mode 100644
index 0000000..ddf4413
--- /dev/null
+++ b/tests/rebase/iterator.c
@@ -0,0 +1,108 @@
+#include "clar_libgit2.h"
+#include "git2/rebase.h"
+#include "posix.h"
+
+#include <fcntl.h>
+
+static git_repository *repo;
+static git_index *_index;
+static git_signature *signature;
+
+// Fixture setup and teardown
+void test_rebase_iterator__initialize(void)
+{
+	repo = cl_git_sandbox_init("rebase");
+	cl_git_pass(git_repository_index(&_index, repo));
+	cl_git_pass(git_signature_now(&signature, "Rebaser", "rebaser@rebaser.rb"));
+}
+
+void test_rebase_iterator__cleanup(void)
+{
+	git_signature_free(signature);
+	git_index_free(_index);
+	cl_git_sandbox_cleanup();
+}
+
+static void test_operations(git_rebase *rebase, size_t expected_current)
+{
+	size_t i, expected_count = 5;
+	git_oid expected_oid[5];
+	git_rebase_operation *operation;
+
+	git_oid_fromstr(&expected_oid[0], "da9c51a23d02d931a486f45ad18cda05cf5d2b94");
+	git_oid_fromstr(&expected_oid[1], "8d1f13f93c4995760ac07d129246ac1ff64c0be9");
+	git_oid_fromstr(&expected_oid[2], "3069cc907e6294623e5917ef6de663928c1febfb");
+	git_oid_fromstr(&expected_oid[3], "588e5d2f04d49707fe4aab865e1deacaf7ef6787");
+	git_oid_fromstr(&expected_oid[4], "b146bd7608eac53d9bf9e1a6963543588b555c64");
+
+	cl_assert_equal_i(expected_count, git_rebase_operation_entrycount(rebase));
+	cl_assert_equal_i(expected_current, git_rebase_operation_current(rebase));
+
+	for (i = 0; i < expected_count; i++) {
+		operation = git_rebase_operation_byindex(rebase, i);
+		cl_assert_equal_i(GIT_REBASE_OPERATION_PICK, operation->type);
+		cl_assert_equal_oid(&expected_oid[i], &operation->id);
+	}
+}
+
+void test_rebase_iterator__iterates(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid commit_id;
+	int error;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+	test_operations(rebase, 0);
+	git_rebase_free(rebase);
+
+	cl_git_pass(git_rebase_open(&rebase, repo));
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+	test_operations(rebase, 0);
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+	test_operations(rebase, 1);
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+	test_operations(rebase, 2);
+
+	git_rebase_free(rebase);
+	cl_git_pass(git_rebase_open(&rebase, repo));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+	test_operations(rebase, 3);
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+	test_operations(rebase, 4);
+
+	cl_git_fail(error = git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_assert_equal_i(GIT_ITEROVER, error);
+	test_operations(rebase, 4);
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
new file mode 100644
index 0000000..e7eb167
--- /dev/null
+++ b/tests/rebase/merge.c
@@ -0,0 +1,487 @@
+#include "clar_libgit2.h"
+#include "git2/rebase.h"
+#include "posix.h"
+#include "signature.h"
+
+#include <fcntl.h>
+
+static git_repository *repo;
+static git_signature *signature;
+
+// Fixture setup and teardown
+void test_rebase_merge__initialize(void)
+{
+	repo = cl_git_sandbox_init("rebase");
+	cl_git_pass(git_signature_new(&signature,
+		"Rebaser", "rebaser@rebaser.rb", 1405694510, 0));
+}
+
+void test_rebase_merge__cleanup(void)
+{
+	git_signature_free(signature);
+	cl_git_sandbox_cleanup();
+}
+
+void test_rebase_merge__next(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_status_list *status_list;
+	const git_status_entry *status_entry;
+	git_oid pick_id, file1_id;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+
+	git_oid_fromstr(&pick_id, "da9c51a23d02d931a486f45ad18cda05cf5d2b94");
+
+	cl_assert_equal_i(GIT_REBASE_OPERATION_PICK, rebase_operation->type);
+	cl_assert_equal_oid(&pick_id, &rebase_operation->id);
+	cl_assert_equal_file("da9c51a23d02d931a486f45ad18cda05cf5d2b94\n", 41, "rebase/.git/rebase-merge/current");
+	cl_assert_equal_file("1\n", 2, "rebase/.git/rebase-merge/msgnum");
+
+	cl_git_pass(git_status_list_new(&status_list, repo, NULL));
+	cl_assert_equal_i(1, git_status_list_entrycount(status_list));
+	cl_assert(status_entry = git_status_byindex(status_list, 0));
+
+	cl_assert_equal_s("beef.txt", status_entry->head_to_index->new_file.path);
+
+	git_oid_fromstr(&file1_id, "8d95ea62e621f1d38d230d9e7d206e41096d76af");
+	cl_assert_equal_oid(&file1_id, &status_entry->head_to_index->new_file.id);
+
+	git_status_list_free(status_list);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__next_with_conflicts(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_status_list *status_list;
+	const git_status_entry *status_entry;
+	git_oid pick_id;
+
+	const char *expected_merge =
+"ASPARAGUS SOUP.\n"
+"\n"
+"<<<<<<< master\n"
+"TAKE FOUR LARGE BUNCHES of asparagus, scrape it nicely, cut off one inch\n"
+"OF THE TOPS, and lay them in water, chop the stalks and put them on the\n"
+"FIRE WITH A PIECE OF BACON, a large onion cut up, and pepper and salt;\n"
+"ADD TWO QUARTS OF WATER, boil them till the stalks are quite soft, then\n"
+"PULP THEM THROUGH A SIEVE, and strain the water to it, which must be put\n"
+"=======\n"
+"Take four large bunches of asparagus, scrape it nicely, CUT OFF ONE INCH\n"
+"of the tops, and lay them in water, chop the stalks and PUT THEM ON THE\n"
+"fire with a piece of bacon, a large onion cut up, and pepper and salt;\n"
+"add two quarts of water, boil them till the stalks are quite soft, then\n"
+"pulp them through a sieve, and strain the water to it, which must be put\n"
+">>>>>>> Conflicting modification 1 to asparagus\n"
+"back in the pot; put into it a chicken cut up, with the tops of\n"
+"asparagus which had been laid by, boil it until these last articles are\n"
+"sufficiently done, thicken with flour, butter and milk, and serve it up.\n";
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/asparagus"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+
+	git_oid_fromstr(&pick_id, "33f915f9e4dbd9f4b24430e48731a59b45b15500");
+
+	cl_assert_equal_i(GIT_REBASE_OPERATION_PICK, rebase_operation->type);
+	cl_assert_equal_oid(&pick_id, &rebase_operation->id);
+	cl_assert_equal_file("33f915f9e4dbd9f4b24430e48731a59b45b15500\n", 41, "rebase/.git/rebase-merge/current");
+	cl_assert_equal_file("1\n", 2, "rebase/.git/rebase-merge/msgnum");
+
+	cl_git_pass(git_status_list_new(&status_list, repo, NULL));
+	cl_assert_equal_i(1, git_status_list_entrycount(status_list));
+	cl_assert(status_entry = git_status_byindex(status_list, 0));
+
+	cl_assert_equal_s("asparagus.txt", status_entry->head_to_index->new_file.path);
+
+	cl_assert_equal_file(expected_merge, strlen(expected_merge), "rebase/asparagus.txt");
+
+	git_status_list_free(status_list);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__next_stops_with_iterover(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid commit_id;
+	int error;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_fail(error = git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_assert_equal_i(GIT_ITEROVER, error);
+
+	cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/end");
+	cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/msgnum");
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__commit(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid commit_id, tree_id, parent_id;
+	git_signature *author;
+	git_commit *commit;
+	git_reflog *reflog;
+	const git_reflog_entry *reflog_entry;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
+
+	git_oid_fromstr(&parent_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
+	cl_assert_equal_i(1, git_commit_parentcount(commit));
+	cl_assert_equal_oid(&parent_id, git_commit_parent_id(commit, 0));
+
+	git_oid_fromstr(&tree_id, "4461379789c777d2a6c1f2ee0e9d6c86731b9992");
+	cl_assert_equal_oid(&tree_id, git_commit_tree_id(commit));
+
+	cl_assert_equal_s(NULL, git_commit_message_encoding(commit));
+	cl_assert_equal_s("Modification 1 to beef\n", git_commit_message(commit));
+
+	cl_git_pass(git_signature_new(&author,
+		"Edward Thomson", "ethomson@edwardthomson.com", 1405621769, 0-(4*60)));
+	cl_assert(git_signature__equal(author, git_commit_author(commit)));
+
+	cl_assert(git_signature__equal(signature, git_commit_committer(commit)));
+
+	/* Make sure the reflogs are updated appropriately */
+	cl_git_pass(git_reflog_read(&reflog, repo, "HEAD"));
+	cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
+	cl_assert_equal_oid(&parent_id, git_reflog_entry_id_old(reflog_entry));
+	cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
+	cl_assert_equal_s("rebase: Modification 1 to beef", git_reflog_entry_message(reflog_entry));
+
+	git_reflog_free(reflog);
+	git_signature_free(author);
+	git_commit_free(commit);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__commit_updates_rewritten(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid commit_id;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_assert_equal_file(
+		"da9c51a23d02d931a486f45ad18cda05cf5d2b94 776e4c48922799f903f03f5f6e51da8b01e4cce0\n"
+		"8d1f13f93c4995760ac07d129246ac1ff64c0be9 ba1f9b4fd5cf8151f7818be2111cc0869f1eb95a\n",
+		164, "rebase/.git/rebase-merge/rewritten");
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__commit_drops_already_applied(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid commit_id;
+	int error;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/green_pea"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_fail(error = git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_assert_equal_i(GIT_EAPPLIED, error);
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_assert_equal_file(
+		"8d1f13f93c4995760ac07d129246ac1ff64c0be9 2ac4fb7b74c1287f6c792acad759e1ec01e18dae\n",
+		82, "rebase/.git/rebase-merge/rewritten");
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__finish(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref, *head_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid commit_id;
+	git_reflog *reflog;
+	const git_reflog_entry *reflog_entry;
+	int error;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/gravy"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_fail(error = git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_assert_equal_i(GIT_ITEROVER, error);
+
+	cl_git_pass(git_rebase_finish(rebase, signature, NULL));
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&head_ref, repo, "HEAD"));
+	cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head_ref));
+	cl_assert_equal_s("refs/heads/gravy", git_reference_symbolic_target(head_ref));
+
+	/* Make sure the reflogs are updated appropriately */
+	cl_git_pass(git_reflog_read(&reflog, repo, "HEAD"));
+	cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
+	cl_assert_equal_oid(&commit_id, git_reflog_entry_id_old(reflog_entry));
+	cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
+	cl_assert_equal_s("rebase finished: returning to refs/heads/gravy", git_reflog_entry_message(reflog_entry));
+	git_reflog_free(reflog);
+
+	cl_git_pass(git_reflog_read(&reflog, repo, "refs/heads/gravy"));
+	cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
+	cl_assert_equal_oid(git_annotated_commit_id(branch_head), git_reflog_entry_id_old(reflog_entry));
+	cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
+	cl_assert_equal_s("rebase finished: refs/heads/gravy onto f87d14a4a236582a0278a916340a793714256864", git_reflog_entry_message(reflog_entry));
+
+	git_reflog_free(reflog);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(head_ref);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+static void test_copy_note(
+	const git_rebase_options *opts,
+	bool should_exist)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_commit *branch_commit;
+	git_rebase_operation *rebase_operation;
+	git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+	git_oid note_id, commit_id;
+	git_note *note = NULL;
+	int error;
+
+	checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/gravy"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_reference_peel((git_object **)&branch_commit,
+		branch_ref, GIT_OBJ_COMMIT));
+
+	/* Add a note to a commit */
+	cl_git_pass(git_note_create(&note_id, repo,
+		git_commit_author(branch_commit), git_commit_committer(branch_commit),
+		"refs/notes/test", git_commit_id(branch_commit),
+		"This is a commit note.", 0));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, opts));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_finish(rebase, signature, opts));
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	if (should_exist) {
+		cl_git_pass(git_note_read(&note, repo, "refs/notes/test", &commit_id));
+		cl_assert_equal_s("This is a commit note.", git_note_message(note));
+	} else {
+		cl_git_fail(error =
+			git_note_read(&note, repo, "refs/notes/test", &commit_id));
+		cl_assert_equal_i(GIT_ENOTFOUND, error);
+	}
+
+	git_note_free(note);
+	git_commit_free(branch_commit);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+void test_rebase_merge__copy_notes_off_by_default(void)
+{
+	test_copy_note(NULL, 0);
+}
+
+void test_rebase_merge__copy_notes_specified_in_options(void)
+{
+	git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
+	opts.rewrite_notes_ref = "refs/notes/test";
+
+	test_copy_note(&opts, 1);
+}
+
+void test_rebase_merge__copy_notes_specified_in_config(void)
+{
+	git_config *config;
+
+	cl_git_pass(git_repository_config(&config, repo));
+	cl_git_pass(git_config_set_string(config,
+		"notes.rewriteRef", "refs/notes/test"));
+
+	test_copy_note(NULL, 1);
+}
+
+void test_rebase_merge__copy_notes_disabled_in_config(void)
+{
+	git_config *config;
+
+	cl_git_pass(git_repository_config(&config, repo));
+	cl_git_pass(git_config_set_bool(config, "notes.rewrite.rebase", 0));
+	cl_git_pass(git_config_set_string(config,
+		"notes.rewriteRef", "refs/notes/test"));
+
+	test_copy_note(NULL, 0);
+}
+
diff --git a/tests/rebase/setup.c b/tests/rebase/setup.c
new file mode 100644
index 0000000..c81ca12
--- /dev/null
+++ b/tests/rebase/setup.c
@@ -0,0 +1,342 @@
+#include "clar_libgit2.h"
+#include "git2/rebase.h"
+#include "posix.h"
+
+#include <fcntl.h>
+
+static git_repository *repo;
+static git_index *_index;
+static git_signature *signature;
+
+// Fixture setup and teardown
+void test_rebase_setup__initialize(void)
+{
+	repo = cl_git_sandbox_init("rebase");
+	cl_git_pass(git_repository_index(&_index, repo));
+	cl_git_pass(git_signature_now(&signature, "Rebaser", "rebaser@rebaser.rb"));
+}
+
+void test_rebase_setup__cleanup(void)
+{
+	git_signature_free(signature);
+	git_index_free(_index);
+	cl_git_sandbox_cleanup();
+}
+
+/* git checkout beef ; git rebase --merge master
+ * git checkout beef ; git rebase --merge master */
+void test_rebase_setup__blocked_when_in_progress(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+	git_rebase_free(rebase);
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	cl_git_fail(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+}
+
+/* git checkout beef ; git rebase --merge master */
+void test_rebase_setup__merge(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_reference *head;
+	git_commit *head_commit;
+	git_oid head_id;
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
+	cl_git_pass(git_repository_head(&head, repo));
+	cl_git_pass(git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT));
+	cl_assert_equal_oid(&head_id, git_commit_id(head_commit));
+
+	cl_assert_equal_file("b146bd7608eac53d9bf9e1a6963543588b555c64\n", 41, "rebase/.git/ORIG_HEAD");
+
+	cl_assert_equal_file("da9c51a23d02d931a486f45ad18cda05cf5d2b94\n", 41, "rebase/.git/rebase-merge/cmt.1");
+	cl_assert_equal_file("8d1f13f93c4995760ac07d129246ac1ff64c0be9\n", 41, "rebase/.git/rebase-merge/cmt.2");
+	cl_assert_equal_file("3069cc907e6294623e5917ef6de663928c1febfb\n", 41, "rebase/.git/rebase-merge/cmt.3");
+	cl_assert_equal_file("588e5d2f04d49707fe4aab865e1deacaf7ef6787\n", 41, "rebase/.git/rebase-merge/cmt.4");
+	cl_assert_equal_file("b146bd7608eac53d9bf9e1a6963543588b555c64\n", 41, "rebase/.git/rebase-merge/cmt.5");
+	cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/end");
+	cl_assert_equal_file("efad0b11c47cb2f0220cbd6f5b0f93bb99064b00\n", 41, "rebase/.git/rebase-merge/onto");
+	cl_assert_equal_file("master\n", 7, "rebase/.git/rebase-merge/onto_name");
+	cl_assert_equal_file("b146bd7608eac53d9bf9e1a6963543588b555c64\n", 41, "rebase/.git/rebase-merge/orig-head");
+
+	git_commit_free(head_commit);
+	git_reference_free(head);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+/* git checkout beef && git rebase --merge --root --onto master */
+void test_rebase_setup__merge_root(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *onto_ref;
+	git_annotated_commit *branch_head, *onto_head;
+	git_reference *head;
+	git_commit *head_commit;
+	git_oid head_id;
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, signature, NULL));
+
+	git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
+	cl_git_pass(git_repository_head(&head, repo));
+	cl_git_pass(git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT));
+	cl_assert_equal_oid(&head_id, git_commit_id(head_commit));
+
+	cl_assert_equal_file("b146bd7608eac53d9bf9e1a6963543588b555c64\n", 41, "rebase/.git/ORIG_HEAD");
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	cl_assert_equal_file("da9c51a23d02d931a486f45ad18cda05cf5d2b94\n", 41, "rebase/.git/rebase-merge/cmt.1");
+	cl_assert_equal_file("8d1f13f93c4995760ac07d129246ac1ff64c0be9\n", 41, "rebase/.git/rebase-merge/cmt.2");
+	cl_assert_equal_file("3069cc907e6294623e5917ef6de663928c1febfb\n", 41, "rebase/.git/rebase-merge/cmt.3");
+	cl_assert_equal_file("588e5d2f04d49707fe4aab865e1deacaf7ef6787\n", 41, "rebase/.git/rebase-merge/cmt.4");
+	cl_assert_equal_file("b146bd7608eac53d9bf9e1a6963543588b555c64\n", 41, "rebase/.git/rebase-merge/cmt.5");
+	cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/end");
+	cl_assert_equal_file("efad0b11c47cb2f0220cbd6f5b0f93bb99064b00\n", 41, "rebase/.git/rebase-merge/onto");
+	cl_assert_equal_file("master\n", 7, "rebase/.git/rebase-merge/onto_name");
+	cl_assert_equal_file("b146bd7608eac53d9bf9e1a6963543588b555c64\n", 41, "rebase/.git/rebase-merge/orig-head");
+
+	git_commit_free(head_commit);
+	git_reference_free(head);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(onto_head);
+	git_reference_free(branch_ref);
+	git_reference_free(onto_ref);
+	git_rebase_free(rebase);
+}
+
+/* git checkout gravy && git rebase --merge --onto master veal */
+void test_rebase_setup__merge_onto_and_upstream(void)
+{
+	git_rebase *rebase;
+	git_reference *branch1_ref, *branch2_ref, *onto_ref;
+	git_annotated_commit *branch1_head, *branch2_head, *onto_head;
+	git_reference *head;
+	git_commit *head_commit;
+	git_oid head_id;
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&branch1_ref, repo, "refs/heads/gravy"));
+	cl_git_pass(git_reference_lookup(&branch2_ref, repo, "refs/heads/veal"));
+	cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch1_head, repo, branch1_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&branch2_head, repo, branch2_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch1_head, branch2_head, onto_head, signature, NULL));
+
+	git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
+	cl_git_pass(git_repository_head(&head, repo));
+	cl_git_pass(git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT));
+	cl_assert_equal_oid(&head_id, git_commit_id(head_commit));
+
+	cl_assert_equal_file("d616d97082eb7bb2dc6f180a7cca940993b7a56f\n", 41, "rebase/.git/ORIG_HEAD");
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	cl_assert_equal_file("d616d97082eb7bb2dc6f180a7cca940993b7a56f\n", 41, "rebase/.git/rebase-merge/cmt.1");
+	cl_assert_equal_file("1\n", 2, "rebase/.git/rebase-merge/end");
+	cl_assert_equal_file("efad0b11c47cb2f0220cbd6f5b0f93bb99064b00\n", 41, "rebase/.git/rebase-merge/onto");
+	cl_assert_equal_file("master\n", 7, "rebase/.git/rebase-merge/onto_name");
+	cl_assert_equal_file("d616d97082eb7bb2dc6f180a7cca940993b7a56f\n", 41, "rebase/.git/rebase-merge/orig-head");
+
+	git_commit_free(head_commit);
+	git_reference_free(head);
+	git_annotated_commit_free(branch1_head);
+	git_annotated_commit_free(branch2_head);
+	git_annotated_commit_free(onto_head);
+	git_reference_free(branch1_ref);
+	git_reference_free(branch2_ref);
+	git_reference_free(onto_ref);
+	git_rebase_free(rebase);
+}
+
+/* Ensure merge commits are dropped in a rebase */
+/* git checkout veal && git rebase --merge master */
+void test_rebase_setup__branch_with_merges(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_reference *head;
+	git_commit *head_commit;
+	git_oid head_id;
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/veal"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
+	cl_git_pass(git_repository_head(&head, repo));
+	cl_git_pass(git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT));
+	cl_assert_equal_oid(&head_id, git_commit_id(head_commit));
+
+	cl_assert_equal_file("f87d14a4a236582a0278a916340a793714256864\n", 41, "rebase/.git/ORIG_HEAD");
+
+	cl_assert_equal_file("4bed71df7017283cac61bbf726197ad6a5a18b84\n", 41, "rebase/.git/rebase-merge/cmt.1");
+	cl_assert_equal_file("2aa3ce842094e08ebac152b3d6d5b0fff39f9c6e\n", 41, "rebase/.git/rebase-merge/cmt.2");
+	cl_assert_equal_file("3e8989b5a16d5258c935d998ef0e6bb139cc4757\n", 41, "rebase/.git/rebase-merge/cmt.3");
+	cl_assert_equal_file("4cacc6f6e740a5bc64faa33e04b8ef0733d8a127\n", 41, "rebase/.git/rebase-merge/cmt.4");
+	cl_assert_equal_file("f87d14a4a236582a0278a916340a793714256864\n", 41, "rebase/.git/rebase-merge/cmt.5");
+	cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/end");
+	cl_assert_equal_file("efad0b11c47cb2f0220cbd6f5b0f93bb99064b00\n", 41, "rebase/.git/rebase-merge/onto");
+	cl_assert_equal_file("master\n", 7, "rebase/.git/rebase-merge/onto_name");
+	cl_assert_equal_file("f87d14a4a236582a0278a916340a793714256864\n", 41, "rebase/.git/rebase-merge/orig-head");
+
+	git_commit_free(head_commit);
+	git_reference_free(head);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+/* git checkout barley && git rebase --merge master */
+void test_rebase_setup__orphan_branch(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_reference *head;
+	git_commit *head_commit;
+	git_oid head_id;
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/barley"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+	cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
+
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+	git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
+	cl_git_pass(git_repository_head(&head, repo));
+	cl_git_pass(git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT));
+	cl_assert_equal_oid(&head_id, git_commit_id(head_commit));
+
+	cl_assert_equal_file("12c084412b952396962eb420716df01022b847cc\n", 41, "rebase/.git/ORIG_HEAD");
+
+	cl_assert_equal_file("aa4c42aecdfc7cd989bbc3209934ea7cda3f4d88\n", 41, "rebase/.git/rebase-merge/cmt.1");
+	cl_assert_equal_file("e4f809f826c1a9fc929874bc0e4644dd2f2a1af4\n", 41, "rebase/.git/rebase-merge/cmt.2");
+	cl_assert_equal_file("9539b2cc291d6a6b1b266df8474d31fdd344dd79\n", 41, "rebase/.git/rebase-merge/cmt.3");
+	cl_assert_equal_file("013cc32d341bab0e6f039f50f153c18986f16c58\n", 41, "rebase/.git/rebase-merge/cmt.4");
+	cl_assert_equal_file("12c084412b952396962eb420716df01022b847cc\n", 41, "rebase/.git/rebase-merge/cmt.5");
+	cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/end");
+	cl_assert_equal_file("efad0b11c47cb2f0220cbd6f5b0f93bb99064b00\n", 41, "rebase/.git/rebase-merge/onto");
+	cl_assert_equal_file("master\n", 7, "rebase/.git/rebase-merge/onto_name");
+	cl_assert_equal_file("12c084412b952396962eb420716df01022b847cc\n", 41, "rebase/.git/rebase-merge/orig-head");
+
+	git_commit_free(head_commit);
+	git_reference_free(head);
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+}
+
+static int rebase_is_blocked(void)
+{
+	git_rebase *rebase = NULL;
+	int error;
+
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+				 
+	cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+						  
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+								   
+	cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+	cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+												    
+	error = git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL);
+
+	git_annotated_commit_free(branch_head);
+	git_annotated_commit_free(upstream_head);
+
+	git_reference_free(branch_ref);
+	git_reference_free(upstream_ref);
+	git_rebase_free(rebase);
+
+	return error;
+}
+
+void test_rebase_setup__blocked_for_staged_change(void)
+{
+	cl_git_rewritefile("rebase/newfile.txt", "Stage an add");
+	git_index_add_bypath(_index, "newfile.txt");
+	cl_git_fail(rebase_is_blocked());
+}
+
+void test_rebase_setup__blocked_for_unstaged_change(void)
+{
+	cl_git_rewritefile("rebase/asparagus.txt", "Unstaged change");
+	cl_git_fail(rebase_is_blocked());
+}
+
+void test_rebase_setup__not_blocked_for_untracked_add(void)
+{
+	cl_git_rewritefile("rebase/newfile.txt", "Untracked file");
+	cl_git_pass(rebase_is_blocked());
+}
+
diff --git a/tests/resources/rebase/.gitted/HEAD b/tests/resources/rebase/.gitted/HEAD
new file mode 100644
index 0000000..cb089cd
--- /dev/null
+++ b/tests/resources/rebase/.gitted/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests/resources/rebase/.gitted/config b/tests/resources/rebase/.gitted/config
new file mode 100644
index 0000000..17e58b1
--- /dev/null
+++ b/tests/resources/rebase/.gitted/config
@@ -0,0 +1,4 @@
+[core]
+	repositoryformatversion = 0
+	bare = false
+	logallrefupdates = true
diff --git a/tests/resources/rebase/.gitted/index b/tests/resources/rebase/.gitted/index
new file mode 100644
index 0000000..0f53a21
Binary files /dev/null and b/tests/resources/rebase/.gitted/index differ
diff --git a/tests/resources/rebase/.gitted/info/exclude b/tests/resources/rebase/.gitted/info/exclude
new file mode 100644
index 0000000..a5196d1
--- /dev/null
+++ b/tests/resources/rebase/.gitted/info/exclude
@@ -0,0 +1,6 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
diff --git a/tests/resources/rebase/.gitted/logs/HEAD b/tests/resources/rebase/.gitted/logs/HEAD
new file mode 100644
index 0000000..62d3b16
--- /dev/null
+++ b/tests/resources/rebase/.gitted/logs/HEAD
@@ -0,0 +1 @@
+efad0b11c47cb2f0220cbd6f5b0f93bb99064b00 efad0b11c47cb2f0220cbd6f5b0f93bb99064b00 Edward Thomson <ethomson@edwardthomson.com> 1405623541 -0400	checkout: moving from master to master
diff --git a/tests/resources/rebase/.gitted/objects/00/66204dd469ee930e551fbcf123f98e211c99ce b/tests/resources/rebase/.gitted/objects/00/66204dd469ee930e551fbcf123f98e211c99ce
new file mode 100644
index 0000000..e6f72ce
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/00/66204dd469ee930e551fbcf123f98e211c99ce differ
diff --git a/tests/resources/rebase/.gitted/objects/00/f1b9a0948a7d5d14405eba6030efcdfbb8ff4a b/tests/resources/rebase/.gitted/objects/00/f1b9a0948a7d5d14405eba6030efcdfbb8ff4a
new file mode 100644
index 0000000..a23f526
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/00/f1b9a0948a7d5d14405eba6030efcdfbb8ff4a
@@ -0,0 +1,3 @@
+x¥ŽAnC!D»æ¾@*À𑪪YäÙGå/~ˆ(U¯ZåÙͼ‘f¦´}ßX
+o£«B%
+BU«#DGa‘‚9øì"R”H~±.-HæÎ]o˜}ñ–µH-±HZSÎÅYLÉyåIØU/ëjøg\[‡“ür8_ÛþÝnð¡“þ©/ýžî½´ýì¼fá€ÑL:Ï}±ÆE¶±ÍùVAú¦r¹+›øT
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/01/3cc32d341bab0e6f039f50f153c18986f16c58 b/tests/resources/rebase/.gitted/objects/01/3cc32d341bab0e6f039f50f153c18986f16c58
new file mode 100644
index 0000000..2e32bd3
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/01/3cc32d341bab0e6f039f50f153c18986f16c58 differ
diff --git a/tests/resources/rebase/.gitted/objects/01/a17f7d154ab5bf9f8bfede3d82dd00ddf7e7dc b/tests/resources/rebase/.gitted/objects/01/a17f7d154ab5bf9f8bfede3d82dd00ddf7e7dc
new file mode 100644
index 0000000..c21329f
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/01/a17f7d154ab5bf9f8bfede3d82dd00ddf7e7dc differ
diff --git a/tests/resources/rebase/.gitted/objects/02/2d3b6bbd0bfbdf147319476fb8bf405691cb0d b/tests/resources/rebase/.gitted/objects/02/2d3b6bbd0bfbdf147319476fb8bf405691cb0d
new file mode 100644
index 0000000..b1f7468
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/02/2d3b6bbd0bfbdf147319476fb8bf405691cb0d differ
diff --git a/tests/resources/rebase/.gitted/objects/05/3808a709cf91385985369159b296cf61a177ac b/tests/resources/rebase/.gitted/objects/05/3808a709cf91385985369159b296cf61a177ac
new file mode 100644
index 0000000..c38c5b2
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/05/3808a709cf91385985369159b296cf61a177ac differ
diff --git a/tests/resources/rebase/.gitted/objects/0e/f2e2b2a2b8d6e1f8dff5e621e0eca21b693d0c b/tests/resources/rebase/.gitted/objects/0e/f2e2b2a2b8d6e1f8dff5e621e0eca21b693d0c
new file mode 100644
index 0000000..d8ef47c
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/0e/f2e2b2a2b8d6e1f8dff5e621e0eca21b693d0c
@@ -0,0 +1,3 @@
+x¥P»N1¤öWl—
+´g¯í³„"J:~`½^ç"åÎÈ1Aü=‚/ ›—Fš‘¶®çnrw£«B‘Y9g/U­
+¦ä“ÄJ“÷ÌÑ‘Mµ$óÆ]·$,jÐHÈ>K Êìœ"åY+FçÊÌ“y»»¢3YL¤8kf™¼Í®„â3ÖZ]ªI‚~Këð\>¸x]Úzm<ê®~£'ý1~Ùƒ´õ¡Ö:"¸GB4»ºúÏó¢ý´_Óy“§Î·Ïœ·Ñà¦|1_"fi
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/0f/5f6d3353be1a9966fa5767b7d604b051798224 b/tests/resources/rebase/.gitted/objects/0f/5f6d3353be1a9966fa5767b7d604b051798224
new file mode 100644
index 0000000..739aca3
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/0f/5f6d3353be1a9966fa5767b7d604b051798224 differ
diff --git a/tests/resources/rebase/.gitted/objects/11/fac10ca1b9318ce361a0be0c3d889d777e299c b/tests/resources/rebase/.gitted/objects/11/fac10ca1b9318ce361a0be0c3d889d777e299c
new file mode 100644
index 0000000..5af5474
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/11/fac10ca1b9318ce361a0be0c3d889d777e299c differ
diff --git a/tests/resources/rebase/.gitted/objects/12/c084412b952396962eb420716df01022b847cc b/tests/resources/rebase/.gitted/objects/12/c084412b952396962eb420716df01022b847cc
new file mode 100644
index 0000000..5244e46
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/12/c084412b952396962eb420716df01022b847cc
@@ -0,0 +1,2 @@
+x¥ŽKjC1³Ö)æúÌèIB6^z—Œ¤äYAQ0¾½ãd×Õ
Må¾ïm‚¥ø2‡¸Â8³)!–m“JÄ¡È"Œ‰ML¨¾yÈe‚6.gg‹C“8iñU»XIWC.›ƒ¯Æg
+Šç¹8–+Ÿç¾ÿô¼ÉjÿÒ‡<†'½æ¾¿ƒAMÞZô4j­V»d§üóFziµežm) ̉ǗÜÔK€U
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/12/f28ed978639d331269d9dc2b74e87db58e1057 b/tests/resources/rebase/.gitted/objects/12/f28ed978639d331269d9dc2b74e87db58e1057
new file mode 100644
index 0000000..b0dbc3e
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/12/f28ed978639d331269d9dc2b74e87db58e1057
@@ -0,0 +1,3 @@
+x¥O9nÃ0tÍWìbp)‰KF&e:`¹\Ú*$…|?´á¸›3˜‘º,sçÝ©mª€XXÐ
+cŠÑÁ#Û¤V†BÌD¤.F1¿¼éÚ€„R	“F
+sØÉûBÖe'‰Èû%ä±>Ú½nðÿxËp½×e¯+\´«ô¥OãÅÎR—OÀ±—9ôãv´Ötµmúfù©y.³p›û„V÷þ‡oÇnþB#Vj
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/19/14d57ddf6c5c997664521cc94f190df46dc1c2 b/tests/resources/rebase/.gitted/objects/19/14d57ddf6c5c997664521cc94f190df46dc1c2
new file mode 100644
index 0000000..921f2cd
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/19/14d57ddf6c5c997664521cc94f190df46dc1c2 differ
diff --git a/tests/resources/rebase/.gitted/objects/1b/1d19799fcc89fa3cb821581fcf7f2e8fd2cc4d b/tests/resources/rebase/.gitted/objects/1b/1d19799fcc89fa3cb821581fcf7f2e8fd2cc4d
new file mode 100644
index 0000000..3d206b0
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/1b/1d19799fcc89fa3cb821581fcf7f2e8fd2cc4d differ
diff --git a/tests/resources/rebase/.gitted/objects/1f/2214c1b13b134d5508f41f6a3b77cc6a8f5182 b/tests/resources/rebase/.gitted/objects/1f/2214c1b13b134d5508f41f6a3b77cc6a8f5182
new file mode 100644
index 0000000..84b875c
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/1f/2214c1b13b134d5508f41f6a3b77cc6a8f5182 differ
diff --git a/tests/resources/rebase/.gitted/objects/20/db906c85e78c6dde82eb2ec6d3231c4b96fce8 b/tests/resources/rebase/.gitted/objects/20/db906c85e78c6dde82eb2ec6d3231c4b96fce8
new file mode 100644
index 0000000..2a908da
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/20/db906c85e78c6dde82eb2ec6d3231c4b96fce8 differ
diff --git a/tests/resources/rebase/.gitted/objects/22/adb22bef75a0371e85ff6d82e5e60e4b425501 b/tests/resources/rebase/.gitted/objects/22/adb22bef75a0371e85ff6d82e5e60e4b425501
new file mode 100644
index 0000000..7f17ef0
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/22/adb22bef75a0371e85ff6d82e5e60e4b425501 differ
diff --git a/tests/resources/rebase/.gitted/objects/2a/a3ce842094e08ebac152b3d6d5b0fff39f9c6e b/tests/resources/rebase/.gitted/objects/2a/a3ce842094e08ebac152b3d6d5b0fff39f9c6e
new file mode 100644
index 0000000..38eca43
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/2a/a3ce842094e08ebac152b3d6d5b0fff39f9c6e
@@ -0,0 +1 @@
+x¥ŽMn!F³æ¾@#8RTeÓew¹€!™Å„ˆ’V½}hÕt÷ýHO/·m[¸…v£—Ñg$©H$ÄÈb…•Œ¨ÙW	>*jUÌ{¹
R4¡Öd19ò™sD‘š\ÄCb¼ðäQ0ü×ÖáM¿¸+œ¯mûh78–¹þ¤Sù=þÚ>·í0Ø%:ç-‹
Öš¹NÙQþ‰1ïM׺fëTp0\:~›'fÐUN
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/2b/4ebffd3111546d278bb5df62e5630930b605fb b/tests/resources/rebase/.gitted/objects/2b/4ebffd3111546d278bb5df62e5630930b605fb
new file mode 100644
index 0000000..5bdfc1e
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/2b/4ebffd3111546d278bb5df62e5630930b605fb differ
diff --git a/tests/resources/rebase/.gitted/objects/30/69cc907e6294623e5917ef6de663928c1febfb b/tests/resources/rebase/.gitted/objects/30/69cc907e6294623e5917ef6de663928c1febfb
new file mode 100644
index 0000000..edd86f7
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/30/69cc907e6294623e5917ef6de663928c1febfb
@@ -0,0 +1 @@
+x¥Ž;n1DSë¼€RŸ]	07.ÓåEÂ[¬eldøúÞ¾Aº™7ÀàI_×e€OóÇØT!&Æ[ËÅUö5´¹R¬L–ÑP±¸oz+Ab)ižçF¾ø8±Ù«Ç÷qéœÛƒ·?—¾þö+u§餯áÝ>¥¯_@Óä)§Œˆn§»ìÐÞ¸ïÞ[„Dz+ªª¹'TG
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/32/52a0692ace4c4c709f22011227d9dc4845f289 b/tests/resources/rebase/.gitted/objects/32/52a0692ace4c4c709f22011227d9dc4845f289
new file mode 100644
index 0000000..2b2434f
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/32/52a0692ace4c4c709f22011227d9dc4845f289 differ
diff --git a/tests/resources/rebase/.gitted/objects/33/f915f9e4dbd9f4b24430e48731a59b45b15500 b/tests/resources/rebase/.gitted/objects/33/f915f9e4dbd9f4b24430e48731a59b45b15500
new file mode 100644
index 0000000..c33f179
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/33/f915f9e4dbd9f4b24430e48731a59b45b15500
@@ -0,0 +1 @@
+x¥Ûi1Eó­*¦iViÁ„@Hi@[­Â®LÚbÜÿî.çæÞZ€Þ¾Œ0YN"e1Æ8K}HÉ!dG‹^H;Iê'î¼
ðÙ'	ŽWIJvDâ5ÌÉ{¢´æP¬¨x×¾Ãgù{¯koGßàÌ3ýWï|/î”{{cç¢F‚WmµV3°ƒŸœQ}“ïšGÝ.Ðz©Rsuââ1¿ÅËíPH¾ZÞ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/34/86a9d4cdf0b7b4a702c199eed541dc3af13a03 b/tests/resources/rebase/.gitted/objects/34/86a9d4cdf0b7b4a702c199eed541dc3af13a03
new file mode 100644
index 0000000..fdbe16d
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/34/86a9d4cdf0b7b4a702c199eed541dc3af13a03
@@ -0,0 +1 @@
+xM½nÃ0„;ë)îŒ,‚L-Э@ƒþe›Ž…Ò¢*Quüö¥…è"Ç#ï#{–÷ÇãÝãÃëóÓ'Þ^>ÎçÎU!:g"\sLè}fÚº?ù»ú¬M_½Rî0ÑjMAbÁ`ý5u®„+Ÿ³˜±Ù'áãØê!ª`u&lÞ¨A·=MkŽ!µY®,žù„^#(.•7è*˜¥æ²#QD²Ô1™ɘÂ!Ic£4‹Ë~øÚK‘öÂRU%@ƒ/l4ÍËdH³_:¬Ag$J‰r#/žõän …eý–x¹9)[¾ÑÖtÀ»,^¥Àg²1Ž®1ÛðãÔn;†ÎÁÎ$æw¿/Š
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/3c/33b080bf75724c8899d8e703614cb59bfbd047 b/tests/resources/rebase/.gitted/objects/3c/33b080bf75724c8899d8e703614cb59bfbd047
new file mode 100644
index 0000000..8716898
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/3c/33b080bf75724c8899d8e703614cb59bfbd047 differ
diff --git a/tests/resources/rebase/.gitted/objects/3d/a85aca38a95b44d77ef55a8deb445e49ba19b4 b/tests/resources/rebase/.gitted/objects/3d/a85aca38a95b44d77ef55a8deb445e49ba19b4
new file mode 100644
index 0000000..fa6d946
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/3d/a85aca38a95b44d77ef55a8deb445e49ba19b4 differ
diff --git a/tests/resources/rebase/.gitted/objects/3e/8989b5a16d5258c935d998ef0e6bb139cc4757 b/tests/resources/rebase/.gitted/objects/3e/8989b5a16d5258c935d998ef0e6bb139cc4757
new file mode 100644
index 0000000..1bbf138
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/3e/8989b5a16d5258c935d998ef0e6bb139cc4757
@@ -0,0 +1,2 @@
+x¥ŽKj1†»ö)tù1¶Jé&Ëìz%C'.®›\?nÈ
ºûðñå¶ïu€[ÒËèªPŠ¦ÕÓŠ™"åÀ›%¬Cñ¢0+›oîzrÚ
+-º&*V,e\b,	¸¼¥ã¶f’PÿŽsëp”wÏsÛÚÞt®éCdz½æ¶¿ƒ
æœwÓÍ\§ìÐbÌ©I-5ó¨SÁÂhpUþ2w_ÎT
diff --git a/tests/resources/rebase/.gitted/objects/3f/05a038dd89f51ba2b3d7b14ba1f8c00f0e31ac b/tests/resources/rebase/.gitted/objects/3f/05a038dd89f51ba2b3d7b14ba1f8c00f0e31ac
new file mode 100644
index 0000000..26bd353
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/3f/05a038dd89f51ba2b3d7b14ba1f8c00f0e31ac differ
diff --git a/tests/resources/rebase/.gitted/objects/3f/d8d53cf02de539b9a25a5941030451f76a152f b/tests/resources/rebase/.gitted/objects/3f/d8d53cf02de539b9a25a5941030451f76a152f
new file mode 100644
index 0000000..91c4d95
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/3f/d8d53cf02de539b9a25a5941030451f76a152f differ
diff --git a/tests/resources/rebase/.gitted/objects/40/0d89e8ee6cd91b67b1f45de1ca190e1c580c6f b/tests/resources/rebase/.gitted/objects/40/0d89e8ee6cd91b67b1f45de1ca190e1c580c6f
new file mode 100644
index 0000000..f674753
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/40/0d89e8ee6cd91b67b1f45de1ca190e1c580c6f
@@ -0,0 +1 @@
+x¥O;Â0eÎ)|P·•badãqC‡6¨
âúÄ
ØÞGzŸT¦i¬àÉoê’3XŲ²¨º!t¤Ü³»§Á%¶bqÉsQAñ{OÔ$†>ŠïI1aPTb´ƒëM|Ö{Yà,¯¸\ïeZË‡ÜÔ:å¯ñc»T¦#¸OwÔ!lm°Ö4µ­ùÏs)2ê˜bÛ„Z ®íO¼=Wó>{VT
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/41/4dfc71ead79c07acd4ea47fecf91f289afc4b9 b/tests/resources/rebase/.gitted/objects/41/4dfc71ead79c07acd4ea47fecf91f289afc4b9
new file mode 100644
index 0000000..546815e
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/41/4dfc71ead79c07acd4ea47fecf91f289afc4b9 differ
diff --git a/tests/resources/rebase/.gitted/objects/41/c5a0a761bb4a7670924c1af0800b30fe9a21be b/tests/resources/rebase/.gitted/objects/41/c5a0a761bb4a7670924c1af0800b30fe9a21be
new file mode 100644
index 0000000..ecb3992
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/41/c5a0a761bb4a7670924c1af0800b30fe9a21be differ
diff --git a/tests/resources/rebase/.gitted/objects/42/cdad903aef3e7b614675e6584a8be417941911 b/tests/resources/rebase/.gitted/objects/42/cdad903aef3e7b614675e6584a8be417941911
new file mode 100644
index 0000000..99b5e6d
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/42/cdad903aef3e7b614675e6584a8be417941911 differ
diff --git a/tests/resources/rebase/.gitted/objects/44/c801fe026abbc141b52a4dec5df15fa98249c6 b/tests/resources/rebase/.gitted/objects/44/c801fe026abbc141b52a4dec5df15fa98249c6
new file mode 100644
index 0000000..eaf24ae
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/44/c801fe026abbc141b52a4dec5df15fa98249c6 differ
diff --git a/tests/resources/rebase/.gitted/objects/4b/21eb6eeeec7f8fc89a1d334faff9bd5f5f8c34 b/tests/resources/rebase/.gitted/objects/4b/21eb6eeeec7f8fc89a1d334faff9bd5f5f8c34
new file mode 100644
index 0000000..0c9f4b9
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/4b/21eb6eeeec7f8fc89a1d334faff9bd5f5f8c34
@@ -0,0 +1,2 @@
+x¥]J1„}Î)úJOÒ™L`A¼èt:»3‘™,^ß(ÞÀ·úâ+é­Õ6ÐÃ8TÁ‰s	7L%ø`I¶-Ƽi@·.$ÉÇTRF
+æ“Ýl¾8ÂQ±8—i¡•‹J”¤ží:g<"¾[?à-ñ‘áýÖÛÙw¸èLÔ‹þîIz{†…ЯÖbpðˆ„hf:a‡þsƼö½|Tu¿Bë¹–*<êÄ!øœßøz?Í72ZÝ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/4b/7c5650008b2e747fe1809eeb5a1dde0e80850a b/tests/resources/rebase/.gitted/objects/4b/7c5650008b2e747fe1809eeb5a1dde0e80850a
new file mode 100644
index 0000000..0163985
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/4b/7c5650008b2e747fe1809eeb5a1dde0e80850a differ
diff --git a/tests/resources/rebase/.gitted/objects/4b/ed71df7017283cac61bbf726197ad6a5a18b84 b/tests/resources/rebase/.gitted/objects/4b/ed71df7017283cac61bbf726197ad6a5a18b84
new file mode 100644
index 0000000..f206618
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/4b/ed71df7017283cac61bbf726197ad6a5a18b84
@@ -0,0 +1,2 @@
+x¥Ž;nB1ES{³ Ûø3–PD“’.ÇáGÆ€Ø=bt÷#nëº°?FAdÖ’IO‰ÅÎh$ÛœI¶[
+Ϋ?êr9æŠ^RÄjŠAÖ>„µ-–sŒ!äÄX\UtÇÖá»Ü¨ø9¶õÜN°“¹þ§½<WÛp[¿À¸	³Ö&
ŸÚi­æ:e‡¼‰Q‡V–º0e*
~;]ïêMÿU9
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/4c/acc6f6e740a5bc64faa33e04b8ef0733d8a127 b/tests/resources/rebase/.gitted/objects/4c/acc6f6e740a5bc64faa33e04b8ef0733d8a127
new file mode 100644
index 0000000..36a6b31
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/4c/acc6f6e740a5bc64faa33e04b8ef0733d8a127 differ
diff --git a/tests/resources/rebase/.gitted/objects/4f/b698bde45d7d2833e3f2aacfbfe8a7e7f60a65 b/tests/resources/rebase/.gitted/objects/4f/b698bde45d7d2833e3f2aacfbfe8a7e7f60a65
new file mode 100644
index 0000000..8bb69d0
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/4f/b698bde45d7d2833e3f2aacfbfe8a7e7f60a65 differ
diff --git a/tests/resources/rebase/.gitted/objects/50/8be4ff49d38465ad3de58f66d38f70e59f881f b/tests/resources/rebase/.gitted/objects/50/8be4ff49d38465ad3de58f66d38f70e59f881f
new file mode 100644
index 0000000..7ce4452
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/50/8be4ff49d38465ad3de58f66d38f70e59f881f differ
diff --git a/tests/resources/rebase/.gitted/objects/53/f75e45a463033854e52fa8d39dc858e45537d0 b/tests/resources/rebase/.gitted/objects/53/f75e45a463033854e52fa8d39dc858e45537d0
new file mode 100644
index 0000000..f25ef1f
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/53/f75e45a463033854e52fa8d39dc858e45537d0 differ
diff --git a/tests/resources/rebase/.gitted/objects/58/8e5d2f04d49707fe4aab865e1deacaf7ef6787 b/tests/resources/rebase/.gitted/objects/58/8e5d2f04d49707fe4aab865e1deacaf7ef6787
new file mode 100644
index 0000000..766adc1
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/58/8e5d2f04d49707fe4aab865e1deacaf7ef6787
@@ -0,0 +1 @@
+x¥ŽK!D]sŠ¾€†o‰1n\ºóÐ4™YÌ`FŒ×7pWõ*©<jË2wÐÎïúÆÙ“3˜\†B*‰³±Å±Š\2%çB(Cvâž6^;‰‘(JϨ£EmØEå¹baDu U9×,Ò³OmƒKy¥­ÀmjË£­päA?éÌßá×Ô–(+j¼„½´RŠA‡lç?oĵ•¹Î”ú<,ô™¹Š7è_T
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/5b/1e8bccf7787e942aecf61912f94a2c274f85a5 b/tests/resources/rebase/.gitted/objects/5b/1e8bccf7787e942aecf61912f94a2c274f85a5
new file mode 100644
index 0000000..d4776d8
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/5b/1e8bccf7787e942aecf61912f94a2c274f85a5 differ
diff --git a/tests/resources/rebase/.gitted/objects/60/29cb003b59f710f9a8ebd9da9ece2d73070b69 b/tests/resources/rebase/.gitted/objects/60/29cb003b59f710f9a8ebd9da9ece2d73070b69
new file mode 100644
index 0000000..a48e023
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/60/29cb003b59f710f9a8ebd9da9ece2d73070b69 differ
diff --git a/tests/resources/rebase/.gitted/objects/61/139b9b40a3e489f4abbc6af14e10ae14006e47 b/tests/resources/rebase/.gitted/objects/61/139b9b40a3e489f4abbc6af14e10ae14006e47
new file mode 100644
index 0000000..b096a96
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/61/139b9b40a3e489f4abbc6af14e10ae14006e47 differ
diff --git a/tests/resources/rebase/.gitted/objects/61/30e5fcbdce2aa8b3cfd84706c58a892e7d8dd0 b/tests/resources/rebase/.gitted/objects/61/30e5fcbdce2aa8b3cfd84706c58a892e7d8dd0
new file mode 100644
index 0000000..116da7c
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/61/30e5fcbdce2aa8b3cfd84706c58a892e7d8dd0 differ
diff --git a/tests/resources/rebase/.gitted/objects/63/c18bf188b8a1ab0bad85161dc3fb43c48ed0db b/tests/resources/rebase/.gitted/objects/63/c18bf188b8a1ab0bad85161dc3fb43c48ed0db
new file mode 100644
index 0000000..297c432
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/63/c18bf188b8a1ab0bad85161dc3fb43c48ed0db differ
diff --git a/tests/resources/rebase/.gitted/objects/67/ed7afb256807556f9b74fa4f7c9284aaec1120 b/tests/resources/rebase/.gitted/objects/67/ed7afb256807556f9b74fa4f7c9284aaec1120
new file mode 100644
index 0000000..82da206
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/67/ed7afb256807556f9b74fa4f7c9284aaec1120 differ
diff --git a/tests/resources/rebase/.gitted/objects/68/af1fc7407fd9addf1701a87eb1c95c7494c598 b/tests/resources/rebase/.gitted/objects/68/af1fc7407fd9addf1701a87eb1c95c7494c598
new file mode 100644
index 0000000..6aaf79f
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/68/af1fc7407fd9addf1701a87eb1c95c7494c598 differ
diff --git a/tests/resources/rebase/.gitted/objects/68/f6182f4c85d39e1309d97c7e456156dc9c0096 b/tests/resources/rebase/.gitted/objects/68/f6182f4c85d39e1309d97c7e456156dc9c0096
new file mode 100644
index 0000000..ed1de3a
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/68/f6182f4c85d39e1309d97c7e456156dc9c0096 differ
diff --git a/tests/resources/rebase/.gitted/objects/6c/8e16469b6ca09a07e00f0e07a5143c31dcfb64 b/tests/resources/rebase/.gitted/objects/6c/8e16469b6ca09a07e00f0e07a5143c31dcfb64
new file mode 100644
index 0000000..2b8d569
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/6c/8e16469b6ca09a07e00f0e07a5143c31dcfb64
@@ -0,0 +1 @@
+xERKnÛ0횧x²+Z +5U’-Dò(jd¢I†Ÿ¾}‡´Ú®Dˆ3ïËɸ	_¿ûÒ}ûÞ¾œÇSÿ Ä(7Ââr€‘áL˜²U+E¸2zä9ÇQé	:ÁjEæÖàé4âøüŒã¡Ã¯ÃÓ«à…´’ó</íÌx·òçmq•‰Bµ:_§b’f‹u¬g ñµ{c¤ò‹„«N+$¼&EEÊ$•³»‹tV;•²¿“õ]ßwïh?1´¿ÇG!çéêð‘eHÕήarÚÜu%mê	Õ0ñG։ݒš¢æ |6Uò…w‚Ëç"+jú¤;oLA²¿â¼â³N©ÁuÕjÅÛiñ£{la+Q”QïÒ#<Ë׶Î3¦â…þ›ª	°ŒÇ~à¤Å¿6vìUΘˆ7ŒÔ|âJª3®([vVx"ñeLà´2\ª$b^­4Ùdn˜e#i箜‹áÇÀ`9qeµ¡‹6Ûî–Âg}Ù?ˆ?QÂȃ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/6d/77ce8fa2cd93c6489236e33e45e35203ca748c b/tests/resources/rebase/.gitted/objects/6d/77ce8fa2cd93c6489236e33e45e35203ca748c
new file mode 100644
index 0000000..5c3f686
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/6d/77ce8fa2cd93c6489236e33e45e35203ca748c
@@ -0,0 +1 @@
+x+)JMU0¶`040031QHJ,ÊI­Ô+©(ahÞùóÞÿš‚z
>þÔœ†rS57jÜÀ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/6d/fb87d20f3dbca02da4a39890114fd9ba6a51e7 b/tests/resources/rebase/.gitted/objects/6d/fb87d20f3dbca02da4a39890114fd9ba6a51e7
new file mode 100644
index 0000000..039c669
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/6d/fb87d20f3dbca02da4a39890114fd9ba6a51e7 differ
diff --git a/tests/resources/rebase/.gitted/objects/73/f346c88d965227a03c0af8d555870b8c5021d4 b/tests/resources/rebase/.gitted/objects/73/f346c88d965227a03c0af8d555870b8c5021d4
new file mode 100644
index 0000000..215df59
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/73/f346c88d965227a03c0af8d555870b8c5021d4 differ
diff --git a/tests/resources/rebase/.gitted/objects/74/0a804e8963759c98e5b8cb912e15ae74a7a4a6 b/tests/resources/rebase/.gitted/objects/74/0a804e8963759c98e5b8cb912e15ae74a7a4a6
new file mode 100644
index 0000000..b817182
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/74/0a804e8963759c98e5b8cb912e15ae74a7a4a6 differ
diff --git a/tests/resources/rebase/.gitted/objects/78/c320b06544e23d786a9ec84ee93861f2933094 b/tests/resources/rebase/.gitted/objects/78/c320b06544e23d786a9ec84ee93861f2933094
new file mode 100644
index 0000000..afa39fb
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/78/c320b06544e23d786a9ec84ee93861f2933094 differ
diff --git a/tests/resources/rebase/.gitted/objects/79/e28694aae0d3064b06f96a5207b943a2357f07 b/tests/resources/rebase/.gitted/objects/79/e28694aae0d3064b06f96a5207b943a2357f07
new file mode 100644
index 0000000..17ff306
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/79/e28694aae0d3064b06f96a5207b943a2357f07 differ
diff --git a/tests/resources/rebase/.gitted/objects/7a/05900f340af0252aaa4e34941f040c5d2fe7f7 b/tests/resources/rebase/.gitted/objects/7a/05900f340af0252aaa4e34941f040c5d2fe7f7
new file mode 100644
index 0000000..43201f8
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/7a/05900f340af0252aaa4e34941f040c5d2fe7f7 differ
diff --git a/tests/resources/rebase/.gitted/objects/7a/677f6201c8f9d46bdfe1f4b08cb504e360a34e b/tests/resources/rebase/.gitted/objects/7a/677f6201c8f9d46bdfe1f4b08cb504e360a34e
new file mode 100644
index 0000000..dc2fd5a
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/7a/677f6201c8f9d46bdfe1f4b08cb504e360a34e differ
diff --git a/tests/resources/rebase/.gitted/objects/7c/7bf85e978f1d18c0566f702d2cb7766b9c8d4f b/tests/resources/rebase/.gitted/objects/7c/7bf85e978f1d18c0566f702d2cb7766b9c8d4f
new file mode 100644
index 0000000..fe8b157
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/7c/7bf85e978f1d18c0566f702d2cb7766b9c8d4f
@@ -0,0 +1 @@
+x¥±NÄ0D©ý««ádç'‘‚	úýÆÞ\VŠ½‘í\~Ÿ€øº™÷¤/1r…¦w5m|À0èÒt¡ntƺ®%×öû‘¬ékcnu–ïaÇà:K,’à™ú“^éWüµ³—øÆêÖ5¦í5<i«µ:èq^éŸ3ê3qe\ ÓKRê
&ڡȶÐóJ¦,N×™à‹ó#|ÈVhç‰N€wäÇ…€Ô™Ôº{‘ÓY}RYa)
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/7f/37fe2d7320360f8a9118b1ed8fba6f38481679 b/tests/resources/rebase/.gitted/objects/7f/37fe2d7320360f8a9118b1ed8fba6f38481679
new file mode 100644
index 0000000..400df28
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/7f/37fe2d7320360f8a9118b1ed8fba6f38481679
@@ -0,0 +1 @@
+x¥Ž½n1„©ýû óâ;{%„hR¦KùöG¸8ŒŒQ^?å
¢if¾‘FÃuÛJ\p×›*$¢ÇäW2#V1‰FCˆAcFqÅ™Ü=7½uð«O‘ȘY>òšÐÏÉ[4Ôd‚ÌA\~ökmð!?¹	|]ëö¨78é /wÑwñ—\·3ø0Íââì§0MnÐq¶ë?gÜg•b…s/ãB€j ­¨|ß5»_X$W‡
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/80/32d630f37266bace093e353f7b97d7f8b20950 b/tests/resources/rebase/.gitted/objects/80/32d630f37266bace093e353f7b97d7f8b20950
new file mode 100644
index 0000000..07050df
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/80/32d630f37266bace093e353f7b97d7f8b20950 differ
diff --git a/tests/resources/rebase/.gitted/objects/80/dce0e74f0534811db734a68c23b49f98584d7a b/tests/resources/rebase/.gitted/objects/80/dce0e74f0534811db734a68c23b49f98584d7a
new file mode 100644
index 0000000..1b98b0a
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/80/dce0e74f0534811db734a68c23b49f98584d7a
@@ -0,0 +1,2 @@
+xERÍNÃ0朧ðTÜHœ*	¶Šm¦îj5KBâ0ííq²§¦©ýý¶·¾‡»‡û›v×µŸíëa»í¡»Uj¯g„ÑçVÇ#BŸ™0A§ £>æÔ@2QbpdÐ^x:ìaûòÛÍ
+Þ6Ok%<!°2¯Ý x—rsrpÖŒ±3ùP§k;§:Ö	Ð~½ú¤òT#E„3ñ¡Á"¥×Æ;]DzGÞÉ9\ɺU×­>¡Ý<î}ß?*=Àg_YG®v
½'{ÕÅdë	~ÕñW&FH~䦨٨m•|’èó±ÈJ„ßxåMµø+Î+¾ø—”8Od&8åÄÐ#„ÌJ,Ì%Š2<?–Ky¯ó‚idaÆS5ß@%õ×Æ‚=éA eÃj’“TRIEÙ‰³Â“P>ŠI€Œ•RuD•ò8’!tl/0x'Fxᮜ£•ŸAÀ2Keµ¡Ùyq‹ñ»þ9ܪðÊÃ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/83/53b9f9deff7c707f280e0f656c80772cca7cd9 b/tests/resources/rebase/.gitted/objects/83/53b9f9deff7c707f280e0f656c80772cca7cd9
new file mode 100644
index 0000000..a4a7e3a
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/83/53b9f9deff7c707f280e0f656c80772cca7cd9
@@ -0,0 +1,2 @@
+xMAjÃ0E»Ö)þL6]…¬ÒÚBh‚í@»”íq,*kTi\7·ïØèJðçóæiÏ
·Û‡§}y<|¢:]ÎcΗ§wÔ¯åဗ·ã±÷hlòt+ C"Â÷d“ä%Ÿ­P*ÐÓŽCF;	¦X˜êíÏû²<Õr›l¤6tëÜat®¥B#âüÂâä¶PeJÁÅ•eòh½ß¡açáW
+âo™1ð”ò¢DQ·º€^#pBï~‘§Ð­–Z1ɶ_Ë(Ðòö'*°Êg¯6kד*
v,0;)FJ«y¶^væ.’=ÏÿEà9\ïMJº_m§¸AÍ£ΰ‰cè·%ïõ°]çDo=†.#³öÍóŒŠ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/85/258e426a341cc1aa035ac7f6d18f84fed2ab38 b/tests/resources/rebase/.gitted/objects/85/258e426a341cc1aa035ac7f6d18f84fed2ab38
new file mode 100644
index 0000000..af1106d
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/85/258e426a341cc1aa035ac7f6d18f84fed2ab38 differ
diff --git a/tests/resources/rebase/.gitted/objects/85/f34ce9ca9e0f33d4146afec9cbe5a26757500a b/tests/resources/rebase/.gitted/objects/85/f34ce9ca9e0f33d4146afec9cbe5a26757500a
new file mode 100644
index 0000000..03e7516
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/85/f34ce9ca9e0f33d4146afec9cbe5a26757500a differ
diff --git a/tests/resources/rebase/.gitted/objects/86/a5415741ed3754ccb0cac1fc19fd82587840a4 b/tests/resources/rebase/.gitted/objects/86/a5415741ed3754ccb0cac1fc19fd82587840a4
new file mode 100644
index 0000000..fe00a22
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/86/a5415741ed3754ccb0cac1fc19fd82587840a4 differ
diff --git a/tests/resources/rebase/.gitted/objects/8d/1f13f93c4995760ac07d129246ac1ff64c0be9 b/tests/resources/rebase/.gitted/objects/8d/1f13f93c4995760ac07d129246ac1ff64c0be9
new file mode 100644
index 0000000..a66cfcc
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/8d/1f13f93c4995760ac07d129246ac1ff64c0be9
@@ -0,0 +1,2 @@
+x¥ŽAnÃ0{Ö+øMÙ¹ôØ[>@“⃣ÀQïÇ-úƒÜvgÅh[×¥¥é£oî0P"Á±¨³²NX*ÆH4Y1åÌ©R.á&›_;˜MQh0$+CÎcå$³š`ÒšŒæÂAýÒ6ø¶§lçK[ïí
+ßéo:ùßðß¾´­GˆŒi¤˜™á1ìt—íþæMøi¶ÔE¥/»Ao0»×ðâ›S€
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/8d/95ea62e621f1d38d230d9e7d206e41096d76af b/tests/resources/rebase/.gitted/objects/8d/95ea62e621f1d38d230d9e7d206e41096d76af
new file mode 100644
index 0000000..464de7c
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/8d/95ea62e621f1d38d230d9e7d206e41096d76af differ
diff --git a/tests/resources/rebase/.gitted/objects/8f/4de6c781b9ff9cedfd7f9f9f224e744f97b259 b/tests/resources/rebase/.gitted/objects/8f/4de6c781b9ff9cedfd7f9f9f224e744f97b259
new file mode 100644
index 0000000..faa9389
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/8f/4de6c781b9ff9cedfd7f9f9f224e744f97b259
@@ -0,0 +1 @@
+x+)JMU0·d040031QHJ,ÊI­Ô+©(a¨|Ô6eÕƒËlÞl?³‚Øw:/2­g‡ªJ)ÊLM‰/HM+tôýSøêúö5W^¹ÿ;?ñSçú#;a9$j
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/92/54a37fde7e97f9a28dee2967fdb2c5d1ed94e9 b/tests/resources/rebase/.gitted/objects/92/54a37fde7e97f9a28dee2967fdb2c5d1ed94e9
new file mode 100644
index 0000000..10d6c13
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/92/54a37fde7e97f9a28dee2967fdb2c5d1ed94e9
@@ -0,0 +1 @@
+xERËnã0ìY_Á0z+Z '5uè¢Îúœe…Ž…(–V¢äï—RŠöd‰Îp8­áéåùAv{ÙÊÍÐA×ûG!zùQúZø#ÛM
oÃçj[wà&PÑ« N)VuPÁ,F£½U 1f·pyѳhÖÐokè›}WZŽ`Õ
hÆ?ÃUnšÏ5ˆ¤ì9˜g¢sKþŠõ®­á°ë· a¿«W50ó›\5ŸLˤá„,jGHþ.æÑ{…0*K¯B¾¿Chàï Û¾ËÙ×m£3ö.HÆ–ÓÏ4á_2Ä㹉ªZ„O¶Œ|ákpé4óÑàÞu#Åþ²§âÈñ–*¸ÎFÏpI‘`D`bTúœW‘¡ÞÑk.ò½à™SsÃM]
ÍKÎGÞ´øIã›{VG¦æ«Ÿ8’âŒ#J;˽ù‘'PŒ¶Èû(bš&£
.dopäø²Ñ»vÑœ¬KÕ˜ˆ#+½{þv‹á«üÉ?ŠÿÐwǃ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/95/39b2cc291d6a6b1b266df8474d31fdd344dd79 b/tests/resources/rebase/.gitted/objects/95/39b2cc291d6a6b1b266df8474d31fdd344dd79
new file mode 100644
index 0000000..9649434
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/95/39b2cc291d6a6b1b266df8474d31fdd344dd79 differ
diff --git a/tests/resources/rebase/.gitted/objects/9a/8535dfcaf7554c728d874f047c5461fb2c71d1 b/tests/resources/rebase/.gitted/objects/9a/8535dfcaf7554c728d874f047c5461fb2c71d1
new file mode 100644
index 0000000..d997426
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/9a/8535dfcaf7554c728d874f047c5461fb2c71d1 differ
diff --git a/tests/resources/rebase/.gitted/objects/9c/d483e7da23819d7f71d24e9843812337886753 b/tests/resources/rebase/.gitted/objects/9c/d483e7da23819d7f71d24e9843812337886753
new file mode 100644
index 0000000..d168455
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/9c/d483e7da23819d7f71d24e9843812337886753
@@ -0,0 +1 @@
+xMAjÃ0E»Ö)þL6]…¬ÒÚ€ÛÛv)ÛãXTѨҨ®o_ÙèJðçóæiZË-·Û‡§}U>QŸ.çRçKƒÓ;š×êpÀ˱,kð€VKs¾“—|ÒB¡À@Øv]$_¨úøç}Uš±ÚSíúunœ0zÓQ‘#PÆÙ…éÄȼP%güÊRõÛ¾,whÙXÁ•œØ21FN!.JäàóVã0ä0˜‚çäúÕ2WTÐÝ×2r´¼nI„]Xå£Í6k×RVõ­Àdd„'ï)¬æQ[Ù©»H´<ýew½7)äýÙ6ù
¾iá(cývdmþtßÉ7C>†Œ&"rî«?v„‹ê
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/a0/1a6ee390f65d834375e072952deaee0c5e92f7 b/tests/resources/rebase/.gitted/objects/a0/1a6ee390f65d834375e072952deaee0c5e92f7
new file mode 100644
index 0000000..eb98c9d
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/a0/1a6ee390f65d834375e072952deaee0c5e92f7 differ
diff --git a/tests/resources/rebase/.gitted/objects/a0/fa65f96c1e3bdc7287e334229279dcc1248fa4 b/tests/resources/rebase/.gitted/objects/a0/fa65f96c1e3bdc7287e334229279dcc1248fa4
new file mode 100644
index 0000000..fd43545
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/a0/fa65f96c1e3bdc7287e334229279dcc1248fa4
@@ -0,0 +1,3 @@
+xERÍnà Þ™§ðD½M›ÔS6µ«´i©šöqL£¾ý­ºSÀ|þ~ìtÆuðúþöR·ûúPZh›Ó~%ıþÞÀ¶9à§>|màãôû¹Û´àÑË Ï)VUAX­ÐÜ*P‰3€³\¶jÍŽ»
›}[´=yqægX$aà¦Ñù\ƒHÒL±À<˜³ù+M#Hðf+TÎ2-“†3W¬ft¶ü]Ì£÷
+a”†ÖBö=Ðâà’d ˜9:§Í]´)§§¾$MlÏ
Te>™byækpéœmEW¼ëF
+’óåL…Èñ”*XF­F˜S$è8£àSE†zGë\ä{Á3§â†	ÿC•	d,9Ÿí‹ç6ܣ왚;ŒÔ|â•”d¼¢d9YÖ‰Èì€' •Ažw@Ó0h¥Ñ’¹AÏëËAïÚEs0.ñªºD¼²2ÐY›é‘õüɯÄ9Ï̃
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/a1/25b9b655932711abceaf8962948e6b601d67b6 b/tests/resources/rebase/.gitted/objects/a1/25b9b655932711abceaf8962948e6b601d67b6
new file mode 100644
index 0000000..50bcee1
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/a1/25b9b655932711abceaf8962948e6b601d67b6 differ
diff --git a/tests/resources/rebase/.gitted/objects/a7/00acc970eccccc73be53cd269462176544e6d1 b/tests/resources/rebase/.gitted/objects/a7/00acc970eccccc73be53cd269462176544e6d1
new file mode 100644
index 0000000..e5c62db
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/a7/00acc970eccccc73be53cd269462176544e6d1 differ
diff --git a/tests/resources/rebase/.gitted/objects/a7/b066537e6be7109abfe4ff97b675d4e077da20 b/tests/resources/rebase/.gitted/objects/a7/b066537e6be7109abfe4ff97b675d4e077da20
new file mode 100644
index 0000000..54f9b66
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/a7/b066537e6be7109abfe4ff97b675d4e077da20 differ
diff --git a/tests/resources/rebase/.gitted/objects/aa/4c42aecdfc7cd989bbc3209934ea7cda3f4d88 b/tests/resources/rebase/.gitted/objects/aa/4c42aecdfc7cd989bbc3209934ea7cda3f4d88
new file mode 100644
index 0000000..628c2d3
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/aa/4c42aecdfc7cd989bbc3209934ea7cda3f4d88
@@ -0,0 +1 @@
+x¥Á	B1D=§Šm@Ùý=Ø
l²~À¸#b÷F±o3o`^ÒZK‹~Õ›ˆdfñL“Ï6ìØ1GÏ9¦)̘1 5ôè‹68ó“ÃeÑz×ìeÐO:ÊwøµMÒz€É¡ßZë¦ÖèÍ CÞåÏsb.½½fˆÔ®ò2o!Fw
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/ab/25a53ef5622d443ecb0492b7516725f0deac8f b/tests/resources/rebase/.gitted/objects/ab/25a53ef5622d443ecb0492b7516725f0deac8f
new file mode 100644
index 0000000..83ef51e
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ab/25a53ef5622d443ecb0492b7516725f0deac8f differ
diff --git a/tests/resources/rebase/.gitted/objects/ad/c97cfb874cdfb9d5ab17b54f3771dea6e02ccf b/tests/resources/rebase/.gitted/objects/ad/c97cfb874cdfb9d5ab17b54f3771dea6e02ccf
new file mode 100644
index 0000000..cc7ccd0
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ad/c97cfb874cdfb9d5ab17b54f3771dea6e02ccf differ
diff --git a/tests/resources/rebase/.gitted/objects/ae/87cae12879a3c37d7cc994afc6395bcb0eaf99 b/tests/resources/rebase/.gitted/objects/ae/87cae12879a3c37d7cc994afc6395bcb0eaf99
new file mode 100644
index 0000000..5c8469e
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ae/87cae12879a3c37d7cc994afc6395bcb0eaf99 differ
diff --git a/tests/resources/rebase/.gitted/objects/b1/46bd7608eac53d9bf9e1a6963543588b555c64 b/tests/resources/rebase/.gitted/objects/b1/46bd7608eac53d9bf9e1a6963543588b555c64
new file mode 100644
index 0000000..3e4b975
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/b1/46bd7608eac53d9bf9e1a6963543588b555c64
@@ -0,0 +1 @@
+x¥ŽÁj1D{öWè,¯e«B.=æÖÐÚ»‡ÃÆ!¿_7ôs˜yÔ¶mk‡@ù£ïª€Æ‚3NC±y¶ˆ–dšs.%	!w“]¯ˆY©ó±Æ¯ì³i™9‘bU)bY-eÎN}i;|קì~–¶ÝÛŽ:èŸ;ë«øO‡Ò¶`ô”2#|úè½tœíú挻´ºÚZ¤¯ãAo0«šûcJT/
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/b1/b94ec02f8ed87d0efa4c65fb38d5d6da7e8b32 b/tests/resources/rebase/.gitted/objects/b1/b94ec02f8ed87d0efa4c65fb38d5d6da7e8b32
new file mode 100644
index 0000000..d15c022
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/b1/b94ec02f8ed87d0efa4c65fb38d5d6da7e8b32 differ
diff --git a/tests/resources/rebase/.gitted/objects/b6/72b141d48c369fee6c4deeb32a904387594365 b/tests/resources/rebase/.gitted/objects/b6/72b141d48c369fee6c4deeb32a904387594365
new file mode 100644
index 0000000..d8cdb71
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/b6/72b141d48c369fee6c4deeb32a904387594365 differ
diff --git a/tests/resources/rebase/.gitted/objects/b7/c536a5883c8adaeb34d5e198c5a3dbbdc608b5 b/tests/resources/rebase/.gitted/objects/b7/c536a5883c8adaeb34d5e198c5a3dbbdc608b5
new file mode 100644
index 0000000..b594984
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/b7/c536a5883c8adaeb34d5e198c5a3dbbdc608b5 differ
diff --git a/tests/resources/rebase/.gitted/objects/b9/f72b9158fa8c49fb4e4c10b26817ed867be803 b/tests/resources/rebase/.gitted/objects/b9/f72b9158fa8c49fb4e4c10b26817ed867be803
new file mode 100644
index 0000000..9701667
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/b9/f72b9158fa8c49fb4e4c10b26817ed867be803
@@ -0,0 +1,3 @@
+x¥O;N1¥žS¸Û
+d;Nf"!´
%=ÊÇaFb&«âö' {_[/Õ}ß:ò7½©‚)yÉÖ¤‚œÕ}`¬Bƒb©Ì.å2]BÓ£Ct3Gʲ$ã|QuI²j4<ŠYæÑ5Îþå‰."ÄÑ[6ÞyÇ…q&—2ÇE攦píkmð˜?BËð¼Öý½p¯CýFgý1~Ù]ªû uÌã!Ü¢ NCãºþóÌô¤íU!¶p¤N1´7ý<Ávô
+¹mš_.¦/ÚÚdÛ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/bc/cc8eabb5cfe2ec09959c7f4155aa73429fd604 b/tests/resources/rebase/.gitted/objects/bc/cc8eabb5cfe2ec09959c7f4155aa73429fd604
new file mode 100644
index 0000000..de778eb
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/bc/cc8eabb5cfe2ec09959c7f4155aa73429fd604 differ
diff --git a/tests/resources/rebase/.gitted/objects/c4/e6cca3ec6ae0148ed231f97257df8c311e015f b/tests/resources/rebase/.gitted/objects/c4/e6cca3ec6ae0148ed231f97257df8c311e015f
new file mode 100644
index 0000000..2bbf28f
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/c4/e6cca3ec6ae0148ed231f97257df8c311e015f
@@ -0,0 +1 @@
+x%P1nÄ0ëìWð¹CNE§N7¶è¡:*‰’p¬Ô’/¸ßWÎmI‘”ú$=^^ŸŸ._ï?¿¸~|žC¸°ã¼6©yTÈ„A¨(#1eôÌÓé´“.ˆ†áÀ(Hto@̸K-aë°Õ°…¡´²“sá1r6)&)8¸Å·TêÖa¶<0ׇ¿JÙ¢Ý[‡ŒK‡5IJ²²­ÈÀªcáÁ¸q͓쌫r_ÍÛ‡"u^@ÐÈ7~X)—›÷2¸ Ýâ	G…,æ¥f¬R¸ùå`BÚúÂ4¶3£½ÁvQŸø¤›HÖ©¦Öu­êa²b SwÞcJ q…)fÆ”èæO‚ùvû×;‡í«ŒŸ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/c5/17380440ed78865ffe3fa130b9738615c76618 b/tests/resources/rebase/.gitted/objects/c5/17380440ed78865ffe3fa130b9738615c76618
new file mode 100644
index 0000000..b9a52a3
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/c5/17380440ed78865ffe3fa130b9738615c76618 differ
diff --git a/tests/resources/rebase/.gitted/objects/cb/20a10406172afd6ca3138ce36ecaf8b1269e8e b/tests/resources/rebase/.gitted/objects/cb/20a10406172afd6ca3138ce36ecaf8b1269e8e
new file mode 100644
index 0000000..acd6bdc
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/cb/20a10406172afd6ca3138ce36ecaf8b1269e8e differ
diff --git a/tests/resources/rebase/.gitted/objects/d4/82e77aecb8e07da43e4cad6e0dcb59219e12af b/tests/resources/rebase/.gitted/objects/d4/82e77aecb8e07da43e4cad6e0dcb59219e12af
new file mode 100644
index 0000000..af3bd17
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/d4/82e77aecb8e07da43e4cad6e0dcb59219e12af differ
diff --git a/tests/resources/rebase/.gitted/objects/d6/16d97082eb7bb2dc6f180a7cca940993b7a56f b/tests/resources/rebase/.gitted/objects/d6/16d97082eb7bb2dc6f180a7cca940993b7a56f
new file mode 100644
index 0000000..fa2e8d9
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/d6/16d97082eb7bb2dc6f180a7cca940993b7a56f
@@ -0,0 +1 @@
+x¥NK uÍ)æš)0-MŒqãÒ`Ð.Z¢ÆۋƸ{ÿ¼çyª É­jßùÑJ@œD7D”Ä6ô”¼q‘byçVW.²´"³	â¬ÆVC'žCGÚ›–$)%3¦1ô¢ø^/¹À!>¹D8]ò|Ël¥©´—¯ñc›çt©×„D°F‹¨šÚÎVùsFsœÒ¸Ní‚šá\øñRoV<
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/d6/b9ec0dfb972a6815ace42545cde5f2631cd776 b/tests/resources/rebase/.gitted/objects/d6/b9ec0dfb972a6815ace42545cde5f2631cd776
new file mode 100644
index 0000000..1239704
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/d6/b9ec0dfb972a6815ace42545cde5f2631cd776 differ
diff --git a/tests/resources/rebase/.gitted/objects/da/82b3a60c50cf5ac524ec3000d743447329465d b/tests/resources/rebase/.gitted/objects/da/82b3a60c50cf5ac524ec3000d743447329465d
new file mode 100644
index 0000000..352a13a
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/da/82b3a60c50cf5ac524ec3000d743447329465d differ
diff --git a/tests/resources/rebase/.gitted/objects/da/9c51a23d02d931a486f45ad18cda05cf5d2b94 b/tests/resources/rebase/.gitted/objects/da/9c51a23d02d931a486f45ad18cda05cf5d2b94
new file mode 100644
index 0000000..85b78ee
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/da/9c51a23d02d931a486f45ad18cda05cf5d2b94
@@ -0,0 +1,2 @@
+x¥Ž;!†­9Å\@3ÀÂ@bŒ¥à1·X1+Æë‹ÆØýäËWڲ̌£M_™! 5Õ[KÆûœ
+c´lÊ‘*IÈ£CuO+ß:P¡,Áq¤ ºêPÐy/„¦š’‰"–P'QéÙ¯m…S}¥µÂåÚ–G»ÁžÇúIGþ¿¶+m9€žÌhò¶8!ª±ÙÎbÔ¹ÕYæ’ú<4ô™YÔõ¯S•
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/dc/12ac1e10f2be70e8ecd52132a08da98a309c3a b/tests/resources/rebase/.gitted/objects/dc/12ac1e10f2be70e8ecd52132a08da98a309c3a
new file mode 100644
index 0000000..9907248
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/dc/12ac1e10f2be70e8ecd52132a08da98a309c3a
@@ -0,0 +1 @@
+x¥ŽMJ1…]çÅì•ÊϤ¦Ad@\ºóUIÅCw†LD¼½Q¼»÷Þ/µm«…»ÑUAI1eq‹U<ùhKfO‘¼gë$Ø#2/æÊ]÷š‰/%«.¤ˆÙå(–-.Ÿâä
ŒµuxÉŸÜ3¼­m»µu®?鬿à¯=¤¶=
x$ŒDÜc@4s²CÿycžWíý®5]êþ‡×–k©‰GJFQ-ó
ºZy
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/df/d3d25264693fcd7348ad286f3c34f3f6b30918 b/tests/resources/rebase/.gitted/objects/df/d3d25264693fcd7348ad286f3c34f3f6b30918
new file mode 100644
index 0000000..3de3fda
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/df/d3d25264693fcd7348ad286f3c34f3f6b30918 differ
diff --git a/tests/resources/rebase/.gitted/objects/e4/f809f826c1a9fc929874bc0e4644dd2f2a1af4 b/tests/resources/rebase/.gitted/objects/e4/f809f826c1a9fc929874bc0e4644dd2f2a1af4
new file mode 100644
index 0000000..e475019
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/e4/f809f826c1a9fc929874bc0e4644dd2f2a1af4
@@ -0,0 +1,3 @@
+x¥ŽMŠ1„]çïùym'0ˆ—î¼@%yÁÛ1"ÞÞ8Ì
fWõ_ªëºt²SØô&Beç
+Ü,ÖO15æȾ`òÖÁxÃpÈP?hrëpbI¹¤9åàCŒÉY‚cÁ p…³÷
+~©Žù‰–é|©ë½Þè[ý¤ƒüí+ÕuO†õ´³–YÓV³ÖjÐ!ÛåŸ7êTóR–„¾C½RD»ÊK½ÿXV
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/e5/2ff405da5b7e1e9b0929939fa8405d81fe8a45 b/tests/resources/rebase/.gitted/objects/e5/2ff405da5b7e1e9b0929939fa8405d81fe8a45
new file mode 100644
index 0000000..30c1987
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/e5/2ff405da5b7e1e9b0929939fa8405d81fe8a45
@@ -0,0 +1,3 @@
+x¥Ž;j1†]ës˜‘V“&eºôaV3ƒUìÊ(
+¹~d“¤ûðñ•¶ïu€‹î4ºZŠ"KF×Å/)&—ƒc!,A²ÓdîÔ倨vË„Ù¯”8°õƒlqAѺm«ª'CßãÖ:¼ñu†[Û¿Ú™ë#½ÊóøkçÒö+؉ŠÎ…äá=¢™ë”òOŒyo\µu*Xh
+Ü«ðç]ÈüxV¢
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/e7/bb00c4eab291e08361fda376733a12b4150aa9 b/tests/resources/rebase/.gitted/objects/e7/bb00c4eab291e08361fda376733a12b4150aa9
new file mode 100644
index 0000000..da96e9d
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/e7/bb00c4eab291e08361fda376733a12b4150aa9 differ
diff --git a/tests/resources/rebase/.gitted/objects/e8/8cc0a6919a74599ce8e1dcb81eb2bbae33a645 b/tests/resources/rebase/.gitted/objects/e8/8cc0a6919a74599ce8e1dcb81eb2bbae33a645
new file mode 100644
index 0000000..e8ce172
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/e8/8cc0a6919a74599ce8e1dcb81eb2bbae33a645 differ
diff --git a/tests/resources/rebase/.gitted/objects/e9/5f47e016dcc70b0b888df8e40e97b8aabafd4c b/tests/resources/rebase/.gitted/objects/e9/5f47e016dcc70b0b888df8e40e97b8aabafd4c
new file mode 100644
index 0000000..cc3312a
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/e9/5f47e016dcc70b0b888df8e40e97b8aabafd4c differ
diff --git a/tests/resources/rebase/.gitted/objects/e9/f22c10ffb378446c0bbcab7ee3d9d5a0040672 b/tests/resources/rebase/.gitted/objects/e9/f22c10ffb378446c0bbcab7ee3d9d5a0040672
new file mode 100644
index 0000000..3446b2f
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/e9/f22c10ffb378446c0bbcab7ee3d9d5a0040672
@@ -0,0 +1,2 @@
+xMÍjÃ0„{ÖS̘\z
+9µ`Ú‚iB~=Êö:•µª´ª“·ïÚèiav˜ývZÏ-ž·Û§×—cSá´¿6Æ.gì?q~?Ö5Þ>šæÐÚäé^AÆD„Ÿb“äEŸ­Pª0ÐŽCFW%V&»:›«1wÉFêaC¿î]Fï:ªTiœ_2ƒ8¹/©RRpqÍ2y²Þïвóp‚+ñwÈ̹¤¼ Q@Ô«.`P	œ0¸_Bäú•R-&Ùî{YZ怩ˆpP€>{¥Y½ži´S…ÙɈH1RZɳõ²3ìyþÏáúpRÒûJ[âgž¬p†M¤1†ny¯_Àö½íZ†ŒNkbõ›?ŒÂÊ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/ec/725f5639730640f91cd0be5f2d6d7ac5d69c79 b/tests/resources/rebase/.gitted/objects/ec/725f5639730640f91cd0be5f2d6d7ac5d69c79
new file mode 100644
index 0000000..0fb3334
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ec/725f5639730640f91cd0be5f2d6d7ac5d69c79 differ
diff --git a/tests/resources/rebase/.gitted/objects/ed/f7b3ffde1624c60d2d6b1a2bb792d86de172e0 b/tests/resources/rebase/.gitted/objects/ed/f7b3ffde1624c60d2d6b1a2bb792d86de172e0
new file mode 100644
index 0000000..e2e98d6
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/ed/f7b3ffde1624c60d2d6b1a2bb792d86de172e0
@@ -0,0 +1,3 @@
+x¥OKN!uÍ)êh¡
+ctá
f?ú8½èfÒb¼¾8™¸{Ÿä}¸oÛ:`Iø0U¨Â…ØZ¦Èb­Hª-PKÑž‰‚hEõ³¹k=t@LÍrÒBÙ‚„Ì>!ùEnDˆ­p–h®~K?àC~ê!pºôí«ïð¢SýCoz3îì‰ûö
+!úD± <úè½›ê;ôŸ1î]dë¬ïŸóõ~¾ju¿Z’U„
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/ee/23c5eeedadf8595c0ff60a366d970a165e373d b/tests/resources/rebase/.gitted/objects/ee/23c5eeedadf8595c0ff60a366d970a165e373d
new file mode 100644
index 0000000..b32600f
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ee/23c5eeedadf8595c0ff60a366d970a165e373d differ
diff --git a/tests/resources/rebase/.gitted/objects/ee/f0edde5daa94da5f297d4ddb5dfbc1980f0902 b/tests/resources/rebase/.gitted/objects/ee/f0edde5daa94da5f297d4ddb5dfbc1980f0902
new file mode 100644
index 0000000..e9b3f58
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ee/f0edde5daa94da5f297d4ddb5dfbc1980f0902 differ
diff --git a/tests/resources/rebase/.gitted/objects/ef/ad0b11c47cb2f0220cbd6f5b0f93bb99064b00 b/tests/resources/rebase/.gitted/objects/ef/ad0b11c47cb2f0220cbd6f5b0f93bb99064b00
new file mode 100644
index 0000000..285e140
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/ef/ad0b11c47cb2f0220cbd6f5b0f93bb99064b00
@@ -0,0 +1 @@
+x¥=nÃ0…3ë¼@Š¢dŠ.»å¬D&l¶‚^¿jÐt{?ÀÃ÷J[×¥%:õ]r¤˜•)I`_ŠÁ¥L–ªÏ–Ù´’|…ìî²ëÖaŒ3¢F1¤H"ÂxfoÈXb%ÓÉ&'~k;|ÔoÙ+\nm=Úgé¯z×gñç^K[ßÀ3ÆD>Í	^ƺ‘Ø®ÿœqŸ­.¶éË@ˆÐÈ1þÈõq¸æ©V
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/f5/56d5fef35003561dc0b64b37057d7541239105 b/tests/resources/rebase/.gitted/objects/f5/56d5fef35003561dc0b64b37057d7541239105
new file mode 100644
index 0000000..f4143e1
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/f5/56d5fef35003561dc0b64b37057d7541239105 differ
diff --git a/tests/resources/rebase/.gitted/objects/f6/3fa37e285bd11b0a7b48fa584a4091814a3ada b/tests/resources/rebase/.gitted/objects/f6/3fa37e285bd11b0a7b48fa584a4091814a3ada
new file mode 100644
index 0000000..e650383
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/f6/3fa37e285bd11b0a7b48fa584a4091814a3ada differ
diff --git a/tests/resources/rebase/.gitted/objects/f7/5c193a1df47186727179f24867bc4d27a8991f b/tests/resources/rebase/.gitted/objects/f7/5c193a1df47186727179f24867bc4d27a8991f
new file mode 100644
index 0000000..618cb68
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/f7/5c193a1df47186727179f24867bc4d27a8991f differ
diff --git a/tests/resources/rebase/.gitted/objects/f8/7d14a4a236582a0278a916340a793714256864 b/tests/resources/rebase/.gitted/objects/f8/7d14a4a236582a0278a916340a793714256864
new file mode 100644
index 0000000..1d29712
--- /dev/null
+++ b/tests/resources/rebase/.gitted/objects/f8/7d14a4a236582a0278a916340a793714256864
@@ -0,0 +1,2 @@
+x¥ŽKŠAD]×)òUÙõqãÒÈÎ6ØÖЖz}Ûan0»ˆ<nó<uÀT6}Q…Õ4$1&+)E.X¥–h>N1‘Kà~hÑ[¯†Š#ŽU²«b–4cP¯LƼij£G¿´Žò¢Eà|ió½Ýà[WúIýþÚ·y!ú”‡œaë£÷n¥«l×Þ¸S“É&¦>­
+ôO¥«{äƒTÈ
\ No newline at end of file
diff --git a/tests/resources/rebase/.gitted/objects/fc/e0584b379f535e50e036db587db71884ea6b36 b/tests/resources/rebase/.gitted/objects/fc/e0584b379f535e50e036db587db71884ea6b36
new file mode 100644
index 0000000..ce8b2fb
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/fc/e0584b379f535e50e036db587db71884ea6b36 differ
diff --git a/tests/resources/rebase/.gitted/objects/ff/b36e513f5fdf8a6ba850a20142676a2ac4807d b/tests/resources/rebase/.gitted/objects/ff/b36e513f5fdf8a6ba850a20142676a2ac4807d
new file mode 100644
index 0000000..f655d12
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ff/b36e513f5fdf8a6ba850a20142676a2ac4807d differ
diff --git a/tests/resources/rebase/.gitted/objects/ff/dfa89389040a87008c4ab1834120d3046daaea b/tests/resources/rebase/.gitted/objects/ff/dfa89389040a87008c4ab1834120d3046daaea
new file mode 100644
index 0000000..54c938e
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/ff/dfa89389040a87008c4ab1834120d3046daaea differ
diff --git a/tests/resources/rebase/.gitted/refs/heads/asparagus b/tests/resources/rebase/.gitted/refs/heads/asparagus
new file mode 100644
index 0000000..a3c9d67
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/asparagus
@@ -0,0 +1 @@
+4b21eb6eeeec7f8fc89a1d334faff9bd5f5f8c34
diff --git a/tests/resources/rebase/.gitted/refs/heads/barley b/tests/resources/rebase/.gitted/refs/heads/barley
new file mode 100644
index 0000000..feab944
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/barley
@@ -0,0 +1 @@
+12c084412b952396962eb420716df01022b847cc
diff --git a/tests/resources/rebase/.gitted/refs/heads/beef b/tests/resources/rebase/.gitted/refs/heads/beef
new file mode 100644
index 0000000..1c69e6a
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/beef
@@ -0,0 +1 @@
+b146bd7608eac53d9bf9e1a6963543588b555c64
diff --git a/tests/resources/rebase/.gitted/refs/heads/dried_pea b/tests/resources/rebase/.gitted/refs/heads/dried_pea
new file mode 100644
index 0000000..9ede602
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/dried_pea
@@ -0,0 +1 @@
+7f37fe2d7320360f8a9118b1ed8fba6f38481679
diff --git a/tests/resources/rebase/.gitted/refs/heads/gravy b/tests/resources/rebase/.gitted/refs/heads/gravy
new file mode 100644
index 0000000..3753b73
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/gravy
@@ -0,0 +1 @@
+d616d97082eb7bb2dc6f180a7cca940993b7a56f
diff --git a/tests/resources/rebase/.gitted/refs/heads/green_pea b/tests/resources/rebase/.gitted/refs/heads/green_pea
new file mode 100644
index 0000000..3bffe27
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/green_pea
@@ -0,0 +1 @@
+d482e77aecb8e07da43e4cad6e0dcb59219e12af
diff --git a/tests/resources/rebase/.gitted/refs/heads/master b/tests/resources/rebase/.gitted/refs/heads/master
new file mode 100644
index 0000000..abbe9cc
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/master
@@ -0,0 +1 @@
+efad0b11c47cb2f0220cbd6f5b0f93bb99064b00
diff --git a/tests/resources/rebase/.gitted/refs/heads/veal b/tests/resources/rebase/.gitted/refs/heads/veal
new file mode 100644
index 0000000..484f489
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/veal
@@ -0,0 +1 @@
+f87d14a4a236582a0278a916340a793714256864
diff --git a/tests/resources/rebase/asparagus.txt b/tests/resources/rebase/asparagus.txt
new file mode 100644
index 0000000..67ed7af
--- /dev/null
+++ b/tests/resources/rebase/asparagus.txt
@@ -0,0 +1,10 @@
+ASPARAGUS SOUP.
+
+TAKE FOUR LARGE BUNCHES of asparagus, scrape it nicely, cut off one inch
+OF THE TOPS, and lay them in water, chop the stalks and put them on the
+FIRE WITH A PIECE OF BACON, a large onion cut up, and pepper and salt;
+ADD TWO QUARTS OF WATER, boil them till the stalks are quite soft, then
+PULP THEM THROUGH A SIEVE, and strain the water to it, which must be put
+back in the pot; put into it a chicken cut up, with the tops of
+asparagus which had been laid by, boil it until these last articles are
+sufficiently done, thicken with flour, butter and milk, and serve it up.
diff --git a/tests/resources/rebase/beef.txt b/tests/resources/rebase/beef.txt
new file mode 100644
index 0000000..68f6182
--- /dev/null
+++ b/tests/resources/rebase/beef.txt
@@ -0,0 +1,22 @@
+BEEF SOUP.
+
+Take the hind shin of beef, cut off all the flesh off the leg-bone,
+which must be taken away entirely, or the soup will be greasy. Wash the
+meat clean and lay it in a pot, sprinkle over it one small
+table-spoonful of pounded black pepper, and two of salt; three onions
+the size of a hen's egg, cut small, six small carrots scraped and cut
+up, two small turnips pared and cut into dice; pour on three quarts of
+water, cover the pot close, and keep it gently and steadily boiling five
+hours, which will leave about three pints of clear soup; do not let the
+pot boil over, but take off the scum carefully, as it rises. When it has
+boiled four hours, put in a small bundle of thyme and parsley, and a
+pint of celery cut small, or a tea-spoonful of celery seed pounded.
+These latter ingredients would lose their delicate flavour if boiled too
+much. Just before you take it up, brown it in the following manner: put
+a small table-spoonful of nice brown sugar into an iron skillet, set it
+on the fire and stir it till it melts and looks very dark, pour into it
+a ladle full of the soup, a little at a time; stirring it all the while.
+Strain this browning and mix it well with the soup; take out the bundle
+of thyme and parsley, put the nicest pieces of meat in your tureen, and
+pour on the soup and vegetables; put in some toasted bread cut in dice,
+and serve it up.
diff --git a/tests/resources/rebase/bouilli.txt b/tests/resources/rebase/bouilli.txt
new file mode 100644
index 0000000..4b7c565
--- /dev/null
+++ b/tests/resources/rebase/bouilli.txt
@@ -0,0 +1,18 @@
+SOUP WITH BOUILLI.
+
+Take the nicest part of the thick brisket of beef, about eight pounds,
+put it into a pot with every thing directed for the other soup; make it
+exactly in the same way, only put it on an hour sooner, that you may
+have time to prepare the bouilli; after it has boiled five hours, take
+out the beef, cover up the soup and set it near the fire that it may
+keep hot. Take the skin off the beef, have the yelk of an egg well
+beaten, dip a feather in it and wash the top of your beef, sprinkle over
+it the crumb of stale bread finely grated, put it in a Dutch oven
+previously heated, put the top on with coals enough to brown, but not
+burn the beef; let it stand nearly an hour, and prepare your gravy
+thus:--Take a sufficient quantity of soup and the vegetables boiled in
+it; add to it a table-spoonful of red wine, and two of mushroom catsup,
+thicken with a little bit of butter and a little brown flour; make it
+very hot, pour it in your dish, and put the beef on it. Garnish it with
+green pickle, cut in thin slices, serve up the soup in a tureen with
+bits of toasted bread.
diff --git a/tests/resources/rebase/gravy.txt b/tests/resources/rebase/gravy.txt
new file mode 100644
index 0000000..c4e6cca
--- /dev/null
+++ b/tests/resources/rebase/gravy.txt
@@ -0,0 +1,8 @@
+GRAVY SOUP.
+
+Get eight pounds of coarse lean beef--wash it clean and lay it in your
+pot, put in the same ingredients as for the shin soup, with the same
+quantity of water, and follow the process directed for that. Strain the
+soup through a sieve, and serve it up clear, with nothing more than
+toasted bread in it; two table-spoonsful of mushroom catsup will add a
+fine flavour to the soup.
diff --git a/tests/resources/rebase/oyster.txt b/tests/resources/rebase/oyster.txt
new file mode 100644
index 0000000..68af1fc
--- /dev/null
+++ b/tests/resources/rebase/oyster.txt
@@ -0,0 +1,13 @@
+OYSTER SOUP.
+
+Wash and drain two quarts of oysters, put them on with three quarts of
+water, three onions chopped up, two or three slices of lean ham, pepper
+and salt; boil it till reduced one-half, strain it through a sieve,
+return the liquid into the pot, put in one quart of fresh oysters, boil
+it till they are sufficiently done, and thicken the soup with four
+spoonsful of flour, two gills of rich cream, and the yelks of six new
+laid eggs beaten well; boil it a few minutes after the thickening is put
+in. Take care that it does not curdle, and that the flour is not in
+lumps; serve it up with the last oysters that were put in. If the
+flavour of thyme be agreeable, you may put in a little, but take care
+that it does not boil in it long enough to discolour the soup.
diff --git a/tests/resources/rebase/veal.txt b/tests/resources/rebase/veal.txt
new file mode 100644
index 0000000..a7b0665
--- /dev/null
+++ b/tests/resources/rebase/veal.txt
@@ -0,0 +1,18 @@
+VEAL SOUP.
+
+Put into a pot three quarts of water, three onions cut small, one
+spoonful of black pepper pounded, and two of salt, with two or three
+slices of lean ham; let it boil steadily two hours; skim it
+occasionally, then put into it a shin of veal, let it boil two hours
+longer; take out the slices of ham, and skim off the grease if any
+should rise, take a gill of good cream, mix with it two table-spoonsful
+of flour very nicely, and the yelks of two eggs beaten well, strain this
+mixture, and add some chopped parsley; pour some soup on by degrees,
+stir it well, and pour it into the pot, continuing to stir until it has
+boiled two or three minutes to take off the raw taste of the eggs. If
+the cream be not perfectly sweet, and the eggs quite new, the thickening
+will curdle in the soup. For a change you may put a dozen ripe tomatos
+in, first taking off their skins, by letting them stand a few minutes in
+hot water, when they may be easily peeled. When made in this way you
+must thicken it with the flour only. Any part of the veal may be used,
+but the shin or knuckle is the nicest.