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

Function handle_path

rerere.c:436–462  ·  view source on GitHub ↗

* Read contents a file with conflicts, normalize the conflicts * by (1) discarding the common ancestor version in diff3-style, * (2) reordering our side and their side so that whichever sorts * alphabetically earlier comes before the other one, while * computing the "conflict ID", which is just an SHA-1 hash of * one side of the conflict, NUL, the other side of the conflict, * and NUL concat

Source from the content-addressed store, hash-verified

434 * hunks and -1 if an error occurred.
435 */
436static int handle_path(unsigned char *hash, struct rerere_io *io, int marker_size)
437{
438 struct git_hash_ctx ctx;
439 struct strbuf buf = STRBUF_INIT, out = STRBUF_INIT;
440 int has_conflicts = 0;
441 if (hash)
442 the_hash_algo->init_fn(&ctx);
443
444 while (!io->getline(&buf, io)) {
445 if (is_cmarker(buf.buf, '<', marker_size)) {
446 has_conflicts = handle_conflict(&out, io, marker_size,
447 hash ? &ctx : NULL);
448 if (has_conflicts < 0)
449 break;
450 rerere_io_putmem(out.buf, out.len, io);
451 strbuf_reset(&out);
452 } else
453 rerere_io_putstr(buf.buf, io);
454 }
455 strbuf_release(&buf);
456 strbuf_release(&out);
457
458 if (hash)
459 git_hash_final(hash, &ctx);
460
461 return has_conflicts;
462}
463
464/*
465 * Scan the path for conflicts, do the "handle_path()" thing above, and

Callers 2

handle_fileFunction · 0.85
handle_cacheFunction · 0.85

Calls 6

is_cmarkerFunction · 0.85
handle_conflictFunction · 0.85
rerere_io_putmemFunction · 0.85
rerere_io_putstrFunction · 0.85
strbuf_releaseFunction · 0.85
git_hash_finalFunction · 0.85

Tested by

no test coverage detected