Commit Graph

33 Commits

Author SHA1 Message Date
Tom Jones
190c4c2499 diff3: Use ranges for new and old diffedits in ed scripts
This should make the output logic easier to read. No functional change
intended.

Sponsored by:	Klara, Inc.
2022-08-02 14:38:11 +01:00
Tom Jones
c0e6ccb12a diff3: Use ranges for the old and new diffedits in A scripts
This makes the output logic easier to read. No functional change
intended.

Sponsored by:	Klara, Inc.
2022-08-02 14:37:05 +01:00
Tom Jones
264a559ac8 diff3: Simplify startmark calculation in Ascript
Remove redundant calculation for startmark.

Sponsored by:	Klara, Inc.
2022-08-02 14:36:05 +01:00
Tom Jones
2c4276aaa2 diff3: Use variables for old and new in A scripts
This makes the code easier to follow, no functional changes intended

Sponsored by:	Klara, Inc.
2022-08-01 14:54:20 +01:00
Tom Jones
ca53a8445a diff3: Replace literal marker with variable
Sponsored by:	Klara, Inc.
2022-08-01 14:53:53 +01:00
Tom Jones
85d92faf43 diff3: Fix indentation
Sponsored by:	Klara, Inc.
2022-08-01 14:14:25 +01:00
Tom Jones
d458eb8de1 diff3: make the eflag logic easier to follow
Discussed with:	dim
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D35324
2022-07-05 12:36:11 +01:00
Tom Jones
26b5deef22 diff3: Add man page description for version and help
Reviewed by:	Pau Amma
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D35325
2022-06-23 13:37:28 +01:00
Tom Jones
3ddd6eb688 diff3: Add help and version options
Add help and version flags. Exit values in these paths are set to match
the behaviour of gnu diff3.
2022-05-25 14:53:06 +01:00
Tom Jones
59f6408d8d diff3: Copy line into debug information
Sponsored by:	Klara Inc.
2022-05-25 14:45:51 +01:00
Tom Jones
7d975c7f93 diff3: Don't perform a bitwise OR when comparing diffs
This fixes the build now that it uses -Wbitwise-instead-of-logical

Sponsored by:	Klara Inc.
2022-05-25 14:43:14 +01:00
Tom Jones
c1c381eb7f diff3: Remove test case that references non existent test files
Sponsored by:	Klara, Inc.
2022-05-02 16:00:44 +01:00
Tom Jones
034dd2d54f diff3: Add support for -m
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-19 16:20:24 +01:00
Tom Jones
9ab079c5e8 diff3: Add support for -A
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-19 15:54:32 +01:00
Tom Jones
df092859b4 diff3: seperate old and new markers from file markers
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-19 15:40:07 +01:00
Tom Jones
2184ca3f19 diff3: Clean up printing of ranges for edscript output
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-19 14:51:18 +01:00
Tom Jones
7c03df6855 diff3: allow diff3 ed scripts to generate deletions
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
2022-04-15 15:00:59 +01:00
Piotr Pawel Stefaniak
9f7a81b133 diff3: document and test -T
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D31650
2021-08-25 18:20:59 +02:00
Piotr Pawel Stefaniak
54a3415cb6 diff3: implement --strip-trailing-cr
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D31626
2021-08-23 07:04:28 +02:00
Piotr Pawel Stefaniak
e8ff95356c diff3.1: update manual page to match code 2021-08-23 07:04:28 +02:00
Piotr Pawel Stefaniak
702dda4368 diff3: improve style 2021-08-23 07:04:28 +02:00
Piotr Pawel Stefaniak
7f7b03f389 diff3: sync with upstream
* replace realloc calls with reallocarray calls
 * fix merging of files that lack newlines

Obtained from:	OpenBSD
2021-08-23 07:04:28 +02:00
Baptiste Daroussin
94678ee678 Replace homemade getline(3) by actual getline(3) 2019-12-17 11:03:32 +00:00
Baptiste Daroussin
9520071f7e Use strtoimax.
Use existing strtoimax instead of reinventing it
2019-12-17 09:13:48 +00:00
Mariusz Zaborski
377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Mariusz Zaborski
7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +00:00
Bryan Drewery
3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Enji Cooper
d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper
4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +00:00
Baptiste Daroussin
9500abb088 Update the diff3 manpage to reflect the fact the version in freebsd does
not use temporary files nor uses a /usr/libexec/diff3prog
2017-05-25 18:46:13 +00:00
Baptiste Daroussin
cb5a670ece For now comment tests for arguments which are not in par with GNU diff3 yet 2017-05-25 17:58:01 +00:00
Baptiste Daroussin
433115a0a4 Remove the MAX_CHECK macro, it was initially used to test if a file was a
text file or not.

The check is not done by diff3 but by diff (the argument -a is directly passed
to diff(1))
2017-05-25 17:55:40 +00:00
Baptiste Daroussin
e1910ebda4 Import working progress BSD diff3
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
2017-05-25 17:45:50 +00:00