line |
true |
false |
branch |
66
|
0 |
0 |
if (git_pool_init(&out->pool, sizeof(git_diff_line)) < 0) |
69
|
0 |
0 |
if (!in_len) |
72
|
0 |
0 |
for (start = in; start < in + in_len; start = end) { |
75
|
0 |
0 |
if (end == NULL) |
78
|
0 |
0 |
else if (end < in + in_len) |
82
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(line); |
84
|
0 |
0 |
if (git_vector_insert(&out->lines, line) < 0) |
95
|
0 |
0 |
if (image == NULL) |
111
|
0 |
0 |
if (git_vector_length(&preimage->lines) + linenum > |
118
|
0 |
0 |
for (i = 0; i < git_vector_length(&preimage->lines); i++) { |
122
|
0 |
0 |
if (preimage_line->content_len != image_line->content_len || |
|
0 |
0 |
if (preimage_line->content_len != image_line->content_len || |
141
|
0 |
0 |
if (linenum > max) |
161
|
0 |
0 |
if (postlen > prelen) |
164
|
0 |
0 |
else if (prelen > postlen) |
168
|
0 |
0 |
if (error) { |
173
|
0 |
0 |
for (i = 0; i < git_vector_length(&postimage->lines); i++) { |
197
|
0 |
0 |
if (ctx->opts.hunk_cb) { |
200
|
0 |
0 |
if (error) { |
201
|
0 |
0 |
if (error > 0) { |
211
|
0 |
0 |
for (i = 0; i < hunk->line_count; i++) { |
213
|
0 |
0 |
git_diff_line *line = git_array_get(patch->lines, linenum), *prev; |
215
|
0 |
0 |
if (!line) { |
224
|
0 |
0 |
prev = i ? git_array_get(patch->lines, linenum - 1) : NULL; |
|
0 |
0 |
prev = i ? git_array_get(patch->lines, linenum - 1) : NULL; |
225
|
0 |
0 |
if (prev && prev->content[prev->content_len - 1] == '\n') |
|
0 |
0 |
if (prev && prev->content[prev->content_len - 1] == '\n') |
229
|
0 |
0 |
if ((error = git_vector_insert(&preimage.lines, line)) < 0 || |
|
0 |
0 |
if ((error = git_vector_insert(&preimage.lines, line)) < 0 || |
234
|
0 |
0 |
if ((error = git_vector_insert(&preimage.lines, line)) < 0) |
238
|
0 |
0 |
if ((error = git_vector_insert(&postimage.lines, line)) < 0) |
244
|
0 |
0 |
if (hunk->hunk.new_start) { |
253
|
0 |
0 |
if (!find_hunk_linenum(&line_num, image, &preimage, line_num)) { |
281
|
0 |
0 |
if ((error = patch_image_init_fromstr(&image, source, source_len)) < 0) |
284
|
0 |
0 |
git_array_foreach(patch->hunks, i, hunk) { |
|
0 |
0 |
git_array_foreach(patch->hunks, i, hunk) { |
285
|
0 |
0 |
if ((error = apply_hunk(&image, patch, hunk, ctx)) < 0) |
289
|
0 |
0 |
git_vector_foreach(&image.lines, i, line) |
308
|
0 |
0 |
if (binary_file->datalen == 0) |
314
|
0 |
0 |
if (!error && inflated.size != binary_file->inflatedlen) { |
|
0 |
0 |
if (!error && inflated.size != binary_file->inflatedlen) { |
319
|
0 |
0 |
if (error < 0) |
322
|
0 |
0 |
if (binary_file->type == GIT_DIFF_BINARY_DELTA) { |
333
|
0 |
0 |
else if (binary_file->type == GIT_DIFF_BINARY_LITERAL) { |
355
|
0 |
0 |
if (!patch->binary.contains_data) { |
360
|
0 |
0 |
if (!patch->binary.old_file.datalen && !patch->binary.new_file.datalen) |
|
0 |
0 |
if (!patch->binary.old_file.datalen && !patch->binary.new_file.datalen) |
364
|
0 |
0 |
if ((error = apply_binary_delta(out, source, source_len, |
369
|
0 |
0 |
if ((error = apply_binary_delta(&reverse, out->ptr, out->size, |
374
|
0 |
0 |
if (source_len != reverse.size || |
|
0 |
0 |
if (source_len != reverse.size || |
375
|
0 |
0 |
(source_len && memcmp(source, reverse.ptr, source_len) != 0)) { |
381
|
0 |
0 |
if (error < 0) |
402
|
0 |
0 |
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); |
|
0 |
0 |
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); |
|
0 |
0 |
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); |
|
0 |
0 |
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); |
|
0 |
0 |
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); |
|
0 |
0 |
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); |
404
|
0 |
0 |
if (given_opts) |
410
|
0 |
0 |
if (patch->delta->status != GIT_DELTA_DELETED) { |
414
|
0 |
0 |
mode = newfile->mode ? |
418
|
0 |
0 |
if (patch->delta->flags & GIT_DIFF_FLAG_BINARY) |
420
|
0 |
0 |
else if (patch->hunks.size) |
425
|
0 |
0 |
if (error) |
438
|
0 |
0 |
if (error < 0) |
466
|
0 |
0 |
if ((error = git_patch_from_diff(&patch, diff, i)) < 0) |
471
|
0 |
0 |
if (opts->delta_cb) { |
474
|
0 |
0 |
if (error) { |
475
|
0 |
0 |
if (error > 0) |
486
|
0 |
0 |
if (delta->status != GIT_DELTA_RENAMED && |
|
0 |
0 |
if (delta->status != GIT_DELTA_RENAMED && |
488
|
0 |
0 |
if (git_strmap_exists(removed_paths, delta->old_file.path)) { |
501
|
0 |
0 |
if (delta->status != GIT_DELTA_RENAMED) { |
502
|
0 |
0 |
if ((error = git_reader_read(&pre_contents, &pre_id, &pre_filemode, |
505
|
0 |
0 |
} else if (error == GIT_ENOTFOUND) { |
513
|
0 |
0 |
if (!skip_preimage && delta->status != GIT_DELTA_ADDED) { |
|
0 |
0 |
if (!skip_preimage && delta->status != GIT_DELTA_ADDED) { |
518
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
522
|
0 |
0 |
if (error == GIT_READER_MISMATCH) |
525
|
0 |
0 |
if (error < 0) |
543
|
0 |
0 |
if (preimage) { |
546
|
0 |
0 |
pre_entry.mode = delta->old_file.mode ? delta->old_file.mode : pre_filemode; |
549
|
0 |
0 |
if ((error = git_index_add(preimage, &pre_entry)) < 0) |
554
|
0 |
0 |
if (delta->status != GIT_DELTA_DELETED) { |
555
|
0 |
0 |
if ((error = git_apply__patch(&post_contents, &filename, &mode, |
556
|
0 |
0 |
pre_contents.ptr, pre_contents.size, patch, opts)) < 0 || |
566
|
0 |
0 |
if ((error = git_index_add(postimage, &post_entry)) < 0) |
570
|
0 |
0 |
if (delta->status == GIT_DELTA_RENAMED || |
|
0 |
0 |
if (delta->status == GIT_DELTA_RENAMED || |
574
|
0 |
0 |
if (delta->status == GIT_DELTA_RENAMED || |
|
0 |
0 |
if (delta->status == GIT_DELTA_RENAMED || |
600
|
0 |
0 |
if (git_strmap_new(&removed_paths) < 0) |
603
|
0 |
0 |
for (i = 0; i < git_diff_num_deltas(diff); i++) { |
604
|
0 |
0 |
if ((error = apply_one(repo, pre_reader, preimage, post_reader, postimage, diff, removed_paths, i, opts)) < 0) |
627
|
0 |
0 |
assert(out && repo && preimage && diff); |
|
0 |
0 |
assert(out && repo && preimage && diff); |
|
0 |
0 |
assert(out && repo && preimage && diff); |
|
0 |
0 |
assert(out && repo && preimage && diff); |
631
|
0 |
0 |
if (given_opts) |
634
|
0 |
0 |
if ((error = git_reader_for_tree(&pre_reader, preimage)) < 0) |
641
|
0 |
0 |
if ((error = git_index_new(&postimage)) < 0 || |
|
0 |
0 |
if ((error = git_index_new(&postimage)) < 0 || |
642
|
0 |
0 |
(error = git_index_read_tree(postimage, preimage)) < 0 || |
651
|
0 |
0 |
for (i = 0; i < git_diff_num_deltas(diff); i++) { |
654
|
0 |
0 |
if (delta->status == GIT_DELTA_DELETED || |
|
0 |
0 |
if (delta->status == GIT_DELTA_DELETED || |
656
|
0 |
0 |
if ((error = git_index_remove(postimage, |
662
|
0 |
0 |
if ((error = apply_deltas(repo, pre_reader, NULL, post_reader, postimage, diff, &opts)) < 0) |
668
|
0 |
0 |
if (error < 0) |
697
|
0 |
0 |
if ((error = git_vector_init(&paths, git_diff_num_deltas(diff), NULL)) < 0) |
700
|
0 |
0 |
for (i = 0; i < git_diff_num_deltas(diff); i++) { |
703
|
0 |
0 |
if ((error = git_vector_insert(&paths, (void *)delta->old_file.path)) < 0) |
706
|
0 |
0 |
if (strcmp(delta->old_file.path, delta->new_file.path) && |
|
0 |
0 |
if (strcmp(delta->old_file.path, delta->new_file.path) && |
715
|
0 |
0 |
if (location == GIT_APPLY_LOCATION_WORKDIR) |
746
|
0 |
0 |
if ((error = git_repository_index(&index, repo)) < 0) |
750
|
0 |
0 |
for (i = 0; i < git_diff_num_deltas(diff); i++) { |
753
|
0 |
0 |
if (delta->status == GIT_DELTA_DELETED || |
|
0 |
0 |
if (delta->status == GIT_DELTA_DELETED || |
755
|
0 |
0 |
if ((error = git_index_remove(index, delta->old_file.path, 0)) < 0) |
761
|
0 |
0 |
for (i = 0; i < git_index_entrycount(postimage); i++) { |
764
|
0 |
0 |
if ((error = git_index_add(index, entry)) < 0) |
775
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE( |
808
|
0 |
0 |
assert(repo && diff); |
|
0 |
0 |
assert(repo && diff); |
810
|
0 |
0 |
GIT_ERROR_CHECK_VERSION( |
813
|
0 |
0 |
if (given_opts) |
835
|
0 |
0 |
if (error < 0) |
845
|
0 |
0 |
if ((error = git_index_new(&preimage)) < 0 || |
|
0 |
0 |
if ((error = git_index_new(&preimage)) < 0 || |
846
|
0 |
0 |
(error = git_index_new(&postimage)) < 0 || |
850
|
0 |
0 |
if (!(opts.flags & GIT_APPLY_CHECK)) |
851
|
0 |
0 |
if ((error = git_repository_index(&index, repo)) < 0 || |
|
0 |
0 |
if ((error = git_repository_index(&index, repo)) < 0 || |
855
|
0 |
0 |
if ((error = apply_deltas(repo, pre_reader, preimage, post_reader, postimage, diff, &opts)) < 0) |
858
|
0 |
0 |
if ((opts.flags & GIT_APPLY_CHECK)) |
875
|
0 |
0 |
if (error < 0) |