git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: "Дилян Палаузов" <dilyan.palauzov@aegee.org>,
	"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 07:51:09 -0700	[thread overview]
Message-ID: <xmqqwm77nule.fsf@gitster.g> (raw)
In-Reply-To: <626efd2e-0396-45a3-9a12-29bb8cbfc173@gmail.com> (Phillip Wood's message of "Wed, 13 Aug 2025 14:11:55 +0100")

Phillip Wood <phillip.wood123@gmail.com> writes:

> 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

Thanks for a concise and accurate diagnosis.  It is unfortunate that
we cannot point at POSIX X-<.

  reply	other threads:[~2025-08-13 14:51 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
2025-08-13 14:51   ` Junio C Hamano [this message]
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=xmqqwm77nule.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dilyan.palauzov@aegee.org \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.com \
    /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).