]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r351836, r351866, r354328: patch(1) /dev/null testing+improvement
authorKyle Evans <kevans@FreeBSD.org>
Tue, 3 Dec 2019 18:55:09 +0000 (18:55 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 3 Dec 2019 18:55:09 +0000 (18:55 +0000)
commitbe3a0c5043ce6f6dd57ad55276e9b67447be6867
tree26502a128ed6e59a03d612cf66588fe6530c078c
parent71f0711edec2d95229f1a0f63b60040c2195bfb2
MFC r351836, r351866, r354328: patch(1) /dev/null testing+improvement

r351836: patch(1): add some basic tests

Summary:
- basic: test application of patches created by diff -u at the
  beginning/middle/end of file, which have differing amounts of context
  before and after chunks being added
- limited_ctx: stems from PR 74127 in which a rogue line was getting added
  when the patch should have been rejected. Similar behavior was
  reproducible with larger contexts near the beginning/end of a file. See
  r326084 for details
- file_creation: patch sourced from /dev/null should create the file
- file_nodupe: said patch sourced from /dev/null shouldn't dupe the contents
  when re-applied (personal vendetta, WIP, see comment)
- file_removal: this follows from nodupe; the reverse of a patch sourced
  from /dev/null is most naturally deleting the file, as is expected based
  on GNU patch behavior (WIP)

r351866: patch(1): fix the file removal test, strengthen it a bit

To remain compatible with GNU patch, we should ensure that once we're
removing empty files after a reversed /dev/null patch we don't remove files
that have been modified. GNU patch leaves these intact and just reverses the
hunk that created the file, effectively implying --remove-empty-files for
reversed /dev/null patches.

r354328: patch(1): give /dev/null patches special treatment

We have a bad habit of duplicating contents of files that are sourced from
/dev/null and applied more than once... take the more sane (in most ways)
GNU route and complain if the file exists and offer reversal options.

This still falls short a little bit as selecting "don't reverse, apply
anyway" will still give you duplicated file contents. There's probably other
issues as well, but awareness is the first step to happiness.
13 files changed:
etc/mtree/BSD.tests.dist
usr.bin/patch/Makefile
usr.bin/patch/patch.1
usr.bin/patch/patch.c
usr.bin/patch/pch.c
usr.bin/patch/pch.h
usr.bin/patch/tests/Makefile [new file with mode: 0644]
usr.bin/patch/tests/PR74127-cline.diff [new file with mode: 0644]
usr.bin/patch/tests/PR74127-good.diff [new file with mode: 0644]
usr.bin/patch/tests/PR74127-repro.diff [new file with mode: 0644]
usr.bin/patch/tests/PR74127.in [new file with mode: 0644]
usr.bin/patch/tests/unified_patch_test.sh [new file with mode: 0755]
usr.bin/patch/util.c