MCPcopy Create free account
hub / github.com/git/git / load_current

Function load_current

apply.c:3677–3714  ·  view source on GitHub ↗

* When directly falling back to add/add three-way merge, we read from * the current contents of the new_name. In no cases other than that * this function will be called. */

Source from the content-addressed store, hash-verified

3675 * this function will be called.
3676 */
3677static int load_current(struct apply_state *state,
3678 struct image *image,
3679 struct patch *patch)
3680{
3681 struct strbuf buf = STRBUF_INIT;
3682 int status, pos;
3683 size_t len;
3684 char *img;
3685 struct stat st;
3686 struct cache_entry *ce;
3687 char *name = patch->new_name;
3688 unsigned mode = patch->new_mode;
3689
3690 if (!patch->is_new)
3691 BUG("patch to %s is not a creation", patch->old_name);
3692
3693 pos = index_name_pos(state->repo->index, name, strlen(name));
3694 if (pos < 0)
3695 return error(_("%s: does not exist in index"), name);
3696 ce = state->repo->index->cache[pos];
3697 if (lstat(name, &st)) {
3698 if (errno != ENOENT)
3699 return error_errno("%s", name);
3700 if (checkout_target(state->repo->index, ce, &st))
3701 return -1;
3702 }
3703 if (verify_index_match(state, ce, &st))
3704 return error(_("%s: does not match index"), name);
3705
3706 status = load_patch_target(state, &buf, ce, &st, patch, name, mode);
3707 if (status < 0)
3708 return status;
3709 else if (status)
3710 return -1;
3711 img = strbuf_detach(&buf, &len);
3712 image_prepare(image, img, len, !patch->is_binary);
3713 return 0;
3714}
3715
3716static int try_threeway(struct apply_state *state,
3717 struct image *image,

Callers 1

try_threewayFunction · 0.85

Calls 8

index_name_posFunction · 0.85
errorFunction · 0.85
error_errnoFunction · 0.85
checkout_targetFunction · 0.85
verify_index_matchFunction · 0.85
load_patch_targetFunction · 0.85
strbuf_detachFunction · 0.85
image_prepareFunction · 0.85

Tested by

no test coverage detected