{"thread":{"id":"58059","subject":"Diff for unmerged files always misses the `\\ No newline at end of file` mark","startedAt":"2022-06-23T15:39:21Z","lastAt":"2022-06-25T11:49:50Z","messageCount":2,"participants":["Danil Pristupov","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"457795","messageId":"CAKdzDnn7KkRpXta1LiHcDPCztPcPRTFv8zTW_v+GpBAuSTW6yg@mail.gmail.com","threadId":"58059","inReplyTo":null,"subject":"Diff for unmerged files always misses the `\\ No newline at end of file` mark","fromName":"Danil Pristupov","fromEmail":"danil@danil.cz","sentAt":"2022-06-23T15:39:07Z","receivedAt":"2022-06-23T15:39:21Z","isPatch":false,"sender":{"key":"danil@danil.cz","avatar":"https://gravatar.com/avatar/0c17c2eda2eaabbcc09a02149bedaff23bc8894c7be16e6b25d6602abfc34243?d=mp&s=160"},"body":"Some time ago I reported a bug there, but got no response. I hope it's\nOK if I post it again.\n\nDiff for unmerged files always misses the `\\ No newline at end of file` mark.\n\nI was able to reproduce this with all git versions on all platforms.\n\nSteps to reproduce (macOS, 2.32.0 (Apple Git-132)):\n\n```\ngit init\necho \"line1\\nline2\" > eol.txt\necho -n \"line1\\nline2\" > noeol.txt\ngit add .\ngit commit -m \"initial\"\ngit branch br1\necho \"line11\\nline2\" > eol.txt\necho -n \"line11\\nline2\" > noeol.txt\ngit add .\ngit commit -m \"line1\"\ngit checkout br1\necho \"line12\\nline2\" > eol.txt\necho -n \"line12\\nline2\" > noeol.txt\ngit add .\ngit commit -m \"line2\"\ngit merge master\ngit diff -- eol.txt > eol.diff\ngit diff -- noeol.txt > noeol.diff\n```\n\nExpected behavior: `noeol.diff` must have the `\\\\ No newline at end of\nfile` mark (I guess double slash `\\` must be used as a prefix)\n\n```\n$ git diff -- eol.txt\ndiff --cc eol.txt\nindex 3dc0c7e,5328e33..0000000\n--- a/eol.txt\n+++ b/eol.txt\n@@@ -1,2 -1,2 +1,6 @@@\n++<<<<<<< HEAD\n +line12\n++=======\n+ line11\n++>>>>>>> master\n  line2\n\\\\ No newline at end of file\n```\n\nActual behavior: `noeol.diff` does NOT have the `\\\\ No newline at end\nof file` mark\n\n```\n$ git diff -- eol.txt\ndiff --cc eol.txt\nindex 3dc0c7e,5328e33..0000000\n--- a/eol.txt\n+++ b/eol.txt\n@@@ -1,2 -1,2 +1,6 @@@\n++<<<<<<< HEAD\n +line12\n++=======\n+ line11\n++>>>>>>> master\n  line2\n```\n"},{"id":"457867","messageId":"Yrb2Wv92eLmXY6NV@tapette.crustytoothpaste.net","threadId":"58059","inReplyTo":"CAKdzDnn7KkRpXta1LiHcDPCztPcPRTFv8zTW_v+GpBAuSTW6yg@mail.gmail.com","subject":"Re: Diff for unmerged files always misses the `\\ No newline at end of file` mark","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-06-25T11:49:46Z","receivedAt":"2022-06-25T11:49:50Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-06-23 at 15:39:07, Danil Pristupov wrote:\n> Some time ago I reported a bug there, but got no response. I hope it's\n> OK if I post it again.\n> \n> Diff for unmerged files always misses the `\\ No newline at end of file` mark.\n> \n> I was able to reproduce this with all git versions on all platforms.\n> \n> Steps to reproduce (macOS, 2.32.0 (Apple Git-132)):\n> \n> ```\n> git init\n> echo \"line1\\nline2\" > eol.txt\n> echo -n \"line1\\nline2\" > noeol.txt\n> git add .\n> git commit -m \"initial\"\n> git branch br1\n> echo \"line11\\nline2\" > eol.txt\n> echo -n \"line11\\nline2\" > noeol.txt\n> git add .\n> git commit -m \"line1\"\n> git checkout br1\n> echo \"line12\\nline2\" > eol.txt\n> echo -n \"line12\\nline2\" > noeol.txt\n> git add .\n> git commit -m \"line2\"\n> git merge master\n> git diff -- eol.txt > eol.diff\n> git diff -- noeol.txt > noeol.diff\n> ```\n\nThanks for the report.  I think this is indeed a bug, but maybe someone\nmore familiar with things than I am can confirm.\n\nFrom a preliminary examination, it looks like the --cc and regular modes\nrender diffs completely differently, and code similar to what's at the\nend of emit_rewrite_lines belongs at the end of dump_sline as well.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"}]}