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

Re: [PATCH for-maint] apply: gitdiff_verify_name(): accept "/dev/null\r"

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 23, 2014, 20:35 UTC
Message-ID
<xmqqfvfihy7i.fsf@gitster.dls.corp.google.com>
In-Reply-To
<5421D8C4.2080009@redhat.com>
Laszlo Ersek <lersek@redhat.com> writes:
Show 36 quoted lines
> On 09/23/14 22:02, Junio C Hamano wrote:
>> Laszlo Ersek <lersek@redhat.com> writes:
>> 
>>> On 09/23/14 20:54, Junio C Hamano wrote:
>>> ...
>>>> SMTP transport may be CRLF-unsafe, so I have a suspicion that it may
>>>> turn out that what you are trying to do might be an equilvalent of
>>>>
>>>> 	git format-patch ... |
>>>>         # first lose all \r\n
>>>>         dos2unix | 
>>>> 	# then make everything \r\n
>>>>         unix2dos |
>>>>         # and apply
>>>>         git am
>>>>
>>>> which is not workable in the first place.  I dunno.
>>>
>>> I agree with your analysis. It is indeed the MTA...
>>>>    - CR and LF MUST only occur together as CRLF; they MUST NOT appear
>>>>      independently in the body.
>>>
>>> But why is this situation "not workable"? The same happens with *all*
>>> patches that people mail around, it's just not visible to them, because
>>> git-am strips all CRs indiscriminately.
>> 
>> It is not "git am" or "git apply" that "strips all CRs
>> indiscriminately".  I just tried to apply 0001-add-f2 without
>> letting your MTA/MUA corrupt it on "master" branch in the repository
>> you prepared that patch from, i.e.
>> 
>> 	git checkout master^0 ;# go back
>>         git am 0001-add-f2* ;# apply that "+hello world\r\n" patch
>>         git diff branch ;# nothing
>
> When you did this, was am.keepcr=true in effect?

I actually briefly scratched my head but realized when I saw it work "as expected" without me passing "--keep-cr" to "am" myself.

But I did that experiment in the repository created by following your reproduction recipe, in which it had these:

  git config core.whitespace cr-at-eol
  git config am.keepcr true
so yes I had keepcr set.
Previous: Laszlo ErsekNext: Laszlo Ersek
Message 10 of 15 in “apply: gitdiff_verify_name(): accept "/dev/null\r"”
  1. apply: gitdiff_verify_name(): accept "/dev/null\r"Laszlo Ersek, Sep 23, 2014
  2. Junio C HamanoSep 23, 2014
  3. Laszlo ErsekSep 23, 2014
  4. Junio C HamanoSep 23, 2014
  5. Laszlo ErsekSep 23, 2014
  6. Junio C HamanoSep 23, 2014
  7. Laszlo ErsekSep 23, 2014
  8. Junio C HamanoSep 23, 2014
  9. Laszlo ErsekSep 23, 2014
  10. Junio C HamanoSep 23, 2014
  11. Laszlo ErsekSep 23, 2014
  12. Junio C HamanoSep 23, 2014
  13. Laszlo ErsekSep 24, 2014
  14. Junio C HamanoSep 24, 2014
  15. Junio C HamanoSep 23, 2014

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.