331
return strbuf_getwholeline(sb, io->input, '\n');
332
}
333
334
-/*
335
- * Require the exact number of conflict marker letters, no more, no
336
- * less, followed by SP or any whitespace
337
- * (including LF).
338
- */
339
-static int is_cmarker(char *buf, int marker_char, int marker_size)
340
-{
341
- int want_sp;
342
-
343
- /*
344
- * The beginning of our version and the end of their version
345
- * always are labeled like "<<<<< ours" or ">>>>> theirs",
346
- * hence we set want_sp for them. Note that the version from
347
- * the common ancestor in diff3-style output is not always
348
- * labelled (e.g. "||||| common" is often seen but "|||||"
349
- * alone is also valid), so we do not set want_sp.
350
- */
351
- want_sp = (marker_char == '<') || (marker_char == '>');
352
-
353
- while (marker_size--)
354
- if (*buf++ != marker_char)
355
- return 0;
356
- if (want_sp && *buf != ' ')
357
- return 0;
358
- return isspace(*buf);
359
-}
360
-
334
static void rerere_strbuf_putconflict(struct strbuf *buf, int ch, size_t size)
335
{
336
strbuf_addchars(buf, ch, size);
348
int has_conflicts = -1;
349
350
while (!io->getline(&buf, io)) {
378
- if (is_cmarker(buf.buf, '<', marker_size)) {
351
+ int marker = is_conflict_marker_line(buf.buf, buf.len, marker_size);
352
+ if (marker == '<') {
353
if (handle_conflict(&conflict, io, marker_size, NULL) < 0)
354
break;
355
if (hunk == RR_SIDE_1)
357
else
358
strbuf_addbuf(&two, &conflict);
359
strbuf_release(&conflict);
386
- } else if (is_cmarker(buf.buf, '|', marker_size)) {
360
+ } else if (marker == '|') {
361
if (hunk != RR_SIDE_1)
362
break;
363
hunk = RR_ORIGINAL;
390
- } else if (is_cmarker(buf.buf, '=', marker_size)) {
364
+ } else if (marker == '=') {
365
if (hunk != RR_SIDE_1 && hunk != RR_ORIGINAL)
366
break;
367
hunk = RR_SIDE_2;
394
- } else if (is_cmarker(buf.buf, '>', marker_size)) {
368
+ } else if (marker == '>') {
369
if (hunk != RR_SIDE_2)
370
break;
371
if (strbuf_cmp(&one, &two) > 0)
416
git_hash_init(&ctx, the_hash_algo);
417
418
while (!io->getline(&buf, io)) {
445
- if (is_cmarker(buf.buf, '<', marker_size)) {
419
+ if (is_conflict_marker_line(buf.buf, buf.len, marker_size) == '<') {
420
has_conflicts = handle_conflict(&out, io, marker_size,
421
hash ? &ctx : NULL);
422
if (has_conflicts < 0)