From 4738d90516c8ae83aab844a76cd4b2468caad2b4 Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Sun, 21 Jan 2024 03:07:25 +0000 Subject: [PATCH] diff(1): docuemnt merge3 --- sys/man/1/diff | 43 ++++++++++++++++++++++++++++++++++++++- sys/src/cmd/diff/merge3.c | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/sys/man/1/diff b/sys/man/1/diff index 771ccc83f..e0f89c980 100644 --- a/sys/man/1/diff +++ b/sys/man/1/diff @@ -5,8 +5,11 @@ diff \- differential file comparator .B diff [ .B -abcefmnruw -] +] .I file1 ... file2 +.PP +.B merge3 +.I left common right .SH DESCRIPTION .I Diff tells what lines must be changed in two files to bring them @@ -165,6 +168,44 @@ Except in rare circumstances, .I diff finds a smallest sufficient set of file differences. +.PP +Merge3 merges the contents of +.I left +and +.I right +using +.I common +as a common reference between the two files. +Changes between +.IR left , +.I right +and +.I common +are computed. +Any change which does not conflict is output directly. +When a change does conflict, that is to say, +affects the same lines of the output file, +then the change is output with conflict markers. +The conflict markers look like this: +.IP +.EX +leading content +<<<<<<<<<< leftfile +this is an edit made +to the left file +========== original +this is the initial content +========== rightfile +here is something that was +written into the right file +>>>>>>>>>> +trailing content +.EE +.PP +If no conflicts are detected, +.I merge3 +exits with a nil status, +otherwise it exits with a status of "conflicted". .SH FILES .B /tmp/diff[12] .SH SOURCE diff --git a/sys/src/cmd/diff/merge3.c b/sys/src/cmd/diff/merge3.c index 2dd6755e3..26397f3fe 100644 --- a/sys/src/cmd/diff/merge3.c +++ b/sys/src/cmd/diff/merge3.c @@ -155,11 +155,11 @@ merge(Diff *l, Diff *r) Bprint(&stdout, "========== %s\n", r->file2); fetch(r, r->ixnew, rc->newx, rc->newy, r->input[1], ""); Bprint(&stdout, ">>>>>>>>>>\n"); + status = "conflict"; } ln = y+1; il++; ir++; - status = "conflict"; }else if(rc == nil || (lc != nil && lx < rx)){ fetch(l, l->ixold, ln, lc->oldx-1, l->input[0], ""); fetch(l, l->ixnew, lc->newx, lc->newy, l->input[1], "");