Commit 54b2a37ac7715c74e5b06b76eb2b631987d7b6f8

Ben Straub 2012-11-20T16:02:25

Clean up config.h

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
diff --git a/include/git2/config.h b/include/git2/config.h
index 8ec78e3..af4d540 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -41,23 +41,26 @@ typedef struct {
 	unsigned int level;
 } git_config_entry;
 
+typedef int  (*git_config_foreach_cb)(const git_config_entry *, void *);
+
+
 /**
  * Generic backend that implements the interface to
  * access a configuration file
  */
-struct git_config_file {
+struct git_config_backend {
 	struct git_config *cfg;
 
 	/* Open means open the file/database and parse if necessary */
-	int (*open)(struct git_config_file *, unsigned int level);
-	int (*get)(struct git_config_file *, const char *key, const git_config_entry **entry);
-	int (*get_multivar)(struct git_config_file *, const char *key, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
-	int (*set)(struct git_config_file *, const char *key, const char *value);
-	int (*set_multivar)(git_config_file *cfg, const char *name, const char *regexp, const char *value);
-	int (*del)(struct git_config_file *, const char *key);
-	int (*foreach)(struct git_config_file *, const char *, int (*fn)(const git_config_entry *, void *), void *data);
-	int (*refresh)(struct git_config_file *);
-	void (*free)(struct git_config_file *);
+	int (*open)(struct git_config_backend *, unsigned int level);
+	int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
+	int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
+	int (*set)(struct git_config_backend *, const char *key, const char *value);
+	int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
+	int (*del)(struct git_config_backend *, const char *key);
+	int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
+	int (*refresh)(struct git_config_backend *);
+	void (*free)(struct git_config_backend *);
 };
 
 typedef enum {
@@ -87,11 +90,11 @@ typedef struct {
  * This method will not guess the path to the xdg compatible
  * config file (.config/git/config).
  *
- * @param global_config_path Buffer of GIT_PATH_MAX length to store the path
- * @return 0 if a global configuration file has been
- *	found. Its path will be stored in `buffer`.
+ * @param out Buffer to store the path in
+ * @param length size of the buffer in bytes
+ * @return 0 if a global configuration file has been found. Its path will be stored in `buffer`.
  */
-GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
+GIT_EXTERN(int) git_config_find_global(char *out, size_t length);
 
 /**
  * Locate the path to the global xdg compatible configuration file
@@ -104,11 +107,12 @@ GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
  * may be used on any `git_config` call to load the
  * xdg compatible configuration file.
  *
- * @param xdg_config_path Buffer of GIT_PATH_MAX length to store the path
+ * @param out Buffer to store the path in
+ * @param length size of the buffer in bytes
  * @return 0 if a xdg compatible configuration file has been
  *	found. Its path will be stored in `buffer`.
  */
-GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
+GIT_EXTERN(int) git_config_find_xdg(char *out, size_t length);
 
 /**
  * Locate the path to the system configuration file
@@ -116,11 +120,12 @@ GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
  * If /etc/gitconfig doesn't exist, it will look for
  * %PROGRAMFILES%\Git\etc\gitconfig.
 
- * @param system_config_path Buffer of GIT_PATH_MAX length to store the path
+ * @param global_config_path Buffer to store the path in
+ * @param length size of the buffer in bytes
  * @return 0 if a system configuration file has been
  *	found. Its path will be stored in `buffer`.
  */
-GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
+GIT_EXTERN(int) git_config_find_system(char *out, size_t length);
 
 /**
  * Open the global, XDG and system configuration files
@@ -163,9 +168,9 @@ GIT_EXTERN(int) git_config_new(git_config **out);
  * @return 0 on success, GIT_EEXISTS when adding more than one file
  *  for a given priority level (and force_replace set to 0), or error code
  */
-GIT_EXTERN(int) git_config_add_file(
+GIT_EXTERN(int) git_config_add_backend(
 	git_config *cfg,
-	git_config_file *file,
+	git_config_backend *file,
 	unsigned int level,
 	int force);
 
@@ -223,12 +228,15 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
  * will return different config instances, but containing the same config_file
  * instance.
  *
+ * @param out The configuration instance to create
+ * @param parent Multi-level config to search for the given level
+ * @param level Configuration level to search for
  * @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
  * multi-level parent config, or an error code
  */
 GIT_EXTERN(int) git_config_open_level(
-    git_config **cfg_out,
-    git_config *cfg_parent,
+    git_config **out,
+    const git_config *parent,
     unsigned int level);
 
 /**
@@ -262,7 +270,10 @@ GIT_EXTERN(void) git_config_free(git_config *cfg);
  * @param name the variable's name
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_entry(
+   const git_config_entry **out,
+	const git_config *cfg,
+	const char *name);
 
 /**
  * Get the value of an integer config variable.
@@ -276,7 +287,7 @@ GIT_EXTERN(int) git_config_get_entry(const git_config_entry **out, git_config *c
  * @param name the variable's name
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name);
 
 /**
  * Get the value of a long integer config variable.
@@ -290,7 +301,7 @@ GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *
  * @param name the variable's name
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name);
 
 /**
  * Get the value of a boolean config variable.
@@ -307,7 +318,7 @@ GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *
  * @param name the variable's name
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name);
 
 /**
  * Get the value of a string config variable.
@@ -324,7 +335,7 @@ GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name)
  * @param name the variable's name
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name);
 
 /**
  * Get each value of a multivar.
@@ -338,7 +349,7 @@ GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const c
  * @param fn the function to be called on each value of the variable
  * @param data opaque pointer to pass to the callback
  */
-GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
+GIT_EXTERN(int) git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
 
 /**
  * Set the value of an integer config variable in the config file
@@ -404,7 +415,7 @@ GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const
  * @param cfg the configuration
  * @param name the variable to delete
  */
-GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
+GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name);
 
 /**
  * Perform an operation on each config variable.
@@ -420,8 +431,8 @@ GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
  * @return 0 on success, GIT_EUSER on non-zero callback, or error code
  */
 GIT_EXTERN(int) git_config_foreach(
-	git_config *cfg,
-	int (*callback)(const git_config_entry *, void *payload),
+	const git_config *cfg,
+	git_config_foreach_cb callback,
 	void *payload);
 
 /**
@@ -438,9 +449,9 @@ GIT_EXTERN(int) git_config_foreach(
  * @return 0 or the return value of the callback which didn't return 0
  */
 GIT_EXTERN(int) git_config_foreach_match(
-	git_config *cfg,
+	const git_config *cfg,
 	const char *regexp,
-	int (*callback)(const git_config_entry *entry, void *payload),
+	git_config_foreach_cb callback,
 	void *payload);
 
 /**
@@ -477,7 +488,12 @@ GIT_EXTERN(int) git_config_foreach_match(
  * @param map_n number of mapping objects in `maps`
  * @return 0 on success, error code otherwise
  */
-GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n);
+GIT_EXTERN(int) git_config_get_mapped(
+      int *out,
+      const git_config *cfg,
+      const char *name,
+      const git_cvar_map *maps,
+      size_t map_n);
 
 /**
  * Maps a string value to an integer constant
@@ -489,7 +505,7 @@ GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *nam
  */
 GIT_EXTERN(int) git_config_lookup_map_value(
 	int *out,
-	git_cvar_map *maps,
+	const git_cvar_map *maps,
 	size_t map_n,
 	const char *value);
 
@@ -506,7 +522,7 @@ GIT_EXTERN(int) git_config_lookup_map_value(
 GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
 
 /**
- * Parse a string value as an int64.
+ * Parse a string value as an int32.
  *
  * An optional value suffix of 'k', 'm', or 'g' will
  * cause the value to be multiplied by 1024, 1048576,
@@ -515,10 +531,10 @@ GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
  * @param out place to store the result of the parsing
  * @param value value to parse
  */
-GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
+GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
 
 /**
- * Parse a string value as an int32.
+ * Parse a string value as an int64.
  *
  * An optional value suffix of 'k', 'm', or 'g' will
  * cause the value to be multiplied by 1024, 1048576,
@@ -527,7 +543,7 @@ GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
  * @param out place to store the result of the parsing
  * @param value value to parse
  */
-GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
+GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
 
 
 /** @} */
diff --git a/include/git2/types.h b/include/git2/types.h
index 2562964..11bcf27 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -129,7 +129,7 @@ typedef struct git_index git_index;
 typedef struct git_config git_config;
 
 /** Interface to access a configuration file */
-typedef struct git_config_file git_config_file;
+typedef struct git_config_backend git_config_backend;
 
 /** Representation of a reference log entry */
 typedef struct git_reflog_entry git_reflog_entry;
diff --git a/src/config.c b/src/config.c
index fc9ea65..5ee0d39 100644
--- a/src/config.c
+++ b/src/config.c
@@ -19,13 +19,13 @@
 typedef struct {
 	git_refcount rc;
 
-	git_config_file *file;
+	git_config_backend *file;
 	unsigned int level;
 } file_internal;
 
 static void file_internal_free(file_internal *internal)
 {
-	git_config_file *file;
+	git_config_backend *file;
 
 	file = internal->file;
 	file->free(file);
@@ -87,7 +87,7 @@ int git_config_add_file_ondisk(
 	unsigned int level,
 	int force)
 {
-	git_config_file *file = NULL;
+	git_config_backend *file = NULL;
 	int res;
 
 	assert(cfg && path);
@@ -100,7 +100,7 @@ int git_config_add_file_ondisk(
 	if (git_config_file__ondisk(&file, path) < 0)
 		return -1;
 
-	if ((res = git_config_add_file(cfg, file, level, force)) < 0) {
+	if ((res = git_config_add_backend(cfg, file, level, force)) < 0) {
 		/*
 		 * free manually; the file is not owned by the config
 		 * instance yet and will not be freed on cleanup
@@ -132,7 +132,7 @@ int git_config_open_ondisk(git_config **out, const char *path)
 
 static int find_internal_file_by_level(
 	file_internal **internal_out,
-	git_config *cfg,
+	const git_config *cfg,
 	int level)
 {
 	int pos = -1;
@@ -224,7 +224,7 @@ static int git_config__add_internal(
 
 int git_config_open_level(
     git_config **cfg_out,
-    git_config *cfg_parent,
+    const git_config *cfg_parent,
     unsigned int level)
 {
 	git_config *cfg;
@@ -247,9 +247,9 @@ int git_config_open_level(
 	return 0;
 }
 
-int git_config_add_file(
+int git_config_add_backend(
 	git_config *cfg,
-	git_config_file *file,
+	git_config_backend *file,
 	unsigned int level,
 	int force)
 {
@@ -284,7 +284,7 @@ int git_config_refresh(git_config *cfg)
 
 	for (i = 0; i < cfg->files.length && !error; ++i) {
 		file_internal *internal = git_vector_get(&cfg->files, i);
-		git_config_file *file = internal->file;
+		git_config_backend *file = internal->file;
 		error = file->refresh(file);
 	}
 
@@ -296,34 +296,34 @@ int git_config_refresh(git_config *cfg)
  */
 
 int git_config_foreach(
-	git_config *cfg, int (*fn)(const git_config_entry *, void *), void *data)
+	const git_config *cfg, git_config_foreach_cb cb, void *payload)
 {
-	return git_config_foreach_match(cfg, NULL, fn, data);
+	return git_config_foreach_match(cfg, NULL, cb, payload);
 }
 
 int git_config_foreach_match(
-	git_config *cfg,
+	const git_config *cfg,
 	const char *regexp,
-	int (*fn)(const git_config_entry *, void *),
-	void *data)
+	git_config_foreach_cb cb,
+	void *payload)
 {
 	int ret = 0;
 	unsigned int i;
 	file_internal *internal;
-	git_config_file *file;
+	git_config_backend *file;
 
 	for (i = 0; i < cfg->files.length && ret == 0; ++i) {
 		internal = git_vector_get(&cfg->files, i);
 		file = internal->file;
-		ret = file->foreach(file, regexp, fn, data);
+		ret = file->foreach(file, regexp, cb, payload);
 	}
 
 	return ret;
 }
 
-int git_config_delete(git_config *cfg, const char *name)
+int git_config_delete_entry(git_config *cfg, const char *name)
 {
-	git_config_file *file;
+	git_config_backend *file;
 	file_internal *internal;
 
 	internal = git_vector_get(&cfg->files, 0);
@@ -355,7 +355,7 @@ int git_config_set_bool(git_config *cfg, const char *name, int value)
 
 int git_config_set_string(git_config *cfg, const char *name, const char *value)
 {
-	git_config_file *file;
+	git_config_backend *file;
 	file_internal *internal;
 
 	internal = git_vector_get(&cfg->files, 0);
@@ -369,9 +369,9 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
  ***********/
 int git_config_get_mapped(
 	int *out,
-	git_config *cfg,
+	const git_config *cfg,
 	const char *name,
-	git_cvar_map *maps,
+	const git_cvar_map *maps,
 	size_t map_n)
 {
 	const char *value;
@@ -383,7 +383,7 @@ int git_config_get_mapped(
 	return git_config_lookup_map_value(out, maps, map_n, value);
 }
 
-int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
+int git_config_get_int64(int64_t *out, const git_config *cfg, const char *name)
 {
 	const char *value;
 	int ret;
@@ -394,7 +394,7 @@ int git_config_get_int64(int64_t *out, git_config *cfg, const char *name)
 	return git_config_parse_int64(out, value);
 }
 
-int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
+int git_config_get_int32(int32_t *out, const git_config *cfg, const char *name)
 {
 	const char *value;
 	int ret;
@@ -405,7 +405,7 @@ int git_config_get_int32(int32_t *out, git_config *cfg, const char *name)
 	return git_config_parse_int32(out, value);
 }
 
-static int get_string_at_file(const char **out, git_config_file *file, const char *name)
+static int get_string_at_file(const char **out, const git_config_backend *file, const char *name)
 {
 	const git_config_entry *entry;
 	int res;
@@ -417,7 +417,7 @@ static int get_string_at_file(const char **out, git_config_file *file, const cha
 	return res;
 }
 
-static int get_string(const char **out, git_config *cfg, const char *name)
+static int get_string(const char **out, const git_config *cfg, const char *name)
 {
 	file_internal *internal;
 	unsigned int i;
@@ -434,7 +434,7 @@ static int get_string(const char **out, git_config *cfg, const char *name)
 	return GIT_ENOTFOUND;
 }
 
-int git_config_get_bool(int *out, git_config *cfg, const char *name)
+int git_config_get_bool(int *out, const git_config *cfg, const char *name)
 {
 	const char *value = NULL;
 	int ret;
@@ -445,7 +445,7 @@ int git_config_get_bool(int *out, git_config *cfg, const char *name)
 	return git_config_parse_bool(out, value);
 }
 
-int git_config_get_string(const char **out, git_config *cfg, const char *name)
+int git_config_get_string(const char **out, const git_config *cfg, const char *name)
 {
 	int ret;
 	const char *str = NULL;
@@ -457,7 +457,7 @@ int git_config_get_string(const char **out, git_config *cfg, const char *name)
 	return 0;
 }
 
-int git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name)
+int git_config_get_entry(const git_config_entry **out, const git_config *cfg, const char *name)
 {
 	file_internal *internal;
 	unsigned int i;
@@ -467,7 +467,7 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch
 	*out = NULL;
 
 	git_vector_foreach(&cfg->files, i, internal) {
-		git_config_file *file = internal->file;
+		git_config_backend *file = internal->file;
 		int ret = file->get(file, name, out);
 		if (ret != GIT_ENOTFOUND)
 			return ret;
@@ -476,11 +476,11 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch
 	return GIT_ENOTFOUND;
 }
 
-int git_config_get_multivar(git_config *cfg, const char *name, const char *regexp,
-			    int (*fn)(const git_config_entry *entry, void *data), void *data)
+int git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp,
+		git_config_foreach_cb cb, void *payload)
 {
 	file_internal *internal;
-	git_config_file *file;
+	git_config_backend *file;
 	int ret = GIT_ENOTFOUND;
 	size_t i;
 
@@ -493,7 +493,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
 	for (i = cfg->files.length; i > 0; --i) {
 		internal = git_vector_get(&cfg->files, i - 1);
 		file = internal->file;
-		ret = file->get_multivar(file, name, regexp, fn, data);
+		ret = file->get_multivar(file, name, regexp, cb, payload);
 		if (ret < 0 && ret != GIT_ENOTFOUND)
 			return ret;
 	}
@@ -503,7 +503,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex
 
 int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
 {
-	git_config_file *file;
+	git_config_backend *file;
 	file_internal *internal;
 
 	internal = git_vector_get(&cfg->files, 0);
@@ -634,7 +634,7 @@ int git_config_open_default(git_config **out)
  ***********/
 int git_config_lookup_map_value(
 	int *out,
-	git_cvar_map *maps,
+	const git_cvar_map *maps,
 	size_t map_n,
 	const char *value)
 {
@@ -644,7 +644,7 @@ int git_config_lookup_map_value(
 		goto fail_parse;
 
 	for (i = 0; i < map_n; ++i) {
-		git_cvar_map *m = maps + i;
+		const git_cvar_map *m = maps + i;
 
 		switch (m->cvar_type) {
 		case GIT_CVAR_FALSE:
@@ -790,7 +790,7 @@ static int rename_config_entries_cb(
 			return error;
 	}
 
-	return git_config_delete(data->config, entry->name);
+	return git_config_delete_entry(data->config, entry->name);
 }
 
 int git_config_rename_section(
diff --git a/src/config.h b/src/config.h
index c7595ee..ac8da6f 100644
--- a/src/config.h
+++ b/src/config.h
@@ -43,6 +43,6 @@ extern int git_config_rename_section(
  * @param out the new backend
  * @param path where the config file is located
  */
-extern int git_config_file__ondisk(struct git_config_file **out, const char *path);
+extern int git_config_file__ondisk(struct git_config_backend **out, const char *path);
 
 #endif
diff --git a/src/config_file.c b/src/config_file.c
index 1209c53..7cc812a 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -64,7 +64,7 @@ typedef struct cvar_t {
 		 (iter) = (tmp))
 
 typedef struct {
-	git_config_file parent;
+	git_config_backend parent;
 
 	git_strmap *values;
 
@@ -149,7 +149,7 @@ static void free_vars(git_strmap *values)
 	git_strmap_free(values);
 }
 
-static int config_open(git_config_file *cfg, unsigned int level)
+static int config_open(git_config_backend *cfg, unsigned int level)
 {
 	int res;
 	diskfile_backend *b = (diskfile_backend *)cfg;
@@ -176,7 +176,7 @@ static int config_open(git_config_file *cfg, unsigned int level)
 	return res;
 }
 
-static int config_refresh(git_config_file *cfg)
+static int config_refresh(git_config_backend *cfg)
 {
 	int res, updated = 0;
 	diskfile_backend *b = (diskfile_backend *)cfg;
@@ -203,7 +203,7 @@ static int config_refresh(git_config_file *cfg)
 	return res;
 }
 
-static void backend_free(git_config_file *_backend)
+static void backend_free(git_config_backend *_backend)
 {
 	diskfile_backend *backend = (diskfile_backend *)_backend;
 
@@ -216,7 +216,7 @@ static void backend_free(git_config_file *_backend)
 }
 
 static int file_foreach(
-	git_config_file *backend,
+	git_config_backend *backend,
 	const char *regexp,
 	int (*fn)(const git_config_entry *, void *),
 	void *data)
@@ -262,7 +262,7 @@ cleanup:
 	return result;
 }
 
-static int config_set(git_config_file *cfg, const char *name, const char *value)
+static int config_set(git_config_backend *cfg, const char *name, const char *value)
 {
 	cvar_t *var = NULL, *old_var;
 	diskfile_backend *b = (diskfile_backend *)cfg;
@@ -346,7 +346,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value)
 /*
  * Internal function that actually gets the value in string form
  */
-static int config_get(git_config_file *cfg, const char *name, const git_config_entry **out)
+static int config_get(const git_config_backend *cfg, const char *name, const git_config_entry **out)
 {
 	diskfile_backend *b = (diskfile_backend *)cfg;
 	char *key;
@@ -368,7 +368,7 @@ static int config_get(git_config_file *cfg, const char *name, const git_config_e
 }
 
 static int config_get_multivar(
-	git_config_file *cfg,
+	git_config_backend *cfg,
 	const char *name,
 	const char *regex_str,
 	int (*fn)(const git_config_entry *, void *),
@@ -431,7 +431,7 @@ static int config_get_multivar(
 }
 
 static int config_set_multivar(
-	git_config_file *cfg, const char *name, const char *regexp, const char *value)
+	git_config_backend *cfg, const char *name, const char *regexp, const char *value)
 {
 	int replaced = 0;
 	cvar_t *var, *newvar;
@@ -506,7 +506,7 @@ static int config_set_multivar(
 	return result;
 }
 
-static int config_delete(git_config_file *cfg, const char *name)
+static int config_delete(git_config_backend *cfg, const char *name)
 {
 	cvar_t *var;
 	diskfile_backend *b = (diskfile_backend *)cfg;
@@ -540,7 +540,7 @@ static int config_delete(git_config_file *cfg, const char *name)
 	return result;
 }
 
-int git_config_file__ondisk(git_config_file **out, const char *path)
+int git_config_file__ondisk(git_config_backend **out, const char *path)
 {
 	diskfile_backend *backend;
 
@@ -562,7 +562,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path)
 	backend->parent.refresh = config_refresh;
 	backend->parent.free = backend_free;
 
-	*out = (git_config_file *)backend;
+	*out = (git_config_backend *)backend;
 
 	return 0;
 }
diff --git a/src/config_file.h b/src/config_file.h
index b500dd6..a9671b6 100644
--- a/src/config_file.h
+++ b/src/config_file.h
@@ -9,36 +9,36 @@
 
 #include "git2/config.h"
 
-GIT_INLINE(int) git_config_file_open(git_config_file *cfg, unsigned int level)
+GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level)
 {
 	return cfg->open(cfg, level);
 }
 
-GIT_INLINE(void) git_config_file_free(git_config_file *cfg)
+GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
 {
 	cfg->free(cfg);
 }
 
 GIT_INLINE(int) git_config_file_get_string(
-	const git_config_entry **out, git_config_file *cfg, const char *name)
+	const git_config_entry **out, git_config_backend *cfg, const char *name)
 {
 	return cfg->get(cfg, name, out);
 }
 
 GIT_INLINE(int) git_config_file_set_string(
-	git_config_file *cfg, const char *name, const char *value)
+	git_config_backend *cfg, const char *name, const char *value)
 {
 	return cfg->set(cfg, name, value);
 }
 
 GIT_INLINE(int) git_config_file_delete(
-	git_config_file *cfg, const char *name)
+	git_config_backend *cfg, const char *name)
 {
 	return cfg->del(cfg, name);
 }
 
 GIT_INLINE(int) git_config_file_foreach(
-	git_config_file *cfg,
+	git_config_backend *cfg,
 	int (*fn)(const git_config_entry *entry, void *data),
 	void *data)
 {
@@ -46,7 +46,7 @@ GIT_INLINE(int) git_config_file_foreach(
 }
 
 GIT_INLINE(int) git_config_file_foreach_match(
-	git_config_file *cfg,
+	git_config_backend *cfg,
 	const char *regexp,
 	int (*fn)(const git_config_entry *entry, void *data),
 	void *data)
diff --git a/src/remote.c b/src/remote.c
index 063e518..5035588 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -303,7 +303,7 @@ int git_remote_save(const git_remote *remote)
 			return -1;
 		}
 	} else {
-		int error = git_config_delete(config, git_buf_cstr(&buf));
+		int error = git_config_delete_entry(config, git_buf_cstr(&buf));
 		if (error == GIT_ENOTFOUND) {
 			error = 0;
 			giterr_clear();
@@ -356,7 +356,7 @@ int git_remote_save(const git_remote *remote)
 		if (git_config_set_string(config, git_buf_cstr(&buf), "--no-tags") < 0)
 			goto on_error;
 	} else if (tagopt) {
-		if (git_config_delete(config, git_buf_cstr(&buf)) < 0)
+		if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0)
 			goto on_error;
 	}
 
diff --git a/src/repository.c b/src/repository.c
index 1642f45..efbb3a3 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -824,7 +824,7 @@ static int repo_init_config(
 			SET_REPO_CONFIG(string, "core.worktree", work_dir);
 		}
 		else if ((opts->flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0) {
-			if (git_config_delete(config, "core.worktree") < 0)
+			if (git_config_delete_entry(config, "core.worktree") < 0)
 				giterr_clear();
 		}
 	} else {
@@ -1356,7 +1356,7 @@ int git_repository_set_workdir(
 
 		/* passthrough error means gitlink is unnecessary */
 		if (error == GIT_PASSTHROUGH)
-			error = git_config_delete(config, "core.worktree");
+			error = git_config_delete_entry(config, "core.worktree");
 		else if (!error)
 			error = git_config_set_string(config, "core.worktree", path.ptr);
 
diff --git a/src/submodule.c b/src/submodule.c
index 6093ff9..994ce31 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -66,7 +66,7 @@ __KHASH_IMPL(
 	str_hash_no_trailing_slash, str_equal_no_trailing_slash);
 
 static int load_submodule_config(git_repository *repo, bool force);
-static git_config_file *open_gitmodules(git_repository *, bool, const git_oid *);
+static git_config_backend *open_gitmodules(git_repository *, bool, const git_oid *);
 static int lookup_head_remote(git_buf *url, git_repository *repo);
 static int submodule_get(git_submodule **, git_repository *, const char *, const char *);
 static void submodule_release(git_submodule *sm, int decr);
@@ -201,7 +201,7 @@ int git_submodule_add_setup(
 	int use_gitlink)
 {
 	int error = 0;
-	git_config_file *mods = NULL;
+	git_config_backend *mods = NULL;
 	git_submodule *sm;
 	git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
 	git_repository_init_options initopt;
@@ -412,7 +412,7 @@ cleanup:
 int git_submodule_save(git_submodule *submodule)
 {
 	int error = 0;
-	git_config_file *mods;
+	git_config_backend *mods;
 	git_buf key = GIT_BUF_INIT;
 
 	assert(submodule);
@@ -717,7 +717,7 @@ int git_submodule_reload(git_submodule *submodule)
 	git_index *index;
 	int pos, error;
 	git_tree *head;
-	git_config_file *mods;
+	git_config_backend *mods;
 
 	assert(submodule);
 
@@ -1187,14 +1187,14 @@ static int load_submodule_config_from_head(
 	return error;
 }
 
-static git_config_file *open_gitmodules(
+static git_config_backend *open_gitmodules(
 	git_repository *repo,
 	bool okay_to_create,
 	const git_oid *gitmodules_oid)
 {
 	const char *workdir = git_repository_workdir(repo);
 	git_buf path = GIT_BUF_INIT;
-	git_config_file *mods = NULL;
+	git_config_backend *mods = NULL;
 
 	if (workdir != NULL) {
 		if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0)
@@ -1230,7 +1230,7 @@ static int load_submodule_config(git_repository *repo, bool force)
 	int error;
 	git_oid gitmodules_oid;
 	git_buf path = GIT_BUF_INIT;
-	git_config_file *mods = NULL;
+	git_config_backend *mods = NULL;
 
 	if (repo->submodules && !force)
 		return 0;
@@ -1378,7 +1378,7 @@ static int submodule_update_config(
 		goto cleanup;
 
 	if (!value)
-		error = git_config_delete(config, key.ptr);
+		error = git_config_delete_entry(config, key.ptr);
 	else
 		error = git_config_set_string(config, key.ptr, value);
 
diff --git a/src/vector.h b/src/vector.h
index 6d820b8..46129f1 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -55,7 +55,7 @@ GIT_INLINE(int) git_vector_bsearch2(
 	return git_vector_bsearch3(NULL, v, cmp, key);
 }
 
-GIT_INLINE(void *) git_vector_get(git_vector *v, size_t position)
+GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position)
 {
 	return (position < v->length) ? v->contents[position] : NULL;
 }
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 0efcaf5..e301290 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -537,7 +537,7 @@ int p_inet_pton(int af, const char* src, void* dst)
 			return -1;
 	}
 
-	if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
+	if (WSAStringToAddress((LPSTR)src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
 	{
 		errno = WSAGetLastError();
 		return -1;
diff --git a/tests-clar/config/add.c b/tests-clar/config/add.c
index 9854fbb..405f1e2 100644
--- a/tests-clar/config/add.c
+++ b/tests-clar/config/add.c
@@ -19,7 +19,7 @@ void test_config_add__to_existing_section(void)
 	cl_git_pass(git_config_set_int32(cfg, "empty.tmp", 5));
 	cl_git_pass(git_config_get_int32(&i, cfg, "empty.tmp"));
 	cl_assert(i == 5);
-	cl_git_pass(git_config_delete(cfg, "empty.tmp"));
+	cl_git_pass(git_config_delete_entry(cfg, "empty.tmp"));
 	git_config_free(cfg);
 }
 
@@ -32,6 +32,6 @@ void test_config_add__to_new_section(void)
 	cl_git_pass(git_config_set_int32(cfg, "section.tmp", 5));
 	cl_git_pass(git_config_get_int32(&i, cfg, "section.tmp"));
 	cl_assert(i == 5);
-	cl_git_pass(git_config_delete(cfg, "section.tmp"));
+	cl_git_pass(git_config_delete_entry(cfg, "section.tmp"));
 	git_config_free(cfg);
 }
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c
index d98d1dd..411d40a 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_git_pass(git_config_delete(cfg, "core.dummy"));
+	cl_git_pass(git_config_delete_entry(cfg, "core.dummy"));
 	git_config_free(cfg);
 
 	cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
@@ -94,7 +94,7 @@ void test_config_write__delete_value_at_specific_level(void)
 
 	cl_git_pass(git_config_open_level(&cfg_specific, cfg, GIT_CONFIG_LEVEL_GLOBAL));
 
-	cl_git_pass(git_config_delete(cfg_specific, "core.dummy2"));
+	cl_git_pass(git_config_delete_entry(cfg_specific, "core.dummy2"));
 	git_config_free(cfg);
 
 	cl_git_pass(git_config_open_ondisk(&cfg, "config15"));
@@ -125,7 +125,7 @@ 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_ENOTFOUND);
+	cl_assert(git_config_delete_entry(cfg, "core.imaginary") == GIT_ENOTFOUND);
 	git_config_free(cfg);
 }
 
diff --git a/tests-clar/network/remoterename.c b/tests-clar/network/remoterename.c
index e9a7fc0..b145545 100644
--- a/tests-clar/network/remoterename.c
+++ b/tests-clar/network/remoterename.c
@@ -64,7 +64,7 @@ void test_network_remoterename__renaming_a_remote_without_a_fetchrefspec_doesnt_
 
 	git_remote_free(_remote);
 	cl_git_pass(git_repository_config__weakptr(&config, _repo));
-	cl_git_pass(git_config_delete(config, "remote.test.fetch"));
+	cl_git_pass(git_config_delete_entry(config, "remote.test.fetch"));
 
 	cl_git_pass(git_remote_load(&_remote, _repo, "test"));
 
diff --git a/tests-clar/notes/notesref.c b/tests-clar/notes/notesref.c
index 67c4003..d26056f 100644
--- a/tests-clar/notes/notesref.c
+++ b/tests-clar/notes/notesref.c
@@ -57,7 +57,7 @@ void test_notes_notesref__config_corenotesref(void)
 	cl_git_pass(git_note_default_ref(&default_ref, _repo));
 	cl_assert(!strcmp(default_ref, "refs/notes/mydefaultnotesref"));
 
-	cl_git_pass(git_config_delete(_cfg, "core.notesRef"));
+	cl_git_pass(git_config_delete_entry(_cfg, "core.notesRef"));
 
 	cl_git_pass(git_note_default_ref(&default_ref, _repo));
 	cl_assert(!strcmp(default_ref, GIT_NOTES_DEFAULT_REF));
diff --git a/tests-clar/submodule/modify.c b/tests-clar/submodule/modify.c
index bfb8c8a..f6d41fd 100644
--- a/tests-clar/submodule/modify.c
+++ b/tests-clar/submodule/modify.c
@@ -76,7 +76,7 @@ void test_submodule_modify__add(void)
 static int delete_one_config(const git_config_entry *entry, void *payload)
 {
 	git_config *cfg = payload;
-	return git_config_delete(cfg, entry->name);
+	return git_config_delete_entry(cfg, entry->name);
 }
 
 static int init_one_submodule(