The busybox version of the patch command is not handling patches correctly
which end with "\ No newline at end of file".
If the patch is from a file with a newline to one without, the patch
command "succeeds" but does not remove the newline.
If the patch is from a file without a newline to one with a newline, the
patch command fails with a "Hunk ... FAILED" error.

I'm using busybox v1.23.2, but I don't see any source code changes since
then that would affect this behavior.

Here is a log to show how I reproduced the issue.

# echo -n line > nonewline
/data # hexdump -Cv nonewline
00000000  6c 69 6e 65                                       |line|
00000004
# echo line > withnewline
# hexdump -Cv withnewline
00000000  6c 69 6e 65 0a                                    |line.|
00000005
# diff withnewline nonewline > rmnewline.patch
# cat rmnewline.patch
--- withnewline
+++ nonewline
@@ -1 +1 @@
-line
+line
\ No newline at end of file
# cp withnewline withnewline.tmp
# patch withnewline.tmp rmnewline.patch
patching file withnewline.tmp
# hexdump -Cv withnewline.tmp
00000000  6c 69 6e 65 0a                                    |line.|
00000005
/data # diff nonewline withnewline > addnewline.patch
/data # cat addnewline.patch
--- nonewline
+++ withnewline
@@ -1 +1 @@
-line
\ No newline at end of file
+line
/data # cp nonewline nonewline.tmp
/data # patch nonewline.tmp addnewline.patch
patching file nonewline.tmp
Hunk 1 FAILED 1/1.
-line
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to