shithub: riscv

Download patch

ref: 4738d90516c8ae83aab844a76cd4b2468caad2b4
parent: c59eb6d117c6dc99bc6e4330d3a9a3453888dee7
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 20 22:07:25 EST 2024

diff(1): docuemnt merge3

--- a/sys/man/1/diff
+++ b/sys/man/1/diff
@@ -5,8 +5,11 @@
 .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 @@
 .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
--- a/sys/src/cmd/diff/merge3.c
+++ b/sys/src/cmd/diff/merge3.c
@@ -155,11 +155,11 @@
 				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], "");