Commit 0c7f49dd4316b332f30b4ea72a657bace41e1245

Patrick Steinhardt 2017-06-30T13:39:01

Make sure to always include "common.h" first Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.

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
diff --git a/src/annotated_commit.c b/src/annotated_commit.c
index c2c770c..72ba80a 100644
--- a/src/annotated_commit.c
+++ b/src/annotated_commit.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "annotated_commit.h"
+
 #include "refs.h"
 #include "cache.h"
 
diff --git a/src/annotated_commit.h b/src/annotated_commit.h
index 3ac8b5f..b390066 100644
--- a/src/annotated_commit.h
+++ b/src/annotated_commit.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_annotated_commit_h__
 #define INCLUDE_annotated_commit_h__
 
+#include "common.h"
+
 #include "oidarray.h"
 
 #include "git2/oid.h"
diff --git a/src/apply.c b/src/apply.c
index 595f5f3..7801a0a 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "apply.h"
+
 #include <assert.h>
 
 #include "git2/patch.h"
@@ -12,7 +14,6 @@
 #include "array.h"
 #include "patch.h"
 #include "fileops.h"
-#include "apply.h"
 #include "delta.h"
 #include "zstream.h"
 
diff --git a/src/apply.h b/src/apply.h
index 96e0f55..b29460c 100644
--- a/src/apply.h
+++ b/src/apply.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_apply_h__
 #define INCLUDE_apply_h__
 
+#include "common.h"
+
 #include "git2/patch.h"
 #include "buffer.h"
 
diff --git a/src/attr.c b/src/attr.c
index fe3ccf4..17309d0 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "attr.h"
+
 #include "repository.h"
 #include "sysdir.h"
 #include "config.h"
diff --git a/src/attr.h b/src/attr.h
index f9f216d..9775652 100644
--- a/src/attr.h
+++ b/src/attr.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_attr_h__
 #define INCLUDE_attr_h__
 
+#include "common.h"
+
 #include "attr_file.h"
 #include "attrcache.h"
 
diff --git a/src/attr_file.c b/src/attr_file.c
index 0ac4c9c..55d0c38 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -5,10 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "attr_file.h"
+
 #include "repository.h"
 #include "filebuf.h"
-#include "attr_file.h"
 #include "attrcache.h"
 #include "git2/blob.h"
 #include "git2/tree.h"
diff --git a/src/attr_file.h b/src/attr_file.h
index a9af240..fedf55a 100644
--- a/src/attr_file.h
+++ b/src/attr_file.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_attr_file_h__
 #define INCLUDE_attr_file_h__
 
+#include "common.h"
+
 #include "git2/oid.h"
 #include "git2/attr.h"
 #include "vector.h"
diff --git a/src/attrcache.c b/src/attrcache.c
index d516bb4..65e7b46 100644
--- a/src/attrcache.c
+++ b/src/attrcache.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "attrcache.h"
+
 #include "repository.h"
 #include "attr_file.h"
 #include "config.h"
diff --git a/src/attrcache.h b/src/attrcache.h
index b91edd3..f528911 100644
--- a/src/attrcache.h
+++ b/src/attrcache.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_attrcache_h__
 #define INCLUDE_attrcache_h__
 
+#include "common.h"
+
 #include "attr_file.h"
 #include "strmap.h"
 
diff --git a/src/blame.c b/src/blame.c
index 2c8584b..a923bf0 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -6,6 +6,7 @@
  */
 
 #include "blame.h"
+
 #include "git2/commit.h"
 #include "git2/revparse.h"
 #include "git2/revwalk.h"
diff --git a/src/blame.h b/src/blame.h
index d8db8d5..8fd3ee5 100644
--- a/src/blame.h
+++ b/src/blame.h
@@ -1,8 +1,9 @@
 #ifndef INCLUDE_blame_h__
 #define INCLUDE_blame_h__
 
-#include "git2/blame.h"
 #include "common.h"
+
+#include "git2/blame.h"
 #include "vector.h"
 #include "diff.h"
 #include "array.h"
diff --git a/src/blame_git.c b/src/blame_git.c
index 13f5cb4..3c221b3 100644
--- a/src/blame_git.c
+++ b/src/blame_git.c
@@ -6,6 +6,7 @@
  */
 
 #include "blame_git.h"
+
 #include "commit.h"
 #include "blob.h"
 #include "xdiff/xinclude.h"
diff --git a/src/blame_git.h b/src/blame_git.h
index 1891b0e..48b85a2 100644
--- a/src/blame_git.h
+++ b/src/blame_git.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_blame_git__
 #define INCLUDE_blame_git__
 
