summaryrefslogtreecommitdiff
path: root/usr.bin/diff3/diff3.c
AgeCommit message (Collapse)Author
2024-09-26diff3: Remove debugging remnant.Dag-Erling Smørgrav
Fixes: cf73401c4f7a MFC after: 3 weeks
2024-09-25diff3: Fix merge mode.Dag-Erling Smørgrav
This is mostly thj@'s work, with some tweaks and cleanup by me. There are still some cases where our output differs from GNU diff3, but it's much better than before and I'd rather commit what I have now than let it continue to languish in a metaphorical drawer. MFC after 3 weeks Sponsored by: Klara, Inc. Reviewed by: thj Differential Revision: https://reviews.freebsd.org/D46762
2023-11-26usr.bin: Automated cleanup of cdefs and other formattingWarner Losh
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
2023-11-26usr.bin: Remove ancient SCCS tags.Warner Losh
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
2023-09-06diff3: make the diff3 -E -m and diff3 -m behaviour match gnu diff3Baptiste Daroussin
In gnu diff3 3 way merging files where the new file and the target are already the same will die and show what has failed to be merged except if -E is passed in argument, in this case it will finish the merge. This difference in behaviour was breaking one of the etcupdate testcase with bsd diff3 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D41730
2023-08-16Remove $FreeBSD$: one-line .c patternWarner Losh
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2022-08-02diff3: Use ranges for new and old diffedits in ed scriptsTom Jones
This should make the output logic easier to read. No functional change intended. Sponsored by: Klara, Inc.
2022-08-02diff3: Use ranges for the old and new diffedits in A scriptsTom Jones
This makes the output logic easier to read. No functional change intended. Sponsored by: Klara, Inc.
2022-08-02diff3: Simplify startmark calculation in AscriptTom Jones
Remove redundant calculation for startmark. Sponsored by: Klara, Inc.
2022-08-01diff3: Use variables for old and new in A scriptsTom Jones
This makes the code easier to follow, no functional changes intended Sponsored by: Klara, Inc.
2022-08-01diff3: Replace literal marker with variableTom Jones
Sponsored by: Klara, Inc.
2022-08-01diff3: Fix indentationTom Jones
Sponsored by: Klara, Inc.
2022-07-05diff3: make the eflag logic easier to followTom Jones
Discussed with: dim Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35324
2022-05-25diff3: Add help and version optionsTom Jones
Add help and version flags. Exit values in these paths are set to match the behaviour of gnu diff3.
2022-05-25diff3: Copy line into debug informationTom Jones
Sponsored by: Klara Inc.
2022-05-25diff3: Don't perform a bitwise OR when comparing diffsTom Jones
This fixes the build now that it uses -Wbitwise-instead-of-logical Sponsored by: Klara Inc.
2022-04-19diff3: Add support for -mTom Jones
diff3 in -m mode generates a complete file with changes bracketed with conflict markers. This adds support for diff3 to generate version control style three way merge output. The output format was inferred from looking at the gnu diff3 output on a selection of test files as a specification of what diff3 -m should output is not available. It is likely there are cases where the -m output differs from other tools and I am happy to update diff3 to address these. Discussed with: pstef, kevans Sponsored by: Klara, Inc.
2022-04-19diff3: Add support for -ATom Jones
Diff3 in -A mode generates an ed script to show how the 3 files and brackets changes that conflict. The ed script generated should when applied leave familiar merge conflict markers in a patched file. Diff3 output is not documented, this feature has been arrived at by comparing bsd diff3 output to gnu diff3 output until they were made to agree. There are likely to still be differences between these formats. The gnu diff3 guide is actually quite good at explaining how diff3 output should appear, but it doesn't cover every form of output from diff3. https://www.gnu.org/software/diffutils/manual/diffutils.html#Comparing-Three-Files Discussed with: pstef, kevans Sponsored by: Klara, Inc.
2022-04-19diff3: seperate old and new markers from file markersTom Jones
With -A and -m output the conflict markers are not tied to the file name. Seperate out these markers. Sponsored by: Klara, Inc.
2022-04-19diff3: Clean up printing of ranges for edscript outputTom Jones
Replace the edscript code that tracked and printed lines using byte offsets with code that can work from line offsets. This tidies up the reduces duplication in the edscript output code. It also fixes the usage of the de struct so that it only tracks diffs as line offsets rather than the usage changing from line offsets to byte offsets during the lifetime of diff3. Large files with large numbers of ranges will probably suffer in performance here, but as we don't use diff3 yet this isn't a regression. Include a warning for future hackers so they have a place to start hacking from. Reviewed by: pstef Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D34941
2022-04-15diff3: allow diff3 ed scripts to generate deletionsTom Jones
diff3 with the -e (ed script flag) can generate line deletions, add support for deletions and add a test case to exercise this behaviour. This functionality was unearthed through comparison of bsd diff3 and gnu diff3 output. Reviewed by: pstef Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D34912
2021-08-23diff3: implement --strip-trailing-crPiotr Pawel Stefaniak
Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D31626
2021-08-23diff3: improve stylePiotr Pawel Stefaniak
2021-08-23diff3: sync with upstreamPiotr Pawel Stefaniak
* replace realloc calls with reallocarray calls * fix merging of files that lack newlines Obtained from: OpenBSD
2019-12-17Replace homemade getline(3) by actual getline(3)Baptiste Daroussin
Notes: svn path=/head/; revision=355854
2019-12-17Use strtoimax.Baptiste Daroussin
Use existing strtoimax instead of reinventing it Notes: svn path=/head/; revision=355847
2018-11-04capsicum: use a new capsicum helpers in toolsMariusz Zaborski
Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
2018-06-19Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski
No functional change intended. Notes: svn path=/head/; revision=335395
2017-05-25Remove the MAX_CHECK macro, it was initially used to test if a file was aBaptiste Daroussin
text file or not. The check is not done by diff3 but by diff (the argument -a is directly passed to diff(1)) Notes: svn path=/head/; revision=318889
2017-05-25Import working progress BSD diff3Baptiste Daroussin
import bsd diff3 from OpenBSD. Differences with OpenBSD: - lots of warning fixed - no shell wrapper with diff3 actually living in libexec - capsicumized Keep it disconnected as it is not yet good enough to replace GNU diff The motivation to import it now it to allow other people to jump in and also to have an open development on it Obtained from: OpenBSD Notes: svn path=/head/; revision=318888