diff options
Diffstat (limited to 'gnu/usr.bin/rcs/merge')
-rw-r--r-- | gnu/usr.bin/rcs/merge/Makefile | 8 | ||||
-rw-r--r-- | gnu/usr.bin/rcs/merge/merge.1 | 137 | ||||
-rw-r--r-- | gnu/usr.bin/rcs/merge/merge.c | 113 |
3 files changed, 258 insertions, 0 deletions
diff --git a/gnu/usr.bin/rcs/merge/Makefile b/gnu/usr.bin/rcs/merge/Makefile new file mode 100644 index 0000000000000..9022bc4bf6e5b --- /dev/null +++ b/gnu/usr.bin/rcs/merge/Makefile @@ -0,0 +1,8 @@ +PROG= merge +SRCS= merge.c +CFLAGS+= -I${.CURDIR}/../lib +LDADD= ${LIBRCS} +DPADD= ${LIBRCS} + +.include "../../Makefile.inc" +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/rcs/merge/merge.1 b/gnu/usr.bin/rcs/merge/merge.1 new file mode 100644 index 0000000000000..a4fd35b7986aa --- /dev/null +++ b/gnu/usr.bin/rcs/merge/merge.1 @@ -0,0 +1,137 @@ +.de Id +.ds Rv \\$3 +.ds Dt \\$4 +.. +.Id $FreeBSD$ +.ds r \&\s-1RCS\s0 +.TH MERGE 1 \*(Dt GNU +.SH NAME +merge \- three-way file merge +.SH SYNOPSIS +.B merge +[ +.I "options" +] +.I "file1 file2 file3" +.SH DESCRIPTION +.B merge +incorporates all changes that lead from +.I file2 +to +.I file3 +into +.IR file1 . +The result ordinarily goes into +.IR file1 . +.B merge +is useful for combining separate changes to an original. Suppose +.I file2 +is the original, and both +.I file1 +and +.I file3 +are modifications of +.IR file2 . +Then +.B merge +combines both changes. +.PP +A conflict occurs if both +.I file1 +and +.I file3 +have changes in a common segment of lines. +If a conflict is found, +.B merge +normally outputs a warning and brackets the conflict with +.B <<<<<<< +and +.B >>>>>>> +lines. +A typical conflict will look like this: +.LP +.RS +.nf +.BI <<<<<<< " file A" +.I "lines in file A" +.B "=======" +.I "lines in file B" +.BI >>>>>>> " file B" +.RE +.fi +.LP +If there are conflicts, the user should edit the result and delete one of the +alternatives. +.SH OPTIONS +.TP +.B \-A +Output conflicts using the +.B \-A +style of +.BR diff3 (1), +if supported by +.BR diff3 . +This merges all changes leading from +.I file2 +to +.I file3 +into +.IR file1 , +and generates the most verbose output. +.TP +\f3\-E\fP, \f3\-e\fP +These options specify conflict styles that generate less information +than +.BR \-A . +See +.BR diff3 (1) +for details. +The default is +.BR \-E . +With +.BR \-e , +.B merge +does not warn about conflicts. +.TP +.BI \-L " label" +This option may be given up to three times, and specifies labels +to be used in place of the corresponding file names in conflict reports. +That is, +.B "merge\ \-L\ x\ \-L\ y\ \-L\ z\ a\ b\ c" +generates output that looks like it came from files +.BR x , +.B y +and +.B z +instead of from files +.BR a , +.B b +and +.BR c . +.TP +.BI \-p +Send results to standard output instead of overwriting +.IR file1 . +.TP +.BI \-q +Quiet; do not warn about conflicts. +.TP +.BI \-V +Print \*r's version number. +.SH DIAGNOSTICS +Exit status is 0 for no conflicts, 1 for some conflicts, 2 for trouble. +.SH IDENTIFICATION +Author: Walter F. Tichy. +.br +Manual Page Revision: \*(Rv; Release Date: \*(Dt. +.br +Copyright \(co 1982, 1988, 1989 Walter F. Tichy. +.br +Copyright \(co 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert. +.SH SEE ALSO +diff3(1), diff(1), rcsmerge(1), co(1). +.SH BUGS +It normally does not make sense to merge binary files as if they were text, but +.B merge +tries to do it anyway. +.br diff --git a/gnu/usr.bin/rcs/merge/merge.c b/gnu/usr.bin/rcs/merge/merge.c new file mode 100644 index 0000000000000..aa127bf1c8ec8 --- /dev/null +++ b/gnu/usr.bin/rcs/merge/merge.c @@ -0,0 +1,113 @@ +/* merge - three-way file merge */ + +/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert + Distributed under license by the Free Software Foundation, Inc. + +This file is part of RCS. + +RCS is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +RCS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with RCS; see the file COPYING. +If not, write to the Free Software Foundation, +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Report problems and direct all questions to: + + rcs-bugs@cs.purdue.edu + +*/ + +#include "rcsbase.h" + +static void badoption P((char const*)); + +static char const usage[] = + "\nmerge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3"; + + static void +badoption(a) + char const *a; +{ + error("unknown option: %s%s", a, usage); +} + + +mainProg(mergeId, "merge", "$FreeBSD$") +{ + register char const *a; + char const *arg[3], *label[3], *edarg = 0; + int labels, tostdout; + + labels = 0; + tostdout = false; + + for (; (a = *++argv) && *a++ == '-'; --argc) { + switch (*a++) { + case 'A': case 'E': case 'e': + if (edarg && edarg[1] != (*argv)[1]) + error("%s and %s are incompatible", + edarg, *argv + ); + edarg = *argv; + break; + + case 'p': tostdout = true; break; + case 'q': quietflag = true; break; + + case 'L': + if (3 <= labels) + faterror("too many -L options"); + if (!(label[labels++] = *++argv)) + faterror("-L needs following argument"); + --argc; + break; + + case 'V': + printf("RCS version %s\n", RCS_version_string); + exitmain(0); + + default: + badoption(a - 2); + continue; + } + if (*a) + badoption(a - 2); + } + + if (argc != 4) + faterror("%s arguments%s", + argc<4 ? "not enough" : "too many", usage + ); + + /* This copy keeps us `const'-clean. */ + arg[0] = argv[0]; + arg[1] = argv[1]; + arg[2] = argv[2]; + + for (; labels < 3; labels++) + label[labels] = arg[labels]; + + if (nerror) + exiterr(); + exitmain(merge(tostdout, edarg, label, arg)); +} + + +#if RCS_lint +# define exiterr mergeExit +#endif + void +exiterr() +{ + tempunlink(); + _exit(DIFF_TROUBLE); +} |