Minimal skills

Per Hedeland per at hedeland.org
Thu Jun 4 11:44:06 UTC 2020


On 2020-06-04 08:23, Polytropon wrote:
> On Wed, 3 Jun 2020 23:56:37 -0600, Brandon helsley wrote:
>
>> Could you tell me what this tool "diff" is.
>
> A diff (the tool, the process, and its result) means "difference".
> For example, if you find a manpage where the explanation for a
> certain option is missing, you take the original file, make a
> working copy of it, change that working copy, and create a file
> that contains the difference (i. e., the diff, also often
> called the patch) between the original and the updated version.
> This diff can then be sent to the FreeBSD team, and they will
> apply it; the next issue of FreeBSD will then contain the
> updated manpage instead of the original one.
>
> See "man diff" and "man patch" for details.
>
> Persons who have proven to be trusted contributors will get
> direct access to the source code repository: they can check in
> their changes by themselves.
>
> Here is a simplified outline of the process:
>
> 	# cd /usr/src/bin/ls
> 	# cp ls.1 ls.1.orig
> 	# vim ls.1
> 		... you make your changes ...
> 		:wq
> 	# diff ls.1 ls.1.orig > ls.1.diff

Sorry to pick on this one error in the huge amounts of useful info
that you provide, but this is *really* not the way to use diff, at
least not if you expect anyone else to use the result. First, it
produces a reverse diff, i.e. the changes needed to go from the new
version of the file to the old one, which is at least
annoying/confusing - and second, in combination with using the
(unfortunately default) "normal" format, it becomes pretty much
useless. These days, the proper way is

 	# diff -u ls.1.orig ls.1 > ls.1.diff

> Now ls.1.diff is what will be submitted. On the FreeBSD team's
> side, something like this happens:
>
> 	# cd /usr/src/bin/ls
> 	# patch < ls.1.diff

At best, with the diff produced by your command, this will make patch,
after asking and being told which file to patch, say

  Reversed (or previously applied) patch detected!  Assume -R? [y]

and actually work if you say 'y'. But there are several caveats for
both the reverse-detection and the application of the patch to work
when the "normal" format is used (see "man patch":-). Whereas with the
-u ("unified") format it works pretty much 100% (but you still
shouldn't produce a reverse diff, of course), and additionally the
name of the file to patch would be auto-detected.

--Per


More information about the freebsd-questions mailing list