diff options
Diffstat (limited to 'src/diff_output.c')
-rw-r--r-- | src/diff_output.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/diff_output.c b/src/diff_output.c index e79bf30d2..8a7a7a2a1 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -495,7 +495,7 @@ static void diff_patch_init( patch->old_src = patch->diff->old_src; patch->new_src = patch->diff->new_src; } else { - patch->old_src = patch->new_src = GIT_ITERATOR_TREE; + patch->old_src = patch->new_src = GIT_ITERATOR_TYPE_TREE; } } @@ -578,7 +578,7 @@ static int diff_patch_load( */ if ((delta->old_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 && - patch->old_src == GIT_ITERATOR_WORKDIR) { + patch->old_src == GIT_ITERATOR_TYPE_WORKDIR) { if ((error = get_workdir_content( ctxt, delta, &delta->old_file, &patch->old_data)) < 0) goto cleanup; @@ -587,7 +587,7 @@ static int diff_patch_load( } if ((delta->new_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 && - patch->new_src == GIT_ITERATOR_WORKDIR) { + patch->new_src == GIT_ITERATOR_TYPE_WORKDIR) { if ((error = get_workdir_content( ctxt, delta, &delta->new_file, &patch->new_data)) < 0) goto cleanup; @@ -596,7 +596,7 @@ static int diff_patch_load( } if ((delta->old_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 && - patch->old_src != GIT_ITERATOR_WORKDIR) { + patch->old_src != GIT_ITERATOR_TYPE_WORKDIR) { if ((error = get_blob_content( ctxt, delta, &delta->old_file, &patch->old_data, &patch->old_blob)) < 0) @@ -606,7 +606,7 @@ static int diff_patch_load( } if ((delta->new_file.flags & GIT_DIFF_FILE_NO_DATA) == 0 && - patch->new_src != GIT_ITERATOR_WORKDIR) { + patch->new_src != GIT_ITERATOR_TYPE_WORKDIR) { if ((error = get_blob_content( ctxt, delta, &delta->new_file, &patch->new_data, &patch->new_blob)) < 0) @@ -1666,32 +1666,28 @@ int git_diff__paired_foreach( int cmp; git_diff_delta *i2h, *w2i; size_t i, j, i_max, j_max; - bool icase = false; + int (*strcomp)(const char *, const char *); i_max = idx2head ? idx2head->deltas.length : 0; j_max = wd2idx ? wd2idx->deltas.length : 0; - if (idx2head && wd2idx && - (0 != (idx2head->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) || - 0 != (wd2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE))) - { - /* Then use the ignore-case sorter... */ - icase = true; - - /* and assert that both are ignore-case sorted. If this function - * ever needs to support merge joining result sets that are not sorted - * by the same function, then it will need to be extended to do a spool - * and sort on one of the results before merge joining */ - assert(0 != (idx2head->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) && - 0 != (wd2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE)); - } + /* Get appropriate strcmp function */ + strcomp = idx2head ? idx2head->strcomp : wd2idx ? wd2idx->strcomp : NULL; + + /* Assert both iterators use matching ignore-case. If this function ever + * supports merging diffs that are not sorted by the same function, then + * it will need to spool and sort on one of the results before merging + */ + if (idx2head && wd2idx) { + assert(idx2head->strcomp == wd2idx->strcomp); + } for (i = 0, j = 0; i < i_max || j < j_max; ) { i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL; w2i = wd2idx ? GIT_VECTOR_GET(&wd2idx->deltas,j) : NULL; cmp = !w2i ? -1 : !i2h ? 1 : - STRCMP_CASESELECT(icase, i2h->old_file.path, w2i->old_file.path); + strcomp(i2h->old_file.path, w2i->old_file.path); if (cmp < 0) { if (cb(i2h, NULL, payload)) |