Commit Graph

21 Commits

Author SHA1 Message Date
Tom Jones
8cf449db88 diff: add support for --help and --version
Add support for --help and --version to be compatible with gnu diff.

gnu diff --help writes to stdout, do the same to be compatible

Reviewed by:	bapt, pstef, debrup, Pau Amma
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D34508
2022-03-10 16:17:37 +00:00
Tom Jones
8f79bd9b85 diff: Detect Objective-C methods
When searching back for function definitions, consider lines starting
with '+' and '-', this allows us to pick up Objective-C methods as well
as C style function definitions.

Reviewed by:	bapt
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D34202
2022-02-18 15:09:57 +00:00
Piotr Pawel Stefaniak
e51aabf8cb diff: implement option -F (--show-function-line)
With unified and context diffs, show the last line that matches the
provided pattern before the context.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D31714
2021-09-16 01:46:44 +02:00
Cameron Katri
f38702e5a5 diff(1): Add --color support
Adds a --color flag to diff(1) that supports the same options as GNU's
diff(1). The colors are customizable with the env var DIFFCOLORS in
a format similar to grep(1)'s GREPCOLORS. An example would be 04;36:41
for additions to be underlined light blue, and deletions have a red
background.

Differential Revision:	https://reviews.freebsd.org/D30545
2021-09-16 01:46:44 +02:00
Fernando Apesteguía
204fa3b066 diff(1): Add EXAMPLES section
Add examples for -r, -u, -N, -x, -q and -I

Approved by:	0mp@
Differential Revision:	https://reviews.freebsd.org/D25345
2020-06-19 06:48:16 +00:00
Baptiste Daroussin
8ccef19395 Document long version of -b option
PR:		234195
Submitted by:	Fehmi Noyan Isi <fnoyanisi@yahoo.com>
Reported by:	Andras Farkas <deepbluemistake@gmail.com>
MFC after:	3 days
2020-06-01 09:15:15 +00:00
Kyle Evans
43fbd65451 diff: fix segfault with --tabsize and no/malformed argument
--tabsize was previously listed as optional_argument, but didn't account for
the optionality of it in the argument handling. This is irrelevant -- the
manpage doesn't indicate that the argument is optional, and indeed there's
no clear interpretation of omitting the argument because there's no other
side effect of --tabsize.

The "malformed" argument part of the header on this message is simply
referring to usage like this:

% diff --tabsize 4 A B

With an optional_argument, the argument must be attached to the parameter
directly (e.g. --tabsize=4), so the argument is effectively NULL with the
above invocation as if no argument had been passed.

PR:		243974
Submitted by:	fehmi noyan isi <fnoyanisi yahoo com> (diff.c portion)
MFC after:	3 days
2020-02-13 20:23:55 +00:00
Mateusz Piotrowski
469635f600 diff.1: Fix style & document -y as extension to POSIX
- Long options must be stylized with the Fl macro as well.

Reviewed by:	bapt
Approved by:	bcr (mentor)
Differential Revision:	https://reviews.freebsd.org/D23642
2020-02-12 20:06:41 +00:00
Baptiste Daroussin
79208b1025 Fix most of the style warnings 2020-02-07 12:26:38 +00:00
Baptiste Daroussin
64793e748c diff: implement -y (--side-by-side) along with -W and --suppress-common-lines
PR:		219933
Submitted by:	fehmi noyan isi <fnoyanisi@yahoo.com>
MFC after:	3 weeks
2020-02-07 10:17:13 +00:00
Kyle Evans
e68edb8cf0 diff(1): Implement -B/--ignore-blank-lines
As noted by cem in r338035, coccinelle invokes diff(1) with the -B flag.
This was not previously implemented here, so one was forced to create a link
for GNU diff to /usr/local/bin/diff

Implement the -B flag and add some primitive tests for it. It is implemented
in the same fashion that -I is implemented; each chunk's lines are scanned,
and if a non-blank line is encountered then the chunk will be output.
Otherwise, it's skipped.

MFC after:	2 weeks
2018-08-19 03:57:20 +00:00
Baptiste Daroussin
933870f0d1 Cross reference pr(1) which diff might call with -l option 2017-04-20 19:14:52 +00:00
Baptiste Daroussin
bcf91ad6d3 Document all long options 2017-04-20 19:05:43 +00:00
Baptiste Daroussin
fddcb7b82f Implement a basic --changed-group-format
etcupdate(8) requires that option, while GNU diff supports many more variation
of that options, their behaviour beside the simple verion implemented here are
quite inconsistent as such I do not plan to implement those.

The only special keyword supported by this implementation are: %< and %>
%= is not implemented as the documentation of GNU diff says: common lines, but
it actually when tested print the changes from the first file
2017-04-20 14:22:33 +00:00
Baptiste Daroussin
a077708d35 add a stub --speed-large-files for compatibility with GNU diff
There is no intention to implement it, but lots of scripts/tools using
diff(1) passes GNU diff option
2017-04-08 08:46:02 +00:00
Enji Cooper
7dacb9e765 diff(1): document remaining long options
While here, try and tie together some of the short options with
their long option equivalents, where possible.

Sponsored by:	Dell EMC Isilon
2017-03-23 04:35:52 +00:00
Enji Cooper
78b83a1ea1 diff(1): fix SYNOPSIS section noting non-existent option, --no-ignore-case
`--no-ignore-case` should be `--no-ignore-file-name-case` per code for
compatibility with [g]diff(1).

Sponsored by:	Dell EMC Isilon
2017-03-22 18:13:14 +00:00
Enji Cooper
9ba2762423 diff(1): add --strip-trailing-cr to last example in the SYNOPSIS
This syncs the last example in the SYNOPSIS with the other examples.

Reviewed by:	bapt
Sponsored by:	Dell EMC Isilon
Differential Revision:	D10017
2017-03-19 21:49:15 +00:00
Enji Cooper
b7ea08a976 diff(1): sort long options under -D example in SYNOPSYS
Sponsored by:	Dell EMC Isilon
2017-03-15 17:54:47 +00:00
Baptiste Daroussin
57f942af81 Fix wrong date in diff(1)
Reported by:	rgrimes
2017-03-12 03:36:33 +00:00
Baptiste Daroussin
3bbe3f672e Import diff from OpenBSD and remove GNU diff
Some of the modifications from the previous summer of code has been integrated
Modification for compatibility with GNU diff output has been added

Main difference with OpenBSD:
Implement multiple GNU diff options:
* --ignore-file-name-case
* --no-ignore-file-name-case
* --normal
* --tabsize
* --strip-trailing-cr
Make diff -p compatible with GNU diff
Implement diff -l
Make diff -r compatible with GNU diff

Capsicumize diffing 2 regular files
Add a simple test suite

Approved by:	AsiaBSDcon devsummit
Obtained from:	OpenBSD, GSoC
Relnotes:	yes
2017-03-11 05:01:29 +00:00