Commit 16b83019af63d837b6934bcf1b71b8697d5d94c8

Russell Belfer 2012-03-04T23:28:36

Fix usage of "new" for fieldname in public header This should restore the ability to include libgit2 headers in C++ projects. Cherry picked 2de60205dfea2c4a422b2108a5e8605f97c2e895 from development into new-error-handling.

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
diff --git a/include/git2/diff.h b/include/git2/diff.h
index d8dc91c..741be3a 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -57,8 +57,8 @@ typedef struct {
 	uint32_t flags;				/**< defaults to GIT_DIFF_NORMAL */
 	uint16_t context_lines;		/**< defaults to 3 */
 	uint16_t interhunk_lines;	/**< defaults to 3 */
-	char *src_prefix;			/**< defaults to "a" */
-	char *dst_prefix;			/**< defaults to "b" */
+	char *old_prefix;			/**< defaults to "a" */
+	char *new_prefix;			/**< defaults to "b" */
 	git_strarray pathspec;		/**< defaults to show all paths */
 } git_diff_options;
 
@@ -115,11 +115,11 @@ typedef struct {
  * It will just use the git attributes for those files.
  */
 typedef struct {
-	git_diff_file old;
-	git_diff_file new;
+	git_diff_file old_file;
+	git_diff_file new_file;
 	git_delta_t   status;
-	unsigned int similarity; /**< for RENAMED and COPIED, value from 0 to 100 */
-	int binary;
+	unsigned int  similarity; /**< for RENAMED and COPIED, value 0-100 */
+	int           binary;
 } git_diff_delta;
 
 /**
@@ -208,15 +208,15 @@ GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff);
  *
  * @param repo The repository containing the trees.
  * @param opts Structure with options to influence diff or NULL for defaults.
- * @param old A git_tree object to diff from.
- * @param new A git_tree object to diff to.
+ * @param old_tree A git_tree object to diff from.
+ * @param new_tree A git_tree object to diff to.
  * @param diff A pointer to a git_diff_list pointer that will be allocated.
  */
 GIT_EXTERN(int) git_diff_tree_to_tree(
 	git_repository *repo,
 	const git_diff_options *opts, /**< can be NULL for defaults */
-	git_tree *old,
-	git_tree *new,
+	git_tree *old_tree,
+	git_tree *new_tree,
 	git_diff_list **diff);
 
 /**
@@ -224,13 +224,13 @@ GIT_EXTERN(int) git_diff_tree_to_tree(
  *
  * @param repo The repository containing the tree and index.
  * @param opts Structure with options to influence diff or NULL for defaults.
- * @param old A git_tree object to diff from.
+ * @param old_tree A git_tree object to diff from.
  * @param diff A pointer to a git_diff_list pointer that will be allocated.
  */
 GIT_EXTERN(int) git_diff_index_to_tree(
 	git_repository *repo,
 	const git_diff_options *opts, /**< can be NULL for defaults */
-	git_tree *old,
+	git_tree *old_tree,
 	git_diff_list **diff);
 
 /**
@@ -259,13 +259,13 @@ GIT_EXTERN(int) git_diff_workdir_to_index(
  *
  * @param repo The repository containing the tree.
  * @param opts Structure with options to influence diff or NULL for defaults.
- * @param old A git_tree object to diff from.
+ * @param old_tree A git_tree object to diff from.
  * @param diff A pointer to a git_diff_list pointer that will be allocated.
  */
 GIT_EXTERN(int) git_diff_workdir_to_tree(
 	git_repository *repo,
 	const git_diff_options *opts, /**< can be NULL for defaults */
-	git_tree *old,
+	git_tree *old_tree,
 	git_diff_list **diff);
 
 /**
@@ -340,8 +340,8 @@ GIT_EXTERN(int) git_diff_print_patch(
  */
 GIT_EXTERN(int) git_diff_blobs(
 	git_repository *repo,
-	git_blob *old,
-	git_blob *new,
+	git_blob *old_blob,
+	git_blob *new_blob,
 	git_diff_options *options,
 	void *cb_data,
 	git_diff_hunk_fn hunk_cb,
diff --git a/src/diff.c b/src/diff.c
index 5d70b82..b8a8fb6 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -63,12 +63,12 @@ static git_diff_delta *diff_delta__alloc(
 	if (!delta)
 		return NULL;
 
-	delta->old.path = git_pool_strdup(&diff->pool, path);
-	if (delta->old.path == NULL) {
+	delta->old_file.path = git_pool_strdup(&diff->pool, path);
+	if (delta->old_file.path == NULL) {
 		git__free(delta);
 		return NULL;
 	}
-	delta->new.path = delta->old.path;
+	delta->new_file.path = delta->old_file.path;
 
 	if (diff->opts.flags & GIT_DIFF_REVERSE) {
 		switch (status) {
@@ -91,16 +91,16 @@ static git_diff_delta *diff_delta__dup(
 
 	memcpy(delta, d, sizeof(git_diff_delta));
 
-	delta->old.path = git_pool_strdup(pool, d->old.path);
-	if (delta->old.path == NULL)
+	delta->old_file.path = git_pool_strdup(pool, d->old_file.path);
+	if (delta->old_file.path == NULL)
 		goto fail;
 
-	if (d->new.path != d->old.path) {
-		delta->new.path = git_pool_strdup(pool, d->new.path);
-		if (delta->new.path == NULL)
+	if (d->new_file.path != d->old_file.path) {
+		delta->new_file.path = git_pool_strdup(pool, d->new_file.path);
+		if (delta->new_file.path == NULL)
 			goto fail;
 	} else {
-		delta->new.path = delta->old.path;
+		delta->new_file.path = delta->old_file.path;
 	}
 
 	return delta;
@@ -117,14 +117,14 @@ static git_diff_delta *diff_delta__merge_like_cgit(
 	if (!dup)
 		return NULL;
 
-	if (git_oid_cmp(&dup->new.oid, &b->new.oid) == 0)
+	if (git_oid_cmp(&dup->new_file.oid, &b->new_file.oid) == 0)
 		return dup;
 
-	git_oid_cpy(&dup->new.oid, &b->new.oid);
+	git_oid_cpy(&dup->new_file.oid, &b->new_file.oid);
 
-	dup->new.mode = b->new.mode;
-	dup->new.size = b->new.size;
-	dup->new.flags = b->new.flags;
+	dup->new_file.mode = b->new_file.mode;
+	dup->new_file.size = b->new_file.size;
+	dup->new_file.flags = b->new_file.flags;
 
 	/* Emulate C git for merging two diffs (a la 'git diff <sha>').
 	 *
@@ -132,7 +132,7 @@ static git_diff_delta *diff_delta__merge_like_cgit(
 	 * diffs with the index but uses the workdir contents.  This emulates
 	 * those choices so we can emulate the type of diff.
 	 */
-	if (git_oid_cmp(&dup->old.oid, &dup->new.oid) == 0) {
+	if (git_oid_cmp(&dup->old_file.oid, &dup->new_file.oid) == 0) {
 		if (dup->status == GIT_DELTA_DELETED)
 			/* preserve pending delete info */;
 		else if (b->status == GIT_DELTA_UNTRACKED ||
@@ -173,17 +173,17 @@ static int diff_delta__from_one(
 	assert(status != GIT_DELTA_MODIFIED);
 
 	if (delta->status == GIT_DELTA_DELETED) {
-		delta->old.mode = entry->mode;
-		delta->old.size = entry->file_size;
-		git_oid_cpy(&delta->old.oid, &entry->oid);
+		delta->old_file.mode = entry->mode;
+		delta->old_file.size = entry->file_size;
+		git_oid_cpy(&delta->old_file.oid, &entry->oid);
 	} else /* ADDED, IGNORED, UNTRACKED */ {
-		delta->new.mode = entry->mode;
-		delta->new.size = entry->file_size;
-		git_oid_cpy(&delta->new.oid, &entry->oid);
+		delta->new_file.mode = entry->mode;
+		delta->new_file.size = entry->file_size;
+		git_oid_cpy(&delta->new_file.oid, &entry->oid);
 	}
 
-	delta->old.flags |= GIT_DIFF_FILE_VALID_OID;
-	delta->new.flags |= GIT_DIFF_FILE_VALID_OID;
+	delta->old_file.flags |= GIT_DIFF_FILE_VALID_OID;
+	delta->new_file.flags |= GIT_DIFF_FILE_VALID_OID;
 
 	if (git_vector_insert(&diff->deltas, delta) < 0) {
 		git__free(delta);
@@ -196,8 +196,8 @@ static int diff_delta__from_one(
 static int diff_delta__from_two(
 	git_diff_list *diff,
 	git_delta_t   status,
-	const git_index_entry *old,
-	const git_index_entry *new,
+	const git_index_entry *old_entry,
+	const git_index_entry *new_entry,
 	git_oid *new_oid)
 {
 	git_diff_delta *delta;
@@ -207,22 +207,22 @@ static int diff_delta__from_two(
 		return 0;
 
 	if ((diff->opts.flags & GIT_DIFF_REVERSE) != 0) {
-		const git_index_entry *temp = old;
-		old = new;
-		new = temp;
+		const git_index_entry *temp = old_entry;
+		old_entry = new_entry;
+		new_entry = temp;
 	}
 
-	delta = diff_delta__alloc(diff, status, old->path);
+	delta = diff_delta__alloc(diff, status, old_entry->path);
 	GITERR_CHECK_ALLOC(delta);
 
-	delta->old.mode = old->mode;
-	git_oid_cpy(&delta->old.oid, &old->oid);
-	delta->old.flags |= GIT_DIFF_FILE_VALID_OID;
+	delta->old_file.mode = old_entry->mode;
+	git_oid_cpy(&delta->old_file.oid, &old_entry->oid);
+	delta->old_file.flags |= GIT_DIFF_FILE_VALID_OID;
 
-	delta->new.mode = new->mode;
-	git_oid_cpy(&delta->new.oid, new_oid ? new_oid : &new->oid);
-	if (new_oid || !git_oid_iszero(&new->oid))
-		delta->new.flags |= GIT_DIFF_FILE_VALID_OID;
+	delta->new_file.mode = new_entry->mode;
+	git_oid_cpy(&delta->new_file.oid, new_oid ? new_oid : &new_entry->oid);
+	if (new_oid || !git_oid_iszero(&new_entry->oid))
+		delta->new_file.flags |= GIT_DIFF_FILE_VALID_OID;
 
 	if (git_vector_insert(&diff->deltas, delta) < 0) {
 		git__free(delta);
@@ -246,7 +246,7 @@ static char *diff_strdup_prefix(git_pool *pool, const char *prefix)
 static int diff_delta__cmp(const void *a, const void *b)
 {
 	const git_diff_delta *da = a, *db = b;
-	int val = strcmp(da->old.path, db->old.path);
+	int val = strcmp(da->old_file.path, db->old_file.path);
 	return val ? val : ((int)da->status - (int)db->status);
 }
 
@@ -292,18 +292,18 @@ static git_diff_list *git_diff_list_alloc(
 	memcpy(&diff->opts, opts, sizeof(git_diff_options));
 	memset(&diff->opts.pathspec, 0, sizeof(diff->opts.pathspec));
 
-	diff->opts.src_prefix = diff_strdup_prefix(&diff->pool,
-		opts->src_prefix ? opts->src_prefix : DIFF_SRC_PREFIX_DEFAULT);
-	diff->opts.dst_prefix = diff_strdup_prefix(&diff->pool,
-		opts->dst_prefix ? opts->dst_prefix : DIFF_DST_PREFIX_DEFAULT);
+	diff->opts.old_prefix = diff_strdup_prefix(&diff->pool,
+		opts->old_prefix ? opts->old_prefix : DIFF_OLD_PREFIX_DEFAULT);
+	diff->opts.new_prefix = diff_strdup_prefix(&diff->pool,
+		opts->new_prefix ? opts->new_prefix : DIFF_NEW_PREFIX_DEFAULT);
 
-	if (!diff->opts.src_prefix || !diff->opts.dst_prefix)
+	if (!diff->opts.old_prefix || !diff->opts.new_prefix)
 		goto fail;
 
 	if (diff->opts.flags & GIT_DIFF_REVERSE) {
-		char *swap = diff->opts.src_prefix;
-		diff->opts.src_prefix = diff->opts.dst_prefix;
-		diff->opts.dst_prefix = swap;
+		char *swap = diff->opts.old_prefix;
+		diff->opts.old_prefix = diff->opts.new_prefix;
+		diff->opts.new_prefix = swap;
 	}
 
 	/* only copy pathspec if it is "interesting" so we can test
@@ -402,9 +402,9 @@ static int oid_for_workdir_item(
 #define EXEC_BIT_MASK 0000111
 
 static int maybe_modified(
-	git_iterator *old,
+	git_iterator *old_iter,
 	const git_index_entry *oitem,
-	git_iterator *new,
+	git_iterator *new_iter,
 	const git_index_entry *nitem,
 	git_diff_list *diff)
 {
@@ -413,7 +413,7 @@ static int maybe_modified(
 	unsigned int omode = oitem->mode;
 	unsigned int nmode = nitem->mode;
 
-	GIT_UNUSED(old);
+	GIT_UNUSED(old_iter);
 
 	if (!diff_path_matches_pathspec(diff, oitem->path))
 		return 0;
@@ -452,7 +452,7 @@ static int maybe_modified(
 		status = GIT_DELTA_UNMODIFIED;
 
 	/* if we have a workdir item with an unknown oid, check deeper */
-	else if (git_oid_iszero(&nitem->oid) && new->type == GIT_ITERATOR_WORKDIR) {
+	else if (git_oid_iszero(&nitem->oid) && new_iter->type == GIT_ITERATOR_WORKDIR) {
 		/* TODO: add check against index file st_mtime to avoid racy-git */
 
 		/* if they files look exactly alike, then we'll assume the same */
@@ -503,8 +503,8 @@ static int maybe_modified(
 static int diff_from_iterators(
 	git_repository *repo,
 	const git_diff_options *opts, /**< can be NULL for defaults */
-	git_iterator *old,
-	git_iterator *new,
+	git_iterator *old_iter,
+	git_iterator *new_iter,
 	git_diff_list **diff_ptr)
 {
 	const git_index_entry *oitem, *nitem;
@@ -513,11 +513,11 @@ static int diff_from_iterators(
 	if (!diff)
 		goto fail;
 
-	diff->old_src = old->type;
-	diff->new_src = new->type;
+	diff->old_src = old_iter->type;
+	diff->new_src = new_iter->type;
 
-	if (git_iterator_current(old, &oitem) < 0 ||
-		git_iterator_current(new, &nitem) < 0)
+	if (git_iterator_current(old_iter, &oitem) < 0 ||
+		git_iterator_current(new_iter, &nitem) < 0)
 		goto fail;
 
 	/* run iterators building diffs */
@@ -526,7 +526,7 @@ static int diff_from_iterators(
 		/* create DELETED records for old items not matched in new */
 		if (oitem && (!nitem || strcmp(oitem->path, nitem->path) < 0)) {
 			if (diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem) < 0 ||
-				git_iterator_advance(old, &oitem) < 0)
+				git_iterator_advance(old_iter, &oitem) < 0)
 				goto fail;
 		}
 
@@ -541,12 +541,12 @@ static int diff_from_iterators(
 			if (ignore_prefix != NULL &&
 				git__prefixcmp(nitem->path, ignore_prefix) == 0)
 			{
-				if (git_iterator_advance(new, &nitem) < 0)
+				if (git_iterator_advance(new_iter, &nitem) < 0)
 					goto fail;
 				continue;
 			}
 
-			is_ignored = git_iterator_current_is_ignored(new);
+			is_ignored = git_iterator_current_is_ignored(new_iter);
 
 			if (S_ISDIR(nitem->mode)) {
 				/* recurse into directory if explicitly requested or
@@ -557,7 +557,7 @@ static int diff_from_iterators(
 				{
 					if (is_ignored)
 						ignore_prefix = nitem->path;
-					if (git_iterator_advance_into_directory(new, &nitem) < 0)
+					if (git_iterator_advance_into_directory(new_iter, &nitem) < 0)
 						goto fail;
 					continue;
 				}
@@ -565,11 +565,11 @@ static int diff_from_iterators(
 			}
 			else if (is_ignored)
 				delta_type = GIT_DELTA_IGNORED;
-			else if (new->type == GIT_ITERATOR_WORKDIR)
+			else if (new_iter->type == GIT_ITERATOR_WORKDIR)
 				delta_type = GIT_DELTA_UNTRACKED;
 
 			if (diff_delta__from_one(diff, delta_type, nitem) < 0 ||
-				git_iterator_advance(new, &nitem) < 0)
+				git_iterator_advance(new_iter, &nitem) < 0)
 				goto fail;
 		}
 
@@ -579,21 +579,21 @@ static int diff_from_iterators(
 		else {
 			assert(oitem && nitem && strcmp(oitem->path, nitem->path) == 0);
 
-			if (maybe_modified(old, oitem, new, nitem, diff) < 0 ||
-				git_iterator_advance(old, &oitem) < 0 ||
-				git_iterator_advance(new, &nitem) < 0)
+			if (maybe_modified(old_iter, oitem, new_iter, nitem, diff) < 0 ||
+				git_iterator_advance(old_iter, &oitem) < 0 ||
+				git_iterator_advance(new_iter, &nitem) < 0)
 				goto fail;
 		}
 	}
 
-	git_iterator_free(old);
-	git_iterator_free(new);
+	git_iterator_free(old_iter);
+	git_iterator_free(new_iter);
 	*diff_ptr = diff;
 	return 0;
 
 fail:
-	git_iterator_free(old);
-	git_iterator_free(new);
+	git_iterator_free(old_iter);
+	git_iterator_free(new_iter);
 	git_diff_list_free(diff);
 	*diff_ptr = NULL;
 	return -1;
@@ -603,16 +603,16 @@ fail:
 int git_diff_tree_to_tree(
 	git_repository *repo,
 	const git_diff_options *opts, /**< can be NULL for defaults */
-	git_tree *old,
-	git_tree *new,
+	git_tree *old_tree,
+	git_tree *new_tree,
 	git_diff_list **diff)
 {
 	git_iterator *a = NULL, *b = NULL;
 
-	assert(repo && old && new && diff);
+	assert(repo && old_tree && new_tree && diff);
 
-	if (git_iterator_for_tree(repo, old, &a) < 0 ||
-		git_iterator_for_tree(repo, new, &b) < 0)
+	if (git_iterator_for_tree(repo, old_tree, &a) < 0 ||
+		git_iterator_for_tree(repo, new_tree, &b) < 0)
 		return -1;
 
 	return diff_from_iterators(repo, opts, a, b, diff);
@@ -621,14 +621,14 @@ int git_diff_tree_to_tree(
 int git_diff_index_to_tree(
 	git_repository *repo,
 	const git_diff_options *opts,
-	git_tree *old,
+	git_tree *old_tree,
 	git_diff_list **diff)
 {
 	git_iterator *a = NULL, *b = NULL;
 
-	assert(repo && old && diff);
+	assert(repo && old_tree && diff);
 
-	if (git_iterator_for_tree(repo, old, &a) < 0 ||
+	if (git_iterator_for_tree(repo, old_tree, &a) < 0 ||
 		git_iterator_for_index(repo, &b) < 0)
 		return -1;
 
@@ -655,14 +655,14 @@ int git_diff_workdir_to_index(
 int git_diff_workdir_to_tree(
 	git_repository *repo,
 	const git_diff_options *opts,
-	git_tree *old,
+	git_tree *old_tree,
 	git_diff_list **diff)
 {
 	git_iterator *a = NULL, *b = NULL;
 
-	assert(repo && old && diff);
+	assert(repo && old_tree && diff);
 
-	if (git_iterator_for_tree(repo, old, &a) < 0 ||
+	if (git_iterator_for_tree(repo, old_tree, &a) < 0 ||
 		git_iterator_for_workdir(repo, &b) < 0)
 		return -1;
 
@@ -691,7 +691,7 @@ int git_diff_merge(
 	for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) {
 		git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i);
 		const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j);
-		int cmp = !f ? -1 : !o ? 1 : strcmp(o->old.path, f->old.path);
+		int cmp = !f ? -1 : !o ? 1 : strcmp(o->old_file.path, f->old_file.path);
 
 		if (cmp < 0) {
 			delta = diff_delta__dup(o, &onto_pool);
diff --git a/src/diff.h b/src/diff.h
index 6c432c8..ac24579 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -14,8 +14,8 @@
 #include "repository.h"
 #include "pool.h"
 
-#define DIFF_SRC_PREFIX_DEFAULT "a/"
-#define DIFF_DST_PREFIX_DEFAULT "b/"
+#define DIFF_OLD_PREFIX_DEFAULT "a/"
+#define DIFF_NEW_PREFIX_DEFAULT "b/"
 
 enum {
 	GIT_DIFFCAPS_HAS_SYMLINKS     = (1 << 0), /* symlinks on platform? */
diff --git a/src/diff_output.c b/src/diff_output.c
index a5a1139..a6d75f6 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -116,11 +116,11 @@ static int update_file_is_binary_by_attr(git_repository *repo, git_diff_file *fi
 
 static void update_delta_is_binary(git_diff_delta *delta)
 {
-	if ((delta->old.flags & GIT_DIFF_FILE_BINARY) != 0 ||
-		(delta->new.flags & GIT_DIFF_FILE_BINARY) != 0)
+	if ((delta->old_file.flags & GIT_DIFF_FILE_BINARY) != 0 ||
+		(delta->new_file.flags & GIT_DIFF_FILE_BINARY) != 0)
 		delta->binary = 1;
-	else if ((delta->old.flags & GIT_DIFF_FILE_NOT_BINARY) != 0 ||
-			 (delta->new.flags & GIT_DIFF_FILE_NOT_BINARY) != 0)
+	else if ((delta->old_file.flags & GIT_DIFF_FILE_NOT_BINARY) != 0 ||
+			 (delta->new_file.flags & GIT_DIFF_FILE_NOT_BINARY) != 0)
 		delta->binary = 0;
 	/* otherwise leave delta->binary value untouched */
 }
@@ -134,33 +134,33 @@ static int file_is_binary_by_attr(
 	delta->binary = -1;
 
 	/* make sure files are conceivably mmap-able */
-	if ((git_off_t)((size_t)delta->old.size) != delta->old.size ||
-		(git_off_t)((size_t)delta->new.size) != delta->new.size)
+	if ((git_off_t)((size_t)delta->old_file.size) != delta->old_file.size ||
+		(git_off_t)((size_t)delta->new_file.size) != delta->new_file.size)
 	{
-		delta->old.flags |= GIT_DIFF_FILE_BINARY;
-		delta->new.flags |= GIT_DIFF_FILE_BINARY;
+		delta->old_file.flags |= GIT_DIFF_FILE_BINARY;
+		delta->new_file.flags |= GIT_DIFF_FILE_BINARY;
 		delta->binary = 1;
 		return 0;
 	}
 
 	/* check if user is forcing us to text diff these files */
 	if (diff->opts.flags & GIT_DIFF_FORCE_TEXT) {
-		delta->old.flags |= GIT_DIFF_FILE_NOT_BINARY;
-		delta->new.flags |= GIT_DIFF_FILE_NOT_BINARY;
+		delta->old_file.flags |= GIT_DIFF_FILE_NOT_BINARY;
+		delta->new_file.flags |= GIT_DIFF_FILE_NOT_BINARY;
 		delta->binary = 0;
 		return 0;
 	}
 
 	/* check diff attribute +, -, or 0 */
-	if (update_file_is_binary_by_attr(diff->repo, &delta->old) < 0)
+	if (update_file_is_binary_by_attr(diff->repo, &delta->old_file) < 0)
 		return -1;
 
-	mirror_new = (delta->new.path == delta->old.path ||
-				  strcmp(delta->new.path, delta->old.path) == 0);
+	mirror_new = (delta->new_file.path == delta->old_file.path ||
+				  strcmp(delta->new_file.path, delta->old_file.path) == 0);
 	if (mirror_new)
-		delta->new.flags &= (delta->old.flags & BINARY_DIFF_FLAGS);
+		delta->new_file.flags &= (delta->old_file.flags & BINARY_DIFF_FLAGS);
 	else
-		error = update_file_is_binary_by_attr(diff->repo, &delta->new);
+		error = update_file_is_binary_by_attr(diff->repo, &delta->new_file);
 
 	update_delta_is_binary(delta);
 
@@ -175,20 +175,20 @@ static int file_is_binary_by_content(
 {
 	GIT_UNUSED(diff);
 
-	if ((delta->old.flags & BINARY_DIFF_FLAGS) == 0) {
+	if ((delta->old_file.flags & BINARY_DIFF_FLAGS) == 0) {
 		size_t search_len = min(old_data->len, 4000);
 		if (strnlen(old_data->data, search_len) != search_len)
-			delta->old.flags |= GIT_DIFF_FILE_BINARY;
+			delta->old_file.flags |= GIT_DIFF_FILE_BINARY;
 		else
-			delta->old.flags |= GIT_DIFF_FILE_NOT_BINARY;
+			delta->old_file.flags |= GIT_DIFF_FILE_NOT_BINARY;
 	}
 
-	if ((delta->new.flags & BINARY_DIFF_FLAGS) == 0) {
+	if ((delta->new_file.flags & BINARY_DIFF_FLAGS) == 0) {
 		size_t search_len = min(new_data->len, 4000);
 		if (strnlen(new_data->data, search_len) != search_len)
-			delta->new.flags |= GIT_DIFF_FILE_BINARY;
+			delta->new_file.flags |= GIT_DIFF_FILE_BINARY;
 		else
-			delta->new.flags |= GIT_DIFF_FILE_NOT_BINARY;
+			delta->new_file.flags |= GIT_DIFF_FILE_NOT_BINARY;
 	}
 
 	update_delta_is_binary(delta);
@@ -349,37 +349,37 @@ int git_diff_foreach(
 			 delta->status == GIT_DELTA_MODIFIED))
 		{
 			if (diff->old_src == GIT_ITERATOR_WORKDIR)
-				error = get_workdir_content(diff->repo, &delta->old, &old_data);
+				error = get_workdir_content(diff->repo, &delta->old_file, &old_data);
 			else
 				error = get_blob_content(
-					diff->repo, &delta->old.oid, &old_data, &old_blob);
+					diff->repo, &delta->old_file.oid, &old_data, &old_blob);
 			if (error < 0)
 				goto cleanup;
 		}
 
 		if (delta->binary != 1 &&
-			(hunk_cb || line_cb || git_oid_iszero(&delta->new.oid)) &&
+			(hunk_cb || line_cb || git_oid_iszero(&delta->new_file.oid)) &&
 			(delta->status == GIT_DELTA_ADDED ||
 			 delta->status == GIT_DELTA_MODIFIED))
 		{
 			if (diff->new_src == GIT_ITERATOR_WORKDIR)
-				error = get_workdir_content(diff->repo, &delta->new, &new_data);
+				error = get_workdir_content(diff->repo, &delta->new_file, &new_data);
 			else
 				error = get_blob_content(
-					diff->repo, &delta->new.oid, &new_data, &new_blob);
+					diff->repo, &delta->new_file.oid, &new_data, &new_blob);
 			if (error < 0)
 				goto cleanup;
 
-			if ((delta->new.flags | GIT_DIFF_FILE_VALID_OID) == 0) {
+			if ((delta->new_file.flags | GIT_DIFF_FILE_VALID_OID) == 0) {
 				error = git_odb_hash(
-					&delta->new.oid, new_data.data, new_data.len, GIT_OBJ_BLOB);
+					&delta->new_file.oid, new_data.data, new_data.len, GIT_OBJ_BLOB);
 				if (error < 0)
 					goto cleanup;
 
 				/* since we did not have the definitive oid, we may have
 				 * incorrect status and need to skip this item.
 				 */
-				if (git_oid_cmp(&delta->old.oid, &delta->new.oid) == 0) {
+				if (git_oid_cmp(&delta->old_file.oid, &delta->new_file.oid) == 0) {
 					delta->status = GIT_DELTA_UNMODIFIED;
 					if ((diff->opts.flags & GIT_DIFF_INCLUDE_UNMODIFIED) == 0)
 						goto cleanup;
@@ -423,8 +423,8 @@ int git_diff_foreach(
 			&xdiff_params, &xdiff_config, &xdiff_callback);
 
 cleanup:
-		release_content(&delta->old, &old_data, old_blob);
-		release_content(&delta->new, &new_data, new_blob);
+		release_content(&delta->old_file, &old_data, old_blob);
+		release_content(&delta->new_file, &new_data, new_blob);
 
 		if (error < 0)
 			break;
@@ -473,23 +473,23 @@ static int print_compact(void *data, git_diff_delta *delta, float progress)
 	if (!code)
 		return 0;
 
-	old_suffix = pick_suffix(delta->old.mode);
-	new_suffix = pick_suffix(delta->new.mode);
+	old_suffix = pick_suffix(delta->old_file.mode);
+	new_suffix = pick_suffix(delta->new_file.mode);
 
 	git_buf_clear(pi->buf);
 
-	if (delta->old.path != delta->new.path &&
-		strcmp(delta->old.path,delta->new.path) != 0)
+	if (delta->old_file.path != delta->new_file.path &&
+		strcmp(delta->old_file.path,delta->new_file.path) != 0)
 		git_buf_printf(pi->buf, "%c\t%s%c -> %s%c\n", code,
-			delta->old.path, old_suffix, delta->new.path, new_suffix);
-	else if (delta->old.mode != delta->new.mode &&
-		delta->old.mode != 0 && delta->new.mode != 0)
+			delta->old_file.path, old_suffix, delta->new_file.path, new_suffix);
+	else if (delta->old_file.mode != delta->new_file.mode &&
+		delta->old_file.mode != 0 && delta->new_file.mode != 0)
 		git_buf_printf(pi->buf, "%c\t%s%c (%o -> %o)\n", code,
-			delta->old.path, new_suffix, delta->old.mode, delta->new.mode);
+			delta->old_file.path, new_suffix, delta->old_file.mode, delta->new_file.mode);
 	else if (old_suffix != ' ')
-		git_buf_printf(pi->buf, "%c\t%s%c\n", code, delta->old.path, old_suffix);
+		git_buf_printf(pi->buf, "%c\t%s%c\n", code, delta->old_file.path, old_suffix);
 	else
-		git_buf_printf(pi->buf, "%c\t%s\n", code, delta->old.path);
+		git_buf_printf(pi->buf, "%c\t%s\n", code, delta->old_file.path);
 
 	if (git_buf_oom(pi->buf))
 		return -1;
@@ -524,21 +524,21 @@ static int print_oid_range(diff_print_info *pi, git_diff_delta *delta)
 	char start_oid[8], end_oid[8];
 
 	/* TODO: Determine a good actual OID range to print */
-	git_oid_to_string(start_oid, sizeof(start_oid), &delta->old.oid);
-	git_oid_to_string(end_oid, sizeof(end_oid), &delta->new.oid);
+	git_oid_to_string(start_oid, sizeof(start_oid), &delta->old_file.oid);
+	git_oid_to_string(end_oid, sizeof(end_oid), &delta->new_file.oid);
 
 	/* TODO: Match git diff more closely */
-	if (delta->old.mode == delta->new.mode) {
+	if (delta->old_file.mode == delta->new_file.mode) {
 		git_buf_printf(pi->buf, "index %s..%s %o\n",
-			start_oid, end_oid, delta->old.mode);
+			start_oid, end_oid, delta->old_file.mode);
 	} else {
-		if (delta->old.mode == 0) {
-			git_buf_printf(pi->buf, "new file mode %o\n", delta->new.mode);
-		} else if (delta->new.mode == 0) {
-			git_buf_printf(pi->buf, "deleted file mode %o\n", delta->old.mode);
+		if (delta->old_file.mode == 0) {
+			git_buf_printf(pi->buf, "new file mode %o\n", delta->new_file.mode);
+		} else if (delta->new_file.mode == 0) {
+			git_buf_printf(pi->buf, "deleted file mode %o\n", delta->old_file.mode);
 		} else {
-			git_buf_printf(pi->buf, "old mode %o\n", delta->old.mode);
-			git_buf_printf(pi->buf, "new mode %o\n", delta->new.mode);
+			git_buf_printf(pi->buf, "old mode %o\n", delta->old_file.mode);
+			git_buf_printf(pi->buf, "new mode %o\n", delta->new_file.mode);
 		}
 		git_buf_printf(pi->buf, "index %s..%s\n", start_oid, end_oid);
 	}
@@ -552,31 +552,31 @@ static int print_oid_range(diff_print_info *pi, git_diff_delta *delta)
 static int print_patch_file(void *data, git_diff_delta *delta, float progress)
 {
 	diff_print_info *pi = data;
-	const char *oldpfx = pi->diff->opts.src_prefix;
-	const char *oldpath = delta->old.path;
-	const char *newpfx = pi->diff->opts.dst_prefix;
-	const char *newpath = delta->new.path;
+	const char *oldpfx = pi->diff->opts.old_prefix;
+	const char *oldpath = delta->old_file.path;
+	const char *newpfx = pi->diff->opts.new_prefix;
+	const char *newpath = delta->new_file.path;
 	int result;
 
 	GIT_UNUSED(progress);
 
 	if (!oldpfx)
-		oldpfx = DIFF_SRC_PREFIX_DEFAULT;
+		oldpfx = DIFF_OLD_PREFIX_DEFAULT;
 
 	if (!newpfx)
-		newpfx = DIFF_DST_PREFIX_DEFAULT;
+		newpfx = DIFF_NEW_PREFIX_DEFAULT;
 
 	git_buf_clear(pi->buf);
-	git_buf_printf(pi->buf, "diff --git %s%s %s%s\n", oldpfx, delta->old.path, newpfx, delta->new.path);
+	git_buf_printf(pi->buf, "diff --git %s%s %s%s\n", oldpfx, delta->old_file.path, newpfx, delta->new_file.path);
 
 	if (print_oid_range(pi, delta) < 0)
 		return -1;
 
-	if (git_oid_iszero(&delta->old.oid)) {
+	if (git_oid_iszero(&delta->old_file.oid)) {
 		oldpfx = "";
 		oldpath = "/dev/null";
 	}
-	if (git_oid_iszero(&delta->new.oid)) {
+	if (git_oid_iszero(&delta->new_file.oid)) {
 		newpfx = "";
 		newpath = "/dev/null";
 	}
@@ -681,7 +681,7 @@ int git_diff_blobs(
 {
 	diff_output_info info;
 	git_diff_delta delta;
-	mmfile_t old, new;
+	mmfile_t old_data, new_data;
 	xpparam_t xdiff_params;
 	xdemitconf_t xdiff_config;
 	xdemitcb_t xdiff_callback;
@@ -695,31 +695,31 @@ int git_diff_blobs(
 	}
 
 	if (old_blob) {
-		old.ptr  = (char *)git_blob_rawcontent(old_blob);
-		old.size = git_blob_rawsize(old_blob);
+		old_data.ptr  = (char *)git_blob_rawcontent(old_blob);
+		old_data.size = git_blob_rawsize(old_blob);
 	} else {
-		old.ptr  = "";
-		old.size = 0;
+		old_data.ptr  = "";
+		old_data.size = 0;
 	}
 
 	if (new_blob) {
-		new.ptr  = (char *)git_blob_rawcontent(new_blob);
-		new.size = git_blob_rawsize(new_blob);
+		new_data.ptr  = (char *)git_blob_rawcontent(new_blob);
+		new_data.size = git_blob_rawsize(new_blob);
 	} else {
-		new.ptr  = "";
-		new.size = 0;
+		new_data.ptr  = "";
+		new_data.size = 0;
 	}
 
 	/* populate a "fake" delta record */
-	delta.status = old.ptr ?
-		(new.ptr ? GIT_DELTA_MODIFIED : GIT_DELTA_DELETED) :
-		(new.ptr ? GIT_DELTA_ADDED : GIT_DELTA_UNTRACKED);
-	delta.old.mode = 0100644; /* can't know the truth from a blob alone */
-	delta.new.mode = 0100644;
-	git_oid_cpy(&delta.old.oid, git_object_id((const git_object *)old_blob));
-	git_oid_cpy(&delta.new.oid, git_object_id((const git_object *)new_blob));
-	delta.old.path = NULL;
-	delta.new.path = NULL;
+	delta.status = old_data.ptr ?
+		(new_data.ptr ? GIT_DELTA_MODIFIED : GIT_DELTA_DELETED) :
+		(new_data.ptr ? GIT_DELTA_ADDED : GIT_DELTA_UNTRACKED);
+	delta.old_file.mode = 0100644; /* can't know the truth from a blob alone */
+	delta.new_file.mode = 0100644;
+	git_oid_cpy(&delta.old_file.oid, git_object_id((const git_object *)old_blob));
+	git_oid_cpy(&delta.new_file.oid, git_object_id((const git_object *)new_blob));
+	delta.old_file.path = NULL;
+	delta.new_file.path = NULL;
 	delta.similarity = 0;
 
 	info.diff    = NULL;
@@ -733,7 +733,7 @@ int git_diff_blobs(
 	xdiff_callback.outf = diff_output_cb;
 	xdiff_callback.priv = &info;
 
-	xdl_diff(&old, &new, &xdiff_params, &xdiff_config, &xdiff_callback);
+	xdl_diff(&old_data, &new_data, &xdiff_params, &xdiff_config, &xdiff_callback);
 
 	return 0;
 }
diff --git a/src/status.c b/src/status.c
index 62cc37e..356cbeb 100644
--- a/src/status.c
+++ b/src/status.c
@@ -150,7 +150,7 @@ int git_status_foreach_ext(
 	if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) {
 		for (i = 0; !err && i < idx2head->deltas.length; i++) {
 			i2h = GIT_VECTOR_GET(&idx2head->deltas, i);
-			err = cb(i2h->old.path, index_delta2status(i2h->status), cbdata);
+			err = cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata);
 		}
 		git_diff_list_free(idx2head);
 		idx2head = NULL;
@@ -163,16 +163,16 @@ int git_status_foreach_ext(
 		i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL;
 		w2i = wd2idx   ? GIT_VECTOR_GET(&wd2idx->deltas,j)   : NULL;
 
-		cmp = !w2i ? -1 : !i2h ? 1 : strcmp(i2h->old.path, w2i->old.path);
+		cmp = !w2i ? -1 : !i2h ? 1 : strcmp(i2h->old_file.path, w2i->old_file.path);
 
 		if (cmp < 0) {
-			err = cb(i2h->old.path, index_delta2status(i2h->status), cbdata);
+			err = cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata);
 			i++;
 		} else if (cmp > 0) {
-			err = cb(w2i->old.path, workdir_delta2status(w2i->status), cbdata);
+			err = cb(w2i->old_file.path, workdir_delta2status(w2i->status), cbdata);
 			j++;
 		} else {
-			err = cb(i2h->old.path, index_delta2status(i2h->status) |
+			err = cb(i2h->old_file.path, index_delta2status(i2h->status) |
 					 workdir_delta2status(w2i->status), cbdata);
 			i++; j++;
 		}
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index fdb79a4..05e7486 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -59,8 +59,8 @@ check_range:
 	cl_assert_equal_i(0, range->new_lines);
 
 check_delta:
-	cl_assert_equal_s("subdir.txt", delta->old.path);
-	cl_assert_equal_s("subdir.txt", delta->new.path);
+	cl_assert_equal_s("subdir.txt", delta->old_file.path);
+	cl_assert_equal_s("subdir.txt", delta->new_file.path);
 	cl_assert_equal_i(GIT_DELTA_DELETED, delta->status);
 
 	return 0;