Commit 904b67e69fa15b7a3246e43b3d78645ffa2331f6

Vicent Martí 2012-05-18T01:48:50

errors: Rename error codes

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
diff --git a/examples/diff.c b/examples/diff.c
index 3c44695..1b4ab54 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -36,7 +36,7 @@ int resolve_to_tree(git_repository *repo, const char *identifier, git_tree **tre
 	}
 
 	if (obj == NULL)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	switch (git_object_type(obj)) {
 	case GIT_OBJ_TREE:
@@ -47,7 +47,7 @@ int resolve_to_tree(git_repository *repo, const char *identifier, git_tree **tre
 		git_object_free(obj);
 		break;
 	default:
-		err = GIT_NOTFOUND;
+		err = GIT_ENOTFOUND;
 	}
 
 	return err;
diff --git a/include/git2/branch.h b/include/git2/branch.h
index 5ffc7dd..e2432bc 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -63,7 +63,7 @@ GIT_EXTERN(int) git_branch_create(
  * @param branch_type Type of the considered branch. This should
  * be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
  *
- * @return 0 on success, GIT_NOTFOUND if the branch
+ * @return 0 on success, GIT_ENOTFOUND if the branch
  * doesn't exist or an error code.
  */
 GIT_EXTERN(int) git_branch_delete(
@@ -108,7 +108,7 @@ GIT_EXTERN(int) git_branch_list(
  *
  * @param force Overwrite existing branch.
  *
- * @return 0 on success, GIT_NOTFOUND if the branch
+ * @return 0 on success, GIT_ENOTFOUND if the branch
  * doesn't exist or an error code.
  */
 GIT_EXTERN(int) git_branch_move(
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 361c0ac..fb66700 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -58,12 +58,13 @@ enum {
 enum {
 	GIT_OK = 0,
 	GIT_ERROR = -1,
-	GIT_NOTFOUND = -3,
-	GIT_EXISTS = -23,
-	GIT_AMBIGUOUS = -29,
+	GIT_ENOTFOUND = -3,
+	GIT_EEXISTS = -4,
+	GIT_EAMBIGUOUS = -5,
+	GIT_EBUFS = -6,
+
 	GIT_PASSTHROUGH = -30,
-	GIT_SHORTBUFFER = -32,
-	GIT_REVWALKOVER = -33,
+	GIT_REVWALKOVER = -31,
 };
 
 typedef struct {
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 6f448f6..1df1933 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -109,7 +109,7 @@ GIT_EXTERN(void) git_odb_free(git_odb *db);
  * @param id identity of the object to read.
  * @return
  * - 0 if the object was read;
- * - GIT_NOTFOUND if the object is not in the database.
+ * - GIT_ENOTFOUND if the object is not in the database.
  */
 GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
 
@@ -136,8 +136,8 @@ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *i
  * @param short_id a prefix of the id of the object to read.
  * @param len the length of the prefix
  * @return 0 if the object was read;
- *	GIT_NOTFOUND if the object is not in the database.
- *	GIT_AMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
+ *	GIT_ENOTFOUND if the object is not in the database.
+ *	GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
  */
 GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, unsigned int len);
 
@@ -157,7 +157,7 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
  * @param id identity of the object to read.
  * @return
  * - 0 if the object was read;
- * - GIT_NOTFOUND if the object is not in the database.
+ * - GIT_ENOTFOUND if the object is not in the database.
  */
 GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id);
 
diff --git a/include/git2/refspec.h b/include/git2/refspec.h
index c46c187..c0a8eab 100644
--- a/include/git2/refspec.h
+++ b/include/git2/refspec.h
@@ -51,7 +51,7 @@ GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *
  * @param outlen the size ouf the `out` buffer
  * @param spec the refspec
  * @param name the name of the reference to transform
- * @return 0, GIT_SHORTBUFFER or another error
+ * @return 0, GIT_EBUFS or another error
  */
 GIT_EXTERN(int) git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name);
 
diff --git a/include/git2/status.h b/include/git2/status.h
index 080db9f..6a424df 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -131,7 +131,7 @@ GIT_EXTERN(int) git_status_foreach_ext(
  * @param status_flags the status value
  * @param repo a repository object
  * @param path the file to retrieve status for, rooted at the repo's workdir
- * @return GIT_EINVALIDPATH when `path` points at a folder, GIT_NOTFOUND when
+ * @return GIT_EINVALIDPATH when `path` points at a folder, GIT_ENOTFOUND when
  *		the file doesn't exist in any of HEAD, the index or the worktree,
  *		0 otherwise
  */
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index 9e6118b..9301682 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -85,13 +85,13 @@ GIT_EXTERN(int) git_submodule_foreach(
  *
  * Given either the submodule name or path (they are ususally the same),
  * this returns a structure describing the submodule.  If the submodule
- * does not exist, this will return GIT_NOTFOUND and set the submodule
+ * does not exist, this will return GIT_ENOTFOUND and set the submodule
  * pointer to NULL.
  *
  * @param submodule Pointer to submodule description object pointer..
  * @param repo The repository.
  * @param name The name of the submodule.  Trailing slashes will be ignored.
- * @return 0 on success, GIT_NOTFOUND if submodule does not exist, -1 on error
+ * @return 0 on success, GIT_ENOTFOUND if submodule does not exist, -1 on error
  */
 GIT_EXTERN(int) git_submodule_lookup(
 	git_submodule **submodule,
diff --git a/include/git2/tag.h b/include/git2/tag.h
index 7f318ad..859c289 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -143,7 +143,7 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
  * @param oid Pointer where to store the OID of the
  * newly created tag. If the tag already exists, this parameter
  * will be the oid of the existing tag, and the function will
- * return a GIT_EXISTS error code.
+ * return a GIT_EEXISTS error code.
  *
  * @param repo Repository where to store the tag
  *
@@ -199,7 +199,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
  * @param oid Pointer where to store the OID of the provided
  * target object. If the tag already exists, this parameter
  * will be filled with the oid of the existing pointed object
- * and the function will return a GIT_EXISTS error code.
+ * and the function will return a GIT_EEXISTS error code.
  *
  * @param repo Repository where to store the lightweight tag
  *
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 3b3b0e2..777f8ff 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -278,7 +278,7 @@ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_tr
  * @param subtree Pointer where to store the subtree
  * @param root A previously loaded tree which will be the root of the relative path
  * @param subtree_path Path to the contained subtree
- * @return 0 on success; GIT_NOTFOUND if the path does not lead to a subtree
+ * @return 0 on success; GIT_ENOTFOUND if the path does not lead to a subtree
  */
 GIT_EXTERN(int) git_tree_get_subtree(git_tree **subtree, git_tree *root, const char *subtree_path);
 
diff --git a/src/attr.c b/src/attr.c
index 5fef914..093f64d 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -245,13 +245,13 @@ static int load_attr_file(
 	struct stat st;
 
 	if (p_stat(filename, &st) < 0)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	if (sig != NULL &&
 		(git_time_t)st.st_mtime == sig->seconds &&
 		(git_off_t)st.st_size == sig->size &&
 		(unsigned int)st.st_ino == sig->ino)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	error = git_futils_readbuffer_updated(&content, filename, NULL, NULL);
 	if (error < 0)
@@ -286,7 +286,7 @@ static int load_attr_blob_from_index(
 	entry = git_index_get(index, error);
 
 	if (old_oid && git_oid_cmp(old_oid, &entry->oid) == 0)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	if ((error = git_blob_lookup(blob, repo, &entry->oid)) < 0)
 		return error;
@@ -396,7 +396,7 @@ int git_attr_cache__push_file(
 
 	if (error) {
 		/* not finding a file is not an error for this function */
-		if (error == GIT_NOTFOUND) {
+		if (error == GIT_ENOTFOUND) {
 			giterr_clear();
 			error = 0;
 		}
@@ -550,7 +550,7 @@ static int collect_attr_files(
 		error = git_futils_find_system_file(&dir, GIT_ATTR_FILE_SYSTEM);
 		if (!error)
 			error = push_attr_file(repo, files, NULL, dir.ptr);
-		else if (error == GIT_NOTFOUND)
+		else if (error == GIT_ENOTFOUND)
 			error = 0;
 	}
 
@@ -577,11 +577,11 @@ int git_attr_cache__init(git_repository *repo)
 		return -1;
 
 	ret = git_config_get_string(&cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG);
-	if (ret < 0 && ret != GIT_NOTFOUND)
+	if (ret < 0 && ret != GIT_ENOTFOUND)
 		return ret;
 
 	ret = git_config_get_string(&cache->cfg_excl_file, cfg, GIT_IGNORE_CONFIG);
-	if (ret < 0 && ret != GIT_NOTFOUND)
+	if (ret < 0 && ret != GIT_ENOTFOUND)
 		return ret;
 
 	giterr_clear();
diff --git a/src/attr_file.c b/src/attr_file.c
index 601b286..5030ad5 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -99,7 +99,7 @@ int git_attr_file__parse_buffer(
 		/* if the rule wasn't a pattern, on to the next */
 		if (error < 0) {
 			git_attr_rule__clear(rule); /* reset rule contents */
-			if (error == GIT_NOTFOUND)
+			if (error == GIT_ENOTFOUND)
 				error = 0;
 		} else {
 			rule = NULL; /* vector now "owns" the rule */
@@ -328,7 +328,7 @@ void git_attr_path__free(git_attr_path *info)
 
 /*
  * This will return 0 if the spec was filled out,
- * GIT_NOTFOUND if the fnmatch does not require matching, or
+ * GIT_ENOTFOUND if the fnmatch does not require matching, or
  * another error code there was an actual problem.
  */
 int git_attr_fnmatch__parse(
@@ -347,7 +347,7 @@ int git_attr_fnmatch__parse(
 	while (git__isspace(*pattern)) pattern++;
 	if (!*pattern || *pattern == '#') {
 		*base = git__next_line(pattern);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	spec->flags = 0;
@@ -464,7 +464,7 @@ static int merge_assignments(void **old_raw, void *new_raw)
 
 	GIT_REFCOUNT_DEC(*old, git_attr_assignment__free);
 	*old = new;
-	return GIT_EXISTS;
+	return GIT_EEXISTS;
 }
 
 int git_attr_assignment__parse(
@@ -551,7 +551,7 @@ int git_attr_assignment__parse(
 
 					error = git_vector_insert_sorted(
 						assigns, massign, &merge_assignments);
-					if (error < 0 && error != GIT_EXISTS)
+					if (error < 0 && error != GIT_EEXISTS)
 						return error;
 				}
 			}
@@ -559,7 +559,7 @@ int git_attr_assignment__parse(
 
 		/* insert allocated assign into vector */
 		error = git_vector_insert_sorted(assigns, assign, &merge_assignments);
-		if (error < 0 && error != GIT_EXISTS)
+		if (error < 0 && error != GIT_EEXISTS)
 			return error;
 
 		/* clear assign since it is now "owned" by the vector */
@@ -571,7 +571,7 @@ int git_attr_assignment__parse(
 
 	*base = git__next_line(scan);
 
-	return (assigns->length == 0) ? GIT_NOTFOUND : 0;
+	return (assigns->length == 0) ? GIT_ENOTFOUND : 0;
 }
 
 static void git_attr_rule__clear(git_attr_rule *rule)
diff --git a/src/branch.c b/src/branch.c
index 45f67ff..9698bbf 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -190,7 +190,7 @@ int git_branch_move(git_repository *repo, const char *old_branch_name, const cha
 	if ((error = git_buf_joinpath(&old_reference_name, GIT_REFS_HEADS_DIR, old_branch_name)) < 0)
 		goto cleanup;
 
-	/* We need to be able to return GIT_NOTFOUND */
+	/* We need to be able to return GIT_ENOTFOUND */
 	if ((error = git_reference_lookup(&reference, repo, git_buf_cstr(&old_reference_name))) < 0)
 		goto cleanup;
 
diff --git a/src/commit.c b/src/commit.c
index 1c6bee9..2bf12f3 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -100,7 +100,7 @@ static int update_reference(git_repository *repo, git_oid *oid, const char *ref_
 
 	/* If we haven't found the reference at all, we assume we need to create
 	 * a new reference and that's it */
-	if (res == GIT_NOTFOUND) {
+	if (res == GIT_ENOTFOUND) {
 		giterr_clear();
 		return git_reference_create_oid(NULL, repo, ref_name, oid, 1);
 	}
@@ -125,7 +125,7 @@ static int update_reference(git_repository *repo, git_oid *oid, const char *ref_
 		 * this is means we're creating a new branch, for example.
 		 * We need to create a new direct reference with that name
 		 */
-		if (res == GIT_NOTFOUND) {
+		if (res == GIT_ENOTFOUND) {
 			giterr_clear();
 			res = git_reference_create_oid(NULL, repo, sym_target, oid, 1);
 			git_reference_free(ref);
@@ -320,7 +320,7 @@ int git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n)
 	parent_oid = git_vector_get(&commit->parent_oids, n);
 	if (parent_oid == NULL) {
 		giterr_set(GITERR_INVALID, "Parent %u does not exist", n);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	return git_commit_lookup(parent, commit->object.repo, parent_oid);
diff --git a/src/config.c b/src/config.c
index b60faf8..618202c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -263,7 +263,7 @@ int git_config_lookup_map_value(
 	size_t i;
 
 	if (!value)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	for (i = 0; i < map_n; ++i) {
 		git_cvar_map *m = maps + i;
@@ -295,7 +295,7 @@ int git_config_lookup_map_value(
 		}
 	}
 
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 }
 
 int git_config_get_mapped(
@@ -387,12 +387,12 @@ int git_config_get_string(const char **out, git_config *cfg, const char *name)
 	git_vector_foreach(&cfg->files, i, internal) {
 		git_config_file *file = internal->file;
 		int ret = file->get(file, name, out);
-		if (ret != GIT_NOTFOUND)
+		if (ret != GIT_ENOTFOUND)
 			return ret;
 	}
 
 	giterr_set(GITERR_CONFIG, "Config variable '%s' not found", name);
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 }
 
 int git_config_get_multivar(git_config *cfg, const char *name, const char *regexp,
@@ -400,7 +400,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
 {
 	file_internal *internal;
 	git_config_file *file;
-	int ret = GIT_NOTFOUND;
+	int ret = GIT_ENOTFOUND;
 	unsigned int i;
 
 	assert(cfg->files.length);
@@ -413,7 +413,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
 		internal = git_vector_get(&cfg->files, i - 1);
 		file = internal->file;
 		ret = file->get_multivar(file, name, regexp, fn, data);
-		if (ret < 0 && ret != GIT_NOTFOUND)
+		if (ret < 0 && ret != GIT_ENOTFOUND)
 			return ret;
 	}
 
@@ -424,14 +424,14 @@ int git_config_set_multivar(git_config *cfg, const char *name, const char *regex
 {
 	file_internal *internal;
 	git_config_file *file;
-	int ret = GIT_NOTFOUND;
+	int ret = GIT_ENOTFOUND;
 	unsigned int i;
 
 	for (i = cfg->files.length; i > 0; --i) {
 		internal = git_vector_get(&cfg->files, i - 1);
 		file = internal->file;
 		ret = file->set_multivar(file, name, regexp, value);
-		if (ret < 0 && ret != GIT_NOTFOUND)
+		if (ret < 0 && ret != GIT_ENOTFOUND)
 			return ret;
 	}
 
diff --git a/src/config_cache.c b/src/config_cache.c
index b23fd7b..ca9602e 100644
--- a/src/config_cache.c
+++ b/src/config_cache.c
@@ -72,7 +72,7 @@ int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar)
 		error = git_config_get_mapped(out,
 			config, data->cvar_name, data->maps, data->map_count);
 
-		if (error == GIT_NOTFOUND)
+		if (error == GIT_ENOTFOUND)
 			*out = data->default_value;
 
 		else if (error < 0)
diff --git a/src/config_file.c b/src/config_file.c
index 6ecc974..cbc48bc 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -161,7 +161,7 @@ static int config_open(git_config_file *cfg)
 	res = git_futils_readbuffer(&b->reader.buffer, b->file_path);
 
 	/* It's fine if the file doesn't exist */
-	if (res == GIT_NOTFOUND)
+	if (res == GIT_ENOTFOUND)
 		return 0;
 
 	if (res < 0 || config_parse(b) <  0) {
@@ -289,7 +289,7 @@ static int config_get(git_config_file *cfg, const char *name, const char **out)
 
 	/* no error message; the config system will write one */
 	if (!git_strmap_valid_index(b->values, pos))
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	*out = ((cvar_t *)git_strmap_value_at(b->values, pos))->value;
 
@@ -315,7 +315,7 @@ static int config_get_multivar(
 	git__free(key);
 
 	if (!git_strmap_valid_index(b->values, pos))
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	var = git_strmap_value_at(b->values, pos);
 
@@ -377,7 +377,7 @@ static int config_set_multivar(
 	pos = git_strmap_lookup_index(b->values, key);
 	if (!git_strmap_valid_index(b->values, pos)) {
 		git__free(key);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	var = git_strmap_value_at(b->values, pos);
@@ -444,7 +444,7 @@ static int config_delete(git_config_file *cfg, const char *name)
 	git__free(key);
 
 	if (!git_strmap_valid_index(b->values, pos))
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	var = git_strmap_value_at(b->values, pos);
 
@@ -978,7 +978,7 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p
 	result = git_futils_readbuffer(&cfg->reader.buffer, cfg->file_path);
 
 	/* Initialise the reading position */
-	if (result == GIT_NOTFOUND) {
+	if (result == GIT_ENOTFOUND) {
 		cfg->reader.read_ptr = NULL;
 		cfg->reader.eof = 1;
 		data_start = NULL;
diff --git a/src/crlf.c b/src/crlf.c
index 5fb1be5..303a46d 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -85,7 +85,7 @@ static int crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, con
 	error = git_attr_get_many(attr_vals,
 		repo, 0, path, NUM_CONV_ATTRS, attr_names);
 
-	if (error == GIT_NOTFOUND) {
+	if (error == GIT_ENOTFOUND) {
 		ca->crlf_action = GIT_CRLF_GUESS;
 		ca->eol = GIT_EOL_UNSET;
 		return 0;
diff --git a/src/diff.c b/src/diff.c
index 882534f..0b2f8fb 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -343,7 +343,7 @@ static git_diff_list *git_diff_list_alloc(
 		if (!match)
 			goto fail;
 		ret = git_attr_fnmatch__parse(match, &diff->pool, NULL, &pattern);
-		if (ret == GIT_NOTFOUND) {
+		if (ret == GIT_ENOTFOUND) {
 			git__free(match);
 			continue;
 		} else if (ret < 0)
diff --git a/src/fileops.c b/src/fileops.c
index c467143..ee9d421 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -95,7 +95,7 @@ int git_futils_open_ro(const char *path)
 	int fd = p_open(path, O_RDONLY);
 	if (fd < 0) {
 		if (errno == ENOENT)
-			fd = GIT_NOTFOUND;
+			fd = GIT_ENOTFOUND;
 		giterr_set(GITERR_OS, "Failed to open '%s'", path);
 	}
 	return fd;
@@ -365,7 +365,7 @@ int git_futils_find_global_file(git_buf *path, const char *filename)
 
 	if (git_path_exists(path->ptr) == false) {
 		git_buf_clear(path);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	return 0;
@@ -414,7 +414,7 @@ static int win32_find_system_file(git_buf *path, const char *filename)
 	char *file_utf8 = NULL;
 
 	if (!root || !filename || (len = strlen(filename)) == 0)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	/* allocate space for wchar_t path to file */
 	file_utf16 = git__calloc(root->len + len + 2, sizeof(wchar_t));
@@ -438,7 +438,7 @@ static int win32_find_system_file(git_buf *path, const char *filename)
 
 	/* check access */
 	if (_waccess(file_utf16, F_OK) < 0) {
-		error = GIT_NOTFOUND;
+		error = GIT_ENOTFOUND;
 		goto cleanup;
 	}
 
@@ -470,6 +470,6 @@ int git_futils_find_system_file(git_buf *path, const char *filename)
 #ifdef GIT_WIN32
 	return win32_find_system_file(path, filename);
 #else
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 #endif
 }
diff --git a/src/fileops.h b/src/fileops.h
index 8dd4bb6..be619d6 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -139,7 +139,7 @@ extern int git_futils_mmap_ro(
  * @param path path to file to be opened.
  * @return
  * - 0 on success;
- * - GIT_NOTFOUND if not found;
+ * - GIT_ENOTFOUND if not found;
  * - -1 on an unspecified OS related error.
  */
 extern int git_futils_mmap_ro_file(
@@ -159,7 +159,7 @@ extern void git_futils_mmap_free(git_map *map);
  * @param filename name of file to find in the home directory
  * @return
  * - 0 if found;
- * - GIT_NOTFOUND if not found;
+ * - GIT_ENOTFOUND if not found;
  * - -1 on an unspecified OS related error.
  */
 extern int git_futils_find_global_file(git_buf *path, const char *filename);
@@ -171,7 +171,7 @@ extern int git_futils_find_global_file(git_buf *path, const char *filename);
  * @param filename name of file to find in the home directory
  * @return
  * - 0 if found;
- * - GIT_NOTFOUND if not found;
+ * - GIT_ENOTFOUND if not found;
  * - -1 on an unspecified OS related error.
  */
 extern int git_futils_find_system_file(git_buf *path, const char *filename);
diff --git a/src/ignore.c b/src/ignore.c
index 2a70605..fc6194b 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -40,7 +40,7 @@ static int parse_ignore_file(
 			git__free(match->pattern);
 			match->pattern = NULL;
 
-			if (error == GIT_NOTFOUND)
+			if (error == GIT_ENOTFOUND)
 				error = 0;
 		} else {
 			match = NULL; /* vector now "owns" the match */
diff --git a/src/index.c b/src/index.c
index 03b1913..f1ae9a7 100644
--- a/src/index.c
+++ b/src/index.c
@@ -411,7 +411,7 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
 	 * if no entry exists add the entry at the end;
 	 * the index is no longer sorted
 	 */
-	if (position == GIT_NOTFOUND)
+	if (position == GIT_ENOTFOUND)
 		return git_vector_insert(&index->entries, entry);
 
 	/* exists, replace it */
diff --git a/src/indexer.c b/src/indexer.c
index da6d5d2..6f735e6 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -205,9 +205,9 @@ static int store_delta(git_indexer_stream *idx)
 	}
 
 	error = packfile_unpack_compressed(&obj, idx->pack, &w, &idx->off, entry_size, type);
-	if (error == GIT_SHORTBUFFER) {
+	if (error == GIT_EBUFS) {
 		idx->off = entry_start;
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 	} else if (error < 0){
 		return -1;
 	}
@@ -355,7 +355,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 			return 0;
 
 		error = git_packfile_unpack(&obj, idx->pack, &idx->off);
-		if (error == GIT_SHORTBUFFER) {
+		if (error == GIT_EBUFS) {
 			idx->off = entry_start;
 			return 0;
 		}
@@ -363,7 +363,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 		if (error < 0) {
 			idx->off = entry_start;
 			error = store_delta(idx);
-			if (error == GIT_SHORTBUFFER)
+			if (error == GIT_EBUFS)
 				return 0;
 			if (error < 0)
 				return error;
diff --git a/src/iterator.c b/src/iterator.c
index cb9838d..819b0e2 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -468,7 +468,7 @@ static int workdir_iterator__expand_dir(workdir_iterator *wi)
 	error = git_path_dirload_with_stat(wi->path.ptr, wi->root_len, &wf->entries);
 	if (error < 0 || wf->entries.length == 0) {
 		workdir_iterator__free_frame(wf);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	git_vector_sort(&wf->entries);
@@ -635,7 +635,7 @@ static int workdir_iterator__update_entry(workdir_iterator *wi)
 		if (!is_submodule) {
 			int res = git_submodule_lookup(NULL, wi->repo, wi->entry.path);
 			is_submodule = (res == 0);
-			if (res == GIT_NOTFOUND)
+			if (res == GIT_ENOTFOUND)
 				giterr_clear();
 		}
 
@@ -683,7 +683,7 @@ int git_iterator_for_workdir_range(
 	wi->root_len = wi->path.size;
 
 	if ((error = workdir_iterator__expand_dir(wi)) < 0) {
-		if (error == GIT_NOTFOUND)
+		if (error == GIT_ENOTFOUND)
 			error = 0;
 		else {
 			git_iterator_free((git_iterator *)wi);
diff --git a/src/notes.c b/src/notes.c
index afd6fc2..84ad940 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -73,7 +73,7 @@ static int find_blob(git_oid *blob, git_tree *tree, const char *target)
 			return 0;
 		}
 	}
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 }
 
 static int note_write(git_oid *out, git_repository *repo,
@@ -96,11 +96,11 @@ static int note_write(git_oid *out, git_repository *repo,
 			return error;
 
 		error = find_blob(&oid, tree, target + fanout);
-		if (error != GIT_NOTFOUND) {
+		if (error != GIT_ENOTFOUND) {
 			git_tree_free(tree);
 			if (!error) {
 				giterr_set(GITERR_REPOSITORY, "Note for '%s' exists already", target);
-				error = GIT_EXISTS;
+				error = GIT_EEXISTS;
 			}
 			return error;
 		}
@@ -275,7 +275,7 @@ static int note_get_default_ref(const char **out, git_repository *repo)
 		return -1;
 
 	ret = git_config_get_string(out, cfg, "core.notesRef");
-	if (ret == GIT_NOTFOUND) {
+	if (ret == GIT_ENOTFOUND) {
 		*out = GIT_NOTES_DEFAULT_REF;
 		return 0;
 	}
@@ -352,7 +352,7 @@ int git_note_create(
 		return -1;
 
 	error = git_reference_lookup(&ref, repo, notes_ref);
-	if (error < 0 && error != GIT_NOTFOUND)
+	if (error < 0 && error != GIT_ENOTFOUND)
 		return error;
 
 	if (!error) {
diff --git a/src/object.c b/src/object.c
index 0c40c05..d3673ed 100644
--- a/src/object.c
+++ b/src/object.c
@@ -92,7 +92,7 @@ int git_object_lookup_prefix(
 	assert(repo && object_out && id);
 
 	if (len < GIT_OID_MINPREFIXLEN)
-		return GIT_AMBIGUOUS;
+		return GIT_EAMBIGUOUS;
 
 	error = git_repository_odb__weakptr(&odb, repo);
 	if (error < 0)
@@ -110,7 +110,7 @@ int git_object_lookup_prefix(
 			if (type != GIT_OBJ_ANY && type != object->type) {
 				git_object_free(object);
 				giterr_set(GITERR_ODB, "The given type does not match the type in ODB");
-				return GIT_NOTFOUND;
+				return GIT_ENOTFOUND;
 			}
 
 			*object_out = object;
@@ -151,7 +151,7 @@ int git_object_lookup_prefix(
 	if (type != GIT_OBJ_ANY && type != odb_obj->raw.type) {
 		git_odb_object_free(odb_obj);
 		giterr_set(GITERR_ODB, "The given type does not match the type on the ODB");
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	type = odb_obj->raw.type;
diff --git a/src/odb.c b/src/odb.c
index dcb36e2..a6a18f8 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -485,7 +485,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
 int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)
 {
 	unsigned int i;
-	int error = GIT_NOTFOUND;
+	int error = GIT_ENOTFOUND;
 	git_odb_object *object;
 
 	assert(db && id);
@@ -524,7 +524,7 @@ int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git
 int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
 {
 	unsigned int i;
-	int error = GIT_NOTFOUND;
+	int error = GIT_ENOTFOUND;
 	git_rawobj raw;
 
 	assert(out && db && id);
@@ -541,7 +541,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
 			error = b->read(&raw.data, &raw.len, &raw.type, b, id);
 	}
 
-	/* TODO: If no backends are configured, this returns GIT_NOTFOUND but
+	/* TODO: If no backends are configured, this returns GIT_ENOTFOUND but
 	 * will never have called giterr_set().
 	 */
 
@@ -556,7 +556,7 @@ int git_odb_read_prefix(
 	git_odb_object **out, git_odb *db, const git_oid *short_id, unsigned int len)
 {
 	unsigned int i;
-	int error = GIT_NOTFOUND;
+	int error = GIT_ENOTFOUND;
 	git_oid found_full_oid = {{0}};
 	git_rawobj raw;
 	bool found = false;
@@ -582,7 +582,7 @@ int git_odb_read_prefix(
 		if (b->read != NULL) {
 			git_oid full_oid;
 			error = b->read_prefix(&full_oid, &raw.data, &raw.len, &raw.type, b, short_id, len);
-			if (error == GIT_NOTFOUND || error == GIT_PASSTHROUGH)
+			if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH)
 				continue;
 
 			if (error)
@@ -698,12 +698,12 @@ int git_odb__error_notfound(const char *message, const git_oid *oid)
 	} else
 		giterr_set(GITERR_ODB, "Object not found - %s", message);
 
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 }
 
 int git_odb__error_ambiguous(const char *message)
 {
 	giterr_set(GITERR_ODB, "Ambiguous SHA1 prefix - %s", message);
-	return GIT_AMBIGUOUS;
+	return GIT_EAMBIGUOUS;
 }
 
diff --git a/src/odb.h b/src/odb.h
index 2a5c769..263e4c3 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -68,12 +68,12 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type);
 int git_odb__hashlink(git_oid *out, const char *path);
 
 /*
- * Generate a GIT_NOTFOUND error for the ODB.
+ * Generate a GIT_ENOTFOUND error for the ODB.
  */
 int git_odb__error_notfound(const char *message, const git_oid *oid);
 
 /*
- * Generate a GIT_AMBIGUOUS error for the ODB.
+ * Generate a GIT_EAMBIGUOUS error for the ODB.
  */
 int git_odb__error_ambiguous(const char *message);
 
diff --git a/src/odb_loose.c b/src/odb_loose.c
index c229b54..989b03a 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -460,7 +460,7 @@ static int locate_object(
 	int error = object_file_name(object_location, backend->objects_dir, oid);
 
 	if (!error && !git_path_exists(object_location->ptr))
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	return error;
 }
diff --git a/src/odb_pack.c b/src/odb_pack.c
index e03879e..458f288 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -141,7 +141,7 @@ static int pack_entry_find(struct git_pack_entry *e,
 
 /* Can find the offset of an object given
  * a prefix of an identifier.
- * Sets GIT_AMBIGUOUS if short oid is ambiguous.
+ * Sets GIT_EAMBIGUOUS if short oid is ambiguous.
  * This method assumes that len is between
  * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ.
  */
@@ -224,7 +224,7 @@ static int packfile_load__cb(void *_data, git_buf *path)
 	}
 
 	error = git_packfile_check(&pack, path->ptr);
-	if (error == GIT_NOTFOUND)
+	if (error == GIT_ENOTFOUND)
 		/* ignore missing .pack file as git does */
 		return 0;
 	else if (error < 0)
@@ -306,7 +306,7 @@ static int pack_entry_find_prefix(
 
 	if (backend->last_found) {
 		error = git_pack_entry_find(e, backend->last_found, short_oid, len);
-		if (error == GIT_AMBIGUOUS)
+		if (error == GIT_EAMBIGUOUS)
 			return error;
 		if (!error)
 			found = 1;
@@ -320,7 +320,7 @@ static int pack_entry_find_prefix(
 			continue;
 
 		error = git_pack_entry_find(e, p, short_oid, len);
-		if (error == GIT_AMBIGUOUS)
+		if (error == GIT_EAMBIGUOUS)
 			return error;
 		if (!error) {
 			if (++found > 1)
@@ -354,7 +354,7 @@ int pack_backend__read_header(git_rawobj *obj, git_odb_backend *backend, const g
 	assert(obj && backend && oid);
 
 	if (locate_packfile(&location, (struct pack_backend *)backend, oid) < 0)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	return read_header_packed(obj, &location);
 }
diff --git a/src/pack.c b/src/pack.c
index 66a23f2..0db1069 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -28,7 +28,7 @@ int packfile_unpack_compressed(
 
 /* Can find the offset of an object given
  * a prefix of an identifier.
- * Throws GIT_AMBIGUOUSOIDPREFIX if short oid
+ * Throws GIT_EAMBIGUOUSOIDPREFIX if short oid
  * is ambiguous within the pack.
  * This method assumes that len is between
  * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ.
@@ -222,7 +222,7 @@ static int packfile_unpack_header1(
 	shift = 4;
 	while (c & 0x80) {
 		if (len <= used)
-			return GIT_SHORTBUFFER;
+			return GIT_EBUFS;
 
 		if (bitsizeof(long) <= shift) {
 			*usedp = 0;
@@ -260,11 +260,11 @@ int git_packfile_unpack_header(
 //	base = pack_window_open(p, w_curs, *curpos, &left);
 	base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left);
 	if (base == NULL)
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 
 	ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
 	git_mwindow_close(w_curs);
-	if (ret == GIT_SHORTBUFFER)
+	if (ret == GIT_EBUFS)
 		return ret;
 	else if (ret < 0)
 		return packfile_error("header length is zero");
@@ -428,7 +428,7 @@ int packfile_unpack_compressed(
 		if (st == Z_BUF_ERROR && in == NULL) {
 			inflateEnd(&stream);
 			git__free(buffer);
-			return GIT_SHORTBUFFER;
+			return GIT_EBUFS;
 		}
 
 		*curpos += stream.next_in - in;
@@ -467,7 +467,7 @@ git_off_t get_delta_base(
 	base_info = pack_window_open(p, w_curs, *curpos, &left);
 	/* Assumption: the only reason this would fail is because the file is too small */
 	if (base_info == NULL)
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 	/* pack_window_open() assured us we have [base_info, base_info + 20)
 	 * as a range that we can look at without walking off the
 	 * end of the mapped window. Its actually the hash size
@@ -480,7 +480,7 @@ git_off_t get_delta_base(
 		base_offset = c & 127;
 		while (c & 128) {
 			if (left <= used)
-				return GIT_SHORTBUFFER;
+				return GIT_EBUFS;
 			base_offset += 1;
 			if (!base_offset || MSB(base_offset, 7))
 				return 0; /* overflow */
diff --git a/src/path.c b/src/path.c
index ba67544..84edf6d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -206,7 +206,7 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
 
 	if (p_realpath(path, buf) == NULL) {
 		/* giterr_set resets the errno when dealing with a GITERR_OS kind of error */
-		int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_NOTFOUND : -1;
+		int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_ENOTFOUND : -1;
 		giterr_set(GITERR_OS, "Failed to resolve path '%s'", path);
 
 		git_buf_clear(path_out);
@@ -390,7 +390,7 @@ int git_path_lstat(const char *path, struct stat *st)
 	int err = 0;
 
 	if (p_lstat(path, st) < 0) {
-		err = (errno == ENOENT) ? GIT_NOTFOUND : -1;
+		err = (errno == ENOENT) ? GIT_ENOTFOUND : -1;
 		giterr_set(GITERR_OS, "Failed to stat file '%s'", path);
 	}
 
diff --git a/src/pkt.c b/src/pkt.c
index 8956446..95430dd 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -208,7 +208,7 @@ int git_pkt_parse_line(
 
 	/* Not even enough for the length */
 	if (bufflen > 0 && bufflen < PKT_LEN_SIZE)
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 
 	len = parse_len(line);
 	if (len < 0) {
@@ -230,7 +230,7 @@ int git_pkt_parse_line(
 	 * enough in the buffer to satisfy this line
 	 */
 	if (bufflen > 0 && bufflen < (size_t)len)
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 
 	line += PKT_LEN_SIZE;
 	/*
diff --git a/src/protocol.c b/src/protocol.c
index 1849033..6b38617 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -34,7 +34,7 @@ int git_protocol_store_refs(git_protocol *p, const char *data, size_t len)
 			return 0;
 
 		error = git_pkt_parse_line(&pkt, ptr, &line_end, git_buf_len(buf));
-		if (error == GIT_SHORTBUFFER)
+		if (error == GIT_EBUFS)
 			return 0; /* Ask for more */
 		if (error < 0)
 			return p->error = -1;
diff --git a/src/refs.c b/src/refs.c
index 88e2218..1ef3e13 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -437,7 +437,7 @@ static int packed_load(git_repository *repo)
 	 * for us here, so just return. Anything else means we need to
 	 * refresh the packed refs.
 	 */
-	if (result == GIT_NOTFOUND) {
+	if (result == GIT_ENOTFOUND) {
 		git_strmap_clear(ref_cache->packfile);
 		return 0;
 	}
@@ -917,7 +917,7 @@ static int reference_can_write(
 		if (exists) {
 			giterr_set(GITERR_REFERENCE,
 				"A reference with that name (%s) already exists", refname);
-			return GIT_EXISTS;
+			return GIT_EEXISTS;
 		}
 	}
 
@@ -962,7 +962,7 @@ static int packed_lookup(git_reference *ref)
 	pos = git_strmap_lookup_index(packfile_refs, ref->name);
 	if (!git_strmap_valid_index(packfile_refs, pos)) {
 		giterr_set(GITERR_REFERENCE, "Reference '%s' not found", ref->name);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	pack_ref = git_strmap_value_at(packfile_refs, pos);
@@ -984,7 +984,7 @@ static int reference_lookup(git_reference *ref)
 
 	/* only try to lookup this reference on the packfile if it
 	 * wasn't found on the loose refs; not if there was a critical error */
-	if (result == GIT_NOTFOUND) {
+	if (result == GIT_ENOTFOUND) {
 		giterr_clear();
 		result = packed_lookup(ref);
 		if (result == 0)
diff --git a/src/refspec.c b/src/refspec.c
index adb162d..697b1bf 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -68,7 +68,7 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con
 	baselen = strlen(spec->dst);
 	if (outlen <= baselen) {
 		giterr_set(GITERR_INVALID, "Reference name too long");
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 	}
 
 	/*
@@ -90,7 +90,7 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con
 
 	if (outlen <= baselen + namelen) {
 		giterr_set(GITERR_INVALID, "Reference name too long");
-		return GIT_SHORTBUFFER;
+		return GIT_EBUFS;
 	}
 
 	memcpy(out, spec->dst, baselen);
diff --git a/src/remote.c b/src/remote.c
index db4d0a7..9740344 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -135,7 +135,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 	}
 
 	error = parse_remote_refspec(config, &remote->fetch, git_buf_cstr(&buf));
-	if (error == GIT_NOTFOUND)
+	if (error == GIT_ENOTFOUND)
 		error = 0;
 
 	if (error < 0) {
@@ -150,7 +150,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
 	}
 
 	error = parse_remote_refspec(config, &remote->push, git_buf_cstr(&buf));
-	if (error == GIT_NOTFOUND)
+	if (error == GIT_ENOTFOUND)
 		error = 0;
 
 	if (error < 0) {
@@ -357,10 +357,10 @@ int git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, co
 			goto on_error;
 
 		error = git_reference_name_to_oid(&old, remote->repo, refname.ptr);
-		if (error < 0 && error != GIT_NOTFOUND)
+		if (error < 0 && error != GIT_ENOTFOUND)
 			goto on_error;
 
-		if (error == GIT_NOTFOUND)
+		if (error == GIT_ENOTFOUND)
 			memset(&old, 0, GIT_OID_RAWSZ);
 
 		if (!git_oid_cmp(&old, &head->oid))
diff --git a/src/repository.c b/src/repository.c
index 2979b44..6ce3a56 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -148,7 +148,7 @@ static int load_workdir(git_repository *repo, git_buf *parent_path)
 	error = git_config_get_string(&worktree, config, "core.worktree");
 	if (!error && worktree != NULL)
 		repo->workdir = git__strdup(worktree);
-	else if (error != GIT_NOTFOUND)
+	else if (error != GIT_ENOTFOUND)
 		return error;
 	else {
 		giterr_clear();
@@ -342,7 +342,7 @@ static int find_repo(
 	if (!git_buf_len(repo_path) && !error) {
 		giterr_set(GITERR_REPOSITORY,
 			"Could not find repository from '%s'", start_path);
-		error = GIT_NOTFOUND;
+		error = GIT_ENOTFOUND;
 	}
 
 	return error;
@@ -403,7 +403,7 @@ int git_repository_discover(
 	*repository_path = '\0';
 
 	if ((error = find_repo(&path, NULL, start_path, flags, ceiling_dirs)) < 0)
-		return error != GIT_NOTFOUND ? -1 : error;
+		return error != GIT_ENOTFOUND ? -1 : error;
 
 	if (size < (size_t)(path.size + 1)) {
 		giterr_set(GITERR_REPOSITORY,
@@ -851,7 +851,7 @@ int git_repository_head_orphan(git_repository *repo)
 	error = git_repository_head(&ref, repo);
 	git_reference_free(ref);
 
-	if (error == GIT_NOTFOUND)
+	if (error == GIT_ENOTFOUND)
 		return 1;
 
 	if (error < 0)
@@ -883,7 +883,7 @@ int git_repository_is_empty(git_repository *repo)
 	git_reference_free(head);
 	git_reference_free(branch);
 
-	if (error == GIT_NOTFOUND)
+	if (error == GIT_ENOTFOUND)
 		return 1;
 
 	if (error < 0)
diff --git a/src/revwalk.c b/src/revwalk.c
index 67695f8..e64d93f 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -375,7 +375,7 @@ int git_merge_base(git_oid *out, git_repository *repo, git_oid *one, git_oid *tw
 
 	if (!result) {
 		git_revwalk_free(walk);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 	git_oid_cpy(out, &result->item->oid);
diff --git a/src/status.c b/src/status.c
index 6676cd3..e9ad3cf 100644
--- a/src/status.c
+++ b/src/status.c
@@ -214,7 +214,7 @@ int git_status_file(
 	if (!error && !sfi.count) {
 		giterr_set(GITERR_INVALID,
 			"Attempt to get status of nonexistent file '%s'", path);
-		error = GIT_NOTFOUND;
+		error = GIT_ENOTFOUND;
 	}
 
 	*status_flags = sfi.status;
diff --git a/src/submodule.c b/src/submodule.c
index a63043f..3c07e65 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -351,7 +351,7 @@ int git_submodule_foreach(
 	git_strmap_foreach_value(repo->submodules, sm, {
 		/* usually the following will not come into play */
 		if (sm->refcount > 1) {
-			if (git_vector_bsearch(&seen, sm) != GIT_NOTFOUND)
+			if (git_vector_bsearch(&seen, sm) != GIT_ENOTFOUND)
 				continue;
 			if ((error = git_vector_insert(&seen, sm)) < 0)
 				break;
@@ -378,7 +378,7 @@ int git_submodule_lookup(
 
 	pos = git_strmap_lookup_index(repo->submodules, name);
 	if (!git_strmap_valid_index(repo->submodules, pos))
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	if (sm_ptr)
 		*sm_ptr = git_strmap_value_at(repo->submodules, pos);
diff --git a/src/tag.c b/src/tag.c
index 2a9ffee..63424f5 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -254,7 +254,7 @@ static int git_tag_create__internal(
 	}
 
 	error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag_name);
-	if (error < 0 && error != GIT_NOTFOUND)
+	if (error < 0 && error != GIT_ENOTFOUND)
 		return -1;
 
 	/** Ensure the tag name doesn't conflict with an already existing
@@ -262,7 +262,7 @@ static int git_tag_create__internal(
 	if (error == 0 && !allow_ref_overwrite) {
 		git_buf_free(&ref_name);
 		giterr_set(GITERR_TAG, "Tag already exists");
-		return GIT_EXISTS;
+		return GIT_EEXISTS;
 	}
 
 	if (create_tag_annotation) {
@@ -332,7 +332,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
 	}
 
 	error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag.tag_name);
-	if (error < 0 && error != GIT_NOTFOUND)
+	if (error < 0 && error != GIT_ENOTFOUND)
 		goto on_error;
 
 	/* We don't need these objects after this */
@@ -345,7 +345,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
 	 *	reference unless overwriting has explictly been requested **/
 	if (error == 0 && !allow_ref_overwrite) {
 		giterr_set(GITERR_TAG, "Tag already exists");
-		return GIT_EXISTS;
+		return GIT_EEXISTS;
 	}
 
 	/* write the buffer */
diff --git a/src/transports/git.c b/src/transports/git.c
index c8f5080..5baa810 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -147,7 +147,7 @@ static int store_refs(transport_git *t)
 			return 0;
 
 		ret = git_protocol_store_refs(&t->proto, buf->data, buf->offset);
-		if (ret == GIT_SHORTBUFFER) {
+		if (ret == GIT_EBUFS) {
 			gitno_consume_n(buf, buf->len);
 			continue;
 		}
@@ -279,7 +279,7 @@ static int recv_pkt(gitno_buffer *buf)
 			return -1;
 
 		error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->offset);
-		if (error == GIT_SHORTBUFFER)
+		if (error == GIT_EBUFS)
 			continue;
 		if (error < 0)
 			return -1;
@@ -384,7 +384,7 @@ static int git_download_pack(git_transport *transport, git_repository *repo, git
 			}
 
 			error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->offset);
-			if (error == GIT_SHORTBUFFER)
+			if (error == GIT_EBUFS)
 				break;
 
 			if (error < 0)
diff --git a/src/transports/http.c b/src/transports/http.c
index b382f7c..2a8ebbb 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -354,7 +354,7 @@ static int on_body_parse_response(http_parser *parser, const char *str, size_t l
 			return 0;
 
 		error = git_pkt_parse_line(&pkt, ptr, &line_end, git_buf_len(buf));
-		if (error == GIT_SHORTBUFFER) {
+		if (error == GIT_EBUFS) {
 			return 0; /* Ask for more */
 		}
 		if (error < 0)
diff --git a/src/tree.c b/src/tree.c
index a5fe2b6..92b1b1e 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -117,7 +117,7 @@ static int tree_key_search(git_vector *entries, const char *filename)
 	}
 
 	/* The filename doesn't exist at all */
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 }
 
 void git_tree__free(git_tree *tree)
@@ -186,7 +186,7 @@ const git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename
 	assert(tree && filename);
 
 	idx = tree_key_search(&tree->entries, filename);
-	if (idx == GIT_NOTFOUND)
+	if (idx == GIT_ENOTFOUND)
 		return NULL;
 
 	return git_vector_get(&tree->entries, idx);
@@ -518,7 +518,7 @@ int git_treebuilder_insert(git_tree_entry **entry_out, git_treebuilder *bld, con
 	git_oid_cpy(&entry->oid, id);
 	entry->attr = attributes;
 
-	if (pos == GIT_NOTFOUND) {
+	if (pos == GIT_ENOTFOUND) {
 		if (git_vector_insert(&bld->entries, entry) < 0)
 			return -1;
 	}
@@ -682,7 +682,7 @@ static int tree_frompath(
 		giterr_set(GITERR_TREE,
 			"No tree entry can be found from "
 			"the given tree and relative path '%s'.", treeentry_path->ptr);
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 	}
 
 
diff --git a/src/vector.c b/src/vector.c
index 6bd1e93..6f9aacc 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -137,7 +137,7 @@ int git_vector_bsearch3(
 	if (at_pos != NULL)
 		*at_pos = (unsigned int)pos;
 
-	return (rval >= 0) ? (int)pos : GIT_NOTFOUND;
+	return (rval >= 0) ? (int)pos : GIT_ENOTFOUND;
 }
 
 int git_vector_search2(
@@ -152,7 +152,7 @@ int git_vector_search2(
 			return i;
 	}
 
-	return GIT_NOTFOUND;
+	return GIT_ENOTFOUND;
 }
 
 static int strict_comparison(const void *a, const void *b)
@@ -172,7 +172,7 @@ int git_vector_remove(git_vector *v, unsigned int idx)
 	assert(v);
 
 	if (idx >= v->length || v->length == 0)
-		return GIT_NOTFOUND;
+		return GIT_ENOTFOUND;
 
 	for (i = idx; i < v->length - 1; ++i)
 		v->contents[i] = v->contents[i + 1];
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c
index 4583a14..f877447 100644
--- a/tests-clar/config/write.c
+++ b/tests-clar/config/write.c
@@ -62,7 +62,7 @@ void test_config_write__delete_value(void)
 	git_config_free(cfg);
 
 	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
-	cl_assert(git_config_get_int32(&i, cfg, "core.dummy") == GIT_NOTFOUND);
+	cl_assert(git_config_get_int32(&i, cfg, "core.dummy") == GIT_ENOTFOUND);
 	cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1));
 	git_config_free(cfg);
 }
@@ -87,6 +87,6 @@ void test_config_write__delete_inexistent(void)
 	git_config *cfg;
 
 	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
-	cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_NOTFOUND);
+	cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND);
 	git_config_free(cfg);
 }
diff --git a/tests-clar/core/path.c b/tests-clar/core/path.c
index af8bf81..d826612 100644
--- a/tests-clar/core/path.c
+++ b/tests-clar/core/path.c
@@ -413,8 +413,8 @@ void test_core_path__13_cannot_prettify_a_non_existing_file(void)
 	git_buf p = GIT_BUF_INIT;
 
 	cl_must_pass(git_path_exists(NON_EXISTING_FILEPATH) == false);
-	cl_assert_equal_i(GIT_NOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
-	cl_assert_equal_i(GIT_NOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH, NULL));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_path_prettify(&p, NON_EXISTING_FILEPATH "/so-do-i", NULL));
 
 	git_buf_free(&p);
 }
diff --git a/tests-clar/core/vector.c b/tests-clar/core/vector.c
index 5b47dde..ef3d6c3 100644
--- a/tests-clar/core/vector.c
+++ b/tests-clar/core/vector.c
@@ -143,7 +143,7 @@ static int merge_structs(void **old_raw, void *new)
 	((my_struct *)old)->count += 1;
 	git__free(new);
 	_struct_count--;
-	return GIT_EXISTS;
+	return GIT_EEXISTS;
 }
 
 static my_struct *alloc_struct(int value)
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 6420163..3436f8d 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -153,7 +153,7 @@ void test_index_tests__find_in_empty(void)
 
    for (i = 0; i < ARRAY_SIZE(test_entries); ++i) {
       int idx = git_index_find(index, test_entries[i].path);
-      cl_assert(idx == GIT_NOTFOUND);
+      cl_assert(idx == GIT_ENOTFOUND);
    }
 
    git_index_free(index);
diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c
index 17cc797..0649c86 100644
--- a/tests-clar/network/remotes.c
+++ b/tests-clar/network/remotes.c
@@ -156,7 +156,7 @@ void test_network_remotes__list(void)
 
 void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
 {
-	cl_assert_equal_i(GIT_NOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
 }
 
 void test_network_remotes__add(void)
diff --git a/tests-clar/notes/notes.c b/tests-clar/notes/notes.c
index c23a9f0..5185f25 100644
--- a/tests-clar/notes/notes.c
+++ b/tests-clar/notes/notes.c
@@ -127,7 +127,7 @@ void test_notes_notes__retrieving_a_list_of_notes_for_an_unknown_namespace_retur
 
 	error = git_note_foreach(_repo, "refs/notes/i-am-not", note_list_cb, &retrieved_notes);
 	cl_git_fail(error);
-	cl_assert_equal_i(GIT_NOTFOUND, error);
+	cl_assert_equal_i(GIT_ENOTFOUND, error);
 
 	cl_assert_equal_i(0, retrieved_notes);
 }
diff --git a/tests-clar/object/lookup.c b/tests-clar/object/lookup.c
index f840cb3..7cbcc61 100644
--- a/tests-clar/object/lookup.c
+++ b/tests-clar/object/lookup.c
@@ -22,7 +22,7 @@ void test_object_lookup__lookup_wrong_type_returns_enotfound(void)
 
 	cl_git_pass(git_oid_fromstr(&oid, commit));
 	cl_assert_equal_i(
-		GIT_NOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_TAG));
+		GIT_ENOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_TAG));
 }
 
 void test_object_lookup__lookup_nonexisting_returns_enotfound(void)
@@ -33,7 +33,7 @@ void test_object_lookup__lookup_nonexisting_returns_enotfound(void)
 
 	cl_git_pass(git_oid_fromstr(&oid, unknown));
 	cl_assert_equal_i(
-		GIT_NOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_ANY));
+		GIT_ENOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_ANY));
 }
 
 void test_object_lookup__lookup_wrong_type_by_abbreviated_id_returns_enotfound(void)
@@ -44,7 +44,7 @@ void test_object_lookup__lookup_wrong_type_by_abbreviated_id_returns_enotfound(v
 
 	cl_git_pass(git_oid_fromstrn(&oid, commit, strlen(commit)));
 	cl_assert_equal_i(
-		GIT_NOTFOUND, git_object_lookup_prefix(&object, g_repo, &oid, strlen(commit), GIT_OBJ_TAG));
+		GIT_ENOTFOUND, git_object_lookup_prefix(&object, g_repo, &oid, strlen(commit), GIT_OBJ_TAG));
 }
 
 void test_object_lookup__lookup_wrong_type_eventually_returns_enotfound(void)
@@ -59,5 +59,5 @@ void test_object_lookup__lookup_wrong_type_eventually_returns_enotfound(void)
 	git_object_free(object);
 
 	cl_assert_equal_i(
-		GIT_NOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_TAG));
+		GIT_ENOTFOUND, git_object_lookup(&object, g_repo, &oid, GIT_OBJ_TAG));
 }
diff --git a/tests-clar/object/tree/frompath.c b/tests-clar/object/tree/frompath.c
index 7d4adaf..06c69ac 100644
--- a/tests-clar/object/tree/frompath.c
+++ b/tests-clar/object/tree/frompath.c
@@ -66,8 +66,8 @@ void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void)
 
 void test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment(void)
 {
-	assert_tree_from_path(tree, "nope/de/fgh/1.txt", GIT_NOTFOUND, NULL);
-	assert_tree_from_path(tree, "ab/me-neither/fgh/2.txt", GIT_NOTFOUND, NULL);
+	assert_tree_from_path(tree, "nope/de/fgh/1.txt", GIT_ENOTFOUND, NULL);
+	assert_tree_from_path(tree, "ab/me-neither/fgh/2.txt", GIT_ENOTFOUND, NULL);
 }
 
 void test_object_tree_frompath__fail_when_processing_an_invalid_path(void)
diff --git a/tests-clar/refs/branches/delete.c b/tests-clar/refs/branches/delete.c
index 629c491..03d3c56 100644
--- a/tests-clar/refs/branches/delete.c
+++ b/tests-clar/refs/branches/delete.c
@@ -81,7 +81,7 @@ static void assert_non_exisitng_branch_removal(const char *branch_name, git_bran
 	error = git_branch_delete(repo, branch_name, branch_type);
 
 	cl_git_fail(error);
-	cl_assert_equal_i(GIT_NOTFOUND, error);
+	cl_assert_equal_i(GIT_ENOTFOUND, error);
 }
 
 void test_refs_branches_delete__deleting_a_non_existing_branch_returns_ENOTFOUND(void)
diff --git a/tests-clar/refs/branches/move.c b/tests-clar/refs/branches/move.c
index 8948497..242e5cd 100644
--- a/tests-clar/refs/branches/move.c
+++ b/tests-clar/refs/branches/move.c
@@ -68,5 +68,5 @@ void test_refs_branches_move__moving_a_non_exisiting_branch_returns_ENOTFOUND(vo
 	error = git_branch_move(repo, "where/am/I", NEW_BRANCH_NAME, 0);
 	cl_git_fail(error);
 
-	cl_assert_equal_i(GIT_NOTFOUND, error);
+	cl_assert_equal_i(GIT_ENOTFOUND, error);
 }
diff --git a/tests-clar/repo/discover.c b/tests-clar/repo/discover.c
index 635bf96..b3d639b 100644
--- a/tests-clar/repo/discover.c
+++ b/tests-clar/repo/discover.c
@@ -82,7 +82,7 @@ void test_repo_discover__0(void)
 	append_ceiling_dir(&ceiling_dirs_buf, TEMP_REPO_FOLDER);
 	ceiling_dirs = git_buf_cstr(&ceiling_dirs_buf);
 
-	cl_assert_equal_i(GIT_NOTFOUND, git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
 
 	cl_git_pass(git_repository_init(&repo, DISCOVER_FOLDER, 1));
 	cl_git_pass(git_repository_discover(repository_path, sizeof(repository_path), DISCOVER_FOLDER, 0, ceiling_dirs));
@@ -117,7 +117,7 @@ void test_repo_discover__0(void)
 	cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER1, 0, ceiling_dirs));
 	cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER2, 0, ceiling_dirs));
 	cl_git_fail(git_repository_discover(found_path, sizeof(found_path), ALTERNATE_MALFORMED_FOLDER3, 0, ceiling_dirs));
-	cl_assert_equal_i(GIT_NOTFOUND, git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), ALTERNATE_NOT_FOUND_FOLDER, 0, ceiling_dirs));
 
 	append_ceiling_dir(&ceiling_dirs_buf, SUB_REPOSITORY_FOLDER);
 	ceiling_dirs = git_buf_cstr(&ceiling_dirs_buf);
@@ -125,9 +125,9 @@ void test_repo_discover__0(void)
 	//this must pass as ceiling_directories cannot predent the current
 	//working directory to be checked
 	cl_git_pass(git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER, 0, ceiling_dirs));
-	cl_assert_equal_i(GIT_NOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs));
-	cl_assert_equal_i(GIT_NOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs));
-	cl_assert_equal_i(GIT_NOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB, 0, ceiling_dirs));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB, 0, ceiling_dirs));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_discover(found_path, sizeof(found_path), SUB_REPOSITORY_FOLDER_SUB_SUB_SUB, 0, ceiling_dirs));
 
 	//.gitfile redirection should not be affected by ceiling directories
 	ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER, ceiling_dirs, sub_repository_path);
diff --git a/tests-clar/repo/open.c b/tests-clar/repo/open.c
index 62578be..c70ec83 100644
--- a/tests-clar/repo/open.c
+++ b/tests-clar/repo/open.c
@@ -278,5 +278,5 @@ void test_repo_open__win32_path(void)
 void test_repo_open__opening_a_non_existing_repository_returns_ENOTFOUND(void)
 {
 	git_repository *repo;
-	cl_assert_equal_i(GIT_NOTFOUND, git_repository_open(&repo, "i-do-not/exist"));
+	cl_assert_equal_i(GIT_ENOTFOUND, git_repository_open(&repo, "i-do-not/exist"));
 }
diff --git a/tests-clar/revwalk/mergebase.c b/tests-clar/revwalk/mergebase.c
index 694dffc..e807e3a 100644
--- a/tests-clar/revwalk/mergebase.c
+++ b/tests-clar/revwalk/mergebase.c
@@ -63,7 +63,7 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
 	error = git_merge_base(&result, _repo, &one, &two);
 	cl_git_fail(error);
 
-	cl_assert_equal_i(GIT_NOTFOUND, error);
+	cl_assert_equal_i(GIT_ENOTFOUND, error);
 }
 
 /*
diff --git a/tests-clar/status/submodules.c b/tests-clar/status/submodules.c
index 63a44dc..9423e84 100644
--- a/tests-clar/status/submodules.c
+++ b/tests-clar/status/submodules.c
@@ -34,9 +34,9 @@ void test_status_submodules__api(void)
 {
 	git_submodule *sm;
 
-	cl_assert(git_submodule_lookup(NULL, g_repo, "nonexistent") == GIT_NOTFOUND);
+	cl_assert(git_submodule_lookup(NULL, g_repo, "nonexistent") == GIT_ENOTFOUND);
 
-	cl_assert(git_submodule_lookup(NULL, g_repo, "modified") == GIT_NOTFOUND);
+	cl_assert(git_submodule_lookup(NULL, g_repo, "modified") == GIT_ENOTFOUND);
 
 	cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo"));
 	cl_assert(sm != NULL);
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index d839e84..6cc6259 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -199,7 +199,7 @@ void test_status_worktree__single_nonexistent_file(void)
 
 	error = git_status_file(&status_flags, repo, "nonexistent");
 	cl_git_fail(error);
-	cl_assert(error == GIT_NOTFOUND);
+	cl_assert(error == GIT_ENOTFOUND);
 }
 
 /* this test is equivalent to t18-status.c:singlestatus2 */
@@ -211,7 +211,7 @@ void test_status_worktree__single_nonexistent_file_empty_repo(void)
 
 	error = git_status_file(&status_flags, repo, "nonexistent");
 	cl_git_fail(error);
-	cl_assert(error == GIT_NOTFOUND);
+	cl_assert(error == GIT_ENOTFOUND);
 }
 
 /* this test is equivalent to t18-status.c:singlestatus3 */
@@ -235,7 +235,7 @@ void test_status_worktree__single_folder(void)
 
 	error = git_status_file(&status_flags, repo, "subdir");
 	cl_git_fail(error);
-	cl_assert(error != GIT_NOTFOUND);
+	cl_assert(error != GIT_ENOTFOUND);
 }
 
 
@@ -416,7 +416,7 @@ void test_status_worktree__cannot_retrieve_the_status_of_a_bare_repository(void)
 	error = git_status_file(&status, repo, "dummy");
 
 	cl_git_fail(error);
-	cl_assert(error != GIT_NOTFOUND);
+	cl_assert(error != GIT_ENOTFOUND);
 
 	git_repository_free(repo);
 }