git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: "Дилян Палаузов" <dilyan.palauzov@aegee.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: git diff shows twice “\ No newline at end of file” - no need for repetition
Date: Wed, 13 Aug 2025 14:11:55 +0100	[thread overview]
Message-ID: <626efd2e-0396-45a3-9a12-29bb8cbfc173@gmail.com> (raw)
In-Reply-To: <1b0d634286da16f32cd9faf541ee28c811d6c83f.camel@aegee.org>

On 13/08/2025 08:20, Дилян Палаузов wrote:
> Hello,
> 
> when a file, which does not end in a new line, is modified, git diff shows twice the text “\ No newline at end of file”. As this piece of the file is not modified, I think git diff should print it once.  In the example below the first “\ No newline at end of file” should be skipped.

The "\ No newline at end of file" applies to the line that precedes it. 
Removing the first instance in your example would mean the the newline 
at the end of the file had been removed when the line was changed. The 
output of git matches what GNU diff shows for incomplete lines.

Thanks

Phillip


> I am using git 2.50.0.
> 
> As a matter of fact github also shows this information twice - https://github.com/alex-shpak/hugo-book/pull/755/files - which I find is bad.
> 
> Greetings
>    Дилян
> 
> $ git diff
> diff --git a/layouts/_partials/docs/toc-show.html b/layouts/_partials/docs/toc-show.html
> index 21122a1..c243ae5 100644
> --- a/layouts/_partials/docs/toc-show.html
> +++ b/layouts/_partials/docs/toc-show.html
> @@ -2,4 +2,4 @@
>     and
>       (default .Site.Params.BookToC .Params.BookToC)
>       (not (eq .TableOfContents "<nav id=\"TableOfContents\"></nav>"))
> -) }}
> \ No newline at end of file
> +}}
> \ No newline at end of file
> 


  reply	other threads:[~2025-08-13 13:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  7:20 git diff shows twice “\ No newline at end of file” - no need for repetition Дилян Палаузов
2025-08-13 13:11 ` Phillip Wood [this message]
2025-08-13 14:51   ` Junio C Hamano
2025-08-13 14:42 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=626efd2e-0396-45a3-9a12-29bb8cbfc173@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=dilyan.palauzov@aegee.org \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).