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

Function image_prepare

apply.c:330–352  ·  view source on GitHub ↗

* "buf" has the file contents to be patched (read from various sources). * attach it to "image" and add line-based index to it. * "image" now owns the "buf". */

Source from the content-addressed store, hash-verified

328 * "image" now owns the "buf".
329 */
330static void image_prepare(struct image *image, char *buf, size_t len,
331 int prepare_linetable)
332{
333 const char *cp, *ep;
334
335 image_clear(image);
336 strbuf_attach(&image->buf, buf, len, len + 1);
337
338 if (!prepare_linetable)
339 return;
340
341 ep = image->buf.buf + image->buf.len;
342 cp = image->buf.buf;
343 while (cp < ep) {
344 const char *next;
345 for (next = cp; next < ep && *next != '\n'; next++)
346 ;
347 if (next < ep)
348 next++;
349 image_add_line(image, cp, next - cp, 0);
350 cp = next;
351 }
352}
353
354static void image_remove_first_line(struct image *img)
355{

Callers 4

update_pre_post_imagesFunction · 0.85
load_preimageFunction · 0.85
load_currentFunction · 0.85
try_threewayFunction · 0.85

Calls 3

image_clearFunction · 0.85
strbuf_attachFunction · 0.85
image_add_lineFunction · 0.85

Tested by

no test coverage detected