git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Diff for unmerged files always misses the `\ No newline at end of file` mark

From
Danil Pristupov <danil@danil.cz>
Date
Jun 23, 2022, 15:39 UTC
Message-ID
<CAKdzDnn7KkRpXta1LiHcDPCztPcPRTFv8zTW_v+GpBAuSTW6yg@mail.gmail.com>

Some time ago I reported a bug there, but got no response. I hope it's OK if I post it again.

Diff for unmerged files always misses the `\ No newline at end of file` mark.
I was able to reproduce this with all git versions on all platforms.
Steps to reproduce (macOS, 2.32.0 (Apple Git-132)):

``` git init echo "line1\nline2" > eol.txt echo -n "line1\nline2" > noeol.txt git add . git commit -m "initial" git branch br1 echo "line11\nline2" > eol.txt echo -n "line11\nline2" > noeol.txt git add . git commit -m "line1" git checkout br1 echo "line12\nline2" > eol.txt echo -n "line12\nline2" > noeol.txt git add . git commit -m "line2" git merge master git diff -- eol.txt > eol.diff git diff -- noeol.txt > noeol.diff ```

Expected behavior: `noeol.diff` must have the `\\ No newline at end of file` mark (I guess double slash `\` must be used as a prefix)

``` $ git diff -- eol.txt diff --cc eol.txt index 3dc0c7e,5328e33..0000000

--- a/eol.txt
+++ b/eol.txt
@@@ -1,2 -1,2 +1,6 @@@
++<<<<<<< HEAD
 +line12
++=======
+ line11
++>>>>>>> master
  line2
\\ No newline at end of file
```

Actual behavior: `noeol.diff` does NOT have the `\\ No newline at end
of file` mark

```
$ git diff -- eol.txt
diff --cc eol.txt
index 3dc0c7e,5328e33..0000000
--- a/eol.txt
+++ b/eol.txt
@@@ -1,2 -1,2 +1,6 @@@
++<<<<<<< HEAD
 +line12
++=======
+ line11
++>>>>>>> master
  line2
```
Next: brian m. carlson
Message 1 of 2 in “Diff for unmerged files always misses the `\ No newline at end of file` mark”
  1. Danil PristupovJun 23, 2022
  2. brian m. carlsonJun 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.