MCPcopy Index your code
hub / github.com/git/git / apply_data

Function apply_data

apply.c:3803–3830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3801}
3802
3803static int apply_data(struct apply_state *state, struct patch *patch,
3804 struct stat *st, const struct cache_entry *ce)
3805{
3806 struct image image = IMAGE_INIT;
3807
3808 if (load_preimage(state, &image, patch, st, ce) < 0)
3809 return -1;
3810
3811 if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {
3812 if (state->apply_verbosity > verbosity_silent &&
3813 state->threeway && !patch->direct_to_threeway)
3814 fprintf(stderr, _("Falling back to direct application...\n"));
3815
3816 /* Note: with --reject, apply_fragments() returns 0 */
3817 if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0) {
3818 image_clear(&image);
3819 return -1;
3820 }
3821 }
3822 patch->result = strbuf_detach(&image.buf, &patch->resultsize);
3823 add_to_fn_table(state, patch);
3824 free(image.line);
3825
3826 if (0 < patch->is_delete && patch->resultsize)
3827 return error(_("removal patch leaves file contents"));
3828
3829 return 0;
3830}
3831
3832/*
3833 * If "patch" that we are looking at modifies or deletes what we have,

Callers 1

check_patchFunction · 0.85

Calls 7

load_preimageFunction · 0.85
try_threewayFunction · 0.85
apply_fragmentsFunction · 0.85
image_clearFunction · 0.85
strbuf_detachFunction · 0.85
add_to_fn_tableFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected