{"thread":{"id":"63061","subject":"Failing to apply patch generated with BSD (MacOS) diff -- multiple No newline at end of file","startedAt":"2025-03-04T23:25:02Z","lastAt":"2025-03-04T23:25:02Z","messageCount":1,"participants":["Farid Zakaria"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"513582","messageId":"CACCo2jkKraSnGUeRqJSuis9EfiubxEbm1dT2WZk7gfk9xjQ1rg@mail.gmail.com","threadId":"63061","inReplyTo":null,"subject":"Failing to apply patch generated with BSD (MacOS) diff -- multiple No newline at end of file","fromName":"Farid Zakaria","fromEmail":"farid.m.zakaria@gmail.com","sentAt":"2025-03-04T23:24:50Z","receivedAt":"2025-03-04T23:25:02Z","isPatch":false,"sender":{"key":"farid.m.zakaria@gmail.com","avatar":"https://gravatar.com/avatar/13645be9e435a4ee3dd61831ce55d857aec3b1f26b0ec6bc700d170a9900d21c?d=mp&s=160"},"body":"I was diagnosing an issue in a separate Git implementation\n(https://github.com/bluekeyes/go-gitdiff/issues/57) and noticed a\nrelated bug with Git.\n\nBSD's diff seems to produce diffs where each hunk in the diff file may\ninclude '\\ No newline at end of file'\n(This is different than what the GNU diff generates)\n\nApplying the diff via git (git apply) removed multiple new lines from\neach corresponding hunk.\n\n** What did you do before the bug happened? (Steps to reproduce your issue) **\n\nI produced a diff with Apple BSD `diff` and it produced a diff with multiple\nhunks each with `\\ No newline at end of file` in it\n\nFor instance\n```\n@@ -161,12 +161,7 @@\n this is line 161\n this is line 162\n this is line 163\n-this is line 164\n-this is line 165\n-this is line 166\n-this is line 167\n-this is line 168\n-this is line 169\n+the number on the remaining lines is 5 ahead of their actual position\nin the file\n this is line 170\n this is line 171\n this is line 172\n\\ No newline at end of file\n@@ -197,4 +192,4 @@\n this is line 197\n this is line 198\n this is line 199\n-this is line 200\n+this is line 200\n\\ No newline at end of file\n```\n\n** What did you expect to happen? (Expected behavior) **\n\nWhen I `git apply` it seems to have removed the new line from each\npreceeding line in the hunk rather than at the end of the file.\n\nThis does not match what happens when I run `patch` program. It\ncorrectly seems to skip the multiple occurrences of \"No newline...\"\nand only strip the newline at the end of the file.\n\n** What happened instead? (Actual behavior) **\n\nMultiple new lines were stripped.\n\n[System Info]\ngit version:\ngit version 2.44.1\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /nix/store/4hnzq5yiv16j2k4rka60x3hnck9rrlxg-bash-5.2p32/bin/bash\nfeature: fsmonitor--daemon\nuname: Darwin 23.6.0 Darwin Kernel Version 23.6.0: Thu Dec 19 20:47:53\nPST 2024; root:xnu-10063.141.1.703.2~1/RELEASE_ARM64_T6030 arm64\ncompiler info: clang: 16.0.6\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n"}]}