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

Function read_old_data

apply.c:2401–2427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2399}
2400
2401static int read_old_data(struct stat *st, struct patch *patch,
2402 const char *path, struct strbuf *buf)
2403{
2404 int conv_flags = patch->crlf_in_old ?
2405 CONV_EOL_KEEP_CRLF : CONV_EOL_RENORMALIZE;
2406 switch (st->st_mode & S_IFMT) {
2407 case S_IFLNK:
2408 if (strbuf_readlink(buf, path, st->st_size) < 0)
2409 return error(_("unable to read symlink %s"), path);
2410 return 0;
2411 case S_IFREG:
2412 if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
2413 return error(_("unable to open or read %s"), path);
2414 /*
2415 * "git apply" without "--index/--cached" should never look
2416 * at the index; the target file may not have been added to
2417 * the index yet, and we may not even be in any Git repository.
2418 * Pass NULL to convert_to_git() to stress this; the function
2419 * should never look at the index when explicit crlf option
2420 * is given.
2421 */
2422 convert_to_git(NULL, path, buf->buf, buf->len, buf, conv_flags);
2423 return 0;
2424 default:
2425 return -1;
2426 }
2427}
2428
2429/*
2430 * Update the preimage, and the common lines in postimage,

Callers 1

load_patch_targetFunction · 0.85

Calls 4

strbuf_readlinkFunction · 0.85
errorFunction · 0.85
strbuf_read_fileFunction · 0.85
convert_to_gitFunction · 0.85

Tested by

no test coverage detected