+#include "common.h"
+
 #include "blame.h"
 
 int git_blame__get_origin(
diff --git a/src/blob.c b/src/blob.c
index 19d3039..3396fe7 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -5,14 +5,14 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "blob.h"
+
 #include "git2/common.h"
 #include "git2/object.h"
 #include "git2/repository.h"
 #include "git2/odb_backend.h"
 
-#include "common.h"
 #include "filebuf.h"
-#include "blob.h"
 #include "filter.h"
 #include "buf_text.h"
 
diff --git a/src/blob.h b/src/blob.h
index 4cd9f1e..3f1f977 100644
--- a/src/blob.h
+++ b/src/blob.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_blob_h__
 #define INCLUDE_blob_h__
 
+#include "common.h"
+
 #include "git2/blob.h"
 #include "repository.h"
 #include "odb.h"
diff --git a/src/branch.c b/src/branch.c
index fe4955a..0697a77 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "branch.h"
+
 #include "commit.h"
 #include "tag.h"
 #include "config.h"
diff --git a/src/branch.h b/src/branch.h
index d02f2af..5ae227c 100644
--- a/src/branch.h
+++ b/src/branch.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_branch_h__
 #define INCLUDE_branch_h__
 
+#include "common.h"
+
 #include "buffer.h"
 
 int git_branch_upstream__name(
diff --git a/src/buf_text.h b/src/buf_text.h
index c9c55af..163bef1 100644
--- a/src/buf_text.h
+++ b/src/buf_text.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_buf_text_h__
 #define INCLUDE_buf_text_h__
 
+#include "common.h"
+
 #include "buffer.h"
 
 typedef enum {
diff --git a/src/cache.c b/src/cache.c
index c92a3a7..cdd1297 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -5,12 +5,12 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "cache.h"
+
 #include "repository.h"
 #include "commit.h"
 #include "thread-utils.h"
 #include "util.h"
-#include "cache.h"
 #include "odb.h"
 #include "object.h"
 #include "git2/oid.h"
diff --git a/src/cache.h b/src/cache.h
index 0f0bfcf..9c09954 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_cache_h__
 #define INCLUDE_cache_h__
 
+#include "common.h"
+
 #include "git2/common.h"
 #include "git2/oid.h"
 #include "git2/odb.h"
diff --git a/src/checkout.c b/src/checkout.c
index 25018d2..6c7a944 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -5,10 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include <assert.h>
-
 #include "checkout.h"
 
+#include <assert.h>
+
 #include "git2/repository.h"
 #include "git2/refs.h"
 #include "git2/tree.h"
diff --git a/src/checkout.h b/src/checkout.h
index 60aa29b..517fbf3 100644
--- a/src/checkout.h
+++ b/src/checkout.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_checkout_h__
 #define INCLUDE_checkout_h__
 
+#include "common.h"
+
 #include "git2/checkout.h"
 #include "iterator.h"
 
diff --git a/src/cherrypick.c b/src/cherrypick.c
index d8b6858..e42b748 100644
--- a/src/cherrypick.c
+++ b/src/cherrypick.c
@@ -6,6 +6,7 @@
 */
 
 #include "common.h"
+
 #include "repository.h"
 #include "filebuf.h"
 #include "merge.h"
diff --git a/src/clone.c b/src/clone.c
index 16ddfac..8764bb7 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "clone.h"
+
 #include <assert.h>
 
 #include "git2/clone.h"
@@ -16,7 +18,6 @@
 #include "git2/commit.h"
 #include "git2/tree.h"
 
-#include "common.h"
 #include "remote.h"
 #include "fileops.h"
 #include "refs.h"
diff --git a/src/clone.h b/src/clone.h
index fa20498..864b590 100644
--- a/src/clone.h
+++ b/src/clone.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_clone_h__
 #define INCLUDE_clone_h__
 
+#include "common.h"
+
 #include "git2/clone.h"
 
 extern int git_clone__should_clone_local(const char *url, git_clone_local_t local);
diff --git a/src/commit.c b/src/commit.c
index 4a34005..838688b 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -5,13 +5,14 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "commit.h"
+
 #include "git2/common.h"
 #include "git2/object.h"
 #include "git2/repository.h"
 #include "git2/signature.h"
 #include "git2/sys/commit.h"
 
-#include "common.h"
 #include "odb.h"
 #include "commit.h"
 #include "signature.h"
diff --git a/src/commit.h b/src/commit.h
index d01ac2b..781809d 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_commit_h__
 #define INCLUDE_commit_h__
 
+#include "common.h"
+
 #include "git2/commit.h"
 #include "tree.h"
 #include "repository.h"
diff --git a/src/commit_list.c b/src/commit_list.c
index 3bba58c..96bd9dc 100644
--- a/src/commit_list.c
+++ b/src/commit_list.c
@@ -6,7 +6,7 @@
  */
 
 #include "commit_list.h"
-#include "common.h"
+
 #include "revwalk.h"
 #include "pool.h"
 #include "odb.h"
diff --git a/src/commit_list.h b/src/commit_list.h
index 9746c28..a7551a2 100644
--- a/src/commit_list.h
+++ b/src/commit_list.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_commit_list_h__
 #define INCLUDE_commit_list_h__
 
+#include "common.h"
+
 #include "git2/oid.h"
 
 #define PARENT1  (1 << 0)
diff --git a/src/config.c b/src/config.c
index 169a628..602e0e8 100644
--- a/src/config.c
+++ b/src/config.c
@@ -5,9 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
-#include "sysdir.h"
 #include "config.h"
+
+#include "sysdir.h"
 #include "git2/config.h"
 #include "git2/sys/config.h"
 #include "vector.h"
diff --git a/src/config.h b/src/config.h
index 00c12b5..a5fcf2e 100644
--- a/src/config.h
+++ b/src/config.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_config_h__
 #define INCLUDE_config_h__
 
+#include "common.h"
+
 #include "git2.h"
 #include "git2/config.h"
 #include "vector.h"
diff --git a/src/config_cache.c b/src/config_cache.c
index 8407222..0efb1a7 100644
--- a/src/config_cache.c
+++ b/src/config_cache.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "fileops.h"
 #include "repository.h"
 #include "config.h"
diff --git a/src/config_file.c b/src/config_file.c
index e15d57b..e6eeab4 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "config_file.h"
+
 #include "config.h"
 #include "filebuf.h"
 #include "sysdir.h"
diff --git a/src/config_file.h b/src/config_file.h
index 654e6ca..11b8118 100644
--- a/src/config_file.h
+++ b/src/config_file.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_config_file_h__
 #define INCLUDE_config_file_h__
 
+#include "common.h"
+
 #include "git2/sys/config.h"
 #include "git2/config.h"
 
diff --git a/src/crlf.c b/src/crlf.c
index b8ae5cd..9af6007 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -5,12 +5,13 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #include "git2/attr.h"
 #include "git2/blob.h"
 #include "git2/index.h"
 #include "git2/sys/filter.h"
 
-#include "common.h"
 #include "fileops.h"
 #include "hash.h"
 #include "filter.h"
diff --git a/src/curl_stream.c b/src/curl_stream.c
index 4e0455c..24bf626 100644
--- a/src/curl_stream.c
+++ b/src/curl_stream.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "curl_stream.h"
+
 #ifdef GIT_CURL
 
 #include <curl/curl.h>
diff --git a/src/curl_stream.h b/src/curl_stream.h
index 283f0fe..debade7 100644
--- a/src/curl_stream.h
+++ b/src/curl_stream.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_curl_stream_h__
 #define INCLUDE_curl_stream_h__
 
+#include "common.h"
+
 #include "git2/sys/stream.h"
 
 extern int git_curl_stream_new(git_stream **out, const char *host, const char *port);
diff --git a/src/delta.h b/src/delta.h
index cc93729..f619873 100644
--- a/src/delta.h
+++ b/src/delta.h
@@ -6,6 +6,7 @@
 #define INCLUDE_git_delta_h__
 
 #include "common.h"
+
 #include "pack.h"
 
 typedef struct git_delta_index git_delta_index;
diff --git a/src/describe.c b/src/describe.c
index 4a1e253..edf8edf 100644
--- a/src/describe.c
+++ b/src/describe.c
@@ -4,12 +4,14 @@
  * 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 "git2/describe.h"
 #include "git2/strarray.h"
 #include "git2/diff.h"
 #include "git2/status.h"
 
-#include "common.h"
 #include "commit.h"
 #include "commit_list.h"
 #include "oidmap.h"
diff --git a/src/diff.c b/src/diff.c
index a93bd4c..1c16e9c 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -4,9 +4,10 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#include "git2/version.h"
-#include "common.h"
+
 #include "diff.h"
+
+#include "git2/version.h"
 #include "diff_generate.h"
 #include "patch.h"
 #include "commit.h"
diff --git a/src/diff.h b/src/diff.h
index 5750d2a..4e5dd93 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_diff_h__
 #define INCLUDE_diff_h__
 
+#include "common.h"
+
 #include "git2/diff.h"
 #include "git2/patch.h"
 #include "git2/sys/diff.h"
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 9109f31..8cd57cd 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -4,12 +4,12 @@
  * 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 "diff_driver.h"
 
 #include "git2/attr.h"
 
 #include "diff.h"
-#include "diff_driver.h"
 #include "strmap.h"
 #include "map.h"
 #include "buf_text.h"
diff --git a/src/diff_driver.h b/src/diff_driver.h
index 0706dcf..5691cac 100644
--- a/src/diff_driver.h
+++ b/src/diff_driver.h
@@ -8,6 +8,7 @@
 #define INCLUDE_diff_driver_h__
 
 #include "common.h"
+
 #include "buffer.h"
 
 typedef struct git_diff_driver_registry git_diff_driver_registry;
diff --git a/src/diff_file.c b/src/diff_file.c
index d5fc5e9..270d59b 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -4,12 +4,13 @@
  * 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 "diff_file.h"
+
 #include "git2/blob.h"
 #include "git2/submodule.h"
 #include "diff.h"
 #include "diff_generate.h"
-#include "diff_file.h"
 #include "odb.h"
 #include "fileops.h"
 #include "filter.h"
diff --git a/src/diff_file.h b/src/diff_file.h
index 0d54b6d..5da7a7b 100644
--- a/src/diff_file.h
+++ b/src/diff_file.h
@@ -8,6 +8,7 @@
 #define INCLUDE_diff_file_h__
 
 #include "common.h"
+
 #include "diff.h"
 #include "diff_driver.h"
 #include "map.h"
diff --git a/src/diff_generate.c b/src/diff_generate.c
index f6cc04f..6436ab9 100644
--- a/src/diff_generate.c
+++ b/src/diff_generate.c
@@ -4,9 +4,10 @@
  * 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 "diff.h"
+
 #include "diff_generate.h"
+
+#include "diff.h"
 #include "patch_generate.h"
 #include "fileops.h"
 #include "config.h"
diff --git a/src/diff_generate.h b/src/diff_generate.h
index 8b974be..8de2a06 100644
--- a/src/diff_generate.h
+++ b/src/diff_generate.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_diff_generate_h__
 #define INCLUDE_diff_generate_h__
 
+#include "common.h"
+
 #include "diff.h"
 #include "pool.h"
 #include "index.h"
diff --git a/src/diff_parse.c b/src/diff_parse.c
index 5e3a7a1..78da3b6 100644
--- a/src/diff_parse.c
+++ b/src/diff_parse.c
@@ -4,9 +4,10 @@
  * 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 "diff.h"
+
 #include "diff_parse.h"
+
+#include "diff.h"
 #include "patch.h"
 #include "patch_parse.h"
 
diff --git a/src/diff_parse.h b/src/diff_parse.h
index c47d4cb..8767821 100644
--- a/src/diff_parse.h
+++ b/src/diff_parse.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_diff_parse_h__
 #define INCLUDE_diff_parse_h__
 
+#include "common.h"
+
 #include "diff.h"
 
 typedef struct {
diff --git a/src/diff_print.c b/src/diff_print.c
index 5aa8a37..28ae384 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -4,7 +4,9 @@
  * 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 "diff.h"
 #include "diff_file.h"
 #include "patch_generate.h"
diff --git a/src/diff_stats.c b/src/diff_stats.c
index 2005712..583c684 100644
--- a/src/diff_stats.c
+++ b/src/diff_stats.c
@@ -4,7 +4,9 @@
  * 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 "vector.h"
 #include "diff.h"
 #include "patch_generate.h"
diff --git a/src/diff_tform.c b/src/diff_tform.c
index b004ddd..c0461a3 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -4,7 +4,8 @@
  * 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 "diff_tform.h"
 
 #include "git2/config.h"
 #include "git2/blob.h"
diff --git a/src/diff_tform.h b/src/diff_tform.h
index dbb4b54..a31c40f 100644
--- a/src/diff_tform.h
+++ b/src/diff_tform.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_diff_tform_h__
 #define INCLUDE_diff_tform_h__
 
+#include "common.h"
+
 #include "diff_file.h"
 
 extern int git_diff_find_similar__hashsig_for_file(
diff --git a/src/diff_xdiff.c b/src/diff_xdiff.c
index 60c4d85..5e10db1 100644
--- a/src/diff_xdiff.c
+++ b/src/diff_xdiff.c
@@ -4,11 +4,12 @@
  * 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 "diff_xdiff.h"
+
 #include "git2/errors.h"
-#include "common.h"
 #include "diff.h"
 #include "diff_driver.h"
-#include "diff_xdiff.h"
 #include "patch_generate.h"
 
 static int git_xdiff_scan_int(const char **str, int *value)
diff --git a/src/diff_xdiff.h b/src/diff_xdiff.h
index 8837598..aca80b1 100644
--- a/src/diff_xdiff.h
+++ b/src/diff_xdiff.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_diff_xdiff_h__
 #define INCLUDE_diff_xdiff_h__
 
+#include "common.h"
+
 #include "diff.h"
 #include "xdiff/xdiff.h"
 #include "patch_generate.h"
diff --git a/src/errors.c b/src/errors.c
index 91acc35..a874163 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -4,7 +4,9 @@
  * 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 "global.h"
 #include "posix.h"
 #include "buffer.h"
diff --git a/src/fetch.c b/src/fetch.c
index f408a51..0b22b36 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -5,16 +5,16 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "fetch.h"
+
 #include "git2/oid.h"
 #include "git2/refs.h"
 #include "git2/revwalk.h"
 #include "git2/transport.h"
 
-#include "common.h"
 #include "remote.h"
 #include "refspec.h"
 #include "pack.h"
-#include "fetch.h"
 #include "netops.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/src/fetch.h b/src/fetch.h
index 4cdbf3b..1c75af9 100644
--- a/src/fetch.h
+++ b/src/fetch.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_fetch_h__
 #define INCLUDE_fetch_h__
 
+#include "common.h"
+
 #include "git2/remote.h"
 
 #include "netops.h"
diff --git a/src/fetchhead.c b/src/fetchhead.c
index 6e6f3eb..ac25723 100644
--- a/src/fetchhead.c
+++ b/src/fetchhead.c
@@ -5,11 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "fetchhead.h"
+
 #include "git2/types.h"
 #include "git2/oid.h"
 
-#include "fetchhead.h"
-#include "common.h"
 #include "buffer.h"
 #include "fileops.h"
 #include "filebuf.h"
diff --git a/src/fetchhead.h b/src/fetchhead.h
index 69a1e86..9e51710 100644
--- a/src/fetchhead.h
+++ b/src/fetchhead.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_fetchhead_h__
 #define INCLUDE_fetchhead_h__
 
+#include "common.h"
+
 #include "oid.h"
 #include "vector.h"
 
diff --git a/src/filebuf.c b/src/filebuf.c
index 80250cc..8b7e489 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -4,8 +4,9 @@
  * 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 "filebuf.h"
+
 #include "fileops.h"
 
 static const size_t WRITE_BUFFER_SIZE = (4096 * 2);
diff --git a/src/filebuf.h b/src/filebuf.h
index c65aea7..f51ff23 100644
--- a/src/filebuf.h
+++ b/src/filebuf.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_filebuf_h__
 #define INCLUDE_filebuf_h__
 
+#include "common.h"
+
 #include "fileops.h"
 #include "hash.h"
 #include <zlib.h>
diff --git a/src/fileops.c b/src/fileops.c
index 2f3f58d..ad3f67e 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -4,8 +4,9 @@
  * 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 "fileops.h"
+
 #include "global.h"
 #include "strmap.h"
 #include <ctype.h>
diff --git a/src/fileops.h b/src/fileops.h
index 46886b0..fd54412 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -8,6 +8,7 @@
 #define INCLUDE_fileops_h__
 
 #include "common.h"
+
 #include "map.h"
 #include "posix.h"
 #include "path.h"
diff --git a/src/filter.c b/src/filter.c
index 361e085..6ab0979 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -5,10 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "filter.h"
+
 #include "common.h"
 #include "fileops.h"
 #include "hash.h"
-#include "filter.h"
 #include "repository.h"
 #include "global.h"
 #include "git2/sys/filter.h"
diff --git a/src/filter.h b/src/filter.h
index 9bd835f..b1c403b 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -8,6 +8,7 @@
 #define INCLUDE_filter_h__
 
 #include "common.h"
+
 #include "attr_file.h"
 #include "git2/filter.h"
 
diff --git a/src/fnmatch.c b/src/fnmatch.c
index 33c8a25..3cc2a27 100644
--- a/src/fnmatch.c
+++ b/src/fnmatch.c
@@ -44,12 +44,12 @@
  * Compares a filename or pathname to a pattern.
  */
 
+#include "fnmatch.h"
+
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 
-#include "fnmatch.h"
-
 #define EOS		'\0'
 
 #define RANGE_MATCH		1
diff --git a/src/global.c b/src/global.c
index afa57e1..c6847a4 100644
--- a/src/global.c
+++ b/src/global.c
@@ -4,8 +4,9 @@
  * 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 "global.h"
+
 #include "hash.h"
 #include "sysdir.h"
 #include "filter.h"
diff --git a/src/global.h b/src/global.h
index 88f40aa..b75ad6f 100644
--- a/src/global.h
+++ b/src/global.h
@@ -8,6 +8,7 @@
 #define INCLUDE_global_h__
 
 #include "common.h"
+
 #include "mwindow.h"
 #include "hash.h"
 
diff --git a/src/graph.c b/src/graph.c
index 948f7d3..df82f0f 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #include "revwalk.h"
 #include "merge.h"
 #include "git2/graph.h"
diff --git a/src/hash.c b/src/hash.c
index f3645a9..cc6676d 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -5,7 +5,6 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "hash.h"
 
 int git_hash_buf(git_oid *out, const void *data, size_t len)
diff --git a/src/hash.h b/src/hash.h
index 0db0339..cce3a7f 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_hash_h__
 #define INCLUDE_hash_h__
 
+#include "common.h"
+
 #include "git2/oid.h"
 
 typedef struct git_hash_prov git_hash_prov;
diff --git a/src/hash/hash_generic.c b/src/hash/hash_generic.c
index 472a7a6..7b33b61 100644
--- a/src/hash/hash_generic.c
+++ b/src/hash/hash_generic.c
@@ -5,9 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "hash_generic.h"
+
 #include "hash.h"
-#include "hash/hash_generic.h"
 
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 
diff --git a/src/hash/hash_generic.h b/src/hash/hash_generic.h
index daeb1cd..114b607 100644
--- a/src/hash/hash_generic.h
+++ b/src/hash/hash_generic.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_hash_generic_h__
 #define INCLUDE_hash_generic_h__
 
+#include "common.h"
+
 #include "hash.h"
 
 struct git_hash_ctx {
diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c
index 6bae53e..4d53a57 100644
--- a/src/hash/hash_win32.c
+++ b/src/hash/hash_win32.c
@@ -5,10 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "hash_win32.h"
+
 #include "global.h"
 #include "hash.h"
-#include "hash/hash_win32.h"
 
 #include <wincrypt.h>
 #include <strsafe.h>
diff --git a/src/hash/hash_win32.h b/src/hash/hash_win32.h
index 2eee5ca..187c072 100644
--- a/src/hash/hash_win32.h
+++ b/src/hash/hash_win32.h
@@ -9,6 +9,7 @@
 #define INCLUDE_hash_win32_h__
 
 #include "common.h"
+
 #include "hash.h"
 
 #include <wincrypt.h>
diff --git a/src/hashsig.c b/src/hashsig.c
index bea5383..30d0594 100644
--- a/src/hashsig.c
+++ b/src/hashsig.c
@@ -4,6 +4,9 @@
  * 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 "git2/sys/hashsig.h"
 #include "fileops.h"
 #include "util.h"
diff --git a/src/ident.c b/src/ident.c
index 4718ed6..7eccf9a 100644
--- a/src/ident.c
+++ b/src/ident.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #include "git2/sys/filter.h"
 #include "filter.h"
 #include "buffer.h"
diff --git a/src/idxmap.h b/src/idxmap.h
index dc702c3..f7e903a 100644
--- a/src/idxmap.h
+++ b/src/idxmap.h
@@ -7,8 +7,9 @@
 #ifndef INCLUDE_idxmap_h__
 #define INCLUDE_idxmap_h__
 
-#include <ctype.h>
 #include "common.h"
+
+#include <ctype.h>
 #include "git2/index.h"
 
 #define kmalloc git__malloc
diff --git a/src/ignore.c b/src/ignore.c
index 6496dd1..4c0d26d 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -5,9 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "ignore.h"
+
 #include "git2/ignore.h"
 #include "common.h"
-#include "ignore.h"
 #include "attrcache.h"
 #include "path.h"
 #include "config.h"
diff --git a/src/ignore.h b/src/ignore.h
index 876c8e0..5895d3f 100644
--- a/src/ignore.h
+++ b/src/ignore.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_ignore_h__
 #define INCLUDE_ignore_h__
 
+#include "common.h"
+
 #include "repository.h"
 #include "vector.h"
 #include "attr_file.h"
diff --git a/src/index.c b/src/index.c
index c29e90f..b7602fb 100644
--- a/src/index.c
+++ b/src/index.c
@@ -5,11 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "index.h"
+
 #include <stddef.h>
 
-#include "common.h"
 #include "repository.h"
-#include "index.h"
 #include "tree.h"
 #include "tree-cache.h"
 #include "hash.h"
diff --git a/src/index.h b/src/index.h
index 9918f14..0f1c095 100644
--- a/src/index.h
+++ b/src/index.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_index_h__
 #define INCLUDE_index_h__
 
+#include "common.h"
+
 #include "fileops.h"
 #include "filebuf.h"
 #include "vector.h"
diff --git a/src/indexer.c b/src/indexer.c
index 15f6cc2..766bbc3 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -5,10 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "indexer.h"
+
 #include "git2/indexer.h"
 #include "git2/object.h"
 
-#include "common.h"
 #include "pack.h"
 #include "mwindow.h"
 #include "posix.h"
diff --git a/src/indexer.h b/src/indexer.h
index cae3140..8ee6115 100644
--- a/src/indexer.h
+++ b/src/indexer.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_indexer_h__
 #define INCLUDE_indexer_h__
 
+#include "common.h"
+
 #include "git2/indexer.h"
 
 extern void git_indexer__set_fsync(git_indexer *idx, int do_fsync);
diff --git a/src/iterator.c b/src/iterator.c
index 8fc62c0..9600312 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -6,6 +6,7 @@
  */
 
 #include "iterator.h"
+
 #include "tree.h"
 #include "index.h"
 
diff --git a/src/iterator.h b/src/iterator.h
index 0b239a5..0bcb128 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -8,6 +8,7 @@
 #define INCLUDE_iterator_h__
 
 #include "common.h"
+
 #include "git2/index.h"
 #include "vector.h"
 #include "buffer.h"
diff --git a/src/merge.c b/src/merge.c
index e6fa7dc..72cfa46 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -5,13 +5,13 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "merge.h"
+
 #include "posix.h"
 #include "buffer.h"
 #include "repository.h"
 #include "revwalk.h"
 #include "commit_list.h"
-#include "merge.h"
 #include "path.h"
 #include "refs.h"
 #include "object.h"
diff --git a/src/merge.h b/src/merge.h
index f8cac16..173a1b4 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_merge_h__
 #define INCLUDE_merge_h__
 
+#include "common.h"
+
 #include "vector.h"
 #include "commit_list.h"
 #include "pool.h"
diff --git a/src/merge_driver.c b/src/merge_driver.c
index 0f35d23..ea4bd27 100644
--- a/src/merge_driver.c
+++ b/src/merge_driver.c
@@ -5,11 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "merge_driver.h"
+
 #include "vector.h"
 #include "global.h"
 #include "merge.h"
-#include "merge_driver.h"
 #include "git2/merge.h"
 #include "git2/sys/merge.h"
 
diff --git a/src/merge_driver.h b/src/merge_driver.h
index bde2750..6b7da52 100644
--- a/src/merge_driver.h
+++ b/src/merge_driver.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_merge_driver_h__
 #define INCLUDE_merge_driver_h__
 
+#include "common.h"
+
 #include "git2/merge.h"
 #include "git2/index.h"
 #include "git2/sys/merge.h"
diff --git a/src/merge_file.c b/src/merge_file.c
index 5ecd8f4..a54d6bd 100644
--- a/src/merge_file.c
+++ b/src/merge_file.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "repository.h"
 #include "posix.h"
 #include "fileops.h"
diff --git a/src/message.h b/src/message.h
index 3c4b8dc..88fc788 100644
--- a/src/message.h
+++ b/src/message.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_message_h__
 #define INCLUDE_message_h__
 
+#include "common.h"
+
 #include "git2/message.h"
 #include "buffer.h"
 
diff --git a/src/mwindow.c b/src/mwindow.c
index 7bb9dbb..38d0352 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "mwindow.h"
+
 #include "vector.h"
 #include "fileops.h"
 #include "map.h"
diff --git a/src/mwindow.h b/src/mwindow.h
index bdde9e0..ea962d1 100644
--- a/src/mwindow.h
+++ b/src/mwindow.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_mwindow__
 #define INCLUDE_mwindow__
 
+#include "common.h"
+
 #include "map.h"
 #include "vector.h"
 
diff --git a/src/netops.c b/src/netops.c
index 4b73baa..68f404d 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -5,11 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "netops.h"
+
 #include <ctype.h>
 #include "git2/errors.h"
 
-#include "common.h"
-#include "netops.h"
 #include "posix.h"
 #include "buffer.h"
 #include "http_parser.h"
diff --git a/src/netops.h b/src/netops.h
index b7170a0..75fd9a5 100644
--- a/src/netops.h
+++ b/src/netops.h
@@ -7,8 +7,9 @@
 #ifndef INCLUDE_netops_h__
 #define INCLUDE_netops_h__
 
-#include "posix.h"
 #include "common.h"
+
+#include "posix.h"
 #include "stream.h"
 
 #ifdef GIT_OPENSSL
diff --git a/src/object.c b/src/object.c
index 2da36a2..4d069a3 100644
--- a/src/object.c
+++ b/src/object.c
@@ -4,9 +4,11 @@
  * 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 "object.h"
+
 #include "git2/object.h"
 
-#include "common.h"
 #include "repository.h"
 
 #include "commit.h"
diff --git a/src/object.h b/src/object.h
index dd227d1..ff61c1d 100644
--- a/src/object.h
+++ b/src/object.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_object_h__
 #define INCLUDE_object_h__
 
+#include "common.h"
+
 #include "repository.h"
 
 extern bool git_object__strict_input_validation;
diff --git a/src/object_api.c b/src/object_api.c
index e0d8760..75efa4d 100644
--- a/src/object_api.c
+++ b/src/object_api.c
@@ -4,11 +4,12 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#include "git2/object.h"
 
 #include "common.h"
-#include "repository.h"
 
+#include "git2/object.h"
+
+#include "repository.h"
 #include "commit.h"
 #include "tree.h"
 #include "blob.h"
diff --git a/src/odb.c b/src/odb.c
index ae8f247..7da391b 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -5,13 +5,13 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "odb.h"
+
 #include <zlib.h>
 #include "git2/object.h"
 #include "git2/sys/odb_backend.h"
 #include "fileops.h"
 #include "hash.h"
-#include "odb.h"
 #include "delta.h"
 #include "filter.h"
 #include "repository.h"
diff --git a/src/odb.h b/src/odb.h
index 61d687a..6845b22 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_odb_h__
 #define INCLUDE_odb_h__
 
+#include "common.h"
+
 #include "git2/odb.h"
 #include "git2/oid.h"
 #include "git2/types.h"
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 99fdcb4..72b47f0 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include <zlib.h>
 #include "git2/object.h"
 #include "git2/sys/odb_backend.h"
diff --git a/src/odb_mempack.c b/src/odb_mempack.c
index d6f2fb4..0c05f05 100644
--- a/src/odb_mempack.c
+++ b/src/odb_mempack.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "git2/object.h"
 #include "git2/sys/odb_backend.h"
 #include "fileops.h"
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 51770a8..20aff53 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include <zlib.h>
 #include "git2/repository.h"
 #include "git2/indexer.h"
diff --git a/src/offmap.h b/src/offmap.h
index f9d2483..0b0896b 100644
--- a/src/offmap.h
+++ b/src/offmap.h
@@ -8,6 +8,7 @@
 #define INCLUDE_offmap_h__
 
 #include "common.h"
+
 #include "git2/types.h"
 
 #define kmalloc git__malloc
diff --git a/src/oid.c b/src/oid.c
index 9dc7191..0c63abb 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "oid.h"
+
 #include "git2/oid.h"
 #include "repository.h"
 #include "global.h"
diff --git a/src/oid.h b/src/oid.h
index 922a2a3..70a9277 100644
--- a/src/oid.h
+++ b/src/oid.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_oid_h__
 #define INCLUDE_oid_h__
 
+#include "common.h"
+
 #include "git2/oid.h"
 
 /**
diff --git a/src/oidarray.c b/src/oidarray.c
index 1d51a29..fda3b63 100644
--- a/src/oidarray.c
+++ b/src/oidarray.c
@@ -5,8 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "git2/oidarray.h"
 #include "oidarray.h"
+
+#include "git2/oidarray.h"
 #include "array.h"
 
 void git_oidarray_free(git_oidarray *arr)
diff --git a/src/oidarray.h b/src/oidarray.h
index a7215ae..f051a0e 100644
--- a/src/oidarray.h
+++ b/src/oidarray.h
@@ -8,6 +8,7 @@
 #define INCLUDE_oidarray_h__
 
 #include "common.h"
+
 #include "git2/oidarray.h"
 #include "array.h"
 
diff --git a/src/oidmap.h b/src/oidmap.h
index 5632224..49f129e 100644
--- a/src/oidmap.h
+++ b/src/oidmap.h
@@ -8,6 +8,7 @@
 #define INCLUDE_oidmap_h__
 
 #include "common.h"
+
 #include "git2/oid.h"
 
 #define kmalloc git__malloc
diff --git a/src/openssl_stream.c b/src/openssl_stream.c
index 759c501..3860c4f 100644
--- a/src/openssl_stream.c
+++ b/src/openssl_stream.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "openssl_stream.h"
+
 #ifdef GIT_OPENSSL
 
 #include <ctype.h>
@@ -13,7 +15,6 @@
 #include "posix.h"
 #include "stream.h"
 #include "socket_stream.h"
-#include "openssl_stream.h"
 #include "netops.h"
 #include "git2/transport.h"
 #include "git2/sys/openssl.h"
diff --git a/src/openssl_stream.h b/src/openssl_stream.h
index f5e59da..2dcfcc9 100644
--- a/src/openssl_stream.h
+++ b/src/openssl_stream.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_openssl_stream_h__
 #define INCLUDE_openssl_stream_h__
 
+#include "common.h"
+
 #include "git2/sys/stream.h"
 
 extern int git_openssl_stream_global_init(void);
diff --git a/src/pack.c b/src/pack.c
index f8d0dc9..8f3c8ab 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -5,9 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
-#include "odb.h"
 #include "pack.h"
+
+#include "odb.h"
 #include "delta.h"
 #include "sha1_lookup.h"
 #include "mwindow.h"
diff --git a/src/pack.h b/src/pack.h
index e2bf165..c0ca74f 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -8,11 +8,12 @@
 #ifndef INCLUDE_pack_h__
 #define INCLUDE_pack_h__
 
+#include "common.h"
+
 #include <zlib.h>
 
 #include "git2/oid.h"
 
-#include "common.h"
 #include "map.h"
 #include "mwindow.h"
 #include "odb.h"
diff --git a/src/patch.c b/src/patch.c
index 519cbb8..5e32951 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -5,10 +5,10 @@
 * a Linking Exception. For full terms see the included COPYING file.
 */
 
-#include "git2/patch.h"
-#include "diff.h"
 #include "patch.h"
 
+#include "git2/patch.h"
+#include "diff.h"
 
 int git_patch__invoke_callbacks(
 	git_patch *patch,
diff --git a/src/patch.h b/src/patch.h
index 525ae70..156d131 100644
--- a/src/patch.h
+++ b/src/patch.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_patch_h__
 #define INCLUDE_patch_h__
 
+#include "common.h"
+
 #include "git2/patch.h"
 #include "array.h"
 
diff --git a/src/patch_generate.c b/src/patch_generate.c
index 804fc0e..9363033 100644
--- a/src/patch_generate.c
+++ b/src/patch_generate.c
@@ -4,13 +4,14 @@
  * 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 "patch_generate.h"
+
 #include "git2/blob.h"
 #include "diff.h"
 #include "diff_generate.h"
 #include "diff_file.h"
 #include "diff_driver.h"
-#include "patch_generate.h"
 #include "diff_xdiff.h"
 #include "delta.h"
 #include "zstream.h"
diff --git a/src/patch_generate.h b/src/patch_generate.h
index 2e89b5c..20f78cb 100644
--- a/src/patch_generate.h
+++ b/src/patch_generate.h
@@ -8,6 +8,7 @@
 #define INCLUDE_patch_generate_h__
 
 #include "common.h"
+
 #include "diff.h"
 #include "diff_file.h"
 #include "patch.h"
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 0a9edcd..a531eec 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -4,9 +4,11 @@
  * 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 "patch_parse.h"
+
 #include "git2/patch.h"
 #include "patch.h"
-#include "patch_parse.h"
 #include "diff_parse.h"
 #include "path.h"
 
diff --git a/src/patch_parse.h b/src/patch_parse.h
index 5c4d04f..f27651e 100644
--- a/src/patch_parse.h
+++ b/src/patch_parse.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_patch_parse_h__
 #define INCLUDE_patch_parse_h__
 
+#include "common.h"
+
 #include "patch.h"
 
 typedef struct {
diff --git a/src/path.c b/src/path.c
index 5fc7a05..ea0a3c3 100644
--- a/src/path.c
+++ b/src/path.c
@@ -4,8 +4,9 @@
  * 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 "path.h"
+
 #include "posix.h"
 #include "repository.h"
 #ifdef GIT_WIN32
diff --git a/src/path.h b/src/path.h
index fb45a65..360372c 100644
--- a/src/path.h
+++ b/src/path.h
@@ -8,6 +8,7 @@
 #define INCLUDE_path_h__
 
 #include "common.h"
+
 #include "posix.h"
 #include "buffer.h"
 #include "vector.h"
diff --git a/src/pathspec.c b/src/pathspec.c
index 00dba4f..998b6fb 100644
--- a/src/pathspec.c
+++ b/src/pathspec.c
@@ -5,9 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "pathspec.h"
+
 #include "git2/pathspec.h"
 #include "git2/diff.h"
-#include "pathspec.h"
 #include "buf_text.h"
 #include "attr_file.h"
 #include "iterator.h"
diff --git a/src/pathspec.h b/src/pathspec.h
index 40cd21c..c4d1a83 100644
--- a/src/pathspec.h
+++ b/src/pathspec.h
@@ -8,7 +8,8 @@
 #define INCLUDE_pathspec_h__
 
 #include "common.h"
-#include <git2/pathspec.h>
+
+#include "git2/pathspec.h"
 #include "buffer.h"
 #include "vector.h"
 #include "pool.h"
diff --git a/src/pool.c b/src/pool.c
index 57ce46e..c0efe9c 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -6,6 +6,7 @@
  */
 
 #include "pool.h"
+
 #include "posix.h"
 #ifndef GIT_WIN32
 #include <unistd.h>
diff --git a/src/pool.h b/src/pool.h
index f61f169..92ddf99 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -8,6 +8,7 @@
 #define INCLUDE_pool_h__
 
 #include "common.h"
+
 #include "vector.h"
 
 typedef struct git_pool_page git_pool_page;
diff --git a/src/posix.c b/src/posix.c
index fd9188a..6e7985e 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -4,8 +4,9 @@
  * 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 "posix.h"
+
 #include "path.h"
 #include <stdio.h>
 #include <ctype.h>
diff --git a/src/posix.h b/src/posix.h
index d26371b..3e3bcb2 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -8,6 +8,7 @@
 #define INCLUDE_posix_h__
 
 #include "common.h"
+
 #include <fcntl.h>
 #include <time.h>
 #include "fnmatch.h"
diff --git a/src/pqueue.c b/src/pqueue.c
index 9341d1a..3820e99 100644
--- a/src/pqueue.c
+++ b/src/pqueue.c
@@ -6,6 +6,7 @@
  */
 
 #include "pqueue.h"
+
 #include "util.h"
 
 #define PQUEUE_LCHILD_OF(I) (((I)<<1)+1)
diff --git a/src/pqueue.h b/src/pqueue.h
index 76b1491..c0a6cd4 100644
--- a/src/pqueue.h
+++ b/src/pqueue.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_pqueue_h__
 #define INCLUDE_pqueue_h__
 
+#include "common.h"
+
 #include "vector.h"
 
 typedef git_vector git_pqueue;
diff --git a/src/proxy.c b/src/proxy.c
index f53ac11..b07371d 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "proxy.h"
+
 #include "git2/proxy.h"
 
 int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
diff --git a/src/proxy.h b/src/proxy.h
index bf93827..7582301 100644
--- a/src/proxy.h
+++ b/src/proxy.h
@@ -7,8 +7,10 @@
 #ifndef INCLUDE_proxy_h__
 #define INCLUDE_proxy_h__
 
+#include "common.h"
+
 #include "git2/proxy.h"
 
 extern int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/push.c b/src/push.c
index 09c2340..c2abbb9 100644
--- a/src/push.c
+++ b/src/push.c
@@ -5,14 +5,14 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "push.h"
+
 #include "git2.h"
 
-#include "common.h"
 #include "pack.h"
 #include "pack-objects.h"
 #include "remote.h"
 #include "vector.h"
-#include "push.h"
 #include "tree.h"
 
 static int push_spec_rref_cmp(const void *a, const void *b)
diff --git a/src/push.h b/src/push.h
index e32ad2f..31ac436 100644
--- a/src/push.h
+++ b/src/push.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_push_h__
 #define INCLUDE_push_h__
 
+#include "common.h"
+
 #include "git2.h"
 #include "refspec.h"
 
diff --git a/src/rebase.c b/src/rebase.c
index f528031..3be7512 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "buffer.h"
 #include "repository.h"
 #include "posix.h"
diff --git a/src/refdb.c b/src/refdb.c
index 1ee0efb..c162a15 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -5,8 +5,7 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
-#include "posix.h"
+#include "refdb.h"
 
 #include "git2/object.h"
 #include "git2/refs.h"
@@ -14,9 +13,9 @@
 #include "git2/sys/refdb_backend.h"
 
 #include "hash.h"
-#include "refdb.h"
 #include "refs.h"
 #include "reflog.h"
+#include "posix.h"
 
 int git_refdb_new(git_refdb **out, git_repository *repo)
 {
diff --git a/src/refdb.h b/src/refdb.h
index 4ee3b80..2d4ec75 100644
--- a/src/refdb.h
+++ b/src/refdb.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_refdb_h__
 #define INCLUDE_refdb_h__
 
+#include "common.h"
+
 #include "git2/refdb.h"
 #include "repository.h"
 
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index eb135dc..ade734c 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "refdb_fs.h"
+
 #include "refs.h"
 #include "hash.h"
 #include "repository.h"
@@ -13,7 +15,6 @@
 #include "pack.h"
 #include "reflog.h"
 #include "refdb.h"
-#include "refdb_fs.h"
 #include "iterator.h"
 #include "sortedcache.h"
 #include "signature.h"
diff --git a/src/refdb_fs.h b/src/refdb_fs.h
index a979383..0c84814 100644
--- a/src/refdb_fs.h
+++ b/src/refdb_fs.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_refdb_fs_h__
 #define INCLUDE_refdb_fs_h__
 
+#include "common.h"
+
 #include "strmap.h"
 
 typedef struct {
diff --git a/src/reflog.c b/src/reflog.c
index 98ef1b6..9389992 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -6,6 +6,7 @@
  */
 
 #include "reflog.h"
+
 #include "repository.h"
 #include "filebuf.h"
 #include "signature.h"
diff --git a/src/reflog.h b/src/reflog.h
index 2d31ae4..d54b4cd 100644
--- a/src/reflog.h
+++ b/src/reflog.h
@@ -8,6 +8,7 @@
 #define INCLUDE_reflog_h__
 
 #include "common.h"
+
 #include "git2/reflog.h"
 #include "vector.h"
 
diff --git a/src/refs.c b/src/refs.c
index f7120d9..9420540 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -6,6 +6,7 @@
  */
 
 #include "refs.h"
+
 #include "hash.h"
 #include "repository.h"
 #include "fileops.h"
diff --git a/src/refs.h b/src/refs.h
index 0c90db3..7a1a9ae 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -8,6 +8,7 @@
 #define INCLUDE_refs_h__
 
 #include "common.h"
+
 #include "git2/oid.h"
 #include "git2/refs.h"
 #include "git2/refdb.h"
diff --git a/src/refspec.c b/src/refspec.c
index d200e56..01a77c9 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -5,10 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "refspec.h"
+
 #include "git2/errors.h"
 
-#include "common.h"
-#include "refspec.h"
 #include "util.h"
 #include "posix.h"
 #include "refs.h"
diff --git a/src/refspec.h b/src/refspec.h
index 9a87c97..fd2d8b3 100644
--- a/src/refspec.h
+++ b/src/refspec.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_refspec_h__
 #define INCLUDE_refspec_h__
 
+#include "common.h"
+
 #include "git2/refspec.h"
 #include "buffer.h"
 #include "vector.h"
diff --git a/src/remote.c b/src/remote.c
index bd8b3cf..8998c60 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -5,15 +5,15 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "remote.h"
+
 #include "git2/config.h"
 #include "git2/types.h"
 #include "git2/oid.h"
 #include "git2/net.h"
 
-#include "common.h"
 #include "config.h"
 #include "repository.h"
-#include "remote.h"
 #include "fetch.h"
 #include "refs.h"
 #include "refspec.h"
diff --git a/src/remote.h b/src/remote.h
index e696997..a94481f 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_remote_h__
 #define INCLUDE_remote_h__
 
+#include "common.h"
+
 #include "git2/remote.h"
 #include "git2/transport.h"
 #include "git2/sys/transport.h"
diff --git a/src/repository.c b/src/repository.c
index 71f77ba..fe549e6 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -4,6 +4,9 @@
  * 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 "repository.h"
+
 #include <ctype.h>
 
 #include "git2/object.h"
@@ -11,7 +14,6 @@
 #include "git2/sys/repository.h"
 
 #include "common.h"
-#include "repository.h"
 #include "commit.h"
 #include "tag.h"
 #include "blob.h"
diff --git a/src/repository.h b/src/repository.h
index 52f9ec2..fd6400c 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_repository_h__
 #define INCLUDE_repository_h__
 
+#include "common.h"
+
 #include "git2/common.h"
 #include "git2/oid.h"
 #include "git2/odb.h"
diff --git a/src/reset.c b/src/reset.c
index 066b5db..dfecb66 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "commit.h"
 #include "tag.h"
 #include "merge.h"
diff --git a/src/revert.c b/src/revert.c
index 747938f..54f6d48 100644
--- a/src/revert.c
+++ b/src/revert.c
@@ -6,6 +6,7 @@
 */
 
 #include "common.h"
+
 #include "repository.h"
 #include "filebuf.h"
 #include "merge.h"
diff --git a/src/revparse.c b/src/revparse.c
index fd6bd1e..4ab4fb9 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -5,9 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #include <assert.h>
 
-#include "common.h"
 #include "buffer.h"
 #include "tree.h"
 #include "refdb.h"
diff --git a/src/revwalk.c b/src/revwalk.c
index 77fa9fd..b1aa8f9 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -5,12 +5,12 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "revwalk.h"
+
 #include "commit.h"
 #include "odb.h"
 #include "pool.h"
 
-#include "revwalk.h"
 #include "git2/revparse.h"
 #include "merge.h"
 #include "vector.h"
diff --git a/src/revwalk.h b/src/revwalk.h
index 6b363d4..578328b 100644
--- a/src/revwalk.h
+++ b/src/revwalk.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_revwalk_h__
 #define INCLUDE_revwalk_h__
 
+#include "common.h"
+
 #include "git2/revwalk.h"
 #include "oidmap.h"
 #include "commit_list.h"
diff --git a/src/settings.c b/src/settings.c
index 52b861b..ba2f6a4 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -5,12 +5,13 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #ifdef GIT_OPENSSL
 # include <openssl/err.h>
 #endif
 
 #include <git2.h>
-#include "common.h"
 #include "sysdir.h"
 #include "cache.h"
 #include "global.h"
diff --git a/src/sha1_lookup.c b/src/sha1_lookup.c
index ead26de..5081bbf 100644
--- a/src/sha1_lookup.c
+++ b/src/sha1_lookup.c
@@ -5,10 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "sha1_lookup.h"
+
 #include <stdio.h>
 
-#include "sha1_lookup.h"
-#include "common.h"
 #include "oid.h"
 
 /*
diff --git a/src/sha1_lookup.h b/src/sha1_lookup.h
index 3799620..4d9056f 100644
--- a/src/sha1_lookup.h
+++ b/src/sha1_lookup.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_sha1_lookup_h__
 #define INCLUDE_sha1_lookup_h__
 
+#include "common.h"
+
 #include <stdlib.h>
 
 int sha1_entry_pos(const void *table,
diff --git a/src/signature.c b/src/signature.c
index a56b8a2..430fde3 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "signature.h"
+
 #include "repository.h"
 #include "git2/common.h"
 #include "posix.h"
diff --git a/src/signature.h b/src/signature.h
index 75265df..40d7c54 100644
--- a/src/signature.h
+++ b/src/signature.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_signature_h__
 #define INCLUDE_signature_h__
 
+#include "common.h"
+
 #include "git2/common.h"
 #include "git2/signature.h"
 #include "repository.h"
diff --git a/src/socket_stream.c b/src/socket_stream.c
index c0a1684..4c795e4 100644
--- a/src/socket_stream.c
+++ b/src/socket_stream.c
@@ -5,11 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "socket_stream.h"
+
 #include "posix.h"
 #include "netops.h"
 #include "stream.h"
-#include "socket_stream.h"
 
 #ifndef _WIN32
 #	include <sys/types.h>
diff --git a/src/socket_stream.h b/src/socket_stream.h
index 8e9949f..1f9ff78 100644
--- a/src/socket_stream.h
+++ b/src/socket_stream.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_socket_stream_h__
 #define INCLUDE_socket_stream_h__
 
+#include "common.h"
+
 #include "netops.h"
 
 typedef struct {
diff --git a/src/sortedcache.h b/src/sortedcache.h
index 4cacad6..a53ff48 100644
--- a/src/sortedcache.h
+++ b/src/sortedcache.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_sorted_cache_h__
 #define INCLUDE_sorted_cache_h__
 
+#include "common.h"
+
 #include "util.h"
 #include "fileops.h"
 #include "vector.h"
diff --git a/src/stash.c b/src/stash.c
index d13220c..8a8c57a 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "repository.h"
 #include "commit.h"
 #include "message.h"
diff --git a/src/status.c b/src/status.c
index 6752b56..03682bc 100644
--- a/src/status.c
+++ b/src/status.c
@@ -5,13 +5,13 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "status.h"
+
 #include "git2.h"
 #include "fileops.h"
 #include "hash.h"
 #include "vector.h"
 #include "tree.h"
-#include "status.h"
 #include "git2/status.h"
 #include "repository.h"
 #include "ignore.h"
diff --git a/src/status.h b/src/status.h
index 33008b8..907479a 100644
--- a/src/status.h
+++ b/src/status.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_status_h__
 #define INCLUDE_status_h__
 
+#include "common.h"
+
 #include "diff.h"
 #include "git2/status.h"
 #include "git2/diff.h"
diff --git a/src/stransport_stream.c b/src/stransport_stream.c
index 50ed945..18371ef 100644
--- a/src/stransport_stream.c
+++ b/src/stransport_stream.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "stransport_stream.h"
+
 #ifdef GIT_SECURE_TRANSPORT
 
 #include <CoreFoundation/CoreFoundation.h>
diff --git a/src/stransport_stream.h b/src/stransport_stream.h
index 714f902..f5bbfd9 100644
--- a/src/stransport_stream.h
+++ b/src/stransport_stream.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_stransport_stream_h__
 #define INCLUDE_stransport_stream_h__
 
+#include "common.h"
+
 #include "git2/sys/stream.h"
 
 extern int git_stransport_stream_new(git_stream **out, const char *host, const char *port);
diff --git a/src/submodule.c b/src/submodule.c
index ddd4b06..0b97a59 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "submodule.h"
+
 #include "git2/config.h"
 #include "git2/sys/config.h"
 #include "git2/types.h"
@@ -17,7 +18,6 @@
 #include "config_file.h"
 #include "config.h"
 #include "repository.h"
-#include "submodule.h"
 #include "tree.h"
 #include "iterator.h"
 #include "path.h"
diff --git a/src/submodule.h b/src/submodule.h
index 456a939..72867a3 100644
--- a/src/submodule.h
+++ b/src/submodule.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_submodule_h__
 #define INCLUDE_submodule_h__
 
+#include "common.h"
+
 #include "git2/submodule.h"
 #include "git2/repository.h"
 #include "fileops.h"
diff --git a/src/sysdir.c b/src/sysdir.c
index 9312a7e..7480e82 100644
--- a/src/sysdir.c
+++ b/src/sysdir.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "sysdir.h"
+
 #include "global.h"
 #include "buffer.h"
 #include "path.h"
diff --git a/src/sysdir.h b/src/sysdir.h
index 79f2381..8f4466b 100644
--- a/src/sysdir.h
+++ b/src/sysdir.h
@@ -8,6 +8,7 @@
 #define INCLUDE_sysdir_h__
 
 #include "common.h"
+
 #include "posix.h"
 #include "buffer.h"
 
diff --git a/src/tag.c b/src/tag.c
index 2bf23fc..445c3ff 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -5,9 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
-#include "commit.h"
 #include "tag.h"
+
+#include "commit.h"
 #include "signature.h"
 #include "message.h"
 #include "git2/object.h"
diff --git a/src/tag.h b/src/tag.h
index d0cd393..8aae378 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_tag_h__
 #define INCLUDE_tag_h__
 
+#include "common.h"
+
 #include "git2/tag.h"
 #include "repository.h"
 #include "odb.h"
diff --git a/src/thread-utils.c b/src/thread-utils.c
index dc9b2f0..e5ec6a8 100644
--- a/src/thread-utils.c
+++ b/src/thread-utils.c
@@ -4,6 +4,7 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
+
 #include "common.h"
 #include "thread-utils.h"
 
diff --git a/src/tls_stream.c b/src/tls_stream.c
index 83e2d06..fefb92f 100644
--- a/src/tls_stream.c
+++ b/src/tls_stream.c
@@ -5,8 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "tls_stream.h"
+
 #include "git2/errors.h"
-#include "common.h"
 
 #include "openssl_stream.h"
 #include "stransport_stream.h"
diff --git a/src/tls_stream.h b/src/tls_stream.h
index 98a7041..8971f7e 100644
--- a/src/tls_stream.h
+++ b/src/tls_stream.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_tls_stream_h__
 #define INCLUDE_tls_stream_h__
 
+#include "common.h"
+
 #include "git2/sys/stream.h"
 
 /**
diff --git a/src/trace.c b/src/trace.c
index 0f21428..080d1e8 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -5,10 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "trace.h"
+
 #include "buffer.h"
-#include "common.h"
 #include "global.h"
-#include "trace.h"
 #include "git2/trace.h"
 
 #ifdef GIT_TRACE
diff --git a/src/trace.h b/src/trace.h
index 486084d..4989440 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_trace_h__
 #define INCLUDE_trace_h__
 
+#include "common.h"
+
 #include <git2/trace.h>
 #include "buffer.h"
 
diff --git a/src/transaction.c b/src/transaction.c
index 3d3f35a..675023a 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -5,7 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "transaction.h"
+
 #include "repository.h"
 #include "strmap.h"
 #include "refdb.h"
diff --git a/src/transport.c b/src/transport.c
index b661653..f1e18b3 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -4,7 +4,9 @@
  * 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 "git2/types.h"
 #include "git2/remote.h"
 #include "git2/net.h"
diff --git a/src/transports/auth.c b/src/transports/auth.c
index c1154db..9597cc2 100644
--- a/src/transports/auth.c
+++ b/src/transports/auth.c
@@ -5,9 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "auth.h"
+
 #include "git2.h"
 #include "buffer.h"
-#include "auth.h"
 
 static int basic_next_token(
 	git_buf *out, git_http_auth_context *ctx, git_cred *c)
diff --git a/src/transports/auth.h b/src/transports/auth.h
index 52138cf..06af79d 100644
--- a/src/transports/auth.h
+++ b/src/transports/auth.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_http_auth_h__
 #define INCLUDE_http_auth_h__
 
+#include "common.h"
+
 #include "git2.h"
 #include "netops.h"
 
diff --git a/src/transports/auth_negotiate.c b/src/transports/auth_negotiate.c
index 7c868c9..c9bc304 100644
--- a/src/transports/auth_negotiate.c
+++ b/src/transports/auth_negotiate.c
@@ -5,10 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "auth_negotiate.h"
+
 #ifdef GIT_GSSAPI
 
 #include "git2.h"
-#include "common.h"
 #include "buffer.h"
 #include "auth.h"
 
diff --git a/src/transports/auth_negotiate.h b/src/transports/auth_negotiate.h
index d7270b7..5866c19 100644
--- a/src/transports/auth_negotiate.h
+++ b/src/transports/auth_negotiate.h
@@ -8,6 +8,7 @@
 #ifndef INCLUDE_auth_negotiate_h__
 #define INCLUDE_auth_negotiate_h__
 
+#include "common.h"
 #include "git2.h"
 #include "auth.h"
 
diff --git a/src/transports/cred.c b/src/transports/cred.c
index 8e3f644..8055e2d 100644
--- a/src/transports/cred.c
+++ b/src/transports/cred.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "cred.h"
+
 #include "git2.h"
 #include "smart.h"
 #include "git2/cred_helpers.h"
diff --git a/src/transports/cred.h b/src/transports/cred.h
index 2de8dee..dceab9a 100644
--- a/src/transports/cred.h
+++ b/src/transports/cred.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_git_cred_h__
 #define INCLUDE_git_cred_h__
 
+#include "common.h"
+
 #include "git2/transport.h"
 
 const char *git_cred__username(git_cred *cred);
diff --git a/src/transports/cred_helpers.c b/src/transports/cred_helpers.c
index 5cc9b08..fdc56b1 100644
--- a/src/transports/cred_helpers.c
+++ b/src/transports/cred_helpers.c
@@ -6,6 +6,7 @@
  */
 
 #include "common.h"
+
 #include "git2/cred_helpers.h"
 
 int git_cred_userpass(
diff --git a/src/transports/git.c b/src/transports/git.c
index 01edfdc..e019878 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #include "git2.h"
 #include "buffer.h"
 #include "netops.h"
diff --git a/src/transports/http.c b/src/transports/http.c
index cb4a6d0..332e628 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -4,6 +4,9 @@
  * 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"
+
 #ifndef GIT_WINHTTP
 
 #include "git2.h"
diff --git a/src/transports/local.c b/src/transports/local.c
index e24e998..733ed2c 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -4,7 +4,9 @@
  * 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 "git2/types.h"
 #include "git2/net.h"
 #include "git2/repository.h"
@@ -16,6 +18,7 @@
 #include "git2/pack.h"
 #include "git2/commit.h"
 #include "git2/revparse.h"
+
 #include "pack-objects.h"
 #include "refs.h"
 #include "posix.h"
diff --git a/src/transports/smart.c b/src/transports/smart.c
index a96fdf6..6d5d95f 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -4,8 +4,10 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#include "git2.h"
+
 #include "smart.h"
+
+#include "git2.h"
 #include "refs.h"
 #include "refspec.h"
 #include "proxy.h"
diff --git a/src/transports/smart.h b/src/transports/smart.h
index b47001f..f1ad704 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -4,6 +4,9 @@
  * 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 "git2.h"
 #include "vector.h"
 #include "netops.h"
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 8146fa1..d51238f 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -4,6 +4,9 @@
  * 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 "git2.h"
 #include "git2/odb_backend.h"
 
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 4c55e3f..47d328c 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "ssh.h"
+
 #ifdef GIT_SSH
 #include <libssh2.h>
 #endif
@@ -16,7 +18,6 @@
 #include "smart.h"
 #include "cred.h"
 #include "socket_stream.h"
-#include "ssh.h"
 
 #ifdef GIT_SSH
 
diff --git a/src/transports/ssh.h b/src/transports/ssh.h
index 2db2cc5..e36e724 100644
--- a/src/transports/ssh.h
+++ b/src/transports/ssh.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_ssh_h__
 #define INCLUDE_ssh_h__
 
+#include "common.h"
+
 int git_transport_ssh_global_init(void);
 
 #endif
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index fb504c9..6689c8c 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #ifdef GIT_WINHTTP
 
 #include "git2.h"
diff --git a/src/tree-cache.c b/src/tree-cache.c
index 5480541..b331d22 100644
--- a/src/tree-cache.c
+++ b/src/tree-cache.c
@@ -6,6 +6,7 @@
  */
 
 #include "tree-cache.h"
+
 #include "pool.h"
 #include "tree.h"
 
diff --git a/src/tree-cache.h b/src/tree-cache.h
index c44ca7c..e02300e 100644
--- a/src/tree-cache.h
+++ b/src/tree-cache.h
@@ -9,6 +9,7 @@
 #define INCLUDE_tree_cache_h__
 
 #include "common.h"
+
 #include "pool.h"
 #include "buffer.h"
 #include "git2/oid.h"
diff --git a/src/tree.c b/src/tree.c
index 6b1d1b2..fcee7f3 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -5,9 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
-#include "commit.h"
 #include "tree.h"
+
+#include "commit.h"
 #include "git2/repository.h"
 #include "git2/object.h"
 #include "fileops.h"
diff --git a/src/tree.h b/src/tree.h
index 5e7a66e..00f4b06 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_tree_h__
 #define INCLUDE_tree_h__
 
+#include "common.h"
+
 #include "git2/tree.h"
 #include "repository.h"
 #include "odb.h"
diff --git a/src/unix/map.c b/src/unix/map.c
index 9d9b1fe..8a07fcf 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -4,7 +4,10 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#include <git2/common.h>
+
+#include "common.h"
+
+#include "git2/common.h"
 
 #if !defined(GIT_WIN32) && !defined(NO_MMAP)
 
diff --git a/src/unix/realpath.c b/src/unix/realpath.c
index 2e49150..893bac8 100644
--- a/src/unix/realpath.c
+++ b/src/unix/realpath.c
@@ -4,7 +4,10 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#include <git2/common.h>
+
+#include "common.h"
+
+#include "git2/common.h"
 
 #ifndef GIT_WIN32
 
diff --git a/src/util.c b/src/util.c
index a44f4c9..6ae5cda 100644
--- a/src/util.c
+++ b/src/util.c
@@ -4,8 +4,10 @@
  * This file is part of libgit2, distributed under the GNU GPL v2 with
  * a Linking Exception. For full terms see the included COPYING file.
  */
-#include <git2.h>
-#include "common.h"
+
+#include "util.h"
+
+#include "git2.h"
 #include <stdio.h>
 #include <ctype.h>
 #include "posix.h"
diff --git a/src/util.h b/src/util.h
index 8bba368..b85e03b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_util_h__
 #define INCLUDE_util_h__
 
+#include "common.h"
+
 #include "git2/buffer.h"
 #include "buffer.h"
 #include "thread-utils.h"
diff --git a/src/varint.c b/src/varint.c
index beac8c7..9ffc1d7 100644
--- a/src/varint.c
+++ b/src/varint.c
@@ -5,7 +5,6 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "varint.h"
 
 uintmax_t git_decode_varint(const unsigned char *bufp, size_t *varint_len)
diff --git a/src/varint.h b/src/varint.h
index 650ec7d..652e224 100644
--- a/src/varint.h
+++ b/src/varint.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_varint_h__
 #define INCLUDE_varint_h__
 
+#include "common.h"
+
 #include <stdint.h>
 
 extern int git_encode_varint(unsigned char *, size_t, uintmax_t);
diff --git a/src/vector.c b/src/vector.c
index 620a1f5..b12fa94 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "vector.h"
+
 #include "integer.h"
 
 /* In elements, not bytes */
diff --git a/src/win32/dir.c b/src/win32/dir.c
index 8a724a4..1d37874 100644
--- a/src/win32/dir.c
+++ b/src/win32/dir.c
@@ -4,6 +4,9 @@
  * 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 "dir.h"
+
 #define GIT__WIN32_NO_WRAP_DIR
 #include "posix.h"
 
diff --git a/src/win32/dir.h b/src/win32/dir.h
index bef39d7..704a9a8 100644
--- a/src/win32/dir.h
+++ b/src/win32/dir.h
@@ -8,6 +8,7 @@
 #define INCLUDE_dir_h__
 
 #include "common.h"
+
 #include "w32_util.h"
 
 struct git__dirent {
diff --git a/src/win32/error.c b/src/win32/error.c
index 6b45009..3a52fb5 100644
--- a/src/win32/error.c
+++ b/src/win32/error.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "error.h"
+
 #include "utf-conv.h"
 
 #ifdef GIT_WINHTTP
diff --git a/src/win32/error.h b/src/win32/error.h
index 12947a2..a2ecf6a 100644
--- a/src/win32/error.h
+++ b/src/win32/error.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_git_win32_error_h__
 #define INCLUDE_git_win32_error_h__
 
+#include "common.h"
+
 extern char *git_win32_get_error_message(DWORD error_code);
 
 #endif
diff --git a/src/win32/findfile.c b/src/win32/findfile.c
index 1c768f7..d56aa1f 100644
--- a/src/win32/findfile.c
+++ b/src/win32/findfile.c
@@ -5,10 +5,11 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "findfile.h"
+
 #include "path_w32.h"
 #include "utf-conv.h"
 #include "path.h"
-#include "findfile.h"
 
 #define REG_MSYSGIT_INSTALL_LOCAL L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1"
 
diff --git a/src/win32/findfile.h b/src/win32/findfile.h
index 3d5fff4..1eae469 100644
--- a/src/win32/findfile.h
+++ b/src/win32/findfile.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_git_findfile_h__
 #define INCLUDE_git_findfile_h__
 
+#include "common.h"
+
 extern int git_win32__find_system_dirs(git_buf *out, const wchar_t *subpath);
 extern int git_win32__find_global_dirs(git_buf *out);
 extern int git_win32__find_xdg_dirs(git_buf *out);
diff --git a/src/win32/map.c b/src/win32/map.c
index 5fcc108..6a17aeb 100644
--- a/src/win32/map.c
+++ b/src/win32/map.c
@@ -5,6 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "common.h"
+
 #include "map.h"
 #include <errno.h>
 
diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c
index 40b95c3..f8416b8 100644
--- a/src/win32/path_w32.c
+++ b/src/win32/path_w32.c
@@ -5,9 +5,9 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
-#include "path.h"
 #include "path_w32.h"
+
+#include "path.h"
 #include "utf-conv.h"
 #include "posix.h"
 #include "reparse.h"
diff --git a/src/win32/path_w32.h b/src/win32/path_w32.h
index 3d9f828..ac1fb4b 100644
--- a/src/win32/path_w32.h
+++ b/src/win32/path_w32.h
@@ -8,6 +8,7 @@
 #define INCLUDE_git_path_w32_h__
 
 #include "common.h"
+
 #include "vector.h"
 
 /*
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index e4fe414..c63414a 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -4,6 +4,9 @@
  * 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 "../posix.h"
 #include "../fileops.h"
 #include "path.h"
diff --git a/src/win32/precompiled.h b/src/win32/precompiled.h
index 10ca0b8..851a083 100644
--- a/src/win32/precompiled.h
+++ b/src/win32/precompiled.h
@@ -1,3 +1,5 @@
+#include "common.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
@@ -20,4 +22,3 @@
 #endif
 
 #include "git2.h"
-#include "common.h"
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 87318c9..2d96005 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -6,6 +6,7 @@
  */
 
 #include "thread.h"
+
 #include "../global.h"
 
 #define CLEAN_THREAD_EXIT 0x6F012842
diff --git a/src/win32/thread.h b/src/win32/thread.h
index 7f4a217..d217722 100644
--- a/src/win32/thread.h
+++ b/src/win32/thread.h
@@ -8,7 +8,7 @@
 #ifndef INCLUDE_win32_thread_h__
 #define INCLUDE_win32_thread_h__
 
-#include "../common.h"
+#include "common.h"
 
 #if defined (_MSC_VER)
 #	define GIT_RESTRICT __restrict
diff --git a/src/win32/utf-conv.c b/src/win32/utf-conv.c
index 96fd460..4bde302 100644
--- a/src/win32/utf-conv.c
+++ b/src/win32/utf-conv.c
@@ -5,7 +5,6 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "utf-conv.h"
 
 GIT_INLINE(void) git__set_errno(void)
diff --git a/src/win32/utf-conv.h b/src/win32/utf-conv.h
index 33b95f5..bab7ba9 100644
--- a/src/win32/utf-conv.h
+++ b/src/win32/utf-conv.h
@@ -7,9 +7,10 @@
 #ifndef INCLUDE_git_utfconv_h__
 #define INCLUDE_git_utfconv_h__
 
-#include <wchar.h>
 #include "common.h"
 
+#include <wchar.h>
+
 #ifndef WC_ERR_INVALID_CHARS
 # define WC_ERR_INVALID_CHARS	0x80
 #endif
diff --git a/src/win32/w32_buffer.c b/src/win32/w32_buffer.c
index 9122baa..45c024d 100644
--- a/src/win32/w32_buffer.c
+++ b/src/win32/w32_buffer.c
@@ -5,8 +5,8 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
 #include "w32_buffer.h"
+
 #include "../buffer.h"
 #include "utf-conv.h"
 
diff --git a/src/win32/w32_buffer.h b/src/win32/w32_buffer.h
index 6224398..e15ea68 100644
--- a/src/win32/w32_buffer.h
+++ b/src/win32/w32_buffer.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_git_win32_buffer_h__
 #define INCLUDE_git_win32_buffer_h__
 
+#include "common.h"
+
 #include "../buffer.h"
 
 /**
diff --git a/src/win32/w32_crtdbg_stacktrace.c b/src/win32/w32_crtdbg_stacktrace.c
index 2dbdaf4..7b3c3fb 100644
--- a/src/win32/w32_crtdbg_stacktrace.c
+++ b/src/win32/w32_crtdbg_stacktrace.c
@@ -5,9 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "w32_crtdbg_stacktrace.h"
+
 #if defined(GIT_MSVC_CRTDBG)
 #include "w32_stack.h"
-#include "w32_crtdbg_stacktrace.h"
 
 #define CRTDBG_STACKTRACE__UID_LEN (15)
 
diff --git a/src/win32/w32_crtdbg_stacktrace.h b/src/win32/w32_crtdbg_stacktrace.h
index 2e44fd7..bb869b3 100644
--- a/src/win32/w32_crtdbg_stacktrace.h
+++ b/src/win32/w32_crtdbg_stacktrace.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_w32_crtdbg_stacktrace_h__
 #define INCLUDE_w32_crtdbg_stacktrace_h__
 
+#include "common.h"
+
 #if defined(GIT_MSVC_CRTDBG)
 
 #include <stdlib.h>
diff --git a/src/win32/w32_stack.c b/src/win32/w32_stack.c
index 15af3dc..b40f9d2 100644
--- a/src/win32/w32_stack.c
+++ b/src/win32/w32_stack.c
@@ -5,11 +5,12 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "w32_stack.h"
+
 #if defined(GIT_MSVC_CRTDBG)
 #include "Windows.h"
 #include "Dbghelp.h"
 #include "win32/posix.h"
-#include "w32_stack.h"
 #include "hash.h"
 
 /**
diff --git a/src/win32/w32_stack.h b/src/win32/w32_stack.h
index 21170bd..a514ace 100644
--- a/src/win32/w32_stack.h
+++ b/src/win32/w32_stack.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_w32_stack_h__
 #define INCLUDE_w32_stack_h__
 
+#include "common.h"
+
 #if defined(GIT_MSVC_CRTDBG)
 
 /**
diff --git a/src/win32/w32_util.h b/src/win32/w32_util.h
index 77973b5..d81e55a 100644
--- a/src/win32/w32_util.h
+++ b/src/win32/w32_util.h
@@ -8,6 +8,8 @@
 #ifndef INCLUDE_w32_util_h__
 #define INCLUDE_w32_util_h__
 
+#include "common.h"
+
 #include "utf-conv.h"
 #include "posix.h"
 #include "path_w32.h"
diff --git a/src/worktree.c b/src/worktree.c
index ede155b..5a814a2 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -5,14 +5,13 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
-#include "common.h"
+#include "worktree.h"
 
 #include "git2/branch.h"
 #include "git2/commit.h"
 #include "git2/worktree.h"
 
 #include "repository.h"
-#include "worktree.h"
 
 static bool is_worktree_dir(const char *dir)
 {
diff --git a/src/worktree.h b/src/worktree.h
index 57c2e65..52d13cc 100644
--- a/src/worktree.h
+++ b/src/worktree.h
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_worktree_h__
 #define INCLUDE_worktree_h__
 
+#include "common.h"
+
 #include "git2/common.h"
 #include "git2/worktree.h"
 
diff --git a/src/zstream.c b/src/zstream.c
index 141b49b..4895bdb 100644
--- a/src/zstream.c
+++ b/src/zstream.c
@@ -5,9 +5,10 @@
  * a Linking Exception. For full terms see the included COPYING file.
  */
 
+#include "zstream.h"
+
 #include <zlib.h>
 
-#include "zstream.h"
 #include "buffer.h"
 
 #define ZSTREAM_BUFFER_SIZE (1024 * 1024)
diff --git a/src/zstream.h b/src/zstream.h
index f0006d3..fcc4a31 100644
--- a/src/zstream.h
+++ b/src/zstream.h
@@ -7,9 +7,10 @@
 #ifndef INCLUDE_zstream_h__
 #define INCLUDE_zstream_h__
 
+#include "common.h"
+
 #include <zlib.h>
 
-#include "common.h"
 #include "buffer.h"
 
 typedef enum {