Re: missing handling of "No newline at end of file" in git am
- From
Jeff King <peff@peff.net>
- Date
- Feb 14, 2017, 20:47 UTC
- Message-ID
- <20170214204748.wqnsqkbig4ktw5wf@sigill.intra.peff.net>
- In-Reply-To
- <20170214201104.GA26407@aepfle.de>
On Tue, Feb 14, 2017 at 09:11:04PM +0100, Olaf Hering wrote:
> How is git send-email and git am supposed to handle a text file which > lacks a newline at the very end? This is about git 2.11.0.
That workflow should handle this case, and the resulting applied patch should not have a newline.
Show 5 quoted lines
> Right now the patch in an email generated with 'git send-email' ends > with '\ No newline at end of file', which 'git am' can not handle. To > me it looks like whatever variant of "diff" is used does the right thing > and indicates the lack of newline. Just the used variant of "patch" does > not deal with it.
I can't reproduce here:
# new repo with nothing in it (the base commit is to have something to # reset back to) git init git commit --allow-empty -m base
# our file with no trailing newline printf foo >file git add file git commit -m no-newline
# now make a patch email; it should have the "\ No newline" bit at the # end. git format-patch -1 cat 0001-no-newline.patch
# and now reset back and try to apply it git reset --hard HEAD^ git am 0001-no-newline.patch
# double check that it has no newline xxd <file
I'm using format-patch instead of send-email, but that is the underlying command that send-email is using. Is it possible that your patch is getting munged during email transit in a way that destroy the "No newline" message?
-Peff