Title: patch.py adds extra newline at EOF · Issue #50 · techtonik/python-patch · GitHub
Open Graph Title: patch.py adds extra newline at EOF · Issue #50 · techtonik/python-patch
X Title: patch.py adds extra newline at EOF · Issue #50 · techtonik/python-patch
Description: I have observed that patch.py adds an extra newline at the end of the patched file even though the unified patch doesn't alter the line at all. I know it is good behavior on Linux to have a newline at the end of the file. Some C/C++ codi...
Open Graph Description: I have observed that patch.py adds an extra newline at the end of the patched file even though the unified patch doesn't alter the line at all. I know it is good behavior on Linux to have a newline...
X Description: I have observed that patch.py adds an extra newline at the end of the patched file even though the unified patch doesn't alter the line at all. I know it is good behavior on Linux to have a new...
Opengraph URL: https://github.com/techtonik/python-patch/issues/50
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"patch.py adds extra newline at EOF","articleBody":"I have observed that patch.py adds an extra newline at the end of the patched file even though the unified patch doesn't alter the line at all.\r\n\r\nI know it is good behavior on Linux to have a newline at the end of the file. Some C/C++ coding standards make this even mandatory. But with PHP and some other web technologies, there are strong reasons to NOT have a newline at the end of the file, as it may result in undesired additional newline output to the client, possibly breaking everything.\r\n\r\nSmall example for illustration, including [LF] as newline ('\\n') and [EOF] as the end of the file.\r\n\r\noriginal file (old/test.php):\r\n```\r\n\u003c?php[LF]\r\n[LF]\r\necho \"\u003chtml\u003e\u003ctitle\u003easdf\u003c/title\u003e\u003cbody\u003easdf\u003c/body\u003e\u003c/html\u003e\";[LF]\r\n[LF]\r\n?\u003e[EOF]\r\n```\r\nwith patch file (without [LF] and [EOF], generated via `diff -Naur old/test.php new/test.php \u003e test.php.patch`):\r\n```\r\n--- old/test.php\t2017-03-29 11:19:36.103349100 +0200\r\n+++ new/test.php\t2017-03-29 11:20:16.270349100 +0200\r\n@@ -1,5 +1,5 @@\r\n \u003c?php\r\n \r\n-echo \"\u003chtml\u003e\u003ctitle\u003easdf\u003c/title\u003e\u003cbody\u003easdf\u003c/body\u003e\u003c/html\u003e\";\r\n+echo \"\u003chtml\u003e\u003ctitle\u003eA real title\u003c/title\u003e\u003cbody\u003eA real body\u003c/body\u003e\u003c/html\u003e\";\r\n \r\n ?\u003e\r\n\\ No newline at end of file\r\n\r\n```\r\nbecomes:\r\n```\r\n\u003c?php[LF]\r\n[LF]\r\necho \"\u003chtml\u003e\u003ctitle\u003eA real title\u003c/title\u003e\u003cbody\u003eA real body\u003c/body\u003e\u003c/html\u003e\";[LF]\r\n[LF]\r\n?\u003e[LF][EOF]\r\n```\r\n\r\nbut should be (new/test.php):\r\n```\r\n\u003c?php[LF]\r\n[LF]\r\necho \"\u003chtml\u003e\u003ctitle\u003eA real title\u003c/title\u003e\u003cbody\u003eA real body\u003c/body\u003e\u003c/html\u003e\";[LF]\r\n[LF]\r\n?\u003e[EOF]\r\n```\r\n","author":{"url":"https://github.com/nils-ballmann","@type":"Person","name":"nils-ballmann"},"datePublished":"2017-03-29T09:55:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/50/python-patch/issues/50"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3b4c9946-4983-8869-6a02-b2cbe1503bd1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8904:1D772C:471586:608B8A:696AAA24 |
| html-safe-nonce | 5daccc99dd73d6c25f64e054805d09694ee0efa7238e879fbfcae7ebbcffce1b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTA0OjFENzcyQzo0NzE1ODY6NjA4QjhBOjY5NkFBQTI0IiwidmlzaXRvcl9pZCI6IjM3NDc1MzYxODIxNzQxOTgzMDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 61cf7ded9f87d5c1b6c2e9d5c7566db9098729823fdf96b177c2cc8db879801b |
| hovercard-subject-tag | issue:217823632 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/techtonik/python-patch/50/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c33c9a1e1c3bf40270e4635490ae983b49ca4f37cfff631d9d939fa426f0c850/techtonik/python-patch/issues/50 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c33c9a1e1c3bf40270e4635490ae983b49ca4f37cfff631d9d939fa426f0c850/techtonik/python-patch/issues/50 |
| og:image:alt | I have observed that patch.py adds an extra newline at the end of the patched file even though the unified patch doesn't alter the line at all. I know it is good behavior on Linux to have a newline... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nils-ballmann |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3eaf9b8cf1badcd7041a8ad480b9d9b28bea0ef1cc821ca9ff20f2cc7f4fe4b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/techtonik/python-patch git https://github.com/techtonik/python-patch.git |
| octolytics-dimension-user_id | 515889 |
| octolytics-dimension-user_login | techtonik |
| octolytics-dimension-repository_id | 34159484 |
| octolytics-dimension-repository_nwo | techtonik/python-patch |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 34159484 |
| octolytics-dimension-repository_network_root_nwo | techtonik/python-patch |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd9a979046e6382bd084e2bd873bf65f797125ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width